mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Claiming new plot
This commit is contained in:
parent
5c4f1332d6
commit
2dff41fa53
@ -243,4 +243,6 @@ public interface AbstractDB {
|
||||
* @return Plot Comments within the specified tier
|
||||
*/
|
||||
public ArrayList<PlotComment> getComments(final String world, final Plot plot, final int tier);
|
||||
|
||||
public void createPlotAndSettings(Plot plot);
|
||||
}
|
||||
|
@ -86,6 +86,15 @@ public class DBFunc {
|
||||
dbManager.createPlot(plot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plot
|
||||
*
|
||||
* @param plot Plot to create
|
||||
*/
|
||||
public static void createPlotAndSettings(final Plot plot) {
|
||||
dbManager.createPlotAndSettings(plot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create tables
|
||||
*
|
||||
|
@ -307,6 +307,7 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.setInt(2, plot.id.y);
|
||||
stmt.setString(3, plot.owner.toString());
|
||||
stmt.setString(4, plot.world);
|
||||
System.out.print("STMT: "+stmt.toString());
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
} catch (final Exception e) {
|
||||
@ -317,6 +318,37 @@ public class SQLManager implements AbstractDB {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createPlotAndSettings(final Plot plot) {
|
||||
runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
stmt = SQLManager.this.connection.prepareStatement(SQLManager.this.CREATE_PLOT);
|
||||
stmt.setInt(1, plot.id.x);
|
||||
stmt.setInt(2, plot.id.y);
|
||||
stmt.setString(3, plot.owner.toString());
|
||||
stmt.setString(4, plot.world);
|
||||
System.out.print("STMT: "+stmt.toString());
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
|
||||
int id = getId(plot.world, plot.id);
|
||||
stmt = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(" + "?)");
|
||||
stmt.setInt(1, id);
|
||||
System.out.print("STMT: "+stmt.toString());
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
PlotMain.sendConsoleSenderMessage("&c[ERROR] "+"Failed to save plot " + plot.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create tables
|
||||
*
|
||||
@ -409,6 +441,7 @@ public class SQLManager implements AbstractDB {
|
||||
try {
|
||||
stmt = SQLManager.this.connection.prepareStatement("INSERT INTO `" + SQLManager.this.prefix + "plot_settings`(`plot_plot_id`) VALUES(" + "?)");
|
||||
stmt.setInt(1, id);
|
||||
System.out.print("STMT: "+stmt.toString());
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
} catch (final SQLException e) {
|
||||
@ -1232,5 +1265,4 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
return 0.0d;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -423,8 +423,7 @@ import java.util.UUID;
|
||||
final World w = plot.getWorld();
|
||||
final Plot p = new Plot(plot.id, UUIDHandler.getUUID(player), plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
|
||||
PlotMain.updatePlot(p);
|
||||
DBFunc.createPlot(p);
|
||||
DBFunc.createPlotSettings(DBFunc.getId(w.getName(), plot.id), plot);
|
||||
DBFunc.createPlotAndSettings(p);
|
||||
final PlotWorld plotworld = PlotMain.getWorldSettings(w);
|
||||
if (plotworld.AUTO_MERGE) {
|
||||
autoMerge(w, p, player);
|
||||
|
Loading…
Reference in New Issue
Block a user