1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00

Prevent possible backpack dupes

This will prevent dupes from arising if a player obtains 2 of the same backpack from staff error, flukes, past exploits, etc.
This commit is contained in:
VoidAngel 2017-04-21 09:59:59 -07:00 committed by GitHub
parent 5c9943de17
commit f1a8816bfa

View File

@ -84,9 +84,13 @@ public class BackpackListener implements Listener {
break; break;
} }
} }
Backpacks.openBackpack(p, item); if(!Variables.backpack.containsValue(item))
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F); {
Variables.backpack.put(p.getUniqueId(), item); Backpacks.openBackpack(p, item);
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F);
Variables.backpack.put(p.getUniqueId(), item);
}
else Messages.local.sendTranslation(p, "backpack.already-open", true);
} }
else Messages.local.sendTranslation(p, "backpack.no-stack", true); else Messages.local.sendTranslation(p, "backpack.no-stack", true);
} }
@ -105,9 +109,13 @@ public class BackpackListener implements Listener {
break; break;
} }
} }
Backpacks.openBackpack(p, item); if(!Variables.backpack.containsValue(item))
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F); {
Variables.backpack.put(p.getUniqueId(), item); Backpacks.openBackpack(p, item);
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F);
Variables.backpack.put(p.getUniqueId(), item);
}
else Messages.local.sendTranslation(p, "backpack.already-open", true);
} }
else Messages.local.sendTranslation(p, "backpack.no-stack", true); else Messages.local.sendTranslation(p, "backpack.no-stack", true);
} }
@ -126,9 +134,13 @@ public class BackpackListener implements Listener {
break; break;
} }
} }
Backpacks.openBackpack(p, item); if(!Variables.backpack.containsValue(item))
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F); {
Variables.backpack.put(p.getUniqueId(), item); Backpacks.openBackpack(p, item);
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F);
Variables.backpack.put(p.getUniqueId(), item);
}
else Messages.local.sendTranslation(p, "backpack.already-open", true);
} }
else Messages.local.sendTranslation(p, "backpack.no-stack", true); else Messages.local.sendTranslation(p, "backpack.no-stack", true);
} }
@ -147,9 +159,13 @@ public class BackpackListener implements Listener {
break; break;
} }
} }
Backpacks.openBackpack(p, item); if(!Variables.backpack.containsValue(item))
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F); {
Variables.backpack.put(p.getUniqueId(), item); Backpacks.openBackpack(p, item);
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F);
Variables.backpack.put(p.getUniqueId(), item);
}
else Messages.local.sendTranslation(p, "backpack.already-open", true);
} }
else Messages.local.sendTranslation(p, "backpack.no-stack", true); else Messages.local.sendTranslation(p, "backpack.no-stack", true);
} }
@ -168,9 +184,13 @@ public class BackpackListener implements Listener {
break; break;
} }
} }
Backpacks.openBackpack(p, item); if(!Variables.backpack.containsValue(item))
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F); {
Variables.backpack.put(p.getUniqueId(), item); Backpacks.openBackpack(p, item);
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F);
Variables.backpack.put(p.getUniqueId(), item);
}
else Messages.local.sendTranslation(p, "backpack.already-open", true);
} }
else Messages.local.sendTranslation(p, "backpack.no-stack", true); else Messages.local.sendTranslation(p, "backpack.no-stack", true);
} }
@ -189,9 +209,13 @@ public class BackpackListener implements Listener {
break; break;
} }
} }
Backpacks.openBackpack(p, item); if(!Variables.backpack.containsValue(item))
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F); {
Variables.backpack.put(p.getUniqueId(), item); Backpacks.openBackpack(p, item);
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F);
Variables.backpack.put(p.getUniqueId(), item);
}
else Messages.local.sendTranslation(p, "backpack.already-open", true);
} }
else Messages.local.sendTranslation(p, "backpack.no-stack", true); else Messages.local.sendTranslation(p, "backpack.no-stack", true);
} }
@ -210,9 +234,13 @@ public class BackpackListener implements Listener {
break; break;
} }
} }
Backpacks.openBackpack(p, item); if(!Variables.backpack.containsValue(item))
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F); {
Variables.backpack.put(p.getUniqueId(), item); Backpacks.openBackpack(p, item);
p.playSound(p.getLocation(), Sound.ENTITY_HORSE_ARMOR, 1F, 1F);
Variables.backpack.put(p.getUniqueId(), item);
}
else Messages.local.sendTranslation(p, "backpack.already-open", true);
} }
else Messages.local.sendTranslation(p, "backpack.no-stack", true); else Messages.local.sendTranslation(p, "backpack.no-stack", true);
} }