TntMode #163
@ -82,6 +82,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
getCommand("reset").setExecutor(new CommandReset());
|
||||
getCommand("speed").setExecutor(new CommandSpeed());
|
||||
getCommand("tnt").setExecutor(new CommandTNT());
|
||||
getCommand("buildmode").setExecutor(new CommandBuildMode());
|
||||
getCommand("fire").setExecutor(new CommandFire());
|
||||
getCommand("freeze").setExecutor(new CommandFreeze());
|
||||
getCommand("testblock").setExecutor(new CommandTestblock());
|
||||
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
*
|
||||
* 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.world.Region;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
public class CommandBuildMode extends ToggleCommand {
|
||||
|
||||
public CommandBuildMode() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
public static ToggleCommand getInstance() {
|
||||
return getInstance(CommandBuildMode.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
String getNoPermMessage() {
|
||||
return "§cDu darfst hier den Build mode nicht (de-)aktivieren";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getEnableMessage() {
|
||||
return "§aBuild mode aktiviert";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getDisableMessage() {
|
||||
return "§cBuild mode deaktiviert";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player))
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
if (!CommandTNT.getInstance().isOn()) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cUm den Build mode zu nutzen muss TNT an sein.");
|
||||
return false;
|
||||
}
|
||||
return super.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
|
||||
boolean blocksDestroyed = event.blockList().removeIf(block -> {
|
||||
for (Region region : Region.getRegions()) {
|
||||
if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (!blocksDestroyed) {
|
||||
return;
|
||||
}
|
||||
Bukkit.getOnlinePlayers().forEach(player -> player.sendMessage(BauSystem.PREFIX + "§cEs ist etwas explodiert und hätte blöcke zerstört."));
|
||||
}
|
||||
|
||||
}
|
@ -45,6 +45,14 @@ public class CommandTNT extends ToggleCommand {
|
||||
return "§aTNT-Schaden aktiviert";
|
||||
}
|
||||
Lixfel
hat
Nur Testblock ist ja so nicht ganz richtig. Ist ja eher ein Nicht Baubereich (klingt aber beschissen). Evtl. fällt uns da noch was besseres ein. Nur Testblock ist ja so nicht ganz richtig. Ist ja eher ein Nicht Baubereich (klingt aber beschissen). Evtl. fällt uns da noch was besseres ein.
YoyoNow
hat
Wie würdest du das dann nennen? Wie würdest du das dann nennen?
|
||||
|
||||
@Override
|
||||
public void toggle() {
|
||||
if (CommandBuildMode.getInstance().isOn()) {
|
||||
CommandBuildMode.getInstance().toggle();
|
||||
}
|
||||
super.toggle();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent e) {
|
||||
e.blockList().clear();
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
import de.steamwar.bausystem.commands.CommandBuildMode;
|
||||
import de.steamwar.bausystem.commands.CommandFreeze;
|
||||
import de.steamwar.bausystem.commands.CommandTNT;
|
||||
import de.steamwar.bausystem.commands.CommandTPSLimiter;
|
||||
@ -61,7 +62,7 @@ public class BauScoreboard implements Listener {
|
||||
strings.add("§1");
|
||||
strings.add("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()));
|
||||
strings.add("§2");
|
||||
strings.add("§eTNT§8: " + (!CommandTNT.getInstance().isOn() ? "§aan" : "§caus"));
|
||||
strings.add("§eTNT§8: " + tntString());
|
||||
strings.add("§eFreeze§8: " + (CommandFreeze.getInstance().isOn() ? "§aan" : "§caus"));
|
||||
strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName());
|
||||
strings.add("§eLoader§8: " + (AutoLoader.hasLoader(p) ? "§aan" : "§caus"));
|
||||
@ -104,4 +105,14 @@ public class BauScoreboard implements Listener {
|
||||
return "§8/§7" + CommandTPSLimiter.getCurrentTPSLimit();
|
||||
}
|
||||
|
||||
private String tntString() {
|
||||
Lixfel
hat
Würde das ganze im TNTCommand eher über ein Switch/case mit Enum lösen. Würde das ganze im TNTCommand eher über ein Switch/case mit Enum lösen.
|
||||
if (!CommandTNT.getInstance().isOn()) {
|
||||
if (CommandBuildMode.getInstance().isOn()) {
|
||||
return "§eTestblock";
|
||||
}
|
||||
return "§aan";
|
||||
}
|
||||
return "§caus";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -80,6 +80,14 @@ public class Region {
|
||||
return prototype.inRegion(this, l);
|
||||
}
|
||||
|
||||
public boolean hasBuildRegion() {
|
||||
return prototype.buildArea != null;
|
||||
}
|
||||
|
||||
public boolean inBuildRegion(Location l) {
|
||||
return prototype.buildArea.inRegion(this, l);
|
||||
}
|
||||
|
||||
public void fastreset(){
|
||||
prototype.fastreset(this);
|
||||
}
|
||||
@ -101,7 +109,8 @@ public class Region {
|
||||
}
|
||||
|
||||
public static class Prototype{
|
||||
private static final String SECTION_PATH = "/home/minecraft/backbone/server/UserBau/";
|
||||
// private static final String SECTION_PATH = "/home/minecraft/backbone/server/UserBau/";
|
||||
private static final String SECTION_PATH = "/home/yoyonow/Dev1.15//UserBau/f75632be-e3ec-4069-9bec-d13ac6891177/";
|
||||
private static final Map<String, Prototype> prototypes = new HashMap<>();
|
||||
|
||||
private final int sizeX;
|
||||
@ -116,6 +125,8 @@ public class Region {
|
||||
private final boolean rotate;
|
||||
|
||||
private final Prototype testblock; //nullable
|
||||
private final Prototype buildArea; //nullable
|
||||
|
||||
private final String protectSchematic; //nullable
|
||||
|
||||
private Prototype(ConfigurationSection config){
|
||||
@ -130,9 +141,13 @@ public class Region {
|
||||
|
||||
ConfigurationSection testblockSection = config.getConfigurationSection("testblock");
|
||||
testblock = testblockSection != null ? new Prototype(testblockSection) : null;
|
||||
|
||||
ConfigurationSection buildAreaSection = config.getConfigurationSection("buildArea");
|
||||
buildArea = buildAreaSection != null ? new Prototype(buildAreaSection) : null;
|
||||
|
||||
protectSchematic = config.getString("protection", null);
|
||||
|
||||
if(!config.getName().equals("testblock"))
|
||||
if(!config.getName().equals("testblock") && !config.getName().equals("buildArea"))
|
||||
prototypes.put(config.getName(), this);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ commands:
|
||||
debugstick:
|
||||
tnt:
|
||||
fire:
|
||||
buildmode:
|
||||
trace:
|
||||
tpslimit:
|
||||
testblock:
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Ich würde genau dies nicht machen, da ich nicht möchte, das man nach 5 Sekunden oder so nicht mehr weiß ob es explodiert ist oder so.
Derzeit weißt du es bei "aus" nie. UND: Wenn du dann 100 Messages bekommst, weil .... Auch 10 sind schon nervig.