This commit is contained in:
boy0001 2014-11-01 09:29:08 +11:00
parent 007b9ee298
commit 6044ca63c2
10 changed files with 100 additions and 108 deletions

View File

@ -274,7 +274,7 @@ public class PlotHelper {
SetBlockFast.set(block.getWorld(), block.getX(), block.getY(), block.getZ(), plotblock.id, plotblock.data); SetBlockFast.set(block.getWorld(), block.getX(), block.getY(), block.getZ(), plotblock.id, plotblock.data);
return true; return true;
} }
catch (NoSuchMethodException e) { catch (Throwable e) {
canSetFast = false; canSetFast = false;
} }
} }

View File

@ -733,10 +733,8 @@ public class PlotMain extends JavaPlugin {
/** /**
* Get MySQL Connection * Get MySQL Connection
*
* @return connection MySQL Connection. * @return connection MySQL Connection.
*/ */
@SuppressWarnings("unused")
public static Connection getConnection() { public static Connection getConnection() {
return connection; return connection;
} }
@ -959,7 +957,7 @@ public class PlotMain extends JavaPlugin {
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void killAllEntities() { public static void killAllEntities() {
Bukkit.getScheduler().scheduleAsyncRepeatingTask(getMain(), new Runnable() { Bukkit.getScheduler().scheduleSyncRepeatingTask(getMain(), new Runnable() {
Location location; Location location;
long ticked = 0l; long ticked = 0l;
long error = 0l; long error = 0l;
@ -986,73 +984,72 @@ public class PlotMain extends JavaPlugin {
Entity[] entities = chunk.getEntities(); Entity[] entities = chunk.getEntities();
for (int i = entities.length - 1; i >= 0; i--) { for (int i = entities.length - 1; i >= 0; i--) {
Entity entity = entities[i]; Entity entity = entities[i];
if ((entity instanceof Player) || PlayerEvents.isInPlot(entity.getLocation())) { if ((entity instanceof Player) || PlayerEvents.isInPlot(entity.getLocation())) {
continue; continue;
} }
entity.remove();
boolean tamed = false; // boolean tamed = false;
if (Settings.MOB_PATHFINDING) { // if (Settings.MOB_PATHFINDING) {
if (entity instanceof Tameable) { // if (entity instanceof Tameable) {
Tameable tameable = (Tameable) entity; // Tameable tameable = (Tameable) entity;
if (tameable.isTamed()) { // if (tameable.isTamed()) {
tamed = true; // tamed = true;
} // }
} // }
else // else
if (entity instanceof LivingEntity) { // if (entity instanceof LivingEntity) {
LivingEntity livingEntity = ((LivingEntity) entity); // LivingEntity livingEntity = ((LivingEntity) entity);
if (livingEntity.getCustomName() != null) { // if (livingEntity.getCustomName() != null) {
tamed = true; // tamed = true;
} // }
} // }
if (!tamed) { // if (!tamed) {
entity.remove(); // entity.remove();
continue; // continue;
} // }
boolean found = false; // boolean found = false;
int radius = 1; // int radius = 1;
int dir = 0; // int dir = 0;
int x = this.location.getBlockX(); // int x = this.location.getBlockX();
int y = this.location.getBlockY(); // int y = this.location.getBlockY();
int z = this.location.getBlockZ(); // int z = this.location.getBlockZ();
while (!found && (radius < 4)) { // while (!found && (radius < 4)) {
Location pos; // Location pos;
switch (dir) { // switch (dir) {
case 0: // case 0:
pos = new Location(world, x + radius, y, z); // pos = new Location(world, x + radius, y, z);
dir++; // dir++;
break; // break;
case 1: // case 1:
pos = new Location(world, x, y, z + radius); // pos = new Location(world, x, y, z + radius);
dir++; // dir++;
break; // break;
case 2: // case 2:
pos = new Location(world, x - radius, y, z); // pos = new Location(world, x - radius, y, z);
dir++; // dir++;
break; // break;
case 3: // case 3:
pos = new Location(world, x, y, z - radius); // pos = new Location(world, x, y, z - radius);
dir = 0; // dir = 0;
radius++; // radius++;
break; // break;
default: // default:
pos = this.location; // pos = this.location;
break; // break;
//
} // }
if (PlayerEvents.isInPlot(pos)) { // if (PlayerEvents.isInPlot(pos)) {
entity.teleport(pos.add(0.5, 0, 0.5)); // entity.teleport(pos.add(0.5, 0, 0.5));
found = true; // found = true;
break; // break;
} // }
} // }
entity.teleport(this.location.subtract(this.location.getDirection().normalize().multiply(2))); // entity.teleport(this.location.subtract(this.location.getDirection().normalize().multiply(2)));
} // }
} }
} }
} }
catch (Exception e) { catch (Throwable e) {
++this.error; ++this.error;
} }
finally { finally {
@ -1060,7 +1057,7 @@ public class PlotMain extends JavaPlugin {
} }
} }
} }
}, 0l, 2l); }, 2L, 2L);
} }
/** /**
@ -1083,6 +1080,7 @@ public class PlotMain extends JavaPlugin {
options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH);
options.put("api.location", Settings.API_URL); options.put("api.location", Settings.API_URL);
options.put("api.custom", Settings.CUSTOM_API); options.put("api.custom", Settings.CUSTOM_API);
options.put("titles", Settings.TITLES);
for (Entry<String, Object> node : options.entrySet()) { for (Entry<String, Object> node : options.entrySet()) {
if (!config.contains(node.getKey())) { if (!config.contains(node.getKey())) {
@ -1099,6 +1097,7 @@ public class PlotMain extends JavaPlugin {
Settings.METRICS = config.getBoolean("metrics"); Settings.METRICS = config.getBoolean("metrics");
Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days"); Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled");
Settings.TITLES = config.getBoolean("titles");
Settings.MAX_PLOTS = config.getInt("max_plots"); Settings.MAX_PLOTS = config.getInt("max_plots");
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");
} }

View File

@ -15,6 +15,7 @@ package com.intellectualcrafters.plot;
* @author Empire92 * @author Empire92
*/ */
public class Settings { public class Settings {
public static boolean TITLES = true;
/** /**
* Schematic Save Path * Schematic Save Path
*/ */

View File

@ -14,6 +14,7 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.FlagManager;
import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper; import com.intellectualcrafters.plot.PlotHelper;
@ -108,40 +109,21 @@ public class Auto extends SubCommand {
} }
} }
boolean br = false; boolean br = false;
int x = 0, z = 0, q = 100;
PlotId id;
if ((size_x == 1) && (size_z == 1)) { if ((size_x == 1) && (size_z == 1)) {
while (!br) { while (!br) {
Plot plot = PlotHelper.getPlot(world, Auto.lastPlot); Plot plot = PlotHelper.getPlot(world, Auto.lastPlot);
if (plot==null || plot.owner == null) { if (plot==null || plot.owner == null) {
plot = PlotHelper.getPlot(world, Auto.lastPlot); plot = PlotHelper.getPlot(world, Auto.lastPlot);
boolean result = Claim.claimPlot(plr, plot, true); Claim.claimPlot(plr, plot, true);
br = !result; br = true;
PlotWorld pw = PlotMain.getWorldSettings(world);
Plot plot2 = PlotMain.getPlots(world).get(plot.id);
if (pw.DEFAULT_FLAGS != null && pw.DEFAULT_FLAGS.size() > 0) {
plot2.settings.setFlags(FlagManager.parseFlags(pw.DEFAULT_FLAGS));
}
} }
Auto.lastPlot = getNextPlot(Auto.lastPlot, 1); Auto.lastPlot = getNextPlot(Auto.lastPlot, 1);
} }
while (!br) {
id = new PlotId(x, z);
if (PlotHelper.getPlot(world, id).owner == null) {
Plot plot = PlotHelper.getPlot(world, id);
boolean result = Claim.claimPlot(plr, plot, true);
br = !result;
}
if ((z < q) && ((z - x) < q)) {
z++;
}
else {
if (x < q) {
x++;
z = q - 100;
}
else {
q += 100;
x = q;
z = q;
}
}
}
} }
else { else {
boolean claimed = true; boolean claimed = true;
@ -168,6 +150,11 @@ public class Auto extends SubCommand {
return false; return false;
} }
br = true; br = true;
PlotWorld pw = PlotMain.getWorldSettings(world);
Plot plot2 = PlotMain.getPlots(world).get(start);
if (pw.DEFAULT_FLAGS != null && pw.DEFAULT_FLAGS.size() > 0) {
plot2.settings.setFlags(FlagManager.parseFlags(pw.DEFAULT_FLAGS));
}
} }
} }
} }

