"Trying" to finish my new plugin.

Discussion in 'Plugin Development' started by ImARedSoxFan, May 12, 2012.

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

    ImARedSoxFan

    Hi im trying to develop a plugin called "xWarpSigns"
    The main point of this plugin is to take place of essentials warp signs for the people (like me)
    that have trouble with essentials warps. So i have 3 Commands im trying to put into the plugin
    /xWarpset (name) , /xWarpremove (name) , /xWarp (warp name). But the main thing im trying to accomplish with this plugin is to be able to warp with a sign.
    Line 1 - [xWarp]
    Line 2 - (Warp Name)
    Line 3 -
    Line 4 -


    I have yet to figure out how to do most of this. this is what i have so far.
    package me.ImARedSoxFan.xWarpSigns;

    import java.awt.Event;
    import java.util.ArrayList;
    import java.util.logging.Logger;

    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.event.EventPriority;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    import ru.tehkode.permissions.PermissionManager;
    import ru.tehkode.permissions.PermissionUser;
    import ru.tehkode.permissions.bukkit.PermissionsEx;

    public class xWarpSigns extends JavaPlugin
    {
    private static final Logger log = Logger.getLogger("Minecraft");
    private final xWarpSignsListener blocklistener = new xWarpSignsListener(this);
    public final ArrayList<Player> xWarpSignsUsers = new ArrayList<Player>();



    @Override
    public void onEnable();
    {
    log.info("[xWarpSigns] has been enabled!");
    PermissionManager pex = PermissionsEx.getPermissionManager();
    PermissionUser user = PermissionsEx.getUser(player)
    pex.registerEvent(Event.Type.PLAYER_INTERACT, xWarpSignsListener, EventPriority.NORMAL, this);
    if (Event.getAction() == Action.RIGHT_CLICK_SIGN);
    setupPermissions();

    }



    @Override
    public void onDisable()
    {
    log.info("[xWarpSigns] has been disabled!");
    }

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
    {
    if(commandLabel.equalsIgnoreCase("xWarpSigns"))
    togglexWarpSigns(sender);

    return true;


    }

    private void togglexWarpSigns(CommandSender sender)
    {
    if( !enabled((player) sender) )
    {
    xWarpSignsUsers.add((Player) sender);
    ((Player) sender).sendMessage(ChatColor.BLUE + "xWarpSigns has been enabled!");
    }
    else
    {
    xWarpSignsUsers.remove((Player) sender);
    ((Player) sender).sendMessage(ChatColor.RED + "xWarpSigns has been disabled!");
    }

    }

    public boolean enabled(Player player);
    {
    return xWarpSignsUsers.contains(player);
    }

    void setupPermissions

    }
    And the Listener -
    package me.ImARedSoxFan.xWarpSigns;

    public class xWarpSignsListener extends xWarpSigns
    {

    public static xWarpSigns plugin;

    public xWarpSignsListener(xWarpSigns instance)
    {
    plugin = instance;
    }

    public void onBlockDamage(BlockDamageEvent event);
    {
    if(plugin.enabled(Event.getPlayer()));
    }
    }
     
  2. Offline

    Craftiii4

    You will need to have a block listener that catches the
    Code:java
    1. public void onSignChange(SignChangeEvent event)


    Then check on line 0 (first line) for "[ xWarp ]
    Code:java
    1. if (event.getLine(0).equalsIgnoreCase("[xWarp]")

    Then here, you will want to set to xWarp in case the used lower-case.

    Then catch onto the player interact. And if its 'RIGHT_CLICK_BLOCK' a sign, which has 0 then run the warps etc...... sure you can figure the rest out? ^^
     
  3. Offline

    ImARedSoxFan

    Thank you, But i still dont understand where i place that coding.
    I also dont understand how i implement a listener to save the location when someone does
    /xwarpset or when someone wants to teleport to that saved location.
     
  4. Offline

    Craftiii4

    Save it to an config file?

    Your code is kinda hard to understand? try correct formatting and putting it all into listeners?

    for the formatting use {syntax=java} just use [] instead of {}, same goes for {/syntax}
     
  5. Offline

    ImARedSoxFan

    This may sound dumb, but how do you save to a config file?
     
  6. Offline

    Craftiii4

    This here is a test one I made,

    Code:java
    1. @Override
    2. public void onDisable() {
    3.  
    4. System.out.println("[TestTest04] TestTest04 v"
    5. + getDescription().getVersion() + " disabled!");
    6.  
    7.  
    8. saveConfig();
    9.  
    10. }
    11.  
    12. @Override
    13. public void onEnable() {
    14.  
    15. loadConfiguration();
    16.  
    17. System.out.println("[TestTest04] TestTest04 v"
    18. + getDescription().getVersion() + " Enabled!");
    19.  
    20. }
    21.  
    22.  
    23. public void loadConfiguration() {
    24.  
    25. //inset anything you wish to load in here
    26.  
    27. String string = "Test.1";
    28. getConfig().addDefault(string, "This is a String");
    29. String intl = "Test.2";
    30. getConfig().addDefault(intl, 6);
    31. String doublel = "Test.3";
    32. getConfig().addDefault(doublel, 14.6568);
    33.  
    34. getConfig().options().copyDefaults(true);
    35. saveConfig();
    36.  
    37. }


    You will need to have a config.yml in the same place as your plugin.yml
     
  7. Offline

    ImARedSoxFan

    Where do i insert this?

    Code:
    package me.ImARedSoxFan.xWarpSigns;
     
    import java.awt.Event;
    import java.util.ArrayList;
    import java.util.logging.Logger;
     
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.event.EventPriority;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
    import ru.tehkode.permissions.PermissionManager;
    import ru.tehkode.permissions.PermissionUser;
    import ru.tehkode.permissions.bukkit.PermissionsEx;
     
    public class xWarpSigns extends JavaPlugin       
    {   
        private static final Logger log = Logger.getLogger("Minecraft");
        private final xWarpSignsListener blocklistener = new xWarpSignsListener(this);
        public final ArrayList<Player> xWarpSignsUsers = new ArrayList<Player>();
       
       
       
        @Override
        public void onEnable();
        {
            log.info("[xWarpSigns] has been enabled!");
            PermissionManager pex = PermissionsEx.getPermissionManager();
            PermissionUser user  = PermissionsEx.getUser(player)
            pex.registerEvent(Event.Type.PLAYER_INTERACT, xWarpSignsListener, EventPriority.NORMAL, this);
            if (Event.getAction() == Action.RIGHT_CLICK_SIGN);
            setupPermissions();
       
        }
       
     
       
        @Override
        public void onDisable()
        {
            log.info("[xWarpSigns] has been disabled!");
        }
       
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
        {
            if(commandLabel.equalsIgnoreCase("xWarpSigns"))
                togglexWarpSigns(sender);
           
            return true;
           
           
        }
       
        private void togglexWarpSigns(CommandSender sender)
        {
            if( !enabled((player) sender) )
            {
                xWarpSignsUsers.add((Player) sender);
                ((Player) sender).sendMessage(ChatColor.BLUE + "xWarpSigns has been enabled!");
            }
            else
            {
                xWarpSignsUsers.remove((Player) sender);   
                ((Player) sender).sendMessage(ChatColor.RED + "xWarpSigns has been disabled!");
            }
           
        }
       
        public boolean enabled(Player player);
        {
            return xWarpSignsUsers.contains(player);
        }
       
        void setupPermissions
       
    }
    im not even sure i coded this right. If you see any issues tell me
     
  8. Offline

    ImARedSoxFan

    Hey do you think you could help me code this plugin?
     
  9. Offline

    Craftiii4

    I have provided you with the code you need to get the config working, all you need to do is look at the code, and see what has been done/added.
     
Thread Status:
Not open for further replies.

Share This Page