Resolve issue with explosion cancelling leaving invalid gates (Data
values) Check blockBreakEvents for gate entrance blocks is protectEntrance is enabled (More intensive than regular check. Only enable if required)
This commit is contained in:
parent
b63faca109
commit
dcc978a07e
@ -38,6 +38,8 @@ chargefreedestination: true
|
||||
freegatesgreen: false
|
||||
# Whether to sort network lists alphabetically
|
||||
sortLists: false
|
||||
# Whether to protect gate entrance material
|
||||
protectEntrance: false
|
||||
|
||||
# Debug -- Only enable if you have issues, massive console output
|
||||
debug: false
|
||||
|
@ -3,10 +3,18 @@ package net.TheDgtl.Stargate;
|
||||
public class BloxPopulator {
|
||||
private Blox blox;
|
||||
private int nextMat;
|
||||
private byte nextData;
|
||||
|
||||
public BloxPopulator(Blox b, int m) {
|
||||
blox = b;
|
||||
nextMat = m;
|
||||
nextData = 0;
|
||||
}
|
||||
|
||||
public BloxPopulator(Blox b, int m, byte d) {
|
||||
blox = b;
|
||||
nextMat = m;
|
||||
nextData = d;
|
||||
}
|
||||
|
||||
public void setBlox(Blox b) {
|
||||
@ -17,6 +25,10 @@ public class BloxPopulator {
|
||||
nextMat = m;
|
||||
}
|
||||
|
||||
public void setData(byte d) {
|
||||
nextData = d;
|
||||
}
|
||||
|
||||
public Blox getBlox() {
|
||||
return blox;
|
||||
}
|
||||
@ -25,4 +37,8 @@ public class BloxPopulator {
|
||||
return nextMat;
|
||||
}
|
||||
|
||||
public byte getData() {
|
||||
return nextData;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -337,7 +337,6 @@ public class Portal {
|
||||
Portal end = getDestination();
|
||||
// Only open dest if it's not-fixed or points at this gate
|
||||
if (end != null && (!end.isFixed() || end.getDestinationName().equalsIgnoreCase(getName())) && !end.isOpen()) {
|
||||
Stargate.debug("portal::open", "Ver: " + end.isVerified());
|
||||
end.open(openFor, false);
|
||||
end.setDestination(this);
|
||||
if (end.isVerified()) end.drawSign();
|
||||
|
@ -94,6 +94,7 @@ public class Stargate extends JavaPlugin {
|
||||
public static boolean destMemory = false;
|
||||
public static boolean handleVehicles = true;
|
||||
public static boolean sortLists = false;
|
||||
public static boolean protectEntrance = false;
|
||||
|
||||
// Temp workaround for snowmen, don't check gate entrance
|
||||
public static boolean ignoreEntrance = false;
|
||||
@ -177,6 +178,7 @@ public class Stargate extends JavaPlugin {
|
||||
ignoreEntrance = newConfig.getBoolean("ignoreEntrance");
|
||||
handleVehicles = newConfig.getBoolean("handleVehicles");
|
||||
sortLists = newConfig.getBoolean("sortLists");
|
||||
protectEntrance = newConfig.getBoolean("protectEntrance");
|
||||
// Debug
|
||||
debug = newConfig.getBoolean("debug");
|
||||
permDebug = newConfig.getBoolean("permdebug");
|
||||
@ -895,11 +897,10 @@ public class Stargate extends JavaPlugin {
|
||||
if (event.isCancelled()) return;
|
||||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
if (block.getType() != Material.WALL_SIGN && block.getType() != Material.STONE_BUTTON && !Gate.isGateBlock(block.getTypeId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Portal portal = Portal.getByBlock(block);
|
||||
if (portal == null && protectEntrance)
|
||||
portal = Portal.getByEntrance(block);
|
||||
if (portal == null) return;
|
||||
|
||||
boolean deny = false;
|
||||
@ -1002,13 +1003,12 @@ public class Stargate extends JavaPlugin {
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
for (Block b : event.blockList()) {
|
||||
if (b.getType() != Material.WALL_SIGN && b.getType() != Material.STONE_BUTTON && !Gate.isGateBlock(b.getTypeId())) continue;
|
||||
Portal portal = Portal.getByBlock(b);
|
||||
if (portal == null) continue;
|
||||
if (destroyExplosion) {
|
||||
portal.unregister(true);
|
||||
} else {
|
||||
b.setType(b.getType());
|
||||
Stargate.blockPopulatorQueue.add(new BloxPopulator(new Blox(b), b.getTypeId(), b.getData()));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -1146,6 +1146,7 @@ public class Stargate extends JavaPlugin {
|
||||
BloxPopulator b = Stargate.blockPopulatorQueue.poll();
|
||||
if (b == null) return;
|
||||
b.getBlox().getBlock().setTypeId(b.getMat());
|
||||
b.getBlox().getBlock().setData(b.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user