View File

@ -99,6 +99,9 @@ public class Claim extends SubCommand {
PlotMain.teleportPlayer(player, player.getLocation(), plot); PlotMain.teleportPlayer(player, player.getLocation(), plot);
} }
PlotWorld world = PlotMain.getWorldSettings(plot.getWorld()); PlotWorld world = PlotMain.getWorldSettings(plot.getWorld());
Plot plot2 = PlotMain.getPlots(player.getWorld()).get(plot.id);
if (world.SCHEMATIC_ON_CLAIM) { if (world.SCHEMATIC_ON_CLAIM) {
SchematicHandler.Schematic sch; SchematicHandler.Schematic sch;
if (schematic.equals("")) { if (schematic.equals("")) {
@ -110,10 +113,10 @@ public class Claim extends SubCommand {
sch = SchematicHandler.getSchematic(world.SCHEMATIC_FILE); sch = SchematicHandler.getSchematic(world.SCHEMATIC_FILE);
} }
} }
SchematicHandler.paste(player.getLocation(), sch, plot, 0, 0); SchematicHandler.paste(player.getLocation(), sch, plot2, 0, 0);
} }
if (world.DEFAULT_FLAGS != null && world.DEFAULT_FLAGS.size() > 0) { if (world.DEFAULT_FLAGS != null && world.DEFAULT_FLAGS.size() > 0) {
plot.settings.setFlags(FlagManager.parseFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS)); plot2.settings.setFlags(FlagManager.parseFlags(world.DEFAULT_FLAGS));
} }
} }
return event.isCancelled(); return event.isCancelled();

