No Matter What This Code Will Not Work?

Discussion in 'Plugin Development' started by hurleyboarder, Feb 11, 2014.

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

    hurleyboarder

    Hi, Ive been trying to make a warp plugin, its just my home plugin with the commands changed to /setwarp and /warp.
    Code:
    package me.hurleyboarder;
     
    import java.io.File;
    import java.io.IOException;
     
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.configuration.file.YamlConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class First extends JavaPlugin  {
        File warps;
        FileConfiguration newConfigz;
       
        @Override
        public void onEnable() {
            warps = new File(getDataFolder(), "warps.yml");
            newConfigz = YamlConfiguration.loadConfiguration(warps);
            saveConfig();
        }
        @Override
        public void onDisable() {
            saveConfig();
            try{
                newConfigz.save(warps);
               
                }catch(Exception e){
                e.printStackTrace();
                }
        }
       
       
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
       
            if (cmd.getName().equalsIgnoreCase("setwarp") && sender instanceof Player) {
                Player player1 = (Player) sender;
                if(args.length == 0){
                    player1.sendMessage(ChatColor.RED + "/setwarp [name]");
                }else if(args.length == 1){
               
                newConfigz.set(player1.getName() + ".x", player1.getLocation().getBlockX());
                newConfigz.set(player1.getName() + ".y", player1.getLocation().getBlockY());
                newConfigz.set(player1.getName() + ".z", player1.getLocation().getBlockZ());
                    player1.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Your Home Has Been Set, Do /home To Teleport To!");
                    try {
                        newConfigz.save(warps);
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                } else if(cmd.getName().equalsIgnoreCase("warp") && sender instanceof Player){
                    Player player11 = (Player) sender;
                    
                    int x = newConfigz.getInt(player11.getName() + ".x"), y = newConfigz.getInt(player11.getName() + ".y"), z =newConfigz.getInt(player11.getName() + ".z");
                    player11.teleport(new Location(player11.getWorld(), x, y, z));
                    player11.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Teleported To Home!");
               
                   
           
        return true;       
           
                }}
            return false;}}
       
       
     
     
    
    It doesn't tell me unknown command or does eclipse nor the server says there is any error, it simply just does nothing. I have also tried it in my other plugins and just added it in and the same thing happens.
     
  2. Offline

    Mmarz11

  3. Offline

    hurleyboarder

    name: First
    main: me.hurleyboarder.First
    version: 1.0
    commands:
    setwarp:
    descrition: Blank description.
    usage: /<command>
    warp:
    descrition: Blank description.
    usage: /<command>
     
  4. Offline

    97WaterPolo

    hurleyboarder
    Is it even loading on startup? Console shows something at least when you run the command. Are you getting unknown command? Is nothing literally happening? When this happens to me either I don't register the command, or there is an error on start up.
     
  5. Offline

    _Filip

    I'm not sure, but try adding the annotation @Override above the onCommand method, this will prevent conflicts with other plugins, but I doubt that's the reason.
     
  6. Offline

    hurleyboarder

    The plugin does start but when I type the command literally nothing happens no message nothing, and if I put it in one of my other plugins it still does nothing.
     
  7. Offline

    Mmarz11

    hurleyboarder When I tried your code for the most part it worked. The main issue was that the warp command check was inside the braces of the setwarp command if statement meaning it could never be called. I also added in a return true in the first braces. I would recommend changing the getLocation().getBlockX() to getLocation().getX() so it is using doubles instead of ints and to change the getInt(...) to getDouble(...) to make the teleports more accurate.

    Show Spoiler
    Code:java
    1. package me.hurleyboarder;
    2.  
    3. import java.io.File;
    4. import java.io.IOException;
    5.  
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Location;
    8. import org.bukkit.command.Command;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.configuration.file.FileConfiguration;
    11. import org.bukkit.configuration.file.YamlConfiguration;
    12. import org.bukkit.entity.Player;
    13. import org.bukkit.plugin.java.JavaPlugin;
    14.  
    15. public class First extends JavaPlugin {
    16. File warps;
    17. FileConfiguration newConfigz;
    18.  
    19. @Override
    20. public void onEnable() {
    21. warps = new File(getDataFolder(), "warps.yml");
    22. newConfigz = YamlConfiguration.loadConfiguration(warps);
    23. saveConfig();
    24. }
    25.  
    26. @Override
    27. public void onDisable() {
    28. saveConfig();
    29. try {
    30. newConfigz.save(warps);
    31.  
    32. } catch (Exception e) {
    33. e.printStackTrace();
    34. }
    35. }
    36.  
    37. public boolean onCommand(CommandSender sender, Command cmd, String label,
    38. String[] args) {
    39.  
    40. if (cmd.getName().equalsIgnoreCase("setwarp")
    41. && sender instanceof Player) {
    42. Player player1 = (Player) sender;
    43. if (args.length == 0) {
    44. player1.sendMessage(ChatColor.RED + "/setwarp [name]");
    45. } else if (args.length == 1) {
    46.  
    47. newConfigz.set(player1.getName() + ".x", player1.getLocation()
    48. .getBlockX());
    49. newConfigz.set(player1.getName() + ".y", player1.getLocation()
    50. .getBlockY());
    51. newConfigz.set(player1.getName() + ".z", player1.getLocation()
    52. .getBlockZ());
    53. player1.sendMessage(ChatColor.AQUA + "["
    54. + getConfig().getString("Messenger") + "] "
    55. + ChatColor.GREEN
    56. + "Your Home Has Been Set, Do /home To Teleport To!");
    57. try {
    58. newConfigz.save(warps);
    59. } catch (IOException e) {
    60. // TODO Auto-generated catch block
    61. e.printStackTrace();
    62. }
    63. }
    64. return true;
    65. } else if (cmd.getName().equalsIgnoreCase("warp")
    66. && sender instanceof Player) {
    67. Player player11 = (Player) sender;
    68.  
    69. int x = newConfigz.getInt(player11.getName() + ".x"), y = newConfigz
    70. .getInt(player11.getName() + ".y"), z = newConfigz
    71. .getInt(player11.getName() + ".z");
    72. player11.teleport(new Location(player11.getWorld(), x, y, z));
    73. player11.sendMessage(ChatColor.AQUA + "["
    74. + getConfig().getString("Messenger") + "] "
    75. + ChatColor.GREEN + "Teleported To Home!");
    76.  
    77. return true;
    78.  
    79. }
    80. return false;
    81. }
    82. }
     
  8. Offline

    97WaterPolo

    hurleyboarder
    Code:java
    1. package me.hurleyboarder;
    2. import java.io.File;
    3. import java.io.IOException;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Location;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.configuration.file.FileConfiguration;
    9. import org.bukkit.configuration.file.YamlConfiguration;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12.  
    13. public class First extends JavaPlugin {
    14. File warps;
    15. FileConfiguration newConfigz;
    16. @Override
    17. public void onEnable()
    18. {
    19. warps = new File(getDataFolder(), "warps.yml");
    20. newConfigz = YamlConfiguration.loadConfiguration(warps);
    21. saveConfig();
    22. }
    23. @Override
    24. public void onDisable()
    25. {
    26. saveConfig();
    27. try{
    28. newConfigz.save(warps);
    29. }catch(Exception e){
    30. e.printStackTrace();
    31. }
    32. }
    33. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    34. if (cmd.getName().equalsIgnoreCase("setwarp") && sender instanceof Player)
    35. {
    36. Player player1 = (Player) sender;
    37. if(args.length == 0)
    38. {
    39. player1.sendMessage(ChatColor.RED + "/setwarp [name]");
    40. }
    41. if (!(args.length == 0))
    42. {
    43. if(args.length == 1)
    44. {
    45. newConfigz.set(player1.getName() + ".x", player1.getLocation().getBlockX());
    46. newConfigz.set(player1.getName() + ".y", player1.getLocation().getBlockY());
    47. newConfigz.set(player1.getName() + ".z", player1.getLocation().getBlockZ());
    48. player1.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Your Home Has Been Set, Do /home To Teleport To!");
    49. try
    50. {
    51. newConfigz.save(warps);
    52. } catch (IOException e)
    53. {
    54. // TODO Auto-generated catch block
    55. e.printStackTrace();
    56. }
    57. }
    58.  
    59. }
    60. }
    61.  
    62. if(cmd.getName().equalsIgnoreCase("warp") && sender instanceof Player)
    63. {
    64. Player player11 = (Player) sender;
    65. int x = newConfigz.getInt(player11.getName() + ".x"), y = newConfigz.getInt(player11.getName() + ".y"), z =newConfigz.getInt(player11.getName() + ".z");
    66. player11.teleport(new Location(player11.getWorld(), x, y, z));
    67. player11.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Teleported To Home!");
    68. return true;
    69. }
    70. return false;}}
    71.  

    Okay, my eyes were hurting a little, so I placed it in my IDE and worked out some brackets for me to see.You don't have to use this this is more of me seeing how I would do this. So to start off, upon my first look I usually check if the argument does NOT equal 0 as I made that mistake in the past. I also changed them to if statements.

    1. Next think I notice, is that you are saving the location, but you aren't saving the [name] part of the /setwarp. If you use the /warp command, it needs the variable

    2. This is the opposite of 1. as maybe you only want players to set one home so you don't need the args for the name. If thats the case then you added a little to much, and this is what I think the code should be.

    Code:java
    1. package me.hurleyboarder;
    2.  
    3. import java.io.File;
    4. import java.io.IOException;
    5.  
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Location;
    8. import org.bukkit.command.Command;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.configuration.file.FileConfiguration;
    11. import org.bukkit.configuration.file.YamlConfiguration;
    12. import org.bukkit.entity.Player;
    13. import org.bukkit.plugin.java.JavaPlugin;
    14.  
    15. public class First extends JavaPlugin {
    16. File warps;
    17. FileConfiguration newConfigz;
    18.  
    19. @Override
    20. public void onEnable()
    21. {
    22. warps = new File(getDataFolder(), "warps.yml");
    23. newConfigz = YamlConfiguration.loadConfiguration(warps);
    24. saveConfig();
    25. }
    26. @Override
    27. public void onDisable()
    28. {
    29. saveConfig();
    30. try{
    31. newConfigz.save(warps);
    32.  
    33. }catch(Exception e){
    34. e.printStackTrace();
    35. }
    36. }
    37.  
    38.  
    39. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    40.  
    41. if (cmd.getName().equalsIgnoreCase("setwarp") && sender instanceof Player)
    42. {
    43. Player player1 = (Player) sender;
    44. if(args.length == 0)
    45. {
    46. player1.sendMessage(ChatColor.RED + "/setwarp [name]"); //Not sure if you want it to tell them how to do it as you aren't saving the argument variable.
    47. newConfigz.set(player1.getName() + ".x", player1.getLocation().getBlockX());
    48. newConfigz.set(player1.getName() + ".y", player1.getLocation().getBlockY());
    49. newConfigz.set(player1.getName() + ".z", player1.getLocation().getBlockZ());
    50. player1.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Your Home Has Been Set, Do /home To Teleport To!");
    51. try
    52. {
    53. newConfigz.save(warps);
    54. } catch (IOException e)
    55. {
    56. // TODO Auto-generated catch block
    57. e.printStackTrace();
    58. }
    59. }
    60. }
    61. if(cmd.getName().equalsIgnoreCase("warp") && sender instanceof Player)
    62. {
    63. Player player11 = (Player) sender;
    64.  
    65. int x = newConfigz.getInt(player11.getName() + ".x"), y = newConfigz.getInt(player11.getName() + ".y"), z =newConfigz.getInt(player11.getName() + ".z");
    66. player11.teleport(new Location(player11.getWorld(), x, y, z));
    67. player11.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Teleported To Home!");
    68.  
    69.  
    70.  
    71. return true;
    72.  
    73. }
    74. return false;}}
    75.  


    Since you don't have a variable to save, that extra [name] would literally do nothing. I am thinking the above code is more what you are geared to from my understanding.

    If someone else wishes to add to this or help please do.
    If I completely missed the mark please ignore me.
     
  9. Offline

    hurleyboarder

    I found out what was wrong my other plugin is interfering with this one, the only problem is I don't Know were and how ill show you the code for the other plugin... be prepared its pretty big.
    Code:java
    1. package me.hurleyboarder;
    2.  
    3.  
    4.  
    5.  
    6.  
    7. import java.io.File;
    8. import java.io.IOException;
    9.  
    10. import org.bukkit.ChatColor;
    11. import org.bukkit.GameMode;
    12. import org.bukkit.Location;
    13. import org.bukkit.command.Command;
    14. import org.bukkit.command.CommandSender;
    15. import org.bukkit.configuration.file.FileConfiguration;
    16. import org.bukkit.configuration.file.YamlConfiguration;
    17. import org.bukkit.entity.Player;
    18. import org.bukkit.plugin.java.JavaPlugin;
    19.  
    20. public class EmeraldAvanced extends JavaPlugin {
    21. File homes;
    22. FileConfiguration newConfigz;
    23.  
    24.  
    25.  
    26. @Override
    27. public void onEnable() {
    28. getLogger().info("EmeraldAvanced Enabled!");
    29. new EmeraldAvanced ();
    30. saveDefaultConfig();
    31. homes = new File(getDataFolder(), "homes.yml");
    32. newConfigz = YamlConfiguration.loadConfiguration(homes);
    33.  
    34. }
    35.  
    36. @Override
    37. public void onDisable() {
    38. getLogger().info("EmeraldAvanced Disabled!");
    39. saveDefaultConfig();
    40.  
    41. try{
    42. newConfigz.save(homes);
    43.  
    44. }catch(Exception e){
    45. e.printStackTrace();
    46. }
    47. }
    48. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    49.  
    50. if (cmd.getName().equalsIgnoreCase("craft") && sender instanceof Player) {
    51.  
    52.  
    53. Player player = (Player) sender;
    54. if(sender.hasPermission("emeraldavanced.craft"))
    55. player.openWorkbench(null, true);
    56. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Crafting Table Open!");
    57.  
    58. } else {
    59. if (cmd.getName().equalsIgnoreCase("en") && sender instanceof Player) {
    60.  
    61. Player player = (Player) sender;
    62.  
    63. if(sender.hasPermission("emeraldavanced.enchant"))
    64. player.openEnchanting(null, true);
    65. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Enchantment Table Open!");
    66.  
    67. } else {
    68. if (cmd.getName().equalsIgnoreCase("heal")) {
    69.  
    70. Player player = (Player) sender;
    71. if(sender.hasPermission("emeraldavanced.heal"))
    72.  
    73. player.setHealth(20.0);
    74. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Your Health Has Been Restored!");
    75.  
    76. } else {
    77. if (cmd.getName().equalsIgnoreCase("sethome") && sender instanceof Player) {
    78. Player player = (Player) sender;
    79. if(sender.hasPermission("emeraldavanced.home"));
    80. newConfigz.set(player.getName() + ".x", player.getLocation().getBlockX());
    81. newConfigz.set(player.getName() + ".y", player.getLocation().getBlockY());
    82. newConfigz.set(player.getName() + ".z", player.getLocation().getBlockZ());
    83. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Your Home Has Been Set, Do /home To Teleport To!");
    84. try {
    85. newConfigz.save(homes);
    86. } catch (IOException e) {
    87. // TODO Auto-generated catch block
    88. e.printStackTrace();
    89. }
    90. } else if(cmd.getName().equalsIgnoreCase("home") && sender instanceof Player){
    91. Player player = (Player) sender;
    92. if(sender.hasPermission("emeraldbasic.home"));
    93. int x = newConfigz.getInt(player.getName() + ".x"), y = newConfigz.getInt(player.getName() + ".y"), z =newConfigz.getInt(player.getName() + ".z");
    94. player.teleport(new Location(player.getWorld(), x, y, z));
    95. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Teleported To Home!");
    96. } else {
    97. if (cmd.getName().equalsIgnoreCase("feed")) {
    98.  
    99. Player player = (Player) sender;
    100. if(sender.hasPermission("emeraldavanced.feed"))
    101.  
    102. player.setFoodLevel(25);
    103. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Your Food Level Has Been Restored!");
    104.  
    105. } else {
    106. if (cmd.getName().equalsIgnoreCase("vanish")) {
    107.  
    108. Player player = (Player) sender;
    109. if(sender.hasPermission("emeraldavanced.vanish"))
    110. for (Player other : getServer().getOnlinePlayers()) {
    111. other.hidePlayer(player);
    112. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Now Nobody Can See You! Do /unvanish To Reappear!");
    113. other.sendMessage(ChatColor.YELLOW + player.getName() + " left the game.");
    114. player.setPlayerListName("");
    115. }
    116. }else{
    117.  
    118. if (cmd.getName().equalsIgnoreCase("unvanish")) {
    119.  
    120. Player player = (Player) sender;
    121. if(sender.hasPermission("emeraldavanced.vanish"))
    122. for (Player other : getServer().getOnlinePlayers()) {
    123. other.showPlayer(player);
    124. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Players Can Now See You!");
    125. other.sendMessage(ChatColor.YELLOW + player.getName() + " joined the game.");
    126. player.setPlayerListName(player.getName() + "");
    127. }
    128.  
    129. } else {
    130. if(cmd.getName().equalsIgnoreCase("fly")) {
    131. Player player = (Player) sender;
    132. if(sender.hasPermission("emeraldavanced.fly"))
    133. player.setAllowFlight(isEnabled());
    134. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Flying Enabled, Do /unfly To Stop!");
    135.  
    136. } else {
    137. if(cmd.getName().equalsIgnoreCase("unfly")) {
    138. Player player = (Player) sender;
    139. if(sender.hasPermission("emeraldavanced.fly"))
    140. player.setAllowFlight(false);
    141. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Flying Disabled");
    142.  
    143. } else {
    144. if(cmd.getName().equalsIgnoreCase("gm0")) {
    145. Player player = (Player) sender;
    146. if(sender.hasPermission("emeraldavanced.easygamemodechange"))
    147. player.setGameMode(GameMode.SURVIVAL);
    148. } else {
    149. if(cmd.getName().equalsIgnoreCase("gm1")) {
    150. Player player = (Player) sender;
    151. if(sender.hasPermission("emeraldavanced.easygamemodechange"))
    152. player.setGameMode(GameMode.CREATIVE);
    153. } else {
    154. if(cmd.getName().equalsIgnoreCase("gm2")) {
    155. Player player = (Player) sender;
    156. if(sender.hasPermission("emeraldavanced.easygamemodechange"));
    157. player.setGameMode(GameMode.ADVENTURE);
    158. } else {
    159. if(cmd.getName().equalsIgnoreCase("repair")){
    160. Player player = (Player) sender;
    161. if(sender.hasPermission("emeraldavanced.repair"));
    162. player.getItemInHand().setDurability((short) 0);
    163. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + " Any Tools, And Armor In Hand Have Been Repaired!");
    164.  
    165. }else{
    166. if(cmd.getName().equalsIgnoreCase("suicide")){
    167. Player player = (Player) sender;
    168. if(sender.hasPermission("emeraldavanced.suicide"))
    169. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.RED + " You Have Killed Yourself!");
    170. player.damage(100.0);
    171. } else {
    172. if(cmd.getName().equalsIgnoreCase("kill")){
    173. Player player = (Player) sender;
    174. if(sender.hasPermission("emeraldavanced.kill"))
    175. if(sender instanceof Player){
    176. if(args.length == 1){
    177.  
    178. Player target = getServer().getPlayer(args[0]);
    179. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.RED + "You Have Been Killed By Command! ");
    180. target.damage(40.0);
    181. player.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.RED + target.getName() + " Has Been Killed!");
    182. } else {
    183. sender.sendMessage(ChatColor.RED + "/kill [Player]");
    184. }
    185. } else {
    186. sender.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.DARK_RED + " This command can only be run by a player!");
    187.  
    188.  
    189. } else {
    190. Player player11 = (Player) sender;
    191. if(sender.hasPermission("emeraldavanced.tp"))
    192. if(cmd.getName().equalsIgnoreCase("tp")) {
    193. if(args.length == 0){
    194. player11.sendMessage(ChatColor.DARK_RED + "Too Little Arguments!");
    195. }else if(args.length == 1) {
    196. Player targetPlayer = player11.getServer().getPlayer(args[0]);
    197. Location targetPlayerLocation = targetPlayer.getLocation();
    198. player11.teleport(targetPlayerLocation);
    199. }else if(args.length == 2){
    200. Player targetPlayer = player11.getServer().getPlayer(args[0]);
    201. Player targetPlayer1 = player11.getServer().getPlayer(args[1]);
    202. Location targetPlayer1Location = targetPlayer1.getLocation();
    203. targetPlayer.teleport(targetPlayer1Location);
    204. targetPlayer.sendMessage(ChatColor.BLUE + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + " You Have Been Teleported To " + player11.getName() + "!");
    205.  
    206.  
    207.  
    208.  
    209.  
    210.  
    211. }
    212. }
    213.  
    214.  
    215.  
    216.  
    217.  
    218. }}}}}
    219. return true; }
    220. }}}}}
    221.  
    222.  
    223. }}}}}
    224.  
    225.  
    226.  
    227.  
    228.  
    229.  
    230.  
    231. return false;}}
    232.  
     
  10. Offline

    97WaterPolo

    hurleyboarder
    Okay, for future reference please use that "Tahg" button instead of reply for huge posts like that! :p

    The code you showed us, is it part of EmeraldAdvance?

    If it isn't, how do you know this EmeraldAdvance and the other one are conflicting?
     
  11. Offline

    hurleyboarder

    97waterpolo
    Because the other one didnt work but when I deleted it it worked
     
  12. Offline

    97WaterPolo

    hurleyboarder
    So I take it they are seperate.

    Is there a command that they both share? I can not think of any reason other than that for it not to be working. Let me compile what I posted above and I shall see if it even works :L
     
  13. Offline

    hurleyboarder

    97waterpolo
    My original plan was to have those commnds in that EmeraldAvanced one but it wouldnt work
     
  14. Offline

    97WaterPolo

    hurleyboarder
    Just tested the warping one and it works fine, can you send me the compiled .jar of the EmeraldAdvance? For the warping plugin the following code works perfectly except for the prefix, which is null due to me not having the default config for the onEnable().

    Send me the emerald advance through mediafire or something and I shall try to help you figure this out! ^_^

    Code:java
    1. package com.rebelempiremc.sigler;
    2.  
    3. import java.io.File;
    4. import java.io.IOException;
    5.  
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Location;
    8. import org.bukkit.command.Command;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.configuration.file.FileConfiguration;
    11. import org.bukkit.configuration.file.YamlConfiguration;
    12. import org.bukkit.entity.Player;
    13. import org.bukkit.plugin.java.JavaPlugin;
    14.  
    15. public class First extends JavaPlugin {
    16. File warps;
    17. FileConfiguration newConfigz;
    18.  
    19. @Override
    20. public void onEnable()
    21. {
    22. warps = new File(getDataFolder(), "warps.yml");
    23. newConfigz = YamlConfiguration.loadConfiguration(warps);
    24. saveConfig();
    25. }
    26. @Override
    27. public void onDisable()
    28. {
    29. saveConfig();
    30. try{
    31. newConfigz.save(warps);
    32.  
    33. }catch(Exception e){
    34. e.printStackTrace();
    35. }
    36. }
    37.  
    38.  
    39. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    40.  
    41. if (cmd.getName().equalsIgnoreCase("setwarp") && sender instanceof Player)
    42. {
    43. Player player1 = (Player) sender;
    44. if(args.length == 0)
    45. {
    46. player1.sendMessage(ChatColor.RED + "/setwarp [name]"); //Not sure if you want it to tell them how to do it as you aren't saving the argument variable.
    47. newConfigz.set(player1.getName() + ".x", player1.getLocation().getBlockX());
    48. newConfigz.set(player1.getName() + ".y", player1.getLocation().getBlockY());
    49. newConfigz.set(player1.getName() + ".z", player1.getLocation().getBlockZ());
    50. player1.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Your Home Has Been Set, Do /home To Teleport To!");
    51. try
    52. {
    53. newConfigz.save(warps);
    54. } catch (IOException e)
    55. {
    56. // TODO Auto-generated catch block
    57. e.printStackTrace();
    58. }
    59. }
    60. }
    61. if(cmd.getName().equalsIgnoreCase("warp") && sender instanceof Player)
    62. {
    63. Player player11 = (Player) sender;
    64.  
    65. int x = newConfigz.getInt(player11.getName() + ".x"), y = newConfigz.getInt(player11.getName() + ".y"), z =newConfigz.getInt(player11.getName() + ".z");
    66. player11.teleport(new Location(player11.getWorld(), x, y, z));
    67. player11.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + "Teleported To Home!");
    68.  
    69.  
    70.  
    71. return true;
    72.  
    73. }
    74. return false;}}
    75.  


    Why wouldn't it work?
     
  15. Offline

    hurleyboarder

    97waterpolo
    is there a email I can just send it to

    97waterpolo
    <Edit by Moderator: Redacted mediafire url>

    97waterpolo
    Never mind ill just do it through email

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 3, 2016
  16. Offline

    97WaterPolo

    hurleyboarder
    Okay, I have no idea what the problem is? I tested it and it works fine! Want a compiled .jar? I will also upload source to github if you need, but its a single class.
     
  17. Offline

    hurleyboarder

  18. Offline

    97WaterPolo

    .jar - http://www.fileswap.com/dl/t627vvqxjD/

    Also, with your EmeraldAdvanced, I am got an error that it is already intialized, not to sure but I tested /craft with it when I had both installed. I also added 2 options to the config so DELETE your config.yml and warps.yml. It will regenerate them and add paths in which you can edit.

    Code:
    Code:
    package com.rebelempiremc.sigler;
     
    import java.io.File;
    import java.io.IOException;
     
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.configuration.file.YamlConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class First extends JavaPlugin {
        File warps;
        FileConfiguration newConfigz;
     
        @Override
        public void onEnable()
        {
            warps = new File(getDataFolder(), "warps.yml");
            newConfigz = YamlConfiguration.loadConfiguration(warps);
            saveConfig();
            saveDefaultConfig();
            getConfig().addDefault("Messenger", "First");
            getConfig().addDefault("Setwarp", "Your Home Has Been Set, Do /warp To Teleport To!");
            getConfig().addDefault("MWarp", "Teleported To Home!");
        }
        @Override
        public void onDisable()
        {
            saveConfig();
            try{
                newConfigz.save(warps);
     
            }catch(Exception e){
                e.printStackTrace();
            }
        }
     
     
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
     
            if (cmd.getName().equalsIgnoreCase("setwarp") && sender instanceof Player)
            {
                Player player1 = (Player) sender;
                if(args.length == 0)
                {
                    //player1.sendMessage(ChatColor.RED + "/setwarp [name]"); //Not sure if you want it to tell them how to do it as you aren't saving the argument variable.
                    newConfigz.set(player1.getName() + ".x", player1.getLocation().getBlockX());
                    newConfigz.set(player1.getName() + ".y", player1.getLocation().getBlockY());
                    newConfigz.set(player1.getName() + ".z", player1.getLocation().getBlockZ());
                    player1.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + getConfig().getString("Setwarp"));
                    try
                    {
                        newConfigz.save(warps);
                    } catch (IOException e)
                    {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }
            if(cmd.getName().equalsIgnoreCase("warp") && sender instanceof Player)
            {
                Player player11 = (Player) sender;
     
                int x = newConfigz.getInt(player11.getName() + ".x"), y = newConfigz.getInt(player11.getName() + ".y"), z =newConfigz.getInt(player11.getName() + ".z");
                player11.teleport(new Location(player11.getWorld(), x, y, z));
                player11.sendMessage(ChatColor.AQUA + "[" + getConfig().getString("Messenger") + "] " + ChatColor.GREEN + getConfig().getString("Warp"));
     
     
     
                return true;
     
            }
            return false;}}
    
    Config.yml
    Code:
    Messenger: First
    Setwarp: Your Home Has Been Set, Do /warp To Teleport To!
    Warp: Teleported To Home!
    plugin.yml
    Code:
    name: First
    main: com.rebelempiremc.sigler.First
    version: 1.0
    commands:
      setwarp:
        descrition: Sets the warp
      warp:
        descrition: Warps you home
    Feel free to change up all the names and such, I know your the author, but I find it hard to code when trying to change the name to the other plugin.
     
  19. Offline

    hurleyboarder

    Thank you so much
     
  20. Offline

    97WaterPolo

    hurleyboarder
    No Problem, if this fixed it, go ahead and set your thread to solved. Top of the page > Thread Tools ?> Edit Thread > Prefix > Solved
     
  21. Offline

    hurleyboarder

    97waterpolo
    For some reason it still wont work when I do /setwarp or /warp it does nothing but when I delete emeraldavanced it does. idk im going to bed though so ill see new posts tomorrow. thanks
     
  22. Offline

    97WaterPolo

    Huh, got no idea. I can turn on my test server once more tomorrow and try it, I have the .jar you gave me and the one I compiled. No idea...
     
Thread Status:
Not open for further replies.

Share This Page