mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
further bug fixes
This commit is contained in:
parent
da3ceeab44
commit
30f1f829cb
@ -19,7 +19,6 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
|||||||
*/
|
*/
|
||||||
public class PWE {
|
public class PWE {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public static void setMask(Player p, Location l) {
|
public static void setMask(Player p, Location l) {
|
||||||
try {
|
try {
|
||||||
LocalSession s;
|
LocalSession s;
|
||||||
@ -37,7 +36,7 @@ public class PWE {
|
|||||||
r = (plot.getOwner() != null) && plot.getOwner().equals(p.getUniqueId());
|
r = (plot.getOwner() != null) && plot.getOwner().equals(p.getUniqueId());
|
||||||
|
|
||||||
if (!r) {
|
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;
|
r = true;
|
||||||
} else if (p.hasPermission("plots.worldedit.bypass")) {
|
} else if (p.hasPermission("plots.worldedit.bypass")) {
|
||||||
removeMask(p, s);
|
removeMask(p, s);
|
||||||
@ -70,7 +69,7 @@ public class PWE {
|
|||||||
s.setMask(new com.sk89q.worldedit.masks.RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
|
s.setMask(new com.sk89q.worldedit.masks.RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} 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);
|
removeMask(p, s);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
|
// throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public class PlayerFunctions {
|
|||||||
int rz = (z) % size;
|
int rz = (z) % size;
|
||||||
|
|
||||||
int end = pathWidthLower + plotworld.PLOT_WIDTH;
|
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);
|
boolean eastWest = (rx <= pathWidthLower) || (rx > end);
|
||||||
|
|
||||||
if (northSouth || eastWest) {
|
if (northSouth || eastWest) {
|
||||||
@ -165,9 +165,8 @@ public class PlayerFunctions {
|
|||||||
|
|
||||||
int end = pathWidthLower + plotworld.PLOT_WIDTH;
|
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);
|
boolean eastWest = (rx <= pathWidthLower) || (rx > end);
|
||||||
|
|
||||||
if (northSouth && eastWest) {
|
if (northSouth && eastWest) {
|
||||||
// This means you are in the intersection
|
// This means you are in the intersection
|
||||||
PlotId id = getPlotAbs(loc.add(plotworld.ROAD_WIDTH, 0, plotworld.ROAD_WIDTH));
|
PlotId id = getPlotAbs(loc.add(plotworld.ROAD_WIDTH, 0, plotworld.ROAD_WIDTH));
|
||||||
|
@ -86,6 +86,7 @@ public class Plot implements Cloneable {
|
|||||||
this.deny_entry = this.owner == null;
|
this.deny_entry = this.owner == null;
|
||||||
this.helpers = helpers;
|
this.helpers = helpers;
|
||||||
this.denied = denied;
|
this.denied = denied;
|
||||||
|
this.trusted = new ArrayList<UUID>();
|
||||||
this.settings.setTime(8000l);
|
this.settings.setTime(8000l);
|
||||||
this.settings.setRain(false);
|
this.settings.setRain(false);
|
||||||
this.settings.setTimeChange(false);
|
this.settings.setTimeChange(false);
|
||||||
|
@ -421,7 +421,6 @@ public class PlotHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean createPlot(Player player, Plot plot) {
|
public static boolean createPlot(Player player, Plot plot) {
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
World w = plot.getWorld();
|
World w = plot.getWorld();
|
||||||
Plot p = new Plot(plot.id, player.getUniqueId(), plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
|
Plot p = new Plot(plot.id, player.getUniqueId(), plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
|
||||||
PlotMain.updatePlot(p);
|
PlotMain.updatePlot(p);
|
||||||
|
@ -353,6 +353,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Set<Plot> getPlots(World world, Player player) {
|
public static Set<Plot> getPlots(World world, Player player) {
|
||||||
|
int i = 0;
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
ArrayList<Plot> myplots = new ArrayList<Plot>();
|
ArrayList<Plot> myplots = new ArrayList<Plot>();
|
||||||
for (Plot plot : getPlots(world).values()) {
|
for (Plot plot : getPlots(world).values()) {
|
||||||
@ -1093,7 +1094,13 @@ public class PlotMain extends JavaPlugin {
|
|||||||
if (world == null) {
|
if (world == null) {
|
||||||
return;
|
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())) {
|
if (worlds.contains(world.getName())) {
|
||||||
ChunkGenerator gen = world.getGenerator();
|
ChunkGenerator gen = world.getGenerator();
|
||||||
if ((gen == null) || !gen.getClass().getSimpleName().equals("PlotSquaredGen")) {
|
if ((gen == null) || !gen.getClass().getSimpleName().equals("PlotSquaredGen")) {
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
@ -44,14 +46,12 @@ public class Home extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
} else if (plots.length > 1) {
|
} else if (plots.length > 1) {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NEED_PLOT_NUMBER);
|
args = new String[] {"1"};
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
int id = 0;
|
int id = 0;
|
||||||
try {
|
try {
|
||||||
id = Integer.parseInt(args[0]);
|
id = Integer.parseInt(args[0]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
Plot temp;
|
Plot temp;
|
||||||
if ((temp = isAlias(args[0])) != null) {
|
if ((temp = isAlias(args[0])) != null) {
|
||||||
if (temp.hasOwner()) {
|
if (temp.hasOwner()) {
|
||||||
|
@ -75,7 +75,7 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* TODO: Implement option */
|
/* TODO: Implement option */
|
||||||
boolean advanced_permissions = false;
|
boolean advanced_permissions = true;
|
||||||
if (advanced_permissions) {
|
if (advanced_permissions) {
|
||||||
if (!plr.hasPermission("plots.set." + args[0].toLowerCase())) {
|
if (!plr.hasPermission("plots.set." + args[0].toLowerCase())) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
||||||
|
@ -18,6 +18,8 @@ import java.sql.SQLException;
|
|||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -366,9 +368,14 @@ public class DBFunc {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<String, HashMap<PlotId, Plot>>();
|
HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<String, HashMap<PlotId, Plot>>();
|
||||||
new HashMap<String, World>();
|
|
||||||
Statement stmt = null;
|
Statement stmt = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
Set<String> worlds = new HashSet<String>();
|
||||||
|
if (PlotMain.config.contains("worlds")) {
|
||||||
|
worlds = PlotMain.config.getConfigurationSection("worlds").getKeys(false);
|
||||||
|
}
|
||||||
|
|
||||||
stmt = connection.createStatement();
|
stmt = connection.createStatement();
|
||||||
ResultSet r = stmt.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world` FROM `plot`");
|
ResultSet r = stmt.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world` FROM `plot`");
|
||||||
PlotId plot_id;
|
PlotId plot_id;
|
||||||
@ -441,9 +448,14 @@ public class DBFunc {
|
|||||||
if (plots.containsKey(worldname)) {
|
if (plots.containsKey(worldname)) {
|
||||||
plots.get(worldname).put((plot_id), p);
|
plots.get(worldname).put((plot_id), p);
|
||||||
} else {
|
} else {
|
||||||
HashMap<PlotId, Plot> map = new HashMap<PlotId, Plot>();
|
if (worlds.contains(p.world)) {
|
||||||
map.put((plot_id), p);
|
HashMap<PlotId, Plot> map = new HashMap<PlotId, Plot>();
|
||||||
plots.put(worldname, map);
|
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();
|
stmt.close();
|
||||||
|
@ -65,6 +65,7 @@ import org.bukkit.event.world.WorldLoadEvent;
|
|||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
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.PlotId;
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
import com.intellectualcrafters.plot.PlotWorld;
|
import com.intellectualcrafters.plot.PlotWorld;
|
||||||
@ -90,11 +91,27 @@ public class PlayerEvents implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean enteredPlot(Location l1, Location l2) {
|
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) {
|
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) {
|
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) {
|
public void PlayerMove(PlayerMoveEvent event) {
|
||||||
try {
|
try {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -159,7 +176,7 @@ public class PlayerEvents implements Listener {
|
|||||||
if (!isPlotWorld(player.getWorld())) {
|
if (!isPlotWorld(player.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (enteredPlot(event.getFrom(), event.getTo())) {
|
if (enteredPlot(from,to)) {
|
||||||
Plot plot = getCurrentPlot(event.getTo());
|
Plot plot = getCurrentPlot(event.getTo());
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
if (C.TITLE_ENTERED_PLOT.s().length() > 2) {
|
if (C.TITLE_ENTERED_PLOT.s().length() > 2) {
|
||||||
@ -501,7 +518,7 @@ public class PlayerEvents implements Listener {
|
|||||||
if (!isPlotWorld(world)) {
|
if (!isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((event.getSpawnReason() != SpawnReason.SPAWNER_EGG) || !isInPlot(event.getLocation())) {
|
if (!isInPlot(event.getLocation())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -611,7 +628,7 @@ public class PlayerEvents implements Listener {
|
|||||||
Block b = e.getBlock();
|
Block b = e.getBlock();
|
||||||
if (isPlotWorld(b.getLocation())) {
|
if (isPlotWorld(b.getLocation())) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
if (isInPlot(b.getLocation())) {
|
if (!isInPlot(b.getLocation())) {
|
||||||
if (!p.hasPermission("plots.admin")) {
|
if (!p.hasPermission("plots.admin")) {
|
||||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
@ -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) {
|
public void onPlayerMove(final PlayerMoveEvent e) {
|
||||||
Location t = e.getTo();
|
Location t = e.getTo();
|
||||||
if (!isPlotWorld(t)) {
|
if (!isPlotWorld(t)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user