View File

@ -23,7 +23,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
public class Purge extends SubCommand { public class Purge extends SubCommand {
public Purge() { public Purge() {
super("purge", "plots.admin", "Purge all plots for a world", "purge", "", CommandCategory.ACTIONS, false); super("purge", "plots.admin", "Purge all plots for a world", "purge", "", CommandCategory.DEBUG, false);
} }
@Override @Override

View File

@ -67,7 +67,7 @@ public class Visit extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER);
return true; return true;
} }
if ((i < 0) || (i > plots.size())) { if ((i < 0) || (i >= plots.size())) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER);
return true; return true;
} }

View File

@ -439,7 +439,7 @@ public class SQLManager extends AbstractDB {
user = UUID.fromString(o); user = UUID.fromString(o);
uuids.put(o, user); uuids.put(o, user);
} }
p = new Plot(plot_id, user, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), new ArrayList<UUID>(), "", PlotHomePosition.DEFAULT, null, worldname, new boolean[0]); p = new Plot(plot_id, user, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), new ArrayList<UUID>(), "", PlotHomePosition.DEFAULT, null, worldname, new boolean[] {false, false, false, false});
plots.put(id, p); plots.put(id, p);
} }
stmt.close(); stmt.close();

View File

@ -77,16 +77,18 @@ public class ForceFieldListener implements Listener {
if(!PlayerFunctions.isInPlot(player)) if(!PlayerFunctions.isInPlot(player))
return; return;
Plot plot = PlayerFunctions.getCurrentPlot(player); Plot plot = PlayerFunctions.getCurrentPlot(player);
if(!PlotListener.booleanFlag(plot, "forcefield")) if (plot.settings.getFlag("forcefield") != null && plot.settings.getFlag("forcefield").getValue().equals("true")) {
if(plot.hasRights(player)) { if(!PlotListener.booleanFlag(plot, "forcefield"))
Set<Player> players = getNearbyPlayers(player, plot); if(plot.hasRights(player)) {
for(Player oPlayer : players) { Set<Player> players = getNearbyPlayers(player, plot);
oPlayer.setVelocity(calculateVelocity(player, oPlayer)); for(Player oPlayer : players) {
oPlayer.setVelocity(calculateVelocity(player, oPlayer));
}
} else {
Player oPlayer = hasNearbyPermitted(player, plot);
if(oPlayer == null) return;
player.setVelocity(calculateVelocity(oPlayer, player));
} }
} else { }
Player oPlayer = hasNearbyPermitted(player, plot);
if(oPlayer == null) return;
player.setVelocity(calculateVelocity(oPlayer, player));
}
} }
} }

View File

@ -176,7 +176,7 @@ public class PlotListener {
if(plot.settings.getFlag("weather") != null) { if(plot.settings.getFlag("weather") != null) {
player.setPlayerWeather(getWeatherType(plot.settings.getFlag("weather").getValue())); player.setPlayerWeather(getWeatherType(plot.settings.getFlag("weather").getValue()));
} }
if (C.TITLE_ENTERED_PLOT.s().length() > 2) { if (Settings.TITLES && C.TITLE_ENTERED_PLOT.s().length() > 2) {
String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", plot.getDisplayName()); String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", plot.getDisplayName());
String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)); String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner));
ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()); ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s());