Merge branch 'master' into CannonSimulator
Dieser Commit ist enthalten in:
Commit
2635f98afc
@ -28,9 +28,7 @@ import org.bukkit.entity.FallingBlock;
|
|||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
class TPSLimit_12 {
|
class TPSLimit_12 {
|
||||||
|
|
||||||
|
@ -34,4 +34,16 @@ public class TNTTracer_12 {
|
|||||||
return material == Material.WATER || material == Material.STATIONARY_WATER;
|
return material == Material.WATER || material == Material.STATIONARY_WATER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Material getTraceShowMaterial() {
|
||||||
|
return Material.CONCRETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Material getTraceHideMaterial() {
|
||||||
|
return Material.CONCRETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Material getTraceXZMaterial() {
|
||||||
|
return Material.STEP;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,12 @@
|
|||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import net.minecraft.server.v1_12_R1.BlockPosition;
|
||||||
|
import net.minecraft.server.v1_12_R1.PacketPlayOutOpenSignEditor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
class RegionListener_12 {
|
class RegionListener_12 {
|
||||||
private RegionListener_12(){}
|
private RegionListener_12(){}
|
||||||
@ -33,4 +38,9 @@ class RegionListener_12 {
|
|||||||
return ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")).getWorldEdit().getPlatformManager()
|
return ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")).getWorldEdit().getPlatformManager()
|
||||||
.getCommandManager().getDispatcher().get(command) != null;
|
.getCommandManager().getDispatcher().get(command) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void openSignEditor(Player player, Location location) {
|
||||||
|
PacketPlayOutOpenSignEditor packet = new PacketPlayOutOpenSignEditor(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,5 +50,12 @@
|
|||||||
<artifactId>BauSystem_API</artifactId>
|
<artifactId>BauSystem_API</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>ProtocolLib</artifactId>
|
||||||
|
<version>4.5.0</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${main.basedir}/lib/ProtocolLib.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -27,6 +27,9 @@ class CommandDebugStick_15 {
|
|||||||
private CommandDebugStick_15(){}
|
private CommandDebugStick_15(){}
|
||||||
|
|
||||||
static void giveStick(Player player){
|
static void giveStick(Player player){
|
||||||
player.getInventory().setItemInMainHand(new ItemStack(Material.DEBUG_STICK, 1));
|
if(player.getInventory().getItemInMainHand().getType() == Material.AIR)
|
||||||
|
player.getInventory().setItemInMainHand(new ItemStack(Material.DEBUG_STICK));
|
||||||
|
else
|
||||||
|
player.getInventory().addItem(new ItemStack(Material.DEBUG_STICK));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import org.bukkit.entity.TNTPrimed;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
class TPSLimit_15 {
|
class TPSLimit_15 {
|
||||||
|
|
||||||
|
@ -44,4 +44,16 @@ public class TNTTracer_15 {
|
|||||||
return ((Waterlogged) data).isWaterlogged();
|
return ((Waterlogged) data).isWaterlogged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Material getTraceShowMaterial() {
|
||||||
|
return Material.LIME_CONCRETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Material getTraceHideMaterial() {
|
||||||
|
return Material.RED_CONCRETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Material getTraceXZMaterial() {
|
||||||
|
return Material.QUARTZ_SLAB;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,17 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
class RegionListener_15 {
|
class RegionListener_15 {
|
||||||
private RegionListener_15(){}
|
private RegionListener_15(){}
|
||||||
@ -31,4 +41,14 @@ class RegionListener_15 {
|
|||||||
command = command.toLowerCase();
|
command = command.toLowerCase();
|
||||||
return WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().containsCommand(command);
|
return WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().containsCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void openSignEditor(Player player, Location location) {
|
||||||
|
PacketContainer signOpen = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.OPEN_SIGN_EDITOR);
|
||||||
|
signOpen.getBlockPositionModifier().write(0, new BlockPosition(location.toVector()));
|
||||||
|
try {
|
||||||
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, signOpen);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Invocation target exception", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
33
BauSystem_15/src/de/steamwar/bausystem/world/TPSUtils_15.java
Normale Datei
33
BauSystem_15/src/de/steamwar/bausystem/world/TPSUtils_15.java
Normale Datei
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_15_R1.SystemUtils;
|
||||||
|
|
||||||
|
import java.util.function.LongSupplier;
|
||||||
|
|
||||||
|
public class TPSUtils_15 {
|
||||||
|
|
||||||
|
public static void init(LongSupplier longSupplier) {
|
||||||
|
SystemUtils.a = () -> System.nanoTime() + longSupplier.getAsLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -83,6 +83,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
getCommand("reset").setExecutor(new CommandReset());
|
getCommand("reset").setExecutor(new CommandReset());
|
||||||
getCommand("speed").setExecutor(new CommandSpeed());
|
getCommand("speed").setExecutor(new CommandSpeed());
|
||||||
getCommand("tnt").setExecutor(new CommandTNT());
|
getCommand("tnt").setExecutor(new CommandTNT());
|
||||||
|
getCommand("tnt").setTabCompleter(new CommandTNTTabComplete());
|
||||||
getCommand("fire").setExecutor(new CommandFire());
|
getCommand("fire").setExecutor(new CommandFire());
|
||||||
getCommand("freeze").setExecutor(new CommandFreeze());
|
getCommand("freeze").setExecutor(new CommandFreeze());
|
||||||
getCommand("testblock").setExecutor(new CommandTestblock());
|
getCommand("testblock").setExecutor(new CommandTestblock());
|
||||||
@ -109,6 +110,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
new AFKStopper();
|
new AFKStopper();
|
||||||
|
|
||||||
autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200);
|
autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200);
|
||||||
|
TPSUtils.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BauSystem getPlugin() {
|
public static BauSystem getPlugin() {
|
||||||
|
@ -22,7 +22,7 @@ package de.steamwar.bausystem.commands;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.VersionedRunnable;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -42,14 +42,8 @@ public class CommandDebugStick implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(Core.getVersion()){
|
VersionedRunnable.call(new VersionedRunnable(() -> player.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12."), 8),
|
||||||
case 15:
|
new VersionedRunnable(() -> CommandDebugStick_15.giveStick(player), 15));
|
||||||
CommandDebugStick_15.giveStick(player);
|
|
||||||
break;
|
|
||||||
case 12:
|
|
||||||
default:
|
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12.");
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.world.Detonator;
|
import de.steamwar.bausystem.world.Detonator;
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -62,7 +63,10 @@ public class CommandDetonator implements CommandExecutor {
|
|||||||
case "wand":
|
case "wand":
|
||||||
case "detonator":
|
case "detonator":
|
||||||
case "item":
|
case "item":
|
||||||
|
if(player.getInventory().getItemInMainHand().getType() == Material.AIR)
|
||||||
player.getInventory().setItemInMainHand(Detonator.WAND);
|
player.getInventory().setItemInMainHand(Detonator.WAND);
|
||||||
|
else
|
||||||
|
player.getInventory().addItem(Detonator.WAND);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
Detonator.getDetonator(player);
|
Detonator.getDetonator(player);
|
||||||
break;
|
break;
|
||||||
|
@ -19,19 +19,12 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.world.Region;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.block.BlockBurnEvent;
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
import org.bukkit.event.block.BlockSpreadEvent;
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
|
|
||||||
public class CommandFire extends ToggleCommand {
|
public class CommandFire extends RegionToggleCommand {
|
||||||
|
|
||||||
public CommandFire(){
|
|
||||||
super(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ToggleCommand getInstance(){
|
|
||||||
return getInstance(CommandFire.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getNoPermMessage() {
|
String getNoPermMessage() {
|
||||||
@ -46,14 +39,20 @@ public class CommandFire extends ToggleCommand {
|
|||||||
return "§aFeuerschaden aktiviert";
|
return "§aFeuerschaden aktiviert";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean toggle(Region region) {
|
||||||
|
region.setFire(!region.isFire());
|
||||||
|
return region.isFire();
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFireDamage(BlockBurnEvent e) {
|
public void onFireDamage(BlockBurnEvent e) {
|
||||||
e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFireSpread(BlockSpreadEvent e){
|
public void onFireSpread(BlockSpreadEvent e){
|
||||||
e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,19 +19,19 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.world.Region;
|
||||||
|
import de.steamwar.core.Core;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.block.*;
|
import org.bukkit.event.block.*;
|
||||||
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||||
|
|
||||||
public class CommandFreeze extends ToggleCommand {
|
public class CommandFreeze extends RegionToggleCommand {
|
||||||
|
|
||||||
public CommandFreeze(){
|
|
||||||
super(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ToggleCommand getInstance(){
|
|
||||||
return getInstance(CommandFreeze.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getNoPermMessage() {
|
String getNoPermMessage() {
|
||||||
@ -46,38 +46,71 @@ public class CommandFreeze extends ToggleCommand {
|
|||||||
return "§aWelt aufgetaut";
|
return "§aWelt aufgetaut";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean toggle(Region region) {
|
||||||
|
region.setFreeze(!region.isFreeze());
|
||||||
|
return region.isFreeze();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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
|
@EventHandler
|
||||||
public void onPhysicsEvent(BlockPhysicsEvent e){
|
public void onPhysicsEvent(BlockPhysicsEvent e){
|
||||||
e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPistonExtend(BlockPistonExtendEvent e){
|
public void onPistonExtend(BlockPistonExtendEvent e){
|
||||||
e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPistonRetract(BlockPistonRetractEvent e){
|
public void onPistonRetract(BlockPistonRetractEvent e){
|
||||||
e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockGrow(BlockGrowEvent e){
|
public void onBlockGrow(BlockGrowEvent e){
|
||||||
e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onRedstoneEvent(BlockRedstoneEvent e){
|
public void onRedstoneEvent(BlockRedstoneEvent e){
|
||||||
e.setNewCurrent(e.getOldCurrent());
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setNewCurrent(e.getOldCurrent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockDispense(BlockDispenseEvent e){
|
public void onBlockDispense(BlockDispenseEvent e){
|
||||||
e.setCancelled(true);
|
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
|
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
|
||||||
e.setCancelled(true);
|
if (Region.getRegion(e.getDestination().getLocation()).isFreeze()) e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,23 +20,32 @@
|
|||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.world.Region;
|
||||||
|
import de.steamwar.bausystem.world.TPSUtils;
|
||||||
import de.steamwar.core.TPSWatcher;
|
import de.steamwar.core.TPSWatcher;
|
||||||
import de.steamwar.sql.BauweltMember;
|
import de.steamwar.sql.BauweltMember;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static de.steamwar.bausystem.world.TPSUtils.getTps;
|
||||||
|
|
||||||
public class CommandInfo implements CommandExecutor {
|
public class CommandInfo implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
sender.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName());
|
sender.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName());
|
||||||
sender.sendMessage(BauSystem.PREFIX + "TNT-Schaden: " + (CommandTNT.getInstance().isOn() ? "§aAUS" : "§cAN"));
|
Region region = Region.getRegion(player.getLocation());
|
||||||
sender.sendMessage(BauSystem.PREFIX + "Feuerschaden: " + (CommandFire.getInstance().isOn() ? "§aAUS" : "§cAN"));
|
sender.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.getTntMode().getName() + " §eFire§8: " + (region.isFire() ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (region.isFreeze() ? "§aAN" : "§cAUS"));
|
||||||
sender.sendMessage(BauSystem.PREFIX + "Eingefroren: " + (CommandFreeze.getInstance().isOn() ? "§aJA" : "§cNEIN"));
|
|
||||||
|
|
||||||
List<BauweltMember> members = BauweltMember.getMembers(BauSystem.getOwnerID());
|
List<BauweltMember> members = BauweltMember.getMembers(BauSystem.getOwnerID());
|
||||||
StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: ");
|
StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: ");
|
||||||
@ -49,12 +58,17 @@ public class CommandInfo implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
sender.sendMessage(membermessage.toString());
|
sender.sendMessage(membermessage.toString());
|
||||||
|
|
||||||
sender.sendMessage(BauSystem.PREFIX + "TPS:§e" +
|
StringBuilder tpsMessage = new StringBuilder();
|
||||||
" " + TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_SECOND) +
|
tpsMessage.append(BauSystem.PREFIX).append("TPS:§e");
|
||||||
" " + TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_SECONDS) +
|
tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.ONE_SECOND));
|
||||||
" " + TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE) +
|
tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.TEN_SECONDS));
|
||||||
" " + TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES) +
|
if (!TPSUtils.isWarping()) {
|
||||||
" " + TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES));
|
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));
|
||||||
|
}
|
||||||
|
sender.sendMessage(tpsMessage.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,11 @@ public class CommandProtect implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Region region : Region.getRegions()){
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if(region.inRegion(player.getLocation()) && region.hasProtection()){
|
if (region == null || !region.hasProtection()) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner (M)WG-Region");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Schematic schem = null;
|
Schematic schem = null;
|
||||||
if(args.length > 0){
|
if(args.length > 0){
|
||||||
@ -64,9 +67,4 @@ public class CommandProtect implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner (M)WG-Region");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,11 @@ public class CommandReset implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Region region : Region.getRegions()){
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if(region.inRegion(player.getLocation())){
|
if (region == null) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if(args.length > 0){
|
if(args.length > 0){
|
||||||
Schematic schem = Schematic.getSchemFromDB(args[0], player.getUniqueId());
|
Schematic schem = Schematic.getSchemFromDB(args[0], player.getUniqueId());
|
||||||
@ -65,9 +68,4 @@ public class CommandReset implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package de.steamwar.bausystem.commands;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -46,7 +47,11 @@ public class CommandSkull implements CommandExecutor {
|
|||||||
assert sm != null;
|
assert sm != null;
|
||||||
sm.setDisplayName("§e" + args[0] + "§8s Kopf");
|
sm.setDisplayName("§e" + args[0] + "§8s Kopf");
|
||||||
is.setItemMeta(sm);
|
is.setItemMeta(sm);
|
||||||
|
if(p.getInventory().getItemInMainHand().getType() == Material.AIR)
|
||||||
p.getInventory().setItemInMainHand(is);
|
p.getInventory().setItemInMainHand(is);
|
||||||
|
else
|
||||||
|
p.getInventory().addItem(is);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,34 +19,133 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.world.Region;
|
||||||
|
import de.steamwar.bausystem.world.Welt;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
|
||||||
public class CommandTNT extends ToggleCommand {
|
public class CommandTNT implements CommandExecutor, Listener {
|
||||||
|
|
||||||
public CommandTNT(){
|
public enum TNTMode {
|
||||||
super(true);
|
ON("§aan"),
|
||||||
|
ONLY_TB("§7Kein §eBaurahmen"),
|
||||||
|
OFF("§caus");
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
TNTMode(String name) {
|
||||||
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ToggleCommand getInstance(){
|
public String getName() {
|
||||||
return getInstance(CommandTNT.class);
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
String getNoPermMessage() {
|
|
||||||
return "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren";
|
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
String getEnableMessage(){
|
public CommandTNT() {
|
||||||
return "§cTNT-Schaden deaktiviert";
|
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
String getDisableMessage(){
|
private String getEnableMessage() {
|
||||||
return "§aTNT-Schaden aktiviert";
|
return "§aTNT-Schaden aktiviert";
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
private String getDisableMessage() {
|
||||||
public void onExplode(EntityExplodeEvent e) {
|
return "§cTNT-Schaden deaktiviert";
|
||||||
e.blockList().clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getTestblockEnableMessage() {
|
||||||
|
return "§aTNT-Schaden außerhalb Baurahmen aktiviert";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||||
|
if (!(sender instanceof Player)) return false;
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (Welt.noPermission(player, Permission.world)) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TNTMode requestedMode = null;
|
||||||
|
String requestedMessage = null;
|
||||||
|
if (args.length != 0) {
|
||||||
|
switch (args[0].toLowerCase()) {
|
||||||
|
case "an":
|
||||||
|
case "on":
|
||||||
|
requestedMode = TNTMode.ON;
|
||||||
|
requestedMessage = getEnableMessage();
|
||||||
|
break;
|
||||||
|
case "aus":
|
||||||
|
case "off":
|
||||||
|
requestedMode = TNTMode.OFF;
|
||||||
|
requestedMessage = getDisableMessage();
|
||||||
|
break;
|
||||||
|
case "testblock":
|
||||||
|
case "tb":
|
||||||
|
if (!Region.buildAreaEnabled()) break;
|
||||||
|
requestedMode = TNTMode.ONLY_TB;
|
||||||
|
requestedMessage = getTestblockEnableMessage();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Region region = Region.getRegion(player.getLocation());
|
||||||
|
tntToggle(region, requestedMode, requestedMessage);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
|
||||||
|
if (requestedMode != null && region.hasTestblock()) {
|
||||||
|
region.setTntMode(requestedMode);
|
||||||
|
RegionToggleCommand.actionBar(region, requestedMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (region.getTntMode()) {
|
||||||
|
case ON:
|
||||||
|
case ONLY_TB:
|
||||||
|
region.setTntMode(TNTMode.OFF);
|
||||||
|
RegionToggleCommand.actionBar(region, getDisableMessage());
|
||||||
|
break;
|
||||||
|
case OFF:
|
||||||
|
if (Region.buildAreaEnabled() && region.hasTestblock()) {
|
||||||
|
region.setTntMode(TNTMode.ONLY_TB);
|
||||||
|
RegionToggleCommand.actionBar(region, getTestblockEnableMessage());
|
||||||
|
} else {
|
||||||
|
region.setTntMode(TNTMode.ON);
|
||||||
|
RegionToggleCommand.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.inBuildRegion(block.getLocation())) {
|
||||||
|
RegionToggleCommand.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (region.hasBuildRegion() && region.inBuildRegionExtension(block.getLocation())) {
|
||||||
|
RegionToggleCommand.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return region.getTntMode() == TNTMode.OFF;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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.world.Region;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CommandTNTTabComplete implements TabCompleter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player)) return new ArrayList<>();
|
||||||
|
return tntTabComplete(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> tntTabComplete(String[] args) {
|
||||||
|
List<String> tabComplete = new ArrayList<>();
|
||||||
|
tabComplete.add("an");
|
||||||
|
tabComplete.add("on");
|
||||||
|
tabComplete.add("aus");
|
||||||
|
tabComplete.add("off");
|
||||||
|
if (Region.buildAreaEnabled()) {
|
||||||
|
tabComplete.add("testblock");
|
||||||
|
tabComplete.add("tb");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length >= 2) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
return manageList(tabComplete, args, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> manageList(List<String> strings, String[] args, int index) {
|
||||||
|
for (int i = strings.size() - 1; i >= 0; i--) {
|
||||||
|
if (!strings.get(i).startsWith(args[index])) {
|
||||||
|
strings.remove(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return strings;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -21,6 +21,7 @@ package de.steamwar.bausystem.commands;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.world.TPSUtils;
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
import de.steamwar.core.VersionedRunnable;
|
import de.steamwar.core.VersionedRunnable;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
@ -35,11 +36,16 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
|
|
||||||
public class CommandTPSLimiter implements CommandExecutor {
|
public class CommandTPSLimiter implements CommandExecutor {
|
||||||
|
|
||||||
|
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
private static double currentTPSLimit = 20;
|
private static double currentTPSLimit = 20;
|
||||||
private static World world = Bukkit.getWorlds().get(0);
|
|
||||||
private long lastTime = System.nanoTime();
|
private long lastTime = System.nanoTime();
|
||||||
private long currentTime = System.nanoTime();
|
private long currentTime = System.nanoTime();
|
||||||
|
|
||||||
|
private double delay = 0;
|
||||||
|
private int loops = 0;
|
||||||
|
private long sleepDelay = 0;
|
||||||
|
|
||||||
private BukkitTask tpsLimiter = null;
|
private BukkitTask tpsLimiter = null;
|
||||||
|
|
||||||
private boolean permissionCheck(Player player) {
|
private boolean permissionCheck(Player player) {
|
||||||
@ -72,7 +78,7 @@ public class CommandTPSLimiter implements CommandExecutor {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
double tpsLimitDouble = Double.parseDouble(tpsLimit.replace(',', '.'));
|
double tpsLimitDouble = Double.parseDouble(tpsLimit.replace(',', '.'));
|
||||||
if (tpsLimitDouble < 0.5 || tpsLimitDouble > 20) {
|
if (tpsLimitDouble < 0.5 || tpsLimitDouble > (TPSUtils.isWarpAllowed() ? 40 : 20)) {
|
||||||
sendInvalidArgumentMessage(player);
|
sendInvalidArgumentMessage(player);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -91,21 +97,27 @@ public class CommandTPSLimiter implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendInvalidArgumentMessage(Player player) {
|
private void sendInvalidArgumentMessage(Player player) {
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cNur Zahlen zwischen 0,5 und 20, und 'default' erlaubt.");
|
player.sendMessage(BauSystem.PREFIX + "§cNur Zahlen zwischen 0,5 und " + (TPSUtils.isWarpAllowed() ? 40 : 20) + ", und 'default' erlaubt.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tpsLimiter() {
|
private void tpsLimiter() {
|
||||||
if (currentTPSLimit == 20) {
|
delay = 20 / currentTPSLimit;
|
||||||
|
loops = (int)Math.ceil(delay);
|
||||||
|
sleepDelay = (long) (50 * delay) / loops;
|
||||||
|
|
||||||
|
TPSUtils.setTPS(currentTPSLimit);
|
||||||
|
if (currentTPSLimit >= 20) {
|
||||||
if (tpsLimiter == null) return;
|
if (tpsLimiter == null) return;
|
||||||
tpsLimiter.cancel();
|
tpsLimiter.cancel();
|
||||||
tpsLimiter = null;
|
tpsLimiter = null;
|
||||||
} else {
|
} else {
|
||||||
if (tpsLimiter != null) return;
|
if (tpsLimiter != null) return;
|
||||||
tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
|
tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> TPSLimit_12.createTickCache(world), 8),
|
VersionedRunnable.call(new VersionedRunnable(() -> TPSLimit_12.createTickCache(WORLD), 8),
|
||||||
new VersionedRunnable(() -> TPSLimit_15.createTickCache(world), 14));
|
new VersionedRunnable(() -> TPSLimit_15.createTickCache(WORLD), 14));
|
||||||
for (int i = 0; i < (20 / currentTPSLimit); i++) {
|
|
||||||
sleepUntilNextTick();
|
for (int i = 0; i < loops; i++) {
|
||||||
|
sleepUntilNextTick(sleepDelay);
|
||||||
VersionedRunnable.call(new VersionedRunnable(TPSLimit_12::sendTickPackets, 8),
|
VersionedRunnable.call(new VersionedRunnable(TPSLimit_12::sendTickPackets, 8),
|
||||||
new VersionedRunnable(TPSLimit_15::sendTickPackets, 14));
|
new VersionedRunnable(TPSLimit_15::sendTickPackets, 14));
|
||||||
}
|
}
|
||||||
@ -113,16 +125,12 @@ public class CommandTPSLimiter implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sleepUntilNextTick() {
|
private void sleepUntilNextTick(long neededDelta) {
|
||||||
lastTime = currentTime;
|
lastTime = currentTime;
|
||||||
currentTime = System.nanoTime();
|
currentTime = System.nanoTime();
|
||||||
|
|
||||||
long timeDelta = (currentTime - lastTime) / 1000000;
|
long timeDelta = (currentTime - lastTime) / 1000000;
|
||||||
long neededDelta = 50;
|
if (neededDelta - timeDelta < 0) return;
|
||||||
|
|
||||||
if (neededDelta - timeDelta < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(neededDelta - timeDelta);
|
Thread.sleep(neededDelta - timeDelta);
|
||||||
@ -133,7 +141,7 @@ public class CommandTPSLimiter implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double getCurrentTPSLimit() {
|
public static double getCurrentTPSLimit() {
|
||||||
return currentTPSLimit;
|
return (double)Math.round(currentTPSLimit * 10.0D) / 10.0D;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.world.TPSUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
@ -29,7 +30,11 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CommandTPSLimiterTabComplete implements TabCompleter {
|
public class CommandTPSLimiterTabComplete implements TabCompleter {
|
||||||
|
|
||||||
private List<String> arguments = Arrays.asList("default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20");
|
private List<String> arguments = new ArrayList<>(Arrays.asList("default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"));
|
||||||
|
|
||||||
|
public CommandTPSLimiterTabComplete() {
|
||||||
|
if (TPSUtils.isWarpAllowed()) arguments.addAll(Arrays.asList("21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
@ -45,8 +45,11 @@ public class CommandTestblock implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Region region : Region.getRegions()){
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if(region.inRegion(player.getLocation()) && region.hasTestblock()){
|
if (region == null || !region.hasTestblock()) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Schematic schem = null;
|
Schematic schem = null;
|
||||||
if(args.length > 0){
|
if(args.length > 0){
|
||||||
@ -64,9 +67,4 @@ public class CommandTestblock implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@ package de.steamwar.bausystem.commands;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.gui.GuiTraceShow;
|
||||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||||
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
|
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
|
||||||
import de.steamwar.bausystem.tracer.show.StoredRecords;
|
import de.steamwar.bausystem.tracer.show.StoredRecords;
|
||||||
import de.steamwar.bausystem.tracer.show.TraceShowManager;
|
import de.steamwar.bausystem.tracer.show.TraceShowManager;
|
||||||
import de.steamwar.bausystem.tracer.show.mode.Advanced;
|
import de.steamwar.bausystem.tracer.show.mode.EntityShowMode;
|
||||||
import de.steamwar.bausystem.tracer.show.mode.Basic;
|
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -39,6 +39,7 @@ public class CommandTrace implements CommandExecutor {
|
|||||||
player.sendMessage("§8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen");
|
player.sendMessage("§8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen");
|
||||||
player.sendMessage("§8/§etrace stop §8- §7Stoppt den TNT-Tracer");
|
player.sendMessage("§8/§etrace stop §8- §7Stoppt den TNT-Tracer");
|
||||||
player.sendMessage("§8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart");
|
player.sendMessage("§8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart");
|
||||||
|
player.sendMessage("§8/§etrace show gui §8- §7Zeigt die Trace show gui");
|
||||||
player.sendMessage("§8/§etrace show §8<§edefault§8|§eadvanced§8> §8<§e-water§8|§e-interpolate-xz§8|§e-interpolate-y§8> §8- §7Zeigt alle TNT-Positionen");
|
player.sendMessage("§8/§etrace show §8<§edefault§8|§eadvanced§8> §8<§e-water§8|§e-interpolate-xz§8|§e-interpolate-y§8> §8- §7Zeigt alle TNT-Positionen");
|
||||||
player.sendMessage("§8/§etrace hide §8- §7Versteckt alle TNT-Positionen");
|
player.sendMessage("§8/§etrace hide §8- §7Versteckt alle TNT-Positionen");
|
||||||
player.sendMessage("§8/§etrace delete §8- §7Löscht alle TNT-Positionen");
|
player.sendMessage("§8/§etrace delete §8- §7Löscht alle TNT-Positionen");
|
||||||
@ -88,19 +89,14 @@ public class CommandTrace implements CommandExecutor {
|
|||||||
break;
|
break;
|
||||||
case "show":
|
case "show":
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
TraceShowManager.show(player, new Basic(player, new ShowModeParameter()));
|
TraceShowManager.show(player, new EntityShowMode(player, new ShowModeParameter()));
|
||||||
} else {
|
} else {
|
||||||
ShowModeParameter showModeParameter = ShowModeParameter.parseArguments(args, 2);
|
if (args[1].equalsIgnoreCase("gui")) {
|
||||||
switch (args[1].toLowerCase()) {
|
GuiTraceShow.openGui(player);
|
||||||
case "advanced":
|
return false;
|
||||||
TraceShowManager.show(player, new Advanced(player, showModeParameter));
|
|
||||||
break;
|
|
||||||
case "basic":
|
|
||||||
case "default":
|
|
||||||
default:
|
|
||||||
TraceShowManager.show(player, new Basic(player, showModeParameter));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
ShowModeParameter showModeParameter = ShowModeParameter.parseArguments(args, 1);
|
||||||
|
TraceShowManager.show(player, new EntityShowMode(player, showModeParameter));
|
||||||
}
|
}
|
||||||
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
|
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
|
||||||
break;
|
break;
|
||||||
|
@ -39,9 +39,8 @@ public class CommandTraceTabCompleter implements TabCompleter {
|
|||||||
tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() == RecordStatus.IDLE || RecordStateMachine.getRecordStatus() == RecordStatus.IDLE_AUTO), "start"));
|
tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() == RecordStatus.IDLE || RecordStateMachine.getRecordStatus() == RecordStatus.IDLE_AUTO), "start"));
|
||||||
tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() != RecordStatus.IDLE && RecordStateMachine.getRecordStatus() != RecordStatus.IDLE_AUTO), "stop"));
|
tabCompletes.add(new TabComplete((player, args) -> args.length == 1 && (RecordStateMachine.getRecordStatus() != RecordStatus.IDLE && RecordStateMachine.getRecordStatus() != RecordStatus.IDLE_AUTO), "stop"));
|
||||||
tabCompletes.add(new TabComplete((player, args) -> args.length == 1, "toggleauto", "auto", "show", "hide", "delete", "clear"));
|
tabCompletes.add(new TabComplete((player, args) -> args.length == 1, "toggleauto", "auto", "show", "hide", "delete", "clear"));
|
||||||
tabCompletes.add(new TabComplete((player, args) -> args.length == 2 && args[0].equalsIgnoreCase("show"), "basic", "advanced"));
|
tabCompletes.add(new TabComplete((player, args) -> args.length == 2 && args[0].equalsIgnoreCase("show"), "gui", "-interpolate-xz", "-interpolate-y", "-water", "-advanced", "advanced"));
|
||||||
tabCompletes.add(new TabComplete((player, args) -> args.length > 2 && args[0].equalsIgnoreCase("show") && (args[1].equalsIgnoreCase("basic") || args[1].equalsIgnoreCase("advanced")), "-water"));
|
tabCompletes.add(new TabComplete((player, args) -> args.length > 2 && args[0].equalsIgnoreCase("show") && !args[1].equalsIgnoreCase("gui"), "-interpolate-xz", "-interpolate-y", "-water", "-advanced"));
|
||||||
tabCompletes.add(new TabComplete((player, args) -> args.length > 2 && args[0].equalsIgnoreCase("show") && args[1].equalsIgnoreCase("advanced"), "-interpolate-xz", "-interpolate-y"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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.Permission;
|
||||||
|
import de.steamwar.bausystem.world.Region;
|
||||||
|
import de.steamwar.bausystem.world.Welt;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public abstract class RegionToggleCommand implements CommandExecutor, Listener {
|
||||||
|
|
||||||
|
public RegionToggleCommand() {
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player))
|
||||||
|
return false;
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (Welt.noPermission(player, Permission.world)){
|
||||||
|
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Region region = Region.getRegion(player.getLocation());
|
||||||
|
if (toggle(region)) {
|
||||||
|
actionBar(region, getEnableMessage());
|
||||||
|
} else {
|
||||||
|
actionBar(region, getDisableMessage());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void actionBar(Region region, String s) {
|
||||||
|
if (Region.GlobalRegion.isGlobalRegion(region)) {
|
||||||
|
Bukkit.getOnlinePlayers().stream().filter(player -> Region.getRegion(player.getLocation()) == null).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
|
||||||
|
} else {
|
||||||
|
Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation())).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract String getNoPermMessage();
|
||||||
|
abstract String getEnableMessage();
|
||||||
|
abstract String getDisableMessage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@code true} for {@link #getEnableMessage()}, {@code false} for {@link #getDisableMessage()}
|
||||||
|
*/
|
||||||
|
abstract boolean toggle(Region region);
|
||||||
|
|
||||||
|
}
|
@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.bausystem.commands;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
|
||||||
import de.steamwar.bausystem.Permission;
|
|
||||||
import de.steamwar.bausystem.world.Welt;
|
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public abstract class ToggleCommand implements CommandExecutor, Listener {
|
|
||||||
|
|
||||||
private static Map<Class<? extends ToggleCommand>, Boolean> enabled = new HashMap<>();
|
|
||||||
private static Map<Class<? extends ToggleCommand>, ToggleCommand> instance = new HashMap<>();
|
|
||||||
|
|
||||||
ToggleCommand(boolean on){
|
|
||||||
enabled.put(getClass(), false);
|
|
||||||
if(on)
|
|
||||||
toggle();
|
|
||||||
instance.put(getClass(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if(!(sender instanceof Player))
|
|
||||||
return false;
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (Welt.noPermission(player, Permission.world)){
|
|
||||||
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
toggle();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ToggleCommand getInstance(Class<? extends ToggleCommand> clazz){
|
|
||||||
return instance.get(clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract String getNoPermMessage();
|
|
||||||
abstract String getEnableMessage();
|
|
||||||
abstract String getDisableMessage();
|
|
||||||
|
|
||||||
public boolean isOn(){
|
|
||||||
return enabled.get(getClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggle(){
|
|
||||||
enabled.compute(getClass(), (clazz, value) -> !value);
|
|
||||||
if(enabled.get(getClass())){
|
|
||||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(getEnableMessage())));
|
|
||||||
}else{
|
|
||||||
HandlerList.unregisterAll(this);
|
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(getDisableMessage())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
132
BauSystem_Main/src/de/steamwar/bausystem/gui/GuiTraceShow.java
Normale Datei
132
BauSystem_Main/src/de/steamwar/bausystem/gui/GuiTraceShow.java
Normale Datei
@ -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.gui;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.tracer.TNTTracer_12;
|
||||||
|
import de.steamwar.bausystem.tracer.TNTTracer_15;
|
||||||
|
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
|
||||||
|
import de.steamwar.bausystem.tracer.show.TraceShowManager;
|
||||||
|
import de.steamwar.bausystem.tracer.show.mode.EntityShowMode;
|
||||||
|
import de.steamwar.core.VersionedCallable;
|
||||||
|
import de.steamwar.inventory.SWInventory;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class GuiTraceShow {
|
||||||
|
|
||||||
|
private static final Map<Player, ShowModeParameter> ShowModeParameterMap = new HashMap<>();
|
||||||
|
|
||||||
|
private GuiTraceShow() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void openGui(Player player) {
|
||||||
|
ShowModeParameter playerShowMode = new ShowModeParameter();
|
||||||
|
playerShowMode.setInterpolate_Y(false);
|
||||||
|
playerShowMode.setInterpolate_XZ(false);
|
||||||
|
ShowModeParameterMap.put(player, playerShowMode);
|
||||||
|
|
||||||
|
SWInventory swInventory = new SWInventory(player, 9, "Trace Show GUI");
|
||||||
|
swInventory.addCloseCallback(clickType -> ShowModeParameterMap.remove(player));
|
||||||
|
setActiveShow(player, swInventory);
|
||||||
|
|
||||||
|
SWItem water = new SWItem(Material.TNT, "§eWasser §7Positionen", Arrays.asList("§7Zeigt alles TNT, welches", "§7im Wasser explodiert ist."), false, clickType -> {});
|
||||||
|
swInventory.setItem(5, water);
|
||||||
|
swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, water));
|
||||||
|
|
||||||
|
SWItem interpolateY = new SWItem(Material.QUARTZ_STAIRS, "§eInterpolation §7Y-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der Y-Achse."), false, clickType -> {});
|
||||||
|
swInventory.setItem(6, interpolateY);
|
||||||
|
swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, interpolateY));
|
||||||
|
|
||||||
|
Material xzMaterial = VersionedCallable.call(new VersionedCallable<>(TNTTracer_12::getTraceXZMaterial, 8), new VersionedCallable<>(TNTTracer_15::getTraceXZMaterial, 14));
|
||||||
|
SWItem interpolateXZ = new SWItem(xzMaterial, (byte) 7, "§eInterpolation §7XZ-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der XZ-Achse."), false, clickType -> {});
|
||||||
|
swInventory.setItem(7, interpolateXZ);
|
||||||
|
swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, interpolateXZ));
|
||||||
|
// Water Bucket (-water)
|
||||||
|
// TNT (-water-exploded)
|
||||||
|
// Quartz_Stair (-interpolate-y)
|
||||||
|
// Quartz_Slab (-interpolate-xz)
|
||||||
|
swInventory.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setActiveShow(Player player, SWInventory swInventory) {
|
||||||
|
if (TraceShowManager.hasActiveShow(player)) {
|
||||||
|
Material showMaterial = VersionedCallable.call(new VersionedCallable<>(TNTTracer_12::getTraceShowMaterial, 8), new VersionedCallable<>(TNTTracer_15::getTraceShowMaterial, 14));
|
||||||
|
SWItem shown = new SWItem(showMaterial, (byte) 5, "§aTraces angezeigt", new ArrayList<>(), false, clickType -> {
|
||||||
|
TraceShowManager.hide(player);
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen ausgeblendet");
|
||||||
|
setActiveShow(player, swInventory);
|
||||||
|
});
|
||||||
|
swInventory.setItem(1, shown);
|
||||||
|
} else {
|
||||||
|
Material hideMaterial = VersionedCallable.call(new VersionedCallable<>(TNTTracer_12::getTraceHideMaterial, 8), new VersionedCallable<>(TNTTracer_15::getTraceHideMaterial, 14));
|
||||||
|
SWItem hidden = new SWItem(hideMaterial, (byte) 14, "§cTraces ausgeblendet", new ArrayList<>(), false, clickType -> {
|
||||||
|
show(player);
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
|
||||||
|
setActiveShow(player, swInventory);
|
||||||
|
});
|
||||||
|
swInventory.setItem(1, hidden);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void toggleHideTNTinWaterExploded(Player player, SWInventory swInventory, SWItem swItem) {
|
||||||
|
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
|
||||||
|
showModeParameter.setWater(!showModeParameter.isWater());
|
||||||
|
show(player);
|
||||||
|
|
||||||
|
swItem.setEnchanted(showModeParameter.isWater());
|
||||||
|
swInventory.setItem(5, swItem);
|
||||||
|
swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, swItem));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void toggleInterpolateYPosition(Player player, SWInventory swInventory, SWItem swItem) {
|
||||||
|
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
|
||||||
|
showModeParameter.setInterpolate_Y(!showModeParameter.isInterpolate_Y());
|
||||||
|
show(player);
|
||||||
|
|
||||||
|
swItem.setEnchanted(showModeParameter.isInterpolate_Y());
|
||||||
|
swInventory.setItem(6, swItem);
|
||||||
|
swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, swItem));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void toggleInterpolateXZPosition(Player player, SWInventory swInventory, SWItem swItem) {
|
||||||
|
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
|
||||||
|
showModeParameter.setInterpolate_XZ(!showModeParameter.isInterpolate_XZ());
|
||||||
|
show(player);
|
||||||
|
|
||||||
|
swItem.setEnchanted(showModeParameter.isInterpolate_XZ());
|
||||||
|
swInventory.setItem(7, swItem);
|
||||||
|
swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, swItem));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void show(Player player) {
|
||||||
|
TraceShowManager.show(player, new EntityShowMode(player, ShowModeParameterMap.get(player)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -24,9 +24,8 @@ package de.steamwar.bausystem.tracer.show;
|
|||||||
public class ShowModeParameter {
|
public class ShowModeParameter {
|
||||||
|
|
||||||
private boolean water = false;
|
private boolean water = false;
|
||||||
private boolean interpolate_SET = false;
|
private boolean interpolate_Y = false;
|
||||||
private boolean interpolate_Y = true;
|
private boolean interpolate_XZ = false;
|
||||||
private boolean interpolate_XZ = true;
|
|
||||||
|
|
||||||
public ShowModeParameter() {
|
public ShowModeParameter() {
|
||||||
|
|
||||||
@ -44,6 +43,22 @@ public class ShowModeParameter {
|
|||||||
return interpolate_XZ;
|
return interpolate_XZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setWater(boolean water) {
|
||||||
|
this.water = water;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterpolate_Y(boolean interpolate_Y) {
|
||||||
|
this.interpolate_Y = interpolate_Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterpolate_XZ(boolean interpolate_XZ) {
|
||||||
|
this.interpolate_XZ = interpolate_XZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAdvanced() {
|
||||||
|
return interpolate_Y || interpolate_XZ;
|
||||||
|
}
|
||||||
|
|
||||||
public static ShowModeParameter parseArguments(String[] args, int index) {
|
public static ShowModeParameter parseArguments(String[] args, int index) {
|
||||||
ShowModeParameter showModeParameter = new ShowModeParameter();
|
ShowModeParameter showModeParameter = new ShowModeParameter();
|
||||||
for (int i = index; i < args.length; i++) {
|
for (int i = index; i < args.length; i++) {
|
||||||
@ -55,12 +70,7 @@ public class ShowModeParameter {
|
|||||||
case "-interpolate-y":
|
case "-interpolate-y":
|
||||||
case "-interpolate_y":
|
case "-interpolate_y":
|
||||||
case "-y":
|
case "-y":
|
||||||
if (showModeParameter.interpolate_SET) {
|
|
||||||
showModeParameter.interpolate_Y = true;
|
showModeParameter.interpolate_Y = true;
|
||||||
} else {
|
|
||||||
showModeParameter.interpolate_XZ = false;
|
|
||||||
showModeParameter.interpolate_SET = true;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case "-interpolatex":
|
case "-interpolatex":
|
||||||
case "-interpolate-x":
|
case "-interpolate-x":
|
||||||
@ -74,12 +84,15 @@ public class ShowModeParameter {
|
|||||||
case "-interpolate-xz":
|
case "-interpolate-xz":
|
||||||
case "-interpolate_xz":
|
case "-interpolate_xz":
|
||||||
case "-xz":
|
case "-xz":
|
||||||
if (showModeParameter.interpolate_SET) {
|
|
||||||
showModeParameter.interpolate_XZ = true;
|
showModeParameter.interpolate_XZ = true;
|
||||||
} else {
|
break;
|
||||||
showModeParameter.interpolate_Y = false;
|
case "advanced":
|
||||||
showModeParameter.interpolate_SET = true;
|
case "-advanced":
|
||||||
}
|
case "-a":
|
||||||
|
showModeParameter.interpolate_Y = true;
|
||||||
|
showModeParameter.interpolate_XZ = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,4 +51,9 @@ public class TraceShowManager implements Listener {
|
|||||||
public void onLeave(PlayerQuitEvent event) {
|
public void onLeave(PlayerQuitEvent event) {
|
||||||
showModes.remove(event.getPlayer());
|
showModes.remove(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasActiveShow(Player player) {
|
||||||
|
return showModes.containsKey(player);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
* /
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.bausystem.tracer.show.mode;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.tracer.AbstractTraceEntity;
|
|
||||||
import de.steamwar.bausystem.tracer.RoundedTNTPosition;
|
|
||||||
import de.steamwar.bausystem.tracer.TNTPosition;
|
|
||||||
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Consumer;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Advanced extends Basic {
|
|
||||||
|
|
||||||
private final Map<RoundedTNTPosition, AbstractTraceEntity> updateEntityMap = new HashMap<>();
|
|
||||||
|
|
||||||
public Advanced(Player player, ShowModeParameter showModeParameter) {
|
|
||||||
super(player, showModeParameter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show(TNTPosition position) {
|
|
||||||
super.show(position);
|
|
||||||
|
|
||||||
if (!showModeParameter.isWater() && position.isExploded() && checkWater(position.getLocation())) {
|
|
||||||
for(TNTPosition pos : position.getRecord().getPositions()){
|
|
||||||
applyOnPosition(pos, updatePointPosition ->
|
|
||||||
updateEntityMap.computeIfPresent(new RoundedTNTPosition(updatePointPosition), (p, point) -> point.hide(player, false) ? null : point));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
applyOnPosition(position, updatePointPosition ->
|
|
||||||
updateEntityMap.computeIfAbsent(new RoundedTNTPosition(updatePointPosition), pos -> createEntity(updatePointPosition, false))
|
|
||||||
.display(player, position.isExploded()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
super.hide();
|
|
||||||
updateEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true));
|
|
||||||
updateEntityMap.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void applyOnPosition(TNTPosition position, Consumer<Vector> function){
|
|
||||||
if (position.getPreviousLocation() == null) return;
|
|
||||||
|
|
||||||
if (showModeParameter.isInterpolate_Y()) {
|
|
||||||
Vector updatePointY = position.getPreviousLocation().clone().setY(position.getLocation().getY());
|
|
||||||
if(!position.getLocation().equals(updatePointY))
|
|
||||||
function.accept(updatePointY);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showModeParameter.isInterpolate_XZ()){
|
|
||||||
Vector movement = position.getLocation().clone().subtract(position.getPreviousLocation());
|
|
||||||
Vector updatePointXZ = Math.abs(movement.getX()) > Math.abs(movement.getZ())
|
|
||||||
? position.getLocation().clone().setZ(position.getPreviousLocation().getZ())
|
|
||||||
: position.getLocation().clone().setX(position.getPreviousLocation().getX());
|
|
||||||
if(!position.getLocation().equals(updatePointXZ))
|
|
||||||
function.accept(updatePointXZ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
package de.steamwar.bausystem.tracer.show.mode;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.tracer.*;
|
|
||||||
import de.steamwar.bausystem.tracer.show.ShowMode;
|
|
||||||
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
|
|
||||||
import de.steamwar.core.VersionedCallable;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Basic implements ShowMode {
|
|
||||||
|
|
||||||
protected final Player player;
|
|
||||||
protected final ShowModeParameter showModeParameter;
|
|
||||||
|
|
||||||
private final Map<RoundedTNTPosition, AbstractTraceEntity> tntEntityMap = new HashMap<>();
|
|
||||||
|
|
||||||
public Basic(Player player, ShowModeParameter showModeParameter) {
|
|
||||||
this.player = player;
|
|
||||||
this.showModeParameter = showModeParameter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show(TNTPosition position) {
|
|
||||||
if (!showModeParameter.isWater() && position.isExploded() && checkWater(position.getLocation())) {
|
|
||||||
for(TNTPosition pos : position.getRecord().getPositions()){
|
|
||||||
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(pos);
|
|
||||||
tntEntityMap.computeIfPresent(roundedTNTPosition, (p, tnt) -> tnt.hide(player, false) ? null : tnt);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(position);
|
|
||||||
AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedTNTPosition, pos -> createEntity(position.getLocation(), true));
|
|
||||||
entity.display(player, position.isExploded());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean checkWater(Vector position) {
|
|
||||||
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.inWater(player.getWorld(), position), 8),
|
|
||||||
new VersionedCallable<>(() -> TNTTracer_15.inWater(player.getWorld(), position), 14));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected AbstractTraceEntity createEntity(Vector position, boolean tnt) {
|
|
||||||
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.create(player.getWorld(), position, tnt), 8),
|
|
||||||
new VersionedCallable<>(() -> TNTTracer_15.create(player.getWorld(), position, tnt), 14));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hide() {
|
|
||||||
tntEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true));
|
|
||||||
tntEntityMap.clear();
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* 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.tracer.show.mode;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.tracer.*;
|
||||||
|
import de.steamwar.bausystem.tracer.show.ShowMode;
|
||||||
|
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
|
||||||
|
import de.steamwar.core.VersionedCallable;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Consumer;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class EntityShowMode implements ShowMode {
|
||||||
|
|
||||||
|
protected final Player player;
|
||||||
|
protected final ShowModeParameter showModeParameter;
|
||||||
|
|
||||||
|
private final Map<RoundedTNTPosition, AbstractTraceEntity> tntEntityMap = new HashMap<>();
|
||||||
|
private final Map<RoundedTNTPosition, AbstractTraceEntity> updateEntityMap = new HashMap<>();
|
||||||
|
|
||||||
|
public EntityShowMode(Player player, ShowModeParameter showModeParameter) {
|
||||||
|
this.player = player;
|
||||||
|
this.showModeParameter = showModeParameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void show(TNTPosition position) {
|
||||||
|
if (!showModeParameter.isWater() && position.isExploded() && checkWater(position.getLocation())) {
|
||||||
|
// Basic
|
||||||
|
for (TNTPosition pos : position.getRecord().getPositions()) {
|
||||||
|
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(pos);
|
||||||
|
tntEntityMap.computeIfPresent(roundedTNTPosition, (p, tnt) -> {
|
||||||
|
return tnt.hide(player, false) ? null : tnt;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Advanced
|
||||||
|
for (TNTPosition pos : position.getRecord().getPositions()) {
|
||||||
|
applyOnPosition(pos, updatePointPosition -> {
|
||||||
|
updateEntityMap.computeIfPresent(new RoundedTNTPosition(updatePointPosition), (p, point) -> {
|
||||||
|
return point.hide(player, false) ? null : point;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(position);
|
||||||
|
AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedTNTPosition, pos -> createEntity(position.getLocation(), true));
|
||||||
|
entity.display(player, position.isExploded());
|
||||||
|
|
||||||
|
applyOnPosition(position, updatePointPosition -> {
|
||||||
|
updateEntityMap.computeIfAbsent(new RoundedTNTPosition(updatePointPosition), pos -> {
|
||||||
|
return createEntity(updatePointPosition, false);
|
||||||
|
}).display(player, position.isExploded());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkWater(Vector position) {
|
||||||
|
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.inWater(player.getWorld(), position), 8),
|
||||||
|
new VersionedCallable<>(() -> TNTTracer_15.inWater(player.getWorld(), position), 14));
|
||||||
|
}
|
||||||
|
|
||||||
|
private AbstractTraceEntity createEntity(Vector position, boolean tnt) {
|
||||||
|
return VersionedCallable.call(new VersionedCallable<>(() -> TNTTracer_12.create(player.getWorld(), position, tnt), 8),
|
||||||
|
new VersionedCallable<>(() -> TNTTracer_15.create(player.getWorld(), position, tnt), 14));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyOnPosition(TNTPosition position, Consumer<Vector> function) {
|
||||||
|
if (position.getPreviousLocation() == null) return;
|
||||||
|
|
||||||
|
if (showModeParameter.isInterpolate_Y()) {
|
||||||
|
Vector updatePointY = position.getPreviousLocation().clone().setY(position.getLocation().getY());
|
||||||
|
if (!position.getLocation().equals(updatePointY)) {
|
||||||
|
function.accept(updatePointY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showModeParameter.isInterpolate_XZ()) {
|
||||||
|
Vector movement = position.getLocation().clone().subtract(position.getPreviousLocation());
|
||||||
|
Vector updatePointXZ = Math.abs(movement.getX()) > Math.abs(movement.getZ())
|
||||||
|
? position.getLocation().clone().setZ(position.getPreviousLocation().getZ())
|
||||||
|
: position.getLocation().clone().setX(position.getPreviousLocation().getX());
|
||||||
|
if (!position.getLocation().equals(updatePointXZ)) {
|
||||||
|
function.accept(updatePointXZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void hide() {
|
||||||
|
tntEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true));
|
||||||
|
tntEntityMap.clear();
|
||||||
|
updateEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true));
|
||||||
|
updateEntityMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import de.steamwar.core.VersionedCallable;
|
import de.steamwar.core.VersionedCallable;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -225,12 +224,8 @@ public class AutoLoader extends IAutoLoader implements Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean setRedstone(Location location, boolean active){
|
boolean setRedstone(Location location, boolean active){
|
||||||
switch(Core.getVersion()){
|
return VersionedCallable.call(new VersionedCallable<>(() -> AutoLoader_12.setRedstone(location, active), 8),
|
||||||
case 15:
|
new VersionedCallable<>(() -> AutoLoader_15.setRedstone(location, active), 15));
|
||||||
return AutoLoader_15.setRedstone(location, active);
|
|
||||||
default:
|
|
||||||
return AutoLoader_12.setRedstone(location, active);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -256,12 +251,8 @@ public class AutoLoader extends IAutoLoader implements Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean perform() {
|
public boolean perform() {
|
||||||
switch(Core.getVersion()){
|
return VersionedCallable.call(new VersionedCallable<>(() -> AutoLoader_12.tntPlaceActionPerform(location), 8),
|
||||||
case 15:
|
new VersionedCallable<>(() -> AutoLoader_15.tntPlaceActionPerform(location), 15));
|
||||||
return AutoLoader_15.tntPlaceActionPerform(location);
|
|
||||||
default:
|
|
||||||
return AutoLoader_12.tntPlaceActionPerform(location);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
import de.steamwar.bausystem.commands.CommandFreeze;
|
|
||||||
import de.steamwar.bausystem.commands.CommandTNT;
|
|
||||||
import de.steamwar.bausystem.commands.CommandTPSLimiter;
|
import de.steamwar.bausystem.commands.CommandTPSLimiter;
|
||||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||||
import de.steamwar.core.TPSWatcher;
|
import de.steamwar.core.TPSWatcher;
|
||||||
@ -61,8 +59,10 @@ public class BauScoreboard implements Listener {
|
|||||||
strings.add("§1");
|
strings.add("§1");
|
||||||
strings.add("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()));
|
strings.add("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()));
|
||||||
strings.add("§2");
|
strings.add("§2");
|
||||||
strings.add("§eTNT§8: " + (!CommandTNT.getInstance().isOn() ? "§aan" : "§caus"));
|
Region region = Region.getRegion(p.getLocation());
|
||||||
strings.add("§eFreeze§8: " + (CommandFreeze.getInstance().isOn() ? "§aan" : "§caus"));
|
strings.add("§eTNT§8: " + region.getTntMode().getName());
|
||||||
|
strings.add("§eFreeze§8: " + (region.isFreeze() ? "§aan" : "§caus"));
|
||||||
|
strings.add("§eFire§8: " + (region.isFire() ? "§aaus" : "§can"));
|
||||||
strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName());
|
strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName());
|
||||||
strings.add("§eLoader§8: " + (AutoLoader.hasLoader(p) ? "§aan" : "§caus"));
|
strings.add("§eLoader§8: " + (AutoLoader.hasLoader(p) ? "§aan" : "§caus"));
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public class BauScoreboard implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
strings.add("§4");
|
strings.add("§4");
|
||||||
strings.add("§eTPS§8: " + tpsColor() + TPSWatcher.getTPS() + tpsLimit());
|
strings.add("§eTPS§8: " + tpsColor() + TPSUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit());
|
||||||
|
|
||||||
int i = strings.size();
|
int i = strings.size();
|
||||||
HashMap<String, Integer> result = new HashMap<>();
|
HashMap<String, Integer> result = new HashMap<>();
|
||||||
@ -87,7 +87,7 @@ public class BauScoreboard implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String tpsColor() {
|
private String tpsColor() {
|
||||||
double tps = TPSWatcher.getTPS();
|
double tps = TPSUtils.getTps(TPSWatcher.TPSType.ONE_SECOND);
|
||||||
if (tps > CommandTPSLimiter.getCurrentTPSLimit() * 0.9) {
|
if (tps > CommandTPSLimiter.getCurrentTPSLimit() * 0.9) {
|
||||||
return "§a";
|
return "§a";
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ public class Detonator implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation()));
|
locs.add(new Detoloader.DetonatorActivation(detoloader.getActivation(), event.getClickedBlock().getLocation()));
|
||||||
}
|
}
|
||||||
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " getsetzt" :
|
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " gesetzt" :
|
||||||
detoloader.getBlock(), detoloader.addBack);
|
detoloader.getBlock(), detoloader.addBack);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.bausystem.commands.CommandTNT.TNTMode;
|
||||||
|
import de.steamwar.core.VersionedRunnable;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -32,11 +33,13 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Region {
|
public class Region {
|
||||||
|
|
||||||
private static final List<Region> regions = new ArrayList<>();
|
private static final List<Region> regions = new ArrayList<>();
|
||||||
|
private static boolean buildArea = false;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
@ -59,27 +62,110 @@ public class Region {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Region> getRegions(){
|
public static boolean buildAreaEnabled() {
|
||||||
return regions;
|
return buildArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Region getRegion(Location location) {
|
||||||
|
for (Region region : regions) {
|
||||||
|
if (region.inRegion(location)) return region;
|
||||||
|
}
|
||||||
|
return GlobalRegion.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String name;
|
||||||
private final int minX;
|
private final int minX;
|
||||||
private final int minY;
|
private final int minY;
|
||||||
private final int minZ;
|
private final int minZ;
|
||||||
private final Prototype prototype;
|
private final Prototype prototype;
|
||||||
|
private final String optionsLinkedWith; // nullable
|
||||||
|
private Region linkedRegion = null; // nullable
|
||||||
|
|
||||||
|
private TNTMode tntMode = Region.buildAreaEnabled() ? TNTMode.ONLY_TB : TNTMode.OFF;
|
||||||
|
private boolean freeze = false;
|
||||||
|
private boolean fire = false;
|
||||||
|
|
||||||
private Region(ConfigurationSection config){
|
private Region(ConfigurationSection config){
|
||||||
|
name = config.getName();
|
||||||
minX = config.getInt("minX");
|
minX = config.getInt("minX");
|
||||||
minY = config.getInt("minY");
|
minY = config.getInt("minY");
|
||||||
minZ = config.getInt("minZ");
|
minZ = config.getInt("minZ");
|
||||||
prototype = Prototype.prototypes.get(config.getString("prototype"));
|
prototype = Prototype.prototypes.get(config.getString("prototype"));
|
||||||
|
optionsLinkedWith = config.getString("optionsLinkedWith", null);
|
||||||
|
if (!hasTestblock()) tntMode = TNTMode.OFF;
|
||||||
regions.add(this);
|
regions.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Region(String name) {
|
||||||
|
this.name = name;
|
||||||
|
this.minX = 0;
|
||||||
|
this.minY = 0;
|
||||||
|
this.minZ = 0;
|
||||||
|
this.prototype = null;
|
||||||
|
this.optionsLinkedWith = null;
|
||||||
|
tntMode = TNTMode.OFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLinkedRegion(Consumer<Region> regionConsumer) {
|
||||||
|
if (optionsLinkedWith == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (linkedRegion != null) {
|
||||||
|
regionConsumer.accept(linkedRegion);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Region region : regions) {
|
||||||
|
if (region.name.equals(name)) {
|
||||||
|
linkedRegion = region;
|
||||||
|
regionConsumer.accept(linkedRegion);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TNTMode getTntMode() {
|
||||||
|
return tntMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTntMode(TNTMode tntMode) {
|
||||||
|
this.tntMode = tntMode;
|
||||||
|
setLinkedRegion(region -> region.tntMode = tntMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFreeze() {
|
||||||
|
return freeze;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFreeze(boolean freeze) {
|
||||||
|
this.freeze = freeze;
|
||||||
|
setLinkedRegion(region -> region.freeze = freeze);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFire() {
|
||||||
|
return fire;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFire(boolean fire) {
|
||||||
|
this.fire = fire;
|
||||||
|
setLinkedRegion(region -> region.fire = fire);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean inRegion(Location l){
|
public boolean inRegion(Location l){
|
||||||
return prototype.inRegion(this, l);
|
return prototype.inRegion(this, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasBuildRegion() {
|
||||||
|
return prototype.buildArea != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inBuildRegion(Location l) {
|
||||||
|
return prototype.buildArea.inRegion(this, l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inBuildRegionExtension(Location l) {
|
||||||
|
return prototype.buildArea.inRegionExtension(this, l);
|
||||||
|
}
|
||||||
|
|
||||||
public void fastreset(){
|
public void fastreset(){
|
||||||
prototype.fastreset(this);
|
prototype.fastreset(this);
|
||||||
}
|
}
|
||||||
@ -104,8 +190,45 @@ public class Region {
|
|||||||
prototype.protect(this, schem);
|
prototype.protect(this, schem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class GlobalRegion extends Region {
|
||||||
|
|
||||||
|
private static final GlobalRegion GLOBAL_REGION = new GlobalRegion();
|
||||||
|
|
||||||
|
public static GlobalRegion getInstance() {
|
||||||
|
return GLOBAL_REGION;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isGlobalRegion(Region region) {
|
||||||
|
return region == GLOBAL_REGION;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GlobalRegion() {
|
||||||
|
super("Global");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean inRegion(Location l) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasBuildRegion() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasTestblock() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasProtection() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static class Prototype{
|
public static class Prototype{
|
||||||
private static final String SECTION_PATH = "/home/minecraft/backbone/server/UserBau/";
|
|
||||||
private static final Map<String, Prototype> prototypes = new HashMap<>();
|
private static final Map<String, Prototype> prototypes = new HashMap<>();
|
||||||
|
|
||||||
private final int sizeX;
|
private final int sizeX;
|
||||||
@ -116,10 +239,17 @@ public class Region {
|
|||||||
private final int offsetY;
|
private final int offsetY;
|
||||||
private final int offsetZ;
|
private final int offsetZ;
|
||||||
|
|
||||||
|
private final int extensionPositiveZ;
|
||||||
|
private final int extensionNegativeZ;
|
||||||
|
private final int extensionPositiveY;
|
||||||
|
private final int extensionAxisX;
|
||||||
|
|
||||||
private final String schematic;
|
private final String schematic;
|
||||||
private final boolean rotate;
|
private final boolean rotate;
|
||||||
|
|
||||||
private final Prototype testblock; //nullable
|
private final Prototype testblock; //nullable
|
||||||
|
private final Prototype buildArea; //nullable
|
||||||
|
|
||||||
private final String protectSchematic; //nullable
|
private final String protectSchematic; //nullable
|
||||||
|
|
||||||
private Prototype(ConfigurationSection config){
|
private Prototype(ConfigurationSection config){
|
||||||
@ -130,35 +260,46 @@ public class Region {
|
|||||||
offsetX = config.getInt("offsetX", 0);
|
offsetX = config.getInt("offsetX", 0);
|
||||||
offsetY = config.getInt("offsetY", 0);
|
offsetY = config.getInt("offsetY", 0);
|
||||||
offsetZ = config.getInt("offsetZ", 0);
|
offsetZ = config.getInt("offsetZ", 0);
|
||||||
|
extensionPositiveZ = config.getInt("extensionPositiveZ", 0);
|
||||||
|
extensionNegativeZ = config.getInt("extensionNegativeZ", 0);
|
||||||
|
extensionPositiveY = config.getInt("extensionPositiveY", 0);
|
||||||
|
extensionAxisX = config.getInt("extensionAxisX", 0);
|
||||||
rotate = config.getBoolean("rotate", false);
|
rotate = config.getBoolean("rotate", false);
|
||||||
|
|
||||||
ConfigurationSection testblockSection = config.getConfigurationSection("testblock");
|
ConfigurationSection testblockSection = config.getConfigurationSection("testblock");
|
||||||
testblock = testblockSection != null ? new Prototype(testblockSection) : null;
|
testblock = testblockSection != null ? new Prototype(testblockSection) : null;
|
||||||
|
|
||||||
|
ConfigurationSection buildAreaSection = config.getConfigurationSection("buildArea");
|
||||||
|
buildArea = buildAreaSection != null ? new Prototype(buildAreaSection) : null;
|
||||||
|
if (buildArea != null) {
|
||||||
|
Region.buildArea = true;
|
||||||
|
}
|
||||||
|
|
||||||
protectSchematic = config.getString("protection", null);
|
protectSchematic = config.getString("protection", null);
|
||||||
|
|
||||||
if(!config.getName().equals("testblock"))
|
if(!config.getName().equals("testblock") && !config.getName().equals("buildArea"))
|
||||||
prototypes.put(config.getName(), this);
|
prototypes.put(config.getName(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inRegion(Region region, Location l){
|
public boolean inRegion(Region region, Location l){
|
||||||
return inRange(l.getX(), region.minX + offsetX, sizeX + offsetX) &&
|
return inRange(l.getX(), region.minX + offsetX, sizeX) &&
|
||||||
inRange(l.getY(), region.minY + offsetY, sizeY + offsetY) &&
|
inRange(l.getY(), region.minY + offsetY, sizeY) &&
|
||||||
inRange(l.getZ(), region.minZ + offsetZ, sizeZ + offsetZ);
|
inRange(l.getZ(), region.minZ + offsetZ, sizeZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inRegionExtension(Region region, Location l) {
|
||||||
|
return inRange(l.getX(), region.minX + offsetX - extensionAxisX + 1, sizeX + extensionAxisX * 2 - 1) &&
|
||||||
|
inRange(l.getY(), region.minY + offsetY, sizeY + extensionPositiveY - 1) &&
|
||||||
|
inRange(l.getZ(), region.minZ + offsetZ - extensionNegativeZ + 1, sizeZ + extensionNegativeZ - 1 + extensionPositiveZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fastreset(Region region){
|
public void fastreset(Region region){
|
||||||
File file = new File(SECTION_PATH + schematic);
|
File file = new File(schematic);
|
||||||
int x = region.minX + offsetX + sizeX/2;
|
int x = region.minX + offsetX + sizeX/2;
|
||||||
int y = region.minY + offsetY;
|
int y = region.minY + offsetY;
|
||||||
int z = region.minZ + offsetZ + sizeZ/2;
|
int z = region.minZ + offsetZ + sizeZ/2;
|
||||||
switch(Core.getVersion()){
|
VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(file, x, y, z, rotate), 8),
|
||||||
case 12:
|
new VersionedRunnable(() -> Region_15.fastpaste(file, x, y, z, rotate), 15));
|
||||||
Region_12.paste(file, x, y, z, rotate);
|
|
||||||
break;
|
|
||||||
case 15:
|
|
||||||
default:
|
|
||||||
Region_15.fastpaste(file, x, y, z, rotate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(Region region, Schematic schem) throws IOException, NoClipboardException {
|
public void reset(Region region, Schematic schem) throws IOException, NoClipboardException {
|
||||||
@ -166,7 +307,7 @@ public class Region {
|
|||||||
int y = region.minY + offsetY;
|
int y = region.minY + offsetY;
|
||||||
int z = region.minZ + offsetZ + sizeZ / 2;
|
int z = region.minZ + offsetZ + sizeZ / 2;
|
||||||
if(schem == null)
|
if(schem == null)
|
||||||
paste(new File(SECTION_PATH + schematic), x, y, z, rotate);
|
paste(new File(schematic), x, y, z, rotate);
|
||||||
else
|
else
|
||||||
paste(schem.load(), x, y, z, rotate);
|
paste(schem.load(), x, y, z, rotate);
|
||||||
}
|
}
|
||||||
@ -180,7 +321,7 @@ public class Region {
|
|||||||
int y = region.minY + testblock.offsetY - 1;
|
int y = region.minY + testblock.offsetY - 1;
|
||||||
int z = region.minZ + offsetZ + sizeZ / 2;
|
int z = region.minZ + offsetZ + sizeZ / 2;
|
||||||
if(schem == null)
|
if(schem == null)
|
||||||
paste(new File(SECTION_PATH + protectSchematic), x, y, z, rotate);
|
paste(new File(protectSchematic), x, y, z, rotate);
|
||||||
else
|
else
|
||||||
paste(schem.load(), x, y, z, rotate);
|
paste(schem.load(), x, y, z, rotate);
|
||||||
}
|
}
|
||||||
@ -198,25 +339,13 @@ public class Region {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void paste(File file, int x, int y, int z, boolean rotate){ //Type of protect
|
private static void paste(File file, int x, int y, int z, boolean rotate){ //Type of protect
|
||||||
switch(Core.getVersion()){
|
VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(file, x, y, z, rotate), 8),
|
||||||
case 12:
|
new VersionedRunnable(() -> Region_15.paste(file, x, y, z, rotate), 15));
|
||||||
Region_12.paste(file, x, y, z, rotate);
|
|
||||||
break;
|
|
||||||
case 15:
|
|
||||||
default:
|
|
||||||
Region_15.paste(file, x, y, z, rotate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){
|
private static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){
|
||||||
switch(Core.getVersion()){
|
VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(clipboard, x, y, z, rotate), 8),
|
||||||
case 12:
|
new VersionedRunnable(() -> Region_15.paste(clipboard, x, y, z, rotate), 15));
|
||||||
Region_12.paste(clipboard, x, y, z, rotate);
|
|
||||||
break;
|
|
||||||
case 15:
|
|
||||||
default:
|
|
||||||
Region_15.paste(clipboard, x, y, z, rotate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,18 +20,29 @@
|
|||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.core.VersionedCallable;
|
||||||
|
import de.steamwar.core.VersionedRunnable;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.*;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
public class RegionListener implements Listener {
|
public class RegionListener implements Listener {
|
||||||
|
|
||||||
@ -59,9 +70,25 @@ public class RegionListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onBlockPlace(BlockPlaceEvent e) {
|
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||||
Player p = e.getPlayer();
|
if (Core.getVersion() == 12) return;
|
||||||
|
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
try{
|
||||||
|
if (Welt.noPermission(p, Permission.build)){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren");
|
||||||
|
e.setBuildable(false);
|
||||||
|
}
|
||||||
|
}catch(NullPointerException ex){
|
||||||
|
//ignored, caused by worldedit brushes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent e) {
|
||||||
|
if (Core.getVersion() == 15) return;
|
||||||
|
|
||||||
|
Player p = e.getPlayer();
|
||||||
try{
|
try{
|
||||||
if (Welt.noPermission(p, Permission.build)){
|
if (Welt.noPermission(p, Permission.build)){
|
||||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren");
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren");
|
||||||
@ -79,13 +106,8 @@ public class RegionListener implements Listener {
|
|||||||
if(command.startsWith(shortcut))
|
if(command.startsWith(shortcut))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
switch(Core.getVersion()){
|
return VersionedCallable.call(new VersionedCallable<>(() -> RegionListener_12.isWorldEditCommand(command), 8),
|
||||||
case 12:
|
new VersionedCallable<>(() -> RegionListener_15.isWorldEditCommand(command), 15));
|
||||||
return RegionListener_12.isWorldEditCommand(command);
|
|
||||||
case 15:
|
|
||||||
default:
|
|
||||||
return RegionListener_15.isWorldEditCommand(command);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -98,4 +120,49 @@ public class RegionListener implements Listener {
|
|||||||
event.setLine(i, line);
|
event.setLine(i, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void editSign(PlayerInteractEvent event) {
|
||||||
|
if(event.getAction() != Action.RIGHT_CLICK_BLOCK ||
|
||||||
|
!event.getClickedBlock().getType().name().contains("SIGN") ||
|
||||||
|
!event.getPlayer().isSneaking() ||
|
||||||
|
(event.getItem() != null && event.getItem().getType() != Material.AIR))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Sign sign = (Sign) event.getClickedBlock().getState();
|
||||||
|
String[] lines = sign.getLines();
|
||||||
|
for (int i = 0; i < lines.length; i++) {
|
||||||
|
sign.setLine(i, lines[i].replace('§', '&'));
|
||||||
|
}
|
||||||
|
sign.update();
|
||||||
|
|
||||||
|
VersionedRunnable.call(new VersionedRunnable(() -> RegionListener_12.openSignEditor(player, event.getClickedBlock().getLocation()), 12),
|
||||||
|
new VersionedRunnable(() -> RegionListener_15.openSignEditor(player, event.getClickedBlock().getLocation()), 15));
|
||||||
|
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(BauSystem.getPlugin(), PacketType.Play.Client.UPDATE_SIGN) {
|
||||||
|
@Override
|
||||||
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
|
if(!event.getPlayer().equals(player))
|
||||||
|
return;
|
||||||
|
Bukkit.getScheduler().runTask(BauSystem.getPlugin(), () -> {
|
||||||
|
PacketContainer packetContainer = event.getPacket();
|
||||||
|
BlockPosition position = packetContainer.getBlockPositionModifier().read(0);
|
||||||
|
String[] lines = packetContainer.getStringArrays().read(0);
|
||||||
|
|
||||||
|
Block signLoc = position.toLocation(player.getWorld()).getBlock();
|
||||||
|
if(!signLoc.getType().name().contains("SIGN"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Sign sign = ((Sign) signLoc.getState());
|
||||||
|
for (int i = 0; i < lines.length; i++) {
|
||||||
|
sign.setLine(i, ChatColor.translateAlternateColorCodes('&', lines[i]));
|
||||||
|
}
|
||||||
|
sign.update();
|
||||||
|
|
||||||
|
ProtocolLibrary.getProtocolManager().removePacketListener(this);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,10 @@
|
|||||||
package de.steamwar.bausystem.world;
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.commands.CommandFire;
|
|
||||||
import de.steamwar.bausystem.commands.CommandFreeze;
|
|
||||||
import de.steamwar.bausystem.commands.CommandScript;
|
import de.steamwar.bausystem.commands.CommandScript;
|
||||||
import de.steamwar.bausystem.commands.CommandTNT;
|
import de.steamwar.bausystem.commands.CommandTNT;
|
||||||
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.VersionedCallable;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -55,7 +53,7 @@ public class ScriptListener implements Listener {
|
|||||||
if(item == null || isNoBook(item) || item.getItemMeta() == null)
|
if(item == null || isNoBook(item) || item.getItemMeta() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (CommandScript.BOOK.getItemMeta() != null && item.getItemMeta().getDisplayName().equals(CommandScript.BOOK.getItemMeta().getDisplayName())) {
|
if (CommandScript.BOOK.getItemMeta() != null && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equals(CommandScript.BOOK.getItemMeta().getDisplayName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,13 +72,8 @@ public class ScriptListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isNoBook(ItemStack item){
|
private boolean isNoBook(ItemStack item){
|
||||||
switch(Core.getVersion()){
|
return VersionedCallable.call(new VersionedCallable<>(() -> ScriptListener_12.isNoBook(item), 8),
|
||||||
case 12:
|
new VersionedCallable<>(() -> ScriptListener_15.isNoBook(item), 15));
|
||||||
return ScriptListener_12.isNoBook(item);
|
|
||||||
case 15:
|
|
||||||
default:
|
|
||||||
return ScriptListener_15.isNoBook(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ScriptExecutor {
|
private static class ScriptExecutor {
|
||||||
@ -153,6 +146,8 @@ public class ScriptListener implements Listener {
|
|||||||
index = ifJumpIndex;
|
index = ifJumpIndex;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(player, "/" + command);
|
PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(player, "/" + command);
|
||||||
@ -235,6 +230,8 @@ public class ScriptListener implements Listener {
|
|||||||
case "--":
|
case "--":
|
||||||
add(scriptExecutor, args[0], -1);
|
add(scriptExecutor, args[0], -1);
|
||||||
return;
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
setValue(scriptExecutor, args[0], args[1]);
|
setValue(scriptExecutor, args[0], args[1]);
|
||||||
}
|
}
|
||||||
@ -280,18 +277,20 @@ public class ScriptListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int getValue(ScriptExecutor scriptExecutor, String key) {
|
private static int getValue(ScriptExecutor scriptExecutor, String key) {
|
||||||
|
Region region = Region.getRegion(scriptExecutor.player.getLocation());
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "trace":
|
case "trace":
|
||||||
return RecordStateMachine.getRecordStatus().isTracing() ? 1 : 0;
|
return RecordStateMachine.getRecordStatus().isTracing() ? 1 : 0;
|
||||||
case "tnt":
|
case "tnt":
|
||||||
return CommandTNT.getInstance().isOn() ? 1 : 0;
|
return region == null || region.getTntMode() == CommandTNT.TNTMode.OFF ? 0 : 1;
|
||||||
case "freeze":
|
case "freeze":
|
||||||
return CommandFreeze.getInstance().isOn() ? 1 : 0;
|
return region == null || !region.isFreeze() ? 0 : 1;
|
||||||
case "fire":
|
case "fire":
|
||||||
return CommandFire.getInstance().isOn() ? 1 : 0;
|
return region == null || !region.isFire() ? 0 : 1;
|
||||||
}
|
default:
|
||||||
return scriptExecutor.variables.getOrDefault(key, 0);
|
return scriptExecutor.variables.getOrDefault(key, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isVariable(ScriptExecutor scriptExecutor, String key) {
|
private static boolean isVariable(ScriptExecutor scriptExecutor, String key) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
65
BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java
Normale Datei
65
BauSystem_Main/src/de/steamwar/bausystem/world/TPSUtils.java
Normale Datei
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bausystem.world;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.commands.CommandTPSLimiter;
|
||||||
|
import de.steamwar.core.TPSWatcher;
|
||||||
|
import de.steamwar.core.VersionedRunnable;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
public class TPSUtils {
|
||||||
|
|
||||||
|
private TPSUtils() {
|
||||||
|
throw new IllegalStateException("Utility Class");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean warp = true;
|
||||||
|
private static long nanoOffset = 0;
|
||||||
|
private static long nanoDOffset = 0;
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
VersionedRunnable.call(new VersionedRunnable(() -> warp = false, 8),
|
||||||
|
new VersionedRunnable(() -> {
|
||||||
|
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> nanoOffset += nanoDOffset, 1, 1);
|
||||||
|
TPSUtils_15.init(() -> nanoOffset);
|
||||||
|
}, 15));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setTPS(double tps) {
|
||||||
|
double d = 50 - (50 / (tps / 20.0));
|
||||||
|
nanoDOffset = Math.max(0, Math.min((long) (d * 1000000), 25000000));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWarpAllowed() {
|
||||||
|
return warp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isWarping() {
|
||||||
|
return nanoDOffset > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getTps(TPSWatcher.TPSType tpsType) {
|
||||||
|
if (TPSUtils.isWarping()) return TPSWatcher.getTPS(tpsType, Math.max(CommandTPSLimiter.getCurrentTPSLimit(), 20));
|
||||||
|
return TPSWatcher.getTPS(tpsType);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,10 +1,12 @@
|
|||||||
name: BauSystem
|
name: BauSystem
|
||||||
author: Lixfel
|
authors: [Lixfel, YoyoNow, Chaoscaot]
|
||||||
version: "1.0"
|
version: "1.0"
|
||||||
depend: [WorldEdit, SpigotCore]
|
depend: [WorldEdit, SpigotCore, ProtocolLib]
|
||||||
load: POSTWORLD
|
load: POSTWORLD
|
||||||
main: de.steamwar.bausystem.BauSystem
|
main: de.steamwar.bausystem.BauSystem
|
||||||
api-version: "1.13"
|
api-version: "1.13"
|
||||||
|
website: "https://steamwar.de"
|
||||||
|
description: "So unseriös wie wir sind: BauSystem nur besser."
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
debugstick:
|
debugstick:
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren