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);
return true;
}
catch (NoSuchMethodException e) {
catch (Throwable e) {
canSetFast = false;
}
}

View File

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

View File

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

View File

@ -14,6 +14,7 @@ import org.bukkit.World;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.FlagManager;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
@ -108,40 +109,21 @@ public class Auto extends SubCommand {
}
}
boolean br = false;
int x = 0, z = 0, q = 100;
PlotId id;
if ((size_x == 1) && (size_z == 1)) {
while (!br) {
Plot plot = PlotHelper.getPlot(world, Auto.lastPlot);
if (plot==null || plot.owner == null) {
plot = PlotHelper.getPlot(world, Auto.lastPlot);
boolean result = Claim.claimPlot(plr, plot, true);
br = !result;
Claim.claimPlot(plr, plot, true);
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);
}
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 {
boolean claimed = true;
@ -168,6 +150,11 @@ public class Auto extends SubCommand {
return false;
}
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);
}
PlotWorld world = PlotMain.getWorldSettings(plot.getWorld());
Plot plot2 = PlotMain.getPlots(player.getWorld()).get(plot.id);
if (world.SCHEMATIC_ON_CLAIM) {
SchematicHandler.Schematic sch;
if (schematic.equals("")) {
@ -110,10 +113,10 @@ public class Claim extends SubCommand {
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) {
plot.settings.setFlags(FlagManager.parseFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS));
plot2.settings.setFlags(FlagManager.parseFlags(world.DEFAULT_FLAGS));
}
}
return event.isCancelled();

View File

@ -23,7 +23,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
public class Purge extends SubCommand {
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

View File

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

View File

@ -439,7 +439,7 @@ public class SQLManager extends AbstractDB {
user = UUID.fromString(o);
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);
}
stmt.close();

View File

@ -77,16 +77,18 @@ public class ForceFieldListener implements Listener {
if(!PlayerFunctions.isInPlot(player))
return;
Plot plot = PlayerFunctions.getCurrentPlot(player);
if(!PlotListener.booleanFlag(plot, "forcefield"))
if(plot.hasRights(player)) {
Set<Player> players = getNearbyPlayers(player, plot);
for(Player oPlayer : players) {
oPlayer.setVelocity(calculateVelocity(player, oPlayer));
if (plot.settings.getFlag("forcefield") != null && plot.settings.getFlag("forcefield").getValue().equals("true")) {
if(!PlotListener.booleanFlag(plot, "forcefield"))
if(plot.hasRights(player)) {
Set<Player> players = getNearbyPlayers(player, plot);
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) {
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 sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner));
ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s());