Weird Kit issue

Discussion in 'Plugin Development' started by RizzelDazz, Feb 6, 2014.

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

    RizzelDazz

    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
    1. if (s.getLine(0).equalsIgnoreCase("§1[Flash]")) {
    2. clearInv(player, pi);
    3. player.updateInventory();
    4. kitFlash(player, pi);
    5. }


    kitFlash();
    Code:java
    1. @SuppressWarnings("deprecation")
    2. private void kitFlash(Player player, PlayerInventory pi) {
    3. player.getWorld().playSound(player.getLocation(), Sound.ORB_PICKUP, 1,
    4. 0);
    5. pi.addItem(FSword);
    6. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,
    7. 999999999, 1));
    8. if (Main.blue.contains(player)) {
    9. //set armor
    10. } else {
    11. //set armor
    12. }
    13. player.updateInventory();
    14. }


    clearInv();
    Code:java
    1. private void clearInv(Player player, PlayerInventory pi) {
    2. player.getInventory().clear();
    3. //player.getInventory().setHelmet(null);
    4. //player.getInventory().setChestplate(null);
    5. //player.getInventory().setLeggings(null);
    6. //player.getInventory().setBoots(null);
    7. player.updateInventory();
    8. for(PotionEffect effect : player.getActivePotionEffects())
    9. {
    10. player.removePotionEffect(effect.getType());
    11. }
    12. }
    13. }


    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.
     
    Last edited by a moderator: Jun 6, 2016
  2. Offline

    TehVoyager

    When the player picks a new kit remove them from the kit list.
     
  3. Offline

    moneyremco

    And if you dont use the clearinv() but this:
    Code:java
    1. if (s.getLine(0).equalsIgnoreCase("§1[Flash]")) {
    2. player.getInventory().clear();
    3. player.removePotionEffects();
    4. player.updateInventory();
    5. kitFlash(player, pi);
    6. }

    (not tested, im on my phone now)
     
  4. Offline

    RizzelDazz

    @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.
     
  5. Offline

    xMrPoi

    Could you provide the full code?
     
  6. Offline

    RizzelDazz

    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.
     
Thread Status:
Not open for further replies.

Share This Page