diff --git a/pom.xml b/pom.xml
index bdc7be2..48f9466 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,13 +6,13 @@
com.alpsbte
PlotSystem-Terra
- 2.1
+ 3.0
-
+
- nachwahl-repo
- https://maven.nachwahl.dev/
+ alpsbte-repo
+ https://mvn.alps-bte.com/repository/alps-bte/
@@ -97,9 +97,9 @@
- com.jcraft
+ com.github.mwiede
jsch
- 0.1.55
+ 0.2.0
compile
diff --git a/src/main/java/com/alpsbte/plotsystemterra/PlotSystemTerra.java b/src/main/java/com/alpsbte/plotsystemterra/PlotSystemTerra.java
index 263e060..35123a7 100644
--- a/src/main/java/com/alpsbte/plotsystemterra/PlotSystemTerra.java
+++ b/src/main/java/com/alpsbte/plotsystemterra/PlotSystemTerra.java
@@ -1,6 +1,7 @@
package com.alpsbte.plotsystemterra;
import com.alpsbte.plotsystemterra.commands.CMD_CreatePlot;
+import com.alpsbte.plotsystemterra.commands.CMD_PastePlot;
import com.alpsbte.plotsystemterra.core.DatabaseConnection;
import com.alpsbte.plotsystemterra.core.EventListener;
import com.alpsbte.plotsystemterra.core.config.ConfigManager;
@@ -26,15 +27,17 @@
public class PlotSystemTerra extends JavaPlugin {
- private static final String VERSION = "2.1";
+ private static final String VERSION = "3.0";
private static PlotSystemTerra plugin;
private ConfigManager configManager;
+ private PlotPaster plotPaster;
private boolean pluginEnabled = false;
@Override
public void onEnable() {
+ System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog"); // Disable Logging
plugin = this;
String successPrefix = ChatColor.DARK_GRAY + "[" + ChatColor.DARK_GREEN + "✔" + ChatColor.DARK_GRAY + "] " + ChatColor.GRAY;
@@ -97,6 +100,7 @@ public void onEnable() {
// Register commands
try {
this.getCommand("createplot").setExecutor(new CMD_CreatePlot());
+ this.getCommand("pasteplot").setExecutor(new CMD_PastePlot());
Bukkit.getConsoleSender().sendMessage(successPrefix + "Successfully registered commands.");
} catch (Exception ex) {
Bukkit.getConsoleSender().sendMessage(errorPrefix + "Could not register commands.");
@@ -122,7 +126,8 @@ public void onEnable() {
});
// Start checking for plots to paste
- new PlotPaster().start();
+ plotPaster = new PlotPaster();
+ plotPaster.start();
pluginEnabled = true;
Bukkit.getConsoleSender().sendMessage(" ");
@@ -164,6 +169,10 @@ public static PlotSystemTerra getPlugin() {
return plugin;
}
+ public PlotPaster getPlotPaster() {
+ return plotPaster;
+ }
+
public static class DependencyManager {
// List with all missing dependencies
diff --git a/src/main/java/com/alpsbte/plotsystemterra/commands/CMD_PastePlot.java b/src/main/java/com/alpsbte/plotsystemterra/commands/CMD_PastePlot.java
new file mode 100644
index 0000000..8674755
--- /dev/null
+++ b/src/main/java/com/alpsbte/plotsystemterra/commands/CMD_PastePlot.java
@@ -0,0 +1,59 @@
+package com.alpsbte.plotsystemterra.commands;
+
+import com.alpsbte.plotsystemterra.PlotSystemTerra;
+import com.alpsbte.plotsystemterra.core.DatabaseConnection;
+import com.alpsbte.plotsystemterra.core.plotsystem.CityProject;
+import com.alpsbte.plotsystemterra.core.plotsystem.PlotPaster;
+import com.alpsbte.plotsystemterra.utils.Utils;
+import com.sk89q.worldedit.Vector;
+import org.bukkit.Bukkit;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+
+import java.sql.ResultSet;
+import java.util.logging.Level;
+
+public class CMD_PastePlot implements CommandExecutor {
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String s, String[] args) {
+ if(Utils.hasPermission(sender, "pasteplot")) {
+ try {
+ if (args.length >= 1 && Utils.tryParseInt(args[0]) != null) {
+ int plotID = Integer.parseInt(args[0]);
+
+ try (ResultSet rs = DatabaseConnection.createStatement("SELECT status, city_project_id, mc_coordinates, version FROM plotsystem_plots WHERE id = ?")
+ .setValue(plotID).executeQuery()) {
+
+ if (rs.next() && rs.getString(1).equals("completed")) {
+ PlotPaster plotPaster = PlotSystemTerra.getPlugin().getPlotPaster();
+
+ String[] splitCoordinates = rs.getString(3).split(",");
+ Vector mcCoordinates = Vector.toBlockPoint(
+ Float.parseFloat(splitCoordinates[0]),
+ Float.parseFloat(splitCoordinates[1]),
+ Float.parseFloat(splitCoordinates[2])
+ );
+
+ try {
+ PlotPaster.pastePlotSchematic(plotID, new CityProject(rs.getInt(2)), plotPaster.world, mcCoordinates, rs.getDouble(4), plotPaster.fastMode);
+ Bukkit.broadcastMessage("§7§l>§a Pasted §61 §aplot!");
+ } catch (Exception ex) {
+ Bukkit.getLogger().log(Level.SEVERE, "An error occurred while pasting plot with the ID " + plotID + "!", ex);
+ sender.sendMessage(Utils.getErrorMessageFormat("An error occurred while pasting plot!"));
+ }
+ } else sender.sendMessage(Utils.getErrorMessageFormat("Plot with the ID " + plotID + " is not completed!"));
+
+ DatabaseConnection.closeResultSet(rs);
+ }
+ } else {
+ sender.sendMessage(Utils.getErrorMessageFormat("Incorrect Input! Try /pasteplot "));
+ }
+ } catch (Exception ex) {
+ Bukkit.getLogger().log(Level.SEVERE, "An error occurred while pasting plot!", ex);
+ sender.sendMessage(Utils.getErrorMessageFormat("An error occurred while pasting plot!"));
+ }
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/com/alpsbte/plotsystemterra/core/DatabaseConnection.java b/src/main/java/com/alpsbte/plotsystemterra/core/DatabaseConnection.java
index 8dd1dd7..0985067 100644
--- a/src/main/java/com/alpsbte/plotsystemterra/core/DatabaseConnection.java
+++ b/src/main/java/com/alpsbte/plotsystemterra/core/DatabaseConnection.java
@@ -39,7 +39,6 @@ public static void InitializeDatabase() throws ClassNotFoundException {
dataSource = new HikariDataSource(config);
}
- @Deprecated
public static Connection getConnection() {
int retries = 3;
while (retries > 0) {
@@ -73,31 +72,6 @@ public static void closeResultSet(ResultSet resultSet) throws SQLException {
Bukkit.getLogger().log(Level.SEVERE, "There are multiple database connections opened. Please report this issue.");
}
- /**
- * Returns a missing auto increment id
- * @param table in the database
- * @return smallest missing auto increment id in the table
- */
- public static int getTableID(String table) {
- try {
- String query ="SELECT id + 1 available_id FROM $table t WHERE NOT EXISTS (SELECT * FROM $table WHERE $table.id = t.id + 1) ORDER BY id LIMIT 1"
- .replace("$table", table);
- try (ResultSet rs = DatabaseConnection.createStatement(query).executeQuery()) {
- if (rs.next()) {
- int i = rs.getInt(1);
- DatabaseConnection.closeResultSet(rs);
- return i;
- }
-
- DatabaseConnection.closeResultSet(rs);
- return 1;
- }
- } catch (SQLException ex) {
- Bukkit.getLogger().log(Level.SEVERE, "A SQL error occurred!", ex);
- return 1;
- }
- }
-
public static class StatementBuilder {
private final String sql;
private final List