further bug fixes

This commit is contained in:
boy0001 2014-10-07 22:34:57 +11:00
parent da3ceeab44
commit 30f1f829cb
10 changed files with 58 additions and 24 deletions

View File

@ -19,7 +19,6 @@ import com.sk89q.worldedit.regions.CuboidRegion;
*/
public class PWE {
@SuppressWarnings("unused")
public static void setMask(Player p, Location l) {
try {
LocalSession s;
@ -37,7 +36,7 @@ public class PWE {
r = (plot.getOwner() != null) && plot.getOwner().equals(p.getUniqueId());
if (!r) {
if (p.hasPermission("plots.worldedit.member") && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
if ((plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
r = true;
} else if (p.hasPermission("plots.worldedit.bypass")) {
removeMask(p, s);
@ -70,7 +69,7 @@ public class PWE {
s.setMask(new com.sk89q.worldedit.masks.RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
}
} catch (Exception e) {
throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
// throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
}
}
@ -102,7 +101,7 @@ public class PWE {
}
removeMask(p, s);
} catch (Exception e) {
throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
// throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
}
}
}

View File

@ -122,7 +122,7 @@ public class PlayerFunctions {
int rz = (z) % size;
int end = pathWidthLower + plotworld.PLOT_WIDTH;
boolean northSouth = (rz <= pathWidthLower) || (rz > (pathWidthLower + plotworld.PLOT_WIDTH));
boolean northSouth = (rz <= pathWidthLower) || (rz > end);
boolean eastWest = (rx <= pathWidthLower) || (rx > end);
if (northSouth || eastWest) {
@ -165,9 +165,8 @@ public class PlayerFunctions {
int end = pathWidthLower + plotworld.PLOT_WIDTH;
boolean northSouth = (rz <= pathWidthLower) || (rz > (pathWidthLower + plotworld.PLOT_WIDTH));
boolean northSouth = (rz <= pathWidthLower) || (rz > end);
boolean eastWest = (rx <= pathWidthLower) || (rx > end);
if (northSouth && eastWest) {
// This means you are in the intersection
PlotId id = getPlotAbs(loc.add(plotworld.ROAD_WIDTH, 0, plotworld.ROAD_WIDTH));

View File

@ -86,6 +86,7 @@ public class Plot implements Cloneable {
this.deny_entry = this.owner == null;
this.helpers = helpers;
this.denied = denied;
this.trusted = new ArrayList<UUID>();
this.settings.setTime(8000l);
this.settings.setRain(false);
this.settings.setTimeChange(false);

View File

@ -421,7 +421,6 @@ public class PlotHelper {
}
public static boolean createPlot(Player player, Plot plot) {
@SuppressWarnings("deprecation")
World w = plot.getWorld();
Plot p = new Plot(plot.id, player.getUniqueId(), plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
PlotMain.updatePlot(p);

View File

@ -353,6 +353,7 @@ public class PlotMain extends JavaPlugin {
* @return
*/
public static Set<Plot> getPlots(World world, Player player) {
int i = 0;
UUID uuid = player.getUniqueId();
ArrayList<Plot> myplots = new ArrayList<Plot>();
for (Plot plot : getPlots(world).values()) {
@ -1093,7 +1094,13 @@ public class PlotMain extends JavaPlugin {
if (world == null) {
return;
}
Set<String> worlds = config.getConfigurationSection("worlds").getKeys(false);
Set<String> worlds;
if (config.contains("worlds")) {
worlds = config.getConfigurationSection("worlds").getKeys(false);
}
else {
worlds = new HashSet<String>();
}
if (worlds.contains(world.getName())) {
ChunkGenerator gen = world.getGenerator();
if ((gen == null) || !gen.getClass().getSimpleName().equals("PlotSquaredGen")) {

View File

@ -9,6 +9,8 @@
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
@ -44,14 +46,12 @@ public class Home extends SubCommand {
return true;
} else if (plots.length > 1) {
if (args.length < 1) {
PlayerFunctions.sendMessage(plr, C.NEED_PLOT_NUMBER);
return true;
args = new String[] {"1"};
}
int id = 0;
try {
id = Integer.parseInt(args[0]);
} catch (Exception e) {
Plot temp;
if ((temp = isAlias(args[0])) != null) {
if (temp.hasOwner()) {

View File

@ -75,7 +75,7 @@ public class Set extends SubCommand {
}
}
/* TODO: Implement option */
boolean advanced_permissions = false;
boolean advanced_permissions = true;
if (advanced_permissions) {
if (!plr.hasPermission("plots.set." + args[0].toLowerCase())) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);

View File

@ -18,6 +18,8 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
@ -366,9 +368,14 @@ public class DBFunc {
e.printStackTrace();
}
HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<String, HashMap<PlotId, Plot>>();
new HashMap<String, World>();
Statement stmt = null;
try {
Set<String> worlds = new HashSet<String>();
if (PlotMain.config.contains("worlds")) {
worlds = PlotMain.config.getConfigurationSection("worlds").getKeys(false);
}
stmt = connection.createStatement();
ResultSet r = stmt.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world` FROM `plot`");
PlotId plot_id;
@ -441,9 +448,14 @@ public class DBFunc {
if (plots.containsKey(worldname)) {
plots.get(worldname).put((plot_id), p);
} else {
HashMap<PlotId, Plot> map = new HashMap<PlotId, Plot>();
map.put((plot_id), p);
plots.put(worldname, map);
if (worlds.contains(p.world)) {
HashMap<PlotId, Plot> map = new HashMap<PlotId, Plot>();
map.put((plot_id), p);
plots.put(worldname, map);
}
else {
PlotMain.sendConsoleSenderMessage("&cPlot '"+p.id+"' in DB for world '"+p.world+"' does not exist! Please create this world, or remove the plots from the DB!");
}
}
}
stmt.close();

View File

@ -65,6 +65,7 @@ import org.bukkit.event.world.WorldLoadEvent;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
@ -90,11 +91,27 @@ public class PlayerEvents implements Listener {
}
public boolean enteredPlot(Location l1, Location l2) {
return !isInPlot(l1) && isInPlot(l2);
PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(),l1.getBlockX(),64,l1.getBlockZ()));
PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(),l2.getBlockX(),64,l2.getBlockZ()));
if (p2==null)
return false;
if (p1==null)
return true;
if (p1.equals(p2))
return false;
return true;
}
public boolean leftPlot(Location l1, Location l2) {
return isInPlot(l1) && !isInPlot(l2);
PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(),l1.getBlockX(),64,l1.getBlockZ()));
PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(),l2.getBlockX(),64,l2.getBlockZ()));
if (p1==null)
return false;
if (p2==null)
return true;
if (p1.equals(p2))
return false;
return true;
}
private boolean isPlotWorld(Location l) {
@ -149,7 +166,7 @@ public class PlayerEvents implements Listener {
}
}
@EventHandler
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void PlayerMove(PlayerMoveEvent event) {
try {
Player player = event.getPlayer();
@ -159,7 +176,7 @@ public class PlayerEvents implements Listener {
if (!isPlotWorld(player.getWorld())) {
return;
}
if (enteredPlot(event.getFrom(), event.getTo())) {
if (enteredPlot(from,to)) {
Plot plot = getCurrentPlot(event.getTo());
if (plot.hasOwner()) {
if (C.TITLE_ENTERED_PLOT.s().length() > 2) {
@ -501,7 +518,7 @@ public class PlayerEvents implements Listener {
if (!isPlotWorld(world)) {
return;
}
if ((event.getSpawnReason() != SpawnReason.SPAWNER_EGG) || !isInPlot(event.getLocation())) {
if (!isInPlot(event.getLocation())) {
event.setCancelled(true);
}
}
@ -611,7 +628,7 @@ public class PlayerEvents implements Listener {
Block b = e.getBlock();
if (isPlotWorld(b.getLocation())) {
Player p = e.getPlayer();
if (isInPlot(b.getLocation())) {
if (!isInPlot(b.getLocation())) {
if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
e.setCancelled(true);

View File

@ -98,7 +98,7 @@ public class WorldEditListener implements Listener {
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent e) {
Location t = e.getTo();
if (!isPlotWorld(t)) {