SteamWar/BauSystem
Archiviert
13
0

Merge branch 'master' into ScriptSystemImprovements

# Conflicts:
#	BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java
Dieser Commit ist enthalten in:
yoyosource 2021-03-20 12:44:35 +01:00
Commit f3f17710e0
61 geänderte Dateien mit 423 neuen und 401 gelöschten Zeilen

Datei anzeigen

@ -49,7 +49,7 @@ class TPSLimit_12 {
static void sendTickPackets() {
Bukkit.getOnlinePlayers().forEach(player -> {
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
for (Packet<?> p : packets) {
connection.sendPacket(p);
}

Datei anzeigen

@ -44,9 +44,9 @@ class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity {
this.setCustomNameVisible(true);
this.setCustomName("Bumm");
this.exploded = true;
if(references++ > 0)
if (references++ > 0)
sendDestroy(player);
}else if(references++ > 0)
} else if (references++ > 0)
return;
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(this, 0, 0);
@ -60,7 +60,7 @@ class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity {
@Override
public boolean hide(Player player, boolean force) {
if(!force && --references > 0)
if (!force && --references > 0)
return false;
sendDestroy(player);
@ -68,7 +68,7 @@ class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity {
return true;
}
private void sendDestroy(Player player){
private void sendDestroy(Player player) {
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy);
}

Datei anzeigen

@ -33,11 +33,12 @@ import java.util.stream.Collectors;
class AutoLoader_12 {
private AutoLoader_12(){}
private AutoLoader_12() {
}
static boolean tntPlaceActionPerform(Location location){
static boolean tntPlaceActionPerform(Location location) {
Material m = location.getBlock().getType();
if(m != Material.AIR && m != Material.STATIONARY_WATER && m != Material.WATER)
if (m != Material.AIR && m != Material.STATIONARY_WATER && m != Material.WATER)
return false;
location.getBlock().setType(Material.TNT);
@ -45,34 +46,34 @@ class AutoLoader_12 {
}
@SuppressWarnings("deprecation")
static boolean setRedstone(Location location, boolean active){
static boolean setRedstone(Location location, boolean active) {
Block block = location.getBlock();
Material material = block.getType();
if(material == Material.LEVER || material == Material.STONE_BUTTON || material == Material.WOOD_BUTTON){
if(active)
block.setData((byte)(block.getData() | 8));
if (material == Material.LEVER || material == Material.STONE_BUTTON || material == Material.WOOD_BUTTON) {
if (active)
block.setData((byte) (block.getData() | 8));
else
block.setData((byte)(block.getData() & -9));
}else if(material == Material.STONE_PLATE || material == Material.WOOD_PLATE) {
block.setData((byte) (block.getData() & -9));
} else if (material == Material.STONE_PLATE || material == Material.WOOD_PLATE) {
if (active)
block.setData((byte) 1);
else
block.setData((byte) 0);
}else if(material == Material.TRIPWIRE) {
if(active) {
} else if (material == Material.TRIPWIRE) {
if (active) {
ArmorStand armorStand = (ArmorStand) Bukkit.getWorlds().get(0).spawnEntity(location, EntityType.ARMOR_STAND);
armorStand.setVisible(false);
armorStand.setBasePlate(false);
armorStand.addScoreboardTag("detonator-" + location.getBlockX() + location.getBlockY() + location.getBlockZ());
}else {
} else {
List<Entity> entityList = Bukkit.getWorlds().get(0).getEntitiesByClasses(ArmorStand.class).stream().filter(entity ->
entity.getScoreboardTags().contains("detonator-" + location.getBlockX() + location.getBlockY() + location.getBlockZ()))
.limit(1)
.collect(Collectors.toList());
if(entityList.isEmpty()) return false;
if (entityList.isEmpty()) return false;
entityList.get(0).remove();
}
}else{
} else {
return false;
}
block.getState().update(true);
@ -80,24 +81,24 @@ class AutoLoader_12 {
}
@SuppressWarnings("deprecation")
static Detoloader onPlayerInteractLoader(PlayerInteractEvent event){
static Detoloader onPlayerInteractLoader(PlayerInteractEvent event) {
Block block = event.getClickedBlock();
Material material = block.getType();
if(material == Material.LEVER){
if((block.getData() & 8) == 8) {
if (material == Material.LEVER) {
if ((block.getData() & 8) == 8) {
return new Detoloader("Hebel", 0).setActive(false);
}else{
} else {
return new Detoloader("Hebel", 0).setActive(true);
}
}else if(material == Material.STONE_BUTTON){
} else if (material == Material.STONE_BUTTON) {
return new Detoloader("Knopf", Detoloader.STONE_BUTTON);
}else if(material == Material.WOOD_BUTTON){
} else if (material == Material.WOOD_BUTTON) {
return new Detoloader("Knopf", Detoloader.WOODEN_BUTTON);
}else if (material == Material.NOTE_BLOCK) {
} else if (material == Material.NOTE_BLOCK) {
return new Detoloader("Noteblock", Detoloader.NOTE_BLOCK);
}else if(material == Material.STONE_PLATE || material == Material.WOOD_PLATE){
} else if (material == Material.STONE_PLATE || material == Material.WOOD_PLATE) {
return new Detoloader("Druckplatte", Detoloader.PRESSURE_PLATE);
}else if (material == Material.TRIPWIRE) {
} else if (material == Material.TRIPWIRE) {
return new Detoloader("Tripwire", Detoloader.TRIPWIRE);
}
return new Detoloader("§eUnbekannter Block betätigt (nicht aufgenommen)", -1).setAddBack(false);

Datei anzeigen

@ -28,7 +28,8 @@ import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
class RegionListener_12 {
private RegionListener_12(){}
private RegionListener_12() {
}
static boolean isWorldEditCommand(String command) {
if (command.startsWith("/")) {

Datei anzeigen

@ -37,9 +37,10 @@ import java.io.IOException;
import java.util.Objects;
class Region_12 {
private Region_12(){}
private Region_12() {
}
static void paste(File file, int x, int y, int z, boolean rotate){
static void paste(File file, int x, int y, int z, boolean rotate) {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Clipboard clipboard;
try {
@ -51,18 +52,18 @@ class Region_12 {
paste(clipboard, x, y, z, rotate);
}
static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){
static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate) {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = clipboard.getDimensions();
Vector v = new Vector(x, y, z);
Vector offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
AffineTransform aT = new AffineTransform();
if(rotate){
if (rotate) {
aT = aT.rotateY(180);
v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
}else{
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
v = v.add(dimensions.getX() / 2 + dimensions.getX() % 2, 0, dimensions.getZ() / 2 + dimensions.getZ() % 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
} else {
v = v.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ() / 2 - dimensions.getZ() % 2).subtract(offset);
}
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);

Datei anzeigen

@ -23,9 +23,10 @@ import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
class ScriptListener_12 {
private ScriptListener_12(){}
private ScriptListener_12() {
}
static boolean isNoBook(ItemStack item){
static boolean isNoBook(ItemStack item) {
return item.getType() != Material.BOOK_AND_QUILL && item.getType() != Material.WRITTEN_BOOK;
}
}

Datei anzeigen

@ -25,7 +25,8 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
class CommandDebugStick_15 {
private CommandDebugStick_15(){}
private CommandDebugStick_15() {
}
static void giveStick(Player player){
SWUtils.giveItemToPlayer(player, new ItemStack(Material.DEBUG_STICK));

Datei anzeigen

@ -50,7 +50,7 @@ class TPSLimit_15 {
static void sendTickPackets() {
Bukkit.getOnlinePlayers().forEach(player -> {
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
for (Packet<?> p : packets) {
connection.sendPacket(p);
}

Datei anzeigen

@ -34,11 +34,11 @@ public class TNTTracer_15 {
public static boolean inWater(World world, Vector tntPosition) {
Block block = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ());
if(block.getType() == Material.WATER)
if (block.getType() == Material.WATER)
return true;
BlockData data = block.getBlockData();
if(!(data instanceof Waterlogged))
if (!(data instanceof Waterlogged))
return false;
return ((Waterlogged) data).isWaterlogged();

Datei anzeigen

@ -50,9 +50,9 @@ class TraceEntity_15 extends EntityFallingBlock implements AbstractTraceEntity {
this.setCustomNameVisible(true);
this.setCustomName(new ChatComponentText("Bumm"));
this.exploded = true;
if(references++ > 0)
if (references++ > 0)
sendDestroy(player);
}else if(references++ > 0)
} else if (references++ > 0)
return;
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, tnt ? Block.getCombinedId(Blocks.TNT.getBlockData()) : Block.getCombinedId(Blocks.WHITE_STAINED_GLASS.getBlockData()), ZERO);
@ -65,7 +65,7 @@ class TraceEntity_15 extends EntityFallingBlock implements AbstractTraceEntity {
@Override
public boolean hide(Player player, boolean force) {
if(!force && --references > 0)
if (!force && --references > 0)
return false;
sendDestroy(player);
@ -73,7 +73,7 @@ class TraceEntity_15 extends EntityFallingBlock implements AbstractTraceEntity {
return true;
}
private void sendDestroy(Player player){
private void sendDestroy(Player player) {
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy);
}

Datei anzeigen

@ -54,7 +54,7 @@ class AutoLoader_15 {
powerable.setPowered(active);
block.setBlockData(powerable);
if(data instanceof Openable) {
if (data instanceof Openable) {
Openable openable = (Openable) data;
openable.setOpen(active);
block.setBlockData(openable);
@ -63,7 +63,7 @@ class AutoLoader_15 {
if (data instanceof Switch) {
Switch swtch = (Switch) data;
Block relative;
switch(swtch.getFace()){
switch (swtch.getFace()) {
case FLOOR:
relative = block.getRelative(BlockFace.DOWN);
break;
@ -75,7 +75,7 @@ class AutoLoader_15 {
break;
}
updateBlock(relative);
} else if(block.getType() == Material.TRIPWIRE) {
} else if (block.getType() == Material.TRIPWIRE) {
updateBlock(block);
}
return true;
@ -101,13 +101,13 @@ class AutoLoader_15 {
return new Detoloader("Hebel", 0).setActive(!powerable.isPowered());
} else if (material == Material.STONE_BUTTON) {
return new Detoloader("Knopf", Detoloader.STONE_BUTTON);
} else if (material.name().contains("PRESSURE_PLATE")){
} else if (material.name().contains("PRESSURE_PLATE")) {
return new Detoloader("Druckplatte", Detoloader.PRESSURE_PLATE);
} else if (material.name().contains("BUTTON")) {
return new Detoloader("Knopf", Detoloader.WOODEN_BUTTON);
}else if (material == Material.NOTE_BLOCK) {
} else if (material == Material.NOTE_BLOCK) {
return new Detoloader("Noteblock", Detoloader.NOTE_BLOCK);
}else if (material.name().equals("TRIPWIRE")) {
} else if (material.name().equals("TRIPWIRE")) {
return new Detoloader("Tripwire", Detoloader.TRIPWIRE);
} else {
return new Detoloader("§eUnbekannter Block betätigt (aufgenommen)", 0).setAddBack(false);
@ -115,7 +115,7 @@ class AutoLoader_15 {
}
static boolean getLever(Block block) {
if(!(block.getBlockData() instanceof Powerable))
if (!(block.getBlockData() instanceof Powerable))
return false;
return ((Powerable) block.getBlockData()).isPowered();
}

Datei anzeigen

@ -32,7 +32,8 @@ import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
class RegionListener_15 {
private RegionListener_15(){}
private RegionListener_15() {
}
static boolean isWorldEditCommand(String command) {
if (command.startsWith("/")) {

Datei anzeigen

@ -44,9 +44,10 @@ import java.io.IOException;
import java.util.Objects;
class Region_15 {
private Region_15(){}
private Region_15() {
}
static void paste(File file, int x, int y, int z, boolean rotate){
static void paste(File file, int x, int y, int z, boolean rotate) {
Clipboard clipboard;
try {
clipboard = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file)).read();
@ -57,16 +58,16 @@ class Region_15 {
paste(clipboard, x, y, z, rotate);
}
static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate){
static void paste(Clipboard clipboard, int x, int y, int z, boolean rotate) {
BlockVector3 dimensions = clipboard.getDimensions();
BlockVector3 v = BlockVector3.at(x, y, z);
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
AffineTransform aT = new AffineTransform();
if(rotate){
if (rotate) {
aT = aT.rotateY(180);
v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
}else{
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
v = v.add(dimensions.getX() / 2 + dimensions.getX() % 2, 0, dimensions.getZ() / 2 + dimensions.getZ() % 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
} else {
v = v.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ() / 2 - dimensions.getZ() % 2).subtract(offset);
}
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1);
@ -76,7 +77,7 @@ class Region_15 {
e.flushSession();
}
static void fastpaste(File file, int x, int y, int z, boolean rotate){
static void fastpaste(File file, int x, int y, int z, boolean rotate) {
Clipboard clipboard;
try {
clipboard = Objects.requireNonNull(ClipboardFormats.findByFile(file)).getReader(new FileInputStream(file)).read();
@ -87,26 +88,26 @@ class Region_15 {
BlockVector3 dimensions = clipboard.getDimensions();
BlockVector3 v = BlockVector3.at(x, y, z);
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
if(rotate){
v = v.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
}else{
v = v.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset);
if (rotate) {
v = v.add(dimensions.getX() / 2 + dimensions.getX() % 2, 0, dimensions.getZ() / 2 + dimensions.getZ() % 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
} else {
v = v.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ() / 2 - dimensions.getZ() % 2).subtract(offset);
}
WorldServer world = ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle();
WorldServer world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
v = v.add(offset);
for(int X = v.getBlockX(); X < v.getBlockX() + dimensions.getBlockX(); X++){
for(int Y = v.getBlockY(); Y < v.getBlockY() + dimensions.getBlockY(); Y++){
for(int Z = v.getBlockZ(); Z < v.getBlockZ() + dimensions.getBlockZ(); Z++){
for (int X = v.getBlockX(); X < v.getBlockX() + dimensions.getBlockX(); X++) {
for (int Y = v.getBlockY(); Y < v.getBlockY() + dimensions.getBlockY(); Y++) {
for (int Z = v.getBlockZ(); Z < v.getBlockZ() + dimensions.getBlockZ(); Z++) {
BlockPosition blockPos = new BlockPosition(X, Y, Z);
BaseBlock fullBlock = clipboard.getFullBlock(BlockVector3.at(X, Y, Z).subtract(v).add(clipboard.getRegion().getMinimumPoint()));
BlockData replaceTo = BukkitAdapter.adapt(fullBlock);
world.removeTileEntity(blockPos);
if(replaceTo == null)
world.setTypeAndData(blockPos, ((CraftBlockData)Material.AIR.createBlockData()).getState(), 1042);
if (replaceTo == null)
world.setTypeAndData(blockPos, ((CraftBlockData) Material.AIR.createBlockData()).getState(), 1042);
else
world.setTypeAndData(new BlockPosition(X, Y, Z), ((CraftBlockData)replaceTo).getState(), 1042);
world.setTypeAndData(new BlockPosition(X, Y, Z), ((CraftBlockData) replaceTo).getState(), 1042);
world.getChunkProvider().flagDirty(blockPos);
}

Datei anzeigen

@ -23,9 +23,10 @@ import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
class ScriptListener_15 {
private ScriptListener_15(){}
private ScriptListener_15() {
}
static boolean isNoBook(ItemStack item){
static boolean isNoBook(ItemStack item) {
return item.getType() != Material.WRITABLE_BOOK && item.getType() != Material.WRITTEN_BOOK;
}
}

Datei anzeigen

@ -26,7 +26,7 @@ import org.bukkit.entity.Player;
import java.util.LinkedList;
abstract class IAutoLoader {
abstract class AbstractAutoLoader {
abstract Player getPlayer();
abstract boolean setRedstone(Location location, boolean active);
@ -44,9 +44,9 @@ abstract class IAutoLoader {
abstract static class LoaderAction {
final Location location;
final IAutoLoader loader;
final AbstractAutoLoader loader;
LoaderAction(IAutoLoader loader, Location location){
LoaderAction(AbstractAutoLoader loader, Location location){
this.location = location;
this.loader = loader;
loader.getActions().add(this);
@ -63,7 +63,7 @@ abstract class IAutoLoader {
final int length;
int status;
RedstoneActivation(IAutoLoader loader, Location location, int ticks, boolean active){
RedstoneActivation(AbstractAutoLoader loader, Location location, int ticks, boolean active){
super(loader, location);
this.length = ticks;
this.active = active;
@ -93,7 +93,7 @@ abstract class IAutoLoader {
final int length;
int status;
TemporaryActivation(IAutoLoader loader, Location location, int ticks){
TemporaryActivation(AbstractAutoLoader loader, Location location, int ticks){
super(loader, location);
this.length = ticks;
status = 0;

Datei anzeigen

@ -79,9 +79,9 @@ public class Detoloader {
}
//Timings
public static final int STONE_BUTTON = 20;
public static final int WOODEN_BUTTON = 30;
public static final int STONE_BUTTON = 20;
public static final int WOODEN_BUTTON = 30;
public static final int PRESSURE_PLATE = 20;
public static final int NOTE_BLOCK = 1;
public static final int TRIPWIRE = 20;
public static final int NOTE_BLOCK = 1;
public static final int TRIPWIRE = 20;
}

Datei anzeigen

@ -32,7 +32,7 @@ public class CommandBau implements CommandExecutor {
private void onToggleBD(Player p, String arg) {
SteamwarUser id = SteamwarUser.get(arg);
if(negativeToggleCheck(p, id)){
if (negativeToggleCheck(p, id)) {
return;
}
@ -42,7 +42,7 @@ public class CommandBau implements CommandExecutor {
private void onToggleWE(Player p, String arg) {
SteamwarUser id = SteamwarUser.get(arg);
if(negativeToggleCheck(p, id)){
if (negativeToggleCheck(p, id)) {
return;
}
@ -52,7 +52,7 @@ public class CommandBau implements CommandExecutor {
private void onToggleWorld(Player p, String arg) {
SteamwarUser id = SteamwarUser.get(arg);
if(negativeToggleCheck(p, id)){
if (negativeToggleCheck(p, id)) {
return;
}
@ -60,7 +60,7 @@ public class CommandBau implements CommandExecutor {
Welt.toggleWorld(p, target);
}
private boolean negativeToggleCheck(Player p, SteamwarUser id){
private boolean negativeToggleCheck(Player p, SteamwarUser id) {
if (id == null) {
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
return true;
@ -76,19 +76,19 @@ public class CommandBau implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if(!BauSystem.getOwner().equals(player.getUniqueId())){
if (!BauSystem.getOwner().equals(player.getUniqueId())) {
player.sendMessage(BauSystem.PREFIX + "§cDies ist nicht deine Welt!");
return false;
}
if(args[0].equalsIgnoreCase("togglebuild")){
if (args[0].equalsIgnoreCase("togglebuild")) {
onToggleBD(player, args[1]);
}else if(args[0].equalsIgnoreCase("togglewe")){
} else if (args[0].equalsIgnoreCase("togglewe")) {
onToggleWE(player, args[1]);
}else if(args[0].equalsIgnoreCase("toggleworld")){
} else if (args[0].equalsIgnoreCase("toggleworld")) {
onToggleWorld(player, args[1]);
}
return false;

Datei anzeigen

@ -36,32 +36,34 @@ public class CommandClear extends BukkitCommand {
description = "Leere dein Inventar oder das eines anderen Spielers.";
usageMessage = "/clear [Spieler]";
}
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if (args.length == 0){
if (args.length == 0) {
clear(player);
player.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde geleert.");
return true;
}
// check if admin
if(Welt.noPermission(player, Permission.world)){
if (Welt.noPermission(player, Permission.world)) {
player.sendMessage(BauSystem.PREFIX + "$cDu darfst hier keine fremden Inventare leeren.");
return false;
}
Player target = Bukkit.getPlayerExact(args[0]);
if(!(target instanceof Player)){
if (!(target instanceof Player)) {
player.sendMessage(BauSystem.PREFIX + "§cDas ist kein Spieler.");
return false;
}
clear(target);
target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + player.getDisplayName() +" §7geleert.");
player.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() +" §7wurde geleert.");
target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + player.getDisplayName() + " §7geleert.");
player.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() + " §7wurde geleert.");
return true;
}
private void clear(Player player){
private void clear(Player player) {
player.getInventory().clear();
player.getInventory().setHelmet(new ItemStack(Material.AIR));
player.getInventory().setChestplate(new ItemStack(Material.AIR));

Datei anzeigen

@ -33,11 +33,11 @@ public class CommandDebugStick implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if (Welt.noPermission(player, Permission.build)){
if (Welt.noPermission(player, Permission.build)) {
player.sendMessage(BauSystem.PREFIX + "§cKein Debugstick für dich hier.");
return false;
}

Datei anzeigen

@ -39,7 +39,7 @@ public class CommandDetonator implements CommandExecutor {
}
private boolean permissionCheck(Player player) {
if(Welt.noPermission(player, Permission.world)){
if (Welt.noPermission(player, Permission.world)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen");
return false;
}
@ -48,11 +48,11 @@ public class CommandDetonator implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
if(!(sender instanceof Player))
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if(args.length == 0){
if (args.length == 0) {
help(player);
return false;
}

Datei anzeigen

@ -30,12 +30,14 @@ public class CommandFire extends RegionToggleCommand {
String getNoPermMessage() {
return "§cDu darfst hier nicht Feuerschaden (de-)aktivieren";
}
@Override
String getEnableMessage(){
String getEnableMessage() {
return "§cFeuerschaden deaktiviert";
}
@Override
String getDisableMessage(){
String getDisableMessage() {
return "§aFeuerschaden aktiviert";
}
@ -51,7 +53,7 @@ public class CommandFire extends RegionToggleCommand {
}
@EventHandler
public void onFireSpread(BlockSpreadEvent e){
public void onFireSpread(BlockSpreadEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true);
}

Datei anzeigen

@ -100,12 +100,12 @@ public class CommandFreeze extends RegionToggleCommand {
}
@EventHandler
public void onRedstoneEvent(BlockRedstoneEvent e){
public void onRedstoneEvent(BlockRedstoneEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setNewCurrent(e.getOldCurrent());
}
@EventHandler
public void onBlockDispense(BlockDispenseEvent e){
public void onBlockDispense(BlockDispenseEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
}

Datei anzeigen

@ -34,75 +34,75 @@ import java.util.List;
public class CommandGamemode extends BukkitCommand {
private static final List<String> GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival",
"spectator");
"spectator");
public CommandGamemode() {
super("gamemode");
List<String> aliases = new ArrayList<>();
aliases.add("gm");
this.setAliases(aliases);
this.description = "Ändert den Spielmodus eines Spielers";
this.usageMessage = "/gm [Spielmodus]";
super("gamemode");
List<String> aliases = new ArrayList<>();
aliases.add("gm");
this.setAliases(aliases);
this.description = "Ändert den Spielmodus eines Spielers";
this.usageMessage = "/gm [Spielmodus]";
}
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!(sender instanceof Player)) {
return false;
}else if (args.length == 0) {
sender.sendMessage(BauSystem.PREFIX + this.usageMessage);
return false;
}
if (!(sender instanceof Player)) {
return false;
} else if (args.length == 0) {
sender.sendMessage(BauSystem.PREFIX + this.usageMessage);
return false;
}
Player p = (Player) sender;
Player p = (Player) sender;
if(!p.getUniqueId().equals(BauSystem.getOwner())){
BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId());
if(member == null || !member.isBuild()){
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier deinen Spielmodus nicht ändern");
return false;
}
}
if (!p.getUniqueId().equals(BauSystem.getOwner())) {
BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId());
if (member == null || !member.isBuild()) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier deinen Spielmodus nicht ändern");
return false;
}
}
GameMode mode = createMode(args[0]);
GameMode mode = createMode(args[0]);
if(mode == null){
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spielmodus");
return false;
}
if (mode == null) {
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spielmodus");
return false;
}
p.setGameMode(mode);
return true;
p.setGameMode(mode);
return true;
}
@SuppressWarnings("deprecation")
private GameMode createMode(String modeArg){
try {
return GameMode.getByValue(Integer.parseInt(modeArg));
} catch (NumberFormatException ignored) {
if ((modeArg.equalsIgnoreCase("creative")) || (modeArg.equalsIgnoreCase("c")))
return GameMode.CREATIVE;
else if ((modeArg.equalsIgnoreCase("adventure")) || (modeArg.equalsIgnoreCase("a")))
return GameMode.ADVENTURE;
else if ((modeArg.equalsIgnoreCase("spectator")) || (modeArg.equalsIgnoreCase("sp")))
return GameMode.SPECTATOR;
else if ((modeArg.equalsIgnoreCase("survival")) || (modeArg.equalsIgnoreCase("s")))
return GameMode.SURVIVAL;
}
return null;
}
private GameMode createMode(String modeArg) {
try {
return GameMode.getByValue(Integer.parseInt(modeArg));
} catch (NumberFormatException ignored) {
if ((modeArg.equalsIgnoreCase("creative")) || (modeArg.equalsIgnoreCase("c")))
return GameMode.CREATIVE;
else if ((modeArg.equalsIgnoreCase("adventure")) || (modeArg.equalsIgnoreCase("a")))
return GameMode.ADVENTURE;
else if ((modeArg.equalsIgnoreCase("spectator")) || (modeArg.equalsIgnoreCase("sp")))
return GameMode.SPECTATOR;
else if ((modeArg.equalsIgnoreCase("survival")) || (modeArg.equalsIgnoreCase("s")))
return GameMode.SURVIVAL;
}
return null;
}
@Override
@Override
public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
Validate.notNull(sender, "Sender cannot be null");
Validate.notNull(args, "Arguments cannot be null");
Validate.notNull(alias, "Alias cannot be null");
Validate.notNull(sender, "Sender cannot be null");
Validate.notNull(args, "Arguments cannot be null");
Validate.notNull(alias, "Alias cannot be null");
if (args.length == 1)
return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES,
new ArrayList<>(GAMEMODE_NAMES.size()));
if (args.length == 2) {
return super.tabComplete(sender, alias, args);
}
return ImmutableList.of();
if (args.length == 1)
return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES,
new ArrayList<>(GAMEMODE_NAMES.size()));
if (args.length == 2) {
return super.tabComplete(sender, alias, args);
}
return ImmutableList.of();
}
}

Datei anzeigen

@ -31,7 +31,7 @@ public class CommandGills implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
toggleGills(player);
@ -39,7 +39,7 @@ public class CommandGills implements CommandExecutor {
}
public static void toggleGills(Player player) {
if(player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) {
if (player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) {
player.sendMessage(BauSystem.PREFIX + "Wassersicht deaktiviert");
player.removePotionEffect(PotionEffectType.WATER_BREATHING);
return;

Datei anzeigen

@ -27,7 +27,8 @@ import java.lang.reflect.Field;
public class CommandInjector {
private CommandInjector(){}
private CommandInjector() {
}
private static final String PACKAGE_NAME = Bukkit.getServer().getClass().getPackage().getName();
private static final String VERSION = PACKAGE_NAME.substring(PACKAGE_NAME.lastIndexOf('.') + 1);

Datei anzeigen

@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
public class CommandLoader implements CommandExecutor {
private void help(Player player){
private void help(Player player) {
player.sendMessage("§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen");
player.sendMessage("§8/§7loader undo §8- §7Entfernt die zuletzt aufgenommene Aktion");
player.sendMessage("§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Aktionen ab");
@ -42,21 +42,21 @@ public class CommandLoader implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if(Welt.noPermission(player, Permission.build)){
if (Welt.noPermission(player, Permission.build)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den AutoLader verwenden");
return false;
}
if(args.length == 0){
if (args.length == 0) {
help(player);
return false;
}
switch(args[0].toLowerCase()){
switch (args[0].toLowerCase()) {
case "setup":
setup(player);
break;
@ -81,16 +81,16 @@ public class CommandLoader implements CommandExecutor {
return false;
}
private void setup(Player player){
private void setup(Player player) {
AutoLoader.getLoader(player).setup();
}
private void undo(Player player){
private void undo(Player player) {
AutoLoader loader = loader(player);
if(loader == null)
if (loader == null)
return;
if(!loader.isSetup()){
if (!loader.isSetup()) {
player.sendMessage("§cDer AutoLader wird in den Setup-Zustand versetzt");
setup(player);
}
@ -98,58 +98,58 @@ public class CommandLoader implements CommandExecutor {
loader.undo();
}
private void start(Player player){
private void start(Player player) {
AutoLoader loader = loader(player);
if(loader == null)
if (loader == null)
return;
loader.start();
}
private void stop(Player player){
if(!AutoLoader.hasLoader(player)){
private void stop(Player player) {
if (!AutoLoader.hasLoader(player)) {
player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen aktiven AutoLader");
return;
}
AutoLoader.getLoader(player).stop();
}
private void wait(Player player, String[] args){
if(args.length != 2){
private void wait(Player player, String[] args) {
if (args.length != 2) {
help(player);
return;
}
AutoLoader loader = loader(player);
if(loader == null)
if (loader == null)
loader = AutoLoader.getLoader(player);
try {
loader.wait(Integer.parseInt(args[1]));
}catch (NumberFormatException e){
} catch (NumberFormatException e) {
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Ganzzahl an");
}
}
private void speed(Player player, String[] args){
if(args.length != 2){
private void speed(Player player, String[] args) {
if (args.length != 2) {
help(player);
return;
}
AutoLoader loader = loader(player);
if(loader == null)
if (loader == null)
loader = AutoLoader.getLoader(player);
try {
loader.blockWait(Integer.parseInt(args[1]));
}catch (NumberFormatException e){
} catch (NumberFormatException e) {
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Ganzzahl an");
}
}
private AutoLoader loader(Player player){
if(AutoLoader.hasLoader(player))
private AutoLoader loader(Player player) {
if (AutoLoader.hasLoader(player))
return AutoLoader.getLoader(player);
player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen aktiven AutoLader");
player.sendMessage(BauSystem.PREFIX + "§7Es wird ein neuer AutoLader gestartet");

Datei anzeigen

@ -32,31 +32,31 @@ import org.bukkit.entity.Player;
public class CommandLockschem implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup();
if(userGroup != UserGroup.Admin &&
if (userGroup != UserGroup.Admin &&
userGroup != UserGroup.Developer &&
userGroup != UserGroup.Moderator &&
userGroup != UserGroup.Supporter)
return false;
if(args.length != 2) {
if (args.length != 2) {
sendHelp(player);
return false;
}
SteamwarUser schemOwner = SteamwarUser.get(args[0]);
if(schemOwner == null) {
if (schemOwner == null) {
player.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!");
return false;
}
Schematic schematic = Schematic.getSchemFromDB(args[1], schemOwner.getUUID());
if(schematic == null) {
if (schematic == null) {
player.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!");
return false;
}

Datei anzeigen

@ -31,7 +31,7 @@ public class CommandNV implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
toggleNightvision(player);
@ -39,7 +39,7 @@ public class CommandNV implements CommandExecutor {
}
public static void toggleNightvision(Player player) {
if(player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
player.sendMessage(BauSystem.PREFIX + "Nachtsicht deaktiviert");
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
return;

Datei anzeigen

@ -32,15 +32,15 @@ import org.bukkit.entity.Player;
import java.util.logging.Level;
public class CommandProtect implements CommandExecutor {
public class CommandProtect implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if(Welt.noPermission(player, Permission.worldedit)){
if (Welt.noPermission(player, Permission.worldedit)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Boden schützen");
return false;
}
@ -52,16 +52,16 @@ public class CommandProtect implements CommandExecutor {
}
try {
Schematic schem = null;
if(args.length > 0){
if (args.length > 0) {
schem = Schematic.getSchemFromDB(args[0], player.getUniqueId());
if(schem == null){
if (schem == null) {
player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
return false;
}
}
region.protect(schem);
player.sendMessage(BauSystem.PREFIX + "§7Boden geschützt");
}catch(Exception e){
} catch (Exception e) {
player.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region");
Bukkit.getLogger().log(Level.WARNING, "Failed protect", e);
}

Datei anzeigen

@ -36,11 +36,11 @@ public class CommandReset implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if(Welt.noPermission(player, Permission.world)){
if (Welt.noPermission(player, Permission.world)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region zurücksetzen");
return false;
}
@ -51,18 +51,18 @@ public class CommandReset implements CommandExecutor {
return false;
}
try {
if(args.length > 0){
if (args.length > 0) {
Schematic schem = Schematic.getSchemFromDB(args[0], player.getUniqueId());
if(schem == null){
if (schem == null) {
player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
return false;
}
region.reset(schem);
}else{
} else {
region.fastreset();
}
player.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
}catch(Exception e){
} catch (Exception e) {
player.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
Bukkit.getLogger().log(Level.WARNING, "Failed reset", e);
}

Datei anzeigen

@ -33,17 +33,17 @@ public class CommandSkull implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
if(!(commandSender instanceof Player))
if (!(commandSender instanceof Player))
return false;
Player p = (Player) commandSender;
if(args.length != 1){
if (args.length != 1) {
p.sendMessage(BauSystem.PREFIX + "§8/§eskull §8[§eSpieler§8]");
return false;
}
ItemStack is = SWItem.getPlayerSkull(args[0]).getItemStack();
SkullMeta sm = (SkullMeta)is.getItemMeta();
SkullMeta sm = (SkullMeta) is.getItemMeta();
assert sm != null;
sm.setDisplayName("§e" + args[0] + "§8s Kopf");
is.setItemMeta(sm);

Datei anzeigen

@ -29,19 +29,19 @@ public class CommandSpeed implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if (args.length == 0){
if (args.length == 0) {
player.sendMessage(BauSystem.PREFIX + "/speed [Geschwindigkeit]");
return false;
}
float speed;
try{
try {
speed = Float.parseFloat(args[0]);
}catch(NumberFormatException e){
} catch (NumberFormatException e) {
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
return false;
}

Datei anzeigen

@ -102,7 +102,7 @@ public class CommandTPSLimiter implements CommandExecutor {
private void tpsLimiter() {
delay = 20 / currentTPSLimit;
loops = (int)Math.ceil(delay);
loops = (int) Math.ceil(delay);
sleepDelay = (long) (50 * delay) / loops;
TPSUtils.setTPS(currentTPSLimit);
@ -141,7 +141,7 @@ public class CommandTPSLimiter implements CommandExecutor {
}
public static double getCurrentTPSLimit() {
return (double)Math.round(currentTPSLimit * 10.0D) / 10.0D;
return (double) Math.round(currentTPSLimit * 10.0D) / 10.0D;
}
}

Datei anzeigen

@ -35,7 +35,8 @@ public class CommandTPSLimiterTabComplete implements TabCompleter {
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"));
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

Datei anzeigen

@ -31,51 +31,51 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import java.util.List;
public class CommandTeleport extends BukkitCommand {
public CommandTeleport() {
super("tp");
description = "Teleportiert dich zu einem genannten Spieler.";
usageMessage = "/tp [Spieler]";
}
public CommandTeleport() {
super("tp");
description = "Teleportiert dich zu einem genannten Spieler.";
usageMessage = "/tp [Spieler]";
}
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!(sender instanceof Player))
return false;
else if (args.length != 1) {
sender.sendMessage(BauSystem.PREFIX + usageMessage);
return false;
}
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!(sender instanceof Player))
return false;
else if (args.length != 1) {
sender.sendMessage(BauSystem.PREFIX + usageMessage);
return false;
}
Player p = (Player) sender;
Player p = (Player) sender;
Player target = Bukkit.getPlayerExact(args[0]);
Player target = Bukkit.getPlayerExact(args[0]);
if (target == null) {
p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist derzeit offline.");
return true;
}
if (target == null) {
p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist derzeit offline.");
return true;
}
if(p.getUniqueId().equals(target.getUniqueId())){
p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!");
return false;
}
if (p.getUniqueId().equals(target.getUniqueId())) {
p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!");
return false;
}
if(!BauSystem.getOwner().equals(p.getUniqueId())){
BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId());
if(member == null || !member.isBuild()){
p.sendMessage(BauSystem.PREFIX + "§cDu darfst dich auf dieser Welt nicht teleportieren!");
return false;
}
}
if (!BauSystem.getOwner().equals(p.getUniqueId())) {
BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId());
if (member == null || !member.isBuild()) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst dich auf dieser Welt nicht teleportieren!");
return false;
}
}
p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
return true;
p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
return true;
}
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
Validate.notNull(sender, "Sender cannot be null");
Validate.notNull(args, "Arguments cannot be null");
Validate.notNull(alias, "Alias cannot be null");
Validate.notNull(sender, "Sender cannot be null");
Validate.notNull(args, "Arguments cannot be null");
Validate.notNull(alias, "Alias cannot be null");
return super.tabComplete(sender, alias, args);
return super.tabComplete(sender, alias, args);
}
}

Datei anzeigen

@ -36,11 +36,11 @@ public class CommandTestblock implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if(Welt.noPermission(player, Permission.worldedit)){
if (Welt.noPermission(player, Permission.worldedit)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Testblock zurücksetzen");
return false;
}
@ -52,16 +52,16 @@ public class CommandTestblock implements CommandExecutor {
}
try {
Schematic schem = null;
if(args.length > 0){
if (args.length > 0) {
schem = Schematic.getSchemFromDB(args[0], player.getUniqueId());
if(schem == null){
if (schem == null) {
player.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
return false;
}
}
region.resetTestblock(schem);
player.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
}catch(Exception e){
} catch (Exception e) {
player.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks");
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
}

Datei anzeigen

@ -30,38 +30,38 @@ import org.bukkit.entity.Player;
public class CommandTime extends BukkitCommand {
public CommandTime() {
super("time");
this.description = "Ändert die Zeit auf der Spielwelt";
this.usageMessage = "/time <Zeit 0=Morgen, 6000=Mittag, 18000=Mitternacht>";
super("time");
this.description = "Ändert die Zeit auf der Spielwelt";
this.usageMessage = "/time <Zeit 0=Morgen, 6000=Mittag, 18000=Mitternacht>";
}
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!(sender instanceof Player)) {
return false;
} else if (args.length == 0) {
sender.sendMessage(BauSystem.PREFIX + this.usageMessage);
return false;
}
Player player = (Player) sender;
if (!(sender instanceof Player)) {
return false;
} else if (args.length == 0) {
sender.sendMessage(BauSystem.PREFIX + this.usageMessage);
return false;
}
Player player = (Player) sender;
if (Welt.noPermission(player, Permission.world)){
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern");
return false;
}
if (Welt.noPermission(player, Permission.world)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern");
return false;
}
int time;
try{
time = Integer.valueOf(args[0]);
}catch(NumberFormatException e){
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
return false;
}
if (time < 0 || time > 24000) {
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
return false;
}
int time;
try {
time = Integer.valueOf(args[0]);
} catch (NumberFormatException e) {
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
return false;
}
if (time < 0 || time > 24000) {
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
return false;
}
Bukkit.getWorlds().get(0).setTime(time);
return false;
}
Bukkit.getWorlds().get(0).setTime(time);
return false;
}
}

Datei anzeigen

@ -49,7 +49,7 @@ public class CommandTrace implements CommandExecutor {
}
private boolean permissionCheck(Player player) {
if(Welt.noPermission(player, Permission.world)){
if (Welt.noPermission(player, Permission.world)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen");
return false;
}
@ -58,10 +58,10 @@ public class CommandTrace implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) return false;
if (!(sender instanceof Player)) return false;
Player player = (Player) sender;
if(args.length == 0){
if (args.length == 0) {
help(player);
return false;
}

Datei anzeigen

@ -46,7 +46,7 @@ public class CommandTraceTabCompleter implements TabCompleter {
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) return new ArrayList<>();
if (!(sender instanceof Player)) return new ArrayList<>();
return tracerTabComplete((Player) sender, args);
}

Datei anzeigen

@ -42,11 +42,11 @@ public abstract class RegionToggleCommand implements CommandExecutor, Listener {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if (Welt.noPermission(player, Permission.world)){
if (Welt.noPermission(player, Permission.world)) {
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
return false;
}
@ -69,7 +69,9 @@ public abstract class RegionToggleCommand implements CommandExecutor, Listener {
}
abstract String getNoPermMessage();
abstract String getEnableMessage();
abstract String getDisableMessage();
/**

Datei anzeigen

@ -56,16 +56,19 @@ public class GuiTraceShow {
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 -> {});
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 -> {});
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 -> {});
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)

Datei anzeigen

@ -42,9 +42,9 @@ public class RoundedTNTPosition {
}
public RoundedTNTPosition(double x, double y, double z) {
this.x = (int)(x * factor);
this.y = (int)(y * factor);
this.z = (int)(z * factor);
this.x = (int) (x * factor);
this.y = (int) (y * factor);
this.z = (int) (z * factor);
}
@Override

Datei anzeigen

@ -49,7 +49,7 @@ public class TNTPosition {
return exploded;
}
public Record.TNTRecord getRecord(){
public Record.TNTRecord getRecord() {
return record;
}

Datei anzeigen

@ -87,7 +87,7 @@ public class RecordStateMachine {
return recorder.getStartTime();
}
public static void postClear(){
public static void postClear() {
if (recorder == null) return;
recorder.postClear();
}

Datei anzeigen

@ -34,13 +34,13 @@ public class TraceAutoHandler implements Listener {
private BukkitTask task;
private int lastExplosion = 0; // Time since the last explosion in ticks
public void enable(){
public void enable() {
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
}
public void disable(){
public void disable() {
HandlerList.unregisterAll(this);
if(task != null){
if (task != null) {
task.cancel();
task = null;
}
@ -52,13 +52,13 @@ public class TraceAutoHandler implements Listener {
return;
lastExplosion = 0;
if(task == null){
if (task == null) {
RecordStateMachine.autoRecord();
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), this::run, 1, 1);
}
}
private void run(){
private void run() {
lastExplosion++;
if (lastExplosion > 80) {

Datei anzeigen

@ -55,7 +55,7 @@ public class Record {
return record;
}
public void clear(){
public void clear() {
tnt.clear();
}
@ -87,7 +87,7 @@ public class Record {
add(tntPrimed, true);
}
public List<TNTPosition> getPositions(){
public List<TNTPosition> getPositions() {
return positions;
}
}

Datei anzeigen

@ -23,5 +23,6 @@ import de.steamwar.bausystem.tracer.TNTPosition;
public interface ShowMode {
void show(TNTPosition position);
void hide();
}

Datei anzeigen

@ -2,7 +2,6 @@ package de.steamwar.bausystem.tracer.show;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.tracer.TNTPosition;
import de.steamwar.bausystem.tracer.show.mode.*;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -13,7 +12,8 @@ import java.util.HashMap;
import java.util.Map;
public class TraceShowManager implements Listener {
private TraceShowManager() {}
private TraceShowManager() {
}
private static final Map<Player, ShowMode> showModes = new HashMap<>();

Datei anzeigen

@ -32,13 +32,13 @@ public class AFKStopper implements Listener {
private int minutesAfk;
public AFKStopper(){
public AFKStopper() {
minutesAfk = 0;
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
switch(minutesAfk){
switch (minutesAfk) {
case 5:
for(Player p : Bukkit.getOnlinePlayers())
for (Player p : Bukkit.getOnlinePlayers())
p.kickPlayer("§cAuf diesem Server ist seit 5 Minuten nichts passiert.");
break;
case 4:
@ -50,7 +50,7 @@ public class AFKStopper implements Listener {
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent event){
public void onPlayerMove(PlayerMoveEvent event) {
minutesAfk = 0;
}
}

Datei anzeigen

@ -39,7 +39,7 @@ import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map;
public class AutoLoader extends IAutoLoader implements Listener {
public class AutoLoader extends AbstractAutoLoader implements Listener {
private static final Map<Player, AutoLoader> players = new HashMap<>();
@ -184,11 +184,11 @@ public class AutoLoader extends IAutoLoader implements Listener {
if (lastLocation != null && lastLocation.distance(event.getClickedBlock().getLocation()) <= 1) return;
if (detoloader.useActive) {
new IAutoLoader.RedstoneActivation(this, event.getClickedBlock().getLocation()
new AbstractAutoLoader.RedstoneActivation(this, event.getClickedBlock().getLocation()
, detoloader.getActivation() == 0 ? getLastActivation() : detoloader.getActivation()
, detoloader.isActive());
} else {
new IAutoLoader.TemporaryActivation(this, event.getClickedBlock().getLocation()
new AbstractAutoLoader.TemporaryActivation(this, event.getClickedBlock().getLocation()
, detoloader.getActivation());
}
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " betätigt" :
@ -251,9 +251,9 @@ public class AutoLoader extends IAutoLoader implements Listener {
return lastActivation;
}
class TNTPlaceAction extends IAutoLoader.LoaderAction {
class TNTPlaceAction extends AbstractAutoLoader.LoaderAction {
TNTPlaceAction(IAutoLoader loader, Location location){
TNTPlaceAction(AbstractAutoLoader loader, Location location){
super(loader, location);
}

Datei anzeigen

@ -77,7 +77,7 @@ public class BauScoreboard implements Listener {
int i = strings.size();
HashMap<String, Integer> result = new HashMap<>();
for(String s : strings)
for (String s : strings)
result.put(s, i--);
return result;
}

Datei anzeigen

@ -33,10 +33,10 @@ public class ClipboardListener implements Listener {
private static final String CLIPBOARD_SCHEMNAME = "//copy";
@EventHandler
public void onLogin(PlayerJoinEvent e){
public void onLogin(PlayerJoinEvent e) {
try {
Schematic schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, e.getPlayer().getUniqueId());
if(schematic != null){
if (schematic != null) {
schematic.loadToPlayer(e.getPlayer());
}
} catch (Exception ex) {
@ -45,20 +45,20 @@ public class ClipboardListener implements Listener {
}
@EventHandler
public void onLogout(PlayerQuitEvent e){
public void onLogout(PlayerQuitEvent e) {
UUID playerUUID = e.getPlayer().getUniqueId();
Schematic schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, playerUUID);
boolean newSchem = false;
if(schematic == null){
if (schematic == null) {
Schematic.createSchem(CLIPBOARD_SCHEMNAME, playerUUID, "", SchematicType.Normal);
schematic = Schematic.getSchemFromDB(CLIPBOARD_SCHEMNAME, playerUUID);
newSchem = true;
}
try{
try {
schematic.saveFromPlayer(e.getPlayer());
} catch (Exception ex) {
if(newSchem)
if (newSchem)
schematic.remove();
}
}

Datei anzeigen

@ -68,7 +68,7 @@ public class Detonator implements Listener {
List<int[]> locs = new ArrayList<>();
for (int i = 0; i < 128; i++) {
NamespacedKey key = new NamespacedKey(BauSystem.getPlugin(), DETO_PREFIX + i);
if(container.has(key, PersistentDataType.INTEGER_ARRAY))
if (container.has(key, PersistentDataType.INTEGER_ARRAY))
locs.add(container.get(key, PersistentDataType.INTEGER_ARRAY));
}
return new Detonator(player, locs.toArray(new int[0][0]));
@ -84,7 +84,7 @@ public class Detonator implements Listener {
}
public static ItemStack toggleLocation(ItemStack item, Player player, Detoloader detoloader, Location location) {
if(VersionedCallable.call(new VersionedCallable<>(() -> PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).stream().anyMatch(activation -> activation.location.equals(location)), 12),
if (VersionedCallable.call(new VersionedCallable<>(() -> PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).stream().anyMatch(activation -> activation.location.equals(location)), 12),
new VersionedCallable<>(() -> hasLocation(item, location), 15))) {
DetonatorListener.print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " entfernt" :
detoloader.getBlock(), Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() - 1);
@ -92,10 +92,10 @@ public class Detonator implements Listener {
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).removeIf(activation -> activation.location.equals(location));
return item;
}, 12), new VersionedCallable<>(() -> removeLocation(item, location), 15));
}else {
} else {
DetonatorListener.print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " hinzugefügt" :
detoloader.getBlock(), Math.min(Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() + 1, 128));
if(detoloader.getActivation() == 0)
if (detoloader.getActivation() == 0)
return VersionedCallable.call(new VersionedCallable<>(() -> {
PLAYER_LOCS.computeIfAbsent(player, player1 -> new HashSet<>()).add(new Detoloader.DetonatorActivation(location));
return item;
@ -151,7 +151,7 @@ public class Detonator implements Listener {
public static ItemStack pushLocToDetonator(ItemStack item, Detoloader.DetonatorActivation detoloader) {
int slot = getFreeSlot(item);
if(slot == -1)
if (slot == -1)
throw new SecurityException("Der Detonator ist auf 128 Positionen Limitiert");
ItemMeta meta = item.getItemMeta();
Location block = detoloader.location;
@ -181,9 +181,9 @@ public class Detonator implements Listener {
PersistentDataContainer container = meta.getPersistentDataContainer();
for (int i = 0; i < 128; i++) {
NamespacedKey key = new NamespacedKey(BauSystem.getPlugin(), DETO_PREFIX + i);
if(container.has(key, PersistentDataType.INTEGER_ARRAY)) {
if (container.has(key, PersistentDataType.INTEGER_ARRAY)) {
int[] locs = container.get(key, PersistentDataType.INTEGER_ARRAY);
if(locs[0] == location.getBlockX() && locs[1] == location.getBlockY() && locs[2] == location.getBlockZ())
if (locs[0] == location.getBlockX() && locs[1] == location.getBlockY() && locs[2] == location.getBlockZ())
return i;
}
}

Datei anzeigen

@ -21,7 +21,7 @@ public class DetonatorListener implements Listener {
if (VersionedCallable.call(new VersionedCallable<>(() -> event.getItem().isSimilar(Detonator.WAND), 12),
new VersionedCallable<>(() -> event.getItem().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE), 15))) {
Player player = event.getPlayer();
if(Welt.noPermission(player, Permission.world)){
if (Welt.noPermission(player, Permission.world)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen");
return;
}
@ -37,7 +37,7 @@ public class DetonatorListener implements Listener {
if (detoloader == null) {
return;
} else if (detoloader.activation == -1) {
print(player, detoloader.getBlock(), detoloader.addBack?Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size():0);
print(player, detoloader.getBlock(), detoloader.addBack ? Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() : 0);
return;
}
@ -50,7 +50,7 @@ public class DetonatorListener implements Listener {
player.getInventory().setItemInMainHand(Detonator.setLocation(player, item, new Detoloader.DetonatorActivation(detoloader.activation, event.getClickedBlock().getLocation())));
}
print(player, detoloader.addBack ? "§e" + detoloader.getBlock() + " gesetzt" :
detoloader.getBlock(), detoloader.addBack?Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size():0);
detoloader.getBlock(), detoloader.addBack ? Detonator.getDetonator(player, player.getInventory().getItemInMainHand()).getLocs().size() : 0);
}
break;
case RIGHT_CLICK_AIR:
@ -58,7 +58,7 @@ public class DetonatorListener implements Listener {
Detonator.execute(player);
break;
}
}catch (RuntimeException e) {
} catch (RuntimeException e) {
player.sendMessage(BauSystem.PREFIX + "§c" + e.getMessage());
player.getInventory().setItemInMainHand(item);
}
@ -68,7 +68,7 @@ public class DetonatorListener implements Listener {
public static void print(Player player, String message, int size) {
if (size == 0) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
}else {
} else {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + size));
}
}

Datei anzeigen

@ -23,10 +23,10 @@ public class PredefinedBook {
}
public static List<PredefinedBook> getBooks() {
if(bookCache != null)
if (bookCache != null)
return bookCache;
List<PredefinedBook> books = new ArrayList<>();
for (String book:configuration.getKeys(false)) {
for (String book : configuration.getKeys(false)) {
ConfigurationSection section = Objects.requireNonNull(configuration.getConfigurationSection(book));
books.add(new PredefinedBook(section));
}
@ -38,7 +38,7 @@ public class PredefinedBook {
return configuration.getKeys(false).size();
}
private List<String> lines;
private List<String> lines;
private List<String> lore;
private String author;
private String name;
@ -52,7 +52,7 @@ public class PredefinedBook {
}
public ItemStack toItemStack() {
if(finishedBook != null)
if (finishedBook != null)
return finishedBook;
ItemStack book = new ItemStack(getBookMat());
BookMeta meta = (BookMeta) book.getItemMeta();
@ -94,22 +94,22 @@ public class PredefinedBook {
int currentLine = 0;
int currentpage = 0;
boolean first = true;
for (String line:lines) {
for (String line : lines) {
int linesPlus = (int) Math.ceil((double) line.length() / charsPerLine);
currentLine += linesPlus;
if(currentLine >= 14 || line.equals("!")) {
if (currentLine >= 14 || line.equals("!")) {
currentLine = linesPlus;
currentpage++;
if(currentpage > 50)
if (currentpage > 50)
throw new IllegalStateException("Book " + name + " has more pages than 50");
pages.add(currentpage, new StringBuilder());
first = true;
if(line.equals("!"))
if (line.equals("!"))
continue;
}
if(!first) {
if (!first) {
pages.get(currentpage).append("\n");
}else {
} else {
first = false;
}
pages.get(currentpage).append(line);

Datei anzeigen

@ -42,7 +42,7 @@ public class Region {
private static boolean buildArea = false;
private static boolean extensionArea = false;
static{
static {
YamlConfiguration config = new YamlConfiguration();
try {
config.load(new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections.yml"));
@ -52,13 +52,13 @@ public class Region {
ConfigurationSection prototypes = config.getConfigurationSection("prototypes");
assert prototypes != null;
for(String prototype : prototypes.getKeys(false)){
for (String prototype : prototypes.getKeys(false)) {
new Prototype(Objects.requireNonNull(prototypes.getConfigurationSection(prototype)));
}
ConfigurationSection regions = config.getConfigurationSection("regions");
assert regions != null;
for(String region : regions.getKeys(false)){
for (String region : regions.getKeys(false)) {
new Region(Objects.requireNonNull(regions.getConfigurationSection(region)));
}
}
@ -90,7 +90,7 @@ public class Region {
private boolean freeze = false;
private boolean fire = false;
private Region(ConfigurationSection config){
private Region(ConfigurationSection config) {
name = config.getName();
minX = config.getInt("minX");
minY = config.getInt("minY");
@ -155,7 +155,7 @@ public class Region {
setLinkedRegion(region -> region.fire = fire);
}
public boolean inRegion(Location l){
public boolean inRegion(Location l) {
return prototype.inRegion(this, l);
}
@ -171,7 +171,7 @@ public class Region {
return prototype.buildArea.inRegionExtension(this, l);
}
public void fastreset(){
public void fastreset() {
prototype.fastreset(this);
}
@ -183,11 +183,11 @@ public class Region {
return prototype.hasTestblock();
}
public void resetTestblock(Schematic schem) throws IOException, NoClipboardException{
public void resetTestblock(Schematic schem) throws IOException, NoClipboardException {
prototype.resetTestblock(this, schem);
}
public boolean hasProtection(){
public boolean hasProtection() {
return prototype.hasProtection();
}
@ -250,7 +250,7 @@ public class Region {
}
}
public static class Prototype{
public static class Prototype {
private static final Map<String, Prototype> prototypes = new HashMap<>();
private final int sizeX;
@ -275,7 +275,7 @@ public class Region {
private final String protectSchematic; //nullable
private Prototype(ConfigurationSection config){
private Prototype(ConfigurationSection config) {
sizeX = config.getInt("sizeX");
sizeY = config.getInt("sizeY");
sizeZ = config.getInt("sizeZ");
@ -304,27 +304,27 @@ public class Region {
protectSchematic = config.getString("protection", null);
if(!config.getName().equals("testblock") && !config.getName().equals("buildArea"))
if (!config.getName().equals("testblock") && !config.getName().equals("buildArea"))
prototypes.put(config.getName(), this);
}
public boolean inRegion(Region region, Location l){
return inRange(l.getX(), region.minX + offsetX, sizeX) &&
public boolean inRegion(Region region, Location l) {
return inRange(l.getX(), region.minX + offsetX, sizeX) &&
inRange(l.getY(), region.minY + offsetY, sizeY) &&
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) &&
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(schematic);
int x = region.minX + offsetX + sizeX/2;
int x = region.minX + offsetX + sizeX / 2;
int y = region.minY + offsetY;
int z = region.minZ + offsetZ + sizeZ/2;
int z = region.minZ + offsetZ + sizeZ / 2;
VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(file, x, y, z, rotate), 8),
new VersionedRunnable(() -> Region_15.fastpaste(file, x, y, z, rotate), 15));
}
@ -333,7 +333,7 @@ public class Region {
int x = region.minX + offsetX + sizeX / 2;
int y = region.minY + offsetY;
int z = region.minZ + offsetZ + sizeZ / 2;
if(schem == null)
if (schem == null)
paste(new File(schematic), x, y, z, rotate);
else
paste(schem.load(), x, y, z, rotate);
@ -347,7 +347,7 @@ public class Region {
int x = region.minX + offsetX + sizeX / 2;
int y = region.minY + testblock.offsetY - 1;
int z = region.minZ + offsetZ + sizeZ / 2;
if(schem == null)
if (schem == null)
paste(new File(protectSchematic), x, y, z, rotate);
else
paste(schem.load(), x, y, z, rotate);
@ -361,16 +361,16 @@ public class Region {
testblock.reset(region, schem);
}
private static boolean inRange(double l, int min, int size){
private static boolean inRange(double l, int min, int size) {
return min <= l && l <= min + size;
}
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
VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(file, x, y, z, rotate), 8),
new VersionedRunnable(() -> Region_15.paste(file, x, y, z, rotate), 15));
}
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) {
VersionedRunnable.call(new VersionedRunnable(() -> Region_12.paste(clipboard, x, y, z, rotate), 8),
new VersionedRunnable(() -> Region_15.paste(clipboard, x, y, z, rotate), 15));
}

Datei anzeigen

@ -53,7 +53,7 @@ public class RegionListener implements Listener {
Player p = e.getPlayer();
if (Welt.noPermission(p, Permission.worldedit)){
if (Welt.noPermission(p, Permission.worldedit)) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier kein WorldEdit benutzen");
e.setCancelled(true);
}
@ -63,7 +63,7 @@ public class RegionListener implements Listener {
public void onBlockBreak(BlockBreakEvent e) {
Player p = e.getPlayer();
if (Welt.noPermission(p, Permission.build)){
if (Welt.noPermission(p, Permission.build)) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke abbauen");
e.setCancelled(true);
}
@ -74,12 +74,12 @@ public class RegionListener implements Listener {
if (Core.getVersion() == 12) return;
Player p = e.getPlayer();
try{
if (Welt.noPermission(p, Permission.build)){
try {
if (Welt.noPermission(p, Permission.build)) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren");
e.setBuildable(false);
}
}catch(NullPointerException ex){
} catch (NullPointerException ex) {
//ignored, caused by worldedit brushes
}
}
@ -89,12 +89,12 @@ public class RegionListener implements Listener {
if (Core.getVersion() == 15) return;
Player p = e.getPlayer();
try{
if (Welt.noPermission(p, Permission.build)){
try {
if (Welt.noPermission(p, Permission.build)) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine Blöcke platzieren");
e.setCancelled(true);
}
}catch(NullPointerException ex){
} catch (NullPointerException ex) {
//ignored, caused by worldedit brushes
}
}
@ -102,8 +102,8 @@ public class RegionListener implements Listener {
private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"};
private boolean isWorldEditCommand(String command) {
for(String shortcut : shortcutCommands)
if(command.startsWith(shortcut))
for (String shortcut : shortcutCommands)
if (command.startsWith(shortcut))
return true;
return VersionedCallable.call(new VersionedCallable<>(() -> RegionListener_12.isWorldEditCommand(command), 8),
@ -112,9 +112,9 @@ public class RegionListener implements Listener {
@EventHandler
public void onSignChange(SignChangeEvent event) {
for(int i = 0; i <= 3; ++i) {
for (int i = 0; i <= 3; ++i) {
String line = event.getLine(i);
if(line == null)
if (line == null)
continue;
line = ChatColor.translateAlternateColorCodes('&', line);
event.setLine(i, line);
@ -123,7 +123,7 @@ public class RegionListener implements Listener {
@EventHandler
public void editSign(PlayerInteractEvent event) {
if(event.getAction() != Action.RIGHT_CLICK_BLOCK ||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK ||
!event.getClickedBlock().getType().name().contains("SIGN") ||
!event.getPlayer().isSneaking() ||
(event.getItem() != null && event.getItem().getType() != Material.AIR))
@ -143,7 +143,7 @@ public class RegionListener implements Listener {
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(BauSystem.getPlugin(), PacketType.Play.Client.UPDATE_SIGN) {
@Override
public void onPacketReceiving(PacketEvent event) {
if(!event.getPlayer().equals(player))
if (!event.getPlayer().equals(player))
return;
Bukkit.getScheduler().runTask(BauSystem.getPlugin(), () -> {
PacketContainer packetContainer = event.getPacket();
@ -151,7 +151,7 @@ public class RegionListener implements Listener {
String[] lines = packetContainer.getStringArrays().read(0);
Block signLoc = position.toLocation(player.getWorld()).getBlock();
if(!signLoc.getType().name().contains("SIGN"))
if (!signLoc.getType().name().contains("SIGN"))
return;
Sign sign = ((Sign) signLoc.getState());

Datei anzeigen

@ -53,7 +53,7 @@ public class ScriptListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onLeftClick(PlayerInteractEvent event) {
ItemStack item = event.getItem();
if(item == null || isNoBook(item) || item.getItemMeta() == null)
if (item == null || isNoBook(item) || item.getItemMeta() == null)
return;
if (CommandScript.BOOK.getItemMeta() != null && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equals(CommandScript.BOOK.getItemMeta().getDisplayName())) {
@ -74,7 +74,7 @@ public class ScriptListener implements Listener {
new ScriptExecutor((BookMeta) item.getItemMeta(), event.getPlayer());
}
private boolean isNoBook(ItemStack item){
private boolean isNoBook(ItemStack item) {
return VersionedCallable.call(new VersionedCallable<>(() -> ScriptListener_12.isNoBook(item), 8),
new VersionedCallable<>(() -> ScriptListener_15.isNoBook(item), 15));
}
@ -91,7 +91,7 @@ public class ScriptListener implements Listener {
public ScriptExecutor(BookMeta bookMeta, Player player) {
this.player = player;
for(String page : bookMeta.getPages()) {
for (String page : bookMeta.getPages()) {
for (String command : page.split("\n")) {
if (command.startsWith("#") || command.trim().isEmpty()) continue;
if (command.startsWith(".")) {
@ -291,7 +291,7 @@ public class ScriptListener implements Listener {
int jumpTruePoint = scriptExecutor.jumpPoints.getOrDefault(args[2], -1);
int jumpFalsePoint = args.length > 3 ? scriptExecutor.jumpPoints.getOrDefault(args[3], -1) : -1;
int firstValue = getValueOrParse(scriptExecutor, args[0]);
int secondValue = getValueOrParse(scriptExecutor, args[1]);
if (firstValue == secondValue) {
@ -428,7 +428,7 @@ public class ScriptListener implements Listener {
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
return 0;
return 0;
}
}

Datei anzeigen

@ -312,7 +312,7 @@ public class TNTSimulator {
}
private static double clamp(double d) {
return (int)(d * 10000) * 0.0001;
return (int) (d * 10000) * 0.0001;
}
public void delete() {

Datei anzeigen

@ -58,7 +58,8 @@ public class TPSUtils {
}
public static double getTps(TPSWatcher.TPSType tpsType) {
if (TPSUtils.isWarping()) return TPSWatcher.getTPS(tpsType, Math.max(CommandTPSLimiter.getCurrentTPSLimit(), 20));
if (TPSUtils.isWarping())
return TPSWatcher.getTPS(tpsType, Math.max(CommandTPSLimiter.getCurrentTPSLimit(), 20));
return TPSWatcher.getTPS(tpsType);
}

Datei anzeigen

@ -28,17 +28,18 @@ import org.bukkit.entity.Player;
public class Welt {
private Welt(){}
private Welt() {
}
public static boolean noPermission(Player member, Permission perm){
if(member.getUniqueId().equals(BauSystem.getOwner()))
public static boolean noPermission(Player member, Permission perm) {
if (member.getUniqueId().equals(BauSystem.getOwner()))
return false;
BauweltMember member1 = BauweltMember.getBauMember(BauSystem.getOwner(), member.getUniqueId());
if(member1 == null)
if (member1 == null)
return true;
switch(perm){
switch (perm) {
case build:
return !member1.isBuild();
case worldedit:
@ -52,12 +53,12 @@ public class Welt {
}
}
private static void sendMessages(Player p, boolean ableTo, BauweltMember target, String what){
private static void sendMessages(Player p, boolean ableTo, BauweltMember target, String what) {
Player z = Bukkit.getPlayer(SteamwarUser.get(target.getMemberID()).getUUID());
if (z != null) {
if (ableTo) {
z.sendMessage(BauSystem.PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a " + what);
}else {
} else {
z.sendMessage(BauSystem.PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c " + what);
}
}
@ -68,17 +69,17 @@ public class Welt {
}
}
public static void toggleBuild(Player p, BauweltMember target){
public static void toggleBuild(Player p, BauweltMember target) {
target.setBuild(!target.isBuild());
sendMessages(p, target.isBuild(), target, "bauen");
}
public static void toggleWE(Player p, BauweltMember target){
public static void toggleWE(Player p, BauweltMember target) {
target.setWorldEdit(!target.isWorldEdit());
sendMessages(p, target.isWorldEdit(), target, "WorldEdit verwenden");
}
public static void toggleWorld(Player p, BauweltMember target){
public static void toggleWorld(Player p, BauweltMember target) {
target.setWorld(!target.isWorld());
sendMessages(p, target.isWorld(), target, "Einstellungen vornehmen");
}