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