Merge branch 'master' into ChaosBauGUI
# Conflicts: # BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java # BauSystem_Main/src/de/steamwar/bausystem/commands/CommandTNT.java # BauSystem_Main/src/de/steamwar/bausystem/world/Region.java
Dieser Commit ist enthalten in:
Commit
a7df81aca5
@ -19,19 +19,12 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.world.Region;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.block.BlockBurnEvent;
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
import org.bukkit.event.block.BlockSpreadEvent;
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
|
|
||||||
public class CommandFire extends ToggleCommand {
|
public class CommandFire extends RegionToggleCommand {
|
||||||
|
|
||||||
public CommandFire(){
|
|
||||||
super(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ToggleCommand getInstance(){
|
|
||||||
return getInstance(CommandFire.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getNoPermMessage() {
|
String getNoPermMessage() {
|
||||||
@ -46,14 +39,34 @@ public class CommandFire extends ToggleCommand {
|
|||||||
return "§aFeuerschaden aktiviert";
|
return "§aFeuerschaden aktiviert";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean toggle(Region region) {
|
||||||
|
region.setFire(!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) {
|
||||||
e.setCancelled(true);
|
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||||
|
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){
|
||||||
e.setCancelled(true);
|
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||||
|
if (region.isFire()) e.setCancelled(true);
|
||||||
|
}, () -> {
|
||||||
|
if (Region.NoRegion.fire) e.setCancelled(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,21 +19,15 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.world.Region;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.block.*;
|
import org.bukkit.event.block.*;
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||||
|
|
||||||
public class CommandFreeze extends ToggleCommand {
|
public class CommandFreeze extends RegionToggleCommand {
|
||||||
|
|
||||||
public CommandFreeze(){
|
|
||||||
super(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ToggleCommand getInstance(){
|
|
||||||
return getInstance(CommandFreeze.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getNoPermMessage() {
|
String getNoPermMessage() {
|
||||||
@ -48,48 +42,118 @@ public class CommandFreeze extends ToggleCommand {
|
|||||||
return "§aWelt aufgetaut";
|
return "§aWelt aufgetaut";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean toggle(Region region) {
|
||||||
|
region.setFreeze(!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) {
|
||||||
e.setCancelled(true);
|
Region.getRegion(e.getLocation(), region -> {
|
||||||
|
if (region.isFreeze()) e.setCancelled(true);
|
||||||
|
}, () -> {
|
||||||
|
if (Region.NoRegion.freeze) e.setCancelled(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||||
|
if (!e.isBuildable()) return;
|
||||||
|
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||||
|
if (!region.isFreeze()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.getMaterial() == Material.TNT) {
|
||||||
|
e.setBuildable(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) {
|
||||||
e.setCancelled(true);
|
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||||
|
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){
|
||||||
e.setCancelled(true);
|
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||||
|
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){
|
||||||
e.setCancelled(true);
|
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||||
|
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){
|
||||||
e.setCancelled(true);
|
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||||
|
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){
|
||||||
e.setCancelled(true);
|
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||||
|
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){
|
||||||
e.setNewCurrent(e.getOldCurrent());
|
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||||
|
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){
|
||||||
e.setCancelled(true);
|
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||||
|
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){
|
||||||
e.setCancelled(true);
|
Region.getRegion(e.getDestination().getLocation(), region -> {
|
||||||
|
if (region.isFreeze()) e.setCancelled(true);
|
||||||
|
}, () -> {
|
||||||
|
if (Region.NoRegion.freeze) e.setCancelled(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,14 @@
|
|||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.world.Region;
|
||||||
import de.steamwar.core.TPSWatcher;
|
import de.steamwar.core.TPSWatcher;
|
||||||
import de.steamwar.sql.BauweltMember;
|
import de.steamwar.sql.BauweltMember;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -33,10 +35,18 @@ public class CommandInfo implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
sender.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName());
|
sender.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName());
|
||||||
sender.sendMessage(BauSystem.PREFIX + "TNT-Schaden: " + CommandTNT.getTntMode().getName());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
sender.sendMessage(BauSystem.PREFIX + "Feuerschaden: " + (CommandFire.getInstance().isOn() ? "§aAUS" : "§cAN"));
|
if (region == null) {
|
||||||
sender.sendMessage(BauSystem.PREFIX + "Eingefroren: " + (CommandFreeze.getInstance().isOn() ? "§aJA" : "§cNEIN"));
|
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"));
|
||||||
|
}
|
||||||
|
|
||||||
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: ");
|
||||||
|
@ -45,8 +45,11 @@ public class CommandProtect implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Region region : Region.getRegions()){
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if(region.inRegion(player.getLocation()) && region.hasProtection()){
|
if (region == null || !region.hasProtection()) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner (M)WG-Region");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Schematic schem = null;
|
Schematic schem = null;
|
||||||
if(args.length > 0){
|
if(args.length > 0){
|
||||||
@ -64,9 +67,4 @@ public class CommandProtect implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner (M)WG-Region");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,11 @@ public class CommandReset implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Region region : Region.getRegions()){
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if(region.inRegion(player.getLocation())){
|
if (region == null) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if(args.length > 0){
|
if(args.length > 0){
|
||||||
Schematic schem = Schematic.getSchemFromDB(args[0], player.getUniqueId());
|
Schematic schem = Schematic.getSchemFromDB(args[0], player.getUniqueId());
|
||||||
@ -65,9 +68,4 @@ public class CommandReset implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,6 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.world.Region;
|
import de.steamwar.bausystem.world.Region;
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -42,13 +40,9 @@ public class CommandTNT implements CommandExecutor, Listener {
|
|||||||
return tntMode;
|
return tntMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setTntMode(TNTMode tntMode) {
|
|
||||||
CommandTNT.tntMode = tntMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum TNTMode {
|
public enum TNTMode {
|
||||||
ON("§aan"),
|
ON("§aan"),
|
||||||
ONLY_TB("§7nur §eTestblock"),
|
ONLY_TB("§7Kein §eBaurahmen"),
|
||||||
OFF("§caus");
|
OFF("§caus");
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
@ -80,7 +74,7 @@ public class CommandTNT implements CommandExecutor, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getTestblockEnableMessage() {
|
private String getTestblockEnableMessage() {
|
||||||
return "§aTNT-Schaden am Testblock aktiviert";
|
return "§aTNT-Schaden außerhalb Baurahmen aktiviert";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDamageMessage() {
|
private String getDamageMessage() {
|
||||||
@ -97,74 +91,98 @@ public class CommandTNT implements CommandExecutor, Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TNTMode requestedMode = null;
|
||||||
|
String requestedMessage = null;
|
||||||
if (args.length != 0) {
|
if (args.length != 0) {
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "an":
|
case "an":
|
||||||
case "on":
|
case "on":
|
||||||
tntMode = TNTMode.ON;
|
requestedMode = TNTMode.ON;
|
||||||
sendToActionBar(getEnableMessage());
|
requestedMessage = getEnableMessage();
|
||||||
return false;
|
break;
|
||||||
case "aus":
|
case "aus":
|
||||||
case "off":
|
case "off":
|
||||||
tntMode = TNTMode.OFF;
|
requestedMode = TNTMode.OFF;
|
||||||
sendToActionBar(getDisableMessage());
|
requestedMessage = getDisableMessage();
|
||||||
return false;
|
break;
|
||||||
case "testblock":
|
case "testblock":
|
||||||
case "tb":
|
case "tb":
|
||||||
if (!Region.buildAreaEnabled()) break;
|
if (!Region.buildAreaEnabled()) break;
|
||||||
tntMode = TNTMode.ONLY_TB;
|
requestedMode = TNTMode.ONLY_TB;
|
||||||
sendToActionBar(getTestblockEnableMessage());
|
requestedMessage = getTestblockEnableMessage();
|
||||||
return false;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (tntMode) {
|
Region region = Region.getRegion(player.getLocation());
|
||||||
|
if (region == null) {
|
||||||
|
tntGlobalToggle(requestedMode, requestedMessage);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
tntToggle(region, requestedMode, requestedMessage);
|
||||||
|
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 ON:
|
||||||
case ONLY_TB:
|
case ONLY_TB:
|
||||||
tntMode = TNTMode.OFF;
|
Region.NoRegion.tnt = TNTMode.OFF;
|
||||||
sendToActionBar(getDisableMessage());
|
RegionToggleCommand.actionBar(getDisableMessage());
|
||||||
break;
|
break;
|
||||||
case OFF:
|
case OFF:
|
||||||
if (Region.buildAreaEnabled()) {
|
Region.NoRegion.tnt = TNTMode.ON;
|
||||||
tntMode = TNTMode.ONLY_TB;
|
RegionToggleCommand.actionBar(getEnableMessage());
|
||||||
sendToActionBar(getTestblockEnableMessage());
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
|
||||||
|
if (requestedMode != null && region.hasTestblock()) {
|
||||||
|
region.setTntMode(requestedMode);
|
||||||
|
RegionToggleCommand.actionBar(region, requestedMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (region.getTntMode()) {
|
||||||
|
case ON:
|
||||||
|
case ONLY_TB:
|
||||||
|
region.setTntMode(TNTMode.OFF);
|
||||||
|
RegionToggleCommand.actionBar(region, getDisableMessage());
|
||||||
|
break;
|
||||||
|
case OFF:
|
||||||
|
if (Region.buildAreaEnabled() && region.hasTestblock()) {
|
||||||
|
region.setTntMode(TNTMode.ONLY_TB);
|
||||||
|
RegionToggleCommand.actionBar(region, getTestblockEnableMessage());
|
||||||
} else {
|
} else {
|
||||||
tntMode = TNTMode.ON;
|
region.setTntMode(TNTMode.ON);
|
||||||
sendToActionBar(getEnableMessage());
|
RegionToggleCommand.actionBar(region, getEnableMessage());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onExplode(EntityExplodeEvent event) {
|
public void onExplode(EntityExplodeEvent event) {
|
||||||
switch (tntMode) {
|
event.blockList().removeIf(block -> {
|
||||||
case ON:
|
Region region = Region.getRegion(block.getLocation());
|
||||||
break;
|
if (region == null) {
|
||||||
case OFF:
|
return Region.NoRegion.tnt == TNTMode.OFF;
|
||||||
event.blockList().clear();
|
|
||||||
break;
|
|
||||||
case ONLY_TB:
|
|
||||||
boolean blocksDestroyed = event.blockList().removeIf(block -> {
|
|
||||||
for (Region region : Region.getRegions()) {
|
|
||||||
if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
if (region.getTntMode() == TNTMode.OFF) return true;
|
||||||
|
if (region.getTntMode() == TNTMode.ON) return false;
|
||||||
|
if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) {
|
||||||
|
RegionToggleCommand.actionBar(region, getDamageMessage());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
if (blocksDestroyed) {
|
|
||||||
sendToActionBar(getDamageMessage());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendToActionBar(String message) {
|
|
||||||
Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,11 @@ public class CommandTestblock implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Region region : Region.getRegions()){
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if(region.inRegion(player.getLocation()) && region.hasTestblock()){
|
if (region == null || !region.hasTestblock()) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Schematic schem = null;
|
Schematic schem = null;
|
||||||
if(args.length > 0){
|
if(args.length > 0){
|
||||||
@ -64,9 +67,4 @@ public class CommandTestblock implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
* /
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.world.Region;
|
||||||
|
import de.steamwar.bausystem.world.Welt;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public abstract class RegionToggleCommand implements CommandExecutor, Listener {
|
||||||
|
|
||||||
|
public RegionToggleCommand() {
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player))
|
||||||
|
return false;
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (Welt.noPermission(player, Permission.world)){
|
||||||
|
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Region region = Region.getRegion(player.getLocation());
|
||||||
|
if (region == null) {
|
||||||
|
if (toggleGlobal()) {
|
||||||
|
actionBar(getEnableMessage());
|
||||||
|
} else {
|
||||||
|
actionBar(getDisableMessage());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (toggle(region)) {
|
||||||
|
actionBar(region, getEnableMessage());
|
||||||
|
} else {
|
||||||
|
actionBar(region, getDisableMessage());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void actionBar(Region region, String 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 getEnableMessage();
|
||||||
|
abstract String getDisableMessage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code true} for {@link #getEnableMessage()}, {@code false} for {@link #getDisableMessage()}
|
||||||
|
*/
|
||||||
|
abstract boolean toggle(Region region);
|
||||||
|
abstract boolean toggleGlobal();
|
||||||
|
|
||||||
|
}
|
@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.world.Welt;
|
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public abstract class ToggleCommand implements CommandExecutor, Listener {
|
|
||||||
|
|
||||||
private static Map<Class<? extends ToggleCommand>, Boolean> enabled = new HashMap<>();
|
|
||||||
private static Map<Class<? extends ToggleCommand>, ToggleCommand> instance = new HashMap<>();
|
|
||||||
|
|
||||||
ToggleCommand(boolean on){
|
|
||||||
enabled.put(getClass(), false);
|
|
||||||
if(on)
|
|
||||||
toggle();
|
|
||||||
instance.put(getClass(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if(!(sender instanceof Player))
|
|
||||||
return false;
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (Welt.noPermission(player, Permission.world)){
|
|
||||||
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
toggle();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ToggleCommand getInstance(Class<? extends ToggleCommand> clazz){
|
|
||||||
return instance.get(clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract String getNoPermMessage();
|
|
||||||
abstract String getEnableMessage();
|
|
||||||
abstract String getDisableMessage();
|
|
||||||
|
|
||||||
public boolean isOn(){
|
|
||||||
return enabled.get(getClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggle(){
|
|
||||||
enabled.compute(getClass(), (clazz, value) -> !value);
|
|
||||||
if(enabled.get(getClass())){
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(getEnableMessage())));
|
|
||||||
}else{
|
|
||||||
HandlerList.unregisterAll(this);
|
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(getDisableMessage())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
import de.steamwar.bausystem.commands.CommandFreeze;
|
|
||||||
import de.steamwar.bausystem.commands.CommandTNT;
|
|
||||||
import de.steamwar.bausystem.commands.CommandTPSLimiter;
|
import de.steamwar.bausystem.commands.CommandTPSLimiter;
|
||||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||||
import de.steamwar.core.TPSWatcher;
|
import de.steamwar.core.TPSWatcher;
|
||||||
@ -61,8 +59,16 @@ public class BauScoreboard implements Listener {
|
|||||||
strings.add("§1");
|
strings.add("§1");
|
||||||
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");
|
||||||
strings.add("§eTNT§8: " + CommandTNT.getTntMode().getName());
|
Region region = Region.getRegion(p.getLocation());
|
||||||
strings.add("§eFreeze§8: " + (CommandFreeze.getInstance().isOn() ? "§aan" : "§caus"));
|
if (region != null) {
|
||||||
|
strings.add("§eTNT§8: " + region.getTntMode().getName());
|
||||||
|
strings.add("§eFreeze§8: " + (region.isFreeze() ? "§aan" : "§caus"));
|
||||||
|
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"));
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
|
import de.steamwar.bausystem.commands.CommandTNT.TNTMode;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
@ -32,6 +33,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Region {
|
public class Region {
|
||||||
@ -39,8 +41,11 @@ 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 boolean buildAreaEnabled() {
|
public static class NoRegion {
|
||||||
return buildArea;
|
private NoRegion() {}
|
||||||
|
public static TNTMode tnt = TNTMode.OFF;
|
||||||
|
public static boolean fire = false;
|
||||||
|
public static boolean freeze = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static{
|
static{
|
||||||
@ -64,32 +69,95 @@ public class Region {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Region> getRegions(){
|
public static boolean buildAreaEnabled() {
|
||||||
return regions;
|
return buildArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Region getRegionIn(Location location) {
|
public static Region getRegion(Location location) {
|
||||||
for(Region region : Region.getRegions()) {
|
for (Region region : regions) {
|
||||||
if (region.inRegion(location)) {
|
if (region.inRegion(location)) return region;
|
||||||
return region;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 int minX;
|
private final int minX;
|
||||||
private final int minY;
|
private final int minY;
|
||||||
private final int minZ;
|
private final int minZ;
|
||||||
private final Prototype prototype;
|
private final Prototype prototype;
|
||||||
|
private final String optionsLinkedWith; // nullable
|
||||||
|
private Region linkedRegion = null; // nullable
|
||||||
|
|
||||||
|
private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF;
|
||||||
|
private boolean freeze = false;
|
||||||
|
private boolean fire = false;
|
||||||
|
|
||||||
private Region(ConfigurationSection config){
|
private Region(ConfigurationSection config){
|
||||||
|
name = config.getName();
|
||||||
minX = config.getInt("minX");
|
minX = config.getInt("minX");
|
||||||
minY = config.getInt("minY");
|
minY = config.getInt("minY");
|
||||||
minZ = config.getInt("minZ");
|
minZ = config.getInt("minZ");
|
||||||
prototype = Prototype.prototypes.get(config.getString("prototype"));
|
prototype = Prototype.prototypes.get(config.getString("prototype"));
|
||||||
|
optionsLinkedWith = config.getString("optionsLinkedWith", null);
|
||||||
|
if (!hasTestblock()) tntMode = TNTMode.OFF;
|
||||||
regions.add(this);
|
regions.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setLinkedRegion(Consumer<Region> regionConsumer) {
|
||||||
|
if (optionsLinkedWith == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (linkedRegion != null) {
|
||||||
|
regionConsumer.accept(linkedRegion);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Region region : regions) {
|
||||||
|
if (region.name.equals(name)) {
|
||||||
|
linkedRegion = region;
|
||||||
|
regionConsumer.accept(linkedRegion);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TNTMode getTntMode() {
|
||||||
|
return tntMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTntMode(TNTMode tntMode) {
|
||||||
|
this.tntMode = tntMode;
|
||||||
|
setLinkedRegion(region -> region.tntMode = tntMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFreeze() {
|
||||||
|
return freeze;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFreeze(boolean freeze) {
|
||||||
|
this.freeze = freeze;
|
||||||
|
setLinkedRegion(region -> region.freeze = freeze);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFire() {
|
||||||
|
return fire;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFire(boolean fire) {
|
||||||
|
this.fire = fire;
|
||||||
|
setLinkedRegion(region -> region.fire = fire);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean inRegion(Location l){
|
public boolean inRegion(Location l){
|
||||||
return prototype.inRegion(this, l);
|
return prototype.inRegion(this, l);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockCanBuildEvent;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
@ -71,13 +71,13 @@ public class RegionListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onBlockPlace(BlockPlaceEvent e) {
|
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
if (Welt.noPermission(p, Permission.build)){
|
if (Welt.noPermission(p, Permission.build)){
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren");
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren");
|
||||||
e.setCancelled(true);
|
e.setBuildable(false);
|
||||||
}
|
}
|
||||||
}catch(NullPointerException ex){
|
}catch(NullPointerException ex){
|
||||||
//ignored, caused by worldedit brushes
|
//ignored, caused by worldedit brushes
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.commands.CommandFire;
|
|
||||||
import de.steamwar.bausystem.commands.CommandFreeze;
|
|
||||||
import de.steamwar.bausystem.commands.CommandScript;
|
import de.steamwar.bausystem.commands.CommandScript;
|
||||||
import de.steamwar.bausystem.commands.CommandTNT;
|
import de.steamwar.bausystem.commands.CommandTNT;
|
||||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||||
@ -153,6 +151,8 @@ public class ScriptListener implements Listener {
|
|||||||
index = ifJumpIndex;
|
index = ifJumpIndex;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(player, "/" + command);
|
PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(player, "/" + command);
|
||||||
@ -235,6 +235,8 @@ public class ScriptListener implements Listener {
|
|||||||
case "--":
|
case "--":
|
||||||
add(scriptExecutor, args[0], -1);
|
add(scriptExecutor, args[0], -1);
|
||||||
return;
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
setValue(scriptExecutor, args[0], args[1]);
|
setValue(scriptExecutor, args[0], args[1]);
|
||||||
}
|
}
|
||||||
@ -280,18 +282,20 @@ public class ScriptListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int getValue(ScriptExecutor scriptExecutor, String key) {
|
private static int getValue(ScriptExecutor scriptExecutor, String key) {
|
||||||
|
Region region = Region.getRegion(scriptExecutor.player.getLocation());
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "trace":
|
case "trace":
|
||||||
return RecordStateMachine.getRecordStatus().isTracing() ? 1 : 0;
|
return RecordStateMachine.getRecordStatus().isTracing() ? 1 : 0;
|
||||||
case "tnt":
|
case "tnt":
|
||||||
return CommandTNT.getTntMode() == CommandTNT.TNTMode.OFF ? 0 : 1;
|
return region == null || region.getTntMode() == CommandTNT.TNTMode.OFF ? 0 : 1;
|
||||||
case "freeze":
|
case "freeze":
|
||||||
return CommandFreeze.getInstance().isOn() ? 1 : 0;
|
return region == null || !region.isFreeze() ? 0 : 1;
|
||||||
case "fire":
|
case "fire":
|
||||||
return CommandFire.getInstance().isOn() ? 1 : 0;
|
return region == null || !region.isFire() ? 0 : 1;
|
||||||
}
|
default:
|
||||||
return scriptExecutor.variables.getOrDefault(key, 0);
|
return scriptExecutor.variables.getOrDefault(key, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isVariable(ScriptExecutor scriptExecutor, String key) {
|
private static boolean isVariable(ScriptExecutor scriptExecutor, String key) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
name: BauSystem
|
name: BauSystem
|
||||||
author: Lixfel
|
authors: [Lixfel, YoyoNow, Chaoscaot]
|
||||||
version: "1.0"
|
version: "1.0"
|
||||||
depend: [WorldEdit, SpigotCore, ProtocolLib]
|
depend: [WorldEdit, SpigotCore, ProtocolLib]
|
||||||
load: POSTWORLD
|
load: POSTWORLD
|
||||||
main: de.steamwar.bausystem.BauSystem
|
main: de.steamwar.bausystem.BauSystem
|
||||||
api-version: "1.13"
|
api-version: "1.13"
|
||||||
|
website: "https://steamwar.de"
|
||||||
|
description: "So unseriös wie wir sind: BauSystem nur besser."
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
debugstick:
|
debugstick:
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren