SteamWar/BauSystem
Archiviert
13
0

Add CommandBuildMode

Dieser Commit ist enthalten in:
jojo 2021-01-20 11:04:46 +01:00
Ursprung 1afa2b9242
Commit a22e1d37b9
6 geänderte Dateien mit 125 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -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());

Datei anzeigen

@ -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."));
}
}

Datei anzeigen

@ -45,6 +45,14 @@ public class CommandTNT extends ToggleCommand {
return "§aTNT-Schaden aktiviert";
}
@Override
public void toggle() {
if (CommandBuildMode.getInstance().isOn()) {
CommandBuildMode.getInstance().toggle();
}
super.toggle();
}
@EventHandler
public void onExplode(EntityExplodeEvent e) {
e.blockList().clear();

Datei anzeigen

@ -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() {
if (!CommandTNT.getInstance().isOn()) {
if (CommandBuildMode.getInstance().isOn()) {
return "§eTestblock";
}
return "§aan";
}
return "§caus";
}
}

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -10,6 +10,7 @@ commands:
debugstick:
tnt:
fire:
buildmode:
trace:
tpslimit:
testblock: