forked from SteamWar/SteamWar
Add LegacyBauSystem with adaptions to current SpigotCore
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CommandClear extends SWCommand {
|
||||
|
||||
public CommandClear() {
|
||||
super("clear");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§eclear §8- §7Leere dein Inventar");
|
||||
p.sendMessage("§8/§ebau clear §8[§7Player§8] §8- §7Leere ein Spieler Inventar");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericClearCommand(Player p) {
|
||||
clear(p);
|
||||
p.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde geleert.");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void clearPlayerCommand(Player p, Player target) {
|
||||
if (!permissionCheck(p)) return;
|
||||
clear(target);
|
||||
target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von " + p.getDisplayName() + " §7geleert.");
|
||||
p.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() + " §7wurde geleert.");
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.WORLD)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine fremden Inventare leeren.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void clear(Player player) {
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setHelmet(new ItemStack(Material.AIR));
|
||||
player.getInventory().setChestplate(new ItemStack(Material.AIR));
|
||||
player.getInventory().setLeggings(new ItemStack(Material.AIR));
|
||||
player.getInventory().setBoots(new ItemStack(Material.AIR));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.world.Color;
|
||||
import de.steamwar.bausystem.world.regions.GlobalRegion;
|
||||
import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class CommandColor extends SWCommand {
|
||||
|
||||
private static CommandColor instance = null;
|
||||
|
||||
public CommandColor() {
|
||||
super("color");
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static CommandColor getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region");
|
||||
p.sendMessage("§8/§ecolor §8[§7Color§8] §8[§7Type§8] §8- §7Setze die Farbe der Region oder Global");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericColor(Player p, Color color) {
|
||||
genericColorSet(p, color, ColorizationType.LOCAL);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericColorSet(Player p, Color color, ColorizationType colorizationType) {
|
||||
if (!permissionCheck(p)) {
|
||||
return;
|
||||
}
|
||||
if (colorizationType == ColorizationType.GLOBAL) {
|
||||
Region.setGlobalColor(color);
|
||||
p.sendMessage(BauSystem.PREFIX + "Alle Regions farben auf §e" + color.name().toLowerCase() + "§7 gesetzt");
|
||||
return;
|
||||
}
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (GlobalRegion.isGlobalRegion(region)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
||||
return;
|
||||
}
|
||||
region.setColor(color);
|
||||
p.sendMessage(BauSystem.PREFIX + "Regions farben auf §e" + color.name().toLowerCase() + "§7 gesetzt");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericColorSet(Player p, ColorizationType colorizationType, Color color) {
|
||||
genericColorSet(p, color, colorizationType);
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player p) {
|
||||
if (!BauSystem.getOwner().equals(p.getUniqueId())) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDies ist nicht deine Welt!");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ColorizationType {
|
||||
LOCAL,
|
||||
GLOBAL
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.FlatteningWrapper;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandDebugStick extends SWCommand {
|
||||
|
||||
public CommandDebugStick() {
|
||||
super("debugstick");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§edebugstick §8- §7Erhalte einen DebugStick");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p) {
|
||||
FlatteningWrapper.impl.giveStick(p);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.world.Detonator;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandDetonator extends SWCommand {
|
||||
|
||||
public CommandDetonator() {
|
||||
super ("detonator", "dt");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§edetonator wand §8- §7Legt den Fernzünder ins Inventar");
|
||||
p.sendMessage("§8/§edetonator detonate §8- §7Benutzt den nächst besten Fernzünder");
|
||||
p.sendMessage("§8/§edetonator reset §8- §7Löscht alle markierten Positionen");
|
||||
p.sendMessage("§8/§edetonator remove §8- §7Entfernt den Fernzünder");
|
||||
}
|
||||
|
||||
@Register("wand")
|
||||
public void wandCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
||||
}
|
||||
|
||||
@Register("detonator")
|
||||
public void detonatorCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
||||
}
|
||||
|
||||
@Register("item")
|
||||
public void itemCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
||||
}
|
||||
|
||||
|
||||
@Register("remove")
|
||||
public void removeCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
p.getInventory().removeItem(Detonator.WAND);
|
||||
}
|
||||
|
||||
|
||||
@Register("detonate")
|
||||
public void detonateCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Detonator.execute(p);
|
||||
}
|
||||
|
||||
@Register("click")
|
||||
public void clickCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Detonator.execute(p);
|
||||
}
|
||||
|
||||
@Register("use")
|
||||
public void useCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Detonator.execute(p);
|
||||
}
|
||||
|
||||
|
||||
@Register("clear")
|
||||
public void clearCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Detonator.clear(p);
|
||||
}
|
||||
|
||||
@Register("delete")
|
||||
public void deleteCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Detonator.clear(p);
|
||||
}
|
||||
|
||||
@Register("reset")
|
||||
public void resetCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Detonator.clear(p);
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.WORLD)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
|
||||
public class CommandFire extends SWCommand implements Listener {
|
||||
|
||||
public CommandFire() {
|
||||
super("fire");
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§efire §8- §7Toggle Feuerschaden");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void toggleCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (toggle(region)) {
|
||||
RegionUtils.actionBar(region, getEnableMessage());
|
||||
} else {
|
||||
RegionUtils.actionBar(region, getDisableMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String getNoPermMessage() {
|
||||
return "§cDu darfst hier nicht Feuerschaden (de-)aktivieren";
|
||||
}
|
||||
|
||||
private String getEnableMessage() {
|
||||
return "§cRegions Feuerschaden deaktiviert";
|
||||
}
|
||||
|
||||
private String getDisableMessage() {
|
||||
return "§aRegions Feuerschaden aktiviert";
|
||||
}
|
||||
|
||||
private boolean toggle(Region region) {
|
||||
region.setFire(!region.isFire());
|
||||
return region.isFire();
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.WORLD)) {
|
||||
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFireDamage(BlockBurnEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFireSpread(BlockSpreadEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.Core;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
|
||||
public class CommandFreeze extends SWCommand implements Listener {
|
||||
|
||||
public CommandFreeze() {
|
||||
super("freeze", "stoplag");
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§efreeze §8- §7Toggle Freeze");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void toggleCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (toggle(region)) {
|
||||
RegionUtils.actionBar(region, getEnableMessage());
|
||||
} else {
|
||||
RegionUtils.actionBar(region, getDisableMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String getNoPermMessage() {
|
||||
return "§cDu darfst diese Welt nicht einfrieren";
|
||||
}
|
||||
|
||||
private String getEnableMessage(){
|
||||
return "§cRegion eingefroren";
|
||||
}
|
||||
|
||||
private String getDisableMessage(){
|
||||
return "§aRegion aufgetaut";
|
||||
}
|
||||
|
||||
private boolean toggle(Region region) {
|
||||
region.setFreeze(!region.isFreeze());
|
||||
return region.isFreeze();
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.WORLD)) {
|
||||
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||
if (!Region.getRegion(e.getLocation()).isFreeze()) return;
|
||||
e.setCancelled(true);
|
||||
if (e.getEntityType() == EntityType.PRIMED_TNT) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> {
|
||||
e.getLocation().getBlock().setType(Material.TNT, false);
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||
if (Core.getVersion() == 12) return;
|
||||
if (!e.isBuildable()) return;
|
||||
if (!Region.getRegion(e.getBlock().getLocation()).isFreeze()) return;
|
||||
if (e.getMaterial() == Material.TNT) {
|
||||
e.setBuildable(false);
|
||||
e.getBlock().setType(Material.TNT, false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPhysicsEvent(BlockPhysicsEvent e){
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonExtend(BlockPistonExtendEvent e){
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonRetract(BlockPistonRetractEvent e){
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockGrow(BlockGrowEvent e){
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRedstoneEvent(BlockRedstoneEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setNewCurrent(e.getOldCurrent());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockDispense(BlockDispenseEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
|
||||
if (Region.getRegion(e.getDestination().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,530 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||
import de.steamwar.bausystem.tracer.show.TraceShowManager;
|
||||
import de.steamwar.bausystem.world.*;
|
||||
import de.steamwar.bausystem.world.regions.GlobalRegion;
|
||||
import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CommandGUI extends SWCommand implements Listener {
|
||||
|
||||
private static final Set<Player> OPEN_INVS = new HashSet<>();
|
||||
private static final Set<Player> OPEN_TRACER_INVS = new HashSet<>();
|
||||
private static final Set<Player> LAST_F_PLAYER = new HashSet<>();
|
||||
private static boolean isRefreshing = false;
|
||||
|
||||
public CommandGUI() {
|
||||
super("gui");
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(BauSystem.getPlugin(), LAST_F_PLAYER::clear, 0, 20);
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§egui §8- §7Öffne die GUI");
|
||||
p.sendMessage("§8/§egui item §8- §7Gebe das GUI item");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p) {
|
||||
openBauGui(p);
|
||||
OPEN_INVS.add(p);
|
||||
}
|
||||
|
||||
@Register({"item"})
|
||||
public void itemCommand(Player p) {
|
||||
SWUtils.giveItemToPlayer(p, new ItemStack(Material.NETHER_STAR));
|
||||
}
|
||||
|
||||
public static void openBauGui(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
SWInventory inv = new SWInventory(player, 5 * 9, SteamwarUser.get(BauSystem.getOwner()).getUserName() + "s Bau");
|
||||
inv.setCallback(-1, clickType -> {
|
||||
if (!isRefreshing)
|
||||
OPEN_INVS.remove(player);
|
||||
});
|
||||
|
||||
inv.setItem(43, getMaterial("GLASS_PANE", "THIN_GLASS"), "§7Platzhalter", clickType -> {
|
||||
});
|
||||
inv.setItem(42, Material.NETHER_STAR, "§7Bau GUI Item", Arrays.asList("§7Du kannst dieses Item zum Öffnen der BauGUI nutzen", "§7oder Doppel F (Swap hands) drücken."), false, clickType -> {
|
||||
player.closeInventory();
|
||||
player.performCommand("gui item");
|
||||
});
|
||||
|
||||
ItemStack dtWand = wand(player, Detonator.WAND, "§8/§7dt wand", Permission.WORLD, "§cDu hast keine Worldrechte");
|
||||
inv.setItem(39, dtWand, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
player.closeInventory();
|
||||
player.performCommand("dt wand");
|
||||
});
|
||||
|
||||
ItemStack redstoneWand = wand(player, CommandRedstoneTester.WAND, "§8/§7redstonetester", null, "");
|
||||
inv.setItem(37, redstoneWand, clickType -> {
|
||||
player.closeInventory();
|
||||
player.performCommand("redstonetester");
|
||||
});
|
||||
|
||||
inv.setItem(40, getMaterial("WOODEN_AXE", "WOOD_AXE"), "§eWorldedit Axt", getNoPermsLore(Arrays.asList("§8//§7wand"), player, "§cDu hast keine Worldeditrechte", Permission.WORLDEDIT), false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
player.closeInventory();
|
||||
player.performCommand("/wand");
|
||||
});
|
||||
inv.setItem(41, getMaterial("DEBUG_STICK", "STICK"), "§eDebugstick", getNoPermsLore(Arrays.asList("§8/§7debugstick"), player, "§cDu hast keine Worldrechte", Permission.WORLD), Core.getVersion() < 13, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
player.closeInventory();
|
||||
player.performCommand("debugstick");
|
||||
});
|
||||
|
||||
inv.setItem(20, Material.COMPASS, "§7TPS Limitieren", getNoPermsLore(Arrays.asList("§7Aktuell: §e" + CommandTPSLimiter.getCurrentTPSLimit(), "§8/§7tpslimit §8[§e0,5 - " + (TPSUtils.isWarpAllowed() ? 40 : 20) + "§8]"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
SWAnvilInv anvilInv = new SWAnvilInv(player, "TPS Limitieren");
|
||||
anvilInv.setItem(Material.COMPASS);
|
||||
anvilInv.setCallback(s -> player.performCommand("tpslimit " + s));
|
||||
anvilInv.open();
|
||||
});
|
||||
inv.setItem(5, Material.FEATHER, "§7Geschwindigkeit", Arrays.asList("§7Aktuell: §e" + player.getFlySpeed() * 10, "§8/§7speed §8[§e1 - 10§8]"), false, clickType -> {
|
||||
SWAnvilInv anvilInv = new SWAnvilInv(player, "Geschwindigkeit");
|
||||
anvilInv.setItem(Material.FEATHER);
|
||||
anvilInv.setCallback(s -> player.performCommand("speed " + s));
|
||||
anvilInv.open();
|
||||
});
|
||||
|
||||
if (player.getUniqueId().equals(BauSystem.getOwner())) {
|
||||
SWItem skull = SWItem.getPlayerSkull(player.getName());
|
||||
skull.setName("§7Bau verwalten");
|
||||
List<String> skullLore = new ArrayList<>();
|
||||
skullLore.add("§7TNT: §e" + region.getTntMode().getName());
|
||||
skullLore.add("§7StopLag: §e" + (region.isFreeze() ? "Eingeschaltet" : "Ausgeschaltet"));
|
||||
skullLore.add("§7Fire: §e" + (region.isFire() ? "Ausgeschaltet" : "Eingeschaltet"));
|
||||
skullLore.add("§7Members: §e" + (BauweltMember.getMembers(BauSystem.getOwnerID()).size() - 1));
|
||||
skull.setLore(skullLore);
|
||||
inv.setItem(4, skull);
|
||||
}
|
||||
|
||||
inv.setItem(6, Material.BOOK, "§7Script Bücher", Arrays.asList("§7Aktuell §e" + PredefinedBook.getBookCount() + " §7Bücher"), true, clickType -> {
|
||||
player.closeInventory();
|
||||
scriptBooksGUI(player);
|
||||
});
|
||||
|
||||
inv.setItem(21, Material.OBSERVER, "§7Tracer", getNoPermsLore(Arrays.asList("§7Status: §e" + RecordStateMachine.getRecordStatus().getName()), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
player.closeInventory();
|
||||
OPEN_TRACER_INVS.add(player);
|
||||
traceGUI(player);
|
||||
});
|
||||
|
||||
inv.setItem(22, Material.DISPENSER, "§7Auto-Loader", getNoPermsLore(Arrays.asList("§7Status: " + (AutoLoader.hasLoader(player) ? "§aan" : "§caus")), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
player.closeInventory();
|
||||
autoLoaderGUI(player);
|
||||
});
|
||||
|
||||
inv.setItem(17, getMaterial("PLAYER_HEAD", "SKULL_ITEM"), (byte) 3, "§7Spielerkopf geben", Arrays.asList("§8/§7skull §8[§eSpieler§8]"), false, clickType -> {
|
||||
SWAnvilInv anvilInv = new SWAnvilInv(player, "Spielerköpfe");
|
||||
anvilInv.setItem(Material.NAME_TAG);
|
||||
anvilInv.setCallback(s -> player.performCommand("skull " + s));
|
||||
anvilInv.open();
|
||||
});
|
||||
|
||||
if (GlobalRegion.isGlobalRegion(region)) {
|
||||
inv.setItem(9, Material.BARRIER, "§eKeine Region", clickType -> {
|
||||
});
|
||||
inv.setItem(18, Material.BARRIER, "§eKeine Region", clickType -> {
|
||||
});
|
||||
inv.setItem(27, Material.BARRIER, "§eKeine Region", clickType -> {
|
||||
});
|
||||
} else {
|
||||
inv.setItem(27, getMaterial("HEAVY_WEIGHTED_PRESSURE_PLATE", "IRON_PLATE"), "§eRegion Reseten", getNoPermsLore(Arrays.asList("§8/§7reset"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
confirmationInventory(player, "Region Reseten?", () -> player.performCommand("reset"), () -> openBauGui(player));
|
||||
});
|
||||
|
||||
if (region.hasProtection()) {
|
||||
inv.setItem(18, Material.OBSIDIAN, "§eRegion Protecten", getNoPermsLore(Arrays.asList("§8/§7protect"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
confirmationInventory(player, "Region Protecten", () -> player.performCommand("protect"), () -> openBauGui(player));
|
||||
});
|
||||
} else {
|
||||
inv.setItem(18, Material.BARRIER, "§eRegion nicht Protect bar", clickType -> {
|
||||
});
|
||||
}
|
||||
|
||||
if (region.hasTestblock()) {
|
||||
inv.setItem(9, getMaterial("END_STONE", "ENDER_STONE"), "§eTestblock erneuern", getNoPermsLore(Arrays.asList("§8/§7testblock"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
confirmationInventory(player, "Testblock erneuern", () -> player.performCommand("testblock"), () -> openBauGui(player));
|
||||
});
|
||||
} else {
|
||||
inv.setItem(9, Material.BARRIER, "§eDie Region hat keinen Testblock", clickType -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
|
||||
inv.setItem(26, Material.POTION, "§7Nightvision: §eEingeschaltet", Collections.singletonList("§8/§7nv"), false, clickType -> {
|
||||
CommandNV.toggleNightvision(player);
|
||||
openBauGui(player);
|
||||
});
|
||||
} else {
|
||||
inv.setItem(26, Material.GLASS_BOTTLE, "§7Nightvision: §eAusgeschaltet", Collections.singletonList("§8/§7nv"), false, clickType -> {
|
||||
CommandNV.toggleNightvision(player);
|
||||
openBauGui(player);
|
||||
});
|
||||
}
|
||||
|
||||
if (player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) {
|
||||
inv.setItem(35, Material.WATER_BUCKET, "§7Waterbreathing: §eEingeschaltet", Collections.singletonList("§8/§7wv"), false, clickType -> {
|
||||
CommandGills.toggleGills(player);
|
||||
openBauGui(player);
|
||||
});
|
||||
} else {
|
||||
inv.setItem(35, Material.BUCKET, "§7Waterbreathing: §eAusgeschaltet", Collections.singletonList("§8/§7wv"), false, clickType -> {
|
||||
CommandGills.toggleGills(player);
|
||||
openBauGui(player);
|
||||
});
|
||||
}
|
||||
|
||||
boolean isBuildArea = region.hasBuildRegion();
|
||||
List<String> tntLore = getNoPermsLore(Arrays.asList("§8/§7tnt §8[" + (isBuildArea ? "§eTB§7, " : "") + "§eOff §7oder §eOn§7]"), player, "§cDu hast keine Worldrechte", Permission.WORLD);
|
||||
switch (region.getTntMode()) {
|
||||
case OFF:
|
||||
inv.setItem(23, Material.MINECART, "§7TNT: §eAusgeschaltet", tntLore, false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
player.performCommand("tnt " + (isBuildArea ? "tb" : "on"));
|
||||
updateInventories();
|
||||
});
|
||||
break;
|
||||
case ONLY_TB:
|
||||
inv.setItem(23, getMaterial("TNT_MINECART", "EXPLOSIVE_MINECART"), "§7TNT: §enur Testblock", tntLore, false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
player.performCommand("tnt on");
|
||||
updateInventories();
|
||||
});
|
||||
break;
|
||||
default:
|
||||
inv.setItem(23, Material.TNT, "§7TNT: §eEingeschaltet", tntLore, false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
player.performCommand("tnt off");
|
||||
updateInventories();
|
||||
});
|
||||
}
|
||||
|
||||
if (region.isFreeze()) {
|
||||
inv.setItem(24, getMaterial("GUNPOWDER", "SULPHUR"), "§7Freeze: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
player.performCommand("freeze");
|
||||
updateInventories();
|
||||
});
|
||||
} else {
|
||||
inv.setItem(24, Material.REDSTONE, "§7Freeze: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
player.performCommand("freeze");
|
||||
updateInventories();
|
||||
});
|
||||
}
|
||||
|
||||
if (region.isFire()) {
|
||||
inv.setItem(3, getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE"), "§7Fire: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
player.performCommand("fire");
|
||||
updateInventories();
|
||||
});
|
||||
} else {
|
||||
inv.setItem(3, getMaterial("FIRE_CHARGE", "FIREBALL"), "§7Fire: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
|
||||
if (Welt.noPermission(player, Permission.WORLD))
|
||||
return;
|
||||
player.performCommand("fire");
|
||||
updateInventories();
|
||||
});
|
||||
}
|
||||
|
||||
inv.setItem(2, Material.ENDER_PEARL, "§7Teleporter", getNoPermsLore(Arrays.asList("§8/§7tp §8[§eSpieler§8]"), player, "", null), false, clickType -> {
|
||||
List<SWListInv.SWListEntry<String>> playerSWListEntry = new ArrayList<>();
|
||||
Bukkit.getOnlinePlayers().forEach(player1 -> {
|
||||
if (player1.equals(player))
|
||||
return;
|
||||
playerSWListEntry.add(new SWListInv.SWListEntry<>(SWItem.getPlayerSkull(player1.getName()), player1.getName()));
|
||||
});
|
||||
SWListInv<String> playerSWListInv = new SWListInv<>(player, "Teleporter", playerSWListEntry, (clickType1, player1) -> {
|
||||
player.closeInventory();
|
||||
player.performCommand("tp " + player1);
|
||||
});
|
||||
playerSWListInv.open();
|
||||
});
|
||||
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void traceGUI(Player player) {
|
||||
SWInventory inv = new SWInventory(player, 9, "Tracer");
|
||||
inv.setCallback(-1, clickType -> {
|
||||
if (!isRefreshing)
|
||||
OPEN_TRACER_INVS.remove(player);
|
||||
});
|
||||
List<String> stateLore = Arrays.asList("§7Aktuell: §e" + RecordStateMachine.getRecordStatus().getName(), "§8/§7trace §8[§estart§8, stop §8oder §eauto§8]");
|
||||
switch (RecordStateMachine.getRecordStatus()) {
|
||||
case IDLE:
|
||||
inv.setItem(0, getMaterial("SNOWBALL", "SNOW_BALL"), "§7Tracerstatus", stateLore, false, clickType -> {
|
||||
RecordStateMachine.commandAuto();
|
||||
updateInventories();
|
||||
});
|
||||
break;
|
||||
case IDLE_AUTO:
|
||||
inv.setItem(0, Material.ENDER_PEARL, "§7Tracerstatus", stateLore, false, clickType -> {
|
||||
RecordStateMachine.commandStart();
|
||||
updateInventories();
|
||||
});
|
||||
break;
|
||||
case RECORD:
|
||||
case RECORD_AUTO:
|
||||
inv.setItem(0, getMaterial("ENDER_EYE", "EYE_OF_ENDER"), "§7Tracerstatus", stateLore, false, clickType -> {
|
||||
RecordStateMachine.commandStop();
|
||||
updateInventories();
|
||||
});
|
||||
}
|
||||
if (TraceShowManager.hasActiveShow(player)) {
|
||||
inv.setItem(2, Material.TNT, "§7Showstatus", Arrays.asList("§7Aktuell: §eGezeigt", "§8/§7trace §8[§eshow§8/§ehide§8]"), false, clickType -> {
|
||||
player.performCommand("trace hide");
|
||||
traceGUI(player);
|
||||
});
|
||||
} else {
|
||||
inv.setItem(2, Material.GLASS, "§7Showstatus", Arrays.asList("§7Aktuell: §eVersteckt", "§8/§7trace §8[§eshow§8/§ehide§8]"), false, clickType -> {
|
||||
player.performCommand("trace show");
|
||||
traceGUI(player);
|
||||
});
|
||||
}
|
||||
|
||||
inv.setItem(4, getMaterial("TNT_MINECART", "EXPLOSIVE_MINECART"), "§7Trace GUI", Collections.singletonList("§8/§7trace show gui"), false, clickType -> {
|
||||
player.closeInventory();
|
||||
player.performCommand("trace show gui");
|
||||
});
|
||||
|
||||
inv.setItem(6, Material.BARRIER, "§7Trace löschen", Arrays.asList("§8/§7trace delete"), false, clickType -> confirmationInventory(player, "Trace löschen", () -> player.performCommand("trace delete"), () -> {
|
||||
}));
|
||||
|
||||
inv.setItem(8, Material.ARROW, "§7Zurück", clickType -> {
|
||||
player.closeInventory();
|
||||
openBauGui(player);
|
||||
OPEN_INVS.add(player);
|
||||
});
|
||||
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void scriptBooksGUI(Player player) {
|
||||
List<SWListInv.SWListEntry<PredefinedBook>> entries = new ArrayList<>();
|
||||
List<PredefinedBook> books = PredefinedBook.getBooks();
|
||||
books.forEach(predefinedBook -> entries.add(new SWListInv.SWListEntry<>(new SWItem(predefinedBook.getBookMat(), predefinedBook.getName(), predefinedBook.getLore(), false, clickType -> {
|
||||
}), predefinedBook)));
|
||||
SWListInv<PredefinedBook> inv = new SWListInv<>(player, "Script Bücher", entries, (clickType, predefinedBook) -> {
|
||||
player.closeInventory();
|
||||
player.getInventory().addItem(predefinedBook.toItemStack());
|
||||
});
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static void autoLoaderGUI(Player player) {
|
||||
SWInventory inv = new SWInventory(player, 9, "Autoloader");
|
||||
|
||||
boolean hasLoader = AutoLoader.hasLoader(player);
|
||||
|
||||
if (hasLoader) {
|
||||
AutoLoader loader = AutoLoader.getLoader(player);
|
||||
if (loader.isSetup()) {
|
||||
inv.setItem(0, Material.DROPPER, "§7Loader Starten", Collections.singletonList("§8/§7loader start"), false, clickType -> {
|
||||
loader.start();
|
||||
autoLoaderGUI(player);
|
||||
});
|
||||
|
||||
inv.setItem(2, Material.ARROW, "§7Letzte Aktion entfernen", Collections.singletonList("§8/§7loader undo"), false, clickType -> {
|
||||
|
||||
});
|
||||
} else {
|
||||
inv.setItem(0, Material.BLAZE_ROD, "§7Loader Bearbeiten", Collections.singletonList("§8/§7loader setup"), false, clickType -> {
|
||||
loader.setup();
|
||||
autoLoaderGUI(player);
|
||||
});
|
||||
}
|
||||
|
||||
inv.setItem(4, Material.COMPASS, "§7Schuss Delay", Arrays.asList("§7Aktuell: §e" + loader.getTicksBetweenShots(), "§8/§7loader wait §8[§eTicks§8]"), false, clickType -> {
|
||||
SWAnvilInv anvilInv = new SWAnvilInv(player, "Schuss Delay", loader.getTicksBetweenShots() + "");
|
||||
anvilInv.setItem(Material.STONE);
|
||||
anvilInv.setCallback(s -> {
|
||||
player.performCommand("loader wait " + s);
|
||||
autoLoaderGUI(player);
|
||||
});
|
||||
anvilInv.open();
|
||||
});
|
||||
|
||||
inv.setItem(6, getMaterial("CLOCK", "WATCH"), "§7Block platzier Geschwindigkeit", Arrays.asList("§7Aktuell: §e" + loader.getTicksBetweenBlocks(), "§8/§7loader speed §8[§eTicks§8]"), false, clickType -> {
|
||||
SWAnvilInv anvilInv = new SWAnvilInv(player, "Platzier Geschwindigkeit", loader.getTicksBetweenBlocks() + "");
|
||||
anvilInv.setItem(Material.STONE);
|
||||
anvilInv.setCallback(s -> {
|
||||
player.performCommand("loader speed " + s);
|
||||
autoLoaderGUI(player);
|
||||
});
|
||||
anvilInv.open();
|
||||
});
|
||||
|
||||
inv.setItem(8, Material.BARRIER, "§7Loader löschen", Collections.singletonList("§8/§7loader stop"), false, clickType -> confirmationInventory(player, "Loader löschen?", () -> {
|
||||
loader.stop();
|
||||
autoLoaderGUI(player);
|
||||
}, () -> autoLoaderGUI(player)));
|
||||
} else {
|
||||
inv.setItem(4, Material.GOLD_NUGGET, "§eNeuer Autoloader", clickType -> {
|
||||
AutoLoader.getLoader(player);
|
||||
player.closeInventory();
|
||||
});
|
||||
inv.setItem(8, Material.ARROW, "§7Zurück", clickType -> {
|
||||
player.closeInventory();
|
||||
openBauGui(player);
|
||||
OPEN_INVS.add(player);
|
||||
});
|
||||
}
|
||||
|
||||
inv.open();
|
||||
}
|
||||
|
||||
|
||||
private static void confirmChatMessage(Player player, String command) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§7Klicke auf die Nachricht zum bestätigen");
|
||||
TextComponent t = new TextComponent();
|
||||
t.setText("[Hier]");
|
||||
t.setColor(ChatColor.YELLOW);
|
||||
t.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
|
||||
t.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§7" + command)));
|
||||
player.spigot().sendMessage(t);
|
||||
}
|
||||
|
||||
private static List<String> getNoPermsLore(List<String> lore, Player player, String noPerms, Permission perm) {
|
||||
if (perm != null && Welt.noPermission(player, perm)) {
|
||||
lore = new ArrayList<>(lore);
|
||||
lore.add(noPerms);
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
|
||||
private static void updateInventories() {
|
||||
isRefreshing = true;
|
||||
OPEN_INVS.forEach(CommandGUI::openBauGui);
|
||||
OPEN_TRACER_INVS.forEach(CommandGUI::traceGUI);
|
||||
isRefreshing = false;
|
||||
}
|
||||
|
||||
private static void confirmationInventory(Player player, String title, Runnable confirm, Runnable decline) {
|
||||
SWInventory inv = new SWInventory(player, 9, title);
|
||||
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§cAbbrechen", clickType -> {
|
||||
player.closeInventory();
|
||||
decline.run();
|
||||
});
|
||||
inv.setItem(8, SWItem.getDye(10), (byte) 10, "§aBestätigen", clickType -> {
|
||||
player.closeInventory();
|
||||
confirm.run();
|
||||
});
|
||||
inv.open();
|
||||
}
|
||||
|
||||
private static Material getMaterial(String... names) {
|
||||
for (String name : names) {
|
||||
try {
|
||||
return Material.valueOf(name);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
//Ignored /\
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ItemStack wand(Player player, ItemStack base, String command, Permission permission, String noPermissionMessage) {
|
||||
base = base.clone();
|
||||
ItemMeta meta = base.getItemMeta();
|
||||
List<String> lore = meta.getLore();
|
||||
lore.add(command);
|
||||
if (permission != null && Welt.noPermission(player, permission))
|
||||
lore.add(noPermissionMessage);
|
||||
meta.setLore(lore);
|
||||
base.setItemMeta(meta);
|
||||
return base;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
if (event.getItem() == null || event.getItem().getType() != Material.NETHER_STAR)
|
||||
return;
|
||||
openBauGui(event.getPlayer());
|
||||
OPEN_INVS.add(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
|
||||
if (LAST_F_PLAYER.contains(event.getPlayer())) {
|
||||
openBauGui(event.getPlayer());
|
||||
OPEN_INVS.add(event.getPlayer());
|
||||
} else {
|
||||
LAST_F_PLAYER.add(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandGamemode extends SWCommand {
|
||||
|
||||
public CommandGamemode() {
|
||||
super("gamemode", "gm", "g");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void gamemodeHelp(Player p, String... args) {
|
||||
p.sendMessage("§cUnbekannter Spielmodus");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p) {
|
||||
if (p.getGameMode() == GameMode.CREATIVE) {
|
||||
p.setGameMode(GameMode.SPECTATOR);
|
||||
} else {
|
||||
p.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
}
|
||||
|
||||
@Register
|
||||
public void gamemodeCommand(Player p, GameMode gameMode) {
|
||||
p.setGameMode(gameMode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class CommandGills extends SWCommand {
|
||||
|
||||
public CommandGills() {
|
||||
super("watervision", "wv");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§ewatervision §8- §7Toggle WaterBreathing");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p) {
|
||||
toggleGills(p);
|
||||
}
|
||||
|
||||
public static void toggleGills(Player player) {
|
||||
if (player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "Wassersicht deaktiviert");
|
||||
player.removePotionEffect(PotionEffectType.WATER_BREATHING);
|
||||
return;
|
||||
}
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 255, false, false));
|
||||
player.sendMessage(BauSystem.PREFIX + "Wassersicht aktiviert");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.world.TPSUtils;
|
||||
import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.TPSWatcher;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static de.steamwar.bausystem.world.TPSUtils.getTps;
|
||||
|
||||
public class CommandInfo extends SWCommand {
|
||||
|
||||
public CommandInfo() {
|
||||
super("bauinfo");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§ebauinfo §8- §7Gibt Informationen über den Bau");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p) {
|
||||
CommandInfo.sendBauInfo(p);
|
||||
}
|
||||
|
||||
public static void sendBauInfo(Player p) {
|
||||
p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName());
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
p.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.getTntMode().getName() + " §eFire§8: " + (region.isFire() ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (region.isFreeze() ? "§aAN" : "§cAUS"));
|
||||
if (region.hasProtection()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§eProtect§8: " + (region.isProtect() ? "§aAN" : "§cAUS"));
|
||||
}
|
||||
|
||||
List<BauweltMember> members = BauweltMember.getMembers(BauSystem.getOwnerID());
|
||||
StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: ");
|
||||
|
||||
for (BauweltMember member : members) {
|
||||
membermessage.append("§e").append(SteamwarUser.get(member.getMemberID()).getUserName()).append("§8[");
|
||||
membermessage.append(member.isWorldEdit() ? "§a" : "§c").append("WE").append("§8,");
|
||||
membermessage.append(member.isWorld() ? "§a" : "§c").append("W").append("§8]").append(" ");
|
||||
}
|
||||
p.sendMessage(membermessage.toString());
|
||||
|
||||
StringBuilder tpsMessage = new StringBuilder();
|
||||
tpsMessage.append(BauSystem.PREFIX).append("TPS:§e");
|
||||
tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.ONE_SECOND));
|
||||
tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.TEN_SECONDS));
|
||||
if (!TPSUtils.isWarping()) {
|
||||
tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE));
|
||||
tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES));
|
||||
tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES));
|
||||
}
|
||||
p.sendMessage(tpsMessage.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.world.regions.*;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandKillAll extends SWCommand {
|
||||
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
public CommandKillAll() {
|
||||
super("killall", "removeall");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player player, String... args) {
|
||||
player.sendMessage("§8/§ekillall §8- §7Entferne alle Entities aus deiner Region");
|
||||
player.sendMessage("§8/§ekillall §8[§7Global§8/Local§7] §8- §7Entferne alle Entities aus deiner Region oder global");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player player) {
|
||||
genericCommand(player, RegionSelectionType.LOCAL);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player player, RegionSelectionType regionSelectionType) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
AtomicLong removedEntities = new AtomicLong();
|
||||
if (regionSelectionType == RegionSelectionType.GLOBAL || GlobalRegion.isGlobalRegion(region)) {
|
||||
WORLD.getEntities()
|
||||
.stream()
|
||||
.filter(e -> !(e instanceof Player))
|
||||
.forEach(entity -> {
|
||||
entity.remove();
|
||||
removedEntities.getAndIncrement();
|
||||
});
|
||||
RegionUtils.actionBar(GlobalRegion.getInstance(), "§a" + removedEntities.get() + " Entities aus der Welt entfernt");
|
||||
} else {
|
||||
WORLD.getEntities()
|
||||
.stream()
|
||||
.filter(e -> !(e instanceof Player))
|
||||
.filter(e -> region.inRegion(e.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL))
|
||||
.forEach(entity -> {
|
||||
entity.remove();
|
||||
removedEntities.getAndIncrement();
|
||||
});
|
||||
RegionUtils.actionBar(region, "§a" + removedEntities.get() + " Entities aus der Region entfernt");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.AutoLoader;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandLoader extends SWCommand {
|
||||
|
||||
public CommandLoader() {
|
||||
super("loader");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen");
|
||||
p.sendMessage("§8/§7loader undo §8- §7Entfernt die zuletzt aufgenommene Aktion");
|
||||
p.sendMessage("§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Aktionen ab");
|
||||
p.sendMessage("§8/§7loader wait §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Schüssen");
|
||||
p.sendMessage("§8/§7loader speed §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Aktionen");
|
||||
p.sendMessage("§8/§eloader stop §8- §7Stoppt die Aufnahme bzw. das Abspielen");
|
||||
p.sendMessage("§7Der AutoLader arbeitet mit §eIngame§8-§eTicks §8(20 Ticks pro Sekunde)");
|
||||
}
|
||||
|
||||
@Register({"setup"})
|
||||
public void setupCommand(Player p) {
|
||||
setup(p);
|
||||
}
|
||||
|
||||
@Register({"undo"})
|
||||
public void undoCommand(Player p) {
|
||||
undo(p);
|
||||
}
|
||||
|
||||
@Register({"start"})
|
||||
public void startCommand(Player p) {
|
||||
start(p);
|
||||
}
|
||||
|
||||
@Register({"stop"})
|
||||
public void stopCommand(Player p) {
|
||||
stop(p);
|
||||
}
|
||||
|
||||
@Register({"wait"})
|
||||
public void waitCommand(Player p, int time) {
|
||||
wait(p, time);
|
||||
}
|
||||
|
||||
@Register({"speed"})
|
||||
public void speedCommand(Player p, int time) {
|
||||
speed(p, time);
|
||||
}
|
||||
|
||||
private void setup(Player player) {
|
||||
AutoLoader.getLoader(player).setup();
|
||||
}
|
||||
|
||||
private void undo(Player player) {
|
||||
AutoLoader loader = loader(player);
|
||||
if (loader == null)
|
||||
return;
|
||||
|
||||
if (!loader.isSetup()) {
|
||||
player.sendMessage("§cDer AutoLader wird in den Setup-Zustand versetzt");
|
||||
setup(player);
|
||||
}
|
||||
|
||||
loader.undo();
|
||||
}
|
||||
|
||||
private void start(Player player) {
|
||||
AutoLoader loader = loader(player);
|
||||
if (loader == null)
|
||||
return;
|
||||
|
||||
loader.start();
|
||||
}
|
||||
|
||||
private void stop(Player player) {
|
||||
if (!AutoLoader.hasLoader(player)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen aktiven AutoLader");
|
||||
return;
|
||||
}
|
||||
AutoLoader.getLoader(player).stop();
|
||||
}
|
||||
|
||||
private void wait(Player player, int time) {
|
||||
AutoLoader loader = loader(player);
|
||||
if (loader == null) {
|
||||
loader = AutoLoader.getLoader(player);
|
||||
}
|
||||
loader.wait(time);
|
||||
}
|
||||
|
||||
private void speed(Player player, int time) {
|
||||
AutoLoader loader = loader(player);
|
||||
if (loader == null) {
|
||||
loader = AutoLoader.getLoader(player);
|
||||
}
|
||||
loader.blockWait(time);
|
||||
}
|
||||
|
||||
private AutoLoader loader(Player player) {
|
||||
if (AutoLoader.hasLoader(player)) {
|
||||
return AutoLoader.getLoader(player);
|
||||
}
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen aktiven AutoLader");
|
||||
player.sendMessage(BauSystem.PREFIX + "§7Es wird ein neuer AutoLader gestartet");
|
||||
setup(player);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.sql.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandLockschem extends SWCommand {
|
||||
|
||||
public CommandLockschem() {
|
||||
super("lockschem");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
if (!SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.CHECK)) {
|
||||
return;
|
||||
}
|
||||
|
||||
sendHelp(p);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p, String owner, String schematicName) {
|
||||
if (!SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.CHECK)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SteamwarUser schemOwner = SteamwarUser.get(owner);
|
||||
if (schemOwner == null) {
|
||||
p.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!");
|
||||
return;
|
||||
}
|
||||
SchematicNode node = SchematicNode.getNodeFromPath(schemOwner, schematicName);
|
||||
if (node == null) {
|
||||
p.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!");
|
||||
return;
|
||||
}
|
||||
p.sendMessage(BauSystem.PREFIX + "Schematic " + node .getName() + " von " +
|
||||
SteamwarUser.get(node.getOwner()).getUserName() + " von " + node.getSchemtype().toString() +
|
||||
" auf NORMAL zurückgesetzt!");
|
||||
node.setSchemtype(SchematicType.Normal);
|
||||
}
|
||||
|
||||
private void sendHelp(Player player) {
|
||||
player.sendMessage("§8/§eschemlock §8[§7Owner§8] §8[§7Schematic§8] §8- §7 Sperre eine Schematic");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class CommandNV extends SWCommand {
|
||||
|
||||
public CommandNV() {
|
||||
super("nightvision", "nv");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§enightvision §8- §7Toggle NightVision");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p) {
|
||||
toggleNightvision(p);
|
||||
}
|
||||
|
||||
public static void toggleNightvision(Player player) {
|
||||
if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "Nachtsicht deaktiviert");
|
||||
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||
return;
|
||||
}
|
||||
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 255, false, false));
|
||||
player.sendMessage(BauSystem.PREFIX + "Nachtsicht aktiviert");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CommandProtect extends SWCommand implements Listener {
|
||||
|
||||
public CommandProtect() {
|
||||
super("protect");
|
||||
if (Region.buildAreaEnabled()) {
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
}
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§eprotect §8- §7Schütze die Region");
|
||||
p.sendMessage("§8/§eprotect §8[§7Schematic§8] §8- §7Schütze die Region mit einer Schematic");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericProtectCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
if (Region.buildAreaEnabled()) {
|
||||
region.setProtect(!region.isProtect());
|
||||
if (region.isProtect()) {
|
||||
RegionUtils.actionBar(region, "§aBoden geschützt");
|
||||
} else {
|
||||
RegionUtils.actionBar(region, "§cBoden Schutz aufgehoben");
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
region.protect(null);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed protect", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Register
|
||||
public void schematicProtectCommand(Player p, String s) {
|
||||
if (!permissionCheck(p)) return;
|
||||
if (Region.buildAreaEnabled()) {
|
||||
genericHelp(p);
|
||||
return;
|
||||
}
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
SteamwarUser owner = SteamwarUser.get(p.getUniqueId());
|
||||
SchematicNode schem = SchematicNode.getNodeFromPath(owner, s);
|
||||
if (schem == null) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
region.protect(schem);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed protect", e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.WORLDEDIT)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Boden schützen");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (!region.hasProtection()) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner (M)WG-Region");
|
||||
return null;
|
||||
}
|
||||
return region;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent event) {
|
||||
Region region = Region.getRegion(event.getLocation());
|
||||
if (!region.isProtect() || !region.hasProtection()) {
|
||||
return;
|
||||
}
|
||||
event.blockList().removeIf(block -> {
|
||||
return block.getY() < region.getProtectYLevel();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class CommandRedstoneTester extends SWCommand {
|
||||
|
||||
public static final ItemStack WAND = new SWItem(Material.BLAZE_ROD, "§eRedstonetester", Arrays.asList("§eLinksklick Block §8- §7Setzt die 1. Position", "§eRechtsklick Block §8- §7Setzt die 2. Position", "§eShift-Rechtsklick Luft §8- §7Zurücksetzten"), false, null).getItemStack();
|
||||
|
||||
public CommandRedstoneTester() {
|
||||
super("redstonetester", "rt");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§eredstonetester §8- §7Gibt den RedstoneTester");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p) {
|
||||
p.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten");
|
||||
SWUtils.giveItemToPlayer(p, WAND);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.Color;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.bausystem.world.regions.GlobalRegion;
|
||||
import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.bausystem.world.regions.RegionExtensionType;
|
||||
import de.steamwar.bausystem.world.regions.RegionType;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CommandRegion extends SWCommand {
|
||||
|
||||
public CommandRegion() {
|
||||
super("region", "rg");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player player) {
|
||||
genericHelp(player);
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player player, String... args) {
|
||||
player.sendMessage("§8/§eregion undo §8- §7Mache die letzten 20 /testblock oder /reset rückgängig");
|
||||
player.sendMessage("§8/§eregion redo §8- §7Wiederhole die letzten 20 §8/§7rg undo");
|
||||
player.sendMessage("§8/§eregion restore §8- §7Setzte die Region zurück, ohne das Gebaute zu löschen");
|
||||
player.sendMessage("§8/§eregion §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus");
|
||||
player.sendMessage("§8/§eregion §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension");
|
||||
player.sendMessage("§8/§eregion color §8[§7Color§8] §8- §7Ändere die Regions Farbe");
|
||||
}
|
||||
|
||||
@Register("undo")
|
||||
public void undoCommand(Player p) {
|
||||
if(!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if(checkGlobalRegion(region, p)) return;
|
||||
|
||||
if (region.undo()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion rückgangig gemacht");
|
||||
} else {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cNichts zum rückgängig machen");
|
||||
}
|
||||
}
|
||||
|
||||
@Register("redo")
|
||||
public void redoCommand(Player p) {
|
||||
if (!permissionCheck(p)) {
|
||||
return;
|
||||
}
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (checkGlobalRegion(region, p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (region.redo()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion wiederhohlt");
|
||||
} else {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cNichts zum wiederhohlen");
|
||||
}
|
||||
}
|
||||
|
||||
@Register
|
||||
public void baurahmenCommand(Player p, RegionType regionType) {
|
||||
CommandSelect.getInstance().baurahmenCommand(p, regionType, RegionExtensionType.NORMAL);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void baurahmenCommand(Player p, RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
CommandSelect.getInstance().baurahmenCommand(p, regionType, regionExtensionType);
|
||||
}
|
||||
|
||||
@Register("restore")
|
||||
public void genericRestoreCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if(checkGlobalRegion(region, p)) return;
|
||||
|
||||
if (region == null) return;
|
||||
try {
|
||||
region.reset(null, true);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Register("restore")
|
||||
public void schematicRestoreCommand(Player p, SchematicNode schem) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if(checkGlobalRegion(region, p)) return;
|
||||
|
||||
if (region == null) return;
|
||||
try {
|
||||
region.reset(schem, true);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed reset", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Register("color")
|
||||
public void colorCommand(Player p, Color color) {
|
||||
CommandColor.getInstance().genericColor(p, color);
|
||||
}
|
||||
|
||||
static boolean checkGlobalRegion(Region region, Player p) {
|
||||
if (GlobalRegion.isGlobalRegion(region)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDu bist in keiner Region");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.WORLDEDIT)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region verändern");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.bausystem.world.regions.GlobalRegion;
|
||||
import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CommandReset extends SWCommand {
|
||||
|
||||
public CommandReset() {
|
||||
super("reset");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§ereset §8- §7Setzte die Region zurück");
|
||||
p.sendMessage("§8/§ereset §8[§7Schematic§8] §8- §7Setzte die Region mit einer Schematic zurück");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericResetCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
try {
|
||||
region.reset(null, false);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Register
|
||||
public void schematicResetCommand(Player p, SchematicNode schem) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
try {
|
||||
region.reset(schem, false);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed reset", e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.WORLD)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region zurücksetzen");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (region == GlobalRegion.getInstance()) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
||||
return null;
|
||||
}
|
||||
return region;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* /
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandScript extends SWCommand {
|
||||
|
||||
public CommandScript() {
|
||||
super("script");
|
||||
}
|
||||
|
||||
public static final ItemStack BOOK = new ItemStack(Material.WRITTEN_BOOK, 1);
|
||||
|
||||
static {
|
||||
List<String> pages = new ArrayList<>();
|
||||
pages.add("§6Script System§8\n\n- Commands\n- Kommentare\n- Scriptausführung\n- Sleep\n- Variablen\n- Konstanten\n- Abfragen\n- Schleifen\n- \"echo\"\n- \"input\"\n- Arithmetik\n- Logik");
|
||||
pages.add("§6Commands§8\n\nEin minecraft Befehl wird im Scriptbuch so hingeschrieben. Dabei kann man ein '/' weglassen. Um Befehle zu trennen kommen diese in neue Zeilen.\n\nStatt\n/tnt -> tnt\n//pos1 -> /pos1");
|
||||
pages.add("§6Kommentare§8\n\nFür ein Kommentar fängt die Zeile mit einem '#' an. Diese Zeilen werden bei dem Ausführen dann ignoriert.\n\nBeispiel:\n§9# TNT an/aus\ntnt");
|
||||
pages.add("§6Scriptausführung§8\n\nWenn du mit dem Buch in der Hand links klickst wird dieses ausgeführt.");
|
||||
pages.add("§6Sleep§8\n\nUm Sachen langsamer zu machen kann man ein 'sleep' in sein Script schreiben. Danach kommt eine Zahl mit der Anzahl der GameTicks die zu schlafen sind.\n\nBeispiel:\n§9# 1 Sekunde schlafen\nsleep 20");
|
||||
pages.add("§6Variablen§8\n\nMit Variablen kann man sich Zahlen speichern. Man definiert diese mit 'var <NAME> <VALUE>'.\n\nBeispiel:\n§9# Setze i zu 0\nvar i 0§8\n\nEs gibt einige spezial values. Dazu zählen");
|
||||
pages.add("§8'true', 'yes', 'false' und 'no', welche für 1, 1, 0 und 0 stehen.\n\nMan kann eine Variable auch um einen erhöhen oder verkleinern. Hierfür schreibt man statt einer Zahl '++', 'inc' oder '--', 'dec'.\n\nBeispiel:\n§9var i ++");
|
||||
pages.add("§8Variablen kann man referenzieren\ndurch '<' vor dem Variablennamen und '>' nach diesem. Diese kann man in jedem Befehl verwenden.\n\nBeispiel:\n§9# Stacked um 10\nvar stacks 10\n/stack <stacks>");
|
||||
pages.add("§8Man kann auch explizit eine globale, locale, oder konstante variable referenzieren, indem 'global.', 'local.' oder 'const.' vor den Namen in die Klammern zu schreiben.");
|
||||
pages.add("§8Um Variablen über das Script ausführen zu speichern gibt es 'global' und 'unglobal' als Befehle. Der erste speichert eine locale Variable global und das zweite löscht eine globale wieder.");
|
||||
pages.add("§8Des weiteren kann man Lokale Variablen mit 'unvar' löschen. Nach dem verlassen einer Welt werden alle Globalen Variablen gelöscht. Globale Variablen kann man mit '/scriptvars' einsehen.");
|
||||
pages.add("§6Konstanten§8\n\nNeben den variablen gibt es noch 5 Konstante Werte, welche nicht mit dem 'var' Befehl verändert werden können.\n\nDiese sind:\n- trace/autotrace\n- tnt\n- freeze\n- fire");
|
||||
pages.add("§8Des weiteren gibt es 3 weitere Variablen, welche explizit Spieler gebunden sind\n\nDiese sind:\n- x\n- y\n- z");
|
||||
pages.add("§6Abfragen§8\n\nMit Abfragen kann man nur Gleichheit von 2 Werten überprüft werden. Hierfür verwendet man\n'if <VAL> <VAL>'.\nNach den zwei Werten kann man ein oder 2 Jump-Points schreiben\n'if [...] <JP> (JP)'.");
|
||||
pages.add("§8Des weiteren kann man überprüfen, ob eine Variable existiert mit 'if <VAL> exists' wonach dann wieder 1 oder 2 Jump-Points sein müssen.");
|
||||
pages.add("§8Ein Jump-Point ist eine Zeile Script, wohin man springen kann. Dieser wird mit einem '.' am Anfang der Zeile beschrieben und direkt danach der Jump-Point Namen ohne Leerzeichen.\n\nBeispiel:\n§9# Jump-Point X\n.X§8");
|
||||
pages.add("§8Um zu einem Jump-Point ohne Abfrage zu springen kann man den\n'jump <JP>' Befehl verwenden.");
|
||||
pages.add("§6Schleifen§8\n\nSchleifen werden mit Jump-Points, if Abfragen und Jumps gebaut.\n\nBeispiel:\n§9var i 0\n.JUMP\nvar i ++\nif i 10 END JUMP\n.END§8");
|
||||
pages.add("§6\"echo\"§8\n\nDer echo Befehl ist da um Ausgaben zu tätigen. Hier drin kann man sowohl Variablen ausgeben, als auch Farbcodes verwenden. Es wird alles nach dem Befehl ausgegeben.\n\nBeispiel:\n§9echo &eSteam&8war &7war hier!");
|
||||
pages.add("§6\"input\"§8\n\nDer input Befehl ist eine Aufforderung einer Eingabe des Users. Die Argumente sind eine Variable und ein Text als Nachricht.\n\nBeispiel:\n§9input age &eDein Alter?");
|
||||
pages.add("§6Arithmetik§8\n\nEs gibt 4 Arithmetische Befehle:\n- add\n- sub\n- mul\n- div\n\nDer erste Parameter ist die Variable welche den ausgerechneten Wert halten soll. Hiernach muss ein");
|
||||
pages.add("§8Wert oder Variable kommen welcher verrechnet wird. Hierbei wird das erste Argument als ersten Operand genommen.\n\nBeispiel:\n§9var i 2\nvar j 3\nadd i j\necho $i");
|
||||
pages.add("§8Man kann auch 3 Argumente angeben. Dann wird die arithmetische Operation zwischen den letzten beiden Argumenten berechnet und als Variable des ersten Arguments abgespeichert. \n\nBeispiel auf der nächsten Seite -->");
|
||||
pages.add("§8Beispiel:\n§9var i 2\nvar j 2\nadd k i j\necho $k");
|
||||
pages.add("§6Logik§8\n\nEs gibt 3 Vergleichs Befehle:\n- equal\n- less\n- greater\n\nUnd 3 Logik Befehle:\n- and\n- or\n- not");
|
||||
pages.add("§8Der erste Parameter ist die Variable welche den ausgerechneten Wert halten soll. Hiernach muss ein Wert oder Variable kommen welcher verrechnet wird. Hierbei wird das erste Argument als ersten Operand genommen. Dies gilt nicht für den 'not' Befehl, welcher");
|
||||
pages.add("§8nur 2 Parameter nimmt. Der erste die Variable und der zweite eine optionale Variable oder ein Wert. Equal vergleicht 2 Werte, less gibt zurück ob der erste kleiner als der zweite Wert ist, greater gibt zurück ob der erste größer als der zweite Wert ist.");
|
||||
pages.add("§8And vergleicht ob 2 Werte true (1) sind. Or vergleicht ob 1 Wert oder 2 Werte true (1) ist/sind. Not invertiert den Wert von true (1) auf false und anders rum.");
|
||||
pages.add("§8Beispiel:\n§9var i 1\nvar j 1\n#Ist i und j gleich\nequal k i j\nvar j 0\n#Ist i kleiner j\nless k i j\n#Ist i größer j\ngreater k i j\n#Ist i und j true\nand k i j\n#Beispiel weiter auf nächster Seite");
|
||||
pages.add("§9#Ist i oder j true\nor k i j\n#Invertiere i\nnot k i");
|
||||
|
||||
BookMeta bookMeta = (BookMeta) BOOK.getItemMeta();
|
||||
bookMeta.setGeneration(BookMeta.Generation.ORIGINAL);
|
||||
bookMeta.setAuthor("§eSteam§8war");
|
||||
bookMeta.setTitle("§7Script Buch");
|
||||
bookMeta.setDisplayName("§7Script Buch");
|
||||
bookMeta.setPages(pages);
|
||||
BOOK.setItemMeta(bookMeta);
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§escript §8- §7Gibt das Script Buch");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void giveCommand(Player p) {
|
||||
SWUtils.giveItemToPlayer(p, BOOK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.world.ScriptListener;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CommandScriptVars extends SWCommand {
|
||||
|
||||
public CommandScriptVars() {
|
||||
super("scripvars");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§escriptvars §8- §7Zähle alle globalen Variablen auf");
|
||||
p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8- §7Gebe den Wert der Variable zurück");
|
||||
p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8[§7Value§8] §8- §7Setzte eine Variable auf einen Wert");
|
||||
p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8<§7remove§8|§7delete§8|§7clear§8> §8- §7Lösche eine Variable");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p) {
|
||||
Map<String, Integer> globalVariables = ScriptListener.GLOBAL_VARIABLES.get(p);
|
||||
if (globalVariables == null) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert");
|
||||
return;
|
||||
}
|
||||
int i = 0;
|
||||
p.sendMessage(BauSystem.PREFIX + globalVariables.size() + " Variable(n)");
|
||||
for (Map.Entry<String, Integer> var : globalVariables.entrySet()) {
|
||||
if (i++ >= 40) break;
|
||||
p.sendMessage("- " + var.getKey() + "=" + var.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Register
|
||||
public void removeCommand(Player p, String varName) {
|
||||
Map<String, Integer> globalVariables = ScriptListener.GLOBAL_VARIABLES.get(p);
|
||||
if (globalVariables == null) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert");
|
||||
return;
|
||||
}
|
||||
if (!globalVariables.containsKey(varName)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cUnbekannte Variable");
|
||||
return;
|
||||
}
|
||||
p.sendMessage(BauSystem.PREFIX + varName + "=" + globalVariables.get(varName));
|
||||
}
|
||||
|
||||
@Register
|
||||
public void booleanValueCommand(Player p, String varName, int value) {
|
||||
ScriptListener.GLOBAL_VARIABLES.computeIfAbsent(p, player -> new HashMap<>()).put(varName, value);
|
||||
p.sendMessage(BauSystem.PREFIX + varName + " auf " + value + " gesetzt");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void removeCommand(Player p, String varName, @Mapper(value = "Delete") String remove) {
|
||||
if (!ScriptListener.GLOBAL_VARIABLES.containsKey(p)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert");
|
||||
return;
|
||||
}
|
||||
ScriptListener.GLOBAL_VARIABLES.get(p).remove(varName);
|
||||
p.sendMessage(BauSystem.PREFIX + "Variable " + varName + " gelöscht");
|
||||
}
|
||||
|
||||
@ClassMapper(value = String.class, local = true)
|
||||
public TypeMapper<String> stringTypeMapper() {
|
||||
return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> {
|
||||
if (commandSender instanceof Player) {
|
||||
Player player = (Player) commandSender;
|
||||
return new ArrayList<>(ScriptListener.GLOBAL_VARIABLES.getOrDefault(player, new HashMap<>()).keySet());
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Mapper(value = "Delete", local = true)
|
||||
public TypeMapper<String> clearStringTypeMapper() {
|
||||
List<String> tabCompletes = Arrays.asList("delete", "clear", "remove");
|
||||
return SWCommandUtils.createMapper(s -> {
|
||||
if (s.equalsIgnoreCase("delete") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("remove")) {
|
||||
return s;
|
||||
}
|
||||
return null;
|
||||
}, s -> tabCompletes);
|
||||
}
|
||||
|
||||
@ClassMapper(value = int.class, local = true)
|
||||
public TypeMapper<Integer> integerTypeMapper() {
|
||||
List<String> tabCompletes = Arrays.asList("true", "false", "yes", "no");
|
||||
return SWCommandUtils.createMapper(s -> {
|
||||
if (s.equalsIgnoreCase("remove") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("delete")) return null;
|
||||
return ScriptListener.parseValue(s);
|
||||
}, s -> tabCompletes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.WorldeditWrapper;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.bausystem.world.regions.*;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class CommandSelect extends SWCommand {
|
||||
|
||||
@Getter
|
||||
private static CommandSelect instance = null;
|
||||
|
||||
public CommandSelect() {
|
||||
super("select");
|
||||
}
|
||||
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§eselect §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus");
|
||||
p.sendMessage("§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void baurahmenCommand(Player p, RegionType regionType) {
|
||||
if (!permissionCheck(p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
|
||||
if (GlobalRegion.isGlobalRegion(region)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDie globale Region kannst du nicht auswählen");
|
||||
return;
|
||||
}
|
||||
|
||||
if (regionType == RegionType.TESTBLOCK) {
|
||||
if (!region.hasTestblock()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen Testblock");
|
||||
return;
|
||||
}
|
||||
setSelection(regionType, RegionExtensionType.NORMAL, region, p);
|
||||
return;
|
||||
}
|
||||
|
||||
if (regionType == RegionType.BUILD) {
|
||||
if (!region.hasBuildRegion()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen BuildArea");
|
||||
return;
|
||||
}
|
||||
setSelection(regionType, RegionExtensionType.NORMAL, region, p);
|
||||
return;
|
||||
}
|
||||
|
||||
setSelection(regionType, RegionExtensionType.NORMAL, region, p);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void baurahmenCommand(Player p, RegionType regionType, RegionExtensionType regionExtensionType) {
|
||||
if (!permissionCheck(p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
|
||||
if (GlobalRegion.isGlobalRegion(region)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDie globale Region kannst du nicht auswählen");
|
||||
return;
|
||||
}
|
||||
|
||||
if (regionType == RegionType.TESTBLOCK) {
|
||||
if (!region.hasTestblock()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen Testblock");
|
||||
return;
|
||||
}
|
||||
if (regionExtensionType == RegionExtensionType.EXTENSION && !region.hasExtensionArea(regionType)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keine Ausfahrmaße");
|
||||
return;
|
||||
}
|
||||
setSelection(regionType, regionExtensionType, region, p);
|
||||
return;
|
||||
}
|
||||
|
||||
if (regionType == RegionType.BUILD) {
|
||||
if (!region.hasBuildRegion()) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen BuildArea");
|
||||
return;
|
||||
}
|
||||
if (regionExtensionType == RegionExtensionType.EXTENSION && !region.hasExtensionArea(regionType)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keine Ausfahrmaße");
|
||||
return;
|
||||
}
|
||||
setSelection(regionType, regionExtensionType, region, p);
|
||||
return;
|
||||
}
|
||||
|
||||
setSelection(regionType, regionExtensionType, region, p);
|
||||
}
|
||||
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.WORLDEDIT)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Select verwenden");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setSelection(RegionType regionType, RegionExtensionType regionExtensionType, Region region, Player p) {
|
||||
Point minPoint = region.getMinPoint(regionType, regionExtensionType);
|
||||
Point maxPoint = region.getMaxPoint(regionType, regionExtensionType);
|
||||
|
||||
WorldeditWrapper.impl.setSelection(p, minPoint, maxPoint);
|
||||
p.sendMessage(BauSystem.PREFIX + "WorldEdit auswahl auf " + minPoint.getX() + ", " + minPoint.getY() + ", " + minPoint.getZ() + " und " + maxPoint.getX() + ", " + maxPoint.getY() + ", " + maxPoint.getZ() + " gesetzt");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.SWUtils;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
public class CommandSkull extends SWCommand {
|
||||
|
||||
public CommandSkull() {
|
||||
super("skull");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§eskull §8[§eSpieler§8] §8- §7Gibt einen SpielerKopf");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void giveCommand(Player p, String skull) {
|
||||
ItemStack is = SWItem.getPlayerSkull(skull).getItemStack();
|
||||
SkullMeta sm = (SkullMeta) is.getItemMeta();
|
||||
assert sm != null;
|
||||
sm.setDisplayName("§e" + skull + "§8s Kopf");
|
||||
is.setItemMeta(sm);
|
||||
SWUtils.giveItemToPlayer(p, is);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandSpeed extends SWCommand {
|
||||
|
||||
public CommandSpeed() {
|
||||
super("speed");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§espeed §8[§7Geschwindigkeit§8] §8- §7Setzte deine Flug- und Gehgeschwindigkeit");
|
||||
}
|
||||
|
||||
@Register({"default"})
|
||||
public void defaultCommand(Player p) {
|
||||
speedCommand(p, 1);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void speedCommand(Player p, float speed) {
|
||||
if (speed < 0 || speed > 10) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
|
||||
return;
|
||||
}
|
||||
|
||||
p.sendMessage("§aGeschwindigkeit wurde auf §6" + speed + " §agesetzt");
|
||||
p.setFlySpeed(speed / 10);
|
||||
p.setWalkSpeed((speed >= 9 ? speed : speed + 1) / 10);
|
||||
}
|
||||
|
||||
@ClassMapper(value = float.class, local = true)
|
||||
public TypeMapper<Float> doubleTypeMapper() {
|
||||
List<String> tabCompletes = Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
|
||||
return SWCommandUtils.createMapper(s -> {
|
||||
try {
|
||||
return Float.parseFloat(s.replace(',', '.'));
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}, s -> tabCompletes);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.bausystem.world.regions.RegionExtensionType;
|
||||
import de.steamwar.bausystem.world.regions.RegionType;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommandTNT extends SWCommand implements Listener {
|
||||
|
||||
public enum TNTMode {
|
||||
ON("§aan"),
|
||||
ONLY_TB("§7Kein §eBaurahmen"),
|
||||
OFF("§caus");
|
||||
|
||||
private String name;
|
||||
|
||||
TNTMode(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public CommandTNT() {
|
||||
super("tnt");
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§etnt §8- §7Ändere das TNT verhalten");
|
||||
p.sendMessage("§8/§etnt §8[§7Mode§8] §8- §7Setzte das TNT verhalten auf einen Modus");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void toggleCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
tntToggle(region, null, null);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void setCommand(Player p, TNTMode tntMode) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
|
||||
String requestedMessage = null;
|
||||
switch (tntMode) {
|
||||
case ON:
|
||||
requestedMessage = getEnableMessage();
|
||||
break;
|
||||
case OFF:
|
||||
requestedMessage = getDisableMessage();
|
||||
break;
|
||||
case ONLY_TB:
|
||||
requestedMessage = getTestblockEnableMessage();
|
||||
break;
|
||||
}
|
||||
tntToggle(region, tntMode, requestedMessage);
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player p) {
|
||||
if (Welt.noPermission(p, Permission.WORLD)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ClassMapper(value = TNTMode.class, local = true)
|
||||
public TypeMapper<TNTMode> tntModeTypeMapper() {
|
||||
Map<String, TNTMode> tntModeMap = new HashMap<>();
|
||||
tntModeMap.put("an", TNTMode.ON);
|
||||
tntModeMap.put("on", TNTMode.ON);
|
||||
tntModeMap.put("aus", TNTMode.OFF);
|
||||
tntModeMap.put("off", TNTMode.OFF);
|
||||
if (Region.buildAreaEnabled()) {
|
||||
tntModeMap.put("testblock", TNTMode.ONLY_TB);
|
||||
tntModeMap.put("tb", TNTMode.ONLY_TB);
|
||||
}
|
||||
List<String> tabCompletes = new ArrayList<>(tntModeMap.keySet());
|
||||
return SWCommandUtils.createMapper(s -> tntModeMap.getOrDefault(s, null), s -> tabCompletes);
|
||||
}
|
||||
|
||||
private String getEnableMessage() {
|
||||
return "§aTNT-Schaden aktiviert";
|
||||
}
|
||||
|
||||
private String getDisableMessage() {
|
||||
return "§cTNT-Schaden deaktiviert";
|
||||
}
|
||||
|
||||
private String getTestblockEnableMessage() {
|
||||
return "§aTNT-Schaden außerhalb Baurahmen aktiviert";
|
||||
}
|
||||
|
||||
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
|
||||
if (requestedMode != null && region.hasTestblock()) {
|
||||
region.setTntMode(requestedMode);
|
||||
RegionUtils.actionBar(region, requestedMessage);
|
||||
return;
|
||||
}
|
||||
switch (region.getTntMode()) {
|
||||
case ON:
|
||||
case ONLY_TB:
|
||||
region.setTntMode(TNTMode.OFF);
|
||||
RegionUtils.actionBar(region, getDisableMessage());
|
||||
break;
|
||||
case OFF:
|
||||
if (Region.buildAreaEnabled() && region.hasTestblock()) {
|
||||
region.setTntMode(TNTMode.ONLY_TB);
|
||||
RegionUtils.actionBar(region, getTestblockEnableMessage());
|
||||
} else {
|
||||
region.setTntMode(TNTMode.ON);
|
||||
RegionUtils.actionBar(region, getEnableMessage());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent event) {
|
||||
event.blockList().removeIf(block -> {
|
||||
Region region = Region.getRegion(block.getLocation());
|
||||
if (region.getTntMode() == TNTMode.ON) return false;
|
||||
if (region.hasBuildRegion() && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.NORMAL)) {
|
||||
RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört");
|
||||
return true;
|
||||
}
|
||||
if (region.hasBuildRegion() && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)) {
|
||||
RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört");
|
||||
return true;
|
||||
}
|
||||
return region.getTntMode() == TNTMode.OFF;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.CraftbukkitWrapper;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.TPSUtils;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandTPSLimiter extends SWCommand {
|
||||
|
||||
private static CommandTPSLimiter instance = null;
|
||||
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
private static double currentTPSLimit = 20;
|
||||
|
||||
private long lastTime = System.nanoTime();
|
||||
private long currentTime = System.nanoTime();
|
||||
|
||||
private double delay = 0;
|
||||
private int loops = 0;
|
||||
private long sleepDelay = 0;
|
||||
|
||||
private BukkitTask tpsLimiter = null;
|
||||
|
||||
private List<String> tabCompletions = new ArrayList<>(Arrays.asList("0,5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"));
|
||||
|
||||
public CommandTPSLimiter() {
|
||||
super("tpslimit");
|
||||
if (TPSUtils.isWarpAllowed()) {
|
||||
for (int i = 20; i <= 60; i += 5) {
|
||||
tabCompletions.add(i + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "Jetziges TPS limit: " + currentTPSLimit);
|
||||
p.sendMessage("§8/§etpslimit §8[§7TPS§8|§edefault§8] §8- §7Setzte die TPS auf dem Bau");
|
||||
}
|
||||
|
||||
@Register({"default"})
|
||||
public void defaultCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
currentTPSLimit = 20;
|
||||
sendNewTPSLimitMessage();
|
||||
tpsLimiter();
|
||||
}
|
||||
|
||||
@Register
|
||||
public void valueCommand(Player p, double tpsLimitDouble) {
|
||||
if (!permissionCheck(p)) return;
|
||||
if (tpsLimitDouble < 0.5 || tpsLimitDouble > (TPSUtils.isWarpAllowed() ? 60 : 20)) {
|
||||
sendInvalidArgumentMessage(p);
|
||||
return;
|
||||
}
|
||||
currentTPSLimit = tpsLimitDouble;
|
||||
sendNewTPSLimitMessage();
|
||||
tpsLimiter();
|
||||
}
|
||||
|
||||
@ClassMapper(value = double.class, local = true)
|
||||
public TypeMapper<Double> doubleTypeMapper() {
|
||||
return SWCommandUtils.createMapper(s -> {
|
||||
try {
|
||||
return Double.parseDouble(s.replace(',', '.'));
|
||||
} catch (NumberFormatException e) {
|
||||
return 0D;
|
||||
}
|
||||
}, s -> tabCompletions);
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.WORLD)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TPS-Limiter nutzen");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendNewTPSLimitMessage() {
|
||||
Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§eTPS limit auf " + currentTPSLimit + " gesetzt.")));
|
||||
}
|
||||
|
||||
private void sendInvalidArgumentMessage(Player player) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cNur Zahlen zwischen 0,5 und " + (TPSUtils.isWarpAllowed() ? 60 : 20) + ", und 'default' erlaubt.");
|
||||
}
|
||||
|
||||
private void tpsLimiter() {
|
||||
delay = 20 / currentTPSLimit;
|
||||
loops = (int) Math.ceil(delay);
|
||||
sleepDelay = (long) (50 * delay) / loops;
|
||||
|
||||
TPSUtils.setTPS(currentTPSLimit);
|
||||
if (currentTPSLimit >= 20) {
|
||||
if (tpsLimiter == null) return;
|
||||
tpsLimiter.cancel();
|
||||
tpsLimiter = null;
|
||||
} else {
|
||||
if (tpsLimiter != null) return;
|
||||
tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
|
||||
CraftbukkitWrapper.impl.createTickCache(WORLD);
|
||||
|
||||
for (int i = 0; i < loops; i++) {
|
||||
sleepUntilNextTick(sleepDelay);
|
||||
CraftbukkitWrapper.impl.sendTickPackets();
|
||||
}
|
||||
}, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void sleepUntilNextTick(long neededDelta) {
|
||||
lastTime = currentTime;
|
||||
currentTime = System.nanoTime();
|
||||
|
||||
long timeDelta = (currentTime - lastTime) / 1000000;
|
||||
if (neededDelta - timeDelta < 0) return;
|
||||
|
||||
try {
|
||||
Thread.sleep(neededDelta - timeDelta);
|
||||
currentTime = System.nanoTime();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
public static double getCurrentTPSLimit() {
|
||||
return (double) Math.round(currentTPSLimit * 10.0D) / 10.0D;
|
||||
}
|
||||
|
||||
public static void setTPS(double d) {
|
||||
if (d < 0.5) d = 0.5;
|
||||
if (d > (TPSUtils.isWarpAllowed() ? 60 : 20)) d = (TPSUtils.isWarpAllowed() ? 60 : 20);
|
||||
if (instance != null) {
|
||||
currentTPSLimit = d;
|
||||
instance.tpsLimiter();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
public class CommandTeleport extends SWCommand {
|
||||
|
||||
public CommandTeleport() {
|
||||
super("teleport", "tp");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§etp §8[§7Player§8] §8- §7Teleportiere dich zu einem Spieler");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p, Player target) {
|
||||
if (p.getUniqueId().equals(target.getUniqueId())) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!");
|
||||
return;
|
||||
}
|
||||
p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.tracer.show.ShowModeParameterType;
|
||||
import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.bausystem.world.regions.RegionExtensionType;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CommandTestblock extends SWCommand {
|
||||
|
||||
public CommandTestblock() {
|
||||
super("testblock", "tb");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§etestblock §8- §7Setzte den Testblock zurück");
|
||||
p.sendMessage("§8/§etestblock §8[§7Schematic§8] §8- §7Setzte den Testblock mit einer Schematic zurück");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericTestblockCommand(Player p) {
|
||||
genericTestblockCommand(p, RegionExtensionType.NORMAL);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericTestblockCommand(Player p, RegionExtensionType regionExtensionType) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
try {
|
||||
region.resetTestblock(null, regionExtensionType == RegionExtensionType.EXTENSION);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Register
|
||||
public void schematicTestblockCommand(Player p, SchematicNode schem) {
|
||||
schematicTestblockCommand(p, schem, RegionExtensionType.NORMAL);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, SchematicNode schem) {
|
||||
schematicTestblockCommand(p, schem, regionExtensionType);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void schematicTestblockCommand(Player p, SchematicNode schem, RegionExtensionType regionExtensionType) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = regionCheck(p);
|
||||
if (region == null) return;
|
||||
try {
|
||||
region.resetTestblock(schem, regionExtensionType == RegionExtensionType.EXTENSION);
|
||||
p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks");
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ClassMapper(value = RegionExtensionType.class, local = true)
|
||||
private TypeMapper<RegionExtensionType> regionExtensionTypeTypeMapper() {
|
||||
Map<String, RegionExtensionType> showModeParameterTypesMap = new HashMap<>();
|
||||
showModeParameterTypesMap.put("-normal", RegionExtensionType.NORMAL);
|
||||
showModeParameterTypesMap.put("-n", RegionExtensionType.NORMAL);
|
||||
showModeParameterTypesMap.put("-extension", RegionExtensionType.EXTENSION);
|
||||
showModeParameterTypesMap.put("-e", RegionExtensionType.EXTENSION);
|
||||
|
||||
List<String> tabCompletes = new ArrayList<>(showModeParameterTypesMap.keySet());
|
||||
return SWCommandUtils.createMapper(s -> showModeParameterTypesMap.getOrDefault(s, null), s -> tabCompletes);
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.WORLDEDIT)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Testblock zurücksetzen");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Region regionCheck(Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (!region.hasTestblock()) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
||||
return null;
|
||||
}
|
||||
return region;
|
||||
}
|
||||
}
|
||||
@@ -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.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandTime extends SWCommand {
|
||||
|
||||
private static List<String> tabCompletions = Arrays.asList("0", "6000", "12000", "18000");
|
||||
|
||||
public CommandTime() {
|
||||
super("time");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§etime §8<§7Zeit 0=Morgen§8, §76000=Mittag§8, §718000=Mitternacht§8> §8- §7Setzt die Zeit auf dem Bau");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p, int time) {
|
||||
if (Welt.noPermission(p, Permission.WORLD)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern");
|
||||
return;
|
||||
}
|
||||
if (time < 0 || time > 24000) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
|
||||
return;
|
||||
}
|
||||
Bukkit.getWorlds().get(0).setTime(time);
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p, Time time) {
|
||||
if (Welt.noPermission(p, Permission.WORLD)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern");
|
||||
return;
|
||||
}
|
||||
Bukkit.getWorlds().get(0).setTime(time.getValue());
|
||||
}
|
||||
|
||||
@ClassMapper(value = int.class, local = true)
|
||||
public TypeMapper<Integer> doubleTypeMapper() {
|
||||
return SWCommandUtils.createMapper(s -> {
|
||||
try {
|
||||
return Integer.parseInt(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}, s -> tabCompletions);
|
||||
}
|
||||
|
||||
public enum Time {
|
||||
NIGHT(18000),
|
||||
DAY(6000),
|
||||
DAWN(0),
|
||||
SUNSET(12000),
|
||||
NACHT(18000),
|
||||
TAG(6000),
|
||||
MORGEN(0),
|
||||
ABEND(12000);
|
||||
|
||||
private int value;
|
||||
|
||||
private Time(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.gui.GuiTraceShow;
|
||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
|
||||
import de.steamwar.bausystem.tracer.show.ShowModeParameterType;
|
||||
import de.steamwar.bausystem.tracer.show.StoredRecords;
|
||||
import de.steamwar.bausystem.tracer.show.TraceShowManager;
|
||||
import de.steamwar.bausystem.tracer.show.mode.EntityShowMode;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandTrace extends SWCommand {
|
||||
|
||||
public CommandTrace() {
|
||||
super("trace");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen");
|
||||
p.sendMessage("§8/§etrace stop §8- §7Stoppt den TNT-Tracer");
|
||||
p.sendMessage("§8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart");
|
||||
p.sendMessage("§8/§etrace show gui §8- §7Zeigt die Trace show gui");
|
||||
p.sendMessage("§8/§etrace show §8<§e-water§8|§e-interpolate-xz§8|§e-interpolate-y§8> §8- §7Zeigt alle TNT-Positionen");
|
||||
p.sendMessage("§8/§etrace hide §8- §7Versteckt alle TNT-Positionen");
|
||||
p.sendMessage("§8/§etrace delete §8- §7Löscht alle TNT-Positionen");
|
||||
// p.sendMessage("§8/§etrace list §8<§7FRAME-ID§8> §8- §7Listet alle TNT auf");
|
||||
// p.sendMessage("§8/§etrace gui §8- §7Zeigt die Trace Oberfläche an");
|
||||
// p.sendMessage("§7Optionale Parameter mit §8<>§7, Benötigte Parameter mit §8[]");
|
||||
}
|
||||
|
||||
@Register({"start"})
|
||||
public void startCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
RecordStateMachine.commandStart();
|
||||
p.sendMessage(BauSystem.PREFIX + "§aTNT-Tracer gestartet");
|
||||
}
|
||||
|
||||
@Register({"stop"})
|
||||
public void stopCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
RecordStateMachine.commandStop();
|
||||
p.sendMessage(BauSystem.PREFIX + "§cTNT-Tracer gestoppt");
|
||||
}
|
||||
|
||||
@Register({"toggleauto"})
|
||||
public void toggleAutoCommand(Player p) {
|
||||
autoCommand(p);
|
||||
}
|
||||
|
||||
@Register({"auto"})
|
||||
public void autoCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
RecordStateMachine.commandAuto();
|
||||
p.sendMessage(BauSystem.PREFIX + RecordStateMachine.getRecordStatus().getAutoMessage());
|
||||
}
|
||||
|
||||
@Register({"clear"})
|
||||
public void clearCommand(Player p) {
|
||||
deleteCommand(p);
|
||||
}
|
||||
|
||||
@Register({"delete"})
|
||||
public void deleteCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
StoredRecords.clear();
|
||||
p.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen gelöscht");
|
||||
}
|
||||
|
||||
@Register({"show"})
|
||||
public void showCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
TraceShowManager.show(p, new EntityShowMode(p, new ShowModeParameter()));
|
||||
p.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
|
||||
}
|
||||
|
||||
@Register({"show"})
|
||||
public void showCommand(Player p, ShowModeParameterType... showModeParameterTypes) {
|
||||
if (!permissionCheck(p)) return;
|
||||
ShowModeParameter showModeParameter = new ShowModeParameter();
|
||||
for (ShowModeParameterType showModeParameterType : showModeParameterTypes) {
|
||||
showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter);
|
||||
}
|
||||
TraceShowManager.show(p, new EntityShowMode(p, showModeParameter));
|
||||
p.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
|
||||
}
|
||||
|
||||
@Register({"show", "gui"})
|
||||
public void showGuiCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
GuiTraceShow.openGui(p);
|
||||
}
|
||||
|
||||
@Register({"hide"})
|
||||
public void hideCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
TraceShowManager.hide(p);
|
||||
p.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen ausgeblendet");
|
||||
}
|
||||
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.WORLD)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
public class CommandWorldSpawn extends SWCommand {
|
||||
|
||||
private World world = Bukkit.getWorlds().get(0);
|
||||
|
||||
public CommandWorldSpawn() {
|
||||
super("worldspawn");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§eworldspawn §8- §7Teleportiere dich zum Spawn");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p) {
|
||||
p.teleport(world.getSpawnLocation(), PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.world.regions.GlobalRegion;
|
||||
import de.steamwar.bausystem.world.regions.Region;
|
||||
import de.steamwar.bausystem.world.regions.RegionExtensionType;
|
||||
import de.steamwar.bausystem.world.regions.RegionType;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@UtilityClass
|
||||
public class RegionUtils {
|
||||
|
||||
public static void actionBar(Region region, String s) {
|
||||
if (GlobalRegion.isGlobalRegion(region)) {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
|
||||
} else {
|
||||
Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user