Problem with checking the world

Discussion in 'Plugin Development' started by ChunkMe, May 9, 2014.

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

    ChunkMe

    Hello Bukkit coders!
    I'm creating a plugin WITH multiworld support and i would let them say in the config on
    wich world the want to apply the plugin.
    But by checking, ill get an error!
    This is the code of one of my classes, i used the same method on all of my other classes (commands/events)
    Code:java
    1. package me.ChunkMe.cmd;
    2.  
    3.  
    4. import me.ChunkMe.MyKits;
    5.  
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.Material;
    8. import org.bukkit.World;
    9. import org.bukkit.command.Command;
    10. import org.bukkit.command.CommandExecutor;
    11. import org.bukkit.command.CommandSender;
    12. import org.bukkit.entity.Player;
    13. import org.bukkit.inventory.ItemStack;
    14. import org.bukkit.inventory.PlayerInventory;
    15. import org.bukkit.inventory.meta.ItemMeta;
    16.  
    17. public class PvP implements CommandExecutor {
    18. public MyKits plugin;
    19. public PvP(MyKits plugin){
    20. this.plugin = plugin;
    21. }
    22. @Override
    23. public boolean onCommand(CommandSender cs, Command cmd, String label,
    24. String[] args) {
    25. Player p = (Player)cs;
    26. String getworld = plugin.getConfig().getString("multiworld").toLowerCase().toString();
    27. String kitname = "PvP";
    28. World currentworld = p.getWorld();
    29.  
    30. if(!(cs instanceof Player)) return true;
    31. if(!getworld.equals(currentworld)){
    32. p.sendMessage(ChatColor.RED + "You need to be in the " + getworld + "world");
    33. }else if(!p.hasPermission("mykits.kit." + kitname)){
    34. p.sendMessage(ChatColor.RED + "You can't use the kit class!");
    35. }else{
    36. p.sendMessage(ChatColor.YELLOW + "You selected the " + kitname + " class!");
    37. PlayerInventory pi = p.getInventory();
    38. //Sword
    39. ItemStack pk = new ItemStack(Material.IRON_SWORD, 1);
    40. ItemMeta meta1 = pk.getItemMeta();
    41. meta1.setDisplayName(ChatColor.RED + "Sword" + ChatColor.GRAY + " (" + kitname + ")");
    42. pk.setItemMeta(meta1);
    43. pi.addItem(pk);
    44. ItemStack pkh = new ItemStack(Material.IRON_HELMET, 1);
    45. //Helmet
    46. ItemMeta meta11 = pkh.getItemMeta();
    47. meta11.setDisplayName(ChatColor.RED + "Armor" + ChatColor.GRAY + " (" + kitname + ")" );
    48. pkh.setItemMeta(meta11);
    49. pi.addItem(pkh);
    50. //ChestPlate
    51. ItemStack pkc = new ItemStack(Material.CHAINMAIL_CHESTPLATE, 1);
    52. ItemMeta meta111 = pkc.getItemMeta();
    53. meta111.setDisplayName(ChatColor.RED + "Armor" + ChatColor.GRAY +" (" + kitname + ")");
    54. pkc.setItemMeta(meta111);
    55. pi.addItem(pkc);
    56. //Leggings
    57. ItemStack pkl = new ItemStack(Material.IRON_LEGGINGS, 1);
    58. ItemMeta meta2 = pkl.getItemMeta();
    59. meta2.setDisplayName(ChatColor.RED + "Armor" + ChatColor.GRAY + " (" + kitname + ")");
    60. pkl.setItemMeta(meta2);
    61. pi.addItem(pkl);
    62. //Soup
    63. ItemStack soup = new ItemStack(Material.MUSHROOM_SOUP, 10000000);
    64. ItemMeta metas = soup.getItemMeta();
    65. metas.setDisplayName(ChatColor.RED + "Soup" + ChatColor.GRAY + " (" + kitname + ")");
    66. soup.setItemMeta(metas);
    67. pi.addItem(soup);
    68. }
    69. return false;
    70. }
    71.  
    72.  
    73.  
    74. }
    75.  


    And yes, i tried if(!getworld.equals(currentworld)){ and
    if(!currentworld.equals(getworld)){
    All of the to doesn't work!

    Bump?

    Bumpiebumpiebump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
Thread Status:
Not open for further replies.

Share This Page