Optimize safeGuard performance

Former-commit-id: 870cd00e9db490251e8c94bca9230564ba82e2ed
This commit is contained in:
Ghost_chu committed 2020-01-04 11:23:12 +08:00
1 parent d1b7a13fec
commit def1c40c61
1 file changed
+13 -12
@@ -162,12 +162,16 @@ public class RealDisplayItem implements DisplayItem {
}
Item item = (Item) entity;
//Set item protect in the armorstand's hand
this.guardedIstack = DisplayItem.createGuardItemStack(this.originalItemStack, this.shop);
item.setItemStack(this.guardedIstack);
if (plugin.getConfig().getBoolean("shop.display-item-use-name")) {
item.setCustomName(Util.getItemStackName(this.guardedIstack));
item.setCustomNameVisible(true);
}
if (plugin.getConfig().getBoolean("shop.display-item-use-name")) {
item.setCustomName(Util.getItemStackName(this.originalItemStack));
item.setCustomNameVisible(true);
}
item.setPickupDelay(Integer.MAX_VALUE);
item.setSilent(true);
item.setPortalCooldown(Integer.MAX_VALUE);
item.setVelocity(new Vector(0, 0.1, 0));
item.setCustomNameVisible(false);
Util.debugLog("Successfully safeGuard Item: " + item.getLocation());
}
@@ -200,12 +204,9 @@ public class RealDisplayItem implements DisplayItem {
Util.debugLog("Canceled the displayItem spawning because a plugin setCancelled the spawning event, usually this is a QuickShop Add on");
return;
}
this.item = this.shop.getLocation().getWorld().dropItem(getDisplayLocation(), originalItemStack);
this.item.setPickupDelay(Integer.MAX_VALUE);
this.item.setSilent(true);
this.item.setPortalCooldown(Integer.MAX_VALUE);
this.item.setVelocity(new Vector(0, 0.1, 0));
this.item.setCustomNameVisible(false);
this.guardedIstack = DisplayItem.createGuardItemStack(this.originalItemStack, this.shop);
this.item = this.shop.getLocation().getWorld().dropItem(getDisplayLocation(), this.guardedIstack);
this.item.setItemStack(this.guardedIstack);
safeGuard(this.item);
Util.debugLog("Spawned new DisplayItem for shop " + shop.getLocation());
}