Documenting some methods

This commit is contained in:
boy0001 2014-10-13 17:44:05 +11:00
parent 4403edf7ca
commit 2b22ebf3d8
3 changed files with 87 additions and 9 deletions

View File

@ -106,6 +106,7 @@ public class PlayerFunctions {
}
/**
* Returns the plot at a location (mega plots are not considered, all plots are treated as small plots)
* @param loc
* @return
*/
@ -119,6 +120,11 @@ public class PlayerFunctions {
return manager.getPlotIdAbs(plotworld, loc);
}
/**
* Returns the plot id at a location (mega plots are considered)
* @param loc
* @return
*/
public static PlotId getPlot(Location loc) {
String world = loc.getWorld().getName();
PlotManager manager = PlotMain.getPlotManager(world);
@ -130,6 +136,7 @@ public class PlayerFunctions {
}
/**
* Sets the weather for a player, given the current plot settings
* @param player
* @param plot
*/
@ -138,6 +145,7 @@ public class PlayerFunctions {
}
/**
* Sets the time for a player, given the current plot settings
* @param player
* @param plot
*/
@ -146,6 +154,7 @@ public class PlayerFunctions {
}
/**
* Returns the plot a player is currently in.
* @param player
* @return
*/
@ -169,23 +178,21 @@ public class PlayerFunctions {
}
/**
* Updates a given plot with another instance
* @deprecated
* @param id
* @param plot
*/
@Deprecated
public static void set(Integer[] id, Plot plot) {
public static void set(Plot plot) {
PlotMain.updatePlot(plot);
}
/**
* Get the plots for a player
* @param plr
* @return
*/
// public static Set<Plot> getPlayerPlots(Player plr) {
// return PlotMain.getPlots(plr);
// }
//
public static Set<Plot> getPlayerPlots(World world, Player plr) {
Set<Plot> p = PlotMain.getPlots(world, plr);
if (p == null) {
@ -195,18 +202,16 @@ public class PlayerFunctions {
}
/**
* Get the number of plots for a player
* @param plr
* @return
*/
// public static int getPlayerPlotCount(Player plr) {
// return getPlayerPlots(plr).size();
// }
//
public static int getPlayerPlotCount(World world, Player plr) {
return getPlayerPlots(world, plr).size();
}
/**
* Get the maximum number of plots a player is allowed
* @param p
* @return
*/

View File

@ -53,6 +53,13 @@ public class PlotHelper {
return id;
}
/**
* Merges all plots in the arraylist (with cost)
* @param plr
* @param world
* @param plotIds
* @return
*/
public static boolean mergePlots(Player plr, World world, ArrayList<PlotId> plotIds) {
PlotWorld plotworld = PlotMain.getWorldSettings(world);
if (PlotMain.useEconomy && plotworld.USE_ECONOMY) {
@ -170,6 +177,9 @@ public class PlotHelper {
}
}
/*
* Random number gen section
*/
public static final long nextLong() {
long a = state;
state = xorShift64(a);
@ -198,6 +208,9 @@ public class PlotHelper {
Location loc = manager.getSignLoc(plr, plotworld, p);
loc.getBlock().setType(Material.AIR);
}
/*
* End of random number gen section
*/
@SuppressWarnings("deprecation")
public static void setSign(Player plr, Plot p) {
@ -217,6 +230,7 @@ public class PlotHelper {
sign.update(true);
}
public static String getPlayerName(UUID uuid) {
if (uuid == null) {
return "unknown";
@ -235,6 +249,11 @@ public class PlotHelper {
return string;
}
/**
* Set a block quickly, attempts to use NMS if possible
* @param block
* @param plotblock
*/
public static void setBlock(Block block, PlotBlock plotblock) {
if (canSetFast) {
@ -263,6 +282,12 @@ public class PlotHelper {
}
}
/**
* Adjusts a plot wall
* @param player
* @param plot
* @param block
*/
public static void adjustWall(Player player, Plot plot, PlotBlock block) {
World world = player.getWorld();
PlotManager manager = PlotMain.getPlotManager(world);
@ -783,22 +808,49 @@ public class PlotHelper {
}
}
/**
* Gets the top plot location of a plot (all plots are treated as small plots)
* - To get the top loc of a mega plot use getPlotTopLoc(...)
* @param world
* @param id
* @return
*/
public static Location getPlotTopLocAbs(World world, PlotId id) {
PlotWorld plotworld = PlotMain.getWorldSettings(world);
PlotManager manager = PlotMain.getPlotManager(world);
return manager.getPlotTopLocAbs(plotworld, id);
}
/**
* Gets the bottom plot location of a plot (all plots are treated as small plots)
* - To get the top loc of a mega plot use getPlotBottomLoc(...)
* @param world
* @param id
* @return
*/
public static Location getPlotBottomLocAbs(World world, PlotId id) {
PlotWorld plotworld = PlotMain.getWorldSettings(world);
PlotManager manager = PlotMain.getPlotManager(world);
return manager.getPlotBottomLocAbs(plotworld, id);
}
/**
* Obtains the width of a plot (x width)
* @param world
* @param id
* @return
*/
public static int getPlotWidth(World world, PlotId id) {
return getPlotTopLoc(world, id).getBlockX() - getPlotBottomLoc(world, id).getBlockX();
}
/**
* Gets the top loc of a plot (if mega, returns top loc of that mega plot)
* - If you would like each plot treated as a small plot use getPlotTopLocAbs(...)
* @param world
* @param id
* @return
*/
public static Location getPlotTopLoc(World world, PlotId id) {
Plot plot = PlotMain.getPlots(world).get(id);
if (plot != null) {
@ -809,6 +861,13 @@ public class PlotHelper {
return manager.getPlotTopLocAbs(plotworld, id);
}
/**
* Gets the bottom loc of a plot (if mega, returns bottom loc of that mega plot)
* - If you would like each plot treated as a small plot use getPlotBottomLocAbs(...)
* @param world
* @param id
* @return
*/
public static Location getPlotBottomLoc(World world, PlotId id) {
Plot plot = PlotMain.getPlots(world).get(id);
if (plot != null) {
@ -819,6 +878,12 @@ public class PlotHelper {
return manager.getPlotBottomLocAbs(plotworld, id);
}
/**
* Fetches the plot from the main class
* @param world
* @param id
* @return
*/
public static Plot getPlot(World world, PlotId id) {
if (id == null) {
return null;
@ -829,6 +894,11 @@ public class PlotHelper {
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), world.getName());
}
/**
* Returns the plot at a given location
* @param loc
* @return
*/
public static Plot getCurrentPlot(Location loc) {
PlotId id = PlayerFunctions.getPlot(loc);
if (id == null) {

View File

@ -73,6 +73,9 @@ public class PlotSettings {
return this.merged[direction];
}
/**
* Returns true if the plot is merged (i.e. if it's a mega plot)
*/
public boolean isMerged() {
return (this.merged[0] || this.merged[1] || this.merged[2] || this.merged[3]);
}