mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Documenting some methods
This commit is contained in:
parent
4403edf7ca
commit
2b22ebf3d8
@ -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
|
* @param loc
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -119,6 +120,11 @@ public class PlayerFunctions {
|
|||||||
return manager.getPlotIdAbs(plotworld, loc);
|
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) {
|
public static PlotId getPlot(Location loc) {
|
||||||
String world = loc.getWorld().getName();
|
String world = loc.getWorld().getName();
|
||||||
PlotManager manager = PlotMain.getPlotManager(world);
|
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 player
|
||||||
* @param plot
|
* @param plot
|
||||||
*/
|
*/
|
||||||
@ -138,6 +145,7 @@ public class PlayerFunctions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Sets the time for a player, given the current plot settings
|
||||||
* @param player
|
* @param player
|
||||||
* @param plot
|
* @param plot
|
||||||
*/
|
*/
|
||||||
@ -146,6 +154,7 @@ public class PlayerFunctions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns the plot a player is currently in.
|
||||||
* @param player
|
* @param player
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -169,23 +178,21 @@ public class PlayerFunctions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Updates a given plot with another instance
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @param id
|
* @param id
|
||||||
* @param plot
|
* @param plot
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void set(Integer[] id, Plot plot) {
|
public static void set(Plot plot) {
|
||||||
PlotMain.updatePlot(plot);
|
PlotMain.updatePlot(plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the plots for a player
|
||||||
* @param plr
|
* @param plr
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// public static Set<Plot> getPlayerPlots(Player plr) {
|
|
||||||
// return PlotMain.getPlots(plr);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
public static Set<Plot> getPlayerPlots(World world, Player plr) {
|
public static Set<Plot> getPlayerPlots(World world, Player plr) {
|
||||||
Set<Plot> p = PlotMain.getPlots(world, plr);
|
Set<Plot> p = PlotMain.getPlots(world, plr);
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
@ -195,18 +202,16 @@ public class PlayerFunctions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the number of plots for a player
|
||||||
* @param plr
|
* @param plr
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// public static int getPlayerPlotCount(Player plr) {
|
|
||||||
// return getPlayerPlots(plr).size();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
public static int getPlayerPlotCount(World world, Player plr) {
|
public static int getPlayerPlotCount(World world, Player plr) {
|
||||||
return getPlayerPlots(world, plr).size();
|
return getPlayerPlots(world, plr).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the maximum number of plots a player is allowed
|
||||||
* @param p
|
* @param p
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -53,6 +53,13 @@ public class PlotHelper {
|
|||||||
return id;
|
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) {
|
public static boolean mergePlots(Player plr, World world, ArrayList<PlotId> plotIds) {
|
||||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
if (PlotMain.useEconomy && plotworld.USE_ECONOMY) {
|
if (PlotMain.useEconomy && plotworld.USE_ECONOMY) {
|
||||||
@ -170,6 +177,9 @@ public class PlotHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Random number gen section
|
||||||
|
*/
|
||||||
public static final long nextLong() {
|
public static final long nextLong() {
|
||||||
long a = state;
|
long a = state;
|
||||||
state = xorShift64(a);
|
state = xorShift64(a);
|
||||||
@ -198,6 +208,9 @@ public class PlotHelper {
|
|||||||
Location loc = manager.getSignLoc(plr, plotworld, p);
|
Location loc = manager.getSignLoc(plr, plotworld, p);
|
||||||
loc.getBlock().setType(Material.AIR);
|
loc.getBlock().setType(Material.AIR);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* End of random number gen section
|
||||||
|
*/
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static void setSign(Player plr, Plot p) {
|
public static void setSign(Player plr, Plot p) {
|
||||||
@ -217,6 +230,7 @@ public class PlotHelper {
|
|||||||
sign.update(true);
|
sign.update(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getPlayerName(UUID uuid) {
|
public static String getPlayerName(UUID uuid) {
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
@ -235,6 +249,11 @@ public class PlotHelper {
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a block quickly, attempts to use NMS if possible
|
||||||
|
* @param block
|
||||||
|
* @param plotblock
|
||||||
|
*/
|
||||||
public static void setBlock(Block block, PlotBlock plotblock) {
|
public static void setBlock(Block block, PlotBlock plotblock) {
|
||||||
|
|
||||||
if (canSetFast) {
|
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) {
|
public static void adjustWall(Player player, Plot plot, PlotBlock block) {
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
PlotManager manager = PlotMain.getPlotManager(world);
|
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) {
|
public static Location getPlotTopLocAbs(World world, PlotId id) {
|
||||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
PlotManager manager = PlotMain.getPlotManager(world);
|
PlotManager manager = PlotMain.getPlotManager(world);
|
||||||
return manager.getPlotTopLocAbs(plotworld, id);
|
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) {
|
public static Location getPlotBottomLocAbs(World world, PlotId id) {
|
||||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
PlotManager manager = PlotMain.getPlotManager(world);
|
PlotManager manager = PlotMain.getPlotManager(world);
|
||||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
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) {
|
public static int getPlotWidth(World world, PlotId id) {
|
||||||
return getPlotTopLoc(world, id).getBlockX() - getPlotBottomLoc(world, id).getBlockX();
|
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) {
|
public static Location getPlotTopLoc(World world, PlotId id) {
|
||||||
Plot plot = PlotMain.getPlots(world).get(id);
|
Plot plot = PlotMain.getPlots(world).get(id);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
@ -809,6 +861,13 @@ public class PlotHelper {
|
|||||||
return manager.getPlotTopLocAbs(plotworld, id);
|
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) {
|
public static Location getPlotBottomLoc(World world, PlotId id) {
|
||||||
Plot plot = PlotMain.getPlots(world).get(id);
|
Plot plot = PlotMain.getPlots(world).get(id);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
@ -819,6 +878,12 @@ public class PlotHelper {
|
|||||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
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) {
|
public static Plot getPlot(World world, PlotId id) {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return 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());
|
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) {
|
public static Plot getCurrentPlot(Location loc) {
|
||||||
PlotId id = PlayerFunctions.getPlot(loc);
|
PlotId id = PlayerFunctions.getPlot(loc);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
|
@ -73,6 +73,9 @@ public class PlotSettings {
|
|||||||
return this.merged[direction];
|
return this.merged[direction];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the plot is merged (i.e. if it's a mega plot)
|
||||||
|
*/
|
||||||
public boolean isMerged() {
|
public boolean isMerged() {
|
||||||
return (this.merged[0] || this.merged[1] || this.merged[2] || this.merged[3]);
|
return (this.merged[0] || this.merged[1] || this.merged[2] || this.merged[3]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user