Formatted code

This commit is contained in:
Stijn Bannink 2023-08-13 16:19:15 +02:00
parent c12af96b9a
commit 8fe6e6766a
24 changed files with 321 additions and 325 deletions

View file

@ -1,5 +1,10 @@
package tech.sbdevelopment.v10lift;
import lombok.Getter;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SingleLineChart;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import tech.sbdevelopment.v10lift.commands.V10LiftCommand;
import tech.sbdevelopment.v10lift.commands.V10LiftTabCompleter;
import tech.sbdevelopment.v10lift.listeners.BlockBreakListener;
@ -12,10 +17,6 @@ import tech.sbdevelopment.v10lift.managers.VaultManager;
import tech.sbdevelopment.v10lift.sbutils.ConfigUpdater;
import tech.sbdevelopment.v10lift.sbutils.UpdateManager;
import tech.sbdevelopment.v10lift.sbutils.YamlFile;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SingleLineChart;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException;
import java.sql.SQLException;
@ -23,9 +24,11 @@ import java.util.Collections;
public class V10LiftPlugin extends JavaPlugin {
@Getter
private static V10LiftPlugin instance;
private static YamlFile config;
private static DBManager dbManager;
@Getter
private static YamlFile messages;
private static boolean vault = false;
@ -129,10 +132,6 @@ public class V10LiftPlugin extends JavaPlugin {
instance = null;
}
public static V10LiftPlugin getInstance() {
return instance;
}
public static YamlFile getSConfig() {
return config;
}
@ -141,10 +140,6 @@ public class V10LiftPlugin extends JavaPlugin {
return dbManager;
}
public static YamlFile getMessages() {
return messages;
}
public static boolean isVaultEnabled() {
return vault;
}

View file

@ -1,6 +1,14 @@
package tech.sbdevelopment.v10lift.api;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import tech.sbdevelopment.v10lift.api.objects.*;
import tech.sbdevelopment.v10lift.api.runnables.DoorCloser;
@ -11,24 +19,18 @@ import tech.sbdevelopment.v10lift.sbutils.LocationSerializer;
import tech.sbdevelopment.v10lift.utils.ConfigUtil;
import tech.sbdevelopment.v10lift.utils.DirectionUtil;
import tech.sbdevelopment.v10lift.utils.DoorUtil;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import tech.sbdevelopment.v10lift.api.objects.*;
import javax.annotation.Nonnull;
import java.util.*;
/** The Main API class, for all the API methods */
/**
* The Main API class, for all the API methods
*/
public class V10LiftAPI {
private static V10LiftAPI instance;
private V10LiftAPI() {}
private V10LiftAPI() {
}
public static V10LiftAPI getInstance() {
if (instance == null) instance = new V10LiftAPI();
@ -504,8 +506,10 @@ public class V10LiftAPI {
* @return 0 if added, -1 if null or doesn't exists, -2 if height is to high, -3 if floor already exists
*/
public int addFloor(String liftName, String floorName, Floor floor) {
if (liftName == null || floorName == null || floor == null || !DataManager.containsLift(liftName) || floor.getWorld() == null) return -1;
if (floor.getY() > Objects.requireNonNull(Bukkit.getServer().getWorld(floor.getWorld()), "World is null at addNewFloor!").getMaxHeight()) return -2;
if (liftName == null || floorName == null || floor == null || !DataManager.containsLift(liftName) || floor.getWorld() == null)
return -1;
if (floor.getY() > Objects.requireNonNull(Bukkit.getServer().getWorld(floor.getWorld()), "World is null at addNewFloor!").getMaxHeight())
return -2;
if (floorName.length() > 13) floorName = floorName.substring(0, 13).trim();
Lift lift = DataManager.getLift(liftName);
if (lift.getFloors().containsKey(floorName) || lift.getFloors().containsValue(floor)) return -3;
@ -765,7 +769,6 @@ public class V10LiftAPI {
*
* @param liftName The name of the lift
* @param block The block
*
* @return true/false
*/
public boolean containsRope(String liftName, Block block) {
@ -792,7 +795,6 @@ public class V10LiftAPI {
* Check if a block is a rope
*
* @param b The block
*
* @return true/false
*/
public boolean isRope(Block b) {
@ -804,6 +806,7 @@ public class V10LiftAPI {
/**
* Send info about a lift to a player
*
* @param sender Where you want to send it to
* @param liftName The name of the lift
*/
@ -813,6 +816,7 @@ public class V10LiftAPI {
/**
* Send info about a lift to a player
*
* @param ent Where you want to send it to
* @param liftName The name of the lift
* @param lift The lift
@ -916,11 +920,11 @@ public class V10LiftAPI {
*
* @param lift The name of the lift
* @param block The block
*
* @return true/false
*/
public boolean removeRope(String lift, Block block) {
if (lift == null || block == null || !DataManager.containsLift(lift) || !containsRope(lift, block)) return false;
if (lift == null || block == null || !DataManager.containsLift(lift) || !containsRope(lift, block))
return false;
String world = block.getWorld().getName();
int x = block.getX();
@ -964,7 +968,6 @@ public class V10LiftAPI {
* @param lift The name of the lift
* @param y The y-pos
* @param world The world
*
* @return true/false
*/
public boolean addToQueue(String lift, int y, World world) {
@ -978,7 +981,6 @@ public class V10LiftAPI {
* @param y The y-pos
* @param world The world
* @param floorName The name of the flor
*
* @return true/false
*/
public boolean addToQueue(String lift, int y, @Nonnull World world, String floorName) {
@ -991,7 +993,6 @@ public class V10LiftAPI {
* @param lift The name of the lift
* @param floor The {@link Floor}
* @param floorName The name of the flor
*
* @return true/false
*/
public boolean addToQueue(String lift, Floor floor, String floorName) {

View file

@ -9,8 +9,13 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.UUID;
/** A floor object, for a floor in the lift. */
@Getter @Setter @NoArgsConstructor @ToString
/**
* A floor object, for a floor in the lift.
*/
@Getter
@Setter
@NoArgsConstructor
@ToString
public class Floor {
private String world;
private int y;

View file

@ -8,29 +8,45 @@ import tech.sbdevelopment.v10lift.api.runnables.DoorCloser;
import java.util.*;
/** A lift object, to create a lift. */
@NoArgsConstructor @ToString
/**
* A lift object, to create a lift.
*/
@Getter
@NoArgsConstructor
@ToString
public class Lift {
@Getter @Setter private String worldName;
@Getter @Setter private int y;
@Getter private HashSet<UUID> owners;
@Getter private final TreeSet<LiftBlock> blocks = new TreeSet<>();
@Getter private final LinkedHashMap<String, Floor> floors = new LinkedHashMap<>();
@Getter private final HashSet<LiftSign> signs = new HashSet<>();
@Getter private final HashSet<LiftBlock> inputs = new HashSet<>();
@Getter private final HashSet<LiftBlock> offlineInputs = new HashSet<>();
@Getter @Setter private LinkedHashMap<String, Floor> queue = null;
@Getter private final HashSet<LiftRope> ropes = new HashSet<>();
@Getter private transient final ArrayList<V10Entity> toMove = new ArrayList<>();
@Getter @Setter private int speed;
@Getter @Setter private boolean realistic;
@Getter @Setter private boolean offline = false;
@Getter @Setter private boolean sound = true;
@Getter @Setter private boolean defective = false;
@Getter @Setter private String signText = null;
@Getter @Setter private int counter = 0;
@Getter @Setter private Floor doorOpen = null;
@Getter @Setter private DoorCloser doorCloser = null;
@Setter
private String worldName;
@Setter
private int y;
private HashSet<UUID> owners;
private final TreeSet<LiftBlock> blocks = new TreeSet<>();
private final LinkedHashMap<String, Floor> floors = new LinkedHashMap<>();
private final HashSet<LiftSign> signs = new HashSet<>();
private final HashSet<LiftBlock> inputs = new HashSet<>();
private final HashSet<LiftBlock> offlineInputs = new HashSet<>();
@Setter
private LinkedHashMap<String, Floor> queue = null;
private final HashSet<LiftRope> ropes = new HashSet<>();
private transient final ArrayList<V10Entity> toMove = new ArrayList<>();
@Setter
private int speed;
@Setter
private boolean realistic;
@Setter
private boolean offline = false;
@Setter
private boolean sound = true;
@Setter
private boolean defective = false;
@Setter
private String signText = null;
@Setter
private int counter = 0;
@Setter
private Floor doorOpen = null;
@Setter
private DoorCloser doorCloser = null;
/**
* Construct a new Lift with multiple owners

View file

@ -3,33 +3,39 @@ package tech.sbdevelopment.v10lift.api.objects;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Map;
/** A liftblock object, for a block in a lift. */
/**
* A liftblock object, for a block in a lift.
*/
@Getter
@NoArgsConstructor
@ToString
public class LiftBlock implements Comparable<LiftBlock> {
@Getter @Setter private String world;
@Getter private int x;
@Getter @Setter private int y;
@Getter private int z;
private String world;
private int x;
@Setter
private int y;
private int z;
//Only used for cabine blocks, because those need caching!
@Getter @Setter private Material mat;
@Getter private byte data;
@Getter private BlockFace face;
@Getter private String bisected;
@Getter private String slabtype;
@Getter private String[] signLines;
@Setter
private Material mat;
private byte data;
private BlockFace face;
private String bisected;
private String slabtype;
private String[] signLines;
//Only used for inputs!
@Getter private String floor;
@Getter @Setter private boolean active = false;
private String floor;
@Setter
private boolean active = false;
//Only used for chests
public Map<String, Object>[] serializedItemStacks = null;
@ -264,22 +270,4 @@ public class LiftBlock implements Comparable<LiftBlock> {
result = prime * result + z;
return result;
}
@Override
public String toString() {
return "LiftBlock{" +
"world='" + world + '\'' +
", x=" + x +
", y=" + y +
", z=" + z +
", mat=" + mat +
", data=" + data +
", face=" + face +
", bisected='" + bisected + '\'' +
", signLines=" + Arrays.toString(signLines) +
", floor='" + floor + '\'' +
", active=" + active +
", serializedItemStacks=" + Arrays.toString(serializedItemStacks) +
'}';
}
}

View file

@ -3,13 +3,19 @@ package tech.sbdevelopment.v10lift.api.objects;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import java.util.Objects;
/** A liftrope object, for a rope in the lift. */
@Getter @Setter @NoArgsConstructor
/**
* A liftrope object, for a rope in the lift.
*/
@Getter
@Setter
@NoArgsConstructor
@ToString
public class LiftRope {
private Material type;
private BlockFace face;
@ -65,18 +71,4 @@ public class LiftRope {
result = prime * result + z;
return result;
}
@Override
public String toString() {
return "LiftRope{" +
"type=" + type +
", face=" + face +
", world='" + world + '\'' +
", x=" + x +
", minY=" + minY +
", maxY=" + maxY +
", z=" + z +
", currently=" + currently +
'}';
}
}

View file

@ -3,9 +3,15 @@ package tech.sbdevelopment.v10lift.api.objects;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
/** A liftsign object, for a info sign for the lift. */
@Getter @Setter @NoArgsConstructor
/**
* A liftsign object, for an info sign for the lift.
*/
@Getter
@Setter
@NoArgsConstructor
@ToString
public class LiftSign {
private String world;
private int x;
@ -63,17 +69,4 @@ public class LiftSign {
result = prime * result + z;
return result;
}
@Override
public String toString() {
return "LiftSign{" +
"world='" + world + '\'' +
", x=" + x +
", z=" + z +
", y=" + y +
", oldText='" + oldText + '\'' +
", type=" + type +
", state=" + state +
'}';
}
}

View file

@ -3,14 +3,19 @@ package tech.sbdevelopment.v10lift.api.objects;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import java.util.UUID;
/** A v10entity object, for a entity in the lift. */
@Getter @NoArgsConstructor
/**
* A v10entity object, for an entity in the lift.
*/
@Getter
@NoArgsConstructor
@ToString
public class V10Entity {
private UUID entityUUID;
private String world;
@ -18,7 +23,8 @@ public class V10Entity {
private int locY;
private int locZ;
private int y;
@Setter private short step;
@Setter
private short step;
/**
* Construct a new V10LiftEntity
@ -93,17 +99,4 @@ public class V10Entity {
public int hashCode() {
return 31 + ((entityUUID == null) ? 0 : entityUUID.hashCode());
}
@Override
public String toString() {
return "V10Entity{" +
"entityUUID=" + entityUUID +
", world='" + world + '\'' +
", locX=" + locX +
", locY=" + locY +
", locZ=" + locZ +
", y=" + y +
", step=" + step +
'}';
}
}

View file

@ -1,11 +1,13 @@
package tech.sbdevelopment.v10lift.api.runnables;
import org.bukkit.Bukkit;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
import tech.sbdevelopment.v10lift.managers.DataManager;
import org.bukkit.Bukkit;
/** The DoorCloser runnable, used for checking if the door can be closed. */
/**
* The DoorCloser runnable, used for checking if the door can be closed.
*/
public class DoorCloser implements Runnable {
private final String liftName;
private final int taskID;

View file

@ -2,6 +2,14 @@ package tech.sbdevelopment.v10lift.api.runnables;
import com.cryptomorin.xseries.XMaterial;
import com.cryptomorin.xseries.XSound;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.block.Sign;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
import tech.sbdevelopment.v10lift.api.enums.LiftDirection;
@ -11,22 +19,15 @@ import tech.sbdevelopment.v10lift.managers.DataManager;
import tech.sbdevelopment.v10lift.sbutils.LocationSerializer;
import tech.sbdevelopment.v10lift.utils.ConfigUtil;
import tech.sbdevelopment.v10lift.utils.DirectionUtil;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
import org.bukkit.block.Sign;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import tech.sbdevelopment.v10lift.api.objects.*;
import java.lang.reflect.Method;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.function.Supplier;
/** The MoveLift runnable, used for moving a lift. */
/**
* The MoveLift runnable, used for moving a lift.
*/
public class MoveLift implements Runnable {
/* Packet teleportation method */
private final Method[] methods = ((Supplier<Method[]>) () -> {
@ -250,7 +251,8 @@ public class MoveLift implements Runnable {
while (toMoveIterator.hasNext()) {
V10Entity v10ent = toMoveIterator.next();
if (v10ent.getStep() > 0) {
if (direction == LiftDirection.UP) v10ent.moveUp(); else v10ent.moveDown();
if (direction == LiftDirection.UP) v10ent.moveUp();
else v10ent.moveDown();
if (v10ent.getStep() > 16) {
toMoveIterator.remove();
}
@ -426,7 +428,8 @@ public class MoveLift implements Runnable {
if (lift.isRealistic()) lift.setCounter(ft);
if (lift.isSound() && block != null) XSound.ENTITY_EXPERIENCE_ORB_PICKUP.play(block.getLocation(), 2.0F, 63.0F);
if (lift.isSound() && block != null)
XSound.ENTITY_EXPERIENCE_ORB_PICKUP.play(block.getLocation(), 2.0F, 63.0F);
}
}

View file

@ -1,6 +1,15 @@
package tech.sbdevelopment.v10lift.commands;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
import tech.sbdevelopment.v10lift.api.objects.Floor;
@ -11,15 +20,6 @@ import tech.sbdevelopment.v10lift.managers.DataManager;
import tech.sbdevelopment.v10lift.managers.VaultManager;
import tech.sbdevelopment.v10lift.sbutils.LocationSerializer;
import tech.sbdevelopment.v10lift.utils.ConfigUtil;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import javax.annotation.Nonnull;
import java.sql.SQLException;

View file

@ -1,15 +1,15 @@
package tech.sbdevelopment.v10lift.commands;
import tech.sbdevelopment.v10lift.api.objects.Lift;
import tech.sbdevelopment.v10lift.managers.DataManager;
import tech.sbdevelopment.v10lift.managers.VaultManager;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import tech.sbdevelopment.v10lift.api.objects.Lift;
import tech.sbdevelopment.v10lift.managers.DataManager;
import tech.sbdevelopment.v10lift.managers.VaultManager;
import javax.annotation.Nonnull;
import java.util.ArrayList;
@ -21,6 +21,7 @@ public class V10LiftTabCompleter implements TabCompleter {
private static final List<String> COMMANDS = Arrays.asList("create", "delete", "rename", "abort", "whois", "edit", "floor", "input", "build", "rope", "door", "speed", "realistic", "repair", "disable", "whitelist", "reload", "help", "start", "stop", "offline");
private static final List<String> SUBRENAME = Arrays.asList("add", "del", "rename");
private static final List<String> SUB = Arrays.asList("add", "del");
@Override
public List<String> onTabComplete(@Nonnull CommandSender commandSender, @Nonnull Command cmd, @Nonnull String label, @Nonnull String[] args) {
if (label.equalsIgnoreCase("v10lift")) {

View file

@ -1,12 +1,5 @@
package tech.sbdevelopment.v10lift.listeners;
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
import tech.sbdevelopment.v10lift.api.objects.Floor;
import tech.sbdevelopment.v10lift.api.objects.Lift;
import tech.sbdevelopment.v10lift.api.objects.LiftBlock;
import tech.sbdevelopment.v10lift.managers.DataManager;
import tech.sbdevelopment.v10lift.utils.ConfigUtil;
import tech.sbdevelopment.v10lift.utils.DoorUtil;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
@ -14,6 +7,13 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
import tech.sbdevelopment.v10lift.api.objects.Floor;
import tech.sbdevelopment.v10lift.api.objects.Lift;
import tech.sbdevelopment.v10lift.api.objects.LiftBlock;
import tech.sbdevelopment.v10lift.managers.DataManager;
import tech.sbdevelopment.v10lift.utils.ConfigUtil;
import tech.sbdevelopment.v10lift.utils.DoorUtil;
import java.util.Map;
import java.util.Objects;

View file

@ -1,8 +1,5 @@
package tech.sbdevelopment.v10lift.listeners;
import tech.sbdevelopment.v10lift.api.objects.Lift;
import tech.sbdevelopment.v10lift.api.objects.LiftBlock;
import tech.sbdevelopment.v10lift.managers.DataManager;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -10,6 +7,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import tech.sbdevelopment.v10lift.api.objects.Lift;
import tech.sbdevelopment.v10lift.api.objects.LiftBlock;
import tech.sbdevelopment.v10lift.managers.DataManager;
public class EntityDamageListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)

View file

@ -1,16 +1,6 @@
package tech.sbdevelopment.v10lift.listeners;
import com.cryptomorin.xseries.XMaterial;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
import tech.sbdevelopment.v10lift.api.objects.Floor;
import tech.sbdevelopment.v10lift.api.objects.Lift;
import tech.sbdevelopment.v10lift.api.objects.LiftBlock;
import tech.sbdevelopment.v10lift.managers.DataManager;
import tech.sbdevelopment.v10lift.managers.ForbiddenBlockManager;
import tech.sbdevelopment.v10lift.managers.VaultManager;
import tech.sbdevelopment.v10lift.utils.ConfigUtil;
import tech.sbdevelopment.v10lift.utils.DoorUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@ -27,6 +17,16 @@ import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
import tech.sbdevelopment.v10lift.api.objects.Floor;
import tech.sbdevelopment.v10lift.api.objects.Lift;
import tech.sbdevelopment.v10lift.api.objects.LiftBlock;
import tech.sbdevelopment.v10lift.managers.DataManager;
import tech.sbdevelopment.v10lift.managers.ForbiddenBlockManager;
import tech.sbdevelopment.v10lift.managers.VaultManager;
import tech.sbdevelopment.v10lift.utils.ConfigUtil;
import tech.sbdevelopment.v10lift.utils.DoorUtil;
import java.util.*;
@ -104,7 +104,8 @@ public class PlayerInteractListener implements Listener {
return;
}
if (!lift.getBlocks().contains(new LiftBlock(sign.getWorld().getName(), sign.getX(), sign.getY(), sign.getZ(), (String) null))) return;
if (!lift.getBlocks().contains(new LiftBlock(sign.getWorld().getName(), sign.getX(), sign.getY(), sign.getZ(), (String) null)))
return;
if (DataManager.containsEditLift(liftName)) return;
e.setCancelled(true);
if (lift.isDefective()) return;
@ -367,7 +368,8 @@ public class PlayerInteractListener implements Listener {
return;
}
if (!lift.getBlocks().contains(new LiftBlock(sign.getWorld().getName(), sign.getX(), sign.getY(), sign.getZ(), (String) null))) return;
if (!lift.getBlocks().contains(new LiftBlock(sign.getWorld().getName(), sign.getX(), sign.getY(), sign.getZ(), (String) null)))
return;
if (DataManager.containsEditLift(liftName)) return;
e.setCancelled(true);
if (lift.isDefective()) return;

View file

@ -1,9 +1,5 @@
package tech.sbdevelopment.v10lift.listeners;
import tech.sbdevelopment.v10lift.api.objects.Lift;
import tech.sbdevelopment.v10lift.api.objects.LiftSign;
import tech.sbdevelopment.v10lift.managers.DataManager;
import tech.sbdevelopment.v10lift.utils.ConfigUtil;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -11,6 +7,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.SignChangeEvent;
import tech.sbdevelopment.v10lift.api.objects.Lift;
import tech.sbdevelopment.v10lift.api.objects.LiftSign;
import tech.sbdevelopment.v10lift.managers.DataManager;
import tech.sbdevelopment.v10lift.utils.ConfigUtil;
public class SignChangeListener implements Listener {

View file

@ -1,10 +1,10 @@
package tech.sbdevelopment.v10lift.managers;
import com.google.gson.Gson;
import org.bukkit.Bukkit;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import tech.sbdevelopment.v10lift.api.objects.Lift;
import tech.sbdevelopment.v10lift.sbutils.SQLiteDB;
import org.bukkit.Bukkit;
import java.sql.Connection;
import java.sql.PreparedStatement;
@ -130,7 +130,8 @@ public class DBManager {
statement.setString(1, liftName);
statement.setBytes(2, liftData);
statement.executeUpdate();
} catch (SQLException ignored) {}
} catch (SQLException ignored) {
}
try {
String query2 = "UPDATE lifts SET liftData = ? WHERE liftName = ?";

View file

@ -1,10 +1,10 @@
package tech.sbdevelopment.v10lift.managers;
import net.milkbowl.vault.permission.Permission;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import java.util.Arrays;
import java.util.HashSet;

View file

@ -19,11 +19,13 @@ import java.util.stream.Collectors;
* Read the new file and scan for comments and ignored sections, if ignored section is found it is treated as a comment.
* Read and write each line of the new config, if the old config has value for the given key it writes that value in the new config.
* If a key has an attached comment above it, it is written first.
*
* @author tchristofferson
*/
public class ConfigUpdater {
/**
* Update a yaml file from a resource inside your plugin jar
*
* @param plugin You plugin
* @param resourceName The yaml file name to update from, typically config.yml
* @param toUpdate The yaml file to update
@ -54,7 +56,8 @@ public class ConfigUpdater {
//Write method doing the work.
//It checks if key has a comment associated with it and writes comment then the key and value
private static void write(FileConfiguration newConfig, FileConfiguration oldConfig, Map<String, String> comments, List<String> ignoredSections, BufferedWriter writer, Yaml yaml) throws IOException {
outer: for (String key : newConfig.getKeys(true)) {
outer:
for (String key : newConfig.getKeys(true)) {
String[] keys = key.split("\\.");
String actualKey = keys[keys.length - 1];
String comment = comments.remove(key);
@ -173,7 +176,8 @@ public class ConfigUpdater {
StringBuilder keyBuilder = new StringBuilder();
int lastLineIndentCount = 0;
outer: for (int i = 0; i<lines.size(); i++) {
outer:
for (int i = 0; i < lines.size(); i++) {
String line = lines.get(i);
if (line != null && line.trim().startsWith("-"))
continue;
@ -228,7 +232,7 @@ public class ConfigUpdater {
} else if (value instanceof List) {
builder.append(getListAsString((List<?>) value, actualKey, prefixSpaces.toString(), yaml));
} else {
builder.append(prefixSpaces.toString()).append(actualKey).append(": ").append(yaml.dump(value));
builder.append(prefixSpaces).append(actualKey).append(": ").append(yaml.dump(value));
}
}
}

View file

@ -11,7 +11,6 @@ public class LocationSerializer {
* Deserialize a serialized location, without {@link Location#getYaw()} and {@link Location#getPitch()}
*
* @param string The location string
*
* @return The location or null if error
*/
@Nullable
@ -33,7 +32,6 @@ public class LocationSerializer {
* Deserialize a serialized location, with {@link Location#getYaw()} and {@link Location#getPitch()}
*
* @param string The location string
*
* @return The location or null if error
*/
@Nonnull
@ -55,7 +53,6 @@ public class LocationSerializer {
* Serialize a location, without {@link Location#getYaw()} and {@link Location#getPitch()}
*
* @param loc The location
*
* @return The serialized string
*/
@Nullable
@ -68,7 +65,6 @@ public class LocationSerializer {
* Serialize a location, with {@link Location#getYaw()} and {@link Location#getPitch()}
*
* @param loc The location
*
* @return The serialized string
*/
@Nullable

View file

@ -2,8 +2,8 @@ package tech.sbdevelopment.v10lift.sbutils;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import org.bukkit.Bukkit;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import java.io.File;
import java.io.IOException;
@ -63,7 +63,7 @@ public class SQLiteDB {
/**
* Get the connection, to execute queries
*
* <p>
* CREATE TABLE - execute()
* SELECT - executeQuery()
* UPDATE - executeUpdate()

View file

@ -1,9 +1,9 @@
package tech.sbdevelopment.v10lift.sbutils;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import java.io.File;
import java.io.IOException;

View file

@ -1,8 +1,8 @@
package tech.sbdevelopment.v10lift.utils;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import tech.sbdevelopment.v10lift.V10LiftPlugin;
import javax.annotation.Nonnull;
import java.util.HashMap;

View file

@ -14,12 +14,14 @@ public class DoorUtil {
/**
* Open a door, with 1.12.x- and 1.13.x+ support
*
* @param b The block (door)
* @return true if opened, false if not opened
*/
public static boolean openDoor(@Nonnull Block b) {
if (b.getType() == XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_IRON_DOOR_OPEN.play(b.getLocation());
if (b.getType().toString().contains("DOOR") && b.getType() != XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_WOODEN_DOOR_OPEN.play(b.getLocation());
if (b.getType().toString().contains("DOOR") && b.getType() != XMaterial.IRON_DOOR.parseMaterial())
XSound.BLOCK_WOODEN_DOOR_OPEN.play(b.getLocation());
if (b.getType().toString().contains("GATE")) XSound.BLOCK_FENCE_GATE_OPEN.play(b.getLocation());
if (XMaterial.supports(13)) {
//1.13+
@ -52,12 +54,14 @@ public class DoorUtil {
/**
* Close a door, with 1.12.x- and 1.13.x+ support
*
* @param b The block (door)
* @return true if opened, false if not opened
*/
public static boolean closeDoor(@Nonnull Block b) {
if (b.getType() == XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_IRON_DOOR_CLOSE.play(b.getLocation());
if (b.getType().toString().contains("DOOR") && b.getType() != XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_WOODEN_DOOR_CLOSE.play(b.getLocation());
if (b.getType().toString().contains("DOOR") && b.getType() != XMaterial.IRON_DOOR.parseMaterial())
XSound.BLOCK_WOODEN_DOOR_CLOSE.play(b.getLocation());
if (b.getType().toString().contains("GATE")) XSound.BLOCK_FENCE_GATE_CLOSE.play(b.getLocation());
if (XMaterial.supports(13)) {
//1.13+