Merge branch 'master' into ChaosBauGUI
Dieser Commit ist enthalten in:
Commit
f00d8324d6
@ -45,28 +45,14 @@ public class CommandFire extends RegionToggleCommand {
|
|||||||
return region.isFire();
|
return region.isFire();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
boolean toggleGlobal() {
|
|
||||||
Region.NoRegion.fire = !Region.NoRegion.fire;
|
|
||||||
return Region.NoRegion.fire;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFireDamage(BlockBurnEvent e) {
|
public void onFireDamage(BlockBurnEvent e) {
|
||||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true);
|
||||||
if (region.isFire()) e.setCancelled(true);
|
|
||||||
}, () -> {
|
|
||||||
if (Region.NoRegion.fire) e.setCancelled(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFireSpread(BlockSpreadEvent e){
|
public void onFireSpread(BlockSpreadEvent e){
|
||||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true);
|
||||||
if (region.isFire()) e.setCancelled(true);
|
|
||||||
}, () -> {
|
|
||||||
if (Region.NoRegion.fire) e.setCancelled(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,112 +48,58 @@ public class CommandFreeze extends RegionToggleCommand {
|
|||||||
return region.isFreeze();
|
return region.isFreeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
boolean toggleGlobal() {
|
|
||||||
Region.NoRegion.freeze = !Region.NoRegion.freeze;
|
|
||||||
return Region.NoRegion.freeze;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||||
Region.getRegion(e.getLocation(), region -> {
|
if (Region.getRegion(e.getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
if (region.isFreeze()) e.setCancelled(true);
|
|
||||||
}, () -> {
|
|
||||||
if (Region.NoRegion.freeze) e.setCancelled(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||||
if (!e.isBuildable()) return;
|
if (!e.isBuildable()) return;
|
||||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
if (!Region.getRegion(e.getBlock().getLocation()).isFreeze()) return;
|
||||||
if (!region.isFreeze()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (e.getMaterial() == Material.TNT) {
|
if (e.getMaterial() == Material.TNT) {
|
||||||
e.setBuildable(false);
|
e.setBuildable(false);
|
||||||
e.getBlock().setType(Material.TNT, false);
|
e.getBlock().setType(Material.TNT, false);
|
||||||
}
|
}
|
||||||
}, () -> {
|
|
||||||
if (!Region.NoRegion.freeze) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (e.getMaterial() == Material.TNT) {
|
|
||||||
e.setBuildable(false);
|
|
||||||
e.getBlock().setType(Material.TNT, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
||||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
if (region.isFreeze()) e.setCancelled(true);
|
|
||||||
}, () -> {
|
|
||||||
if (Region.NoRegion.freeze) e.setCancelled(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPhysicsEvent(BlockPhysicsEvent e){
|
public void onPhysicsEvent(BlockPhysicsEvent e){
|
||||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
if (region.isFreeze()) e.setCancelled(true);
|
|
||||||
}, () -> {
|
|
||||||
if (Region.NoRegion.freeze) e.setCancelled(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPistonExtend(BlockPistonExtendEvent e){
|
public void onPistonExtend(BlockPistonExtendEvent e){
|
||||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
if (region.isFreeze()) e.setCancelled(true);
|
|
||||||
}, () -> {
|
|
||||||
if (Region.NoRegion.freeze) e.setCancelled(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPistonRetract(BlockPistonRetractEvent e){
|
public void onPistonRetract(BlockPistonRetractEvent e){
|
||||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
if (region.isFreeze()) e.setCancelled(true);
|
|
||||||
}, () -> {
|
|
||||||
if (Region.NoRegion.freeze) e.setCancelled(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockGrow(BlockGrowEvent e){
|
public void onBlockGrow(BlockGrowEvent e){
|
||||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
if (region.isFreeze()) e.setCancelled(true);
|
|
||||||
}, () -> {
|
|
||||||
if (Region.NoRegion.freeze) e.setCancelled(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onRedstoneEvent(BlockRedstoneEvent e){
|
public void onRedstoneEvent(BlockRedstoneEvent e){
|
||||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setNewCurrent(e.getOldCurrent());
|
||||||
if (region.isFreeze()) e.setNewCurrent(e.getOldCurrent());
|
|
||||||
}, () -> {
|
|
||||||
if (Region.NoRegion.freeze) e.setNewCurrent(e.getOldCurrent());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockDispense(BlockDispenseEvent e){
|
public void onBlockDispense(BlockDispenseEvent e){
|
||||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
if (region.isFreeze()) e.setCancelled(true);
|
|
||||||
}, () -> {
|
|
||||||
if (Region.NoRegion.freeze) e.setCancelled(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
|
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
|
||||||
Region.getRegion(e.getDestination().getLocation(), region -> {
|
if (Region.getRegion(e.getDestination().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
if (region.isFreeze()) e.setCancelled(true);
|
|
||||||
}, () -> {
|
|
||||||
if (Region.NoRegion.freeze) e.setCancelled(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,11 +42,7 @@ public class CommandInfo implements CommandExecutor {
|
|||||||
|
|
||||||
sender.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName());
|
sender.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName());
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region == null) {
|
|
||||||
sender.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + Region.NoRegion.tnt.getName() + " §eFire§8: " + (Region.NoRegion.fire ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (Region.NoRegion.freeze ? "§aAN" : "§cAUS"));
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.getTntMode().getName() + " §eFire§8: " + (region.isFire() ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (region.isFreeze() ? "§aAN" : "§cAUS"));
|
sender.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.getTntMode().getName() + " §eFire§8: " + (region.isFire() ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (region.isFreeze() ? "§aAN" : "§cAUS"));
|
||||||
}
|
|
||||||
|
|
||||||
List<BauweltMember> members = BauweltMember.getMembers(BauSystem.getOwnerID());
|
List<BauweltMember> members = BauweltMember.getMembers(BauSystem.getOwnerID());
|
||||||
StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: ");
|
StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: ");
|
||||||
|
@ -117,33 +117,10 @@ public class CommandTNT implements CommandExecutor, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region == null) {
|
|
||||||
tntGlobalToggle(requestedMode, requestedMessage);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
tntToggle(region, requestedMode, requestedMessage);
|
tntToggle(region, requestedMode, requestedMessage);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tntGlobalToggle(TNTMode requestedMode, String requestedMessage) {
|
|
||||||
if (requestedMode != null && requestedMode != TNTMode.ONLY_TB) {
|
|
||||||
Region.NoRegion.tnt = requestedMode;
|
|
||||||
RegionToggleCommand.actionBar(requestedMessage);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
switch (Region.NoRegion.tnt) {
|
|
||||||
case ON:
|
|
||||||
case ONLY_TB:
|
|
||||||
Region.NoRegion.tnt = TNTMode.OFF;
|
|
||||||
RegionToggleCommand.actionBar(getDisableMessage());
|
|
||||||
break;
|
|
||||||
case OFF:
|
|
||||||
Region.NoRegion.tnt = TNTMode.ON;
|
|
||||||
RegionToggleCommand.actionBar(getEnableMessage());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
|
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
|
||||||
if (requestedMode != null && region.hasTestblock()) {
|
if (requestedMode != null && region.hasTestblock()) {
|
||||||
region.setTntMode(requestedMode);
|
region.setTntMode(requestedMode);
|
||||||
@ -172,9 +149,6 @@ public class CommandTNT implements CommandExecutor, Listener {
|
|||||||
public void onExplode(EntityExplodeEvent event) {
|
public void onExplode(EntityExplodeEvent event) {
|
||||||
event.blockList().removeIf(block -> {
|
event.blockList().removeIf(block -> {
|
||||||
Region region = Region.getRegion(block.getLocation());
|
Region region = Region.getRegion(block.getLocation());
|
||||||
if (region == null) {
|
|
||||||
return Region.NoRegion.tnt == TNTMode.OFF;
|
|
||||||
}
|
|
||||||
if (region.getTntMode() == TNTMode.OFF) return true;
|
if (region.getTntMode() == TNTMode.OFF) return true;
|
||||||
if (region.getTntMode() == TNTMode.ON) return false;
|
if (region.getTntMode() == TNTMode.ON) return false;
|
||||||
if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) {
|
if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) {
|
||||||
|
@ -52,14 +52,6 @@ public abstract class RegionToggleCommand implements CommandExecutor, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region == null) {
|
|
||||||
if (toggleGlobal()) {
|
|
||||||
actionBar(getEnableMessage());
|
|
||||||
} else {
|
|
||||||
actionBar(getDisableMessage());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (toggle(region)) {
|
if (toggle(region)) {
|
||||||
actionBar(region, getEnableMessage());
|
actionBar(region, getEnableMessage());
|
||||||
} else {
|
} else {
|
||||||
@ -69,11 +61,11 @@ public abstract class RegionToggleCommand implements CommandExecutor, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void actionBar(Region region, String s) {
|
public static void actionBar(Region region, String s) {
|
||||||
|
if (Region.GlobalRegion.isGlobalRegion(region)) {
|
||||||
|
Bukkit.getOnlinePlayers().stream().filter(player -> Region.getRegion(player.getLocation()) == null).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
|
||||||
|
} else {
|
||||||
Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation())).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
|
Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation())).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void actionBar(String s) {
|
|
||||||
Bukkit.getOnlinePlayers().stream().filter(player -> Region.getRegion(player.getLocation()) == null).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract String getNoPermMessage();
|
abstract String getNoPermMessage();
|
||||||
@ -84,6 +76,5 @@ public abstract class RegionToggleCommand implements CommandExecutor, Listener {
|
|||||||
* {@code true} for {@link #getEnableMessage()}, {@code false} for {@link #getDisableMessage()}
|
* {@code true} for {@link #getEnableMessage()}, {@code false} for {@link #getDisableMessage()}
|
||||||
*/
|
*/
|
||||||
abstract boolean toggle(Region region);
|
abstract boolean toggle(Region region);
|
||||||
abstract boolean toggleGlobal();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,15 +60,9 @@ public class BauScoreboard implements Listener {
|
|||||||
strings.add("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()));
|
strings.add("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()));
|
||||||
strings.add("§2");
|
strings.add("§2");
|
||||||
Region region = Region.getRegion(p.getLocation());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
if (region != null) {
|
|
||||||
strings.add("§eTNT§8: " + region.getTntMode().getName());
|
strings.add("§eTNT§8: " + region.getTntMode().getName());
|
||||||
strings.add("§eFreeze§8: " + (region.isFreeze() ? "§aan" : "§caus"));
|
strings.add("§eFreeze§8: " + (region.isFreeze() ? "§aan" : "§caus"));
|
||||||
strings.add("§eFire§8: " + (region.isFire() ? "§aaus" : "§can"));
|
strings.add("§eFire§8: " + (region.isFire() ? "§aaus" : "§can"));
|
||||||
} else {
|
|
||||||
strings.add("§eTNT§8: " + Region.NoRegion.tnt.getName());
|
|
||||||
strings.add("§eFreeze§8: " + (Region.NoRegion.freeze ? "§aan" : "§caus"));
|
|
||||||
strings.add("§eFire§8: " + (Region.NoRegion.fire ? "§aaus" : "§can"));
|
|
||||||
}
|
|
||||||
strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName());
|
strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName());
|
||||||
strings.add("§eLoader§8: " + (AutoLoader.hasLoader(p) ? "§aan" : "§caus"));
|
strings.add("§eLoader§8: " + (AutoLoader.hasLoader(p) ? "§aan" : "§caus"));
|
||||||
|
|
||||||
|
@ -41,13 +41,6 @@ public class Region {
|
|||||||
private static final List<Region> regions = new ArrayList<>();
|
private static final List<Region> regions = new ArrayList<>();
|
||||||
private static boolean buildArea = false;
|
private static boolean buildArea = false;
|
||||||
|
|
||||||
public static class NoRegion {
|
|
||||||
private NoRegion() {}
|
|
||||||
public static TNTMode tnt = TNTMode.OFF;
|
|
||||||
public static boolean fire = false;
|
|
||||||
public static boolean freeze = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static{
|
static{
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
try {
|
try {
|
||||||
@ -77,18 +70,7 @@ public class Region {
|
|||||||
for (Region region : regions) {
|
for (Region region : regions) {
|
||||||
if (region.inRegion(location)) return region;
|
if (region.inRegion(location)) return region;
|
||||||
}
|
}
|
||||||
return null;
|
return GlobalRegion.getInstance();
|
||||||
}
|
|
||||||
|
|
||||||
public static void getRegion(Location location, Consumer<Region> regionConsumer, Runnable noRegion) {
|
|
||||||
boolean b = true;
|
|
||||||
for (Region region : regions) {
|
|
||||||
if (region.inRegion(location)) {
|
|
||||||
regionConsumer.accept(region);
|
|
||||||
b = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (b) noRegion.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
@ -114,6 +96,16 @@ public class Region {
|
|||||||
regions.add(this);
|
regions.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Region(String name) {
|
||||||
|
this.name = name;
|
||||||
|
this.minX = 0;
|
||||||
|
this.minY = 0;
|
||||||
|
this.minZ = 0;
|
||||||
|
this.prototype = null;
|
||||||
|
this.optionsLinkedWith = null;
|
||||||
|
tntMode = TNTMode.OFF;
|
||||||
|
}
|
||||||
|
|
||||||
private void setLinkedRegion(Consumer<Region> regionConsumer) {
|
private void setLinkedRegion(Consumer<Region> regionConsumer) {
|
||||||
if (optionsLinkedWith == null) {
|
if (optionsLinkedWith == null) {
|
||||||
return;
|
return;
|
||||||
@ -194,6 +186,49 @@ public class Region {
|
|||||||
prototype.protect(this, schem);
|
prototype.protect(this, schem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class GlobalRegion extends Region {
|
||||||
|
|
||||||
|
private static final GlobalRegion GLOBAL_REGION = new GlobalRegion();
|
||||||
|
|
||||||
|
public static GlobalRegion getInstance() {
|
||||||
|
return GLOBAL_REGION;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isGlobalRegion(Region region) {
|
||||||
|
return region == GLOBAL_REGION;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GlobalRegion() {
|
||||||
|
super("Global");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean inRegion(Location l) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasBuildRegion() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean inBuildRegion(Location l) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasTestblock() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasProtection() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static class Prototype{
|
public static class Prototype{
|
||||||
private static final Map<String, Prototype> prototypes = new HashMap<>();
|
private static final Map<String, Prototype> prototypes = new HashMap<>();
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren