Time for our weekly code cleanup!

Please tell me if doing this annoys you.
This commit is contained in:
boy0001 2014-10-03 12:36:30 +10:00
parent 58ed037fad
commit 980499a193
55 changed files with 1366 additions and 1186 deletions

View File

@ -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() {

View File

@ -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
*/

View File

@ -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() {

View File

@ -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)
*/

View File

@ -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;
@ -32,7 +34,7 @@ public class PWE {
Plot plot = PlotMain.getPlots(l.getWorld()).get(id);
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,7 +64,6 @@ 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);
@ -78,8 +78,7 @@ public class PWE {
try {
com.sk89q.worldedit.masks.Mask mask = s.getMask();
return mask == null;
}
catch (Throwable e) {
} 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);

View File

@ -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;
@ -77,6 +76,7 @@ public class PlayerFunctions {
}
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)));
@ -86,6 +86,7 @@ public class PlayerFunctions {
}
return plot;
}
/**
*
* @param loc
@ -101,8 +102,7 @@ public class PlayerFunctions {
int pathWidthLower;
if ((plotworld.ROAD_WIDTH % 2) == 0) {
pathWidthLower = (int) (Math.floor(plotworld.ROAD_WIDTH / 2) - 1);
}
else {
} else {
pathWidthLower = (int) Math.floor(plotworld.ROAD_WIDTH / 2);
}
@ -122,8 +122,8 @@ public class PlayerFunctions {
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;
boolean northSouth = (rz <= pathWidthLower) || (rz > (pathWidthLower + plotworld.PLOT_WIDTH));
boolean eastWest = (rx <= pathWidthLower) || (rx > end);
if (northSouth || eastWest) {
return null;
@ -144,8 +144,7 @@ public class PlayerFunctions {
int pathWidthLower;
if ((plotworld.ROAD_WIDTH % 2) == 0) {
pathWidthLower = (int) (Math.floor(plotworld.ROAD_WIDTH / 2) - 1);
}
else {
} else {
pathWidthLower = (int) Math.floor(plotworld.ROAD_WIDTH / 2);
}
@ -166,8 +165,8 @@ public class PlayerFunctions {
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
@ -182,7 +181,8 @@ 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) {

View File

@ -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)
*

View File

@ -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
@ -58,12 +69,14 @@ public class PlotHelper {
/**
* 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)
@ -112,9 +125,9 @@ public class PlotHelper {
Location loc = getPlotTopLocAbs(world, id);
int sx = loc.getBlockX() + 1;
int ex = sx + pathsize - 1;
int ex = (sx + pathsize) - 1;
int sz = loc.getBlockZ() + 1;
int ez = sz + pathsize - 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);
@ -150,7 +163,7 @@ public class PlotHelper {
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()) {
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,12 +173,12 @@ 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
@ -216,8 +229,7 @@ public class PlotHelper {
greaterPlot.settings.setMerged(0, true);
startx--;
endx++;
}
else {
} else {
noMerge = lesserPlot.settings.getMerged(1);
@ -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) {
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;
}
}
@ -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,15 +755,16 @@ 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()) {
PlotId id = PlayerFunctions.getPlot(entity.getLocation());
if (id!=null && id.equals(plot.id)) {
if ((id != null) && id.equals(plot.id)) {
entity.remove();
}
}
@ -765,6 +779,7 @@ public class PlotHelper {
/**
* Clear a plot
*
* @param requester
* @param plot
*/
@ -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) {
}
}

View File

@ -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

View File

