/Donate Command -InGame Text Help-

Discussion in 'Plugin Development' started by Addison Taylor, Feb 26, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Addison Taylor

    Code:
    //The Package
    package com.bukkit.shawn.Basic;
    import org.bukkit.event.Event;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.plugin.PluginManager;
    /**
    * Basic for Bukkit
    *
    * @author Saturisk Ft. Erozionn
    */
    //Starts the class
    public class Basic extends JavaPlugin{
        //Links the BasicPlayerListener
        private final BasicPlayerListener playerListener = new BasicPlayerListener();
        @Override
        //When the plugin is disabled this method is called.
        public void onDisable() {
        }
        @Override
        //When the plugin is enabled this method is called.
        public void onEnable() {
            //Create the pluginmanage pm.
            PluginManager pm = getServer().getPluginManager();
            //Create PlayerCommand listener
            pm.registerEvent(Event.Type.PLAYER_COMMAND, this.playerListener, Event.Priority.Normal, this);
            pm.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Event.Priority.Normal, this);
          //Get the infomation from the yml file.
            PluginDescriptionFile pdfFile = this.getDescription();
            //Print that the plugin has been enabled!
            System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
        }
    }
    //The Package
    package com.bukkit.shawn.Basic;
    //All the imports
    import org.bukkit.entity.Player;
    import org.bukkit.event.player.PlayerChatEvent;
    import org.bukkit.event.player.PlayerListener;
    import org.bukkit.event.player.PlayerLoginEvent;
    import org.bukkit.ChatColor;
    //Starts the class BasicPlayer listener
    public class BasicPlayerListener extends PlayerListener{
    
          //This method is called whenever a player uses a command.
              public void onPlayerJoin(PlayerLoginEvent event) {
    
                  Player player = event.getPlayer();
    
                  player.sendMessage(ChatColor.GREEN + "Welcome To EnvizeCraft " + player.getName() + ", Please Type '/Donate' For The Donating Guidelines On This Server, /Help For More Help and /Commands For Your Access's.");
    
              }
    
            public void onPlayerCommand(PlayerChatEvent event) {
              //Make the message a string.
                String[] split = event.getMessage().split(" ");
                //Get the player that talked.
                Player player = event.getPlayer();
                //If the first part of the string is /basic or /b then do this.
                if (split[0].equalsIgnoreCase("/donate")) {
                    player.sendMessage(ChatColor.GREEN + "[1] Donater Status? What Do You Gain?");
                    player.sendMessage(ChatColor.GREEN + "[2] Any Coloured Name & One Chest Of Any Items. (Stack)");
                    player.sendMessage(ChatColor.GREEN + "[3] To Donate You Can Pay Via Paypal Of A One Of Charge");
                    player.sendMessage(ChatColor.GREEN + "[4] Of £3, This Will Go To Hosting The Server.");
                    player.sendMessage(ChatColor.GREEN + "[5] For More Details Contact: Erozionn. Thanks'");
    
                }
    
                if (split[0].equalsIgnoreCase("/commands")) {
    
                    player.sendMessage(ChatColor.GREEN + "Coming Soon Once Everything Is Complete.");
                    player.sendMessage(ChatColor.GREEN + "Stay Tuned!.");
    
                }
    
          }
    I got the basic code from the /Rules plugin and carried on adding to create this, But i think theres a fault i cant get this to work within game. Please help me
    Thanks,
    Addy.
     
  2. Offline

    yottabyte

Thread Status:
Not open for further replies.

Share This Page