Im facing this really anoying issue, I have kits that a player selects, when they select thge kit it gives them the items and everything. Lets say I have two kits, archer and flash. They choose flash which just has a sword with fire, then they choose archer and they can't shoot arrow but and they hit things with the bow (cow) and it lights on fire which means it is being hit with fire aspect but the flash kit only has fire aspect not archer. They also cant shoot arrows unless they open the inventory and clcik the item and put it back. Client side it shows them holding a bow but other players see it as a sword. I am updatingINV, clearing, giving the items and updating again. If a user picks the bow kit first, they can shoot arrows just fine after a restart. If they switch the kit, then they can still shoot bows while holding a sword but see it as a sword from that person perspective yet other players see it as a bow.. I am going to provide an example of the actions that are done to give the kit, not going to give all code since it is huge Player Clicking Sign: Code:java if (s.getLine(0).equalsIgnoreCase("§1[Flash]")) { clearInv(player, pi); player.updateInventory(); kitFlash(player, pi); } kitFlash(); Code:java @SuppressWarnings("deprecation") private void kitFlash(Player player, PlayerInventory pi) { player.getWorld().playSound(player.getLocation(), Sound.ORB_PICKUP, 1, 0); pi.addItem(FSword); player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999999, 1)); if (Main.blue.contains(player)) {//set armor } else {//set armor } player.updateInventory(); } clearInv(); Code:java private void clearInv(Player player, PlayerInventory pi) {player.getInventory().clear();//player.getInventory().setHelmet(null);//player.getInventory().setChestplate(null);//player.getInventory().setLeggings(null);//player.getInventory().setBoots(null);player.updateInventory();for(PotionEffect effect : player.getActivePotionEffects()){ player.removePotionEffect(effect.getType());}} } Bump, dying to resolve this issue and I can't figure it out. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
And if you dont use the clearinv() but this: Code:java if (s.getLine(0).equalsIgnoreCase("§1[Flash]")) { player.getInventory().clear(); player.removePotionEffects(); player.updateInventory(); kitFlash(player, pi); } (not tested, im on my phone now)
@TehVoayger There are not lists, just methods when picking a kit. moneyremco I will try that, let you know if it works but isn't that really just using the same thing just without the method? Also, there is no removePotionEffects. This did not work(edit) Edit: I added a delayed task for when it gives the items. This is SUPER weird. When choosing the first kit, it clears the inventory like it should, then it gives the kit after seconds. Now when I choose a diifferent kit, it clears the inventory and gives the last kit you choose and the kit you just choosw Edit: I took out my durability class and it still seems to have the same issue, it gives the current kit and the last item you had in your hand. If you had nothing in your hand then the kit works perfectly. TLTR: I need to make it so the plugin clears the item in their hand because it seems to clear everything else besides that.
I provided all code that handled the kit giving. Also, the issue was that when clicking a sign, it does not consider the item in hand there until .5LT or whatever so I just added a delayed task and it worked.