@ -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
@ -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
@ -160,11 +257,10 @@ public class PlotMain extends JavaPlugin {
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++) {
for (int i = 0; i < (nodes.length - 1); i++) {
n.append(nodes[i] + ".");
if (player.hasPermission(n + "*")) {
hasperm = true;
@ -172,9 +268,10 @@ public class PlotMain extends JavaPlugin {
}
}
}
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,7 +294,7 @@ public class PlotMain extends JavaPlugin {
}
String[] nodes = perm.split("\\.");
StringBuilder n = new StringBuilder();
for(int i = 0; i < nodes.length-1; i++) {
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,7 +495,9 @@ public class PlotMain extends JavaPlugin {
continue;
}
long lastPlayed = getLastPlayed(plot.owner);
if(lastPlayed == 0) continue;
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);
@ -502,8 +603,7 @@ public class PlotMain extends JavaPlugin {
ResultSet res = meta.getTables(null, null, "plot", null);
if (!res.next()) {
DBFunc.createTables("mysql", true);
}
else {
} else {
res = meta.getTables(null, null, "plot_trusted", null);
if (!res.next()) {
DBFunc.createTables("mysql", false);
@ -579,12 +679,13 @@ 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) {
checkExpired(PlotMain.getMain(), true);
checkForExpiredPlots();
@ -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
*/
@ -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) {

View File

@ -15,8 +15,6 @@ import java.util.Set;
import org.bukkit.block.Biome;
import com.intellectualcrafters.plot.RUtils.Direction;
/**
* plot settings
*
@ -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

View File

@ -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;
}

View File

@ -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 {

View File

@ -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";

View File

@ -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) {
if ((this.pathsize % 2) == 0) {
pathWidthLower = Math.floor(this.pathsize / 2) - 1;
}
else {
} else {
pathWidthLower = Math.floor(this.pathsize / 2);
}
final int prime = 31;

View File

@ -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);
}
}

View File

@ -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;

View File

@ -7,20 +7,24 @@
* >> 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;
boolean teleport = ((i == end.x) && (j == end.y)) ? true : false;
Claim.claimPlot(plr, plot, teleport);
}
}
@ -118,6 +119,7 @@ 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++) {

View File

@ -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

View 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;
}

View File

@ -17,15 +17,18 @@ 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>
// - /plot list <some parameter to list the most popular, and highest rated
// plots>
TRUSTED("trusted", "trust"),
/**
*

View 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 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;
}

View File

@ -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,7 +86,8 @@ 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"));
// 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))));
}

View File

@ -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;
}

View File

@ -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)) {

View File

@ -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;
/**
*
@ -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();

View File

@ -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,7 +32,7 @@ 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;
}
@ -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;
}

View File

@ -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;
/**
*
@ -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;
}
@ -109,7 +118,7 @@ public class Merge extends SubCommand {
}
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;
}

View File

@ -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() {
@ -49,7 +51,7 @@ public class Rate extends SubCommand {
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;
}

View File

@ -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,9 +21,18 @@ 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;
/**
*
@ -79,15 +87,16 @@ public class Set extends SubCommand{
if (args.length < 2) {
String message = StringUtils.join(FlagManager.getFlags(), "&c, &6");
if (PlotMain.worldGuardListener != null) {
if (message.equals(""))
if (message.equals("")) {
message = StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6");
else
} 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;
}
@ -116,8 +125,9 @@ public class Set extends SubCommand{
}
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);
@ -125,7 +135,7 @@ public class Set extends SubCommand{
}
try {
String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
if (FlagManager.getFlag(args[1].toLowerCase())==null && PlotMain.worldGuardListener != null) {
if ((FlagManager.getFlag(args[1].toLowerCase()) == null) && (PlotMain.worldGuardListener != null)) {
PlotMain.worldGuardListener.addFlag(plr, plr.getWorld(), plot, args[1], value);
return false;
}
@ -141,8 +151,7 @@ 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) {
} catch (Exception e) {
PlayerFunctions.sendMessage(plr, "&c" + e.getMessage());
return false;
}
@ -162,8 +171,11 @@ public class Set extends SubCommand{
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();
if (b) {
p.setPlayerWeather(WeatherType.DOWNFALL);
} else {
p.resetPlayerWeather();
}
}
}
return true;
@ -176,7 +188,9 @@ public class Set extends SubCommand{
}
PlotHomePosition position = null;
for (PlotHomePosition p : PlotHomePosition.values()) {
if(p.isMatching(args[1])) position = p;
if (p.isMatching(args[1])) {
position = p;
}
}
if (position == null) {
PlayerFunctions.sendMessage(plr, C.INVALID_POSITION);
@ -238,14 +252,14 @@ public class Set extends SubCommand{
return true;
}
Material material = null;
for(Material m : plotworld.BLOCKS) {
for (Material m : PlotWorld.BLOCKS) {
if (m.toString().equalsIgnoreCase(args[1])) {
material = m;
break;
}
}
if (material == null) {
PlayerFunctions.sendMessage(plr, getBlockList(plotworld.BLOCKS));
PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
return true;
}
byte data = 0;
@ -274,7 +288,7 @@ public class Set extends SubCommand{
}
//
@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(",");
@ -329,14 +343,14 @@ public class Set extends SubCommand{
return true;
}
Material material = null;
for(Material m : plotworld.BLOCKS) {
for (Material m : PlotWorld.BLOCKS) {
if (m.toString().equalsIgnoreCase(args[1])) {
material = m;
break;
}
}
if (material == null) {
PlayerFunctions.sendMessage(plr, getBlockList(plotworld.BLOCKS));
PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
return true;
}
byte data = 0;
@ -397,5 +411,4 @@ public class Set extends SubCommand{
return builder.toString().substring(1, builder.toString().length() - 1);
}
}

View File

@ -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,8 +100,7 @@ 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;
@ -145,8 +111,7 @@ public class Setup extends SubCommand implements Listener {
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;
}
@ -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;
}
@ -245,7 +190,8 @@ public class Setup extends SubCommand implements Listener {
e.printStackTrace();
}
// World newWorld = WorldCreator.name(world).generator(new WorldGenerator(world)).createWorld();
// World newWorld = WorldCreator.name(world).generator(new
// WorldGenerator(world)).createWorld();
// plr.teleport(newWorld.getSpawnLocation());
setupMap.remove(plr.getName());
@ -268,8 +214,7 @@ public class Setup extends SubCommand implements Listener {
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;
}

View File

@ -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

View File

@ -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,7 +69,7 @@ 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];

View File

@ -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;
}
@ -79,10 +78,12 @@ public class Unlink extends SubCommand {
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 });
DBFunc.setMerged(world.getName(), myplot, myplot.settings.getMerged());
@ -108,8 +109,7 @@ 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;
@ -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
*/
@ -153,22 +154,24 @@ public class Unlink extends SubCommand {
Location pos2 = PlotHelper.getPlotTopLocAbs(w, id);
int sx = pos2.getBlockX() + 1;
int ex = sx + pathsize - 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
*/
@ -178,22 +181,24 @@ public class Unlink extends SubCommand {
Location pos2 = PlotHelper.getPlotTopLocAbs(w, id);
int sz = pos2.getBlockZ() + 1;
int ez = sz + pathsize - 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
*/
@ -201,12 +206,12 @@ public class Unlink extends SubCommand {
Location pos2 = PlotHelper.getPlotTopLocAbs(w, id);
int sx = pos2.getBlockX() + 1;
int ex = sx + pathsize - 1;
int ex = (sx + this.pathsize) - 1;
int sz = pos2.getBlockZ() + 1;
int ez = sz + pathsize - 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 });
}
}

View File

@ -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() {

View File

@ -104,7 +104,7 @@ public class DBFunc {
// 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("(?)");
@ -138,8 +138,8 @@ public class DBFunc {
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++;
}
@ -163,7 +163,7 @@ public class DBFunc {
}
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("(?, ?, ?, ?)");
@ -173,10 +173,10 @@ public class DBFunc {
stmt = connection.prepareStatement(statement.toString());
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();

View File

@ -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");
@ -45,7 +45,8 @@ public class PlotMeConverter {
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())) {
@ -94,13 +97,12 @@ 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;
@ -120,34 +122,28 @@ public class PlotMeConverter {
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(",")) {
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;
@ -158,7 +154,8 @@ public class PlotMeConverter {
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 });
// 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);
}

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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() {

View File

@ -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.
}
}

View File

@ -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;
}
}

View File

@ -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,30 +34,28 @@ 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);
this.str_flags.add(flag.getName());
this.flags.add(flag);
}
}
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);
}
}
}
catch (Exception e) {
} catch (Exception e) {
requester.setOp(op);
}
finally {
} finally {
requester.setOp(op);
}
}
@ -72,17 +65,15 @@ public class WorldGuardListener implements Listener {
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);
}
}
}
catch (Exception e) {
} catch (Exception e) {
requester.setOp(op);
}
finally {
} finally {
requester.setOp(op);
}
}
@ -94,9 +85,10 @@ public class WorldGuardListener implements Listener {
World world = event.getWorld();
RegionManager manager = PlotMain.worldGuard.getRegionManager(world);
for (PlotId plot : plots) {
if (!plot.equals(main))
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();