forked from SteamWar/SteamWar
Add LegacyBauSystem with adaptions to current SpigotCore
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
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.world;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class AFKStopper implements Listener {
|
||||
|
||||
private static final String afkWarning = BauSystem.PREFIX + "§cDieser Server wird bei weiterer Inaktivität in einer Minute gestoppt";
|
||||
|
||||
private int minutesAfk;
|
||||
|
||||
public AFKStopper() {
|
||||
minutesAfk = 0;
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
|
||||
switch (minutesAfk) {
|
||||
case 5:
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
p.kickPlayer("§cAuf diesem Server ist seit 5 Minuten nichts passiert.");
|
||||
break;
|
||||
case 4:
|
||||
Bukkit.broadcastMessage(afkWarning);
|
||||
default:
|
||||
minutesAfk++;
|
||||
}
|
||||
}, 1200, 1200); //every minute
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
minutesAfk = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
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.world;
|
||||
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
abstract class AbstractAutoLoader {
|
||||
|
||||
abstract Player getPlayer();
|
||||
abstract boolean setRedstone(Location location, boolean active);
|
||||
abstract LinkedList<LoaderAction> getActions();
|
||||
abstract void resetLastActivation();
|
||||
abstract int getLastActivation();
|
||||
|
||||
void print(String message, boolean withSize){
|
||||
if(withSize)
|
||||
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + getActions().size()));
|
||||
else
|
||||
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
||||
}
|
||||
|
||||
abstract static class LoaderAction {
|
||||
|
||||
final Location location;
|
||||
final AbstractAutoLoader loader;
|
||||
|
||||
LoaderAction(AbstractAutoLoader loader, Location location){
|
||||
this.location = location;
|
||||
this.loader = loader;
|
||||
loader.getActions().add(this);
|
||||
loader.resetLastActivation();
|
||||
}
|
||||
|
||||
abstract boolean perform();
|
||||
abstract int ticks();
|
||||
}
|
||||
|
||||
static class RedstoneActivation extends LoaderAction{
|
||||
|
||||
final boolean active;
|
||||
final int length;
|
||||
int status;
|
||||
|
||||
RedstoneActivation(AbstractAutoLoader loader, Location location, int ticks, boolean active){
|
||||
super(loader, location);
|
||||
this.length = ticks;
|
||||
this.active = active;
|
||||
status = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean perform() {
|
||||
status++;
|
||||
if(status < length)
|
||||
return false;
|
||||
|
||||
if(!loader.setRedstone(location, active))
|
||||
return false;
|
||||
status = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
int ticks() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static class TemporaryActivation extends LoaderAction{
|
||||
|
||||
final int length;
|
||||
int status;
|
||||
|
||||
TemporaryActivation(AbstractAutoLoader loader, Location location, int ticks){
|
||||
super(loader, location);
|
||||
this.length = ticks;
|
||||
status = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean perform() {
|
||||
if(status == 0){
|
||||
if(!loader.setRedstone(location, true))
|
||||
return false;
|
||||
}else if(status == length){
|
||||
if(!loader.setRedstone(location, false))
|
||||
return false;
|
||||
status = 0;
|
||||
return true;
|
||||
}
|
||||
status++;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
int ticks() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,266 @@
|
||||
/*
|
||||
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.world;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.FlatteningWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class AutoLoader extends AbstractAutoLoader implements Listener {
|
||||
|
||||
private static final Map<Player, AutoLoader> players = new HashMap<>();
|
||||
|
||||
public static AutoLoader getLoader(Player player){
|
||||
if(!players.containsKey(player))
|
||||
return new AutoLoader(player);
|
||||
return players.get(player);
|
||||
}
|
||||
|
||||
public static boolean hasLoader(Player player){
|
||||
return players.containsKey(player);
|
||||
}
|
||||
|
||||
private final Player player;
|
||||
private final BukkitTask task;
|
||||
|
||||
private final LinkedList<LoaderAction> actions = new LinkedList<>();
|
||||
private int ticksBetweenShots = 80;
|
||||
private int ticksBetweenBlocks = 1;
|
||||
|
||||
private int lastActivation;
|
||||
private int waitTicks;
|
||||
private ListIterator<LoaderAction> lastAction;
|
||||
private boolean setup;
|
||||
private Location lastLocation;
|
||||
|
||||
private AutoLoader(Player player){
|
||||
this.player = player;
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), this::run, 1, 1);
|
||||
players.put(player, this);
|
||||
player.sendMessage(BauSystem.PREFIX + "§7Schieße bitte einmal die Kanone ab");
|
||||
player.sendMessage(BauSystem.PREFIX + "§7Und starte anschließend den AutoLader mit §8/§eloader start");
|
||||
setup();
|
||||
}
|
||||
|
||||
public void setup(){
|
||||
print("§aAutoLader im Setup-Modus", false);
|
||||
setup = true;
|
||||
waitTicks = 0;
|
||||
lastActivation = 0;
|
||||
}
|
||||
|
||||
public void start(){
|
||||
if(actions.isEmpty()){
|
||||
print("§cKeine Aktion vorhanden", false);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!setup){
|
||||
print("§cAutoLader läuft bereits", false);
|
||||
return;
|
||||
}
|
||||
|
||||
setup = false;
|
||||
waitTicks = 0;
|
||||
lastActivation = 0;
|
||||
lastAction = actions.listIterator();
|
||||
print("§aAutoLader gestartet", false);
|
||||
}
|
||||
|
||||
public void stop(){
|
||||
print("§cAutoLader gestoppt", false);
|
||||
players.remove(player);
|
||||
HandlerList.unregisterAll(this);
|
||||
if(task != null)
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
public void undo(){
|
||||
if(actions.isEmpty()){
|
||||
print("§cKeine Aktion vorhanden", false);
|
||||
return;
|
||||
}
|
||||
|
||||
actions.removeLast();
|
||||
print("§aUndo erfolgreich", true);
|
||||
}
|
||||
|
||||
public void wait(int time){
|
||||
if(time < 1){
|
||||
print("§cDie Wartezeit ist zu klein", false);
|
||||
return;
|
||||
}
|
||||
|
||||
print("§aSchusswartezeit §e" + time + " §aTicks§8, zuvor " + ticksBetweenShots, false);
|
||||
ticksBetweenShots = time;
|
||||
}
|
||||
|
||||
public void blockWait(int time){
|
||||
if(time < 1){
|
||||
print("§cDie Wartezeit ist zu klein", false);
|
||||
return;
|
||||
}
|
||||
|
||||
print("§aSetzwartezeit §e" + time + " §aTicks§8, zuvor " + ticksBetweenBlocks, false);
|
||||
ticksBetweenBlocks = time;
|
||||
}
|
||||
|
||||
public int getTicksBetweenShots() {
|
||||
return ticksBetweenShots;
|
||||
}
|
||||
|
||||
public int getTicksBetweenBlocks() {
|
||||
return ticksBetweenBlocks;
|
||||
}
|
||||
|
||||
public boolean isSetup() {
|
||||
return setup;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event){
|
||||
if(!setup || !event.getPlayer().equals(player))
|
||||
return;
|
||||
if(event.getBlock().getType() != Material.TNT)
|
||||
return;
|
||||
|
||||
new TNTPlaceAction(this, event.getBlock().getLocation());
|
||||
print("§eTNT platziert", true);
|
||||
}
|
||||
|
||||
//BlockRedstoneEvent?
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event){
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL)
|
||||
return;
|
||||
if (event.getClickedBlock().getType() == Material.OBSERVER)
|
||||
return;
|
||||
if (event.getPlayer().isSneaking())
|
||||
return;
|
||||
|
||||
if (!setup || !event.getPlayer().equals(player))
|
||||
return;
|
||||
|
||||
Detoloader detoloader = FlatteningWrapper.impl.onPlayerInteractLoader(event);
|
||||
if (detoloader == null || detoloader.getActivation() < 0) return;
|
||||
|
||||
if (lastLocation != null && lastLocation.distance(event.getClickedBlock().getLocation()) <= 1) return;
|
||||
|
||||
if (detoloader.useActive) {
|
||||
new AbstractAutoLoader.RedstoneActivation(this, event.getClickedBlock().getLocation()
|
||||
, detoloader.getActivation() == 0 ? getLastActivation() : detoloader.getActivation()
|
||||
, detoloader.isActive());
|
||||
} else {
|
||||
new AbstractAutoLoader.TemporaryActivation(this, event.getClickedBlock().getLocation()
|
||||
, detoloader.getActivation());
|
||||
}
|
||||
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " betätigt" :
|
||||
detoloader.getBlock(), detoloader.addBack);
|
||||
lastLocation = event.getClickedBlock().getLocation();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeave(PlayerQuitEvent event){
|
||||
if(!event.getPlayer().equals(player))
|
||||
return;
|
||||
stop();
|
||||
}
|
||||
|
||||
private void run(){
|
||||
lastActivation++;
|
||||
if(setup)
|
||||
return;
|
||||
while(lastActivation >= waitTicks){
|
||||
lastActivation = 0;
|
||||
|
||||
LoaderAction action = lastAction.next();
|
||||
if(action.perform()){
|
||||
waitTicks = action.ticks();
|
||||
}else{
|
||||
waitTicks = 1;
|
||||
lastAction.previous();
|
||||
}
|
||||
|
||||
if(!lastAction.hasNext()){
|
||||
lastAction = actions.listIterator();
|
||||
waitTicks = ticksBetweenShots;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean setRedstone(Location location, boolean active){
|
||||
return FlatteningWrapper.impl.setRedstone(location, active);
|
||||
}
|
||||
|
||||
@Override
|
||||
LinkedList<LoaderAction> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
void resetLastActivation() {
|
||||
lastActivation = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
int getLastActivation() {
|
||||
return lastActivation;
|
||||
}
|
||||
|
||||
class TNTPlaceAction extends AbstractAutoLoader.LoaderAction {
|
||||
|
||||
TNTPlaceAction(AbstractAutoLoader loader, Location location){
|
||||
super(loader, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean perform() {
|
||||
return FlatteningWrapper.impl.tntPlaceActionPerform(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
int ticks(){
|
||||
return ticksBetweenBlocks;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
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.world;
|
||||
|
||||
import de.steamwar.bausystem.commands.CommandTPSLimiter;
|
||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||
import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.core.TPSWatcher;
|
||||
import de.steamwar.scoreboard.SWScoreboard;
|
||||
import de.steamwar.scoreboard.ScoreboardCallback;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class BauScoreboard implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void handlePlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
SWScoreboard.impl.createScoreboard(player, new ScoreboardCallback() {
|
||||
@Override
|
||||
public HashMap<String, Integer> getData() {
|
||||
return sidebar(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "§eSteam§8War";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private HashMap<String, Integer> sidebar(Player p) {
|
||||
List<String> strings = new ArrayList<>();
|
||||
strings.add("§1");
|
||||
strings.add("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()));
|
||||
strings.add("§2");
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
strings.add("§eTNT§8: " + region.getTntMode().getName());
|
||||
strings.add("§eFreeze§8: " + (region.isFreeze() ? "§aan" : "§caus"));
|
||||
strings.add("§eFire§8: " + (region.isFire() ? "§aaus" : "§can"));
|
||||
strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName());
|
||||
strings.add("§eLoader§8: " + (AutoLoader.hasLoader(p) ? "§aan" : "§caus"));
|
||||
if (region.hasProtection()) {
|
||||
strings.add("§eProtect§8: " + (region.isProtect() ? "§aan" : "§caus"));
|
||||
}
|
||||
|
||||
if (RecordStateMachine.getRecordStatus().isTracing()) {
|
||||
strings.add("§3");
|
||||
strings.add("§eTicks§8: §7" + traceTicks());
|
||||
strings.add("§eAnzahl TNT§8: §7" + RecordStateMachine.size());
|
||||
}
|
||||
|
||||
strings.add("§4");
|
||||
strings.add("§eTPS§8: " + tpsColor() + TPSUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit());
|
||||
|
||||
int i = strings.size();
|
||||
HashMap<String, Integer> result = new HashMap<>();
|
||||
for (String s : strings)
|
||||
result.put(s, i--);
|
||||
return result;
|
||||
}
|
||||
|
||||
private long traceTicks() {
|
||||
return (System.currentTimeMillis() - RecordStateMachine.getStartTime()) / 50;
|
||||
}
|
||||
|
||||
private String tpsColor() {
|
||||
double tps = TPSUtils.getTps(TPSWatcher.TPSType.ONE_SECOND);
|
||||
if (tps > CommandTPSLimiter.getCurrentTPSLimit() * 0.9) {
|
||||
return "§a";
|
||||
}
|
||||
if (tps > CommandTPSLimiter.getCurrentTPSLimit() * 0.5) {
|
||||
return "§e";
|
||||
}
|
||||
return "§c";
|
||||
}
|
||||
|
||||
private String tpsLimit() {
|
||||
if (CommandTPSLimiter.getCurrentTPSLimit() == 20) {
|
||||
return "";
|
||||
}
|
||||
return "§8/§7" + CommandTPSLimiter.getCurrentTPSLimit();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
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.world;
|
||||
|
||||
import de.steamwar.sql.SchematicData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class ClipboardListener implements Listener {
|
||||
|
||||
private static final String CLIPBOARD_SCHEMNAME = "//copy";
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(PlayerJoinEvent e) {
|
||||
try {
|
||||
SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, (Integer) null);
|
||||
if (schematic != null) {
|
||||
new SchematicData(schematic).loadToPlayer(e.getPlayer());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// ignore cause players do all kind of stuff with schematics.... like massively oversized schems
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLogout(PlayerQuitEvent e) {
|
||||
SchematicNode schematic = SchematicNode.getSchematicNode(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, (Integer) null);
|
||||
boolean newSchem = false;
|
||||
if (schematic == null) {
|
||||
schematic = SchematicNode.createSchematic(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), CLIPBOARD_SCHEMNAME, null);
|
||||
newSchem = true;
|
||||
}
|
||||
|
||||
try {
|
||||
new SchematicData(schematic).saveFromPlayer(e.getPlayer());
|
||||
} catch (Exception ex) {
|
||||
if (newSchem) {
|
||||
schematic.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.world;
|
||||
|
||||
public enum Color {
|
||||
WHITE,
|
||||
ORANGE,
|
||||
MAGENTA,
|
||||
LIGHT_BLUE,
|
||||
YELLOW,
|
||||
LIME,
|
||||
PINK,
|
||||
GRAY,
|
||||
LIGHT_GRAY,
|
||||
CYAN,
|
||||
PURPLE,
|
||||
BLUE,
|
||||
BROWN,
|
||||
GREEN,
|
||||
RED,
|
||||
BLACK;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
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.world;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class Detoloader {
|
||||
|
||||
String message;
|
||||
int activation;
|
||||
boolean active, addBack = true, useActive = false;
|
||||
|
||||
public Detoloader(String message, int activation) {
|
||||
this.message = message;
|
||||
this.activation = activation;
|
||||
}
|
||||
|
||||
public String getBlock() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setBlock(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getActivation() {
|
||||
return activation;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public Detoloader setActive(boolean active) {
|
||||
useActive = true;
|
||||
this.active = active;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isAddBack() {
|
||||
return addBack;
|
||||
}
|
||||
|
||||
public Detoloader setAddBack(boolean addBack) {
|
||||
this.addBack = addBack;
|
||||
return this;
|
||||
}
|
||||
|
||||
static class DetonatorActivation {
|
||||
|
||||
int activation = -1;
|
||||
Location location;
|
||||
|
||||
public DetonatorActivation(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public DetonatorActivation(int activation, Location location) {
|
||||
this.activation = activation;
|
||||
this.location = location;
|
||||
}
|
||||
}
|
||||
|
||||
//Timings
|
||||
public static final int STONE_BUTTON = 20;
|
||||
public static final int WOODEN_BUTTON = 30;
|
||||
public static final int PRESSURE_PLATE = 20;
|
||||
public static final int NOTE_BLOCK = 1;
|
||||
public static final int TRIPWIRE = 20;
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
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.world;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.FlatteningWrapper;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Detonator implements Listener {
|
||||
|
||||
public static final ItemStack WAND;
|
||||
|
||||
public static final Map<Player, Set<Detoloader.DetonatorActivation>> PLAYER_LOCS = new HashMap<>();
|
||||
|
||||
static {
|
||||
WAND = new ItemStack(Material.BLAZE_ROD, 1);
|
||||
ItemMeta im = WAND.getItemMeta();
|
||||
|
||||
im.setDisplayName("§eFernzünder");
|
||||
|
||||
List<String> lorelist = Arrays.asList("§eLinks Klick §8- §7Setzte einen Punkt zum Aktivieren",
|
||||
"§eLinks Klick + Shift §8- §7Füge einen Punkt hinzu", "§eRechts Klick §8- §7Löse alle Punkte aus");
|
||||
im.setLore(lorelist);
|
||||
|
||||
WAND.setItemMeta(im);
|
||||
}
|
||||
|
||||
public static Detonator getDetonator(Player player, ItemStack item) {
|
||||
return new Detonator(player, PLAYER_LOCS.get(player));
|
||||
}
|
||||
|
||||
public static ItemStack setLocation(Player player, ItemStack item, Detoloader.DetonatorActivation detoloader) {
|
||||
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).clear();
|
||||
PLAYER_LOCS.get(player).add(detoloader);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack toggleLocation(ItemStack item, Player player, Detoloader detoloader, Location location) {
|
||||
if (PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).stream().anyMatch(activation -> activation.location.equals(location))) {
|
||||
DetonatorListener.print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " entfernt" :
|
||||
detoloader.getBlock(), Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() - 1);
|
||||
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).removeIf(activation -> activation.location.equals(location));
|
||||
return item;
|
||||
} else {
|
||||
DetonatorListener.print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " hinzugefügt" :
|
||||
detoloader.getBlock(), Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() + 1);
|
||||
if (detoloader.getActivation() == 0) {
|
||||
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).add(new Detoloader.DetonatorActivation(location));
|
||||
return item;
|
||||
} else {
|
||||
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).add(new Detoloader.DetonatorActivation(detoloader.getActivation(), location));
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void execute(Player player) {
|
||||
execute(player, PLAYER_LOCS.get(player));
|
||||
}
|
||||
|
||||
private static void execute(Player player, Set<Detoloader.DetonatorActivation> locs) {
|
||||
for (Detoloader.DetonatorActivation activation : locs) {
|
||||
|
||||
if (activation.activation == -1) {
|
||||
FlatteningWrapper.impl.setRedstone(activation.location, !FlatteningWrapper.impl.getLever(activation.location.getBlock()));
|
||||
} else {
|
||||
FlatteningWrapper.impl.setRedstone(activation.location, true);
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> FlatteningWrapper.impl.setRedstone(activation.location, false), activation.activation);
|
||||
}
|
||||
}
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§e" + locs.size() + " §7Punkt" + (locs.size() > 1 ? "e" : "") + " ausgelöst!"));
|
||||
}
|
||||
|
||||
public static void clear(Player player) {
|
||||
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).clear();
|
||||
}
|
||||
|
||||
private final Set<Detoloader.DetonatorActivation> locs;
|
||||
private final Player player;
|
||||
|
||||
private Detonator(Player player, Set<Detoloader.DetonatorActivation> locs) {
|
||||
this.player = player;
|
||||
this.locs = locs;
|
||||
}
|
||||
|
||||
public Set<Detoloader.DetonatorActivation> getLocs() {
|
||||
return locs;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.FlatteningWrapper;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class DetonatorListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.getItem() == null) return;
|
||||
if (event.getItem().isSimilar(Detonator.WAND)) {
|
||||
Player player = event.getPlayer();
|
||||
if (Welt.noPermission(player, Permission.WORLD)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen");
|
||||
return;
|
||||
}
|
||||
ItemStack item = event.getItem();
|
||||
event.setCancelled(true);
|
||||
switch (event.getAction()) {
|
||||
case LEFT_CLICK_BLOCK:
|
||||
Detoloader detoloader = FlatteningWrapper.impl.onPlayerInteractLoader(event);
|
||||
|
||||
if (detoloader == null) {
|
||||
return;
|
||||
} else if (detoloader.activation == -1) {
|
||||
print(player, detoloader.getBlock(), detoloader.addBack ? Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() : 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getPlayer().isSneaking()) {
|
||||
player.getInventory().setItemInMainHand(Detonator.toggleLocation(item, player, detoloader, event.getClickedBlock().getLocation()));
|
||||
} else {
|
||||
if (detoloader.getActivation() == 0) {
|
||||
player.getInventory().setItemInMainHand(Detonator.setLocation(player, item, new Detoloader.DetonatorActivation(event.getClickedBlock().getLocation())));
|
||||
} else {
|
||||
player.getInventory().setItemInMainHand(Detonator.setLocation(player, item, new Detoloader.DetonatorActivation(detoloader.activation, event.getClickedBlock().getLocation())));
|
||||
}
|
||||
print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " gesetzt" :
|
||||
detoloader.getBlock(), detoloader.addBack ? Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() : 0);
|
||||
}
|
||||
break;
|
||||
case RIGHT_CLICK_AIR:
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
Detonator.execute(player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void print(Player player, String message, int size) {
|
||||
if (size == 0) {
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
||||
} else {
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + size));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.world;
|
||||
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ItemFrameListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (!(event.getDamager() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (!(event.getEntity() instanceof ItemFrame)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
ItemFrame itemFrame = (ItemFrame) event.getEntity();
|
||||
ItemStack itemStack = itemFrame.getItem();
|
||||
if (itemStack.getType() != Material.AIR) {
|
||||
SWUtils.giveItemToPlayer((Player) event.getDamager(), itemFrame.getItem());
|
||||
itemFrame.setItem(null);
|
||||
} else {
|
||||
itemFrame.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PredefinedBook {
|
||||
|
||||
private static final FileConfiguration configuration;
|
||||
private static List<PredefinedBook> bookCache;
|
||||
|
||||
static {
|
||||
configuration = YamlConfiguration.loadConfiguration(new File(BauSystem.getPlugin().getDataFolder(), "books.yml"));
|
||||
}
|
||||
|
||||
public static List<PredefinedBook> getBooks() {
|
||||
if (bookCache != null)
|
||||
return bookCache;
|
||||
List<PredefinedBook> books = new ArrayList<>();
|
||||
for (String book : configuration.getKeys(false)) {
|
||||
ConfigurationSection section = Objects.requireNonNull(configuration.getConfigurationSection(book));
|
||||
books.add(new PredefinedBook(section));
|
||||
}
|
||||
bookCache = books;
|
||||
return books;
|
||||
}
|
||||
|
||||
public static int getBookCount() {
|
||||
return configuration.getKeys(false).size();
|
||||
}
|
||||
|
||||
private List<String> lines;
|
||||
private List<String> lore;
|
||||
private String author;
|
||||
private String name;
|
||||
private ItemStack finishedBook;
|
||||
|
||||
PredefinedBook(ConfigurationSection section) {
|
||||
this.lines = section.getStringList("lines");
|
||||
this.lore = section.getStringList("lore");
|
||||
this.author = section.getString("author", "§8Steam§eWar");
|
||||
this.name = section.getName();
|
||||
}
|
||||
|
||||
public ItemStack toItemStack() {
|
||||
if (finishedBook != null)
|
||||
return finishedBook;
|
||||
ItemStack book = new ItemStack(getBookMat());
|
||||
BookMeta meta = (BookMeta) book.getItemMeta();
|
||||
meta.setPages(getPages());
|
||||
meta.setDisplayName(name);
|
||||
meta.setTitle(name);
|
||||
meta.setAuthor(author);
|
||||
meta.setGeneration(BookMeta.Generation.ORIGINAL);
|
||||
meta.setLore(lore);
|
||||
book.setItemMeta(meta);
|
||||
finishedBook = book;
|
||||
return book;
|
||||
}
|
||||
|
||||
public Material getBookMat() {
|
||||
return Material.WRITTEN_BOOK;
|
||||
}
|
||||
|
||||
public List<String> getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<String> getLore() {
|
||||
return lore;
|
||||
}
|
||||
|
||||
private String[] getPages() {
|
||||
List<StringBuilder> pages = new ArrayList<>();
|
||||
pages.add(0, new StringBuilder());
|
||||
int charsPerLine = 19;
|
||||
int currentLine = 0;
|
||||
int currentpage = 0;
|
||||
boolean first = true;
|
||||
for (String line : lines) {
|
||||
int linesPlus = (int) Math.ceil((double) line.length() / charsPerLine);
|
||||
currentLine += linesPlus;
|
||||
if (currentLine >= 14 || line.equals("!")) {
|
||||
currentLine = linesPlus;
|
||||
currentpage++;
|
||||
if (currentpage > 50)
|
||||
throw new IllegalStateException("Book " + name + " has more pages than 50");
|
||||
pages.add(currentpage, new StringBuilder());
|
||||
first = true;
|
||||
if (line.equals("!"))
|
||||
continue;
|
||||
}
|
||||
if (!first) {
|
||||
pages.get(currentpage).append("\n");
|
||||
} else {
|
||||
first = false;
|
||||
}
|
||||
pages.get(currentpage).append(line);
|
||||
}
|
||||
|
||||
String[] finalPages = new String[pages.size()];
|
||||
for (int i = 0; i < pages.size(); i++) {
|
||||
finalPages[i] = pages.get(i).toString();
|
||||
}
|
||||
return finalPages;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
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.world;
|
||||
|
||||
import de.steamwar.Reflection;
|
||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.CraftbukkitWrapper;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.WorldeditWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RegionListener implements Listener {
|
||||
|
||||
private final List<Player> signEditing = new ArrayList<>();
|
||||
|
||||
private static final Class<?> updateSign = Reflection.getClass("{nms}.PacketPlayInUpdateSign");
|
||||
private static final Class<?> blockPosition = Reflection.getClass("{nms}.BlockPosition");
|
||||
private static final Reflection.Field<?> blockPos = Reflection.getField(updateSign, blockPosition, 0);
|
||||
private static final Reflection.Field<String[]> signText = Reflection.getField(updateSign, String[].class, 0);
|
||||
private static final Class<?> baseBlockPosition = Reflection.getClass("{nms}.BaseBlockPosition");
|
||||
private static final Reflection.Field<Integer> blockPosX = Reflection.getField(baseBlockPosition, int.class, 0);
|
||||
private static final Reflection.Field<Integer> blockPosY = Reflection.getField(baseBlockPosition, int.class, 1);
|
||||
private static final Reflection.Field<Integer> blockPosZ = Reflection.getField(baseBlockPosition, int.class, 2);
|
||||
public RegionListener() {
|
||||
TinyProtocol.instance.addFilter(updateSign, (player, packet) -> {
|
||||
if(!signEditing.contains(player))
|
||||
return packet;
|
||||
|
||||
String[] lines = signText.get(packet);
|
||||
Object pos = blockPos.get(packet);
|
||||
|
||||
Bukkit.getScheduler().runTask(BauSystem.getPlugin(), () -> {
|
||||
Block signLoc = new Location(player.getWorld(), blockPosX.get(pos), blockPosY.get(pos), blockPosZ.get(pos)).getBlock();
|
||||
if (!signLoc.getType().name().contains("SIGN"))
|
||||
return;
|
||||
|
||||
Sign sign = ((Sign) signLoc.getState());
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
sign.setLine(i, ChatColor.translateAlternateColorCodes('&', lines[i]));
|
||||
}
|
||||
sign.update();
|
||||
|
||||
signEditing.remove(player);
|
||||
});
|
||||
|
||||
return packet;
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void playerCommandHandler(PlayerCommandPreprocessEvent e) {
|
||||
if (!isWorldEditCommand(e.getMessage().split(" ")[0]))
|
||||
return;
|
||||
|
||||
Player p = e.getPlayer();
|
||||
|
||||
if (Welt.noPermission(p, Permission.WORLDEDIT)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier kein WorldEdit benutzen");
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"};
|
||||
|
||||
private boolean isWorldEditCommand(String command) {
|
||||
for (String shortcut : shortcutCommands)
|
||||
if (command.startsWith(shortcut))
|
||||
return true;
|
||||
|
||||
return WorldeditWrapper.impl.isWorldEditCommand(command);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
for (int i = 0; i <= 3; ++i) {
|
||||
String line = event.getLine(i);
|
||||
if (line == null)
|
||||
continue;
|
||||
line = ChatColor.translateAlternateColorCodes('&', line);
|
||||
event.setLine(i, line);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void editSign(PlayerInteractEvent event) {
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK ||
|
||||
!event.getClickedBlock().getType().name().contains("SIGN") ||
|
||||
!event.getPlayer().isSneaking() ||
|
||||
(event.getItem() != null && event.getItem().getType() != Material.AIR))
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Sign sign = (Sign) event.getClickedBlock().getState();
|
||||
String[] lines = sign.getLines();
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
sign.setLine(i, lines[i].replace('\u00A7' /* WINDOWS \u00A7 -> § */, '&'));
|
||||
}
|
||||
sign.update();
|
||||
|
||||
CraftbukkitWrapper.impl.openSignEditor(player, event.getClickedBlock().getLocation());
|
||||
signEditing.add(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,542 @@
|
||||
/*
|
||||
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.world;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.FlatteningWrapper;
|
||||
import de.steamwar.bausystem.commands.CommandScript;
|
||||
import de.steamwar.bausystem.commands.CommandTNT;
|
||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||
import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.IntBinaryOperator;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ScriptListener implements Listener {
|
||||
|
||||
public static final Map<Player, Map<String, Integer>> GLOBAL_VARIABLES = new HashMap<>();
|
||||
private static final Map<String, Function<Player, Integer>> CONSTANTS = new HashMap<>();
|
||||
|
||||
static {
|
||||
CONSTANTS.put("trace", player -> RecordStateMachine.getRecordStatus().isTracing() ? 1 : 0);
|
||||
CONSTANTS.put("autotrace", player -> RecordStateMachine.getRecordStatus().isAutoTrace() ? 1 : 0);
|
||||
CONSTANTS.put("tnt", player -> Region.getRegion(player.getLocation()).getTntMode() == CommandTNT.TNTMode.OFF ? 0 : 1);
|
||||
CONSTANTS.put("freeze", player -> Region.getRegion(player.getLocation()).isFreeze() ? 1 : 0);
|
||||
CONSTANTS.put("fire", player -> Region.getRegion(player.getLocation()).isFire() ? 1 : 0);
|
||||
CONSTANTS.put("x", player -> player.getLocation().getBlockX());
|
||||
CONSTANTS.put("y", player -> player.getLocation().getBlockY());
|
||||
CONSTANTS.put("z", player -> player.getLocation().getBlockZ());
|
||||
}
|
||||
|
||||
private Set<Player> playerSet = new HashSet<>();
|
||||
|
||||
public ScriptListener() {
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), playerSet::clear, 5, 5);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onLeftClick(PlayerInteractEvent event) {
|
||||
ItemStack item = event.getItem();
|
||||
if (item == null || isNoBook(item) || item.getItemMeta() == null)
|
||||
return;
|
||||
|
||||
if (CommandScript.BOOK.getItemMeta() != null && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equals(CommandScript.BOOK.getItemMeta().getDisplayName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK) {
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR) {
|
||||
playerSet.add(event.getPlayer());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (playerSet.remove(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
new ScriptExecutor((BookMeta) item.getItemMeta(), event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
GLOBAL_VARIABLES.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
private boolean isNoBook(ItemStack item) {
|
||||
return FlatteningWrapper.impl.isNoBook(item);
|
||||
}
|
||||
|
||||
private static class ScriptExecutor {
|
||||
|
||||
private final Player player;
|
||||
private final List<String> commands = new ArrayList<>();
|
||||
private final Map<String, Integer> jumpPoints = new HashMap<>();
|
||||
private Map<String, Integer> variables = new HashMap<>();
|
||||
|
||||
private int index = 0;
|
||||
|
||||
public ScriptExecutor(BookMeta bookMeta, Player player) {
|
||||
this.player = player;
|
||||
|
||||
for (String page : bookMeta.getPages()) {
|
||||
for (String command : page.split("\n")) {
|
||||
command = command.replaceAll(" +", " ");
|
||||
if (command.startsWith("#") || command.trim().isEmpty()) continue;
|
||||
if (command.startsWith(".")) {
|
||||
jumpPoints.put(command.substring(1), commands.size());
|
||||
continue;
|
||||
}
|
||||
commands.add(command);
|
||||
}
|
||||
}
|
||||
if (commands.isEmpty()) return;
|
||||
resume();
|
||||
}
|
||||
|
||||
private void resume() {
|
||||
if (!player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int executionPoints = 0;
|
||||
|
||||
while (index < commands.size()) {
|
||||
String command = commands.get(index++);
|
||||
if (executionPoints++ > 200) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cFüge ein sleep in dein Script ein");
|
||||
return;
|
||||
}
|
||||
|
||||
String firstArg = command;
|
||||
if (command.contains(" ")) {
|
||||
firstArg = command.substring(0, command.indexOf(' '));
|
||||
}
|
||||
switch (firstArg.toLowerCase()) {
|
||||
case "sleep":
|
||||
ScriptListener.sleepCommand(this, generateArgumentArray("sleep", this, command));
|
||||
return;
|
||||
case "exit":
|
||||
return;
|
||||
case "jump":
|
||||
int jumpIndex = ScriptListener.jumpCommand(this, generateArgumentArray("jump", this, command));
|
||||
if (jumpIndex != -1) {
|
||||
index = jumpIndex;
|
||||
} else {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cUnbekannter Jump Punkt: " + command);
|
||||
}
|
||||
continue;
|
||||
case "echo":
|
||||
ScriptListener.echoCommand(this, generateArgumentArray("echo", this, command));
|
||||
continue;
|
||||
case "input":
|
||||
ScriptListener.inputCommand(this, generateArgumentArray("input", this, command));
|
||||
return;
|
||||
case "var":
|
||||
ScriptListener.variableCommand(this, generateArgumentArray("var", this, command));
|
||||
continue;
|
||||
case "unvar":
|
||||
ScriptListener.unvariableCommand(this, generateArgumentArray("unvar", this, command));
|
||||
continue;
|
||||
case "global":
|
||||
ScriptListener.globalCommand(this, generateArgumentArray("global", this, command));
|
||||
continue;
|
||||
case "unglobal":
|
||||
ScriptListener.unglobalCommand(this, generateArgumentArray("unglobal", this, command));
|
||||
continue;
|
||||
case "add":
|
||||
ScriptListener.arithmeticCommand(this, generateArgumentArray("add", this, command), (left, right) -> left + right);
|
||||
continue;
|
||||
case "sub":
|
||||
ScriptListener.arithmeticCommand(this, generateArgumentArray("sub", this, command), (left, right) -> left - right);
|
||||
continue;
|
||||
case "mul":
|
||||
ScriptListener.arithmeticCommand(this, generateArgumentArray("mul", this, command), (left, right) -> left * right);
|
||||
continue;
|
||||
case "div":
|
||||
ScriptListener.arithmeticCommand(this, generateArgumentArray("div", this, command), (left, right) -> left / right);
|
||||
continue;
|
||||
case "equal":
|
||||
ScriptListener.arithmeticCommand(this, generateArgumentArray("equal", this, command), (left, right) -> left == right ? 1 : 0);
|
||||
continue;
|
||||
case "less":
|
||||
ScriptListener.arithmeticCommand(this, generateArgumentArray("less", this, command), (left, right) -> left < right ? 1 : 0);
|
||||
continue;
|
||||
case "greater":
|
||||
ScriptListener.arithmeticCommand(this, generateArgumentArray("greater", this, command), (left, right) -> left > right ? 1 : 0);
|
||||
continue;
|
||||
case "not":
|
||||
ScriptListener.arithmeticInfixCommand(this, generateArgumentArray("not", this, command), (left) -> left == 1 ? 0 : 1);
|
||||
continue;
|
||||
case "and":
|
||||
ScriptListener.arithmeticCommand(this, generateArgumentArray("and", this, command), (left, right) -> left == 1 && right == 1 ? 1 : 0);
|
||||
continue;
|
||||
case "or":
|
||||
ScriptListener.arithmeticCommand(this, generateArgumentArray("or", this, command), (left, right) -> left == 1 || right == 1 ? 1 : 0);
|
||||
continue;
|
||||
case "if":
|
||||
int ifJumpIndex = ScriptListener.ifCommand(this, generateArgumentArray("if", this, command));
|
||||
if (ifJumpIndex != -1) {
|
||||
index = ifJumpIndex;
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(player, "/" + command);
|
||||
Bukkit.getServer().getPluginManager().callEvent(preprocessEvent);
|
||||
if (preprocessEvent.isCancelled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Variable Replaces in commands.
|
||||
command = String.join(" ", generateArgumentArray("", this, command));
|
||||
|
||||
Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command);
|
||||
Bukkit.getServer().dispatchCommand(player, command);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static String[] generateArgumentArray(String command, ScriptExecutor scriptExecutor, String fullCommand) {
|
||||
String[] strings;
|
||||
if (command.isEmpty()) {
|
||||
strings = fullCommand.split(" ");
|
||||
} else {
|
||||
strings = fullCommand.substring(command.length()).trim().split(" ");
|
||||
}
|
||||
return replaceVariables(scriptExecutor, strings);
|
||||
}
|
||||
|
||||
private static void sleepCommand(ScriptExecutor scriptExecutor, String[] args) {
|
||||
int sleepTime = 1;
|
||||
if (args.length > 0) {
|
||||
try {
|
||||
sleepTime = Integer.parseInt(args[0]);
|
||||
if (sleepTime <= 0) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cDie Zeit muss eine Zahl großer 0 sein.");
|
||||
sleepTime = 1;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cDie Zeit darf nur aus Zahlen bestehen.");
|
||||
}
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), scriptExecutor::resume, sleepTime);
|
||||
}
|
||||
|
||||
private static int jumpCommand(ScriptExecutor scriptExecutor, String[] args) {
|
||||
if (args.length < 1) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cEin Jump Punkt muss angegeben sein.");
|
||||
return -1;
|
||||
}
|
||||
return scriptExecutor.jumpPoints.getOrDefault(args[0], -1);
|
||||
}
|
||||
|
||||
private static String[] replaceVariables(ScriptExecutor scriptExecutor, String[] args) {
|
||||
// Legacy '$' notation for variable reference, could be removed later on.
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i].startsWith("$") && isVariable(scriptExecutor, args[i].substring(1))) {
|
||||
args[i] = getValue(scriptExecutor, args[i].substring(1)) + "";
|
||||
}
|
||||
}
|
||||
|
||||
String s = String.join(" ", args);
|
||||
Set<String> variables = new HashSet<>(scriptExecutor.variables.keySet());
|
||||
variables.addAll(CONSTANTS.keySet());
|
||||
if (GLOBAL_VARIABLES.containsKey(scriptExecutor.player)) {
|
||||
variables.addAll(GLOBAL_VARIABLES.get(scriptExecutor.player).keySet());
|
||||
}
|
||||
for (String variable : variables) {
|
||||
s = s.replace("<" + variable + ">", getValue(scriptExecutor, variable) + "");
|
||||
}
|
||||
for (String constVariable : CONSTANTS.keySet()) {
|
||||
s = s.replace("<const." + constVariable + ">", getConstantValue(scriptExecutor, constVariable) + "");
|
||||
}
|
||||
for (String localVariable : scriptExecutor.variables.keySet()) {
|
||||
s = s.replace("<local." + localVariable + ">", getLocalValue(scriptExecutor, localVariable) + "");
|
||||
}
|
||||
for (String globalVariable : GLOBAL_VARIABLES.getOrDefault(scriptExecutor.player, new HashMap<>()).keySet()) {
|
||||
s = s.replace("<global." + globalVariable + ">", getGlobalValue(scriptExecutor, globalVariable) + "");
|
||||
}
|
||||
return s.split(" ");
|
||||
}
|
||||
|
||||
private static void echoCommand(ScriptExecutor scriptExecutor, String[] args) {
|
||||
scriptExecutor.player.sendMessage("§eInfo§8» §7" + ChatColor.translateAlternateColorCodes('&', String.join(" ", replaceVariables(scriptExecutor, args))));
|
||||
}
|
||||
|
||||
private static void variableCommand(ScriptExecutor scriptExecutor, String[] args) {
|
||||
if (args.length < 1) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariablen Namen und Zahlen/Boolsche Wert fehlt.");
|
||||
return;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cZahlen/Boolsche Wert fehlt.");
|
||||
return;
|
||||
}
|
||||
switch (args[1]) {
|
||||
case "inc":
|
||||
case "increment":
|
||||
case "++":
|
||||
add(scriptExecutor, args[0], 1);
|
||||
return;
|
||||
case "dec":
|
||||
case "decrement":
|
||||
case "--":
|
||||
add(scriptExecutor, args[0], -1);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
setValue(scriptExecutor, args[0], parseValue(args[1]));
|
||||
}
|
||||
|
||||
private static void unvariableCommand(ScriptExecutor scriptExecutor, String[] args) {
|
||||
if (args.length < 1) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariablen Namen fehlt.");
|
||||
return;
|
||||
}
|
||||
if (!isLocalVariable(scriptExecutor, args[0])) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariable is nicht definiert");
|
||||
return;
|
||||
}
|
||||
scriptExecutor.variables.remove(args[0]);
|
||||
}
|
||||
|
||||
private static void globalCommand(ScriptExecutor scriptExecutor, String[] args) {
|
||||
if (args.length < 1) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariablen Namen fehlt.");
|
||||
return;
|
||||
}
|
||||
if (!isLocalVariable(scriptExecutor, args[0])) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariable is nicht definiert");
|
||||
return;
|
||||
}
|
||||
GLOBAL_VARIABLES.computeIfAbsent(scriptExecutor.player, player -> new HashMap<>()).put(args[0], scriptExecutor.variables.getOrDefault(args[0], 0));
|
||||
}
|
||||
|
||||
private static void unglobalCommand(ScriptExecutor scriptExecutor, String[] args) {
|
||||
if (args.length < 1) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariablen Namen fehlt.");
|
||||
return;
|
||||
}
|
||||
if (!isGlobalVariable(scriptExecutor, args[0])) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cVariable is nicht definiert");
|
||||
return;
|
||||
}
|
||||
if (GLOBAL_VARIABLES.containsKey(scriptExecutor.player)) {
|
||||
GLOBAL_VARIABLES.get(scriptExecutor.player).remove(args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private static int ifCommand(ScriptExecutor scriptExecutor, String[] args) {
|
||||
if (args.length < 2) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cDie ersten beiden Argumente sind Zahlen/Boolsche Werte oder Variablen.");
|
||||
return -1;
|
||||
}
|
||||
if (args.length < 3) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cDas dritte Argument muss ein JumpPoint sein.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int jumpTruePoint = scriptExecutor.jumpPoints.getOrDefault(args[2], -1);
|
||||
int jumpFalsePoint = args.length > 3 ? scriptExecutor.jumpPoints.getOrDefault(args[3], -1) : -1;
|
||||
|
||||
if (args[1].equals("exists")) {
|
||||
if (isVariable(scriptExecutor, args[0])) {
|
||||
return jumpTruePoint;
|
||||
} else {
|
||||
return jumpFalsePoint;
|
||||
}
|
||||
}
|
||||
int firstValue = getValueOrParse(scriptExecutor, args[0]);
|
||||
int secondValue = getValueOrParse(scriptExecutor, args[1]);
|
||||
if (firstValue == secondValue) {
|
||||
return jumpTruePoint;
|
||||
} else {
|
||||
return jumpFalsePoint;
|
||||
}
|
||||
}
|
||||
|
||||
private static void arithmeticCommand(ScriptExecutor scriptExecutor, String[] args, IntBinaryOperator operation) {
|
||||
if (args.length < 1) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cAls erstes Argument fehlt eine Variable");
|
||||
return;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cAls zweites Argument fehlt eine Zahl oder Variable");
|
||||
return;
|
||||
}
|
||||
|
||||
int firstValue;
|
||||
int secondValue;
|
||||
if (args.length < 3) {
|
||||
if (!isVariable(scriptExecutor, args[0])) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cDas erste Argument muss eine Variable sein");
|
||||
return;
|
||||
}
|
||||
firstValue = getValue(scriptExecutor, args[0]);
|
||||
secondValue = getValueOrParse(scriptExecutor, args[1]);
|
||||
} else {
|
||||
firstValue = getValue(scriptExecutor, args[1]);
|
||||
secondValue = getValueOrParse(scriptExecutor, args[2]);
|
||||
}
|
||||
setValue(scriptExecutor, args[0], operation.applyAsInt(firstValue, secondValue));
|
||||
}
|
||||
|
||||
private static void arithmeticInfixCommand(ScriptExecutor scriptExecutor, String[] args, IntUnaryOperator operation) {
|
||||
if (args.length < 1) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cAls erstes Argument fehlt eine Variable");
|
||||
return;
|
||||
}
|
||||
|
||||
int firstValue;
|
||||
if (args.length < 2) {
|
||||
if (!isVariable(scriptExecutor, args[0])) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cDas erste Argument muss eine Variable sein");
|
||||
return;
|
||||
}
|
||||
firstValue = getValue(scriptExecutor, args[0]);
|
||||
} else {
|
||||
firstValue = getValue(scriptExecutor, args[1]);
|
||||
}
|
||||
setValue(scriptExecutor, args[0], operation.applyAsInt(firstValue));
|
||||
}
|
||||
|
||||
private static void inputCommand(ScriptExecutor scriptExecutor, String[] args) {
|
||||
if (args.length < 1) {
|
||||
scriptExecutor.player.sendMessage(BauSystem.PREFIX + "§cAls erstes Argument fehlt eine Variable");
|
||||
return;
|
||||
}
|
||||
String varName = args[0];
|
||||
StringBuilder st = new StringBuilder();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
if (i != 1) {
|
||||
st.append(" ");
|
||||
}
|
||||
st.append(args[i]);
|
||||
}
|
||||
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(scriptExecutor.player, ChatColor.translateAlternateColorCodes('&', st.toString()));
|
||||
swAnvilInv.setCallback(s -> {
|
||||
int value = parseValue(s);
|
||||
setValue(scriptExecutor, varName, value);
|
||||
scriptExecutor.resume();
|
||||
});
|
||||
swAnvilInv.open();
|
||||
}
|
||||
|
||||
private static void setValue(ScriptExecutor scriptExecutor, String key, int value) {
|
||||
scriptExecutor.variables.put(key, value);
|
||||
}
|
||||
|
||||
private static void add(ScriptExecutor scriptExecutor, String key, int value) {
|
||||
if (!isVariable(scriptExecutor, key)) {
|
||||
scriptExecutor.variables.put(key, 0);
|
||||
}
|
||||
scriptExecutor.variables.put(key, scriptExecutor.variables.get(key) + value);
|
||||
}
|
||||
|
||||
private static int getValueOrParse(ScriptExecutor scriptExecutor, String key) {
|
||||
if (isVariable(scriptExecutor, key)) {
|
||||
return getValue(scriptExecutor, key);
|
||||
} else {
|
||||
return parseValue(key);
|
||||
}
|
||||
}
|
||||
|
||||
private static int getValue(ScriptExecutor scriptExecutor, String key) {
|
||||
if (CONSTANTS.containsKey(key)) {
|
||||
return CONSTANTS.get(key).apply(scriptExecutor.player);
|
||||
}
|
||||
if (GLOBAL_VARIABLES.containsKey(scriptExecutor.player) && GLOBAL_VARIABLES.get(scriptExecutor.player).containsKey(key)) {
|
||||
return GLOBAL_VARIABLES.get(scriptExecutor.player).get(key);
|
||||
}
|
||||
return scriptExecutor.variables.getOrDefault(key, 0);
|
||||
}
|
||||
|
||||
private static int getConstantValue(ScriptExecutor scriptExecutor, String key) {
|
||||
return CONSTANTS.getOrDefault(key, player -> 0).apply(scriptExecutor.player);
|
||||
}
|
||||
|
||||
private static int getGlobalValue(ScriptExecutor scriptExecutor, String key) {
|
||||
if (!GLOBAL_VARIABLES.containsKey(scriptExecutor.player)) {
|
||||
return 0;
|
||||
}
|
||||
return GLOBAL_VARIABLES.get(scriptExecutor.player).getOrDefault(key, 0);
|
||||
}
|
||||
|
||||
private static int getLocalValue(ScriptExecutor scriptExecutor, String key) {
|
||||
return scriptExecutor.variables.getOrDefault(key, 0);
|
||||
}
|
||||
|
||||
private static boolean isVariable(ScriptExecutor scriptExecutor, String key) {
|
||||
if (CONSTANTS.containsKey(key)) {
|
||||
return true;
|
||||
}
|
||||
if (GLOBAL_VARIABLES.containsKey(scriptExecutor.player) && GLOBAL_VARIABLES.get(scriptExecutor.player).containsKey(key)) {
|
||||
return true;
|
||||
}
|
||||
return scriptExecutor.variables.containsKey(key);
|
||||
}
|
||||
|
||||
private static boolean isLocalVariable(ScriptExecutor scriptExecutor, String key) {
|
||||
return isVariable(scriptExecutor, key) && !isGlobalVariable(scriptExecutor, key);
|
||||
}
|
||||
|
||||
private static boolean isGlobalVariable(ScriptExecutor scriptExecutor, String key) {
|
||||
if (!GLOBAL_VARIABLES.containsKey(scriptExecutor.player)) {
|
||||
return false;
|
||||
}
|
||||
return GLOBAL_VARIABLES.get(scriptExecutor.player).containsKey(key);
|
||||
}
|
||||
|
||||
public static int parseValue(String value) {
|
||||
if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes")) {
|
||||
return 1;
|
||||
} else if (value.equalsIgnoreCase("false") || value.equalsIgnoreCase("no")) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(value);
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package de.steamwar.bausystem.world;
|
||||
|
||||
@SuppressWarnings({"unused", "UnusedReturnValue"})
|
||||
public class SizedStack<T> {
|
||||
|
||||
private final int maxSize;
|
||||
private final T[] data;
|
||||
private int size;
|
||||
private int head;
|
||||
|
||||
public SizedStack(int size) {
|
||||
this.maxSize = size;
|
||||
this.data = (T[]) new Object[this.maxSize];
|
||||
this.head = 0;
|
||||
this.size = 0;
|
||||
}
|
||||
|
||||
public T push(final T element) {
|
||||
this.data[this.head] = element;
|
||||
this.increaseHead();
|
||||
this.increaseSize();
|
||||
return element;
|
||||
}
|
||||
|
||||
public T pop() {
|
||||
this.decreaseHead();
|
||||
this.decreaseSize();
|
||||
final T result = this.data[this.head];
|
||||
this.data[this.head] = null;
|
||||
return result;
|
||||
}
|
||||
|
||||
public T peek() {
|
||||
return this.data[this.head];
|
||||
}
|
||||
|
||||
public boolean empty() {
|
||||
return this.size == 0;
|
||||
}
|
||||
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof SizedStack;
|
||||
}
|
||||
|
||||
private void increaseHead() {
|
||||
this.head++;
|
||||
while (this.head > this.maxSize - 1) {
|
||||
this.head -= this.maxSize;
|
||||
}
|
||||
}
|
||||
|
||||
private void decreaseHead() {
|
||||
this.head--;
|
||||
while (this.head < 0) {
|
||||
this.head += this.maxSize;
|
||||
}
|
||||
}
|
||||
|
||||
private void increaseSize() {
|
||||
if (this.size < this.maxSize) {
|
||||
this.size++;
|
||||
}
|
||||
}
|
||||
|
||||
private void decreaseSize() {
|
||||
if (this.size > 0) {
|
||||
this.size--;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
result = result * PRIME + this.maxSize;
|
||||
result = result * PRIME + this.toString().hashCode();
|
||||
result = result * PRIME + this.size;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof SizedStack)) {
|
||||
return false;
|
||||
}
|
||||
final SizedStack<?> other = (SizedStack<?>) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (this.maxSize != other.maxSize) {
|
||||
return false;
|
||||
}
|
||||
if (this.size != other.size) {
|
||||
return false;
|
||||
}
|
||||
if (!this.data.getClass().equals(other.data.getClass())) {
|
||||
return false;
|
||||
}
|
||||
return this.toString().equals(other.toString());
|
||||
}
|
||||
|
||||
public int getMaxSize() {
|
||||
return maxSize;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder result = new StringBuilder("[");
|
||||
for (int i = 0; i < this.size - 1; i++) {
|
||||
result.append(this.data[(this.head - i - 1 < 0) ? (this.head - i - 1 + this.maxSize) : (this.head - i - 1)]).append(",");
|
||||
}
|
||||
result.append(this.data[(this.head - this.size < 0) ? (this.head - this.size + this.maxSize) : (this.head - this.size)]);
|
||||
result.append("]");
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
*
|
||||
* 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.world;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.CraftbukkitWrapper;
|
||||
import de.steamwar.bausystem.commands.CommandTPSLimiter;
|
||||
import de.steamwar.core.TPSWatcher;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class TPSUtils {
|
||||
|
||||
private TPSUtils() {
|
||||
throw new IllegalStateException("Utility Class");
|
||||
}
|
||||
|
||||
private static boolean warp = true;
|
||||
private static long nanoOffset = 0;
|
||||
private static long nanoDOffset = 0;
|
||||
|
||||
public static void disableWarp() {
|
||||
warp = false;
|
||||
}
|
||||
|
||||
public static long getNanoOffset() {
|
||||
return nanoOffset;
|
||||
}
|
||||
|
||||
private static long ticksSinceServerStart = 0;
|
||||
public static final Supplier<Long> currentTick = () -> ticksSinceServerStart;
|
||||
|
||||
public static void init() {
|
||||
CraftbukkitWrapper.impl.initTPS();
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> nanoOffset += nanoDOffset, 1, 1);
|
||||
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> ticksSinceServerStart++, 1, 1);
|
||||
}
|
||||
|
||||
public static void setTPS(double tps) {
|
||||
double d = 50 - (50 / (tps / 20.0));
|
||||
nanoDOffset = Math.max(0, Math.min((long) (d * 1000000), 37500000));
|
||||
}
|
||||
|
||||
public static boolean isWarpAllowed() {
|
||||
return warp;
|
||||
}
|
||||
|
||||
public static boolean isWarping() {
|
||||
return nanoDOffset > 0;
|
||||
}
|
||||
|
||||
public static double getTps(TPSWatcher.TPSType tpsType) {
|
||||
if (TPSUtils.isWarping())
|
||||
return TPSWatcher.getTPS(tpsType, Math.max(CommandTPSLimiter.getCurrentTPSLimit(), 20));
|
||||
return TPSWatcher.getTPS(tpsType);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
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.world;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Welt {
|
||||
|
||||
private Welt() {
|
||||
}
|
||||
|
||||
public static boolean noPermission(Player member, Permission perm) {
|
||||
if (member.getUniqueId().equals(BauSystem.getOwner()))
|
||||
return false;
|
||||
|
||||
BauweltMember member1 = BauweltMember.getBauMember(BauSystem.getOwner(), member.getUniqueId());
|
||||
if (member1 == null)
|
||||
return true;
|
||||
|
||||
switch (perm) {
|
||||
case WORLDEDIT:
|
||||
return !member1.isWorldEdit();
|
||||
case WORLD:
|
||||
return !member1.isWorld();
|
||||
case MEMBER:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.world.regions;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public 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, RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBuildRegion() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTestblock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasProtection() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasExtensionArea(RegionType regionType) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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.world.regions;
|
||||
|
||||
import de.steamwar.bausystem.world.Color;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PasteOptions {
|
||||
|
||||
/**
|
||||
* Used in 1.12 and 1.15
|
||||
*/
|
||||
private boolean rotate = false;
|
||||
|
||||
/**
|
||||
* Used in 1.12 and 1.15
|
||||
*/
|
||||
private boolean ignoreAir = false;
|
||||
|
||||
/**
|
||||
* Used in 1.15
|
||||
*/
|
||||
private Color color = Color.YELLOW;
|
||||
|
||||
/**
|
||||
* Used in 1.15
|
||||
*/
|
||||
private boolean reset = false;
|
||||
|
||||
/**
|
||||
* Used in 1.15
|
||||
*/
|
||||
private Point minPoint = null;
|
||||
|
||||
/**
|
||||
* Used in 1.15
|
||||
*/
|
||||
private Point maxPoint = null;
|
||||
|
||||
/**
|
||||
* Used in 1.15
|
||||
*/
|
||||
private int waterLevel = 0;
|
||||
|
||||
public PasteOptions(boolean rotate) {
|
||||
this.rotate = rotate;
|
||||
}
|
||||
|
||||
public PasteOptions(boolean rotate, Color color) {
|
||||
this.rotate = rotate;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public PasteOptions(boolean rotate, boolean ignoreAir) {
|
||||
this.rotate = rotate;
|
||||
this.ignoreAir = ignoreAir;
|
||||
}
|
||||
|
||||
public PasteOptions(boolean rotate, boolean ignoreAir, boolean reset) {
|
||||
this.rotate = rotate;
|
||||
this.ignoreAir = ignoreAir;
|
||||
this.reset = reset;
|
||||
}
|
||||
|
||||
public PasteOptions(boolean rotate, Color color, boolean reset) {
|
||||
this.rotate = rotate;
|
||||
this.color = color;
|
||||
this.reset = reset;
|
||||
}
|
||||
|
||||
public PasteOptions(boolean rotate, boolean ignoreAir, Color color) {
|
||||
this.rotate = rotate;
|
||||
this.ignoreAir = ignoreAir;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.world.regions;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class Point {
|
||||
final int x;
|
||||
final int y;
|
||||
final int z;
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* 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.world.regions;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.bausystem.WorldeditWrapper;
|
||||
import de.steamwar.bausystem.world.Color;
|
||||
import de.steamwar.sql.NoClipboardException;
|
||||
import de.steamwar.sql.SchematicData;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Prototype {
|
||||
static final Map<String, Prototype> prototypes = new HashMap<>();
|
||||
|
||||
private final int sizeX;
|
||||
private final int sizeY;
|
||||
private final int sizeZ;
|
||||
|
||||
private final int offsetX;
|
||||
private final int offsetY;
|
||||
private final int offsetZ;
|
||||
|
||||
private final int extensionPositiveZ;
|
||||
private final int extensionNegativeZ;
|
||||
private final int extensionPositiveY;
|
||||
private final int extensionAxisX;
|
||||
final boolean extensionPrototypeArea;
|
||||
|
||||
private final int waterLevel;
|
||||
|
||||
private final String schematic;
|
||||
private final boolean rotate;
|
||||
|
||||
final Prototype testblock; //nullable
|
||||
final Prototype buildArea; //nullable
|
||||
|
||||
private final String protectSchematic; //nullable
|
||||
|
||||
Prototype(ConfigurationSection config) {
|
||||
sizeX = config.getInt("sizeX");
|
||||
sizeY = config.getInt("sizeY");
|
||||
sizeZ = config.getInt("sizeZ");
|
||||
schematic = config.getString("schematic");
|
||||
offsetX = config.getInt("offsetX", 0);
|
||||
offsetY = config.getInt("offsetY", 0);
|
||||
offsetZ = config.getInt("offsetZ", 0);
|
||||
extensionPositiveZ = config.getInt("extensionPositiveZ", 0);
|
||||
extensionNegativeZ = config.getInt("extensionNegativeZ", 0);
|
||||
extensionPositiveY = config.getInt("extensionPositiveY", 0);
|
||||
extensionAxisX = config.getInt("extensionAxisX", 0);
|
||||
if (config.contains("extensionPositiveZ") || config.contains("extensionNegativeZ") || config.contains("extensionPositiveY") || config.contains("extensionAxisX")) {
|
||||
Region.extensionArea = true;
|
||||
}
|
||||
extensionPrototypeArea = extensionNegativeZ != 0 || extensionPositiveZ != 0 || extensionPositiveY != 0 || extensionAxisX != 0;
|
||||
waterLevel = config.getInt("waterLevel", 0);
|
||||
rotate = config.getBoolean("rotate", false);
|
||||
|
||||
ConfigurationSection testblockSection = config.getConfigurationSection("testblock");
|
||||
testblock = testblockSection != null ? new Prototype(testblockSection) : null;
|
||||
|
||||
ConfigurationSection buildAreaSection = config.getConfigurationSection("buildArea");
|
||||
buildArea = buildAreaSection != null ? new Prototype(buildAreaSection) : null;
|
||||
if (buildArea != null) {
|
||||
Region.buildArea = true;
|
||||
}
|
||||
|
||||
protectSchematic = config.getString("protection", null);
|
||||
|
||||
if (!config.getName().equals("testblock") && !config.getName().equals("buildArea"))
|
||||
prototypes.put(config.getName(), this);
|
||||
}
|
||||
|
||||
public Point getMinPoint(Region region, RegionExtensionType regionExtensionType) {
|
||||
switch (regionExtensionType) {
|
||||
case EXTENSION:
|
||||
return new Point(
|
||||
region.minPoint.getX() + offsetX - extensionAxisX,
|
||||
region.minPoint.getY() + offsetY,
|
||||
region.minPoint.getZ() + offsetZ - extensionNegativeZ
|
||||
);
|
||||
default:
|
||||
case NORMAL:
|
||||
return new Point(
|
||||
region.minPoint.getX() + offsetX,
|
||||
region.minPoint.getY() + offsetY,
|
||||
region.minPoint.getZ() + offsetZ
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public Point getMaxPoint(Region region, RegionExtensionType regionExtensionType) {
|
||||
switch (regionExtensionType) {
|
||||
case EXTENSION:
|
||||
return new Point(
|
||||
region.minPoint.getX() + offsetX - extensionAxisX + (sizeX + extensionAxisX * 2) - 1,
|
||||
region.minPoint.getY() + offsetY + sizeY + extensionPositiveY - 1,
|
||||
region.minPoint.getZ() + offsetZ - extensionNegativeZ + (sizeZ + extensionNegativeZ + extensionPositiveZ) - 1
|
||||
);
|
||||
default:
|
||||
case NORMAL:
|
||||
return new Point(
|
||||
region.minPoint.getX() + offsetX + sizeX - 1,
|
||||
region.minPoint.getY() + offsetY + sizeY - 1,
|
||||
region.minPoint.getZ() + offsetZ + sizeZ - 1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean inRegion(Region region, Location l, RegionExtensionType regionExtensionType) {
|
||||
switch (regionExtensionType) {
|
||||
case EXTENSION:
|
||||
return inRange(l.getX(), region.minPoint.getX() + offsetX - extensionAxisX, sizeX + extensionAxisX * 2) &&
|
||||
inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY + extensionPositiveY) &&
|
||||
inRange(l.getZ(), region.minPoint.getZ() + offsetZ - extensionNegativeZ, sizeZ + extensionNegativeZ + extensionPositiveZ);
|
||||
default:
|
||||
case NORMAL:
|
||||
return inRange(l.getX(), region.minPoint.getX() + offsetX, sizeX) &&
|
||||
inRange(l.getY(), region.minPoint.getY() + offsetY, sizeY) &&
|
||||
inRange(l.getZ(), region.minPoint.getZ() + offsetZ, sizeZ);
|
||||
}
|
||||
}
|
||||
|
||||
public EditSession reset(Region region, SchematicNode schem, boolean ignoreAir, Color color) throws IOException, NoClipboardException {
|
||||
return reset(region, schem, ignoreAir, color, false);
|
||||
}
|
||||
|
||||
public EditSession reset(Region region, SchematicNode schem, boolean ignoreAir, Color color, boolean reset) throws IOException, NoClipboardException {
|
||||
PasteOptions pasteOptions;
|
||||
if (reset) {
|
||||
pasteOptions = new PasteOptions(rotate ^ (schem != null && (schem.getSchemtype().fightType() || schem.getSchemtype().check())), ignoreAir, color, true, getMinPoint(region, RegionExtensionType.EXTENSION), getMaxPoint(region, RegionExtensionType.EXTENSION), waterLevel);
|
||||
} else {
|
||||
pasteOptions = new PasteOptions(rotate ^ (schem != null && (schem.getSchemtype().fightType() || schem.getSchemtype().check())), ignoreAir, color);
|
||||
}
|
||||
|
||||
int x = region.minPoint.getX() + offsetX + sizeX / 2;
|
||||
int y = region.minPoint.getY() + offsetY;
|
||||
int z = region.minPoint.getZ() + offsetZ + sizeZ / 2;
|
||||
if (schem == null) {
|
||||
return paste(new File(schematic), x, y, z, pasteOptions);
|
||||
} else {
|
||||
return paste(new SchematicData(schem).load(), x, y, z, pasteOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasProtection() {
|
||||
return protectSchematic != null;
|
||||
}
|
||||
|
||||
public EditSession protect(Region region, SchematicNode schem) throws IOException, NoClipboardException {
|
||||
int x = region.minPoint.getX() + offsetX + sizeX / 2;
|
||||
int y = region.minPoint.getY() + testblock.offsetY - 1;
|
||||
int z = region.minPoint.getZ() + offsetZ + sizeZ / 2;
|
||||
if (schem == null) {
|
||||
return paste(new File(protectSchematic), x, y, z, new PasteOptions(rotate, false, Color.YELLOW));
|
||||
} else {
|
||||
return paste(new SchematicData(schem).load(), x, y, z, new PasteOptions(rotate, false, Color.YELLOW));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasTestblock() {
|
||||
return testblock != null;
|
||||
}
|
||||
|
||||
public EditSession resetTestblock(Region region, SchematicNode schem, Color color, boolean reset) throws IOException, NoClipboardException {
|
||||
return testblock.reset(region, schem, false, color, reset && waterLevel == 0);
|
||||
}
|
||||
|
||||
private static boolean inRange(double l, int min, int size) {
|
||||
return min <= l && l < min + size;
|
||||
}
|
||||
|
||||
private static EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions) { //Type of protect
|
||||
return WorldeditWrapper.impl.paste(file, x, y, z, pasteOptions);
|
||||
}
|
||||
|
||||
private static EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) {
|
||||
return WorldeditWrapper.impl.paste(clipboard, x, y, z, pasteOptions);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,388 @@
|
||||
/*
|
||||
* 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.world.regions;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import de.steamwar.bausystem.commands.CommandTNT.TNTMode;
|
||||
import de.steamwar.bausystem.world.Color;
|
||||
import de.steamwar.bausystem.world.SizedStack;
|
||||
import de.steamwar.sql.NoClipboardException;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Region {
|
||||
|
||||
private static final List<Region> regions = new ArrayList<>();
|
||||
static boolean buildArea = false;
|
||||
static boolean extensionArea = false;
|
||||
private static JsonObject regionsObject = new JsonObject();
|
||||
|
||||
static {
|
||||
File regionsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.json");
|
||||
if (regionsFile.exists()) {
|
||||
try {
|
||||
regionsObject = new JsonParser().parse(new FileReader(regionsFile)).getAsJsonObject();
|
||||
} catch (JsonSyntaxException | IOException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Item JSON error");
|
||||
}
|
||||
}
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
try {
|
||||
config.load(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections.yml"));
|
||||
} catch (InvalidConfigurationException | IOException e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Failed to load sections.yml", e);
|
||||
}
|
||||
|
||||
ConfigurationSection prototypes = config.getConfigurationSection("prototypes");
|
||||
assert prototypes != null;
|
||||
for (String prototype : prototypes.getKeys(false)) {
|
||||
new Prototype(Objects.requireNonNull(prototypes.getConfigurationSection(prototype)));
|
||||
}
|
||||
|
||||
ConfigurationSection regions = config.getConfigurationSection("regions");
|
||||
assert regions != null;
|
||||
for (String region : regions.getKeys(false)) {
|
||||
new Region(Objects.requireNonNull(regions.getConfigurationSection(region)));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean buildAreaEnabled() {
|
||||
return buildArea;
|
||||
}
|
||||
|
||||
public static boolean extensionAreaEnabled() {
|
||||
return extensionArea;
|
||||
}
|
||||
|
||||
public static Region getRegion(Location location) {
|
||||
for (Region region : regions) {
|
||||
if (region.inRegion(location, RegionType.NORMAL, RegionExtensionType.NORMAL)) {
|
||||
return region;
|
||||
}
|
||||
}
|
||||
return GlobalRegion.getInstance();
|
||||
}
|
||||
|
||||
public static void setGlobalColor(Color color) {
|
||||
for (Region region : regions) {
|
||||
region.setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
File colorsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.json");
|
||||
if (!colorsFile.exists()) {
|
||||
try {
|
||||
colorsFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(colorsFile)) {
|
||||
fileOutputStream.write(regionsObject.toString().getBytes());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
|
||||
private final String name;
|
||||
final Point minPoint;
|
||||
private final Prototype prototype;
|
||||
private final String optionsLinkedWith; // nullable
|
||||
private Region linkedRegion = null; // nullable
|
||||
private SizedStack<EditSession> undosessions;
|
||||
private SizedStack<EditSession> redosessions;
|
||||
|
||||
private JsonObject regionOptions = new JsonObject();
|
||||
|
||||
@Getter
|
||||
private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF;
|
||||
|
||||
@Getter
|
||||
private boolean freeze = false;
|
||||
|
||||
@Getter
|
||||
private boolean fire = false;
|
||||
|
||||
@Getter
|
||||
private boolean protect = false;
|
||||
|
||||
@Getter
|
||||
private Color color = Color.YELLOW;
|
||||
|
||||
private Region(ConfigurationSection config) {
|
||||
name = config.getName();
|
||||
minPoint = new Point(config.getInt("minX"), config.getInt("minY"), config.getInt("minZ"));
|
||||
prototype = Prototype.prototypes.get(config.getString("prototype"));
|
||||
optionsLinkedWith = config.getString("optionsLinkedWith", null);
|
||||
if (!hasTestblock()) tntMode = TNTMode.OFF;
|
||||
regions.add(this);
|
||||
load();
|
||||
}
|
||||
|
||||
public Region(String name) {
|
||||
this.name = name;
|
||||
this.minPoint = new Point(0, 0, 0);
|
||||
this.prototype = null;
|
||||
this.optionsLinkedWith = null;
|
||||
tntMode = TNTMode.OFF;
|
||||
load();
|
||||
}
|
||||
|
||||
private void load() {
|
||||
if (regionsObject.has(name)) {
|
||||
regionOptions = regionsObject.getAsJsonObject(name);
|
||||
if (regionOptions.has("tnt")) {
|
||||
String tntName = regionsObject.getAsJsonObject(name).getAsJsonPrimitive("tnt").getAsString();
|
||||
try {
|
||||
tntMode = TNTMode.valueOf(tntName);
|
||||
} catch (Exception e) {
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
|
||||
if (regionOptions.has("fire")) {
|
||||
fire = regionOptions.getAsJsonPrimitive("fire").getAsBoolean();
|
||||
}
|
||||
|
||||
if (regionOptions.has("freeze")) {
|
||||
freeze = regionOptions.getAsJsonPrimitive("freeze").getAsBoolean();
|
||||
}
|
||||
|
||||
if (regionOptions.has("protect")) {
|
||||
protect = regionOptions.getAsJsonPrimitive("protect").getAsBoolean();
|
||||
}
|
||||
|
||||
if (regionOptions.has("color")) {
|
||||
String colorName = regionOptions.getAsJsonPrimitive("color").getAsString();
|
||||
try {
|
||||
color = Color.valueOf(colorName);
|
||||
} catch (Exception e) {
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
} else {
|
||||
regionsObject.add(name, regionOptions);
|
||||
}
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
this.color = color;
|
||||
regionOptions.add("color", new JsonPrimitive(color.name()));
|
||||
}
|
||||
|
||||
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 void setTntMode(TNTMode tntMode) {
|
||||
this.tntMode = tntMode;
|
||||
setLinkedRegion(region -> {
|
||||
region.tntMode = tntMode;
|
||||
region.regionOptions.add("tnt", new JsonPrimitive(tntMode.name()));
|
||||
});
|
||||
regionOptions.add("tnt", new JsonPrimitive(tntMode.name()));
|
||||
}
|
||||
|
||||
public void setFreeze(boolean freeze) {
|
||||
this.freeze = freeze;
|
||||
setLinkedRegion(region -> {
|
||||
region.freeze = freeze;
|
||||
region.regionOptions.add("freeze", new JsonPrimitive(freeze));
|
||||
});
|
||||
regionOptions.add("freeze", new JsonPrimitive(freeze));
|
||||
}
|
||||
|
||||
public void setFire(boolean fire) {
|
||||
this.fire = fire;
|
||||
setLinkedRegion(region -> {
|
||||
region.fire = fire;
|
||||
region.regionOptions.add("fire", new JsonPrimitive(fire));
|
||||
});
|
||||
regionOptions.add("fire", new JsonPrimitive(fire));
|
||||
}
|
||||
|
||||
public void setProtect(boolean protect) {
|
||||
this.protect = protect;
|
||||
setLinkedRegion(region -> {
|
||||
region.protect = protect;
|
||||
region.regionOptions.add("protect", new JsonPrimitive(protect));
|
||||
});
|
||||
regionOptions.add("protect", new JsonPrimitive(protect));
|
||||
}
|
||||
|
||||
public Point getMinPoint(RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
switch (regionType) {
|
||||
case BUILD:
|
||||
return prototype.buildArea.getMinPoint(this, regionExtensionType);
|
||||
case TESTBLOCK:
|
||||
return prototype.testblock.getMinPoint(this, regionExtensionType);
|
||||
default:
|
||||
case NORMAL:
|
||||
return prototype.getMinPoint(this, regionExtensionType);
|
||||
}
|
||||
}
|
||||
|
||||
public Point getMaxPoint(RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
switch (regionType) {
|
||||
case BUILD:
|
||||
return prototype.buildArea.getMaxPoint(this, regionExtensionType);
|
||||
case TESTBLOCK:
|
||||
return prototype.testblock.getMaxPoint(this, regionExtensionType);
|
||||
default:
|
||||
case NORMAL:
|
||||
return prototype.getMaxPoint(this, regionExtensionType);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean inRegion(Location l, RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
switch (regionType) {
|
||||
case BUILD:
|
||||
return prototype.buildArea.inRegion(this, l, regionExtensionType);
|
||||
case TESTBLOCK:
|
||||
return prototype.testblock.inRegion(this, l, regionExtensionType);
|
||||
default:
|
||||
case NORMAL:
|
||||
return prototype.inRegion(this, l, regionExtensionType);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasBuildRegion() {
|
||||
return prototype.buildArea != null;
|
||||
}
|
||||
|
||||
public void reset(SchematicNode schem, boolean ignoreAir) throws IOException, NoClipboardException {
|
||||
initSessions();
|
||||
undosessions.push(prototype.reset(this, schem, ignoreAir, color));
|
||||
}
|
||||
|
||||
public boolean hasTestblock() {
|
||||
return prototype.hasTestblock();
|
||||
}
|
||||
|
||||
public void resetTestblock(SchematicNode schem, boolean reset) throws IOException, NoClipboardException {
|
||||
initSessions();
|
||||
undosessions.push(prototype.resetTestblock(this, schem, color, reset));
|
||||
}
|
||||
|
||||
public boolean hasProtection() {
|
||||
return prototype.hasProtection();
|
||||
}
|
||||
|
||||
public void protect(SchematicNode schem) throws IOException, NoClipboardException {
|
||||
initSessions();
|
||||
undosessions.push(prototype.protect(this, schem));
|
||||
}
|
||||
|
||||
public int getProtectYLevel() {
|
||||
return getMinPoint(RegionType.TESTBLOCK, RegionExtensionType.NORMAL).getY();
|
||||
}
|
||||
|
||||
public boolean hasExtensionArea(RegionType regionType) {
|
||||
switch (regionType) {
|
||||
case BUILD:
|
||||
return prototype.buildArea.extensionPrototypeArea;
|
||||
case TESTBLOCK:
|
||||
return prototype.testblock.extensionPrototypeArea;
|
||||
default:
|
||||
case NORMAL:
|
||||
return prototype.extensionPrototypeArea;
|
||||
}
|
||||
}
|
||||
|
||||
private void initSessions() {
|
||||
if (undosessions == null) {
|
||||
undosessions = new SizedStack<>(20);
|
||||
redosessions = new SizedStack<>(20);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean undo() {
|
||||
initSessions();
|
||||
EditSession session = null;
|
||||
try {
|
||||
session = undosessions.pop();
|
||||
if (session == null) {
|
||||
return false;
|
||||
}
|
||||
session.undo(session);
|
||||
redosessions.push(session);
|
||||
return true;
|
||||
} finally {
|
||||
if (session != null) {
|
||||
session.flushQueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean redo() {
|
||||
initSessions();
|
||||
EditSession session = null;
|
||||
try {
|
||||
session = redosessions.pop();
|
||||
if (session == null) {
|
||||
return false;
|
||||
}
|
||||
session.redo(session);
|
||||
undosessions.push(session);
|
||||
return true;
|
||||
} finally {
|
||||
if (session != null) {
|
||||
session.flushQueue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.world.regions;
|
||||
|
||||
public enum RegionExtensionType {
|
||||
NORMAL,
|
||||
EXTENSION
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.world.regions;
|
||||
|
||||
public enum RegionSelectionType {
|
||||
GLOBAL,
|
||||
LOCAL
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.world.regions;
|
||||
|
||||
public enum RegionType {
|
||||
NORMAL,
|
||||
BUILD,
|
||||
TESTBLOCK
|
||||
}
|
||||
Reference in New Issue
Block a user