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

Fix Additional Devices Vulnerable to Duplication Bug

This commit is contained in:
KyleEstein 2018-04-25 23:40:46 -04:00
parent 66176b445a
commit b16b936b81
16 changed files with 118 additions and 31 deletions

View File

@ -211,9 +211,15 @@ public abstract class ProgrammableAndroid extends SlimefunItem {
boolean allow = reason.equals(UnregisterReason.PLAYER_BREAK) && (BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass")); boolean allow = reason.equals(UnregisterReason.PLAYER_BREAK) && (BlockStorage.getBlockInfo(b, "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass"));
if (allow) { if (allow) {
if (BlockStorage.getInventory(b).getItemInSlot(43) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(43)); if (BlockStorage.getInventory(b).getItemInSlot(43) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(43));
BlockStorage.getInventory(b).replaceExistingItem(43, null);
}
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
} }
AndroidStatusHologram.remove(b); AndroidStatusHologram.remove(b);
} }

View File

@ -86,13 +86,13 @@ public abstract class AContainer extends SlimefunItem {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (inv.getItemInSlot(slot) != null) { if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.toInventory().clear(slot); inv.replaceExistingItem(slot, null);
} }
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) { if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.toInventory().clear(slot); inv.replaceExistingItem(slot, null);
} }
} }
} }
@ -141,10 +141,16 @@ public abstract class AContainer extends SlimefunItem {
@Override @Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
} }
processing.remove(b); processing.remove(b);
progress.remove(b); progress.remove(b);

View File

@ -69,7 +69,10 @@ public abstract class AFarm extends SlimefunItem {
@Override @Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
} }
return true; return true;
} }
@ -112,7 +115,10 @@ public abstract class AFarm extends SlimefunItem {
@Override @Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
} }
return true; return true;
} }

View File

@ -88,10 +88,16 @@ public abstract class AGenerator extends SlimefunItem {
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
progress.remove(b.getLocation()); progress.remove(b.getLocation());
@ -141,10 +147,16 @@ public abstract class AGenerator extends SlimefunItem {
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
progress.remove(b.getLocation()); progress.remove(b.getLocation());

View File

@ -134,13 +134,22 @@ public abstract class AReactor extends SlimefunItem {
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
for (int slot: getFuelSlots()) { for (int slot: getFuelSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getCoolantSlots()) { for (int slot: getCoolantSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
progress.remove(b.getLocation()); progress.remove(b.getLocation());

View File

@ -211,7 +211,10 @@ public class AdvancedCargoOutputNode extends SlimefunItem {
@Override @Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
} }
return true; return true;
} }

View File

@ -71,7 +71,10 @@ public class AnimalGrowthAccelerator extends SlimefunItem {
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
me.mrCookieSlime.Slimefun.holograms.AnimalGrowthAccelerator.getArmorStand(b).remove(); me.mrCookieSlime.Slimefun.holograms.AnimalGrowthAccelerator.getArmorStand(b).remove();
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
} }
return true; return true;
} }

View File

@ -71,7 +71,10 @@ public class AutoBreeder extends SlimefunItem {
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
me.mrCookieSlime.Slimefun.holograms.AutoBreeder.getArmorStand(b).remove(); me.mrCookieSlime.Slimefun.holograms.AutoBreeder.getArmorStand(b).remove();
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
} }
return true; return true;
} }

View File

@ -119,10 +119,16 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem {
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
return true; return true;

View File

@ -106,7 +106,10 @@ public class CargoCraftingNode extends SlimefunItem {
@Override @Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
} }
return true; return true;
} }

View File

@ -237,7 +237,10 @@ public class CargoInputNode extends SlimefunItem {
@Override @Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
} }
return true; return true;
} }

View File

@ -81,7 +81,10 @@ public abstract class CropGrowthAccelerator extends SlimefunItem {
@Override @Override
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
} }
return true; return true;
} }

View File

@ -102,10 +102,16 @@ public abstract class ElectricSmeltery extends AContainer {
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
for (int slot: getInputSlots()) { for (int slot: getInputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
progress.remove(b.getLocation()); progress.remove(b.getLocation());

View File

@ -81,13 +81,22 @@ public class ReactorAccessPort extends SlimefunItem {
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
for (int slot: getFuelSlots()) { for (int slot: getFuelSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getCoolantSlots()) { for (int slot: getCoolantSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
return true; return true;

View File

@ -130,10 +130,16 @@ public class WitherAssembler extends SlimefunItem {
BlockMenu inv = BlockStorage.getInventory(b); BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) { if (inv != null) {
for (int slot: getSoulSandSlots()) { for (int slot: getSoulSandSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
for (int slot: getWitherSkullSlots()) { for (int slot: getWitherSkullSlots()) {
if (inv.getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot)); if (inv.getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), inv.getItemInSlot(slot));
inv.replaceExistingItem(slot, null);
}
} }
} }
return true; return true;

View File

@ -70,7 +70,10 @@ public class XPCollector extends SlimefunItem {
public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) { public boolean onBreak(Player p, Block b, SlimefunItem item, UnregisterReason reason) {
me.mrCookieSlime.Slimefun.holograms.XPCollector.getArmorStand(b).remove(); me.mrCookieSlime.Slimefun.holograms.XPCollector.getArmorStand(b).remove();
for (int slot: getOutputSlots()) { for (int slot: getOutputSlots()) {
if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot)); if (BlockStorage.getInventory(b).getItemInSlot(slot) != null) {
b.getWorld().dropItemNaturally(b.getLocation(), BlockStorage.getInventory(b).getItemInSlot(slot));
BlockStorage.getInventory(b).replaceExistingItem(slot, null);
}
} }
return true; return true;
} }