mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 11:55:38 +01:00
Time for our weekly code cleanup!
Please tell me if doing this annoys you.
This commit is contained in:
parent
58ed037fad
commit
980499a193
@ -11,8 +11,10 @@ public class AbstractFlag {
|
||||
|
||||
/**
|
||||
* AbstractFlag is a parameter used in creating a new Flag
|
||||
*
|
||||
* @param key
|
||||
* The key must be alphabetical characters and <= 16 characters in length
|
||||
* The key must be alphabetical characters and <= 16 characters
|
||||
* in length
|
||||
*/
|
||||
public AbstractFlag(String key) {
|
||||
if (!StringUtils.isAlpha(key)) {
|
||||
@ -23,8 +25,10 @@ public class AbstractFlag {
|
||||
}
|
||||
this.key = key.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* AbstractFlag key
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getKey() {
|
||||
|
@ -21,27 +21,15 @@ public enum C {
|
||||
/*
|
||||
* Ratings
|
||||
*/
|
||||
RATING_NOT_VALID("&cYou need to specify a number between 1 and 10"),
|
||||
RATING_ALREADY_EXISTS("&cYou have already rated plot &c%s"),
|
||||
RATING_APPLIED("&cYou successfully rated plot &6%s"),
|
||||
RATING_NOT_YOUR_OWN("&cYou cannot rate your own plot"),
|
||||
RATING_NOT_OWNED("&cYou cannot rate a plot that is not claimed by anyone"),
|
||||
RATING_NOT_VALID("&cYou need to specify a number between 1 and 10"), RATING_ALREADY_EXISTS("&cYou have already rated plot &c%s"), RATING_APPLIED("&cYou successfully rated plot &6%s"), RATING_NOT_YOUR_OWN("&cYou cannot rate your own plot"), RATING_NOT_OWNED("&cYou cannot rate a plot that is not claimed by anyone"),
|
||||
/*
|
||||
* Economy Stuff
|
||||
*/
|
||||
CANNOT_AFFORD_PLOT("&cYou cannot afford to buy this plot. It costs &6%s"),
|
||||
CANNOT_AFFORD_MERGE("&cYou cannot afford to merge the plots. It costs &6%s"),
|
||||
REMOVED_BALANCE("&6%s &chas been taken from your balance"),
|
||||
CANNOT_AFFORD_PLOT("&cYou cannot afford to buy this plot. It costs &6%s"), CANNOT_AFFORD_MERGE("&cYou cannot afford to merge the plots. It costs &6%s"), REMOVED_BALANCE("&6%s &chas been taken from your balance"),
|
||||
/*
|
||||
* Setup Stuff
|
||||
*/
|
||||
SETUP_INIT("&6PlotSquared Setup -> Setup a new plotworld"),
|
||||
SETUP_STEP("&cStep &6%s&c: %s &c<Expecting: &6%s&c, Default: &6%s&c>"),
|
||||
SETUP_INVALID_ARG("&c%s is not a valid argument for step %s. To cancel setup use: /plot setup cancel"),
|
||||
SETUP_VALID_ARG("&cValue &6%s &cset for step %s"),
|
||||
SETUP_FINISHED("&cFinished setup for world &c%s.\n&4If you are using MULTIVERSE or MULTIWORLD you will need to import this world. Otherwise you will need to add this world to the 'bukkit.yml' file (See installation tutorial for more info)"),
|
||||
SETUP_WORLD_TAKEN("&c%s is already a registered plotworld"),
|
||||
SETUP_MISSING_WORLD("&cYou need to specify a world name (&6/p setup {world}&c)\n&6Additional commands:\n&c - &6/p setup <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"),
|
||||
SETUP_INIT("&6PlotSquared Setup -> Setup a new plotworld"), SETUP_STEP("&cStep &6%s&c: %s &c<Expecting: &6%s&c, Default: &6%s&c>"), SETUP_INVALID_ARG("&c%s is not a valid argument for step %s. To cancel setup use: /plot setup cancel"), SETUP_VALID_ARG("&cValue &6%s &cset for step %s"), SETUP_FINISHED("&cFinished setup for world &c%s.\n&4If you are using MULTIVERSE or MULTIWORLD you will need to import this world. Otherwise you will need to add this world to the 'bukkit.yml' file (See installation tutorial for more info)"), SETUP_WORLD_TAKEN("&c%s is already a registered plotworld"), SETUP_MISSING_WORLD("&cYou need to specify a world name (&6/p setup {world}&c)\n&6Additional commands:\n&c - &6/p setup <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"),
|
||||
/*
|
||||
* Schematic Stuff
|
||||
*/
|
||||
@ -77,11 +65,9 @@ public enum C {
|
||||
/*
|
||||
* Permission
|
||||
*/
|
||||
NO_SCHEMATIC_PERMISSION("&cYou don't have the permission required to use schematic &6%s"),
|
||||
NO_PERMISSION("&cYou don't have the permissions required to use this command."), 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."), YOU_BE_DENIED("&cYou are not allowed to enter this plot"),
|
||||
NO_SCHEMATIC_PERMISSION("&cYou don't have the permission required to use schematic &6%s"), NO_PERMISSION("&cYou don't have the permissions required to use this command."), 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."), YOU_BE_DENIED("&cYou are not allowed to enter this plot"),
|
||||
|
||||
NO_PERM_MERGE("&cYou are not the owner of the plot: &6%plot%"), UNLINK_REQUIRED("&cAn unlink is required to do this."), UNLINK_IMPOSSIBLE("&cYou can only unlink a mega-plot"),
|
||||
NO_MERGE_TO_MEGA("&cMega plots cannot be merged into. Please merge from the desired mega plot."),
|
||||
NO_PERM_MERGE("&cYou are not the owner of the plot: &6%plot%"), UNLINK_REQUIRED("&cAn unlink is required to do this."), UNLINK_IMPOSSIBLE("&cYou can only unlink a mega-plot"), NO_MERGE_TO_MEGA("&cMega plots cannot be merged into. Please merge from the desired mega plot."),
|
||||
/*
|
||||
* Commands
|
||||
*/
|
||||
@ -229,7 +215,7 @@ public enum C {
|
||||
*/
|
||||
C(String d) {
|
||||
this.d = d;
|
||||
if(PlotMain.translations == null) {
|
||||
if (PlotMain.translations == null) {
|
||||
this.s = d;
|
||||
} else {
|
||||
this.s = PlotMain.translations.getString(this.toString());
|
||||
|
@ -8,15 +8,17 @@ public class Flag {
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* Flag object used to store basic information for a Plot.
|
||||
* Flags are a key/value pair.
|
||||
* For a flag to be usable by a player, you need to register it with PlotSquared.
|
||||
* Flag object used to store basic information for a Plot. Flags are a
|
||||
* key/value pair. For a flag to be usable by a player, you need to register
|
||||
* it with PlotSquared.
|
||||
*
|
||||
* @param key
|
||||
* AbstractFlag
|
||||
* @param value
|
||||
* Value must be alphanumerical (can have spaces) and be <= 48 characters
|
||||
* @throws IllegalArgumentException if you provide inadequate inputs
|
||||
* Value must be alphanumerical (can have spaces) and be <= 48
|
||||
* characters
|
||||
* @throws IllegalArgumentException
|
||||
* if you provide inadequate inputs
|
||||
*/
|
||||
public Flag(AbstractFlag key, String value) {
|
||||
if (!StringUtils.isAlphanumericSpace(ChatColor.stripColor(value))) {
|
||||
@ -31,6 +33,7 @@ public class Flag {
|
||||
|
||||
/**
|
||||
* Get the AbstractFlag used in creating the flag
|
||||
*
|
||||
* @return AbstractFlag
|
||||
*/
|
||||
public AbstractFlag getAbstractFlag() {
|
||||
@ -39,6 +42,7 @@ public class Flag {
|
||||
|
||||
/**
|
||||
* Get the key for the AbstractFlag
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getKey() {
|
||||
@ -47,6 +51,7 @@ public class Flag {
|
||||
|
||||
/**
|
||||
* Get the value
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getValue() {
|
||||
|
@ -17,6 +17,7 @@ public class FlagManager {
|
||||
|
||||
/**
|
||||
* Register an AbstractFlag with PlotSquared
|
||||
*
|
||||
* @param flag
|
||||
* @return
|
||||
*/
|
||||
@ -29,6 +30,7 @@ public class FlagManager {
|
||||
|
||||
/**
|
||||
* Get a list of registered AbstractFlag objects
|
||||
*
|
||||
* @return List (AbstractFlag)
|
||||
*/
|
||||
public static List<AbstractFlag> getFlags() {
|
||||
@ -36,8 +38,8 @@ public class FlagManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an AbstractFlag by a string
|
||||
* Returns null if flag does not exist
|
||||
* Get an AbstractFlag by a string Returns null if flag does not exist
|
||||
*
|
||||
* @param string
|
||||
* @return AbstractFlag
|
||||
*/
|
||||
@ -69,9 +71,9 @@ public class FlagManager {
|
||||
|
||||
/**
|
||||
* Remove a registered AbstractFlag
|
||||
*
|
||||
* @param flag
|
||||
* @return boolean
|
||||
* Result of operation
|
||||
* @return boolean Result of operation
|
||||
*/
|
||||
public static boolean removeFlag(AbstractFlag flag) {
|
||||
return flags.remove(flag);
|
||||
@ -79,6 +81,7 @@ public class FlagManager {
|
||||
|
||||
/**
|
||||
* Get the flags for a plot
|
||||
*
|
||||
* @param plot
|
||||
* @return List (AbstractFlag)
|
||||
*/
|
||||
|
@ -1,12 +1,14 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.sk89q.worldedit.*;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
|
||||
@ -30,9 +32,9 @@ public class PWE {
|
||||
PlotId id = PlayerFunctions.getPlot(l);
|
||||
if (id != null) {
|
||||
Plot plot = PlotMain.getPlots(l.getWorld()).get(id);
|
||||
if (plot!=null) {
|
||||
if (plot != null) {
|
||||
boolean r;
|
||||
r = plot.getOwner() != null && plot.getOwner().equals(p.getUniqueId());
|
||||
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()))) {
|
||||
@ -41,8 +43,7 @@ public class PWE {
|
||||
removeMask(p, s);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
World w = p.getWorld();
|
||||
|
||||
@ -63,13 +64,12 @@ public class PWE {
|
||||
}
|
||||
}
|
||||
if (noMask(s)) {
|
||||
System.out.print("NONE");
|
||||
BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p);
|
||||
Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69);
|
||||
|
||||
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?");
|
||||
}
|
||||
}
|
||||
@ -77,9 +77,8 @@ public class PWE {
|
||||
public static boolean noMask(LocalSession s) {
|
||||
try {
|
||||
com.sk89q.worldedit.masks.Mask mask = s.getMask();
|
||||
return mask==null;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
return mask == null;
|
||||
} catch (Throwable e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -90,8 +89,7 @@ public class PWE {
|
||||
System.out.print(1);
|
||||
s.setMask(null);
|
||||
System.out.print(2);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
} catch (Throwable e) {
|
||||
System.out.print(3);
|
||||
com.sk89q.worldedit.masks.Mask mask = null;
|
||||
s.setMask(mask);
|
||||
@ -103,13 +101,13 @@ public class PWE {
|
||||
public static void removeMask(Player p) {
|
||||
try {
|
||||
LocalSession s;
|
||||
if(PlotMain.worldEdit == null) {
|
||||
if (PlotMain.worldEdit == null) {
|
||||
s = WorldEdit.getInstance().getSession(p.getName());
|
||||
} else {
|
||||
s = PlotMain.worldEdit.getSession(p);
|
||||
}
|
||||
removeMask(p, s);
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -61,7 +60,7 @@ public class PlayerFunctions {
|
||||
ArrayList<PlotId> myplots = new ArrayList<PlotId>();
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
myplots.add(new PlotId(x,y));
|
||||
myplots.add(new PlotId(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,22 +69,24 @@ public class PlayerFunctions {
|
||||
|
||||
public static Plot getBottomPlot(World world, Plot plot) {
|
||||
if (plot.settings.getMerged(0)) {
|
||||
return getBottomPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y-1)));
|
||||
return getBottomPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y - 1)));
|
||||
}
|
||||
if (plot.settings.getMerged(3)) {
|
||||
return getBottomPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x-1, plot.id.y)));
|
||||
return getBottomPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x - 1, plot.id.y)));
|
||||
}
|
||||
return plot;
|
||||
}
|
||||
|
||||
public static Plot getTopPlot(World world, Plot plot) {
|
||||
if (plot.settings.getMerged(2)) {
|
||||
return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y+1)));
|
||||
return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1)));
|
||||
}
|
||||
if (plot.settings.getMerged(1)) {
|
||||
return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x+1, plot.id.y)));
|
||||
return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x + 1, plot.id.y)));
|
||||
}
|
||||
return plot;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param loc
|
||||
@ -100,35 +101,34 @@ public class PlayerFunctions {
|
||||
int size = plotworld.PLOT_WIDTH + plotworld.ROAD_WIDTH;
|
||||
int pathWidthLower;
|
||||
if ((plotworld.ROAD_WIDTH % 2) == 0) {
|
||||
pathWidthLower = (int) (Math.floor(plotworld.ROAD_WIDTH / 2)-1);
|
||||
}
|
||||
else {
|
||||
pathWidthLower = (int) (Math.floor(plotworld.ROAD_WIDTH / 2) - 1);
|
||||
} else {
|
||||
pathWidthLower = (int) Math.floor(plotworld.ROAD_WIDTH / 2);
|
||||
}
|
||||
|
||||
int dx = x/size;
|
||||
int dz = z/size;
|
||||
int dx = x / size;
|
||||
int dz = z / size;
|
||||
|
||||
if (x<0) {
|
||||
if (x < 0) {
|
||||
dx--;
|
||||
x+=((-dx) * size);
|
||||
x += ((-dx) * size);
|
||||
}
|
||||
if (z<0) {
|
||||
if (z < 0) {
|
||||
dz--;
|
||||
z+=((-dz) * size);
|
||||
z += ((-dz) * size);
|
||||
}
|
||||
|
||||
int rx = (x)%size;
|
||||
int rz = (z)%size;
|
||||
int rx = (x) % size;
|
||||
int rz = (z) % size;
|
||||
|
||||
int end = pathWidthLower+plotworld.PLOT_WIDTH;
|
||||
boolean northSouth = rz<=pathWidthLower || rz>pathWidthLower+plotworld.PLOT_WIDTH;
|
||||
boolean eastWest = rx<=pathWidthLower || rx>end;
|
||||
int end = pathWidthLower + plotworld.PLOT_WIDTH;
|
||||
boolean northSouth = (rz <= pathWidthLower) || (rz > (pathWidthLower + plotworld.PLOT_WIDTH));
|
||||
boolean eastWest = (rx <= pathWidthLower) || (rx > end);
|
||||
|
||||
if (northSouth || eastWest) {
|
||||
return null;
|
||||
}
|
||||
return new PlotId(dx+1,dz+1);
|
||||
return new PlotId(dx + 1, dz + 1);
|
||||
}
|
||||
|
||||
public static PlotId getPlot(Location loc) {
|
||||
@ -137,43 +137,42 @@ public class PlayerFunctions {
|
||||
|
||||
String world = loc.getWorld().getName();
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
if (plotworld==null) {
|
||||
if (plotworld == null) {
|
||||
return null;
|
||||
}
|
||||
int size = plotworld.PLOT_WIDTH + plotworld.ROAD_WIDTH;
|
||||
int pathWidthLower;
|
||||
if ((plotworld.ROAD_WIDTH % 2) == 0) {
|
||||
pathWidthLower = (int) (Math.floor(plotworld.ROAD_WIDTH / 2)-1);
|
||||
}
|
||||
else {
|
||||
pathWidthLower = (int) (Math.floor(plotworld.ROAD_WIDTH / 2) - 1);
|
||||
} else {
|
||||
pathWidthLower = (int) Math.floor(plotworld.ROAD_WIDTH / 2);
|
||||
}
|
||||
|
||||
int dx = x/size;
|
||||
int dz = z/size;
|
||||
int dx = x / size;
|
||||
int dz = z / size;
|
||||
|
||||
if (x<0) {
|
||||
if (x < 0) {
|
||||
dx--;
|
||||
x+=((-dx) * size);
|
||||
x += ((-dx) * size);
|
||||
}
|
||||
if (z<0) {
|
||||
if (z < 0) {
|
||||
dz--;
|
||||
z+=((-dz) * size);
|
||||
z += ((-dz) * size);
|
||||
}
|
||||
|
||||
int rx = (x)%size;
|
||||
int rz = (z)%size;
|
||||
int rx = (x) % 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 eastWest = rx<=pathWidthLower || rx>end;
|
||||
boolean northSouth = (rz <= pathWidthLower) || (rz > (pathWidthLower + plotworld.PLOT_WIDTH));
|
||||
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));
|
||||
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||
if (plot==null) {
|
||||
if (plot == null) {
|
||||
return null;
|
||||
}
|
||||
if ((plot.settings.getMerged(0) && plot.settings.getMerged(3))) {
|
||||
@ -182,10 +181,11 @@ public class PlayerFunctions {
|
||||
return null;
|
||||
}
|
||||
if (northSouth) {
|
||||
// You are on a road running West to East (yeah, I named the var poorly)
|
||||
// You are on a road running West to East (yeah, I named the var
|
||||
// poorly)
|
||||
PlotId id = getPlotAbs(loc.add(0, 0, plotworld.ROAD_WIDTH));
|
||||
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||
if (plot==null) {
|
||||
if (plot == null) {
|
||||
return null;
|
||||
}
|
||||
if (plot.settings.getMerged(0)) {
|
||||
@ -197,7 +197,7 @@ public class PlayerFunctions {
|
||||
// This is the road separating an Eastern and Western plot
|
||||
PlotId id = getPlotAbs(loc.add(plotworld.ROAD_WIDTH, 0, 0));
|
||||
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||
if (plot==null) {
|
||||
if (plot == null) {
|
||||
return null;
|
||||
}
|
||||
if (plot.settings.getMerged(3)) {
|
||||
@ -205,9 +205,9 @@ public class PlayerFunctions {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
PlotId id = new PlotId(dx+1,dz+1);
|
||||
PlotId id = new PlotId(dx + 1, dz + 1);
|
||||
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||
if (plot==null) {
|
||||
if (plot == null) {
|
||||
return id;
|
||||
}
|
||||
return getBottomPlot(loc.getWorld(), plot).id;
|
||||
|
@ -157,7 +157,7 @@ public class Plot implements Cloneable {
|
||||
* @return true if the player is added as a helper or is the owner
|
||||
*/
|
||||
public boolean hasRights(Player player) {
|
||||
return player.hasPermission("plots.admin") || ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(player.getUniqueId())) || ((this.owner != null) && this.owner.equals(player.getUniqueId())) || (this.owner != null && this.trusted != null && Bukkit.getPlayer(this.owner) != null && (this.trusted.contains(player.getUniqueId()) || this.trusted.contains(DBFunc.everyone)));
|
||||
return player.hasPermission("plots.admin") || ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(player.getUniqueId())) || ((this.owner != null) && this.owner.equals(player.getUniqueId())) || ((this.owner != null) && (this.trusted != null) && (Bukkit.getPlayer(this.owner) != null) && (this.trusted.contains(player.getUniqueId()) || this.trusted.contains(DBFunc.everyone)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,7 +226,6 @@ public class Plot implements Cloneable {
|
||||
this.helpers.add(uuid);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add someone as a trusted user (use DBFunc as well)
|
||||
*
|
||||
|
@ -9,8 +9,19 @@
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import org.bukkit.*;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -19,8 +30,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
|
||||
/**
|
||||
* plot functions
|
||||
@ -38,6 +48,7 @@ public class PlotHelper {
|
||||
|
||||
/**
|
||||
* direction 0 = north, 1 = south, etc:
|
||||
*
|
||||
* @param plot
|
||||
* @param direction
|
||||
* @return
|
||||
@ -45,25 +56,27 @@ public class PlotHelper {
|
||||
public static PlotId getPlotIdRelative(PlotId id, int direction) {
|
||||
switch (direction) {
|
||||
case 0:
|
||||
return new PlotId(id.x,id.y-1);
|
||||
return new PlotId(id.x, id.y - 1);
|
||||
case 1:
|
||||
return new PlotId(id.x+1,id.y);
|
||||
return new PlotId(id.x + 1, id.y);
|
||||
case 2:
|
||||
return new PlotId(id.x,id.y+1);
|
||||
return new PlotId(id.x, id.y + 1);
|
||||
case 3:
|
||||
return new PlotId(id.x-1,id.y);
|
||||
return new PlotId(id.x - 1, id.y);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Completely merges a set of plots<br>
|
||||
* <b>(There are no checks to make sure you supply the correct arguments)</b><br>
|
||||
* <b>(There are no checks to make sure you supply the correct
|
||||
* arguments)</b><br>
|
||||
* - Misuse of this method can result in unusable plots<br>
|
||||
* - the set of plots must belong to one owner and be rectangular<br>
|
||||
* - the plot array must be sorted in ascending order<br>
|
||||
* - Road will be removed where required<br>
|
||||
* - changes will be saved to DB<br>
|
||||
*
|
||||
* @param world
|
||||
* @param plotIds
|
||||
* @return boolean (success)
|
||||
@ -73,7 +86,7 @@ public class PlotHelper {
|
||||
int pathsize = plotworld.ROAD_WIDTH;
|
||||
int plotheight = plotworld.PLOT_HEIGHT;
|
||||
|
||||
if (plotIds.size()<2) {
|
||||
if (plotIds.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -95,7 +108,7 @@ public class PlotHelper {
|
||||
}
|
||||
|
||||
PlotId pos1 = plotIds.get(0);
|
||||
PlotId pos2 = plotIds.get(plotIds.size()-1);
|
||||
PlotId pos2 = plotIds.get(plotIds.size() - 1);
|
||||
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
@ -103,7 +116,7 @@ public class PlotHelper {
|
||||
boolean lx = x < pos2.x;
|
||||
boolean ly = y < pos2.y;
|
||||
|
||||
PlotId id = new PlotId(x,y);
|
||||
PlotId id = new PlotId(x, y);
|
||||
Plot plot = PlotMain.getPlots(world).get(id);
|
||||
|
||||
if (lx) {
|
||||
@ -111,19 +124,19 @@ public class PlotHelper {
|
||||
if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) {
|
||||
Location loc = getPlotTopLocAbs(world, id);
|
||||
|
||||
int sx = loc.getBlockX()+1;
|
||||
int ex = sx + pathsize - 1;
|
||||
int sz = loc.getBlockZ()+1;
|
||||
int ez = sz + pathsize - 1;
|
||||
int sx = loc.getBlockX() + 1;
|
||||
int ex = (sx + pathsize) - 1;
|
||||
int sz = loc.getBlockZ() + 1;
|
||||
int ez = (sz + pathsize) - 1;
|
||||
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world,sx,plotheight+1,sz), new Location(world,ex+1,257+1,ez+1), (short) 0);
|
||||
PlotHelper.setSimpleCuboid(world, new Location(world, sx, plotheight + 1, sz), new Location(world, ex + 1, 257 + 1, ez + 1), (short) 0);
|
||||
|
||||
PlotHelper.setCuboid(world, new Location(world,sx+1,1,sz+1), new Location(world,ex,plotheight,ez), filling,filling_data);
|
||||
PlotHelper.setCuboid(world, new Location(world,sx+1,plotheight,sz+1), new Location(world,ex,plotheight+1,ez), plotfloors,plotfloors_data);
|
||||
PlotHelper.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, plotheight, ez), filling, filling_data);
|
||||
PlotHelper.setCuboid(world, new Location(world, sx + 1, plotheight, sz + 1), new Location(world, ex, plotheight + 1, ez), plotfloors, plotfloors_data);
|
||||
}
|
||||
}
|
||||
if (!plot.settings.getMerged(1)) {
|
||||
Plot plot2 = PlotMain.getPlots(world).get(new PlotId(x+1,y));
|
||||
Plot plot2 = PlotMain.getPlots(world).get(new PlotId(x + 1, y));
|
||||
mergePlot(world, plot, plot2);
|
||||
plot.settings.setMerged(1, true);
|
||||
plot2.settings.setMerged(3, true);
|
||||
@ -131,7 +144,7 @@ public class PlotHelper {
|
||||
}
|
||||
if (ly) {
|
||||
if (!plot.settings.getMerged(2)) {
|
||||
Plot plot2 = PlotMain.getPlots(world).get(new PlotId(x,y+1));
|
||||
Plot plot2 = PlotMain.getPlots(world).get(new PlotId(x, y + 1));
|
||||
mergePlot(world, plot, plot2);
|
||||
plot.settings.setMerged(2, true);
|
||||
plot2.settings.setMerged(0, true);
|
||||
@ -142,16 +155,16 @@ public class PlotHelper {
|
||||
}
|
||||
|
||||
Location megaPlotBot = getPlotBottomLoc(world, pos1);
|
||||
Location megaPlotTop = getPlotTopLoc(world, pos2).add(1,0,1);
|
||||
Location megaPlotTop = getPlotTopLoc(world, pos2).add(1, 0, 1);
|
||||
|
||||
short[] result_w = PlotHelper.getBlock(plotworld.WALL_BLOCK);
|
||||
short w_id = result_w[0];
|
||||
byte w_v = (byte) result_w[1];
|
||||
|
||||
for (int x = megaPlotBot.getBlockX(); x<=megaPlotTop.getBlockX(); x++) {
|
||||
for (int z = megaPlotBot.getBlockZ(); z<=megaPlotTop.getBlockZ(); z++) {
|
||||
if (z == megaPlotBot.getBlockZ() || z==megaPlotTop.getBlockZ() || x==megaPlotBot.getBlockX() || x==megaPlotTop.getBlockX()) {
|
||||
world.getBlockAt(x, plotworld.WALL_HEIGHT+1, z).setTypeIdAndData(w_id, w_v, false);
|
||||
for (int x = megaPlotBot.getBlockX(); x <= megaPlotTop.getBlockX(); x++) {
|
||||
for (int z = megaPlotBot.getBlockZ(); z <= megaPlotTop.getBlockZ(); z++) {
|
||||
if ((z == megaPlotBot.getBlockZ()) || (z == megaPlotTop.getBlockZ()) || (x == megaPlotBot.getBlockX()) || (x == megaPlotTop.getBlockX())) {
|
||||
world.getBlockAt(x, plotworld.WALL_HEIGHT + 1, z).setTypeIdAndData(w_id, w_v, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -160,32 +173,32 @@ public class PlotHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges 2 plots
|
||||
* Removes the road inbetween
|
||||
* <br> - Assumes the first plot parameter is lower
|
||||
* <br> - Assumes neither are a Mega-plot
|
||||
* <br> - Assumes plots are directly next to each other
|
||||
* <br> - Saves to DB
|
||||
* Merges 2 plots Removes the road inbetween <br>
|
||||
* - Assumes the first plot parameter is lower <br>
|
||||
* - Assumes neither are a Mega-plot <br>
|
||||
* - Assumes plots are directly next to each other <br>
|
||||
* - Saves to DB
|
||||
*
|
||||
* @param world
|
||||
* @param lesserPlot
|
||||
* @param greaterPlot
|
||||
*/
|
||||
public static void mergePlot(World world, Plot lesserPlot, Plot greaterPlot) {
|
||||
Location pos1 = getPlotBottomLocAbs(world, lesserPlot.id).add(1,0,1);
|
||||
Location pos1 = getPlotBottomLocAbs(world, lesserPlot.id).add(1, 0, 1);
|
||||
Location pos2 = getPlotTopLocAbs(world, lesserPlot.id);
|
||||
|
||||
Location pos3 = getPlotBottomLocAbs(world, greaterPlot.id).add(1,0,1);
|
||||
Location pos3 = getPlotBottomLocAbs(world, greaterPlot.id).add(1, 0, 1);
|
||||
Location pos4 = getPlotTopLocAbs(world, greaterPlot.id);
|
||||
|
||||
int sx = Math.max(pos1.getBlockX(),pos2.getBlockX());
|
||||
int ex = Math.min(pos3.getBlockX(),pos4.getBlockX());
|
||||
int sz = Math.max(pos1.getBlockZ(),pos2.getBlockZ());
|
||||
int ez = Math.min(pos3.getBlockZ(),pos4.getBlockZ());
|
||||
int sx = Math.max(pos1.getBlockX(), pos2.getBlockX());
|
||||
int ex = Math.min(pos3.getBlockX(), pos4.getBlockX());
|
||||
int sz = Math.max(pos1.getBlockZ(), pos2.getBlockZ());
|
||||
int ez = Math.min(pos3.getBlockZ(), pos4.getBlockZ());
|
||||
|
||||
int startx = Math.min(sx,ex);
|
||||
int startz = Math.min(sz,ez);
|
||||
int endx = Math.max(sx,ex)+1;
|
||||
int endz = Math.max(sz,ez)+1;
|
||||
int startx = Math.min(sx, ex);
|
||||
int startz = Math.min(sz, ez);
|
||||
int endx = Math.max(sx, ex) + 1;
|
||||
int endz = Math.max(sz, ez) + 1;
|
||||
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
|
||||
@ -216,8 +229,7 @@ public class PlotHelper {
|
||||
greaterPlot.settings.setMerged(0, true);
|
||||
startx--;
|
||||
endx++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
noMerge = lesserPlot.settings.getMerged(1);
|
||||
|
||||
@ -343,10 +355,10 @@ public class PlotHelper {
|
||||
}
|
||||
|
||||
public static void autoMerge(World world, Plot plot, Player player) {
|
||||
if (plot==null) {
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if(plot.owner==null) {
|
||||
if (plot.owner == null) {
|
||||
return;
|
||||
}
|
||||
if (!plot.owner.equals(player.getUniqueId())) {
|
||||
@ -359,26 +371,26 @@ public class PlotHelper {
|
||||
PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id;
|
||||
PlotId top = PlayerFunctions.getTopPlot(world, plot).id;
|
||||
merge = false;
|
||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x,bot.y-1), new PlotId(top.x,top.y));
|
||||
if (ownsPlots(world,plots,player, 0)) {
|
||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
||||
if (ownsPlots(world, plots, player, 0)) {
|
||||
merge = true;
|
||||
mergePlots(world, plots);
|
||||
continue;
|
||||
}
|
||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x,bot.y), new PlotId(top.x+1,top.y));
|
||||
if (ownsPlots(world,plots,player, 1)) {
|
||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
||||
if (ownsPlots(world, plots, player, 1)) {
|
||||
merge = true;
|
||||
mergePlots(world, plots);
|
||||
continue;
|
||||
}
|
||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x,bot.y), new PlotId(top.x,top.y+1));
|
||||
if (ownsPlots(world,plots,player, 2)) {
|
||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
||||
if (ownsPlots(world, plots, player, 2)) {
|
||||
merge = true;
|
||||
mergePlots(world, plots);
|
||||
continue;
|
||||
}
|
||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x-1,bot.y), new PlotId(top.x,top.y));
|
||||
if (ownsPlots(world,plots,player, 3)) {
|
||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
||||
if (ownsPlots(world, plots, player, 3)) {
|
||||
merge = true;
|
||||
mergePlots(world, plots);
|
||||
continue;
|
||||
@ -388,20 +400,21 @@ public class PlotHelper {
|
||||
SetBlockFast.update(player);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean ownsPlots(World world, ArrayList<PlotId> plots, Player player, int dir) {
|
||||
PlotId id_min = plots.get(0);
|
||||
PlotId id_max = plots.get(plots.size()-1);
|
||||
for (PlotId myid:plots) {
|
||||
PlotId id_max = plots.get(plots.size() - 1);
|
||||
for (PlotId myid : plots) {
|
||||
Plot myplot = PlotMain.getPlots(world).get(myid);
|
||||
if (myplot==null || !myplot.hasOwner() || !(myplot.getOwner().equals(player.getUniqueId()))) {
|
||||
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(player.getUniqueId()))) {
|
||||
return false;
|
||||
}
|
||||
PlotId top = PlayerFunctions.getTopPlot(world, myplot).id;
|
||||
if ((top.x > id_max.x && dir != 1) || (top.y > id_max.y && dir != 2)) {
|
||||
if (((top.x > id_max.x) && (dir != 1)) || ((top.y > id_max.y) && (dir != 2))) {
|
||||
return false;
|
||||
}
|
||||
PlotId bot = PlayerFunctions.getBottomPlot(world, myplot).id;
|
||||
if ((bot.x < id_min.x && dir != 3) || (bot.y < id_min.y && dir != 0)) {
|
||||
if (((bot.x < id_min.x) && (dir != 3)) || ((bot.y < id_min.y) && (dir != 0))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -441,7 +454,7 @@ public class PlotHelper {
|
||||
}
|
||||
|
||||
public static double getWorldFolderSize(World world) {
|
||||
//long size = FileUtil.sizeOfDirectory(world.getWorldFolder());
|
||||
// long size = FileUtil.sizeOfDirectory(world.getWorldFolder());
|
||||
File folder = world.getWorldFolder();
|
||||
long size = folder.length();
|
||||
return (((size) / 1024) / 1024);
|
||||
@ -729,12 +742,12 @@ public class PlotHelper {
|
||||
public static void teleportPlayers(World world, Plot plot, boolean tile) {
|
||||
final Location pos1 = getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = getPlotTopLoc(world, plot.id);
|
||||
for (int i = (pos2.getBlockX() / 16) * 16; i < 16 + (pos2. getBlockX() / 16) * 16; i= 16) {
|
||||
for (int j = (pos1. getBlockZ() / 16) * 16; j < 16 + (pos2.getBlockZ() / 16) * 16; j += 16) {
|
||||
for (int i = (pos2.getBlockX() / 16) * 16; i < (16 + ((pos2.getBlockX() / 16) * 16)); i = 16) {
|
||||
for (int j = (pos1.getBlockZ() / 16) * 16; j < (16 + ((pos2.getBlockZ() / 16) * 16)); j += 16) {
|
||||
Chunk chunk = world.getChunkAt(i, j);
|
||||
for (Entity entity : chunk.getEntities()) {
|
||||
PlotId id = PlayerFunctions.getPlot(entity.getLocation());
|
||||
if(id != null && id.equals(plot.id) && entity.getType() == EntityType.PLAYER) {
|
||||
if ((id != null) && id.equals(plot.id) && (entity.getType() == EntityType.PLAYER)) {
|
||||
entity.teleport(world.getSpawnLocation());
|
||||
// Should this teleport them to floor instead?
|
||||
}
|
||||
@ -742,20 +755,21 @@ public class PlotHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearAllEntities(World world, Plot plot, boolean tile) {
|
||||
final Location pos1 = getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = getPlotTopLoc(world, plot.id);
|
||||
for (int i = (pos1.getBlockX() / 16) * 16; i < 16+(pos2.getBlockX() / 16) * 16; i += 16) {
|
||||
for (int j = (pos1.getBlockZ() / 16) * 16; j < 16+(pos2.getBlockZ() / 16) * 16; j += 16) {
|
||||
for (int i = (pos1.getBlockX() / 16) * 16; i < (16 + ((pos2.getBlockX() / 16) * 16)); i += 16) {
|
||||
for (int j = (pos1.getBlockZ() / 16) * 16; j < (16 + ((pos2.getBlockZ() / 16) * 16)); j += 16) {
|
||||
Chunk chunk = world.getChunkAt(i, j);
|
||||
for (Entity entity:chunk.getEntities()) {
|
||||
for (Entity entity : chunk.getEntities()) {
|
||||
PlotId id = PlayerFunctions.getPlot(entity.getLocation());
|
||||
if (id!=null && id.equals(plot.id)) {
|
||||
if ((id != null) && id.equals(plot.id)) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
if (tile) {
|
||||
for (BlockState entity:chunk.getTileEntities()) {
|
||||
for (BlockState entity : chunk.getTileEntities()) {
|
||||
entity.setRawData((byte) 0);
|
||||
}
|
||||
}
|
||||
@ -765,6 +779,7 @@ public class PlotHelper {
|
||||
|
||||
/**
|
||||
* Clear a plot
|
||||
*
|
||||
* @param requester
|
||||
* @param plot
|
||||
*/
|
||||
@ -775,7 +790,7 @@ public class PlotHelper {
|
||||
|
||||
// clear entities:
|
||||
clearAllEntities(world, plot, false);
|
||||
//teleport players
|
||||
// teleport players
|
||||
teleportPlayers(world, plot, false);
|
||||
|
||||
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
@ -925,8 +940,7 @@ public class PlotHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
|
||||
@ -941,8 +955,7 @@ public class PlotHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -959,8 +972,7 @@ public class PlotHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
|
||||
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
|
||||
@ -972,8 +984,7 @@ public class PlotHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
@ -1088,7 +1099,7 @@ public class PlotHelper {
|
||||
|
||||
public static Location getPlotTopLoc(World world, PlotId id) {
|
||||
Plot plot = PlotMain.getPlots(world).get(id);
|
||||
if (plot!=null) {
|
||||
if (plot != null) {
|
||||
id = PlayerFunctions.getTopPlot(world, plot).id;
|
||||
}
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
@ -1103,7 +1114,7 @@ public class PlotHelper {
|
||||
|
||||
public static Location getPlotBottomLoc(World world, PlotId id) {
|
||||
Plot plot = PlotMain.getPlots(world).get(id);
|
||||
if (plot!=null) {
|
||||
if (plot != null) {
|
||||
id = PlayerFunctions.getBottomPlot(world, plot).id;
|
||||
}
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
|
@ -12,6 +12,7 @@ public class PlotId {
|
||||
|
||||
/**
|
||||
* PlotId class (PlotId x,y values do not correspond to Block locations)
|
||||
*
|
||||
* @param x
|
||||
* The plot x coordinate
|
||||
* @param y
|
||||
@ -39,7 +40,7 @@ public class PlotId {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.x+";"+this.y;
|
||||
return this.x + ";" + this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,6 +9,126 @@
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import static org.bukkit.Material.ACACIA_STAIRS;
|
||||
import static org.bukkit.Material.BEACON;
|
||||
import static org.bukkit.Material.BEDROCK;
|
||||
import static org.bukkit.Material.BIRCH_WOOD_STAIRS;
|
||||
import static org.bukkit.Material.BOOKSHELF;
|
||||
import static org.bukkit.Material.BREWING_STAND;
|
||||
import static org.bukkit.Material.BRICK;
|
||||
import static org.bukkit.Material.BRICK_STAIRS;
|
||||
import static org.bukkit.Material.BURNING_FURNACE;
|
||||
import static org.bukkit.Material.CAKE_BLOCK;
|
||||
import static org.bukkit.Material.CAULDRON;
|
||||
import static org.bukkit.Material.CLAY;
|
||||
import static org.bukkit.Material.CLAY_BRICK;
|
||||
import static org.bukkit.Material.COAL_BLOCK;
|
||||
import static org.bukkit.Material.COAL_ORE;
|
||||
import static org.bukkit.Material.COBBLESTONE;
|
||||
import static org.bukkit.Material.COBBLESTONE_STAIRS;
|
||||
import static org.bukkit.Material.COBBLE_WALL;
|
||||
import static org.bukkit.Material.COMMAND;
|
||||
import static org.bukkit.Material.DARK_OAK_STAIRS;
|
||||
import static org.bukkit.Material.DAYLIGHT_DETECTOR;
|
||||
import static org.bukkit.Material.DIAMOND_BLOCK;
|
||||
import static org.bukkit.Material.DIAMOND_ORE;
|
||||
import static org.bukkit.Material.DIRT;
|
||||
import static org.bukkit.Material.DISPENSER;
|
||||
import static org.bukkit.Material.DROPPER;
|
||||
import static org.bukkit.Material.EMERALD_BLOCK;
|
||||
import static org.bukkit.Material.EMERALD_ORE;
|
||||
import static org.bukkit.Material.ENCHANTMENT_TABLE;
|
||||
import static org.bukkit.Material.ENDER_PORTAL_FRAME;
|
||||
import static org.bukkit.Material.ENDER_STONE;
|
||||
import static org.bukkit.Material.FURNACE;
|
||||
import static org.bukkit.Material.GLASS;
|
||||
import static org.bukkit.Material.GLOWSTONE;
|
||||
import static org.bukkit.Material.GOLD_BLOCK;
|
||||
import static org.bukkit.Material.GOLD_ORE;
|
||||
import static org.bukkit.Material.GRASS;
|
||||
import static org.bukkit.Material.GRAVEL;
|
||||
import static org.bukkit.Material.HARD_CLAY;
|
||||
import static org.bukkit.Material.HAY_BLOCK;
|
||||
import static org.bukkit.Material.HUGE_MUSHROOM_1;
|
||||
import static org.bukkit.Material.HUGE_MUSHROOM_2;
|
||||
import static org.bukkit.Material.IRON_BLOCK;
|
||||
import static org.bukkit.Material.IRON_ORE;
|
||||
import static org.bukkit.Material.JACK_O_LANTERN;
|
||||
import static org.bukkit.Material.JUKEBOX;
|
||||
import static org.bukkit.Material.JUNGLE_WOOD_STAIRS;
|
||||
import static org.bukkit.Material.LAPIS_BLOCK;
|
||||
import static org.bukkit.Material.LAPIS_ORE;
|
||||
import static org.bukkit.Material.LEAVES;
|
||||
import static org.bukkit.Material.LEAVES_2;
|
||||
import static org.bukkit.Material.LOG;
|
||||
import static org.bukkit.Material.LOG_2;
|
||||
import static org.bukkit.Material.MELON_BLOCK;
|
||||
import static org.bukkit.Material.MOB_SPAWNER;
|
||||
import static org.bukkit.Material.MOSSY_COBBLESTONE;
|
||||
import static org.bukkit.Material.MYCEL;
|
||||
import static org.bukkit.Material.NETHERRACK;
|
||||
import static org.bukkit.Material.NETHER_BRICK;
|
||||
import static org.bukkit.Material.NETHER_BRICK_STAIRS;
|
||||
import static org.bukkit.Material.NOTE_BLOCK;
|
||||
import static org.bukkit.Material.OBSIDIAN;
|
||||
import static org.bukkit.Material.PACKED_ICE;
|
||||
import static org.bukkit.Material.PUMPKIN;
|
||||
import static org.bukkit.Material.QUARTZ_BLOCK;
|
||||
import static org.bukkit.Material.QUARTZ_ORE;
|
||||
import static org.bukkit.Material.QUARTZ_STAIRS;
|
||||
import static org.bukkit.Material.REDSTONE_BLOCK;
|
||||
import static org.bukkit.Material.SAND;
|
||||
import static org.bukkit.Material.SANDSTONE;
|
||||
import static org.bukkit.Material.SANDSTONE_STAIRS;
|
||||
import static org.bukkit.Material.SMOOTH_BRICK;
|
||||
import static org.bukkit.Material.SMOOTH_STAIRS;
|
||||
import static org.bukkit.Material.SNOW_BLOCK;
|
||||
import static org.bukkit.Material.SOUL_SAND;
|
||||
import static org.bukkit.Material.SPONGE;
|
||||
import static org.bukkit.Material.SPRUCE_WOOD_STAIRS;
|
||||
import static org.bukkit.Material.STONE;
|
||||
import static org.bukkit.Material.WOOD;
|
||||
import static org.bukkit.Material.WOOD_STAIRS;
|
||||
import static org.bukkit.Material.WOOL;
|
||||
import static org.bukkit.Material.WORKBENCH;
|
||||
import static org.bukkit.Material.getMaterial;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import me.confuser.barapi.BarAPI;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import ca.mera.CameraAPI;
|
||||
|
||||
import com.intellectualcrafters.plot.Logger.LogLevel;
|
||||
@ -27,31 +147,6 @@ import com.intellectualcrafters.plot.listeners.WorldGuardListener;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
|
||||
import me.confuser.barapi.BarAPI;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static org.bukkit.Material.*;
|
||||
|
||||
/**
|
||||
* @awesome @author Citymonstret, Empire92 PlotMain class.
|
||||
*/
|
||||
@ -124,6 +219,7 @@ public class PlotMain extends JavaPlugin {
|
||||
/**
|
||||
* Check a range of permissions e.g. 'plots.plot.<0-100>'<br>
|
||||
* Returns highest integer in range.
|
||||
*
|
||||
* @param player
|
||||
* @param stub
|
||||
* @param range
|
||||
@ -133,11 +229,11 @@ public class PlotMain extends JavaPlugin {
|
||||
if (player.isOp()) {
|
||||
return range;
|
||||
}
|
||||
if (player.hasPermission(stub+".*")) {
|
||||
if (player.hasPermission(stub + ".*")) {
|
||||
return range;
|
||||
}
|
||||
for (int i = range; i>0; i--) {
|
||||
if (player.hasPermission(stub+"."+i)) {
|
||||
for (int i = range; i > 0; i--) {
|
||||
if (player.hasPermission(stub + "." + i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@ -148,6 +244,7 @@ public class PlotMain extends JavaPlugin {
|
||||
* Check a player for a permission<br>
|
||||
* - Op has all permissions <br>
|
||||
* - checks for '*' nodes
|
||||
*
|
||||
* @param player
|
||||
* @param perm
|
||||
* @return
|
||||
@ -156,25 +253,25 @@ public class PlotMain extends JavaPlugin {
|
||||
if (player.isOp()) {
|
||||
return true;
|
||||
}
|
||||
for (String perm:perms) {
|
||||
for (String perm : perms) {
|
||||
boolean hasperm = false;
|
||||
if (player.hasPermission(perm)) {
|
||||
hasperm = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
String[] nodes = perm.split("\\.");
|
||||
StringBuilder n = new StringBuilder();
|
||||
for(int i = 0; i < nodes.length-1; i++) {
|
||||
n.append(nodes[i]+".");
|
||||
if (player.hasPermission(n+"*")) {
|
||||
for (int i = 0; i < (nodes.length - 1); i++) {
|
||||
n.append(nodes[i] + ".");
|
||||
if (player.hasPermission(n + "*")) {
|
||||
hasperm = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hasperm)
|
||||
if (!hasperm) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -183,6 +280,7 @@ public class PlotMain extends JavaPlugin {
|
||||
* Check a player for a permission<br>
|
||||
* - Op has all permissions <br>
|
||||
* - checks for '*' nodes
|
||||
*
|
||||
* @param player
|
||||
* @param perm
|
||||
* @return
|
||||
@ -196,9 +294,9 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
String[] nodes = perm.split("\\.");
|
||||
StringBuilder n = new StringBuilder();
|
||||
for(int i = 0; i < nodes.length-1; i++) {
|
||||
n.append(nodes[i]+".");
|
||||
if (player.hasPermission(n+"*")) {
|
||||
for (int i = 0; i < (nodes.length - 1); i++) {
|
||||
n.append(nodes[i] + ".");
|
||||
if (player.hasPermission(n + "*")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -214,6 +312,7 @@ public class PlotMain extends JavaPlugin {
|
||||
* All loaded plot worlds
|
||||
*/
|
||||
private static HashMap<String, PlotWorld> worlds = new HashMap<String, PlotWorld>();
|
||||
|
||||
/**
|
||||
* Get all plots
|
||||
*
|
||||
@ -277,6 +376,7 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
return new HashMap<PlotId, Plot>();
|
||||
}
|
||||
|
||||
/**
|
||||
* get all plot worlds
|
||||
*/
|
||||
@ -363,21 +463,20 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Implement better system
|
||||
* The whole point of this system is to recycle old plots
|
||||
* So why not just allow users to claim old plots, and try to hide the fact that the are owned.
|
||||
* Reduce amount of expired plots:
|
||||
* - On /plot auto - allow claiming of old plot, clear it so the user doesn't know
|
||||
* - On /plot info, - show that the plot is expired and allowed to be claimed
|
||||
* TODO: Implement better system The whole point of this system is to
|
||||
* recycle old plots So why not just allow users to claim old plots, and try
|
||||
* to hide the fact that the are owned. Reduce amount of expired plots: - On
|
||||
* /plot auto - allow claiming of old plot, clear it so the user doesn't
|
||||
* know - On /plot info, - show that the plot is expired and allowed to be
|
||||
* claimed
|
||||
*
|
||||
* Have the task run less often:
|
||||
* - Run the task when there are very little, or no players online (great for small servers)
|
||||
* - Run the task at startup (also only useful for small servers)
|
||||
* Have the task run less often: - Run the task when there are very little,
|
||||
* or no players online (great for small servers) - Run the task at startup
|
||||
* (also only useful for small servers)
|
||||
*
|
||||
* Also, in terms of faster code:
|
||||
* - Have an array of plots, sorted by expiry time.
|
||||
* - Add new plots to the end.
|
||||
* - The task then only needs to go through the first few plots
|
||||
* Also, in terms of faster code: - Have an array of plots, sorted by expiry
|
||||
* time. - Add new plots to the end. - The task then only needs to go
|
||||
* through the first few plots
|
||||
*
|
||||
* @param plugin
|
||||
* Plugin
|
||||
@ -396,8 +495,10 @@ public class PlotMain extends JavaPlugin {
|
||||
continue;
|
||||
}
|
||||
long lastPlayed = getLastPlayed(plot.owner);
|
||||
if(lastPlayed == 0) continue;
|
||||
int days = (int) (lastPlayed / (1000*60*60*24));
|
||||
if (lastPlayed == 0) {
|
||||
continue;
|
||||
}
|
||||
int days = (int) (lastPlayed / (1000 * 60 * 60 * 24));
|
||||
if (days >= Settings.AUTO_CLEAR_DAYS) {
|
||||
PlotDeleteEvent event = new PlotDeleteEvent(world, plot.id);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
@ -501,12 +602,11 @@ public class PlotMain extends JavaPlugin {
|
||||
DatabaseMetaData meta = connection.getMetaData();
|
||||
ResultSet res = meta.getTables(null, null, "plot", null);
|
||||
if (!res.next()) {
|
||||
DBFunc.createTables("mysql",true);
|
||||
}
|
||||
else {
|
||||
DBFunc.createTables("mysql", true);
|
||||
} else {
|
||||
res = meta.getTables(null, null, "plot_trusted", null);
|
||||
if (!res.next()) {
|
||||
DBFunc.createTables("mysql",false);
|
||||
DBFunc.createTables("mysql", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -579,19 +679,20 @@ public class PlotMain extends JavaPlugin {
|
||||
worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
getServer().getPluginManager().registerEvents(new WorldEditListener(), this);
|
||||
}
|
||||
if (Settings.WORLDGUARD)
|
||||
if (Settings.WORLDGUARD) {
|
||||
if (getServer().getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
worldGuard = (WorldGuardPlugin) getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
worldGuardListener = new WorldGuardListener(this);
|
||||
getServer().getPluginManager().registerEvents(worldGuardListener, this);
|
||||
}
|
||||
if(Settings.AUTO_CLEAR) {
|
||||
}
|
||||
if (Settings.AUTO_CLEAR) {
|
||||
checkExpired(PlotMain.getMain(), true);
|
||||
checkForExpiredPlots();
|
||||
}
|
||||
if(getServer().getPluginManager().getPlugin("Vault") != null) {
|
||||
if (getServer().getPluginManager().getPlugin("Vault") != null) {
|
||||
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if(economyProvider != null) {
|
||||
if (economyProvider != null) {
|
||||
economy = economyProvider.getProvider();
|
||||
}
|
||||
useEconomy = (economy != null);
|
||||
@ -720,13 +821,16 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
|
||||
public static long getLastPlayed(UUID uuid) {
|
||||
if(uuid == null) return 0;
|
||||
if (uuid == null) {
|
||||
return 0;
|
||||
}
|
||||
OfflinePlayer player;
|
||||
if((player = Bukkit.getOfflinePlayer(uuid)) == null || !player.hasPlayedBefore()) {
|
||||
if (((player = Bukkit.getOfflinePlayer(uuid)) == null) || !player.hasPlayedBefore()) {
|
||||
return 0;
|
||||
}
|
||||
return player.getLastPlayed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load configuration files
|
||||
*/
|
||||
@ -797,7 +901,7 @@ public class PlotMain extends JavaPlugin {
|
||||
Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled");
|
||||
Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
|
||||
}
|
||||
if(Settings.DEBUG) {
|
||||
if (Settings.DEBUG) {
|
||||
Map<String, String> settings = new HashMap<>();
|
||||
settings.put("Kill Road Mobs", "" + Settings.KILL_ROAD_MOBS);
|
||||
settings.put("Use Metrics", "" + Settings.METRICS);
|
||||
@ -808,7 +912,7 @@ public class PlotMain extends JavaPlugin {
|
||||
settings.put("DB SQLite Enabled", "" + Settings.DB.USE_SQLITE);
|
||||
settings.put("Auto Clear Enabled", "" + Settings.AUTO_CLEAR);
|
||||
settings.put("Auto Clear Days", "" + Settings.AUTO_CLEAR_DAYS);
|
||||
for(Entry<String, String> setting : settings.entrySet()) {
|
||||
for (Entry<String, String> setting : settings.entrySet()) {
|
||||
sendConsoleSenderMessage(C.PREFIX.s() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
|
||||
}
|
||||
}
|
||||
@ -899,8 +1003,9 @@ public class PlotMain extends JavaPlugin {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Welp! how did this entity get here?
|
||||
entity.teleport(location.subtract(location.getDirection().normalize().multiply(2)));
|
||||
// Welp! how did this entity get
|
||||
// here?
|
||||
entity.teleport(this.location.subtract(this.location.getDirection().normalize().multiply(2)));
|
||||
}
|
||||
}
|
||||
if (!tamed) {
|
||||
@ -944,7 +1049,7 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
Settings.DEBUG = config.getBoolean("debug");
|
||||
if(Settings.DEBUG) {
|
||||
if (Settings.DEBUG) {
|
||||
sendConsoleSenderMessage(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
|
||||
}
|
||||
Web.ENABLED = config.getBoolean("web.enabled");
|
||||
|
@ -15,8 +15,6 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import com.intellectualcrafters.plot.RUtils.Direction;
|
||||
|
||||
/**
|
||||
* plot settings
|
||||
*
|
||||
@ -27,7 +25,7 @@ public class PlotSettings {
|
||||
/**
|
||||
* merged plots
|
||||
*/
|
||||
private boolean[] merged = new boolean[] {false,false,false,false};
|
||||
private boolean[] merged = new boolean[] { false, false, false, false };
|
||||
/**
|
||||
* plot alias
|
||||
*/
|
||||
@ -69,15 +67,16 @@ public class PlotSettings {
|
||||
* 1 = East<br>
|
||||
* 2 = South<br>
|
||||
* 3 = West<br>
|
||||
*
|
||||
* @param direction
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean getMerged(int direction) {
|
||||
return merged[direction];
|
||||
return this.merged[direction];
|
||||
}
|
||||
|
||||
public boolean isMerged() {
|
||||
return (merged[0] || merged[1] || merged[2] || merged[3]);
|
||||
return (this.merged[0] || this.merged[1] || this.merged[2] || this.merged[3]);
|
||||
}
|
||||
|
||||
public boolean[] getMerged() {
|
||||
@ -91,6 +90,7 @@ public class PlotSettings {
|
||||
public void setMerged(int direction, boolean merged) {
|
||||
this.merged[direction] = merged;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param b
|
||||
|
@ -11,9 +11,9 @@ public class PlotSquaredException extends RuntimeException {
|
||||
}
|
||||
|
||||
public static enum PlotError {
|
||||
MISSING_DEPENDENCY("Missing Dependency")
|
||||
;
|
||||
MISSING_DEPENDENCY("Missing Dependency");
|
||||
private String errorHeader;
|
||||
|
||||
PlotError(String errorHeader) {
|
||||
this.errorHeader = errorHeader;
|
||||
}
|
||||
|
@ -1,27 +1,34 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
/**
|
||||
* This is the PlotWorld class (obviously)
|
||||
* <br> - All existing PlotWorld instances should be kept in PlotMain (worlds variable)
|
||||
* <br> - The accessors and mutators are:
|
||||
* <br> PlotMain.isPlotWorld(world)
|
||||
* <br> PlotMain.getPlotWorlds() or PlotMain.getPlotWorldsString() <- use this if you don't need to get world objects
|
||||
* <br> PlotMain.getWorldSettings(World) - get the PlotWorld class for a world
|
||||
* This is the PlotWorld class (obviously) <br>
|
||||
* - All existing PlotWorld instances should be kept in PlotMain (worlds
|
||||
* variable) <br>
|
||||
* - The accessors and mutators are: <br>
|
||||
* PlotMain.isPlotWorld(world) <br>
|
||||
* PlotMain.getPlotWorlds() or PlotMain.getPlotWorldsString() <- use this if you
|
||||
* don't need to get world objects <br>
|
||||
* PlotMain.getWorldSettings(World) - get the PlotWorld class for a world <br>
|
||||
* <br>
|
||||
* <br> Also added is getWorldPlots(World) as the plots are now sorted per world
|
||||
* Also added is getWorldPlots(World) as the plots are now sorted per world <br>
|
||||
* <br>
|
||||
* <br> To get the world of a plot, you can use plot.world - (string) or plot.getWorld() (world object)
|
||||
* To get the world of a plot, you can use plot.world - (string) or
|
||||
* plot.getWorld() (world object) <br>
|
||||
* <br>
|
||||
* <br> All PlotWorld settings are per world in the settings.yml (these settings are automatically added when a world is loaded, either at startup or if a new world is created):
|
||||
* <br> - You can find this in the WorldGenerator class (yeah, it's possibly not the best place, but it makes sure worlds are added to the settings.yml)
|
||||
* All PlotWorld settings are per world in the settings.yml (these settings are
|
||||
* automatically added when a world is loaded, either at startup or if a new
|
||||
* world is created): <br>
|
||||
* - You can find this in the WorldGenerator class (yeah, it's possibly not the
|
||||
* best place, but it makes sure worlds are added to the settings.yml) <br>
|
||||
* <br>
|
||||
* <br> All new DEFAULT CONSTANTS should be static and be given a value
|
||||
* <br> All new variables should not be static and should not be given any values here, but rather in the WorldGenerator class
|
||||
* All new DEFAULT CONSTANTS should be static and be given a value <br>
|
||||
* All new variables should not be static and should not be given any values
|
||||
* here, but rather in the WorldGenerator class
|
||||
*
|
||||
**/
|
||||
public class PlotWorld {
|
||||
|
@ -42,7 +42,7 @@ public class SetBlockFast {
|
||||
}
|
||||
|
||||
public static void update(org.bukkit.entity.Player player) {
|
||||
int distance = Bukkit.getViewDistance()+1;
|
||||
int distance = Bukkit.getViewDistance() + 1;
|
||||
for (int cx = -distance; cx < distance; cx++) {
|
||||
for (int cz = -distance; cz < distance; cz++) {
|
||||
player.getWorld().refreshChunk(player.getLocation().getChunk().getX() + cx, player.getLocation().getChunk().getZ() + cz);
|
||||
|
@ -81,7 +81,10 @@ public class Settings {
|
||||
*
|
||||
*/
|
||||
public static class DB {
|
||||
public static boolean USE_MONGO = false; /* TODO: Implement Mongo @Brandon */;
|
||||
public static boolean USE_MONGO = false; /*
|
||||
* TODO: Implement Mongo
|
||||
* @Brandon
|
||||
*/;
|
||||
public static boolean USE_SQLITE = false;
|
||||
public static boolean USE_MYSQL = true; /* NOTE: Fixed connector */
|
||||
public static String SQLITE_DB = "storage";
|
||||
|
@ -1,5 +1,32 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import static com.intellectualcrafters.plot.PlotWorld.AUTO_MERGE_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.DEFAULT_FLAGS_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.MAIN_BLOCK_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.PLOT_BIOME_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.PLOT_CHAT_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.PLOT_HEIGHT_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.PLOT_WIDTH_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.ROAD_BLOCK_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.ROAD_HEIGHT_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.ROAD_STRIPES_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.ROAD_STRIPES_ENABLED_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.ROAD_WIDTH_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.SCHEMATIC_FILE_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.SCHEMATIC_ON_CLAIM_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.TOP_BLOCK_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.WALL_BLOCK_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.WALL_FILLING_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.WALL_HEIGHT_DEFAULT;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -8,12 +35,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static com.intellectualcrafters.plot.PlotWorld.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @auther Empire92
|
||||
@ -91,11 +112,20 @@ public class WorldGenerator extends ChunkGenerator {
|
||||
options.put("worlds." + world + ".schematic.on_claim", SCHEMATIC_ON_CLAIM_DEFAULT);
|
||||
options.put("worlds." + world + ".schematic.file", SCHEMATIC_FILE_DEFAULT);
|
||||
options.put("worlds." + world + ".flags.default", DEFAULT_FLAGS_DEFAULT);
|
||||
options.put("worlds." + world + ".schematic.schematics", plotworld.SCHEMATICS);
|
||||
options.put("worlds." + world + ".schematic.specify_on_claim", plotworld.SCHEMATIC_CLAIM_SPECIFY);
|
||||
options.put("worlds." + world + ".economy.use", plotworld.USE_ECONOMY); // Access should be static
|
||||
options.put("worlds." + world + ".economy.prices.claim", plotworld.PLOT_PRICE); // Access should be static
|
||||
options.put("worlds." + world + ".economy.prices.merge", plotworld.MERGE_PRICE); // Access should be static
|
||||
options.put("worlds." + world + ".schematic.schematics", this.plotworld.SCHEMATICS);
|
||||
options.put("worlds." + world + ".schematic.specify_on_claim", this.plotworld.SCHEMATIC_CLAIM_SPECIFY);
|
||||
options.put("worlds." + world + ".economy.use", this.plotworld.USE_ECONOMY); // Access
|
||||
// should
|
||||
// be
|
||||
// static
|
||||
options.put("worlds." + world + ".economy.prices.claim", this.plotworld.PLOT_PRICE); // Access
|
||||
// should
|
||||
// be
|
||||
// static
|
||||
options.put("worlds." + world + ".economy.prices.merge", this.plotworld.MERGE_PRICE); // Access
|
||||
// should
|
||||
// be
|
||||
// static
|
||||
options.put("worlds." + world + ".chat.enabled", PLOT_CHAT_DEFAULT);
|
||||
for (Entry<String, Object> node : options.entrySet()) {
|
||||
if (!config.contains(node.getKey())) {
|
||||
@ -222,10 +252,9 @@ public class WorldGenerator extends ChunkGenerator {
|
||||
|
||||
this.result = new short[maxY / 16][];
|
||||
double pathWidthLower;
|
||||
if ((pathsize % 2) == 0) {
|
||||
pathWidthLower = Math.floor(this.pathsize / 2)-1;
|
||||
}
|
||||
else {
|
||||
if ((this.pathsize % 2) == 0) {
|
||||
pathWidthLower = Math.floor(this.pathsize / 2) - 1;
|
||||
} else {
|
||||
pathWidthLower = Math.floor(this.pathsize / 2);
|
||||
}
|
||||
final int prime = 31;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Citymonstret
|
||||
@ -124,10 +124,9 @@ public class XPopulator extends BlockPopulator {
|
||||
this.f_id[i] = result[0];
|
||||
this.f_v[i] = result[1];
|
||||
}
|
||||
if ((pathsize % 2) == 0) {
|
||||
pathWidthLower = Math.floor(this.pathsize / 2)-1;
|
||||
}
|
||||
else {
|
||||
if ((this.pathsize % 2) == 0) {
|
||||
this.pathWidthLower = Math.floor(this.pathsize / 2) - 1;
|
||||
} else {
|
||||
this.pathWidthLower = Math.floor(this.pathsize / 2);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.intellectualcrafters.plot.AbstractFlag;
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.Flag;
|
||||
import com.intellectualcrafters.plot.FlagManager;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
|
@ -1,26 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Auto.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:40
|
||||
*/
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Auto.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:40
|
||||
*/
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Auto extends SubCommand {
|
||||
public Auto() {
|
||||
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING);
|
||||
}
|
||||
|
||||
// TODO auto claim a mega plot!!!!!!!!!!!!
|
||||
@Override
|
||||
public boolean execute(Player plr, String... args) {
|
||||
@ -43,19 +47,17 @@ public class Auto extends SubCommand {
|
||||
String[] split = args[0].split(",");
|
||||
size_x = Integer.parseInt(split[0]);
|
||||
size_z = Integer.parseInt(split[1]);
|
||||
if (size_x < 1 || size_z < 1) {
|
||||
if ((size_x < 1) || (size_z < 1)) {
|
||||
PlayerFunctions.sendMessage(plr, "&cError: size<=0");
|
||||
}
|
||||
if (size_x > 4 || size_z > 4) {
|
||||
if ((size_x > 4) || (size_z > 4)) {
|
||||
PlayerFunctions.sendMessage(plr, "&cError: size>4");
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, "&cError: Invalid size (X,Y)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
||||
return false;
|
||||
}
|
||||
@ -67,7 +69,7 @@ public class Auto extends SubCommand {
|
||||
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) {
|
||||
id = new PlotId(x, z);
|
||||
if (PlotHelper.getPlot(world, id).owner == null) {
|
||||
@ -86,18 +88,17 @@ public class Auto extends SubCommand {
|
||||
z = q;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
while (!br) {
|
||||
PlotId start = new PlotId(x, z);
|
||||
PlotId end = new PlotId(x+size_x-1, z+size_z-1);
|
||||
PlotId end = new PlotId((x + size_x) - 1, (z + size_z) - 1);
|
||||
if (isUnowned(world, start, end)) {
|
||||
// TODO claim event
|
||||
// Claim.claimPlot calls that event...
|
||||
for (int i = start.x; i <= end.x; i++) {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
Plot plot = PlotHelper.getPlot(world, new PlotId(i,j));
|
||||
boolean teleport = (i == end.x && j == end.y) ? true : false;
|
||||
Plot plot = PlotHelper.getPlot(world, new PlotId(i, j));
|
||||
boolean teleport = ((i == end.x) && (j == end.y)) ? true : false;
|
||||
Claim.claimPlot(plr, plot, teleport);
|
||||
}
|
||||
}
|
||||
@ -105,9 +106,9 @@ public class Auto extends SubCommand {
|
||||
br = true;
|
||||
}
|
||||
if ((z < q) && ((z - x) < q)) {
|
||||
z+=size_z;
|
||||
z += size_z;
|
||||
} else if (x < q) {
|
||||
x+=size_x;
|
||||
x += size_x;
|
||||
z = q - 100;
|
||||
} else {
|
||||
q += 100;
|
||||
@ -118,11 +119,12 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isUnowned(World world, PlotId pos1, PlotId pos2) {
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
PlotId id = new PlotId(x,y);
|
||||
if (PlotMain.getPlots(world).get(id)!=null) {
|
||||
PlotId id = new PlotId(x, y);
|
||||
if (PlotMain.getPlots(world).get(id) != null) {
|
||||
if (PlotMain.getPlots(world).get(id).owner != null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -9,12 +9,20 @@
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotHelper;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.PlotWorld;
|
||||
import com.intellectualcrafters.plot.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Citymonstret
|
||||
@ -29,7 +37,7 @@ public class Claim extends SubCommand {
|
||||
@Override
|
||||
public boolean execute(Player plr, String... args) {
|
||||
String schematic = "";
|
||||
if(args.length >= 1) {
|
||||
if (args.length >= 1) {
|
||||
schematic = args[0];
|
||||
}
|
||||
if (!PlayerFunctions.isInPlot(plr)) {
|
||||
@ -46,11 +54,11 @@ public class Claim extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
PlotWorld world = PlotMain.getWorldSettings(plot.getWorld());
|
||||
if(PlotMain.useEconomy && world.USE_ECONOMY) {
|
||||
if (PlotMain.useEconomy && world.USE_ECONOMY) {
|
||||
double cost = world.PLOT_PRICE;
|
||||
if(cost > 0d) {
|
||||
if (cost > 0d) {
|
||||
Economy economy = PlotMain.economy;
|
||||
if(economy.getBalance(plr) < cost) {
|
||||
if (economy.getBalance(plr) < cost) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
return true;
|
||||
}
|
||||
@ -58,13 +66,13 @@ public class Claim extends SubCommand {
|
||||
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
if(!schematic.equals("")) {
|
||||
if(world.SCHEMATIC_CLAIM_SPECIFY) {
|
||||
if(!world.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||
if (!schematic.equals("")) {
|
||||
if (world.SCHEMATIC_CLAIM_SPECIFY) {
|
||||
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
||||
return true;
|
||||
}
|
||||
if(!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) {
|
||||
if (!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
|
||||
return true;
|
||||
}
|
||||
@ -97,11 +105,11 @@ public class Claim extends SubCommand {
|
||||
if (world.SCHEMATIC_ON_CLAIM) {
|
||||
SchematicHandler handler = new SchematicHandler();
|
||||
SchematicHandler.Schematic sch;
|
||||
if(schematic.equals("")) {
|
||||
if (schematic.equals("")) {
|
||||
sch = handler.getSchematic(world.SCHEMATIC_FILE);
|
||||
} else {
|
||||
sch = handler.getSchematic(schematic);
|
||||
if(sch == null) {
|
||||
if (sch == null) {
|
||||
sch = handler.getSchematic(world.SCHEMATIC_FILE);
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,6 @@ import org.bukkit.entity.Player;
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotHelper;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-01.
|
||||
@ -34,7 +31,7 @@ public class Clear extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
if ((plot==null || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -17,16 +17,19 @@ package com.intellectualcrafters.plot.commands;
|
||||
public enum Command {
|
||||
|
||||
// TODO new commands
|
||||
// (allow a plot to be transferred from one plot to another of the same size)
|
||||
// (allow a plot to be transferred from one plot to another of the same
|
||||
// size)
|
||||
// - /plot copy
|
||||
// - /plot paste
|
||||
// (economy)
|
||||
// - /plot buy
|
||||
// - /plot sell <value>
|
||||
// (Rating system) (ratings can be stored as the average, and number of ratings)
|
||||
// (Rating system) (ratings can be stored as the average, and number of
|
||||
// ratings)
|
||||
// - /plot rate <number out of 10>
|
||||
// - /plot list <some parameter to list the most popular, and highest rated plots>
|
||||
TRUSTED("trusted","trust"),
|
||||
// - /plot list <some parameter to list the most popular, and highest rated
|
||||
// plots>
|
||||
TRUSTED("trusted", "trust"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -34,7 +37,7 @@ public enum Command {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
KICK("kick","k"),
|
||||
KICK("kick", "k"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -14,9 +14,6 @@ import org.bukkit.entity.Player;
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotHelper;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-01.
|
||||
@ -34,7 +31,7 @@ public class Copy extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
if ((plot==null || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -9,10 +9,16 @@
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.Lag;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.PlotHelper;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.RUtils;
|
||||
|
||||
/**
|
||||
* @author Citymonstret \\SuperCharged Compiler made by Citymonstret\\
|
||||
* ||#Compiler:ALPHA-1.0#########################
|
||||
@ -80,8 +86,9 @@ public class Debug extends SubCommand {
|
||||
information.append(getSection(section, "PlotWorld"));
|
||||
information.append(getLine(line, "Plot Worlds", worlds));
|
||||
information.append(getLine(line, "Owned Plots", PlotMain.getPlots().size()));
|
||||
//information.append(getLine(line, "PlotWorld Size", PlotHelper.getWorldFolderSize() + "MB"));
|
||||
for(String world : PlotMain.getPlotWorlds()) {
|
||||
// information.append(getLine(line, "PlotWorld Size",
|
||||
// PlotHelper.getWorldFolderSize() + "MB"));
|
||||
for (String world : PlotMain.getPlotWorlds()) {
|
||||
information.append(getLine(line, "World: " + world + " size", PlotHelper.getWorldFolderSize(Bukkit.getWorld(world))));
|
||||
}
|
||||
information.append(getLine(line, "Entities", PlotHelper.getEntities(plr.getWorld())));
|
||||
|
@ -38,7 +38,7 @@ public class Delete extends SubCommand {
|
||||
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
return false;
|
||||
}
|
||||
if ((plot==null || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ public class Home extends SubCommand {
|
||||
public Home() {
|
||||
super(Command.HOME, "Go to your plot", "home {id|alias}", CommandCategory.TELEPORT);
|
||||
}
|
||||
|
||||
private Plot isAlias(String a) {
|
||||
for (Plot p : PlotMain.getPlots()) {
|
||||
if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) {
|
||||
|
@ -9,11 +9,9 @@
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotHelper;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -22,8 +20,11 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotHelper;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -76,7 +77,7 @@ public class Info extends SubCommand {
|
||||
if (plot.owner != null) {
|
||||
owner = Bukkit.getOfflinePlayer(plot.owner).getName();
|
||||
}
|
||||
if (owner==null) {
|
||||
if (owner == null) {
|
||||
owner = plot.owner.toString();
|
||||
}
|
||||
|
||||
@ -92,14 +93,17 @@ public class Info extends SubCommand {
|
||||
info = info.replaceAll("%denied%", getPlayerList(plot.denied));
|
||||
info = info.replaceAll("%rating%", "" + DBFunc.getRatings(plot));
|
||||
info = info.replaceAll("%flags%", StringUtils.join(plot.settings.getFlags(), "").length() > 0 ? StringUtils.join(plot.settings.getFlags(), ",") : "none");
|
||||
//PlayerFunctions.sendMessage(player, PlayerFunctions.getTopPlot(player.getWorld(), plot).id.toString());
|
||||
//PlayerFunctions.sendMessage(player, PlayerFunctions.getBottomPlot(player.getWorld(), plot).id.toString());
|
||||
// PlayerFunctions.sendMessage(player,
|
||||
// PlayerFunctions.getTopPlot(player.getWorld(), plot).id.toString());
|
||||
// PlayerFunctions.sendMessage(player,
|
||||
// PlayerFunctions.getBottomPlot(player.getWorld(),
|
||||
// plot).id.toString());
|
||||
PlayerFunctions.sendMessage(player, info);
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getPlayerList(ArrayList<UUID> l) {
|
||||
if (l == null || l.size() < 1) {
|
||||
if ((l == null) || (l.size() < 1)) {
|
||||
return " none";
|
||||
}
|
||||
String c = C.PLOT_USER_LIST.s();
|
||||
|
@ -15,9 +15,6 @@ import org.bukkit.entity.Player;
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotHelper;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-01.
|
||||
@ -35,11 +32,11 @@ public class Kick extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
if ((plot==null || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (args.length!=1) {
|
||||
if (args.length != 1) {
|
||||
PlayerFunctions.sendMessage(plr, "&c/plot kick <player>");
|
||||
return false;
|
||||
}
|
||||
@ -48,7 +45,7 @@ public class Kick extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
if (!player.getWorld().equals(plr.getWorld()) || !PlayerFunctions.isInPlot(player) || PlayerFunctions.getCurrentPlot(player)==null || !PlayerFunctions.getCurrentPlot(player).equals(plot)) {
|
||||
if (!player.getWorld().equals(plr.getWorld()) || !PlayerFunctions.isInPlot(player) || (PlayerFunctions.getCurrentPlot(player) == null) || !PlayerFunctions.getCurrentPlot(player).equals(plot)) {
|
||||
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
|
||||
return false;
|
||||
}
|
||||
|
@ -9,15 +9,24 @@
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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;
|
||||
import com.intellectualcrafters.plot.SetBlockFast;
|
||||
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -27,7 +36,7 @@ import java.util.ArrayList;
|
||||
public class Merge extends SubCommand {
|
||||
|
||||
public static String[] values = new String[] { "north", "east", "south", "west" };
|
||||
public static String[] aliases = new String[] { "n", "e", "s", "w"};
|
||||
public static String[] aliases = new String[] { "n", "e", "s", "w" };
|
||||
|
||||
public Merge() {
|
||||
super(Command.MERGE, "Merge the plot you are standing on with another plot.", "merge", CommandCategory.ACTIONS);
|
||||
@ -36,7 +45,7 @@ public class Merge extends SubCommand {
|
||||
public static String direction(float yaw) {
|
||||
yaw = yaw / 90;
|
||||
int i = Math.round(yaw);
|
||||
switch(i) {
|
||||
switch (i) {
|
||||
case -4:
|
||||
case 0:
|
||||
case 4:
|
||||
@ -62,7 +71,7 @@ public class Merge extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
if (plot==null || !plot.hasOwner()) {
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
@ -70,20 +79,20 @@ public class Merge extends SubCommand {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (args.length<1) {
|
||||
PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values,C.BLOCK_LIST_SEPARATER.s()));
|
||||
if (args.length < 1) {
|
||||
PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s()));
|
||||
PlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw())));
|
||||
return false;
|
||||
}
|
||||
int direction = -1;
|
||||
for (int i = 0; i<values.length; i++) {
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (args[0].equalsIgnoreCase(values[i]) || args[0].equalsIgnoreCase(aliases[i])) {
|
||||
direction = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (direction==-1) {
|
||||
PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values,C.BLOCK_LIST_SEPARATER.s()));
|
||||
if (direction == -1) {
|
||||
PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s()));
|
||||
PlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw())));
|
||||
return false;
|
||||
}
|
||||
@ -93,34 +102,34 @@ public class Merge extends SubCommand {
|
||||
ArrayList<PlotId> plots;
|
||||
switch (direction) {
|
||||
case 0: // north = -y
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,bot.y-1), new PlotId(top.x,top.y));
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
||||
break;
|
||||
case 1: // east = +x
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,bot.y), new PlotId(top.x+1,top.y));
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
||||
break;
|
||||
case 2: // south = +y
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x,bot.y), new PlotId(top.x,top.y+1));
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
||||
break;
|
||||
case 3: // west = -x
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x-1,bot.y), new PlotId(top.x,top.y));
|
||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
for (PlotId myid : plots) {
|
||||
Plot myplot = PlotMain.getPlots(world).get(myid);
|
||||
if (myplot==null || !myplot.hasOwner() || !(myplot.getOwner().equals(plr.getUniqueId()))) {
|
||||
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(plr.getUniqueId()))) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PlotWorld plotWorld = PlotMain.getWorldSettings(world);
|
||||
if(PlotMain.useEconomy && plotWorld.USE_ECONOMY) {
|
||||
if (PlotMain.useEconomy && plotWorld.USE_ECONOMY) {
|
||||
double cost = plotWorld.MERGE_PRICE;
|
||||
if(cost > 0d) {
|
||||
if (cost > 0d) {
|
||||
Economy economy = PlotMain.economy;
|
||||
if(economy.getBalance(plr) < cost) {
|
||||
if (economy.getBalance(plr) < cost) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
|
||||
return false;
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-10-02.
|
||||
@ -11,7 +12,8 @@ import org.bukkit.entity.Player;
|
||||
public class Rate extends SubCommand {
|
||||
|
||||
/*
|
||||
String cmd, String permission, String description, String usage, String alias, CommandCategory category
|
||||
* String cmd, String permission, String description, String usage, String
|
||||
* alias, CommandCategory category
|
||||
*/
|
||||
|
||||
public Rate() {
|
||||
@ -20,47 +22,47 @@ public class Rate extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(Player plr, String... args) {
|
||||
if(args.length < 1) {
|
||||
if (args.length < 1) {
|
||||
sendMessage(plr, C.RATING_NOT_VALID);
|
||||
return true;
|
||||
}
|
||||
if(!PlayerFunctions.isInPlot(plr)) {
|
||||
if (!PlayerFunctions.isInPlot(plr)) {
|
||||
sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return true;
|
||||
}
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
if(!plot.hasOwner()) {
|
||||
if (!plot.hasOwner()) {
|
||||
sendMessage(plr, C.RATING_NOT_OWNED);
|
||||
return true;
|
||||
}
|
||||
if(plot.getOwner().equals(plr.getUniqueId())) {
|
||||
if (plot.getOwner().equals(plr.getUniqueId())) {
|
||||
sendMessage(plr, C.RATING_NOT_YOUR_OWN);
|
||||
return true;
|
||||
}
|
||||
String arg = args[0];
|
||||
boolean o = false;
|
||||
for(char c : arg.toCharArray()) {
|
||||
if(!Character.isDigit(c)) {
|
||||
for (char c : arg.toCharArray()) {
|
||||
if (!Character.isDigit(c)) {
|
||||
o = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int rating = 0;
|
||||
if(!o) {
|
||||
if (!o) {
|
||||
rating = Integer.parseInt(arg);
|
||||
}
|
||||
if(o || (rating < 0 || rating > 10)) {
|
||||
if (o || ((rating < 0) || (rating > 10))) {
|
||||
sendMessage(plr, C.RATING_NOT_VALID);
|
||||
return true;
|
||||
}
|
||||
//TODO implement check for already rated
|
||||
// TODO implement check for already rated
|
||||
boolean rated = false;
|
||||
if(rated) {
|
||||
if (rated) {
|
||||
sendMessage(plr, C.RATING_ALREADY_EXISTS, plot.getId().toString());
|
||||
}
|
||||
//TODO actually do something...
|
||||
// TODO actually do something...
|
||||
boolean success = false;
|
||||
if(success) {
|
||||
if (success) {
|
||||
sendMessage(plr, C.RATING_APPLIED, plot.getId().toString());
|
||||
} else {
|
||||
sendMessage(plr, C.COMMAND_WENT_WRONG);
|
||||
|
@ -9,10 +9,9 @@
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.events.PlotFlagAddEvent;
|
||||
import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -22,16 +21,25 @@ import org.bukkit.WeatherType;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.Flag;
|
||||
import com.intellectualcrafters.plot.FlagManager;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotHelper;
|
||||
import com.intellectualcrafters.plot.PlotHomePosition;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.PlotWorld;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.events.PlotFlagAddEvent;
|
||||
import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class Set extends SubCommand{
|
||||
public class Set extends SubCommand {
|
||||
|
||||
public Set() {
|
||||
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS);
|
||||
@ -53,41 +61,42 @@ public class Set extends SubCommand{
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if(args.length < 1) {
|
||||
if (args.length < 1) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
|
||||
builder.append(getArgumentList(values));
|
||||
PlayerFunctions.sendMessage(plr, builder.toString());
|
||||
return false;
|
||||
}
|
||||
for(int i = 0; i < aliases.length; i++) {
|
||||
if(aliases[i].equalsIgnoreCase(args[0])) {
|
||||
for (int i = 0; i < aliases.length; i++) {
|
||||
if (aliases[i].equalsIgnoreCase(args[0])) {
|
||||
args[0] = values[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* TODO: Implement option */
|
||||
boolean advanced_permissions = false;
|
||||
if(advanced_permissions) {
|
||||
if(!plr.hasPermission("plots.set." + args[0].toLowerCase())) {
|
||||
if (advanced_permissions) {
|
||||
if (!plr.hasPermission("plots.set." + args[0].toLowerCase())) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("flag")) {
|
||||
if(args.length < 2) {
|
||||
String message = StringUtils.join(FlagManager.getFlags(),"&c, &6");
|
||||
if (args[0].equalsIgnoreCase("flag")) {
|
||||
if (args.length < 2) {
|
||||
String message = StringUtils.join(FlagManager.getFlags(), "&c, &6");
|
||||
if (PlotMain.worldGuardListener != null) {
|
||||
if (message.equals(""))
|
||||
message = StringUtils.join(PlotMain.worldGuardListener.str_flags,"&c, &6");
|
||||
else
|
||||
message += ","+StringUtils.join(PlotMain.worldGuardListener.str_flags,"&c, &6");
|
||||
if (message.equals("")) {
|
||||
message = StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6");
|
||||
} else {
|
||||
message += "," + StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6");
|
||||
}
|
||||
}
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message));
|
||||
return false;
|
||||
}
|
||||
if (!FlagManager.getFlags().contains(args[1].toLowerCase()) && PlotMain.worldGuardListener != null && !PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) {
|
||||
if (!FlagManager.getFlags().contains(args[1].toLowerCase()) && (PlotMain.worldGuardListener != null) && !PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
|
||||
return false;
|
||||
}
|
||||
@ -95,8 +104,8 @@ public class Set extends SubCommand{
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
||||
return false;
|
||||
}
|
||||
if (args.length==2) {
|
||||
if (plot.settings.getFlag(args[1].toLowerCase())==null) {
|
||||
if (args.length == 2) {
|
||||
if (plot.settings.getFlag(args[1].toLowerCase()) == null) {
|
||||
if (PlotMain.worldGuardListener != null) {
|
||||
if (PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) {
|
||||
PlotMain.worldGuardListener.removeFlag(plr, plr.getWorld(), plot, args[1]);
|
||||
@ -107,32 +116,33 @@ public class Set extends SubCommand{
|
||||
return false;
|
||||
}
|
||||
Flag flag = plot.settings.getFlag(args[1].toLowerCase());
|
||||
PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flag,plot);
|
||||
PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flag, plot);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) {
|
||||
if (event.isCancelled()) {
|
||||
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_REMOVED);
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
}
|
||||
java.util.Set<Flag> newflags = plot.settings.getFlags();
|
||||
Flag oldFlag = plot.settings.getFlag(args[1].toLowerCase());
|
||||
if (oldFlag!=null)
|
||||
if (oldFlag != null) {
|
||||
newflags.remove(oldFlag);
|
||||
}
|
||||
plot.settings.setFlags(newflags.toArray(new Flag[0]));
|
||||
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0]));
|
||||
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length)," ");
|
||||
if (FlagManager.getFlag(args[1].toLowerCase())==null && PlotMain.worldGuardListener != null) {
|
||||
String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
if ((FlagManager.getFlag(args[1].toLowerCase()) == null) && (PlotMain.worldGuardListener != null)) {
|
||||
PlotMain.worldGuardListener.addFlag(plr, plr.getWorld(), plot, args[1], value);
|
||||
return false;
|
||||
}
|
||||
Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), value);
|
||||
PlotFlagAddEvent event = new PlotFlagAddEvent(flag,plot);
|
||||
PlotFlagAddEvent event = new PlotFlagAddEvent(flag, plot);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) {
|
||||
if (event.isCancelled()) {
|
||||
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_ADDED);
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
@ -141,44 +151,48 @@ public class Set extends SubCommand{
|
||||
DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags().toArray(new Flag[0]));
|
||||
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, "&c"+e.getMessage());
|
||||
} catch (Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, "&c" + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("rain")) {
|
||||
if(args.length < 2) {
|
||||
if (args[0].equalsIgnoreCase("rain")) {
|
||||
if (args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_ON_OFF);
|
||||
return false;
|
||||
}
|
||||
String word = args[1];
|
||||
if(!word.equalsIgnoreCase("on") && !word.equalsIgnoreCase("off")) {
|
||||
if (!word.equalsIgnoreCase("on") && !word.equalsIgnoreCase("off")) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_ON_OFF);
|
||||
return true;
|
||||
}
|
||||
boolean b = word.equalsIgnoreCase("on");
|
||||
DBFunc.setWeather(plr.getWorld().getName(), plot, b);
|
||||
PlayerFunctions.sendMessage(plr, C.SETTING_UPDATED);
|
||||
for(Player p : Bukkit.getOnlinePlayers()) {
|
||||
if(PlayerFunctions.getCurrentPlot(plr).id == plot.id) {
|
||||
if(b) p.setPlayerWeather(WeatherType.DOWNFALL);
|
||||
else p.resetPlayerWeather();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (PlayerFunctions.getCurrentPlot(plr).id == plot.id) {
|
||||
if (b) {
|
||||
p.setPlayerWeather(WeatherType.DOWNFALL);
|
||||
} else {
|
||||
p.resetPlayerWeather();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("home")) {
|
||||
if(args.length < 2) {
|
||||
if (args[0].equalsIgnoreCase("home")) {
|
||||
if (args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.MISSING_POSITION);
|
||||
return false;
|
||||
}
|
||||
PlotHomePosition position = null;
|
||||
for(PlotHomePosition p : PlotHomePosition.values()) {
|
||||
if(p.isMatching(args[1])) position = p;
|
||||
for (PlotHomePosition p : PlotHomePosition.values()) {
|
||||
if (p.isMatching(args[1])) {
|
||||
position = p;
|
||||
}
|
||||
if(position == null) {
|
||||
}
|
||||
if (position == null) {
|
||||
PlayerFunctions.sendMessage(plr, C.INVALID_POSITION);
|
||||
return false;
|
||||
}
|
||||
@ -187,14 +201,14 @@ public class Set extends SubCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("alias")) {
|
||||
if(args.length < 2) {
|
||||
if (args[0].equalsIgnoreCase("alias")) {
|
||||
if (args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.MISSING_ALIAS);
|
||||
return false;
|
||||
}
|
||||
String alias = args[1];
|
||||
for(Plot p : PlotMain.getPlots(plr.getWorld()).values()) {
|
||||
if(p.settings.getAlias().equalsIgnoreCase(alias)) {
|
||||
for (Plot p : PlotMain.getPlots(plr.getWorld()).values()) {
|
||||
if (p.settings.getAlias().equalsIgnoreCase(alias)) {
|
||||
PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
}
|
||||
@ -207,19 +221,19 @@ public class Set extends SubCommand{
|
||||
PlayerFunctions.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias));
|
||||
return true;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("biome")) {
|
||||
if(args.length < 2) {
|
||||
if (args[0].equalsIgnoreCase("biome")) {
|
||||
if (args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_BIOME);
|
||||
return true;
|
||||
}
|
||||
Biome biome = null;
|
||||
for(Biome b : Biome.values()) {
|
||||
if(b.toString().equalsIgnoreCase(args[1])) {
|
||||
for (Biome b : Biome.values()) {
|
||||
if (b.toString().equalsIgnoreCase(args[1])) {
|
||||
biome = b;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(biome == null) {
|
||||
if (biome == null) {
|
||||
PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values())));
|
||||
return true;
|
||||
}
|
||||
@ -227,54 +241,54 @@ public class Set extends SubCommand{
|
||||
PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase());
|
||||
return true;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("wall")) {
|
||||
if (args[0].equalsIgnoreCase("wall")) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
||||
if (plotworld==null) {
|
||||
if (plotworld == null) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return true;
|
||||
}
|
||||
if(args.length < 2) {
|
||||
if (args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
||||
return true;
|
||||
}
|
||||
Material material = null;
|
||||
for(Material m : plotworld.BLOCKS) {
|
||||
if(m.toString().equalsIgnoreCase(args[1])) {
|
||||
for (Material m : PlotWorld.BLOCKS) {
|
||||
if (m.toString().equalsIgnoreCase(args[1])) {
|
||||
material = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(material == null) {
|
||||
PlayerFunctions.sendMessage(plr, getBlockList(plotworld.BLOCKS));
|
||||
if (material == null) {
|
||||
PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
|
||||
return true;
|
||||
}
|
||||
byte data = 0;
|
||||
|
||||
if(args.length > 2) {
|
||||
if (args.length > 2) {
|
||||
try {
|
||||
data = (byte) Integer.parseInt(args[2]);
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
PlayerFunctions.sendMessage(plr, C.GENERATING_WALL);
|
||||
PlotHelper.adjustWall(plr.getWorld(), plot, (short)material.getId(), data);
|
||||
PlotHelper.adjustWall(plr.getWorld(), plot, (short) material.getId(), data);
|
||||
return true;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("floor")) {
|
||||
if(args.length < 2) {
|
||||
if (args[0].equalsIgnoreCase("floor")) {
|
||||
if (args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
||||
return true;
|
||||
}
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
||||
if (plotworld==null) {
|
||||
if (plotworld == null) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return true;
|
||||
}
|
||||
//
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<Material> materials = (ArrayList<Material>) plotworld.BLOCKS.clone();
|
||||
ArrayList<Material> materials = (ArrayList<Material>) PlotWorld.BLOCKS.clone();
|
||||
materials.add(Material.AIR);
|
||||
//
|
||||
String[] strings = args[1].split(",");
|
||||
@ -287,26 +301,26 @@ public class Set extends SubCommand{
|
||||
byte b = (byte) 0;
|
||||
Material m = null;
|
||||
//
|
||||
for(String s : strings) {
|
||||
for (String s : strings) {
|
||||
s = s.replaceAll(",", "");
|
||||
String[] ss = s.split(";");
|
||||
ss[0] = ss[0].replaceAll(";", "");
|
||||
for(Material ma : materials) {
|
||||
if(ma.toString().equalsIgnoreCase(ss[0])) {
|
||||
for (Material ma : materials) {
|
||||
if (ma.toString().equalsIgnoreCase(ss[0])) {
|
||||
m = ma;
|
||||
}
|
||||
}
|
||||
if(m == null) {
|
||||
if (m == null) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_BLOCK);
|
||||
return true;
|
||||
}
|
||||
if(ss.length == 1) {
|
||||
if (ss.length == 1) {
|
||||
data[index] = (byte) 0;
|
||||
material[index] = m;
|
||||
} else {
|
||||
try {
|
||||
b = (byte) Integer.parseInt(ss[1]);
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
||||
return true;
|
||||
}
|
||||
@ -318,38 +332,38 @@ public class Set extends SubCommand{
|
||||
PlotHelper.setFloor(plr, plot, material, data);
|
||||
return true;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("wall_filling")) {
|
||||
if(args.length < 2) {
|
||||
if (args[0].equalsIgnoreCase("wall_filling")) {
|
||||
if (args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
||||
return true;
|
||||
}
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
||||
if (plotworld==null) {
|
||||
if (plotworld == null) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return true;
|
||||
}
|
||||
Material material = null;
|
||||
for(Material m : plotworld.BLOCKS) {
|
||||
if(m.toString().equalsIgnoreCase(args[1])) {
|
||||
for (Material m : PlotWorld.BLOCKS) {
|
||||
if (m.toString().equalsIgnoreCase(args[1])) {
|
||||
material = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(material == null) {
|
||||
PlayerFunctions.sendMessage(plr, getBlockList(plotworld.BLOCKS));
|
||||
if (material == null) {
|
||||
PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
|
||||
return true;
|
||||
}
|
||||
byte data = 0;
|
||||
|
||||
if(args.length > 2) {
|
||||
if (args.length > 2) {
|
||||
try {
|
||||
data = (byte) Integer.parseInt(args[2]);
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
PlotHelper.adjustWallFilling(plr, plr.getWorld(), plot, (short)material.getId(), data);
|
||||
PlotHelper.adjustWallFilling(plr, plr.getWorld(), plot, (short) material.getId(), data);
|
||||
return true;
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
@ -373,7 +387,7 @@ public class Set extends SubCommand{
|
||||
|
||||
private String getArgumentList(String[] strings) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for(String s : strings) {
|
||||
for (String s : strings) {
|
||||
builder.append(getString(s));
|
||||
}
|
||||
return builder.toString().substring(1, builder.toString().length() - 1);
|
||||
@ -382,20 +396,19 @@ public class Set extends SubCommand{
|
||||
private String getBiomeList(List<Biome> biomes) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
||||
for(Biome b : biomes) {
|
||||
for (Biome b : biomes) {
|
||||
builder.append(getBiome(b));
|
||||
}
|
||||
return builder.toString().substring(1,builder.toString().length() - 1);
|
||||
return builder.toString().substring(1, builder.toString().length() - 1);
|
||||
}
|
||||
|
||||
private String getBlockList(List<Material> blocks) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
||||
for(Material b : blocks) {
|
||||
for (Material b : blocks) {
|
||||
builder.append(getMaterial(b));
|
||||
}
|
||||
return builder.toString().substring(1,builder.toString().length() - 1);
|
||||
return builder.toString().substring(1, builder.toString().length() - 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,49 +1,19 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import static com.intellectualcrafters.plot.PlotWorld.AUTO_MERGE_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.DEFAULT_FLAGS_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.MAIN_BLOCK_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.PLOT_BIOME_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.PLOT_HEIGHT_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.PLOT_WIDTH_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.ROAD_BLOCK_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.ROAD_HEIGHT_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.ROAD_STRIPES_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.ROAD_STRIPES_ENABLED_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.ROAD_WIDTH_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.SCHEMATIC_FILE_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.SCHEMATIC_ON_CLAIM_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.TOP_BLOCK_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.WALL_BLOCK_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.WALL_FILLING_DEFAULT;
|
||||
import static com.intellectualcrafters.plot.PlotWorld.WALL_HEIGHT_DEFAULT;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.PlotWorld;
|
||||
import com.intellectualcrafters.plot.WorldGenerator;
|
||||
import com.intellectualcrafters.plot.listeners.PlayerEvents;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-09-26.
|
||||
@ -58,16 +28,12 @@ public class Setup extends SubCommand implements Listener {
|
||||
private String description;
|
||||
private Object value = 0;
|
||||
private String type;
|
||||
private boolean require_previous;
|
||||
|
||||
public SetupStep(String constant, Object default_value, String description, String type, boolean require_previous) {
|
||||
this.constant = constant;
|
||||
this.default_value = default_value;
|
||||
this.description = description;
|
||||
this.type = type;
|
||||
this.require_previous = require_previous;
|
||||
}
|
||||
public boolean getRequire() {
|
||||
return this.require_previous;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
@ -80,32 +46,33 @@ public class Setup extends SubCommand implements Listener {
|
||||
}
|
||||
switch (this.type) {
|
||||
case "integer":
|
||||
value = Integer.parseInt(string);
|
||||
this.value = Integer.parseInt(string);
|
||||
break;
|
||||
case "boolean":
|
||||
value = Boolean.parseBoolean(string);
|
||||
this.value = Boolean.parseBoolean(string);
|
||||
break;
|
||||
case "double":
|
||||
value = Double.parseDouble(string);
|
||||
this.value = Double.parseDouble(string);
|
||||
break;
|
||||
case "float":
|
||||
value = Float.parseFloat(string);
|
||||
this.value = Float.parseFloat(string);
|
||||
break;
|
||||
case "biome":
|
||||
value = (string.toUpperCase());
|
||||
this.value = (string.toUpperCase());
|
||||
break;
|
||||
case "block":
|
||||
value = string;
|
||||
this.value = string;
|
||||
break;
|
||||
case "blocklist":
|
||||
value = string.split(",");
|
||||
this.value = string.split(",");
|
||||
break;
|
||||
case "string":
|
||||
value = string;
|
||||
this.value = string;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean validValue(String string) {
|
||||
try {
|
||||
if (this.type.equals("integer")) {
|
||||
@ -133,20 +100,18 @@ public class Setup extends SubCommand implements Listener {
|
||||
String[] split = string.split(":");
|
||||
Short.parseShort(split[0]);
|
||||
Short.parseShort(split[1]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Short.parseShort(string);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (this.type.equals("blocklist")) {
|
||||
for (String block:string.split(",")) {
|
||||
for (String block : string.split(",")) {
|
||||
if (block.contains(":")) {
|
||||
String[] split = block.split(":");
|
||||
Short.parseShort(split[0]);
|
||||
Short.parseShort(split[1]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Short.parseShort(block);
|
||||
}
|
||||
}
|
||||
@ -155,14 +120,14 @@ public class Setup extends SubCommand implements Listener {
|
||||
if (this.type.equals("string")) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
if (this.value instanceof String[]) {
|
||||
return (List<String>)(List<?>) Arrays.asList((String[]) this.value);
|
||||
return Arrays.asList((String[]) this.value);
|
||||
}
|
||||
return this.value;
|
||||
}
|
||||
@ -173,7 +138,7 @@ public class Setup extends SubCommand implements Listener {
|
||||
|
||||
public Object getDefaultValue() {
|
||||
if (this.default_value instanceof String[]) {
|
||||
return StringUtils.join((String[]) this.default_value,",");
|
||||
return StringUtils.join((String[]) this.default_value, ",");
|
||||
}
|
||||
return this.default_value;
|
||||
}
|
||||
@ -187,37 +152,17 @@ public class Setup extends SubCommand implements Listener {
|
||||
String world;
|
||||
int current = 0;
|
||||
|
||||
SetupStep[] step = new SetupStep[] {
|
||||
new SetupStep("road.height", PlotWorld.ROAD_HEIGHT_DEFAULT, "Height of road", "integer", false),
|
||||
new SetupStep("plot.height", PlotWorld.PLOT_HEIGHT_DEFAULT, "Height of plot", "integer", false),
|
||||
new SetupStep("wall.height", PlotWorld.WALL_HEIGHT_DEFAULT, "Height of wall", "integer", false),
|
||||
new SetupStep("plot.size", PlotWorld.PLOT_WIDTH_DEFAULT, "Size of plot", "integer", false),
|
||||
new SetupStep("road.width", PlotWorld.ROAD_WIDTH_DEFAULT, "Width of road", "integer", false),
|
||||
new SetupStep("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT, "Plot biome", "biome", false),
|
||||
new SetupStep("plot.filling", PlotWorld.MAIN_BLOCK_DEFAULT, "Plot filling", "blocklist", false),
|
||||
new SetupStep("plot.floor", PlotWorld.TOP_BLOCK_DEFAULT, "Plot floor", "blocklist", false),
|
||||
new SetupStep("wall.block", PlotWorld.WALL_BLOCK_DEFAULT, "Wall block", "block", false),
|
||||
new SetupStep("wall.filling", PlotWorld.WALL_FILLING_DEFAULT, "Wall filling", "block", false),
|
||||
new SetupStep("road.enable_stripes", PlotWorld.ROAD_STRIPES_ENABLED_DEFAULT, "Enable road stripes", "boolean", false),
|
||||
new SetupStep("road.stripes", PlotWorld.ROAD_STRIPES_DEFAULT, "Road stripes block", "block", true),
|
||||
new SetupStep("road.block", PlotWorld.ROAD_BLOCK_DEFAULT, "Road block", "block", false),
|
||||
};
|
||||
SetupStep[] step = new SetupStep[] { new SetupStep("road.height", PlotWorld.ROAD_HEIGHT_DEFAULT, "Height of road", "integer", false), new SetupStep("plot.height", PlotWorld.PLOT_HEIGHT_DEFAULT, "Height of plot", "integer", false), new SetupStep("wall.height", PlotWorld.WALL_HEIGHT_DEFAULT, "Height of wall", "integer", false), new SetupStep("plot.size", PlotWorld.PLOT_WIDTH_DEFAULT, "Size of plot", "integer", false), new SetupStep("road.width", PlotWorld.ROAD_WIDTH_DEFAULT, "Width of road", "integer", false), new SetupStep("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT, "Plot biome", "biome", false), new SetupStep("plot.filling", PlotWorld.MAIN_BLOCK_DEFAULT, "Plot filling", "blocklist", false), new SetupStep("plot.floor", PlotWorld.TOP_BLOCK_DEFAULT, "Plot floor", "blocklist", false), new SetupStep("wall.block", PlotWorld.WALL_BLOCK_DEFAULT, "Wall block", "block", false), new SetupStep("wall.filling", PlotWorld.WALL_FILLING_DEFAULT, "Wall filling", "block", false),
|
||||
new SetupStep("road.enable_stripes", PlotWorld.ROAD_STRIPES_ENABLED_DEFAULT, "Enable road stripes", "boolean", false), new SetupStep("road.stripes", PlotWorld.ROAD_STRIPES_DEFAULT, "Road stripes block", "block", true), new SetupStep("road.block", PlotWorld.ROAD_BLOCK_DEFAULT, "Road block", "block", false), };
|
||||
|
||||
public SetupObject(String world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public SetupStep getNextStep() {
|
||||
return this.step[current++];
|
||||
}
|
||||
|
||||
public int getCurrent() {
|
||||
return this.current;
|
||||
}
|
||||
|
||||
public void setCurrent(String string) {
|
||||
this.step[current].setValue(string);
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return this.step.length;
|
||||
}
|
||||
@ -229,15 +174,15 @@ public class Setup extends SubCommand implements Listener {
|
||||
|
||||
@Override
|
||||
public boolean execute(Player plr, String... args) {
|
||||
if(setupMap.containsKey(plr.getName())) {
|
||||
if (setupMap.containsKey(plr.getName())) {
|
||||
SetupObject object = setupMap.get(plr.getName());
|
||||
if(object.getCurrent() == object.getMax()) {
|
||||
if (object.getCurrent() == object.getMax()) {
|
||||
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
||||
|
||||
SetupStep[] steps = object.step;
|
||||
String world = object.world;
|
||||
for (SetupStep step:steps) {
|
||||
PlotMain.config.set("worlds."+world+"."+step.constant, step.getValue());
|
||||
for (SetupStep step : steps) {
|
||||
PlotMain.config.set("worlds." + world + "." + step.constant, step.getValue());
|
||||
}
|
||||
try {
|
||||
PlotMain.config.save(PlotMain.configFile);
|
||||
@ -245,15 +190,16 @@ public class Setup extends SubCommand implements Listener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// World newWorld = WorldCreator.name(world).generator(new WorldGenerator(world)).createWorld();
|
||||
// plr.teleport(newWorld.getSpawnLocation());
|
||||
// World newWorld = WorldCreator.name(world).generator(new
|
||||
// WorldGenerator(world)).createWorld();
|
||||
// plr.teleport(newWorld.getSpawnLocation());
|
||||
|
||||
setupMap.remove(plr.getName());
|
||||
|
||||
return true;
|
||||
}
|
||||
SetupStep step = object.step[object.current];
|
||||
if(args.length < 1) {
|
||||
if (args.length < 1) {
|
||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
||||
return true;
|
||||
} else {
|
||||
@ -263,23 +209,22 @@ public class Setup extends SubCommand implements Listener {
|
||||
return true;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("back")) {
|
||||
if (object.current>0) {
|
||||
if (object.current > 0) {
|
||||
object.current--;
|
||||
step = object.step[object.current];
|
||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
boolean valid = step.validValue(args[0]);
|
||||
if(valid) {
|
||||
if (valid) {
|
||||
sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(), args[0]);
|
||||
step.setValue(args[0]);
|
||||
object.current++;
|
||||
if(object.getCurrent() == object.getMax()) {
|
||||
if (object.getCurrent() == object.getMax()) {
|
||||
execute(plr, args);
|
||||
return true;
|
||||
}
|
||||
@ -302,7 +247,7 @@ public class Setup extends SubCommand implements Listener {
|
||||
sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
|
||||
return true;
|
||||
}
|
||||
if (PlotMain.getWorldSettings(world)!=null) {
|
||||
if (PlotMain.getWorldSettings(world) != null) {
|
||||
sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
|
||||
return true;
|
||||
}
|
||||
|
@ -90,8 +90,6 @@ public abstract class SubCommand {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Execute.
|
||||
*
|
||||
@ -109,6 +107,7 @@ public abstract class SubCommand {
|
||||
|
||||
/**
|
||||
* Send a message
|
||||
*
|
||||
* @param plr
|
||||
* @param c
|
||||
* @param args
|
||||
|
@ -9,8 +9,6 @@
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
@ -71,13 +69,13 @@ public class TP extends SubCommand {
|
||||
int index = 0;
|
||||
if (a.contains(";")) {
|
||||
String[] split = a.split(";");
|
||||
if (split[1].length()>0 && StringUtils.isNumeric(split[1])) {
|
||||
if ((split[1].length() > 0) && StringUtils.isNumeric(split[1])) {
|
||||
index = Integer.parseInt(split[1]);
|
||||
}
|
||||
a = split[0];
|
||||
}
|
||||
Player player = Bukkit.getPlayer(a);
|
||||
if (player!=null) {
|
||||
if (player != null) {
|
||||
Plot[] plots = PlotMain.getPlots(world, player).toArray(new Plot[0]);
|
||||
if (plots.length > index) {
|
||||
return plots[index];
|
||||
|
@ -22,11 +22,9 @@ import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotHelper;
|
||||
import com.intellectualcrafters.plot.PlotId;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.PlotSettings;
|
||||
import com.intellectualcrafters.plot.PlotWorld;
|
||||
import com.intellectualcrafters.plot.SetBlockFast;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
||||
import com.intellectualcrafters.plot.events.PlotUnlinkEvent;
|
||||
|
||||
/**
|
||||
@ -43,6 +41,7 @@ public class Unlink extends SubCommand {
|
||||
private int pathsize;
|
||||
private int wallheight;
|
||||
private int roadheight;
|
||||
|
||||
public Unlink() {
|
||||
super(Command.UNLINK, "Unlink a mega-plot", "unlink", CommandCategory.ACTIONS);
|
||||
}
|
||||
@ -54,7 +53,7 @@ public class Unlink extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
if ((plot==null || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return true;
|
||||
}
|
||||
@ -76,15 +75,17 @@ public class Unlink extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (PlotId id:ids) {
|
||||
for (PlotId id : ids) {
|
||||
Plot myplot = PlotMain.getPlots(world).get(id);
|
||||
|
||||
if (plot.helpers!=null)
|
||||
if (plot.helpers != null) {
|
||||
myplot.helpers = plot.helpers;
|
||||
if (plot.denied!=null)
|
||||
}
|
||||
if (plot.denied != null) {
|
||||
myplot.denied = plot.denied;
|
||||
}
|
||||
myplot.deny_entry = plot.deny_entry;
|
||||
myplot.settings.setMerged(new boolean[] {false, false, false, false} );
|
||||
myplot.settings.setMerged(new boolean[] { false, false, false, false });
|
||||
DBFunc.setMerged(world.getName(), myplot, myplot.settings.getMerged());
|
||||
}
|
||||
|
||||
@ -108,14 +109,13 @@ public class Unlink extends SubCommand {
|
||||
this.f1_v = (byte) result_f1[1];
|
||||
//
|
||||
|
||||
// Floor 2
|
||||
short[] result_f2 = PlotHelper.getBlock(plotworld.ROAD_STRIPES);
|
||||
PlotHelper.getBlock(plotworld.ROAD_STRIPES);
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
boolean lx = x < pos2.x;
|
||||
boolean ly = y < pos2.y;
|
||||
|
||||
PlotId id = new PlotId(x,y);
|
||||
PlotId id = new PlotId(x, y);
|
||||
|
||||
if (lx) {
|
||||
setRoadX(world, id);
|
||||
@ -135,16 +135,17 @@ public class Unlink extends SubCommand {
|
||||
|
||||
try {
|
||||
SetBlockFast.update(plr);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
PlayerFunctions.sendMessage(plr, "&6Plots unlinked successfully!");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting the road with the greatest X value
|
||||
*
|
||||
* @param world
|
||||
* @param id
|
||||
*/
|
||||
@ -152,23 +153,25 @@ public class Unlink extends SubCommand {
|
||||
Location pos1 = PlotHelper.getPlotBottomLocAbs(w, id);
|
||||
Location pos2 = PlotHelper.getPlotTopLocAbs(w, id);
|
||||
|
||||
int sx = pos2.getBlockX()+1;
|
||||
int ex = sx + pathsize - 1;
|
||||
int sz = pos1.getBlockZ()-1;
|
||||
int ez = pos2.getBlockZ()+2;
|
||||
int sx = pos2.getBlockX() + 1;
|
||||
int ex = (sx + this.pathsize) - 1;
|
||||
int sz = pos1.getBlockZ() - 1;
|
||||
int ez = pos2.getBlockZ() + 2;
|
||||
|
||||
PlotHelper.setSimpleCuboid(w, new Location(w,sx,Math.min(wallheight, roadheight)+1,sz+1), new Location(w,ex+1,257+1,ez), (short) 0);
|
||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(this.wallheight, this.roadheight) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), (short) 0);
|
||||
|
||||
PlotHelper.setCuboid(w, new Location(w,sx,1,sz+1), new Location(w,sx+1,wallheight+1,ez), new short[] {wf_id}, new short[] {wf_v});
|
||||
PlotHelper.setCuboid(w, new Location(w,sx,wallheight+1,sz+1), new Location(w,sx+1,wallheight+2,ez), new short[] {w_id}, new short[] {w_v});
|
||||
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, this.wallheight + 1, ez), new short[] { this.wf_id }, new short[] { this.wf_v });
|
||||
PlotHelper.setCuboid(w, new Location(w, sx, this.wallheight + 1, sz + 1), new Location(w, sx + 1, this.wallheight + 2, ez), new short[] { this.w_id }, new short[] { this.w_v });
|
||||
|
||||
PlotHelper.setCuboid(w, new Location(w,ex,1,sz+1), new Location(w,ex+1,wallheight+1,ez), new short[] {wf_id}, new short[] {wf_v});
|
||||
PlotHelper.setCuboid(w, new Location(w,ex,wallheight+1,sz+1), new Location(w,ex+1,wallheight+2,ez), new short[] {w_id}, new short[] {w_v});
|
||||
PlotHelper.setCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, this.wallheight + 1, ez), new short[] { this.wf_id }, new short[] { this.wf_v });
|
||||
PlotHelper.setCuboid(w, new Location(w, ex, this.wallheight + 1, sz + 1), new Location(w, ex + 1, this.wallheight + 2, ez), new short[] { this.w_id }, new short[] { this.w_v });
|
||||
|
||||
PlotHelper.setCuboid(w, new Location(w,sx+1,1,sz+1), new Location(w,ex,roadheight+1,ez), new short[] {f1_id}, new short[] {f1_v});
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, this.roadheight + 1, ez), new short[] { this.f1_id }, new short[] { this.f1_v });
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting the road with the greatest Y value
|
||||
*
|
||||
* @param world
|
||||
* @param id
|
||||
*/
|
||||
@ -177,36 +180,38 @@ public class Unlink extends SubCommand {
|
||||
Location pos1 = PlotHelper.getPlotBottomLocAbs(w, id);
|
||||
Location pos2 = PlotHelper.getPlotTopLocAbs(w, id);
|
||||
|
||||
int sz = pos2.getBlockZ()+1;
|
||||
int ez = sz + pathsize - 1;
|
||||
int sx = pos1.getBlockX()-1;
|
||||
int ex = pos2.getBlockX()+2;
|
||||
int sz = pos2.getBlockZ() + 1;
|
||||
int ez = (sz + this.pathsize) - 1;
|
||||
int sx = pos1.getBlockX() - 1;
|
||||
int ex = pos2.getBlockX() + 2;
|
||||
|
||||
PlotHelper.setSimpleCuboid(w, new Location(w,sx,Math.min(wallheight, roadheight)+1,sz+1), new Location(w,ex+1,257+1,ez), (short) 0);
|
||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(this.wallheight, this.roadheight) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), (short) 0);
|
||||
|
||||
PlotHelper.setCuboid(w, new Location(w,sx+1,1,sz), new Location(w,ex,wallheight+1,sz+1), new short[] {wf_id}, new short[] {wf_v});
|
||||
PlotHelper.setCuboid(w, new Location(w,sx+1,wallheight+1,sz), new Location(w,ex,wallheight+2,sz+1), new short[] {w_id}, new short[] {w_v});
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, this.wallheight + 1, sz + 1), new short[] { this.wf_id }, new short[] { this.wf_v });
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, this.wallheight + 1, sz), new Location(w, ex, this.wallheight + 2, sz + 1), new short[] { this.w_id }, new short[] { this.w_v });
|
||||
|
||||
PlotHelper.setCuboid(w, new Location(w,sx+1,1,sz), new Location(w,ex,wallheight+1,sz+1), new short[] {wf_id}, new short[] {wf_v});
|
||||
PlotHelper.setCuboid(w, new Location(w,sx+1,wallheight+1,ez), new Location(w,ex,wallheight+2,ez+1), new short[] {w_id}, new short[] {w_v});
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, this.wallheight + 1, sz + 1), new short[] { this.wf_id }, new short[] { this.wf_v });
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, this.wallheight + 1, ez), new Location(w, ex, this.wallheight + 2, ez + 1), new short[] { this.w_id }, new short[] { this.w_v });
|
||||
|
||||
PlotHelper.setCuboid(w, new Location(w,sx+1,1,sz+1), new Location(w,ex,roadheight+1,ez), new short[] {f1_id}, new short[] {f1_v});
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, this.roadheight + 1, ez), new short[] { this.f1_id }, new short[] { this.f1_v });
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting the intersection with the greatest X and Y value
|
||||
*
|
||||
* @param world
|
||||
* @param id
|
||||
*/
|
||||
public void setRoadXY(World w, PlotId id) {
|
||||
Location pos2 = PlotHelper.getPlotTopLocAbs(w, id);
|
||||
|
||||
int sx = pos2.getBlockX()+1;
|
||||
int ex = sx + pathsize - 1;
|
||||
int sz = pos2.getBlockZ()+1;
|
||||
int ez = sz + pathsize - 1;
|
||||
int sx = pos2.getBlockX() + 1;
|
||||
int ex = (sx + this.pathsize) - 1;
|
||||
int sz = pos2.getBlockZ() + 1;
|
||||
int ez = (sz + this.pathsize) - 1;
|
||||
|
||||
PlotHelper.setSimpleCuboid(w, new Location(w,sx,roadheight+1,sz+1), new Location(w,ex+1,257+1,ez), (short) 0);
|
||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx, this.roadheight + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), (short) 0);
|
||||
|
||||
PlotHelper.setCuboid(w, new Location(w,sx+1,1,sz+1), new Location(w,ex,roadheight+1,ez), new short[] {f1_id}, new short[] {f1_v});
|
||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, this.roadheight + 1, ez), new short[] { this.f1_id }, new short[] { this.f1_v });
|
||||
}
|
||||
}
|
||||
|
@ -9,16 +9,17 @@
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Visit extends SubCommand {
|
||||
public Visit() {
|
||||
|
@ -67,7 +67,7 @@ public class DBFunc {
|
||||
}
|
||||
|
||||
public static void createAllSettingsAndHelpers(ArrayList<Plot> plots) {
|
||||
HashMap<String, HashMap<PlotId, Integer>> stored = new HashMap< String, HashMap<PlotId, Integer>>();
|
||||
HashMap<String, HashMap<PlotId, Integer>> stored = new HashMap<String, HashMap<PlotId, Integer>>();
|
||||
HashMap<Integer, ArrayList<UUID>> helpers = new HashMap<Integer, ArrayList<UUID>>();
|
||||
try {
|
||||
PreparedStatement stmt = connection.prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z`, `world` FROM `plot`");
|
||||
@ -79,40 +79,40 @@ public class DBFunc {
|
||||
String world = result.getString("world");
|
||||
|
||||
if (!stored.containsKey(world)) {
|
||||
stored.put(world,new HashMap<PlotId, Integer>());
|
||||
stored.put(world, new HashMap<PlotId, Integer>());
|
||||
}
|
||||
stored.get(world).put(new PlotId(idx,idz), id);
|
||||
stored.get(world).put(new PlotId(idx, idz), id);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (Plot plot:plots) {
|
||||
for (Plot plot : plots) {
|
||||
String world = Bukkit.getWorld(plot.world).getName();
|
||||
if (stored.containsKey(world)) {
|
||||
Integer id = stored.get(world).get(plot.id);
|
||||
if (id!=null) {
|
||||
helpers.put(id,plot.helpers);
|
||||
if (id != null) {
|
||||
helpers.put(id, plot.helpers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (helpers.size()==0) {
|
||||
if (helpers.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add plot settings
|
||||
Integer[] ids = helpers.keySet().toArray(new Integer[0]);
|
||||
StringBuilder statement = new StringBuilder("INSERT INTO `plot_settings` (`plot_plot_id`) values ");
|
||||
for (int i = 0; i<ids.length-1; i++) {
|
||||
for (int i = 0; i < (ids.length - 1); i++) {
|
||||
statement.append("(?),");
|
||||
}
|
||||
statement.append("(?)");
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
stmt = connection.prepareStatement(statement.toString());
|
||||
for (int i = 0; i<ids.length; i++) {
|
||||
stmt.setInt(i+1, ids[i]);
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
stmt.setInt(i + 1, ids[i]);
|
||||
}
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
@ -123,9 +123,9 @@ public class DBFunc {
|
||||
// add plot helpers
|
||||
String prefix = "";
|
||||
statement = new StringBuilder("INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) values ");
|
||||
for (Integer id:helpers.keySet()) {
|
||||
for (UUID helper:helpers.get(id)) {
|
||||
statement.append(prefix+"(?, ?)");
|
||||
for (Integer id : helpers.keySet()) {
|
||||
for (UUID helper : helpers.get(id)) {
|
||||
statement.append(prefix + "(?, ?)");
|
||||
prefix = ",";
|
||||
}
|
||||
}
|
||||
@ -135,11 +135,11 @@ public class DBFunc {
|
||||
try {
|
||||
stmt = connection.prepareStatement(statement.toString());
|
||||
int counter = 0;
|
||||
for (Integer id:helpers.keySet()) {
|
||||
for (UUID helper:helpers.get(id)) {
|
||||
for (Integer id : helpers.keySet()) {
|
||||
for (UUID helper : helpers.get(id)) {
|
||||
|
||||
stmt.setInt(counter*2+1, id);
|
||||
stmt.setString(counter*2+2, helper.toString());
|
||||
stmt.setInt((counter * 2) + 1, id);
|
||||
stmt.setString((counter * 2) + 2, helper.toString());
|
||||
|
||||
counter++;
|
||||
}
|
||||
@ -158,12 +158,12 @@ public class DBFunc {
|
||||
* @param plot
|
||||
*/
|
||||
public static void createPlots(ArrayList<Plot> plots) {
|
||||
if (plots.size()==0) {
|
||||
if (plots.size() == 0) {
|
||||
return;
|
||||
}
|
||||
StringBuilder statement = new StringBuilder("INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) values ");
|
||||
|
||||
for (int i = 0; i<plots.size()-1; i++) {
|
||||
for (int i = 0; i < (plots.size() - 1); i++) {
|
||||
statement.append("(?, ?, ?, ?),");
|
||||
}
|
||||
statement.append("(?, ?, ?, ?)");
|
||||
@ -171,12 +171,12 @@ public class DBFunc {
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
stmt = connection.prepareStatement(statement.toString());
|
||||
for (int i = 0; i<plots.size(); i++) {
|
||||
for (int i = 0; i < plots.size(); i++) {
|
||||
Plot plot = plots.get(i);
|
||||
stmt.setInt(i*4+1, plot.id.x);
|
||||
stmt.setInt(i*4+2, plot.id.y);
|
||||
stmt.setString(i*4+3, plot.owner.toString());
|
||||
stmt.setString(i*4+4, plot.world);
|
||||
stmt.setInt((i * 4) + 1, plot.id.x);
|
||||
stmt.setInt((i * 4) + 2, plot.id.y);
|
||||
stmt.setString((i * 4) + 3, plot.owner.toString());
|
||||
stmt.setString((i * 4) + 4, plot.world);
|
||||
}
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
@ -415,7 +415,7 @@ public class DBFunc {
|
||||
boolean rain;
|
||||
try {
|
||||
rain = (int) settings.get("rain") == 1 ? true : false;
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
rain = false;
|
||||
}
|
||||
String alias = (String) settings.get("alias");
|
||||
@ -439,7 +439,7 @@ public class DBFunc {
|
||||
|
||||
boolean[] merged = new boolean[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
merged[3-i] = (merged_int & (1 << i)) != 0;
|
||||
merged[3 - i] = (merged_int & (1 << i)) != 0;
|
||||
}
|
||||
p = new Plot(plot_id, owner, plotBiome, helpers, trusted, denied, /* changeTime */false, time, rain, alias, position, flags, worldname, merged);
|
||||
if (plots.containsKey(worldname)) {
|
||||
@ -853,7 +853,7 @@ public class DBFunc {
|
||||
statement.setInt(1, getId(plot.getWorld().getName(), plot.id));
|
||||
ResultSet set = statement.executeQuery();
|
||||
double rating = 0;
|
||||
while(set.next()) {
|
||||
while (set.next()) {
|
||||
rating = set.getDouble("rating");
|
||||
}
|
||||
statement.close();
|
||||
|
@ -1,14 +1,5 @@
|
||||
package com.intellectualcrafters.plot.database;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotHomePosition;
|
||||
import com.intellectualcrafters.plot.PlotId;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.worldcretornica.plotme.PlayerList;
|
||||
import com.worldcretornica.plotme.Plot;
|
||||
import com.worldcretornica.plotme.PlotManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
@ -16,6 +7,16 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotHomePosition;
|
||||
import com.intellectualcrafters.plot.PlotId;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.worldcretornica.plotme.PlayerList;
|
||||
import com.worldcretornica.plotme.Plot;
|
||||
import com.worldcretornica.plotme.PlotManager;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-17.
|
||||
*/
|
||||
@ -29,8 +30,7 @@ public class PlotMeConverter {
|
||||
|
||||
public void runAsync() throws Exception {
|
||||
|
||||
/* TODO Fix this... */
|
||||
boolean offlineMode = Bukkit.getOnlineMode();
|
||||
Bukkit.getOnlineMode();
|
||||
|
||||
final PrintStream stream = new PrintStream("converter_log.txt");
|
||||
|
||||
@ -42,10 +42,11 @@ public class PlotMeConverter {
|
||||
HashMap<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
HashMap<String, Plot> plots = PlotManager.getPlots(world);
|
||||
if (plots!=null) {
|
||||
if (plots != null) {
|
||||
|
||||
// TODO generate configuration based on PlotMe config
|
||||
// - Plugin doesn't display a message if database is not setup at all
|
||||
// - Plugin doesn't display a message if database is not
|
||||
// setup at all
|
||||
|
||||
PlotMain.sendConsoleSenderMessage("Converting " + plots.size() + " plots for '" + world.toString() + "'...");
|
||||
for (Plot plot : plots.values()) {
|
||||
@ -60,7 +61,9 @@ public class PlotMeConverter {
|
||||
long eR3040bl230 = 22392948l;
|
||||
try {
|
||||
|
||||
// TODO It just comes up with a NoSuchFieldException. Y U NO WORK!!! (I didn't change anything here btw)
|
||||
// TODO It just comes up with a
|
||||
// NoSuchFieldException. Y U NO WORK!!! (I
|
||||
// didn't change anything here btw)
|
||||
Field fAdded = plot.getClass().getDeclaredField("allowed");
|
||||
Field fDenied = plot.getClass().getDeclaredField("denied");
|
||||
fAdded.setAccessible(true);
|
||||
@ -68,16 +71,16 @@ public class PlotMeConverter {
|
||||
added = (PlayerList) fAdded.get(plot);
|
||||
denied = (PlayerList) fDenied.get(plot);
|
||||
for (Map.Entry<String, UUID> set : added.getAllPlayers().entrySet()) {
|
||||
if (set.getValue() != null || set.getKey().equals("*")) {
|
||||
if ((set.getValue() != null) || set.getKey().equals("*")) {
|
||||
if (set.getKey().equalsIgnoreCase("*") || set.getValue().toString().equals("*")) {
|
||||
psAdded.add(DBFunc.everyone);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
/*
|
||||
* Does this work for offline mode servers?
|
||||
* Does this work for offline mode
|
||||
* servers?
|
||||
*/
|
||||
|
||||
if (uuidMap.containsKey(set.getKey())) {
|
||||
@ -85,7 +88,7 @@ public class PlotMeConverter {
|
||||
continue;
|
||||
}
|
||||
UUID value = Bukkit.getOfflinePlayer(set.getKey()).getUniqueId();
|
||||
if (value!=null) {
|
||||
if (value != null) {
|
||||
uuidMap.put(set.getKey(), value);
|
||||
psAdded.add(value);
|
||||
continue;
|
||||
@ -94,19 +97,18 @@ public class PlotMeConverter {
|
||||
psAdded.add(set.getValue());
|
||||
}
|
||||
for (Map.Entry<String, UUID> set : denied.getAllPlayers().entrySet()) {
|
||||
if (set.getValue() != null || set.getKey().equals("*")) {
|
||||
if ((set.getValue() != null) || set.getKey().equals("*")) {
|
||||
if (set.getKey().equals("*") || set.getValue().toString().equals("*")) {
|
||||
psDenied.add(DBFunc.everyone);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (uuidMap.containsKey(set.getKey())) {
|
||||
psDenied.add(uuidMap.get(set.getKey()));
|
||||
continue;
|
||||
}
|
||||
UUID value = Bukkit.getOfflinePlayer(set.getKey()).getUniqueId();
|
||||
if (value!=null) {
|
||||
if (value != null) {
|
||||
uuidMap.put(set.getKey(), value);
|
||||
psDenied.add(value);
|
||||
continue;
|
||||
@ -116,38 +118,32 @@ public class PlotMeConverter {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Doing it the slow way like a n00b.
|
||||
for (String user:plot.getAllowed().split(",")) {
|
||||
for (String user : plot.getAllowed().split(",")) {
|
||||
try {
|
||||
if (user.equals("*")) {
|
||||
psAdded.add(DBFunc.everyone);
|
||||
}
|
||||
else if (uuidMap.containsKey(user)) {
|
||||
} else if (uuidMap.containsKey(user)) {
|
||||
psAdded.add(uuidMap.get(user));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
UUID uuid = Bukkit.getOfflinePlayer(user).getUniqueId();
|
||||
uuidMap.put(user, uuid);
|
||||
psAdded.add(uuid);
|
||||
}
|
||||
}
|
||||
catch (Exception e2) {
|
||||
} catch (Exception e2) {
|
||||
}
|
||||
}
|
||||
for (String user:plot.getDenied().split(",")) {
|
||||
for (String user : plot.getDenied().split(",")) {
|
||||
try {
|
||||
if (user.equals("*")) {
|
||||
psDenied.add(DBFunc.everyone);
|
||||
}
|
||||
else if (uuidMap.containsKey(user)) {
|
||||
} else if (uuidMap.containsKey(user)) {
|
||||
psDenied.add(uuidMap.get(user));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
UUID uuid = Bukkit.getOfflinePlayer(user).getUniqueId();
|
||||
uuidMap.put(user, uuid);
|
||||
psDenied.add(uuid);
|
||||
}
|
||||
}
|
||||
catch (Exception e2) {
|
||||
} catch (Exception e2) {
|
||||
}
|
||||
}
|
||||
eR3040bl230 = 232000499888388747l;
|
||||
@ -156,9 +152,10 @@ public class PlotMeConverter {
|
||||
}
|
||||
stream.println(eR3040bl230);
|
||||
PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1]));
|
||||
com.intellectualcrafters.plot.Plot pl = new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] {false, false, false, false} );
|
||||
com.intellectualcrafters.plot.Plot pl = new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false });
|
||||
|
||||
// TODO createPlot doesn't add helpers / denied users
|
||||
// TODO createPlot doesn't add helpers / denied
|
||||
// users
|
||||
|
||||
createdPlots.add(pl);
|
||||
}
|
||||
@ -172,9 +169,12 @@ public class PlotMeConverter {
|
||||
stream.close();
|
||||
PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has finished");
|
||||
|
||||
// TODO disable PlotMe -> Unload all plot worlds, change the generator, restart the server automatically
|
||||
// Possibly use multiverse / multiworld if it's to difficult modifying a world's generator while the server is running
|
||||
// Should really do that? Would seem pretty bad from our side + bukkit wouldn't approve
|
||||
// TODO disable PlotMe -> Unload all plot worlds, change the
|
||||
// generator, restart the server automatically
|
||||
// Possibly use multiverse / multiworld if it's to difficult
|
||||
// modifying a world's generator while the server is running
|
||||
// Should really do that? Would seem pretty bad from our side +
|
||||
// bukkit wouldn't approve
|
||||
|
||||
Bukkit.getPluginManager().disablePlugin(PlotMeConverter.this.plugin);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
/**
|
||||
* PlayerClaimPlotEvent: Called when a plot is claimed
|
||||
*
|
||||
* @param player
|
||||
* @param plot
|
||||
*/
|
||||
@ -37,6 +38,7 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
/**
|
||||
* Get the plot involved
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getPlot() {
|
||||
|
@ -17,6 +17,7 @@ public class PlayerEnterPlotEvent extends PlayerEvent {
|
||||
|
||||
/**
|
||||
* PlayerEnterPlotEvent: Called when a player leaves a plot
|
||||
*
|
||||
* @param player
|
||||
* @param plot
|
||||
*/
|
||||
@ -27,6 +28,7 @@ public class PlayerEnterPlotEvent extends PlayerEvent {
|
||||
|
||||
/**
|
||||
* Get the plot involved
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getPlot() {
|
||||
|
@ -13,8 +13,10 @@ public class PlayerLeavePlotEvent extends PlayerEvent {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
|
||||
private Plot plot;
|
||||
|
||||
/**
|
||||
* PlayerLeavePlotEvent: Called when a player leaves a plot
|
||||
*
|
||||
* @param player
|
||||
* @param plot
|
||||
*/
|
||||
@ -22,8 +24,10 @@ public class PlayerLeavePlotEvent extends PlayerEvent {
|
||||
super(player);
|
||||
this.plot = plot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plot involved
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getPlot() {
|
||||
|
@ -18,8 +18,11 @@ public class PlayerPlotDeniedEvent extends Event {
|
||||
private Player initiator;
|
||||
private boolean added;
|
||||
private UUID player;
|
||||
|
||||
/**
|
||||
* PlayerPlotDeniedEvent: Called when the denied UUID list is modified for a plot
|
||||
* PlayerPlotDeniedEvent: Called when the denied UUID list is modified for a
|
||||
* plot
|
||||
*
|
||||
* @param initiator
|
||||
* @param plot
|
||||
* @param player
|
||||
@ -34,27 +37,34 @@ public class PlayerPlotDeniedEvent extends Event {
|
||||
|
||||
/**
|
||||
* If a user was added
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean wasAdded() {
|
||||
return this.added;
|
||||
}
|
||||
|
||||
/**
|
||||
* The player added/removed
|
||||
*
|
||||
* @return UUID
|
||||
*/
|
||||
public UUID getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
* The plot involved
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getPlot() {
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
/**
|
||||
* The player initiating the action
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getInitiator() {
|
||||
|
@ -18,8 +18,10 @@ public class PlayerPlotHelperEvent extends Event {
|
||||
private Player initiator;
|
||||
private boolean added;
|
||||
private UUID player;
|
||||
|
||||
/**
|
||||
* PlayerPlotHelperEvent: Called when a plot helper is added/removed
|
||||
*
|
||||
* @param initiator
|
||||
* @param plot
|
||||
* @param player
|
||||
@ -34,27 +36,34 @@ public class PlayerPlotHelperEvent extends Event {
|
||||
|
||||
/**
|
||||
* If a player was added
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean wasAdded() {
|
||||
return this.added;
|
||||
}
|
||||
|
||||
/**
|
||||
* The UUID added/removed
|
||||
*
|
||||
* @return UUID
|
||||
*/
|
||||
public UUID getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
* The plot involved
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getPlot() {
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
/**
|
||||
* The player initiating the action
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getInitiator() {
|
||||
|
@ -18,8 +18,10 @@ public class PlayerPlotTrustedEvent extends Event {
|
||||
private Player initiator;
|
||||
private boolean added;
|
||||
private UUID player;
|
||||
|
||||
/**
|
||||
* PlayerPlotTrustedEvent: Called when a plot trusted user is added/removed
|
||||
*
|
||||
* @param initiator
|
||||
* @param plot
|
||||
* @param player
|
||||
@ -34,27 +36,34 @@ public class PlayerPlotTrustedEvent extends Event {
|
||||
|
||||
/**
|
||||
* If a player was added
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean wasAdded() {
|
||||
return this.added;
|
||||
}
|
||||
|
||||
/**
|
||||
* The UUID added/removed
|
||||
*
|
||||
* @return UUID
|
||||
*/
|
||||
public UUID getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
* The plot involved
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getPlot() {
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
/**
|
||||
* The player initiating the action
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getInitiator() {
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
|
||||
/**
|
||||
* Called when a player teleports to a plot
|
||||
*/
|
||||
@ -26,8 +27,10 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
|
||||
private Plot plot;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot
|
||||
*
|
||||
* @param player
|
||||
* @param from
|
||||
* @param plot
|
||||
@ -45,6 +48,7 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
|
||||
|
||||
/**
|
||||
* Get the from location
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public Location getFrom() {
|
||||
@ -53,6 +57,7 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
|
||||
|
||||
/**
|
||||
* Get the plot involved
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getPlot() {
|
||||
|
@ -24,8 +24,10 @@ public class PlotClearEvent extends Event implements Cancellable {
|
||||
|
||||
private PlotId id;
|
||||
private String world;
|
||||
|
||||
/**
|
||||
* PlotDeleteEvent: Called when a plot is cleared
|
||||
*
|
||||
* @param world
|
||||
* @param id
|
||||
*/
|
||||
@ -36,6 +38,7 @@ public class PlotClearEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Get the PlotId
|
||||
*
|
||||
* @return PlotId
|
||||
*/
|
||||
public PlotId getPlotId() {
|
||||
@ -44,6 +47,7 @@ public class PlotClearEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Get the world name
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
|
@ -24,8 +24,10 @@ public class PlotDeleteEvent extends Event implements Cancellable {
|
||||
|
||||
private PlotId id;
|
||||
private String world;
|
||||
|
||||
/**
|
||||
* PlotDeleteEvent: Called when a plot is deleted
|
||||
*
|
||||
* @param world
|
||||
* @param id
|
||||
*/
|
||||
@ -36,6 +38,7 @@ public class PlotDeleteEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Get the PlotId
|
||||
*
|
||||
* @return PlotId
|
||||
*/
|
||||
public PlotId getPlotId() {
|
||||
@ -44,6 +47,7 @@ public class PlotDeleteEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Get the world name
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
|
@ -28,6 +28,7 @@ public class PlotFlagAddEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* PlotFlagAddEvent: Called when a Flag is added to a plot
|
||||
*
|
||||
* @param flag
|
||||
* @param plot
|
||||
*/
|
||||
@ -38,6 +39,7 @@ public class PlotFlagAddEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Get the plot involved
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getPlot() {
|
||||
@ -46,6 +48,7 @@ public class PlotFlagAddEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Get the flag involved
|
||||
*
|
||||
* @return Flag
|
||||
*/
|
||||
public Flag getFlag() {
|
||||
|
@ -28,6 +28,7 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* PlotFlagRemoveEvent: Called when a flag is removed from a plot
|
||||
*
|
||||
* @param flag
|
||||
* @param plot
|
||||
*/
|
||||
@ -35,15 +36,19 @@ public class PlotFlagRemoveEvent extends Event implements Cancellable {
|
||||
this.plot = plot;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plot involved
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getPlot() {
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the flag involved
|
||||
*
|
||||
* @return Flag
|
||||
*/
|
||||
public Flag getFlag() {
|
||||
|
@ -10,14 +10,11 @@
|
||||
package com.intellectualcrafters.plot.events;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotId;
|
||||
@ -35,6 +32,7 @@ public class PlotMergeEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* PlotMergeEvent: Called when plots are merged
|
||||
*
|
||||
* @param player
|
||||
* @param plot
|
||||
*/
|
||||
@ -44,13 +42,16 @@ public class PlotMergeEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Get the plots being added;
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
public ArrayList<PlotId> getPlots() {
|
||||
return this.plots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the main plot
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getPlot() {
|
||||
|
@ -10,16 +10,12 @@
|
||||
package com.intellectualcrafters.plot.events;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotId;
|
||||
|
||||
/**
|
||||
@ -34,6 +30,7 @@ public class PlotUnlinkEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Called when a mega-plot is unlinked.
|
||||
*
|
||||
* @param world
|
||||
* @param plots
|
||||
*/
|
||||
@ -44,6 +41,7 @@ public class PlotUnlinkEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Get the plots involved
|
||||
*
|
||||
* @return PlotId
|
||||
*/
|
||||
public ArrayList<PlotId> getPlots() {
|
||||
|
@ -19,7 +19,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
@ -65,7 +64,6 @@ import org.bukkit.event.world.StructureGrowEvent;
|
||||
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;
|
||||
@ -138,7 +136,7 @@ public class PlayerEvents implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onChangeWorld(PlayerChangedWorldEvent event) {
|
||||
if (isPlotWorld(event.getFrom()) && Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) {
|
||||
if (isPlotWorld(event.getFrom()) && (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) {
|
||||
event.getPlayer().setResourcePack("");
|
||||
} else {
|
||||
textures(event.getPlayer());
|
||||
@ -198,8 +196,7 @@ public class PlayerEvents implements Listener {
|
||||
PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
// Gotta catch 'em all.
|
||||
}
|
||||
}
|
||||
@ -251,7 +248,7 @@ public class PlayerEvents implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
if (PlayerFunctions.getPlot(event.getBlock().getLocation())==null) {
|
||||
if (PlayerFunctions.getPlot(event.getBlock().getLocation()) == null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -271,7 +268,7 @@ public class PlayerEvents implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
if (PlayerFunctions.getPlot(event.getBlockPlaced().getLocation())==null) {
|
||||
if (PlayerFunctions.getPlot(event.getBlockPlaced().getLocation()) == null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -488,7 +485,7 @@ public class PlayerEvents implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
if (PlayerFunctions.getPlot(event.getClickedBlock().getLocation())==null) {
|
||||
if (PlayerFunctions.getPlot(event.getClickedBlock().getLocation()) == null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class WorldEditListener implements Listener {
|
||||
}
|
||||
Plot plot = PlotHelper.getCurrentPlot(b.getLocation());
|
||||
if (plot != null) {
|
||||
if ((plot != null) && plot.hasOwner() && plot.helpers!=null && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
|
||||
if ((plot != null) && plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
|
||||
PWE.setMask(p, l);
|
||||
}
|
||||
}
|
||||
@ -113,7 +113,7 @@ public class WorldEditListener implements Listener {
|
||||
if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) {
|
||||
return;
|
||||
}
|
||||
if (idT!=null && !(idF == idT)) {
|
||||
if ((idT != null) && !(idF == idT)) {
|
||||
PWE.setMask(p, t);
|
||||
}
|
||||
}
|
||||
@ -130,8 +130,7 @@ public class WorldEditListener implements Listener {
|
||||
if (!isPlotWorld(t)) {
|
||||
if (isPlotWorld(f)) {
|
||||
PWE.removeMask(p);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -149,8 +148,7 @@ public class WorldEditListener implements Listener {
|
||||
if (!isPlotWorld(t)) {
|
||||
if (isPlotWorld(f)) {
|
||||
PWE.removeMask(p);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
package com.intellectualcrafters.plot.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotHelper;
|
||||
@ -15,8 +20,6 @@ import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
||||
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
||||
import com.intellectualcrafters.plot.events.PlotUnlinkEvent;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
@ -24,14 +27,6 @@ import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-09-24.
|
||||
*/
|
||||
@ -39,64 +34,61 @@ public class WorldGuardListener implements Listener {
|
||||
public ArrayList<String> str_flags = new ArrayList<String>();
|
||||
public ArrayList<Flag<?>> flags = new ArrayList<Flag<?>>();
|
||||
|
||||
|
||||
public WorldGuardListener(PlotMain plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
for (Flag<?> flag:DefaultFlag.getFlags()) {
|
||||
str_flags.add(flag.getName());
|
||||
flags.add(flag);
|
||||
for (Flag<?> flag : DefaultFlag.getFlags()) {
|
||||
this.str_flags.add(flag.getName());
|
||||
this.flags.add(flag);
|
||||
}
|
||||
}
|
||||
public void removeFlag(Player requester, World world, Plot plot,String key) {
|
||||
|
||||
public void removeFlag(Player requester, World world, Plot plot, String key) {
|
||||
boolean op = requester.isOp();
|
||||
requester.setOp(true);
|
||||
try {
|
||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||
ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y);
|
||||
for (Flag flag:flags) {
|
||||
manager.getRegion(plot.id.x + "-" + plot.id.y);
|
||||
for (Flag flag : this.flags) {
|
||||
if (flag.getName().equalsIgnoreCase(key)) {
|
||||
requester.performCommand("region flag "+(plot.id.x + "-" + plot.id.y)+" "+key);
|
||||
requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
requester.setOp(op);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
requester.setOp(op);
|
||||
}
|
||||
}
|
||||
|
||||
public void addFlag(Player requester, World world, Plot plot,String key, String value) {
|
||||
public void addFlag(Player requester, World world, Plot plot, String key, String value) {
|
||||
boolean op = requester.isOp();
|
||||
requester.setOp(true);
|
||||
try {
|
||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||
ProtectedRegion region = manager.getRegion(plot.id.x + "-" + plot.id.y);
|
||||
for (Flag flag:flags) {
|
||||
manager.getRegion(plot.id.x + "-" + plot.id.y);
|
||||
for (Flag flag : this.flags) {
|
||||
if (flag.getName().equalsIgnoreCase(key)) {
|
||||
requester.performCommand("region flag "+(plot.id.x + "-" + plot.id.y)+" "+key+" "+value);
|
||||
requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key + " " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
requester.setOp(op);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
requester.setOp(op);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onMerge(PlotMergeEvent event) {
|
||||
Plot main = event.getPlot();
|
||||
ArrayList<PlotId> plots = event.getPlots();
|
||||
World world = event.getWorld();
|
||||
RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
|
||||
for (PlotId plot:plots) {
|
||||
if (!plot.equals(main))
|
||||
for (PlotId plot : plots) {
|
||||
if (!plot.equals(main)) {
|
||||
manager.removeRegion(plot.x + "-" + plot.y);
|
||||
}
|
||||
}
|
||||
ProtectedRegion region = manager.getRegion(main.id.x + "-" + main.id.y);
|
||||
DefaultDomain owner = region.getOwners();
|
||||
Map<Flag<?>, Object> flags = region.getFlags();
|
||||
@ -104,7 +96,7 @@ public class WorldGuardListener implements Listener {
|
||||
manager.removeRegion(main.id.x + "-" + main.id.y);
|
||||
|
||||
Location location1 = PlotHelper.getPlotBottomLocAbs(world, plots.get(0));
|
||||
Location location2 = PlotHelper.getPlotTopLocAbs(world, plots.get(plots.size()-1));
|
||||
Location location2 = PlotHelper.getPlotTopLocAbs(world, plots.get(plots.size() - 1));
|
||||
|
||||
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
|
||||
BlockVector vector2 = new BlockVector(location2.getBlockX(), world.getMaxHeight(), location2.getBlockZ());
|
||||
@ -119,7 +111,7 @@ public class WorldGuardListener implements Listener {
|
||||
manager.addRegion(rg);
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onUnlink(PlotUnlinkEvent event) {
|
||||
World w = event.getWorld();
|
||||
ArrayList<PlotId> plots = event.getPlots();
|
||||
@ -133,7 +125,7 @@ public class WorldGuardListener implements Listener {
|
||||
DefaultDomain members = region.getMembers();
|
||||
|
||||
manager.removeRegion(main.id.x + "-" + main.id.y);
|
||||
for (int i = 1;i<plots.size();i++) {
|
||||
for (int i = 1; i < plots.size(); i++) {
|
||||
PlotId id = plots.get(i);
|
||||
Location location1 = PlotHelper.getPlotBottomLocAbs(w, id);
|
||||
Location location2 = PlotHelper.getPlotTopLocAbs(w, id);
|
||||
|
Loading…
Reference in New Issue
Block a user