Hello, recently I have been making a plugin and whenever I teleport a player and change/update their inventory, they cannot move their items in their inventory! It doesn't register! For example - client side the player is allowed to move their inventory items, but when another player looks at them, it seems as if they are holding the item that the plugin gave them in that position, and later when the player interacts with the supposed moved items they reset. This may sound confusing, but basically the items aren't movable and they keep go back to their original location after a move! Any help would be appreciated this is my code that causes this:
Code:
String name = e.getCurrentItem().getItemMeta().getDisplayName();[/B][/LEFT][/B][/LEFT][/B][/COLOR][/FONT]
[B][FONT=Droid Sans][COLOR=rgb(44, 44, 44)][B]
[LEFT] name = ChatColor.stripColor(name);
name = name.toUpperCase();
editor.put(e.getWhoClicked().getUniqueId(), KitType.valueOf(name));
KitType kitType = KitType.valueOf(name);
e.getWhoClicked().sendMessage(ChatColor.GREEN + "Editing Kit - " + name);
loc.put(e.getWhoClicked().getUniqueId(), e.getWhoClicked().getLocation());
World world = Bukkit.getWorld(PracticePvP.configYml.getString("KitEditorWorld"));
Location loc = new Location(world, PracticePvP.configYml.getDouble("KitEditorX"), PracticePvP.configYml.getDouble("KitEditorY"), PracticePvP.configYml.getDouble("KitEditorZ"));
e.getWhoClicked().teleport(loc);
Player p = (Player) e.getWhoClicked();
hideFrom.put(e.getWhoClicked().getUniqueId(), editing);
if(hideFrom.get(e.getWhoClicked()) != null) {
for (UUID u : hideFrom.get(e.getWhoClicked())) {
p.hidePlayer(Bukkit.getPlayer(u));
Bukkit.getPlayer(u).hidePlayer(p);
hideFrom.get(Bukkit.getPlayer(u).getUniqueId()).add(p.getUniqueId());
}
}
clearInventory((Player) e.getWhoClicked());
if (kitType.equals(KitType.NODEBUFF)) {
Kit.giveNoDebuff(p);
}
Code:
public static void giveNoDebuff(Player p) {[/B][/LEFT][/B][/LEFT][/B][/COLOR][/FONT]
[B][FONT=Droid Sans][COLOR=rgb(44, 44, 44)][B]
[LEFT][B]
[LEFT] if(PracticePvP.editsYml.get(String.valueOf(p.getUniqueId()) + "." + KitType.NODEBUFF.toString()) != null == false) {
onClick.clearInventory(p);
ItemStack helm = new ItemStack(Material.DIAMOND_HELMET);
ItemStack chest = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemStack legs = new ItemStack(Material.DIAMOND_LEGGINGS);
ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
helm.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
chest.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
legs.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
sword.addEnchantment(Enchantment.DAMAGE_ALL, 2);
ItemStack pearls = new ItemStack(Material.ENDER_PEARL, 16);
ItemStack steak = new ItemStack(Material.COOKED_BEEF, 64);
ItemStack speed = new ItemStack(Material.POTION, 1, (short) 8226);
ItemStack health = new ItemStack(Material.POTION, 1, (short) 16421);
p.getInventory().setHelmet(helm);
p.getInventory().setChestplate(chest);
p.getInventory().setLeggings(legs);
p.getInventory().setBoots(boots);
p.getInventory().setItem(0, sword);
p.getInventory().setItem(1, pearls);
p.getInventory().setItem(2, steak);
p.getInventory().setItem(3, speed);
p.getInventory().setItem(4, speed);
p.getInventory().setItem(11, speed);
p.getInventory().setItem(12, speed);
for (int i = 0; i < p.getInventory().getSize(); i++) {
if (p.getInventory().getItem(i) == null) {
p.getInventory().setItem(i, health);
}
}
} else {
ItemStack helm = new ItemStack(Material.DIAMOND_HELMET);
ItemStack chest = new ItemStack(Material.DIAMOND_CHESTPLATE);
ItemStack legs = new ItemStack(Material.DIAMOND_LEGGINGS);
ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
helm.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
chest.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
legs.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
boots.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
p.getInventory().setHelmet(helm);
p.getInventory().setChestplate(chest);
p.getInventory().setLeggings(legs);
p.getInventory().setBoots(boots);
onClick.clearInventory(p);
p.getInventory().setContents(onClick.getInventory(PracticePvP.editsYml, String.valueOf(p.getUniqueId()) + "." + KitType.NODEBUFF.toString()).getContents());
}
}
