Formatted code
This commit is contained in:
parent
c12af96b9a
commit
8fe6e6766a
24 changed files with 321 additions and 325 deletions
|
@ -1,5 +1,10 @@
|
||||||
package tech.sbdevelopment.v10lift;
|
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.V10LiftCommand;
|
||||||
import tech.sbdevelopment.v10lift.commands.V10LiftTabCompleter;
|
import tech.sbdevelopment.v10lift.commands.V10LiftTabCompleter;
|
||||||
import tech.sbdevelopment.v10lift.listeners.BlockBreakListener;
|
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.ConfigUpdater;
|
||||||
import tech.sbdevelopment.v10lift.sbutils.UpdateManager;
|
import tech.sbdevelopment.v10lift.sbutils.UpdateManager;
|
||||||
import tech.sbdevelopment.v10lift.sbutils.YamlFile;
|
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.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -23,9 +24,11 @@ import java.util.Collections;
|
||||||
|
|
||||||
public class V10LiftPlugin extends JavaPlugin {
|
public class V10LiftPlugin extends JavaPlugin {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static V10LiftPlugin instance;
|
private static V10LiftPlugin instance;
|
||||||
private static YamlFile config;
|
private static YamlFile config;
|
||||||
private static DBManager dbManager;
|
private static DBManager dbManager;
|
||||||
|
@Getter
|
||||||
private static YamlFile messages;
|
private static YamlFile messages;
|
||||||
private static boolean vault = false;
|
private static boolean vault = false;
|
||||||
|
|
||||||
|
@ -129,10 +132,6 @@ public class V10LiftPlugin extends JavaPlugin {
|
||||||
instance = null;
|
instance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static V10LiftPlugin getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static YamlFile getSConfig() {
|
public static YamlFile getSConfig() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@ -141,10 +140,6 @@ public class V10LiftPlugin extends JavaPlugin {
|
||||||
return dbManager;
|
return dbManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static YamlFile getMessages() {
|
|
||||||
return messages;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isVaultEnabled() {
|
public static boolean isVaultEnabled() {
|
||||||
return vault;
|
return vault;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
package tech.sbdevelopment.v10lift.api;
|
package tech.sbdevelopment.v10lift.api;
|
||||||
|
|
||||||
import com.cryptomorin.xseries.XMaterial;
|
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.V10LiftPlugin;
|
||||||
import tech.sbdevelopment.v10lift.api.objects.*;
|
import tech.sbdevelopment.v10lift.api.objects.*;
|
||||||
import tech.sbdevelopment.v10lift.api.runnables.DoorCloser;
|
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.ConfigUtil;
|
||||||
import tech.sbdevelopment.v10lift.utils.DirectionUtil;
|
import tech.sbdevelopment.v10lift.utils.DirectionUtil;
|
||||||
import tech.sbdevelopment.v10lift.utils.DoorUtil;
|
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 javax.annotation.Nonnull;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/** The Main API class, for all the API methods */
|
/**
|
||||||
|
* The Main API class, for all the API methods
|
||||||
|
*/
|
||||||
public class V10LiftAPI {
|
public class V10LiftAPI {
|
||||||
private static V10LiftAPI instance;
|
private static V10LiftAPI instance;
|
||||||
|
|
||||||
private V10LiftAPI() {}
|
private V10LiftAPI() {
|
||||||
|
}
|
||||||
|
|
||||||
public static V10LiftAPI getInstance() {
|
public static V10LiftAPI getInstance() {
|
||||||
if (instance == null) instance = new V10LiftAPI();
|
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
|
* @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) {
|
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 (liftName == null || floorName == null || floor == null || !DataManager.containsLift(liftName) || floor.getWorld() == null)
|
||||||
if (floor.getY() > Objects.requireNonNull(Bukkit.getServer().getWorld(floor.getWorld()), "World is null at addNewFloor!").getMaxHeight()) return -2;
|
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();
|
if (floorName.length() > 13) floorName = floorName.substring(0, 13).trim();
|
||||||
Lift lift = DataManager.getLift(liftName);
|
Lift lift = DataManager.getLift(liftName);
|
||||||
if (lift.getFloors().containsKey(floorName) || lift.getFloors().containsValue(floor)) return -3;
|
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 liftName The name of the lift
|
||||||
* @param block The block
|
* @param block The block
|
||||||
*
|
|
||||||
* @return true/false
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
public boolean containsRope(String liftName, Block block) {
|
public boolean containsRope(String liftName, Block block) {
|
||||||
|
@ -792,7 +795,6 @@ public class V10LiftAPI {
|
||||||
* Check if a block is a rope
|
* Check if a block is a rope
|
||||||
*
|
*
|
||||||
* @param b The block
|
* @param b The block
|
||||||
*
|
|
||||||
* @return true/false
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
public boolean isRope(Block b) {
|
public boolean isRope(Block b) {
|
||||||
|
@ -804,6 +806,7 @@ public class V10LiftAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send info about a lift to a player
|
* Send info about a lift to a player
|
||||||
|
*
|
||||||
* @param sender Where you want to send it to
|
* @param sender Where you want to send it to
|
||||||
* @param liftName The name of the lift
|
* @param liftName The name of the lift
|
||||||
*/
|
*/
|
||||||
|
@ -813,6 +816,7 @@ public class V10LiftAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send info about a lift to a player
|
* Send info about a lift to a player
|
||||||
|
*
|
||||||
* @param ent Where you want to send it to
|
* @param ent Where you want to send it to
|
||||||
* @param liftName The name of the lift
|
* @param liftName The name of the lift
|
||||||
* @param lift The lift
|
* @param lift The lift
|
||||||
|
@ -916,11 +920,11 @@ public class V10LiftAPI {
|
||||||
*
|
*
|
||||||
* @param lift The name of the lift
|
* @param lift The name of the lift
|
||||||
* @param block The block
|
* @param block The block
|
||||||
*
|
|
||||||
* @return true/false
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
public boolean removeRope(String lift, Block block) {
|
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();
|
String world = block.getWorld().getName();
|
||||||
int x = block.getX();
|
int x = block.getX();
|
||||||
|
@ -964,7 +968,6 @@ public class V10LiftAPI {
|
||||||
* @param lift The name of the lift
|
* @param lift The name of the lift
|
||||||
* @param y The y-pos
|
* @param y The y-pos
|
||||||
* @param world The world
|
* @param world The world
|
||||||
*
|
|
||||||
* @return true/false
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
public boolean addToQueue(String lift, int y, World world) {
|
public boolean addToQueue(String lift, int y, World world) {
|
||||||
|
@ -978,7 +981,6 @@ public class V10LiftAPI {
|
||||||
* @param y The y-pos
|
* @param y The y-pos
|
||||||
* @param world The world
|
* @param world The world
|
||||||
* @param floorName The name of the flor
|
* @param floorName The name of the flor
|
||||||
*
|
|
||||||
* @return true/false
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
public boolean addToQueue(String lift, int y, @Nonnull World world, String floorName) {
|
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 lift The name of the lift
|
||||||
* @param floor The {@link Floor}
|
* @param floor The {@link Floor}
|
||||||
* @param floorName The name of the flor
|
* @param floorName The name of the flor
|
||||||
*
|
|
||||||
* @return true/false
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
public boolean addToQueue(String lift, Floor floor, String floorName) {
|
public boolean addToQueue(String lift, Floor floor, String floorName) {
|
||||||
|
|
|
@ -9,8 +9,13 @@ import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
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 {
|
public class Floor {
|
||||||
private String world;
|
private String world;
|
||||||
private int y;
|
private int y;
|
||||||
|
|
|
@ -8,29 +8,45 @@ import tech.sbdevelopment.v10lift.api.runnables.DoorCloser;
|
||||||
|
|
||||||
import java.util.*;
|
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 {
|
public class Lift {
|
||||||
@Getter @Setter private String worldName;
|
@Setter
|
||||||
@Getter @Setter private int y;
|
private String worldName;
|
||||||
@Getter private HashSet<UUID> owners;
|
@Setter
|
||||||
@Getter private final TreeSet<LiftBlock> blocks = new TreeSet<>();
|
private int y;
|
||||||
@Getter private final LinkedHashMap<String, Floor> floors = new LinkedHashMap<>();
|
private HashSet<UUID> owners;
|
||||||
@Getter private final HashSet<LiftSign> signs = new HashSet<>();
|
private final TreeSet<LiftBlock> blocks = new TreeSet<>();
|
||||||
@Getter private final HashSet<LiftBlock> inputs = new HashSet<>();
|
private final LinkedHashMap<String, Floor> floors = new LinkedHashMap<>();
|
||||||
@Getter private final HashSet<LiftBlock> offlineInputs = new HashSet<>();
|
private final HashSet<LiftSign> signs = new HashSet<>();
|
||||||
@Getter @Setter private LinkedHashMap<String, Floor> queue = null;
|
private final HashSet<LiftBlock> inputs = new HashSet<>();
|
||||||
@Getter private final HashSet<LiftRope> ropes = new HashSet<>();
|
private final HashSet<LiftBlock> offlineInputs = new HashSet<>();
|
||||||
@Getter private transient final ArrayList<V10Entity> toMove = new ArrayList<>();
|
@Setter
|
||||||
@Getter @Setter private int speed;
|
private LinkedHashMap<String, Floor> queue = null;
|
||||||
@Getter @Setter private boolean realistic;
|
private final HashSet<LiftRope> ropes = new HashSet<>();
|
||||||
@Getter @Setter private boolean offline = false;
|
private transient final ArrayList<V10Entity> toMove = new ArrayList<>();
|
||||||
@Getter @Setter private boolean sound = true;
|
@Setter
|
||||||
@Getter @Setter private boolean defective = false;
|
private int speed;
|
||||||
@Getter @Setter private String signText = null;
|
@Setter
|
||||||
@Getter @Setter private int counter = 0;
|
private boolean realistic;
|
||||||
@Getter @Setter private Floor doorOpen = null;
|
@Setter
|
||||||
@Getter @Setter private DoorCloser doorCloser = null;
|
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
|
* Construct a new Lift with multiple owners
|
||||||
|
|
|
@ -3,33 +3,39 @@ package tech.sbdevelopment.v10lift.api.objects;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/** A liftblock object, for a block in a lift. */
|
/**
|
||||||
|
* A liftblock object, for a block in a lift.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
@ToString
|
||||||
public class LiftBlock implements Comparable<LiftBlock> {
|
public class LiftBlock implements Comparable<LiftBlock> {
|
||||||
|
private String world;
|
||||||
@Getter @Setter private String world;
|
private int x;
|
||||||
@Getter private int x;
|
@Setter
|
||||||
@Getter @Setter private int y;
|
private int y;
|
||||||
@Getter private int z;
|
private int z;
|
||||||
|
|
||||||
//Only used for cabine blocks, because those need caching!
|
//Only used for cabine blocks, because those need caching!
|
||||||
@Getter @Setter private Material mat;
|
@Setter
|
||||||
@Getter private byte data;
|
private Material mat;
|
||||||
@Getter private BlockFace face;
|
private byte data;
|
||||||
@Getter private String bisected;
|
private BlockFace face;
|
||||||
@Getter private String slabtype;
|
private String bisected;
|
||||||
@Getter private String[] signLines;
|
private String slabtype;
|
||||||
|
private String[] signLines;
|
||||||
|
|
||||||
//Only used for inputs!
|
//Only used for inputs!
|
||||||
@Getter private String floor;
|
private String floor;
|
||||||
@Getter @Setter private boolean active = false;
|
@Setter
|
||||||
|
private boolean active = false;
|
||||||
|
|
||||||
//Only used for chests
|
//Only used for chests
|
||||||
public Map<String, Object>[] serializedItemStacks = null;
|
public Map<String, Object>[] serializedItemStacks = null;
|
||||||
|
@ -264,22 +270,4 @@ public class LiftBlock implements Comparable<LiftBlock> {
|
||||||
result = prime * result + z;
|
result = prime * result + z;
|
||||||
return result;
|
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) +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,19 @@ package tech.sbdevelopment.v10lift.api.objects;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
import java.util.Objects;
|
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 {
|
public class LiftRope {
|
||||||
private Material type;
|
private Material type;
|
||||||
private BlockFace face;
|
private BlockFace face;
|
||||||
|
@ -65,18 +71,4 @@ public class LiftRope {
|
||||||
result = prime * result + z;
|
result = prime * result + z;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "LiftRope{" +
|
|
||||||
"type=" + type +
|
|
||||||
", face=" + face +
|
|
||||||
", world='" + world + '\'' +
|
|
||||||
", x=" + x +
|
|
||||||
", minY=" + minY +
|
|
||||||
", maxY=" + maxY +
|
|
||||||
", z=" + z +
|
|
||||||
", currently=" + currently +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,15 @@ package tech.sbdevelopment.v10lift.api.objects;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
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 {
|
public class LiftSign {
|
||||||
private String world;
|
private String world;
|
||||||
private int x;
|
private int x;
|
||||||
|
@ -63,17 +69,4 @@ public class LiftSign {
|
||||||
result = prime * result + z;
|
result = prime * result + z;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "LiftSign{" +
|
|
||||||
"world='" + world + '\'' +
|
|
||||||
", x=" + x +
|
|
||||||
", z=" + z +
|
|
||||||
", y=" + y +
|
|
||||||
", oldText='" + oldText + '\'' +
|
|
||||||
", type=" + type +
|
|
||||||
", state=" + state +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,19 @@ package tech.sbdevelopment.v10lift.api.objects;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
import java.util.UUID;
|
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 {
|
public class V10Entity {
|
||||||
private UUID entityUUID;
|
private UUID entityUUID;
|
||||||
private String world;
|
private String world;
|
||||||
|
@ -18,7 +23,8 @@ public class V10Entity {
|
||||||
private int locY;
|
private int locY;
|
||||||
private int locZ;
|
private int locZ;
|
||||||
private int y;
|
private int y;
|
||||||
@Setter private short step;
|
@Setter
|
||||||
|
private short step;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new V10LiftEntity
|
* Construct a new V10LiftEntity
|
||||||
|
@ -93,17 +99,4 @@ public class V10Entity {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return 31 + ((entityUUID == null) ? 0 : entityUUID.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 +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package tech.sbdevelopment.v10lift.api.runnables;
|
package tech.sbdevelopment.v10lift.api.runnables;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import tech.sbdevelopment.v10lift.V10LiftPlugin;
|
import tech.sbdevelopment.v10lift.V10LiftPlugin;
|
||||||
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
|
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
|
||||||
import tech.sbdevelopment.v10lift.managers.DataManager;
|
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 {
|
public class DoorCloser implements Runnable {
|
||||||
private final String liftName;
|
private final String liftName;
|
||||||
private final int taskID;
|
private final int taskID;
|
||||||
|
|
|
@ -2,6 +2,14 @@ package tech.sbdevelopment.v10lift.api.runnables;
|
||||||
|
|
||||||
import com.cryptomorin.xseries.XMaterial;
|
import com.cryptomorin.xseries.XMaterial;
|
||||||
import com.cryptomorin.xseries.XSound;
|
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.V10LiftPlugin;
|
||||||
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
|
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
|
||||||
import tech.sbdevelopment.v10lift.api.enums.LiftDirection;
|
import tech.sbdevelopment.v10lift.api.enums.LiftDirection;
|
||||||
|
@ -11,28 +19,21 @@ import tech.sbdevelopment.v10lift.managers.DataManager;
|
||||||
import tech.sbdevelopment.v10lift.sbutils.LocationSerializer;
|
import tech.sbdevelopment.v10lift.sbutils.LocationSerializer;
|
||||||
import tech.sbdevelopment.v10lift.utils.ConfigUtil;
|
import tech.sbdevelopment.v10lift.utils.ConfigUtil;
|
||||||
import tech.sbdevelopment.v10lift.utils.DirectionUtil;
|
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.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.function.Supplier;
|
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 {
|
public class MoveLift implements Runnable {
|
||||||
/* Packet teleportation method */
|
/* Packet teleportation method */
|
||||||
private final Method[] methods = ((Supplier<Method[]>) () -> {
|
private final Method[] methods = ((Supplier<Method[]>) () -> {
|
||||||
try {
|
try {
|
||||||
Method getHandle = Class.forName(Bukkit.getServer().getClass().getPackage().getName() + ".entity.CraftEntity").getDeclaredMethod("getHandle");
|
Method getHandle = Class.forName(Bukkit.getServer().getClass().getPackage().getName() + ".entity.CraftEntity").getDeclaredMethod("getHandle");
|
||||||
return new Method[] {
|
return new Method[]{
|
||||||
getHandle, getHandle.getReturnType().getDeclaredMethod("setPositionRotation", double.class, double.class, double.class, float.class, float.class)
|
getHandle, getHandle.getReturnType().getDeclaredMethod("setPositionRotation", double.class, double.class, double.class, float.class, float.class)
|
||||||
};
|
};
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -250,7 +251,8 @@ public class MoveLift implements Runnable {
|
||||||
while (toMoveIterator.hasNext()) {
|
while (toMoveIterator.hasNext()) {
|
||||||
V10Entity v10ent = toMoveIterator.next();
|
V10Entity v10ent = toMoveIterator.next();
|
||||||
if (v10ent.getStep() > 0) {
|
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) {
|
if (v10ent.getStep() > 16) {
|
||||||
toMoveIterator.remove();
|
toMoveIterator.remove();
|
||||||
}
|
}
|
||||||
|
@ -426,7 +428,8 @@ public class MoveLift implements Runnable {
|
||||||
|
|
||||||
if (lift.isRealistic()) lift.setCounter(ft);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
package tech.sbdevelopment.v10lift.commands;
|
package tech.sbdevelopment.v10lift.commands;
|
||||||
|
|
||||||
import com.cryptomorin.xseries.XMaterial;
|
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.V10LiftPlugin;
|
||||||
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
|
import tech.sbdevelopment.v10lift.api.V10LiftAPI;
|
||||||
import tech.sbdevelopment.v10lift.api.objects.Floor;
|
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.managers.VaultManager;
|
||||||
import tech.sbdevelopment.v10lift.sbutils.LocationSerializer;
|
import tech.sbdevelopment.v10lift.sbutils.LocationSerializer;
|
||||||
import tech.sbdevelopment.v10lift.utils.ConfigUtil;
|
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 javax.annotation.Nonnull;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package tech.sbdevelopment.v10lift.commands;
|
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.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.StringUtil;
|
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 javax.annotation.Nonnull;
|
||||||
import java.util.ArrayList;
|
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> 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> SUBRENAME = Arrays.asList("add", "del", "rename");
|
||||||
private static final List<String> SUB = Arrays.asList("add", "del");
|
private static final List<String> SUB = Arrays.asList("add", "del");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(@Nonnull CommandSender commandSender, @Nonnull Command cmd, @Nonnull String label, @Nonnull String[] args) {
|
public List<String> onTabComplete(@Nonnull CommandSender commandSender, @Nonnull Command cmd, @Nonnull String label, @Nonnull String[] args) {
|
||||||
if (label.equalsIgnoreCase("v10lift")) {
|
if (label.equalsIgnoreCase("v10lift")) {
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
package tech.sbdevelopment.v10lift.listeners;
|
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.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
|
@ -14,6 +7,13 @@ import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.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.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package tech.sbdevelopment.v10lift.listeners;
|
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.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
@ -10,6 +7,9 @@ import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
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 {
|
public class EntityDamageListener implements Listener {
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
|
|
@ -1,16 +1,6 @@
|
||||||
package tech.sbdevelopment.v10lift.listeners;
|
package tech.sbdevelopment.v10lift.listeners;
|
||||||
|
|
||||||
import com.cryptomorin.xseries.XMaterial;
|
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.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
@ -27,6 +17,16 @@ import org.bukkit.event.player.PlayerAnimationEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
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.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -104,7 +104,8 @@ public class PlayerInteractListener implements Listener {
|
||||||
return;
|
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;
|
if (DataManager.containsEditLift(liftName)) return;
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
if (lift.isDefective()) return;
|
if (lift.isDefective()) return;
|
||||||
|
@ -367,7 +368,8 @@ public class PlayerInteractListener implements Listener {
|
||||||
return;
|
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;
|
if (DataManager.containsEditLift(liftName)) return;
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
if (lift.isDefective()) return;
|
if (lift.isDefective()) return;
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package tech.sbdevelopment.v10lift.listeners;
|
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.ChatColor;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -11,6 +7,10 @@ import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
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 {
|
public class SignChangeListener implements Listener {
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package tech.sbdevelopment.v10lift.managers;
|
package tech.sbdevelopment.v10lift.managers;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import tech.sbdevelopment.v10lift.V10LiftPlugin;
|
import tech.sbdevelopment.v10lift.V10LiftPlugin;
|
||||||
import tech.sbdevelopment.v10lift.api.objects.Lift;
|
import tech.sbdevelopment.v10lift.api.objects.Lift;
|
||||||
import tech.sbdevelopment.v10lift.sbutils.SQLiteDB;
|
import tech.sbdevelopment.v10lift.sbutils.SQLiteDB;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
@ -130,7 +130,8 @@ public class DBManager {
|
||||||
statement.setString(1, liftName);
|
statement.setString(1, liftName);
|
||||||
statement.setBytes(2, liftData);
|
statement.setBytes(2, liftData);
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
} catch (SQLException ignored) {}
|
} catch (SQLException ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String query2 = "UPDATE lifts SET liftData = ? WHERE liftName = ?";
|
String query2 = "UPDATE lifts SET liftData = ? WHERE liftName = ?";
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package tech.sbdevelopment.v10lift.managers;
|
package tech.sbdevelopment.v10lift.managers;
|
||||||
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
import tech.sbdevelopment.v10lift.V10LiftPlugin;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import tech.sbdevelopment.v10lift.V10LiftPlugin;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
|
@ -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 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.
|
* 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.
|
* If a key has an attached comment above it, it is written first.
|
||||||
|
*
|
||||||
* @author tchristofferson
|
* @author tchristofferson
|
||||||
*/
|
*/
|
||||||
public class ConfigUpdater {
|
public class ConfigUpdater {
|
||||||
/**
|
/**
|
||||||
* Update a yaml file from a resource inside your plugin jar
|
* Update a yaml file from a resource inside your plugin jar
|
||||||
|
*
|
||||||
* @param plugin You plugin
|
* @param plugin You plugin
|
||||||
* @param resourceName The yaml file name to update from, typically config.yml
|
* @param resourceName The yaml file name to update from, typically config.yml
|
||||||
* @param toUpdate The yaml file to update
|
* @param toUpdate The yaml file to update
|
||||||
|
@ -54,7 +56,8 @@ public class ConfigUpdater {
|
||||||
//Write method doing the work.
|
//Write method doing the work.
|
||||||
//It checks if key has a comment associated with it and writes comment then the key and value
|
//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 {
|
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[] keys = key.split("\\.");
|
||||||
String actualKey = keys[keys.length - 1];
|
String actualKey = keys[keys.length - 1];
|
||||||
String comment = comments.remove(key);
|
String comment = comments.remove(key);
|
||||||
|
@ -173,7 +176,8 @@ public class ConfigUpdater {
|
||||||
StringBuilder keyBuilder = new StringBuilder();
|
StringBuilder keyBuilder = new StringBuilder();
|
||||||
int lastLineIndentCount = 0;
|
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);
|
String line = lines.get(i);
|
||||||
if (line != null && line.trim().startsWith("-"))
|
if (line != null && line.trim().startsWith("-"))
|
||||||
continue;
|
continue;
|
||||||
|
@ -228,7 +232,7 @@ public class ConfigUpdater {
|
||||||
} else if (value instanceof List) {
|
} else if (value instanceof List) {
|
||||||
builder.append(getListAsString((List<?>) value, actualKey, prefixSpaces.toString(), yaml));
|
builder.append(getListAsString((List<?>) value, actualKey, prefixSpaces.toString(), yaml));
|
||||||
} else {
|
} else {
|
||||||
builder.append(prefixSpaces.toString()).append(actualKey).append(": ").append(yaml.dump(value));
|
builder.append(prefixSpaces).append(actualKey).append(": ").append(yaml.dump(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,12 +243,12 @@ public class ConfigUpdater {
|
||||||
int currentSpaces = getSpaces(lines.get(index));
|
int currentSpaces = getSpaces(lines.get(index));
|
||||||
int indents = 0;
|
int indents = 0;
|
||||||
|
|
||||||
for (int i = index-1; i >= 0; i--){
|
for (int i = index - 1; i >= 0; i--) {
|
||||||
String line = lines.get(i);
|
String line = lines.get(i);
|
||||||
if (line == null || line.trim().equals("")) continue;
|
if (line == null || line.trim().equals("")) continue;
|
||||||
int newSpaces = getSpaces(lines.get(i));
|
int newSpaces = getSpaces(lines.get(i));
|
||||||
// differs at least two
|
// differs at least two
|
||||||
if (newSpaces < currentSpaces - 1){
|
if (newSpaces < currentSpaces - 1) {
|
||||||
indents++;
|
indents++;
|
||||||
currentSpaces = newSpaces;
|
currentSpaces = newSpaces;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +257,7 @@ public class ConfigUpdater {
|
||||||
return indents;
|
return indents;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getSpaces(String line){
|
private static int getSpaces(String line) {
|
||||||
int spaces = 0;
|
int spaces = 0;
|
||||||
for (char c : line.toCharArray()) {
|
for (char c : line.toCharArray()) {
|
||||||
if (c == ' ') {
|
if (c == ' ') {
|
||||||
|
|
|
@ -11,7 +11,6 @@ public class LocationSerializer {
|
||||||
* Deserialize a serialized location, without {@link Location#getYaw()} and {@link Location#getPitch()}
|
* Deserialize a serialized location, without {@link Location#getYaw()} and {@link Location#getPitch()}
|
||||||
*
|
*
|
||||||
* @param string The location string
|
* @param string The location string
|
||||||
*
|
|
||||||
* @return The location or null if error
|
* @return The location or null if error
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -33,7 +32,6 @@ public class LocationSerializer {
|
||||||
* Deserialize a serialized location, with {@link Location#getYaw()} and {@link Location#getPitch()}
|
* Deserialize a serialized location, with {@link Location#getYaw()} and {@link Location#getPitch()}
|
||||||
*
|
*
|
||||||
* @param string The location string
|
* @param string The location string
|
||||||
*
|
|
||||||
* @return The location or null if error
|
* @return The location or null if error
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -55,7 +53,6 @@ public class LocationSerializer {
|
||||||
* Serialize a location, without {@link Location#getYaw()} and {@link Location#getPitch()}
|
* Serialize a location, without {@link Location#getYaw()} and {@link Location#getPitch()}
|
||||||
*
|
*
|
||||||
* @param loc The location
|
* @param loc The location
|
||||||
*
|
|
||||||
* @return The serialized string
|
* @return The serialized string
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -68,7 +65,6 @@ public class LocationSerializer {
|
||||||
* Serialize a location, with {@link Location#getYaw()} and {@link Location#getPitch()}
|
* Serialize a location, with {@link Location#getYaw()} and {@link Location#getPitch()}
|
||||||
*
|
*
|
||||||
* @param loc The location
|
* @param loc The location
|
||||||
*
|
|
||||||
* @return The serialized string
|
* @return The serialized string
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -2,8 +2,8 @@ package tech.sbdevelopment.v10lift.sbutils;
|
||||||
|
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import tech.sbdevelopment.v10lift.V10LiftPlugin;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import tech.sbdevelopment.v10lift.V10LiftPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -63,7 +63,7 @@ public class SQLiteDB {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the connection, to execute queries
|
* Get the connection, to execute queries
|
||||||
*
|
* <p>
|
||||||
* CREATE TABLE - execute()
|
* CREATE TABLE - execute()
|
||||||
* SELECT - executeQuery()
|
* SELECT - executeQuery()
|
||||||
* UPDATE - executeUpdate()
|
* UPDATE - executeUpdate()
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package tech.sbdevelopment.v10lift.sbutils;
|
package tech.sbdevelopment.v10lift.sbutils;
|
||||||
|
|
||||||
import tech.sbdevelopment.v10lift.V10LiftPlugin;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import tech.sbdevelopment.v10lift.V10LiftPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package tech.sbdevelopment.v10lift.utils;
|
package tech.sbdevelopment.v10lift.utils;
|
||||||
|
|
||||||
import tech.sbdevelopment.v10lift.V10LiftPlugin;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import tech.sbdevelopment.v10lift.V10LiftPlugin;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
|
@ -14,12 +14,14 @@ public class DoorUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a door, with 1.12.x- and 1.13.x+ support
|
* Open a door, with 1.12.x- and 1.13.x+ support
|
||||||
|
*
|
||||||
* @param b The block (door)
|
* @param b The block (door)
|
||||||
* @return true if opened, false if not opened
|
* @return true if opened, false if not opened
|
||||||
*/
|
*/
|
||||||
public static boolean openDoor(@Nonnull Block b) {
|
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() == 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 (b.getType().toString().contains("GATE")) XSound.BLOCK_FENCE_GATE_OPEN.play(b.getLocation());
|
||||||
if (XMaterial.supports(13)) {
|
if (XMaterial.supports(13)) {
|
||||||
//1.13+
|
//1.13+
|
||||||
|
@ -52,12 +54,14 @@ public class DoorUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close a door, with 1.12.x- and 1.13.x+ support
|
* Close a door, with 1.12.x- and 1.13.x+ support
|
||||||
|
*
|
||||||
* @param b The block (door)
|
* @param b The block (door)
|
||||||
* @return true if opened, false if not opened
|
* @return true if opened, false if not opened
|
||||||
*/
|
*/
|
||||||
public static boolean closeDoor(@Nonnull Block b) {
|
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() == 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 (b.getType().toString().contains("GATE")) XSound.BLOCK_FENCE_GATE_CLOSE.play(b.getLocation());
|
||||||
if (XMaterial.supports(13)) {
|
if (XMaterial.supports(13)) {
|
||||||
//1.13+
|
//1.13+
|
||||||
|
|
Loading…
Reference in a new issue