Fixed plot auto for mega plot
Fixed an issue with SQLManager and SQLite
Added config option for max claim area for a mega plot with plot auto
Fixed an issue with UUIDHandler + online mode and old minecraft
versions.
This commit is contained in:
boy0001 2014-12-15 12:04:13 +11:00
parent fd306bf0a9
commit 7029069e31
6 changed files with 85 additions and 53 deletions

View File

@ -924,7 +924,7 @@ public class PlotMain extends JavaPlugin {
final Map<String, Object> options = new HashMap<>();
options.put("auto_update", false);
options.put("claim.max-auto-area", Settings.MAX_AUTO_SIZE);
options.put("UUID.offline", Settings.OFFLINE_MODE);
options.put("worldguard.enabled", Settings.WORLDGUARD);
options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT);
@ -959,6 +959,7 @@ public class PlotMain extends JavaPlugin {
Settings.MOB_PATHFINDING = config.getBoolean("mob_pathfinding");
Settings.METRICS = config.getBoolean("metrics");
Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
Settings.MAX_AUTO_SIZE = config.getInt("claim.max-auto-area");
Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled");
Settings.TITLES = config.getBoolean("titles");
Settings.MOB_CAP_ENABLED = config.getBoolean("perm-based-mob-cap.enabled");

View File

@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
@ -31,7 +32,9 @@ import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.PlayerFunctions;
import com.intellectualcrafters.plot.util.PlotHelper;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
@ -106,6 +109,8 @@ public class Auto extends SubCommand {
schematic = args[1];
}
} catch (final Exception e) {
size_x = 1;
size_z = 1;
schematic = args[0];
// PlayerFunctions.sendMessage(plr,
// "&cError: Invalid size (X,Y)");
@ -117,8 +122,19 @@ public class Auto extends SubCommand {
// return false;
}
}
if (PlayerFunctions.getPlayerPlotCount(world, plr) >= PlayerFunctions.getAllowedPlots(plr)) {
if (size_x * size_z > Settings.MAX_AUTO_SIZE) {
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + "");
return false;
}
int diff = PlayerFunctions.getPlayerPlotCount(world, plr) - PlayerFunctions.getAllowedPlots(plr);
if (diff + (size_x * size_z) >= 0) {
if (diff < 0) {
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, - diff - 1 + "");
}
else {
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
}
return false;
}
final PlotWorld pWorld = PlotMain.getWorldSettings(world);
@ -136,8 +152,8 @@ public class Auto extends SubCommand {
}
}
if (!schematic.equals("")) {
if (pWorld.SCHEMATIC_CLAIM_SPECIFY) {
if (pWorld.SCHEMATICS.contains(schematic.toLowerCase())) {
// if (pWorld.SCHEMATIC_CLAIM_SPECIFY) {
if (!pWorld.SCHEMATICS.contains(schematic.toLowerCase())) {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
return true;
}
@ -145,7 +161,7 @@ public class Auto extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
return true;
}
}
// }
}
boolean br = false;
if ((size_x == 1) && (size_z == 1)) {
@ -165,23 +181,25 @@ public class Auto extends SubCommand {
Auto.lastPlot = getNextPlot(Auto.lastPlot, 1);
}
} else {
// Why does this need fixing, it should work fine for auto claiming mega plots
boolean lastPlot = true;
PlotId lastId = Auto.lastPlot;
while (!br) {
final PlotId start = getNextPlot(Auto.lastPlot, 1);
// Checking if the current set of plots is a viable option.
{
if ((PlotMain.getPlots(world).get(start) == null) || (PlotMain.getPlots(world).get(start).owner == null)) {
Auto.lastPlot = start;
if (lastPlot) {
lastId = start;
}
if (PlotMain.getPlots(world).get(start) != null && PlotMain.getPlots(world).get(start).owner != null) {
continue;
}
else {
lastPlot = false;
}
System.out.print("UNOWNED: " + start);
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
if (isUnowned(world, start, end)) {
System.out.print("LAST PLOT: " + start);
for (int i = start.x; i <= end.x; i++) {
for (int j = start.y; j <= end.y; j++) {
final Plot plot = PlotHelper.getPlot(world, new PlotId(i, j));

View File

@ -151,6 +151,7 @@ public enum C {
NO_PERMISSION("&cYou are lacking the permission node: &6%s"),
NO_PLOT_PERMS("&cYou don't have the permissions to do that in this plot"),
CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."),
CANT_CLAIM_MORE_PLOTS_NUM("&cYou can't claim more than &6%s &cplots at once"),
YOU_BE_DENIED("&cYou are not allowed to enter this plot"),
NO_PERM_MERGE("&cYou are not the owner of the plot: &6%plot%"),

View File

@ -28,7 +28,10 @@ package com.intellectualcrafters.plot.config;
* @author Empire92
*/
public class Settings {
/**
*
*/
public static int MAX_AUTO_SIZE = 4;
/**
* Default worldedit-require-selection-in-mask: false
*/

View File

@ -67,7 +67,8 @@ public class SQLManager implements AbstractDB {
connection = c;
prefix = p;
// Set timout
setTimout();
// setTimout();
// Public final
SET_OWNER =
"UPDATE `" + prefix + "plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ?";
@ -83,6 +84,7 @@ public class SQLManager implements AbstractDB {
"INSERT INTO `" + prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) VALUES(?, ?, ?, ?)";
//schedule reconnect
if (PlotMain.getMySQL() != null) {
Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotMain.getMain(), new Runnable(){
public void run(){
try {
@ -93,24 +95,25 @@ public class SQLManager implements AbstractDB {
}
}
}, 11000, 11000);
}
public void setTimout() {
runTask(new Runnable() {
@Override
public void run() {
try {
final PreparedStatement statement = connection.prepareStatement("SET GLOBAL wait_timeout =28800;");
statement.executeUpdate();
statement.close();
} catch (final SQLException e) {
e.printStackTrace();
Logger.add(LogLevel.DANGER, "Could not reset MySQL timout.");
}
}
});
}
//
// public void setTimout() {
// runTask(new Runnable() {
// @Override
// public void run() {
// try {
// final PreparedStatement statement = connection.prepareStatement("SET GLOBAL wait_timeout =28800;");
// statement.executeQuery();
// statement.close();
// } catch (final SQLException e) {
// e.printStackTrace();
// Logger.add(LogLevel.DANGER, "Could not reset MySQL timout.");
// }
// }
// });
// }
/**
* Set Plot owner

View File

@ -325,6 +325,12 @@ public class UUIDHandler {
uuidWrapper = new OfflineUUIDWrapper();
}
}
try {
return uuidWrapper.getUUID(player);
}
catch (Throwable e) {
uuidWrapper = new OfflineUUIDWrapper();
return uuidWrapper.getUUID(player);
}
}
}