mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java
This commit is contained in:
commit
1f6ad47a79
@ -1,4 +1,3 @@
|
||||
|
||||
package com.intellectualcrafters.plot.api;
|
||||
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
@ -43,32 +42,40 @@ import java.util.UUID;
|
||||
* @see com.intellectualcrafters.plot.object.Location
|
||||
* @see PlotArea
|
||||
* @see PS
|
||||
* @version 3.3.1
|
||||
>>>>>>> origin/master
|
||||
*/
|
||||
public class PlotAPI {
|
||||
|
||||
/**
|
||||
* Permission that allows for admin access, this permission node will allow the player to use any part of the
|
||||
* plugin, without limitations.
|
||||
* Permission that allows for admin access, this permission node will allow
|
||||
* the player to use any part of the plugin, without limitations.
|
||||
* @deprecated Use C.PERMISSION_ADMIN instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String ADMIN_PERMISSION = C.PERMISSION_ADMIN.s();
|
||||
|
||||
/**
|
||||
* @deprecated Use new PlotAPI() instead
|
||||
* Deprecated, does nothing.
|
||||
* @param plugin not needed
|
||||
* @deprecated Not needed
|
||||
*/
|
||||
@Deprecated
|
||||
public PlotAPI(JavaPlugin plugin) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PS
|
||||
*
|
||||
* @deprecated Use this class if you just want to do a few simple things.<br>
|
||||
* - It will remain stable for future versions of the plugin
|
||||
* - The PlotPlayer and Plot class should be considered relatively safe
|
||||
* - For more advanced/intensive tasks you should consider using other classes
|
||||
* Default Constructor that does nothing.
|
||||
*
|
||||
* @deprecated Use this class if you just want to do a few simple things
|
||||
* <ul>
|
||||
* <li>It will remain stable for future versions
|
||||
* of the plugin</li>
|
||||
* <li>The PlotPlayer and Plot class should be considered
|
||||
* relatively safe</li>
|
||||
* <li>For more advanced/intensive tasks you should consider
|
||||
* using other classes</li>
|
||||
* </ul>
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
@ -108,6 +115,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the PlotSquared configurations file.
|
||||
* @return main configuration
|
||||
*
|
||||
* @see PS#config
|
||||
@ -117,6 +125,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotSquared storage file.
|
||||
* @return storage configuration
|
||||
*
|
||||
* @see PS#storage
|
||||
@ -126,8 +135,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the main class for this plugin <br> - Contains a lot of fields and methods - not very well organized <br>
|
||||
* Only use this if you really need it
|
||||
* Get the main class for this plugin. Only use this if you really need it.
|
||||
*
|
||||
* @return PlotSquared PlotSquared Main Class
|
||||
*
|
||||
@ -138,12 +146,14 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* ChunkManager class contains several useful methods<br>
|
||||
* - Chunk deletion<br>
|
||||
* - Moving or copying regions<br>
|
||||
* - plot swapping<br>
|
||||
* - Entity tracking<br>
|
||||
* - region regeneration<br>
|
||||
* ChunkManager class contains several useful methods.
|
||||
* <ul>
|
||||
* <li>Chunk deletion</li>
|
||||
* <li>Moving or copying regions</li>
|
||||
* <li>Plot swapping</li>
|
||||
* <li>Entity Tracking</li>
|
||||
* <li>Region Regeneration</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return ChunkManager
|
||||
*
|
||||
@ -162,7 +172,8 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* UUIDWrapper class has basic methods for getting UUIDS (it's recommended to use the UUIDHandler class instead)
|
||||
* UUIDWrapper class has basic methods for getting UUIDS. It's recommended
|
||||
* to use the UUIDHandler class instead.
|
||||
*
|
||||
* @return UUIDWrapper
|
||||
*
|
||||
@ -178,7 +189,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @return FlagManager
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.flag.FlagManager
|
||||
* @deprecated Use {@link FlagManager} directly
|
||||
*/
|
||||
@Deprecated
|
||||
public FlagManager getFlagManager() {
|
||||
@ -187,11 +198,9 @@ public class PlotAPI {
|
||||
|
||||
/**
|
||||
* Do not use this. Instead use MainUtil.[method] in your code.
|
||||
* - Basic plot management stuff
|
||||
*
|
||||
* @return MainUtil
|
||||
*
|
||||
* @see MainUtil
|
||||
* @deprecated Use {@link MainUtil} directly
|
||||
*/
|
||||
@Deprecated
|
||||
public MainUtil getMainUtil() {
|
||||
@ -200,11 +209,11 @@ public class PlotAPI {
|
||||
|
||||
/**
|
||||
* Do not use this. Instead use C.PERMISSION_[method] in your code.
|
||||
* - Basic permission management stuff
|
||||
*
|
||||
* @return Array of strings
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.util.Permissions
|
||||
* @deprecated Use {@link C} to list all the permissions
|
||||
*/
|
||||
@Deprecated
|
||||
public String[] getPermissions() {
|
||||
@ -218,7 +227,8 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* SchematicHandler class contains methods related to pasting, reading and writing schematics
|
||||
* SchematicHandler class contains methods related to pasting, reading
|
||||
* and writing schematics.
|
||||
*
|
||||
* @return SchematicHandler
|
||||
*
|
||||
@ -232,8 +242,7 @@ public class PlotAPI {
|
||||
* Use C.[caption] instead
|
||||
*
|
||||
* @return C
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.config.C
|
||||
* @deprecated Use {@link C}
|
||||
*/
|
||||
@Deprecated
|
||||
public C[] getCaptions() {
|
||||
@ -241,7 +250,8 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plot manager for a world. - Most of these methods can be accessed through the MainUtil
|
||||
* Get the plot manager for a world. Most of these methods can be accessed
|
||||
* through the MainUtil.
|
||||
*
|
||||
* @param world Which manager to get
|
||||
*
|
||||
@ -258,6 +268,11 @@ public class PlotAPI {
|
||||
return getPlotManager(world.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of PlotAreas in the world.
|
||||
* @param world The world to check for plot areas
|
||||
* @return A set of PlotAreas
|
||||
*/
|
||||
public Set<PlotArea> getPlotAreas(World world) {
|
||||
if (world == null) {
|
||||
return new HashSet<>();
|
||||
@ -266,10 +281,10 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plot manager for a world. - Contains useful low level methods for plot merging, clearing, and
|
||||
* tessellation
|
||||
* Get the plot manager for a world. Contains useful low level methods for
|
||||
* plot merging, clearing, and tessellation.
|
||||
*
|
||||
* @param world
|
||||
* @param world The world
|
||||
*
|
||||
* @return PlotManager
|
||||
*
|
||||
@ -291,12 +306,13 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings for a world (settings bundled in PlotArea class) - You will need to downcast for the specific
|
||||
* settings a Generator has. e.g. DefaultPlotWorld class implements PlotArea
|
||||
* Get the settings for a world (settings bundled in PlotArea class). You
|
||||
* will need to downcast for the specific settings a Generator has. e.g.
|
||||
* DefaultPlotWorld class implements PlotArea
|
||||
*
|
||||
* @param world (to get settings of)
|
||||
* @param world The World
|
||||
*
|
||||
* @return PlotArea class for that world ! will return null if not a plot world world
|
||||
* @return The {@link PlotArea} for the world or null if not in plotworld
|
||||
*
|
||||
* @see #getPlotAreas(World)
|
||||
* @see com.intellectualcrafters.plot.object.PlotArea
|
||||
@ -310,11 +326,11 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings for a world (settings bundled in PlotArea class)
|
||||
* Get the settings for a world.
|
||||
*
|
||||
* @param world (to get settings of)
|
||||
* @param world The world
|
||||
*
|
||||
* @return PlotArea class for that world ! will return null if not a plot world world
|
||||
* @return The {@link PlotArea} for the world or null if not in plotworld
|
||||
*
|
||||
* @see PS#getPlotArea(String, String)
|
||||
* @see com.intellectualcrafters.plot.object.PlotArea
|
||||
@ -340,17 +356,16 @@ public class PlotAPI {
|
||||
* Send a message to a player.
|
||||
*
|
||||
* @param player Player that will receive the message
|
||||
* @param c (Caption)
|
||||
* @param caption Caption
|
||||
*
|
||||
* @see MainUtil#sendMessage(PlotPlayer, C, String...)
|
||||
* com.intellectualcrafters.plot.config.C, String...)
|
||||
*/
|
||||
public void sendMessage(Player player, C c) {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), c);
|
||||
public void sendMessage(Player player, C caption) {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), caption);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to a player. - Supports color codes
|
||||
* Send a message to a player. Supports color codes.
|
||||
*
|
||||
* @param player Player that will receive the message
|
||||
* @param string The message
|
||||
@ -362,30 +377,30 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the console. - Supports color codes
|
||||
* Send a message to the console. Supports color codes.
|
||||
*
|
||||
* @param msg Message that should be sent to the console
|
||||
* @param message Message that should be sent to the console
|
||||
*
|
||||
* @see MainUtil#sendConsoleMessage(C, String...)
|
||||
*/
|
||||
public void sendConsoleMessage(String msg) {
|
||||
PS.log(msg);
|
||||
public void sendConsoleMessage(String message) {
|
||||
PS.log(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the console
|
||||
* Send a message to the console.
|
||||
*
|
||||
* @param c (Caption)
|
||||
* @param caption The caption
|
||||
*
|
||||
* @see #sendConsoleMessage(String)
|
||||
* @see com.intellectualcrafters.plot.config.C
|
||||
*/
|
||||
public void sendConsoleMessage(C c) {
|
||||
sendConsoleMessage(c.s());
|
||||
public void sendConsoleMessage(C caption) {
|
||||
sendConsoleMessage(caption.s());
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a flag for use in plots
|
||||
* Register a flag for use in plots.
|
||||
*
|
||||
* @param flag Flag that should be registered
|
||||
*
|
||||
@ -397,7 +412,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* get all the currently registered flags
|
||||
* get all the currently registered flags.
|
||||
*
|
||||
* @return array of Flag[]
|
||||
*
|
||||
@ -412,8 +427,8 @@ public class PlotAPI {
|
||||
* Get a plot based on the ID.
|
||||
*
|
||||
* @param world World in which the plot is located
|
||||
* @param x Plot Location X Co-ord
|
||||
* @param z Plot Location Z Co-ord
|
||||
* @param x The PlotID x coordinate
|
||||
* @param z The PlotID y coordinate
|
||||
*
|
||||
* @return plot, null if ID is wrong
|
||||
*
|
||||
@ -434,17 +449,17 @@ public class PlotAPI {
|
||||
/**
|
||||
* Get a plot based on the location.
|
||||
*
|
||||
* @param l The location that you want to to retrieve the plot from
|
||||
* @param location The location to retrieve the plot from
|
||||
*
|
||||
* @return plot if found, otherwise it creates a temporary plot-
|
||||
* @return plot if found, otherwise it creates a temporary plot
|
||||
*
|
||||
* @see Plot
|
||||
*/
|
||||
public Plot getPlot(Location l) {
|
||||
if (l == null) {
|
||||
public Plot getPlot(Location location) {
|
||||
if (location == null) {
|
||||
return null;
|
||||
}
|
||||
return BukkitUtil.getLocation(l).getPlot();
|
||||
return BukkitUtil.getLocation(location).getPlot();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -465,7 +480,7 @@ public class PlotAPI {
|
||||
* Check whether or not a player has a plot.
|
||||
*
|
||||
* @param player Player that you want to check for
|
||||
*
|
||||
* @param world The world to check
|
||||
* @return true if player has a plot, false if not.
|
||||
*
|
||||
* @see #getPlots(World, Player, boolean)
|
||||
@ -478,9 +493,10 @@ public class PlotAPI {
|
||||
/**
|
||||
* Get all plots for the player.
|
||||
*
|
||||
* @param world
|
||||
* @param world The world to retrieve plots from
|
||||
* @param player The player to search for
|
||||
* @param justOwner should we just search for owner? Or with rights?
|
||||
* @return An array of plots for the player
|
||||
*/
|
||||
@Deprecated
|
||||
public Plot[] getPlots(World world, Player player, boolean justOwner) {
|
||||
@ -530,9 +546,9 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if plot world
|
||||
* Get if plotworld.
|
||||
*
|
||||
* @param world (to check if plot world)
|
||||
* @param world The world to check
|
||||
*
|
||||
* @return boolean (if plot world or not)
|
||||
*
|
||||
@ -544,9 +560,9 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plot locations
|
||||
* Get plot locations.
|
||||
*
|
||||
* @param p Plot that you want to get the locations for
|
||||
* @param plot Plot to get the locations for
|
||||
*
|
||||
* @return [0] = bottomLc, [1] = topLoc, [2] = home
|
||||
*
|
||||
@ -555,27 +571,30 @@ public class PlotAPI {
|
||||
* @see Plot
|
||||
*/
|
||||
@Deprecated
|
||||
public Location[] getLocations(Plot p) {
|
||||
return new Location[]{BukkitUtil.getLocation(p.getBottom()), BukkitUtil.getLocation(p.getTop()), BukkitUtil.getLocation(p.getHome())};
|
||||
public Location[] getLocations(Plot plot) {
|
||||
Location bukkitBottom = BukkitUtil.getLocation(plot.getCorners()[0]);
|
||||
Location bukkitTop = BukkitUtil.getLocation(plot.getCorners()[1]);
|
||||
Location bukkitHome = BukkitUtil.getLocation(plot.getHome());
|
||||
return new Location[]{bukkitBottom, bukkitTop, bukkitHome};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get home location
|
||||
* Get home location.
|
||||
*
|
||||
* @param p Plot that you want to get the location for
|
||||
* @param plot Plot that you want to get the location for
|
||||
*
|
||||
* @return plot bottom location
|
||||
*
|
||||
* @see Plot
|
||||
*/
|
||||
public Location getHomeLocation(Plot p) {
|
||||
return BukkitUtil.getLocation(p.getHome());
|
||||
public Location getHomeLocation(Plot plot) {
|
||||
return BukkitUtil.getLocation(plot.getHome());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bottom Location (min, min, min)
|
||||
* Get Bottom Location (min, min, min).
|
||||
*
|
||||
* @param p Plot that you want to get the location for
|
||||
* @param plot Plot that you want to get the location for
|
||||
*
|
||||
* @return plot bottom location
|
||||
*
|
||||
@ -584,14 +603,14 @@ public class PlotAPI {
|
||||
* @see Plot
|
||||
*/
|
||||
@Deprecated
|
||||
public Location getBottomLocation(Plot p) {
|
||||
return BukkitUtil.getLocation(p.getBottom());
|
||||
public Location getBottomLocation(Plot plot) {
|
||||
return BukkitUtil.getLocation(plot.getBottom());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Top Location (max, max, max)
|
||||
* Get Top Location (max, max, max).
|
||||
*
|
||||
* @param p Plot that you want to get the location for
|
||||
* @param plot Plot that you want to get the location for
|
||||
*
|
||||
* @return plot top location
|
||||
*
|
||||
@ -600,12 +619,12 @@ public class PlotAPI {
|
||||
* @see Plot
|
||||
*/
|
||||
@Deprecated
|
||||
public Location getTopLocation(Plot p) {
|
||||
return BukkitUtil.getLocation(p.getTop());
|
||||
public Location getTopLocation(Plot plot) {
|
||||
return BukkitUtil.getLocation(plot.getTop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether or not a player is in a plot
|
||||
* Check whether or not a player is in a plot.
|
||||
*
|
||||
* @param player who we're checking for
|
||||
*
|
||||
@ -617,7 +636,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a subcommand
|
||||
* Register a subcommand.
|
||||
* @deprecated Command registration is done on object creation
|
||||
* @param c SubCommand, that we want to register
|
||||
* @see com.intellectualcrafters.plot.commands.SubCommand
|
||||
@ -628,7 +647,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotSquared class
|
||||
* Get the PlotSquared class.
|
||||
*
|
||||
* @return PlotSquared Class
|
||||
*
|
||||
@ -639,7 +658,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player plot count
|
||||
* Get the player plot count.
|
||||
*
|
||||
* @param world Specify the world we want to select the plots from
|
||||
* @param player Player, for whom we're getting the plot count
|
||||
@ -655,7 +674,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a collection containing the players plots
|
||||
* Get a collection containing the players plots.
|
||||
*
|
||||
* @param world Specify the world we want to select the plots from
|
||||
* @param player Player, for whom we're getting the plots
|
||||
@ -674,9 +693,9 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the numbers of plots, which the player is able to build in
|
||||
* Get the numbers of plots, which the player is able to build in.
|
||||
*
|
||||
* @param player Player, for whom we're getting the plots (trusted, member and owner)
|
||||
* @param player Player, for whom we're getting the plots
|
||||
*
|
||||
* @return the number of allowed plots
|
||||
*
|
||||
@ -687,50 +706,54 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotPlayer for a player<br>
|
||||
* - The PlotPlayer is usually cached and will provide useful functions relating to players
|
||||
* Get the PlotPlayer for a player. The PlotPlayer is usually cached and
|
||||
* will provide useful functions relating to players.
|
||||
*
|
||||
* @see PlotPlayer#wrap(Object)
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
* @param player The player to wrap
|
||||
* @return A PlotPlayer
|
||||
*/
|
||||
public PlotPlayer wrapPlayer(Player player) {
|
||||
return PlotPlayer.wrap(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotPlayer for a UUID (Please note that PlotSquared can be configured to provide different UUIDs than bukkit)
|
||||
* Get the PlotPlayer for a UUID.
|
||||
*
|
||||
* <p><i>Please note that PlotSquared can be configured to provide
|
||||
* different UUIDs than bukkit</i></p>
|
||||
*
|
||||
* @see PlotPlayer#wrap(Object)
|
||||
*
|
||||
* @param uuid
|
||||
* @return
|
||||
* @param uuid The uuid of the player to wrap
|
||||
* @return A PlotPlayer
|
||||
*/
|
||||
public PlotPlayer wrapPlayer(UUID uuid) {
|
||||
return PlotPlayer.wrap(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotPlayer for a username
|
||||
* Get the PlotPlayer for a username.
|
||||
*
|
||||
* @see PlotPlayer#wrap(Object)
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
* @param player The player to wrap
|
||||
* @return The PlotPlayer
|
||||
*/
|
||||
public PlotPlayer wrapPlayer(String player) {
|
||||
return PlotPlayer.wrap(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotPlayer for an offline player<br>
|
||||
* Note that this will work if the player is offline, however not all functionality will work
|
||||
* Get the PlotPlayer for an offline player.
|
||||
* <p>Note that this will work if the player is offline, however not all
|
||||
* functionality will work</p>
|
||||
*
|
||||
* @see PlotPlayer#wrap(Object)
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
* @param player The player to wrap
|
||||
* @return The PlotPlayer
|
||||
*/
|
||||
public PlotPlayer wrapPlayer(OfflinePlayer player) {
|
||||
return PlotPlayer.wrap(player);
|
||||
|
@ -123,7 +123,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
THIS = this;
|
||||
BukkitMain.THIS = this;
|
||||
new PS(this, "Bukkit");
|
||||
}
|
||||
|
||||
@ -131,12 +131,12 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
public void onDisable() {
|
||||
PS.get().disable();
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
THIS = null;
|
||||
BukkitMain.THIS = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
if (THIS != null) {
|
||||
if (BukkitMain.THIS != null) {
|
||||
try {
|
||||
message = C.color(message);
|
||||
if (!Settings.CONSOLE_COLOR) {
|
||||
@ -153,7 +153,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
if (THIS != null) {
|
||||
if (BukkitMain.THIS != null) {
|
||||
onDisable();
|
||||
}
|
||||
}
|
||||
@ -170,11 +170,11 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public void registerCommands() {
|
||||
BukkitCommand bcmd = new BukkitCommand();
|
||||
BukkitCommand bukkitCommand = new BukkitCommand();
|
||||
PluginCommand plotCommand = getCommand("plots");
|
||||
plotCommand.setExecutor(bcmd);
|
||||
plotCommand.setExecutor(bukkitCommand);
|
||||
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
|
||||
plotCommand.setTabCompleter(bcmd);
|
||||
plotCommand.setTabCompleter(bukkitCommand);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -224,10 +224,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
case LIGHTNING:
|
||||
case WITHER_SKULL:
|
||||
case UNKNOWN:
|
||||
case PLAYER: {
|
||||
// non moving / unremovable
|
||||
case PLAYER:
|
||||
// non moving / unmovable
|
||||
continue;
|
||||
}
|
||||
case THROWN_EXP_BOTTLE:
|
||||
case SPLASH_POTION:
|
||||
case SNOWBALL:
|
||||
@ -235,15 +234,13 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
case SPECTRAL_ARROW:
|
||||
case TIPPED_ARROW:
|
||||
case ENDER_PEARL:
|
||||
case ARROW: {
|
||||
case ARROW:
|
||||
// managed elsewhere | projectile
|
||||
continue;
|
||||
}
|
||||
case ARMOR_STAND:
|
||||
case ITEM_FRAME:
|
||||
case PAINTING: {
|
||||
case PAINTING:
|
||||
// TEMPORARILY CLASSIFY AS VEHICLE
|
||||
}
|
||||
case MINECART:
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND:
|
||||
@ -278,15 +275,13 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
case DRAGON_FIREBALL:
|
||||
case DROPPED_ITEM: {
|
||||
case DROPPED_ITEM:
|
||||
// dropped item
|
||||
continue;
|
||||
}
|
||||
case PRIMED_TNT:
|
||||
case FALLING_BLOCK: {
|
||||
case FALLING_BLOCK:
|
||||
// managed elsewhere
|
||||
continue;
|
||||
}
|
||||
case BAT:
|
||||
case BLAZE:
|
||||
case CAVE_SPIDER:
|
||||
@ -320,7 +315,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
case WOLF:
|
||||
case ZOMBIE:
|
||||
case SHULKER:
|
||||
default: {
|
||||
default:
|
||||
if (!Settings.KILL_ROAD_MOBS) {
|
||||
continue;
|
||||
}
|
||||
@ -334,7 +329,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -383,7 +377,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
@Override
|
||||
public boolean initWorldEdit() {
|
||||
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
||||
BukkitMain.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
getServer().getPluginManager().registerEvents(new WEListener(), this);
|
||||
return true;
|
||||
}
|
||||
|
@ -107,9 +107,9 @@ public class DebugUUID extends SubCommand {
|
||||
worlds.add("world");
|
||||
HashSet<UUID> uuids = new HashSet<>();
|
||||
HashSet<String> names = new HashSet<>();
|
||||
for (String worldname : worlds) {
|
||||
File playerdataFolder = new File(worldname + File.separator + "playerdata");
|
||||
String[] dat = playerdataFolder.list(new FilenameFilter() {
|
||||
for (String worldName : worlds) {
|
||||
File playerDataFolder = new File(worldName + File.separator + "playerdata");
|
||||
String[] dat = playerDataFolder.list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File f, String s) {
|
||||
return s.endsWith(".dat");
|
||||
@ -126,7 +126,7 @@ public class DebugUUID extends SubCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
File playersFolder = new File(worldname + File.separator + "players");
|
||||
File playersFolder = new File(worldName + File.separator + "players");
|
||||
dat = playersFolder.list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File f, String s) {
|
||||
@ -286,7 +286,7 @@ public class DebugUUID extends SubCommand {
|
||||
try {
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
} catch (IOException e) {
|
||||
MainUtil.sendMessage(player, "Could not save configuration. It will need to be manuall set!");
|
||||
MainUtil.sendMessage(player, "Could not save configuration. It will need to be manual set!");
|
||||
}
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Populating tables");
|
||||
|
@ -55,16 +55,16 @@ abstract class APlotMeConnector {
|
||||
public Location getPlotTopLocAbs(int path, int plot, PlotId plotid) {
|
||||
int px = plotid.x;
|
||||
int pz = plotid.y;
|
||||
int x = (px * (path + plot)) - (int) Math.floor(path / 2) - 1;
|
||||
int z = (pz * (path + plot)) - (int) Math.floor(path / 2) - 1;
|
||||
int x = px * (path + plot) - (int) Math.floor(path / 2) - 1;
|
||||
int z = pz * (path + plot) - (int) Math.floor(path / 2) - 1;
|
||||
return new Location(null, x, 256, z);
|
||||
}
|
||||
|
||||
public Location getPlotBottomLocAbs(int path, int plot, PlotId plotid) {
|
||||
int px = plotid.x;
|
||||
int pz = plotid.y;
|
||||
int x = (px * (path + plot)) - plot - (int) Math.floor(path / 2) - 1;
|
||||
int z = (pz * (path + plot)) - plot - (int) Math.floor(path / 2) - 1;
|
||||
int x = px * (path + plot) - plot - (int) Math.floor(path / 2) - 1;
|
||||
int z = pz * (path + plot) - plot - (int) Math.floor(path / 2) - 1;
|
||||
return new Location(null, x, 1, z);
|
||||
}
|
||||
|
||||
|
@ -154,8 +154,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
for (Entry<String, HashMap<PlotId, boolean[]>> entry : merges.entrySet()) {
|
||||
String world = entry.getKey();
|
||||
for (Entry<PlotId, boolean[]> entry2 : entry.getValue().entrySet()) {
|
||||
HashMap<PlotId, Plot> newplots = plots.get(world);
|
||||
Plot plot = newplots.get(entry2.getKey());
|
||||
HashMap<PlotId, Plot> newPlots = plots.get(world);
|
||||
Plot plot = newPlots.get(entry2.getKey());
|
||||
if (plot != null) {
|
||||
plot.setMerged(entry2.getValue());
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ public class LikePlotMeConverter {
|
||||
}
|
||||
|
||||
public static String getWorld(String world) {
|
||||
for (World newworld : Bukkit.getWorlds()) {
|
||||
if (newworld.getName().equalsIgnoreCase(world)) {
|
||||
return newworld.getName();
|
||||
for (World newWorld : Bukkit.getWorlds()) {
|
||||
if (newWorld.getName().equalsIgnoreCase(world)) {
|
||||
return newWorld.getName();
|
||||
}
|
||||
}
|
||||
return world;
|
||||
@ -205,11 +205,11 @@ public class LikePlotMeConverter {
|
||||
PS.get().config.set("worlds." + world + ".road.height", pathheight);
|
||||
PS.get().config.set("worlds." + world + ".wall.height", pathheight);
|
||||
PS.get().config.set("worlds." + world + ".plot.height", pathheight);
|
||||
Integer plotsize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||
if (plotsize == 0) {
|
||||
plotsize = 32;
|
||||
Integer plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||
if (plotSize == 0) {
|
||||
plotSize = 32;
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".plot.size", plotsize);
|
||||
PS.get().config.set("worlds." + world + ".plot.size", plotSize);
|
||||
String wallblock = plotmeDgYml.getString("worlds." + plotMeWorldName + ".WallBlock", "44"); //
|
||||
PS.get().config.set("worlds." + world + ".wall.block", wallblock);
|
||||
String floor = plotmeDgYml.getString("worlds." + plotMeWorldName + ".PlotFloorBlock", "2"); //
|
||||
@ -310,10 +310,10 @@ public class LikePlotMeConverter {
|
||||
.isEnabled()) {
|
||||
mw = true;
|
||||
}
|
||||
for (String worldname : worlds) {
|
||||
World world = Bukkit.getWorld(getWorld(worldname));
|
||||
for (String worldName : worlds) {
|
||||
World world = Bukkit.getWorld(getWorld(worldName));
|
||||
if (world == null) {
|
||||
sendMessage("&cInvalid world in PlotMe configuration: " + worldname);
|
||||
sendMessage("&cInvalid world in PlotMe configuration: " + worldName);
|
||||
}
|
||||
String actualWorldName = world.getName();
|
||||
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
||||
@ -344,8 +344,8 @@ public class LikePlotMeConverter {
|
||||
// Load using Bukkit API
|
||||
// - User must set generator manually
|
||||
Bukkit.getServer().unloadWorld(world, true);
|
||||
World myworld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(new HybridGen())).createWorld();
|
||||
myworld.save();
|
||||
World myWorld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(new HybridGen())).createWorld();
|
||||
myWorld.save();
|
||||
}
|
||||
}
|
||||
} catch (CommandException e) {
|
||||
|
@ -111,8 +111,8 @@ public class ChunkListener implements Listener {
|
||||
if (!PS.get().hasPlotArea(name)) {
|
||||
continue;
|
||||
}
|
||||
boolean autosave = world.isAutoSave();
|
||||
if (autosave) {
|
||||
boolean autoSave = world.isAutoSave();
|
||||
if (autoSave) {
|
||||
world.setAutoSave(false);
|
||||
}
|
||||
HashMap<ChunkLoc, Integer> map = players.get(name);
|
||||
@ -142,7 +142,7 @@ public class ChunkListener implements Listener {
|
||||
time = 1;
|
||||
}
|
||||
}
|
||||
if (!Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE && autosave) {
|
||||
if (!Settings.CHUNK_PROCESSOR_TRIM_ON_SAVE && autoSave) {
|
||||
world.setAutoSave(true);
|
||||
}
|
||||
}
|
||||
|
@ -636,22 +636,22 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBigBoom(EntityExplodeEvent event) {
|
||||
Location loc = BukkitUtil.getLocation(event.getLocation());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
Location location = BukkitUtil.getLocation(event.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
if (!PS.get().hasPlotArea(loc.getWorld())) {
|
||||
if (!PS.get().hasPlotArea(location.getWorld())) {
|
||||
return;
|
||||
}
|
||||
Iterator<Block> iter = event.blockList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
iter.next();
|
||||
if (loc.getPlotArea() != null) {
|
||||
iter.remove();
|
||||
Iterator<Block> iterator = event.blockList().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next();
|
||||
if (location.getPlotArea() != null) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(loc);
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
if (plot != null) {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||
List<MetadataValue> meta = event.getEntity().getMetadata("plot");
|
||||
@ -672,12 +672,12 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
this.lastRadius = 0;
|
||||
}
|
||||
Iterator<Block> iter = event.blockList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Block b = iter.next();
|
||||
loc = BukkitUtil.getLocation(b.getLocation());
|
||||
if (!area.contains(loc.getX(), loc.getZ()) || !origin.equals(area.getOwnedPlot(loc))) {
|
||||
iter.remove();
|
||||
Iterator<Block> iterator = event.blockList().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Block block = iterator.next();
|
||||
location = BukkitUtil.getLocation(block.getLocation());
|
||||
if (!area.contains(location.getX(), location.getZ()) || !origin.equals(area.getOwnedPlot(location))) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -1267,8 +1267,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
Block block = event.getBlock();
|
||||
World world = block.getWorld();
|
||||
String worldname = world.getName();
|
||||
if (!PS.get().hasPlotArea(worldname)) {
|
||||
String worldName = world.getName();
|
||||
if (!PS.get().hasPlotArea(worldName)) {
|
||||
return;
|
||||
}
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
@ -1382,7 +1382,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
case LIGHTNING:
|
||||
case WITHER_SKULL:
|
||||
case UNKNOWN:
|
||||
// non moving / unremovable
|
||||
// non moving / unmovable
|
||||
return checkEntity(plot, "entity-cap");
|
||||
case ITEM_FRAME:
|
||||
case PAINTING:
|
||||
@ -1540,17 +1540,17 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
|
||||
} else if (event.getIgnitingBlock() != null) {
|
||||
Block igniter = event.getIgnitingBlock();
|
||||
Block ignitingBlock = event.getIgnitingBlock();
|
||||
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) {
|
||||
if (plot == null || !FlagManager.isPlotFlagTrue(plot, "block-ignition")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (BukkitUtil.getLocation(igniter.getLocation()).getPlot() == null) {
|
||||
if (BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot() == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!BukkitUtil.getLocation(igniter.getLocation()).getPlot().equals(plot)) {
|
||||
if (!BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot().equals(plot)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -1560,11 +1560,11 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (BukkitUtil.getLocation(igniter.getLocation()).getPlot() == null) {
|
||||
if (BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot() == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!BukkitUtil.getLocation(igniter.getLocation()).getPlot().equals(plot)) {
|
||||
if (!BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot().equals(plot)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -25,11 +25,11 @@ public class PlayerEvents183 implements Listener {
|
||||
}
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
Iterator<Block> iter = event.blockList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
loc = BukkitUtil.getLocation(iter.next().getLocation());
|
||||
Iterator<Block> iterator = event.blockList().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
loc = BukkitUtil.getLocation(iterator.next().getLocation());
|
||||
if (loc.getPlotArea() != null) {
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -38,11 +38,11 @@ public class PlayerEvents183 implements Listener {
|
||||
if (plot == null || !FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
Iterator<Block> iter = event.blockList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Block b = iter.next();
|
||||
Iterator<Block> iterator = event.blockList().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Block b = iterator.next();
|
||||
if (!plot.equals(area.getOwnedPlot(BukkitUtil.getLocation(b.getLocation())))) {
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,6 @@ import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
||||
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -26,6 +22,11 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlotPlusListener extends PlotListener implements Listener {
|
||||
|
||||
private static final HashMap<String, Interval> feedRunnable = new HashMap<>();
|
||||
@ -36,15 +37,15 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!healRunnable.isEmpty()) {
|
||||
for (Iterator<Entry<String, Interval>> iter = healRunnable.entrySet().iterator(); iter.hasNext(); ) {
|
||||
Entry<String, Interval> entry = iter.next();
|
||||
for (Iterator<Entry<String, Interval>> iterator = healRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
||||
Entry<String, Interval> entry = iterator.next();
|
||||
Interval value = entry.getValue();
|
||||
++value.count;
|
||||
if (value.count == value.interval) {
|
||||
value.count = 0;
|
||||
Player player = Bukkit.getPlayer(entry.getKey());
|
||||
if (player == null) {
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
double level = player.getHealth();
|
||||
@ -55,15 +56,15 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
if (!feedRunnable.isEmpty()) {
|
||||
for (Iterator<Entry<String, Interval>> iter = feedRunnable.entrySet().iterator(); iter.hasNext(); ) {
|
||||
Entry<String, Interval> entry = iter.next();
|
||||
for (Iterator<Entry<String, Interval>> iterator = feedRunnable.entrySet().iterator(); iterator.hasNext(); ) {
|
||||
Entry<String, Interval> entry = iterator.next();
|
||||
Interval value = entry.getValue();
|
||||
++value.count;
|
||||
if (value.count == value.interval) {
|
||||
value.count = 0;
|
||||
Player player = Bukkit.getPlayer(entry.getKey());
|
||||
if (player == null) {
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
int level = player.getFoodLevel();
|
||||
|
@ -56,7 +56,7 @@ public class EntityWrapper {
|
||||
private ArmorStandStats stand;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public EntityWrapper(org.bukkit.entity.Entity entity, short depth) {
|
||||
public EntityWrapper(Entity entity, short depth) {
|
||||
this.hash = entity.getEntityId();
|
||||
this.depth = depth;
|
||||
Location loc = entity.getLocation();
|
||||
@ -113,21 +113,24 @@ public class EntityWrapper {
|
||||
case THROWN_EXP_BOTTLE:
|
||||
case WEATHER:
|
||||
case WITHER_SKULL:
|
||||
case UNKNOWN: {
|
||||
case UNKNOWN:
|
||||
case TIPPED_ARROW:
|
||||
case SPECTRAL_ARROW:
|
||||
case SHULKER_BULLET:
|
||||
case DRAGON_FIREBALL:
|
||||
case LINGERING_POTION:
|
||||
case AREA_EFFECT_CLOUD:
|
||||
// Do this stuff later
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
PS.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
|
||||
return;
|
||||
}
|
||||
// MISC //
|
||||
case DROPPED_ITEM: {
|
||||
case DROPPED_ITEM:
|
||||
Item item = (Item) entity;
|
||||
this.stack = item.getItemStack();
|
||||
return;
|
||||
}
|
||||
case ITEM_FRAME: {
|
||||
case ITEM_FRAME:
|
||||
ItemFrame itemframe = (ItemFrame) entity;
|
||||
this.x = Math.floor(this.x);
|
||||
this.y = Math.floor(this.y);
|
||||
@ -135,8 +138,7 @@ public class EntityWrapper {
|
||||
this.dataByte = getOrdinal(Rotation.values(), itemframe.getRotation());
|
||||
this.stack = itemframe.getItem().clone();
|
||||
return;
|
||||
}
|
||||
case PAINTING: {
|
||||
case PAINTING:
|
||||
Painting painting = (Painting) entity;
|
||||
this.x = Math.floor(this.x);
|
||||
this.y = Math.floor(this.y);
|
||||
@ -144,23 +146,21 @@ public class EntityWrapper {
|
||||
Art a = painting.getArt();
|
||||
this.dataByte = getOrdinal(BlockFace.values(), painting.getFacing());
|
||||
int h = a.getBlockHeight();
|
||||
if ((h % 2) == 0) {
|
||||
if (h % 2 == 0) {
|
||||
this.y -= 1;
|
||||
}
|
||||
this.dataString = a.name();
|
||||
return;
|
||||
}
|
||||
// END MISC //
|
||||
// INVENTORY HOLDER //
|
||||
case MINECART_CHEST:
|
||||
case MINECART_HOPPER: {
|
||||
case MINECART_HOPPER:
|
||||
storeInventory((InventoryHolder) entity);
|
||||
return;
|
||||
}
|
||||
// START LIVING ENTITY //
|
||||
// START AGEABLE //
|
||||
// START TAMEABLE //
|
||||
case HORSE: {
|
||||
case HORSE:
|
||||
Horse horse = (Horse) entity;
|
||||
this.horse = new HorseStats();
|
||||
this.horse.jump = horse.getJumpStrength();
|
||||
@ -173,51 +173,44 @@ public class EntityWrapper {
|
||||
storeLiving((LivingEntity) entity);
|
||||
storeInventory((InventoryHolder) entity);
|
||||
return;
|
||||
}
|
||||
// END INVENTORY HOLDER //
|
||||
case WOLF:
|
||||
case OCELOT: {
|
||||
case OCELOT:
|
||||
storeTameable((Tameable) entity);
|
||||
storeAgeable((Ageable) entity);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
}
|
||||
// END AMEABLE //
|
||||
case SHEEP: {
|
||||
// END TAMEABLE //
|
||||
case SHEEP:
|
||||
Sheep sheep = (Sheep) entity;
|
||||
this.dataByte = (byte) (sheep.isSheared() ? 1 : 0);
|
||||
this.dataByte2 = sheep.getColor().getDyeData();
|
||||
storeAgeable((Ageable) entity);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
}
|
||||
case VILLAGER:
|
||||
case CHICKEN:
|
||||
case COW:
|
||||
case MUSHROOM_COW:
|
||||
case PIG: {
|
||||
case PIG:
|
||||
storeAgeable((Ageable) entity);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
}
|
||||
// END AGEABLE //
|
||||
case RABBIT: { // NEW
|
||||
case RABBIT: // NEW
|
||||
this.dataByte = getOrdinal(Type.values(), ((Rabbit) entity).getRabbitType());
|
||||
storeAgeable((Ageable) entity);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
}
|
||||
case GUARDIAN: { // NEW
|
||||
// END AGEABLE //
|
||||
case GUARDIAN: // NEW
|
||||
this.dataByte = (byte) (((Guardian) entity).isElder() ? 1 : 0);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
}
|
||||
case SKELETON: { // NEW
|
||||
case SKELETON: // NEW
|
||||
this.dataByte = (byte) ((Skeleton) entity).getSkeletonType().getId();
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
}
|
||||
case ARMOR_STAND: { // NEW
|
||||
case ARMOR_STAND: // NEW
|
||||
// CHECK positions
|
||||
ArmorStand stand = (ArmorStand) entity;
|
||||
this.inventory = new ItemStack[]{stand.getItemInHand().clone(), stand.getHelmet().clone(), stand.getChestplate().clone(),
|
||||
@ -271,7 +264,6 @@ public class EntityWrapper {
|
||||
this.stand.small = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case ENDERMITE: // NEW
|
||||
case BAT:
|
||||
case ENDER_DRAGON:
|
||||
@ -289,11 +281,10 @@ public class EntityWrapper {
|
||||
case ENDERMAN:
|
||||
case CREEPER:
|
||||
case BLAZE:
|
||||
case SHULKER:
|
||||
case SNOWMAN:
|
||||
case IRON_GOLEM: {
|
||||
case IRON_GOLEM:
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
}
|
||||
// END LIVING //
|
||||
}
|
||||
}
|
||||
@ -318,7 +309,7 @@ public class EntityWrapper {
|
||||
entity.setCustomName(this.lived.name);
|
||||
entity.setCustomNameVisible(this.lived.visible);
|
||||
}
|
||||
if ((this.lived.potions != null) && !this.lived.potions.isEmpty()) {
|
||||
if (this.lived.potions != null && !this.lived.potions.isEmpty()) {
|
||||
entity.addPotionEffects(this.lived.potions);
|
||||
}
|
||||
entity.setRemainingAir(this.lived.air);
|
||||
@ -413,21 +404,17 @@ public class EntityWrapper {
|
||||
}
|
||||
Entity entity;
|
||||
switch (this.type) {
|
||||
case DROPPED_ITEM: {
|
||||
case DROPPED_ITEM:
|
||||
return world.dropItem(loc, this.stack);
|
||||
}
|
||||
case PLAYER:
|
||||
case LEASH_HITCH: {
|
||||
case LEASH_HITCH:
|
||||
return null;
|
||||
}
|
||||
case ITEM_FRAME: {
|
||||
case ITEM_FRAME:
|
||||
entity = world.spawn(loc, ItemFrame.class);
|
||||
break;
|
||||
}
|
||||
case PAINTING: {
|
||||
case PAINTING:
|
||||
entity = world.spawn(loc, Painting.class);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
entity = world.spawnEntity(loc, this.type);
|
||||
break;
|
||||
@ -483,38 +470,33 @@ public class EntityWrapper {
|
||||
case WEATHER:
|
||||
case WITHER_SKULL:
|
||||
case MINECART_FURNACE:
|
||||
case UNKNOWN: {
|
||||
case UNKNOWN:
|
||||
// Do this stuff later
|
||||
return entity;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
PS.debug("&cCOULD NOT IDENTIFY ENTITY: " + entity.getType());
|
||||
return entity;
|
||||
}
|
||||
// MISC //
|
||||
case ITEM_FRAME: {
|
||||
case ITEM_FRAME:
|
||||
ItemFrame itemframe = (ItemFrame) entity;
|
||||
itemframe.setRotation(Rotation.values()[this.dataByte]);
|
||||
itemframe.setItem(this.stack);
|
||||
return entity;
|
||||
}
|
||||
case PAINTING: {
|
||||
case PAINTING:
|
||||
Painting painting = (Painting) entity;
|
||||
painting.setFacingDirection(BlockFace.values()[this.dataByte], true);
|
||||
painting.setArt(Art.getByName(this.dataString), true);
|
||||
return entity;
|
||||
}
|
||||
// END MISC //
|
||||
// INVENTORY HOLDER //
|
||||
case MINECART_CHEST:
|
||||
case MINECART_HOPPER: {
|
||||
case MINECART_HOPPER:
|
||||
restoreInventory((InventoryHolder) entity);
|
||||
return entity;
|
||||
}
|
||||
// START LIVING ENTITY //
|
||||
// START AGEABLE //
|
||||
// START TAMEABLE //
|
||||
case HORSE: {
|
||||
case HORSE:
|
||||
Horse horse = (Horse) entity;
|
||||
horse.setJumpStrength(this.horse.jump);
|
||||
horse.setCarryingChest(this.horse.chest);
|
||||
@ -526,17 +508,15 @@ public class EntityWrapper {
|
||||
restoreLiving((LivingEntity) entity);
|
||||
restoreInventory((InventoryHolder) entity);
|
||||
return entity;
|
||||
}
|
||||
// END INVENTORY HOLDER //
|
||||
case WOLF:
|
||||
case OCELOT: {
|
||||
case OCELOT:
|
||||
restoreTameable((Tameable) entity);
|
||||
restoreAgeable((Ageable) entity);
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
}
|
||||
// END AGEABLE //
|
||||
case SHEEP: {
|
||||
case SHEEP:
|
||||
Sheep sheep = (Sheep) entity;
|
||||
if (this.dataByte == 1) {
|
||||
sheep.setSheared(true);
|
||||
@ -547,40 +527,35 @@ public class EntityWrapper {
|
||||
restoreAgeable((Ageable) entity);
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
}
|
||||
case VILLAGER:
|
||||
case CHICKEN:
|
||||
case COW:
|
||||
case MUSHROOM_COW:
|
||||
case PIG: {
|
||||
case PIG:
|
||||
restoreAgeable((Ageable) entity);
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
}
|
||||
// END AGEABLE //
|
||||
case RABBIT: { // NEW
|
||||
case RABBIT: // NEW
|
||||
if (this.dataByte != 0) {
|
||||
((Rabbit) entity).setRabbitType(Type.values()[this.dataByte]);
|
||||
}
|
||||
restoreAgeable((Ageable) entity);
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
}
|
||||
case GUARDIAN: { // NEW
|
||||
case GUARDIAN: // NEW
|
||||
if (this.dataByte != 0) {
|
||||
((Guardian) entity).setElder(true);
|
||||
}
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
}
|
||||
case SKELETON: { // NEW
|
||||
case SKELETON: // NEW
|
||||
if (this.dataByte != 0) {
|
||||
((Skeleton) entity).setSkeletonType(SkeletonType.values()[this.dataByte]);
|
||||
}
|
||||
storeLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
}
|
||||
case ARMOR_STAND: { // NEW
|
||||
case ARMOR_STAND: // NEW
|
||||
// CHECK positions
|
||||
ArmorStand stand = (ArmorStand) entity;
|
||||
if (this.inventory[0] != null) {
|
||||
@ -598,27 +573,27 @@ public class EntityWrapper {
|
||||
if (this.inventory[4] != null) {
|
||||
stand.setBoots(this.inventory[4]);
|
||||
}
|
||||
if ((this.stand.head[0] != 0) || (this.stand.head[1] != 0) || (this.stand.head[2] != 0)) {
|
||||
if (this.stand.head[0] != 0 || this.stand.head[1] != 0 || this.stand.head[2] != 0) {
|
||||
EulerAngle pose = new EulerAngle(this.stand.head[0], this.stand.head[1], this.stand.head[2]);
|
||||
stand.setHeadPose(pose);
|
||||
}
|
||||
if ((this.stand.body[0] != 0) || (this.stand.body[1] != 0) || (this.stand.body[2] != 0)) {
|
||||
if (this.stand.body[0] != 0 || this.stand.body[1] != 0 || this.stand.body[2] != 0) {
|
||||
EulerAngle pose = new EulerAngle(this.stand.body[0], this.stand.body[1], this.stand.body[2]);
|
||||
stand.setBodyPose(pose);
|
||||
}
|
||||
if ((this.stand.leftLeg[0] != 0) || (this.stand.leftLeg[1] != 0) || (this.stand.leftLeg[2] != 0)) {
|
||||
if (this.stand.leftLeg[0] != 0 || this.stand.leftLeg[1] != 0 || this.stand.leftLeg[2] != 0) {
|
||||
EulerAngle pose = new EulerAngle(this.stand.leftLeg[0], this.stand.leftLeg[1], this.stand.leftLeg[2]);
|
||||
stand.setLeftLegPose(pose);
|
||||
}
|
||||
if ((this.stand.rightLeg[0] != 0) || (this.stand.rightLeg[1] != 0) || (this.stand.rightLeg[2] != 0)) {
|
||||
if (this.stand.rightLeg[0] != 0 || this.stand.rightLeg[1] != 0 || this.stand.rightLeg[2] != 0) {
|
||||
EulerAngle pose = new EulerAngle(this.stand.rightLeg[0], this.stand.rightLeg[1], this.stand.rightLeg[2]);
|
||||
stand.setRightLegPose(pose);
|
||||
}
|
||||
if ((this.stand.leftArm[0] != 0) || (this.stand.leftArm[1] != 0) || (this.stand.leftArm[2] != 0)) {
|
||||
if (this.stand.leftArm[0] != 0 || this.stand.leftArm[1] != 0 || this.stand.leftArm[2] != 0) {
|
||||
EulerAngle pose = new EulerAngle(this.stand.leftArm[0], this.stand.leftArm[1], this.stand.leftArm[2]);
|
||||
stand.setLeftArmPose(pose);
|
||||
}
|
||||
if ((this.stand.rightArm[0] != 0) || (this.stand.rightArm[1] != 0) || (this.stand.rightArm[2] != 0)) {
|
||||
if (this.stand.rightArm[0] != 0 || this.stand.rightArm[1] != 0 || this.stand.rightArm[2] != 0) {
|
||||
EulerAngle pose = new EulerAngle(this.stand.rightArm[0], this.stand.rightArm[1], this.stand.rightArm[2]);
|
||||
stand.setRightArmPose(pose);
|
||||
}
|
||||
@ -639,7 +614,6 @@ public class EntityWrapper {
|
||||
}
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
}
|
||||
case ENDERMITE: // NEW
|
||||
case BAT:
|
||||
case ENDER_DRAGON:
|
||||
@ -658,10 +632,9 @@ public class EntityWrapper {
|
||||
case CREEPER:
|
||||
case BLAZE:
|
||||
case SNOWMAN:
|
||||
case IRON_GOLEM: {
|
||||
case IRON_GOLEM:
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
}
|
||||
// END LIVING //
|
||||
}
|
||||
}
|
||||
|
@ -275,9 +275,9 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkModified(String worldname, int x1, int x2, int y1, int y2, int z1, int z2,
|
||||
public int checkModified(String worldName, int x1, int x2, int y1, int y2, int z1, int z2,
|
||||
PlotBlock[] blocks) {
|
||||
World world = BukkitUtil.getWorld(worldname);
|
||||
World world = BukkitUtil.getWorld(worldName);
|
||||
int count = 0;
|
||||
for (int y = y1; y <= y2; y++) {
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
@ -301,8 +301,8 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int get_ey(String worldname, int sx, int ex, int sz, int ez, int sy) {
|
||||
World world = BukkitUtil.getWorld(worldname);
|
||||
public int get_ey(String worldName, int sx, int ex, int sz, int ez, int sy) {
|
||||
World world = BukkitUtil.getWorld(worldName);
|
||||
int maxY = world.getMaxHeight();
|
||||
int ey = sy;
|
||||
for (int x = sx; x <= ex; x++) {
|
||||
|
@ -26,7 +26,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -45,9 +44,9 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
final Location bot = corners[0];
|
||||
Location top = corners[1];
|
||||
|
||||
final int width = (top.getX() - bot.getX()) + 1;
|
||||
int height = (top.getY() - bot.getY()) + 1;
|
||||
final int length = (top.getZ() - bot.getZ()) + 1;
|
||||
final int width = top.getX() - bot.getX() + 1;
|
||||
int height = top.getY() - bot.getY() + 1;
|
||||
final int length = top.getZ() - bot.getZ() + 1;
|
||||
// Main Schematic tag
|
||||
final HashMap<String, Tag> schematic = new HashMap<>();
|
||||
schematic.put("Width", new ShortTag("Width", (short) width));
|
||||
@ -114,7 +113,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
@Override
|
||||
public void run() {
|
||||
long start = System.currentTimeMillis();
|
||||
while (!chunks.isEmpty() && ((System.currentTimeMillis() - start) < 20)) {
|
||||
while (!chunks.isEmpty() && System.currentTimeMillis() - start < 20) {
|
||||
// save schematics
|
||||
ChunkLoc chunk = chunks.remove(0);
|
||||
Chunk bc = worldObj.getChunkAt(chunk.x, chunk.z);
|
||||
@ -145,7 +144,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
int i1 = ry * width * length;
|
||||
for (int z = zzb; z <= zzt; z++) {
|
||||
int rz = z - bz;
|
||||
int i2 = i1 + (rz * width);
|
||||
int i2 = i1 + rz * width;
|
||||
for (int x = xxb; x <= xxt; x++) {
|
||||
int rx = x - bx;
|
||||
int index = i2 + rx;
|
||||
@ -219,9 +218,8 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
case 189:
|
||||
case 190:
|
||||
case 191:
|
||||
case 192: {
|
||||
case 192:
|
||||
break;
|
||||
}
|
||||
case 54:
|
||||
case 130:
|
||||
case 142:
|
||||
@ -256,17 +254,14 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
case 29:
|
||||
case 33:
|
||||
case 151:
|
||||
case 178: {
|
||||
case 178:
|
||||
// TODO implement fully
|
||||
BlockState state = block.getState();
|
||||
if (state != null) {
|
||||
StateWrapper wrapper = new StateWrapper(state);
|
||||
CompoundTag rawTag = wrapper.getTag();
|
||||
if (rawTag != null) {
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
for (Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
Map<String, Tag> values = new HashMap<>(rawTag.getValue());
|
||||
values.put("id", new StringTag("id", wrapper.getId()));
|
||||
values.put("x", new IntTag("x", x));
|
||||
values.put("y", new IntTag("y", y));
|
||||
@ -275,11 +270,9 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
tileEntities.add(tileEntityTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
blockData[index] = block.getData();
|
||||
}
|
||||
}
|
||||
// For optimization reasons, we are not supporting custom data types
|
||||
// Especially since the most likely reason beyond this range is modded servers in which the blocks
|
||||
// have NBT
|
||||
@ -310,7 +303,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schem) {
|
||||
new StateWrapper(ct).restoreTag(x, y, z, schem);
|
||||
public void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schematic) {
|
||||
new StateWrapper(ct).restoreTag(x, y, z, schematic);
|
||||
}
|
||||
}
|
||||
|
@ -62,8 +62,8 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
switch (type) {
|
||||
case 2: {
|
||||
if (object.id != null) {
|
||||
String areaname = object.id + "-" + object.min + "-" + object.max;
|
||||
String areaPath = "areas." + areaname;
|
||||
String areaName = object.id + "-" + object.min + "-" + object.max;
|
||||
String areaPath = "areas." + areaName;
|
||||
if (!worldSection.contains(areaPath)) {
|
||||
worldSection.createSection(areaPath);
|
||||
}
|
||||
@ -75,7 +75,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
options.put("generator.type", object.type);
|
||||
options.put("generator.terrain", object.terrain);
|
||||
options.put("generator.plugin", object.plotManager);
|
||||
if ((object.setupGenerator != null) && !object.setupGenerator.equals(object.plotManager)) {
|
||||
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
|
||||
options.put("generator.init", object.setupGenerator);
|
||||
}
|
||||
for (Entry<String, Object> entry : options.entrySet()) {
|
||||
@ -91,42 +91,40 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
GeneratorWrapper<?> gen = generators.get(object.setupGenerator);
|
||||
if ((gen != null) && gen.isFull()) {
|
||||
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||
if (gen != null && gen.isFull()) {
|
||||
object.setupGenerator = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
case 1:
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
|
||||
PS.get().config.set("worlds." + world + "." + "generator.terrain", object.terrain);
|
||||
PS.get().config.set("worlds." + world + "." + "generator.plugin", object.plotManager);
|
||||
if ((object.setupGenerator != null) && !object.setupGenerator.equals(object.plotManager)) {
|
||||
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
|
||||
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
||||
}
|
||||
GeneratorWrapper<?> gen = generators.get(object.setupGenerator);
|
||||
if ((gen != null) && gen.isFull()) {
|
||||
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||
if (gen != null && gen.isFull()) {
|
||||
object.setupGenerator = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0: {
|
||||
case 0:
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (object.setupGenerator != null) {
|
||||
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core")
|
||||
if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit.getPluginManager().getPlugin("Multiverse-Core")
|
||||
.isEnabled()) {
|
||||
Bukkit.getServer()
|
||||
.dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal -g " + object.setupGenerator);
|
||||
@ -135,7 +133,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||
if (Bukkit.getPluginManager().getPlugin("MultiWorld") != null && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.setupGenerator);
|
||||
setGenerator(world, object.setupGenerator);
|
||||
if (Bukkit.getWorld(world) != null) {
|
||||
@ -148,14 +146,14 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
Bukkit.createWorld(wc);
|
||||
setGenerator(world, object.setupGenerator);
|
||||
} else {
|
||||
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core")
|
||||
if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit.getPluginManager().getPlugin("Multiverse-Core")
|
||||
.isEnabled()) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal");
|
||||
if (Bukkit.getWorld(world) != null) {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||
if (Bukkit.getPluginManager().getPlugin("MultiWorld") != null && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world);
|
||||
if (Bukkit.getWorld(world) != null) {
|
||||
return world;
|
||||
@ -193,7 +191,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
if (!(generator instanceof BukkitPlotGenerator)) {
|
||||
return null;
|
||||
}
|
||||
for (Entry<String, GeneratorWrapper<?>> entry : generators.entrySet()) {
|
||||
for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
|
||||
GeneratorWrapper<?> current = entry.getValue();
|
||||
if (current.equals(generator)) {
|
||||
return entry.getKey();
|
||||
|
@ -97,8 +97,8 @@ public class BukkitUtil extends WorldUtil {
|
||||
return entity.getWorld().getName();
|
||||
}
|
||||
|
||||
public static List<Entity> getEntities(String worldname) {
|
||||
return getWorld(worldname).getEntities();
|
||||
public static List<Entity> getEntities(String worldName) {
|
||||
return getWorld(worldName).getEntities();
|
||||
}
|
||||
|
||||
public static Location getLocation(Entity entity) {
|
||||
@ -114,8 +114,8 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorld(String world) {
|
||||
return getWorld(world) != null;
|
||||
public boolean isWorld(String worldName) {
|
||||
return getWorld(worldName) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -124,8 +124,8 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSign(String worldname, int x, int y, int z, String[] lines) {
|
||||
World world = getWorld(worldname);
|
||||
public void setSign(String worldName, int x, int y, int z, String[] lines) {
|
||||
World world = getWorld(worldName);
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
// block.setType(Material.AIR);
|
||||
block.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false);
|
||||
@ -172,8 +172,8 @@ public class BukkitUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorld(String worldname) {
|
||||
World world = getWorld(worldname);
|
||||
public void saveWorld(String worldName) {
|
||||
World world = getWorld(worldName);
|
||||
if (world != null) {
|
||||
world.save();
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ public class Metrics {
|
||||
// Construct the post data
|
||||
StringBuilder json = new StringBuilder(1024);
|
||||
json.append('{');
|
||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||
// The plugin's description file containing all of the plugin data such as name, version, author, etc
|
||||
appendJSONPair(json, "guid", this.guid);
|
||||
appendJSONPair(json, "plugin_version", pluginVersion);
|
||||
appendJSONPair(json, "server_version", serverVersion);
|
||||
|
@ -223,7 +223,7 @@ public class NbtFactory {
|
||||
|
||||
/**
|
||||
* Construct a new NBT wrapper from a compound.
|
||||
* @param nmsCompound - the NBT compund.
|
||||
* @param nmsCompound - the NBT compound.
|
||||
* @return The wrapper.
|
||||
*/
|
||||
public static NbtCompound fromCompound(Object nmsCompound) {
|
||||
@ -247,7 +247,7 @@ public class NbtFactory {
|
||||
|
||||
/**
|
||||
* Construct a wrapper for an NBT tag stored (in memory) in an item stack. This is where
|
||||
* auxillary data such as enchanting, name and lore is stored. It does not include items
|
||||
* auxiliary data such as enchanting, name and lore is stored. It does not include items
|
||||
* material, damage value or count.
|
||||
* <p>
|
||||
* The item stack must be a wrapper for a CraftItemStack.
|
||||
@ -669,7 +669,7 @@ public class NbtFactory {
|
||||
super(handle, getDataMap(handle));
|
||||
}
|
||||
|
||||
// Simplifiying access to each value
|
||||
// Simplifying access to each value
|
||||
public Byte getByte(String key, Byte defaultValue) {
|
||||
return containsKey(key) ? (Byte) get(key) : defaultValue;
|
||||
}
|
||||
|
@ -116,10 +116,10 @@ public class SendChunk {
|
||||
try {
|
||||
chunk.unload(true, false);
|
||||
} catch (Throwable e) {
|
||||
String worldname = chunk.getWorld().getName();
|
||||
PS.debug("$4Could not save chunk: " + worldname + ";" + chunk.getX() + ";" + chunk.getZ());
|
||||
String worldName = chunk.getWorld().getName();
|
||||
PS.debug("$4Could not save chunk: " + worldName + ";" + chunk.getX() + ";" + chunk.getZ());
|
||||
PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
|
||||
PS.debug("$3 - $4" + worldname + "/level.dat or " + worldname
|
||||
PS.debug("$3 - $4" + worldName + "/level.dat or " + worldName
|
||||
+ "/level_old.dat may be corrupt (try repairing or removing these)");
|
||||
}
|
||||
}
|
||||
@ -127,12 +127,12 @@ public class SendChunk {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendChunk(String worldname, Collection<ChunkLoc> chunkLocs) {
|
||||
World myworld = Bukkit.getWorld(worldname);
|
||||
public void sendChunk(String worldName, Collection<ChunkLoc> chunkLocations) {
|
||||
World myWorld = Bukkit.getWorld(worldName);
|
||||
ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
for (ChunkLoc loc : chunkLocs) {
|
||||
if (myworld.isChunkLoaded(loc.x, loc.z)) {
|
||||
chunks.add(myworld.getChunkAt(loc.x, loc.z));
|
||||
for (ChunkLoc loc : chunkLocations) {
|
||||
if (myWorld.isChunkLoaded(loc.x, loc.z)) {
|
||||
chunks.add(myWorld.getChunkAt(loc.x, loc.z));
|
||||
}
|
||||
}
|
||||
sendChunk(chunks);
|
||||
|
@ -45,10 +45,10 @@ public class SetGenCB {
|
||||
}
|
||||
}
|
||||
if (!set) {
|
||||
Iterator<BlockPopulator> iter = world.getPopulators().iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (iter.next() instanceof BukkitAugmentedGenerator) {
|
||||
iter.remove();
|
||||
Iterator<BlockPopulator> iterator = world.getPopulators().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (iterator.next() instanceof BukkitAugmentedGenerator) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,7 @@ public class FastQueue_1_7 extends SlowQueue {
|
||||
private final RefMethod methodA;
|
||||
private final RefMethod methodGetById;
|
||||
private final RefMethod methodInitLighting;
|
||||
|
||||
private final SendChunk chunksender;
|
||||
private final SendChunk sendChunk;
|
||||
|
||||
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
|
||||
@ -45,7 +44,7 @@ public class FastQueue_1_7 extends SlowQueue {
|
||||
this.methodA = this.classChunk.getMethod("a", int.class, int.class, int.class, this.classBlock, int.class);
|
||||
this.methodGetById = this.classBlock.getMethod("getById", int.class);
|
||||
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||
this.chunksender = new SendChunk();
|
||||
this.sendChunk = new SendChunk();
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -82,7 +81,7 @@ public class FastQueue_1_7 extends SlowQueue {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.chunksender.sendChunk(chunks);
|
||||
this.sendChunk.sendChunk(chunks);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.canSendChunk = false;
|
||||
@ -175,6 +174,6 @@ public class FastQueue_1_7 extends SlowQueue {
|
||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||
this.toUpdate.remove(wrapper);
|
||||
}
|
||||
this.chunksender.sendChunk(world, locations);
|
||||
this.sendChunk.sendChunk(world, locations);
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
private final RefMethod methodA;
|
||||
private final RefMethod methodGetByCombinedId;
|
||||
private final RefConstructor constructorBlockPosition;
|
||||
private final SendChunk chunksender;
|
||||
private final SendChunk sendChunk;
|
||||
|
||||
public FastQueue_1_8() throws RuntimeException {
|
||||
this.methodInitLighting = this.classChunk.getMethod("initLighting");
|
||||
@ -49,7 +49,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
this.methodGetHandle = this.classCraftWorld.getMethod("getHandle");
|
||||
this.methodGetChunkAt = this.classWorld.getMethod("getChunkAt", int.class, int.class);
|
||||
this.methodA = this.classChunk.getMethod("a", this.classBlockPosition, this.classIBlockData);
|
||||
this.chunksender = new SendChunk();
|
||||
this.sendChunk = new SendChunk();
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -59,7 +59,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
int count = 0;
|
||||
ArrayList<Chunk> chunks = new ArrayList<Chunk>();
|
||||
Iterator<Entry<ChunkWrapper, Chunk>> i = FastQueue_1_8.this.toUpdate.entrySet().iterator();
|
||||
while (i.hasNext() && (count < 128)) {
|
||||
while (i.hasNext() && count < 128) {
|
||||
chunks.add(i.next().getValue());
|
||||
i.remove();
|
||||
count++;
|
||||
@ -86,7 +86,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.chunksender.sendChunk(chunks);
|
||||
this.sendChunk.sendChunk(chunks);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.canSendChunk = false;
|
||||
@ -161,7 +161,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
case 29:
|
||||
case 33:
|
||||
case 151:
|
||||
case 178: {
|
||||
case 178:
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
if (block.getData() == newBlock.data) {
|
||||
if (block.getTypeId() != newBlock.id) {
|
||||
@ -176,7 +176,6 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Start data value shortcut
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
@ -263,10 +262,9 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
case 189:
|
||||
case 190:
|
||||
case 191:
|
||||
case 192: {
|
||||
case 192:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (block.getData() == newBlock.data) {
|
||||
return;
|
||||
}
|
||||
@ -311,7 +309,7 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
case 29:
|
||||
case 33:
|
||||
case 151:
|
||||
case 178: {
|
||||
case 178:
|
||||
if (block.getData() == newBlock.data) {
|
||||
block.setTypeId(newBlock.id, false);
|
||||
} else {
|
||||
@ -319,7 +317,6 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// End blockstate workaround //
|
||||
|
||||
// check sign
|
||||
@ -378,6 +375,6 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||
this.toUpdate.remove(wrapper);
|
||||
}
|
||||
this.chunksender.sendChunk(world, locations);
|
||||
this.sendChunk.sendChunk(world, locations);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
@ -14,6 +16,12 @@ import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.util.SendChunk;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -23,18 +31,10 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public class FastQueue_1_8_3 extends SlowQueue {
|
||||
|
||||
private final SendChunk chunksender;
|
||||
private final SendChunk sendChunk;
|
||||
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
|
||||
private final RefMethod methodGetHandleChunk;
|
||||
private final RefMethod methodInitLighting;
|
||||
@ -65,7 +65,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
this.classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
|
||||
this.tileEntityUnload = classWorld.getField("c");
|
||||
this.methodGetWorld = classChunk.getMethod("getWorld");
|
||||
this.chunksender = new SendChunk();
|
||||
this.sendChunk = new SendChunk();
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -102,7 +102,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.chunksender.sendChunk(chunks);
|
||||
this.sendChunk.sendChunk(chunks);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.canSendChunk = false;
|
||||
@ -129,7 +129,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
// Sections
|
||||
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
|
||||
Object c = getHandle.invoke(chunk);
|
||||
Object w = methodGetWorld.of(c).call();
|
||||
Object w = this.methodGetWorld.of(c).call();
|
||||
Class<? extends Object> clazz = c.getClass();
|
||||
Field sections1 = clazz.getDeclaredField("sections");
|
||||
sections1.setAccessible(true);
|
||||
@ -138,7 +138,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
|
||||
Object[] sections = (Object[]) sections1.get(c);
|
||||
HashMap<?, ?> tiles = (HashMap<?, ?>) tileEntities.get(c);
|
||||
Collection<Object> tilesUnload = (Collection<Object>) tileEntityUnload.of(w).get();
|
||||
Collection<Object> tilesUnload = (Collection<Object>) this.tileEntityUnload.of(w).get();
|
||||
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
|
||||
|
||||
Method getX = null;
|
||||
@ -407,6 +407,6 @@ public class FastQueue_1_8_3 extends SlowQueue {
|
||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||
this.toUpdate.remove(wrapper);
|
||||
}
|
||||
this.chunksender.sendChunk(world, locations);
|
||||
this.sendChunk.sendChunk(world, locations);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
@ -15,6 +17,12 @@ import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.SendChunk;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -24,14 +32,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public class FastQueue_1_9 extends SlowQueue {
|
||||
|
||||
@ -143,7 +143,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
// Sections
|
||||
Method getHandle = chunk.getClass().getDeclaredMethod("getHandle");
|
||||
Object c = getHandle.invoke(chunk);
|
||||
Object w = methodGetWorld.of(c).call();
|
||||
Object w = this.methodGetWorld.of(c).call();
|
||||
Class<? extends Object> clazz = c.getClass();
|
||||
Field sf = clazz.getDeclaredField("sections");
|
||||
sf.setAccessible(true);
|
||||
@ -152,7 +152,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
|
||||
Object[] sections = (Object[]) sf.get(c);
|
||||
HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
|
||||
Collection<Object> tilesUnload = (Collection<Object>) tileEntityUnload.of(w).get();
|
||||
Collection<Object> tilesUnload = (Collection<Object>) this.tileEntityUnload.of(w).get();
|
||||
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
|
||||
|
||||
Method xm = null;
|
||||
@ -230,7 +230,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
setType.call(x, y & 15, z, this.air);
|
||||
continue;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
int x = MainUtil.x_loc[j][k];
|
||||
int y = MainUtil.y_loc[j][k];
|
||||
int z = MainUtil.z_loc[j][k];
|
||||
@ -238,7 +238,6 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
setType.call(x, y & 15, z, iBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fill) {
|
||||
fs.setCount(j, Short.MAX_VALUE);
|
||||
}
|
||||
@ -306,7 +305,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
if (fixAll && !(boolean) this.methodAreNeighborsLoaded.of(c).call(1)) {
|
||||
World world = chunk.getWorld();
|
||||
ChunkWrapper wrapper = bc.getChunkWrapper();
|
||||
String worldname = wrapper.world;
|
||||
String worldName = wrapper.world;
|
||||
for (int x = wrapper.x - 1; x <= wrapper.x + 1; x++) {
|
||||
for (int z = wrapper.z - 1; z <= wrapper.z + 1; z++) {
|
||||
if (x != 0 && z != 0) {
|
||||
@ -314,7 +313,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
while (!other.isLoaded()) {
|
||||
other.load(true);
|
||||
}
|
||||
ChunkManager.manager.loadChunk(worldname, new ChunkLoc(x, z), true);
|
||||
ChunkManager.manager.loadChunk(worldName, new ChunkLoc(x, z), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,12 +62,12 @@ public class SlowQueue implements PlotQueue<Chunk> {
|
||||
if (this.blocks.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
Iterator<Entry<ChunkWrapper, PlotChunk<Chunk>>> iter = this.blocks.entrySet().iterator();
|
||||
PlotChunk<Chunk> toReturn = iter.next().getValue();
|
||||
Iterator<Entry<ChunkWrapper, PlotChunk<Chunk>>> iterator = this.blocks.entrySet().iterator();
|
||||
PlotChunk<Chunk> toReturn = iterator.next().getValue();
|
||||
if (SetQueue.IMP.isWaiting()) {
|
||||
return null;
|
||||
}
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
execute(toReturn);
|
||||
fixLighting(toReturn, true);
|
||||
return toReturn;
|
||||
|
@ -55,10 +55,10 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
@Override
|
||||
public void run() {
|
||||
PS.debug(C.PREFIX + "&6Starting player data caching for: " + world);
|
||||
File uuidfile = new File(PS.get().IMP.getDirectory(), "uuids.txt");
|
||||
if (uuidfile.exists()) {
|
||||
File uuidFile = new File(PS.get().IMP.getDirectory(), "uuids.txt");
|
||||
if (uuidFile.exists()) {
|
||||
try {
|
||||
List<String> lines = Files.readAllLines(uuidfile.toPath(), StandardCharsets.UTF_8);
|
||||
List<String> lines = Files.readAllLines(uuidFile.toPath(), StandardCharsets.UTF_8);
|
||||
for (String line : lines) {
|
||||
try {
|
||||
line = line.trim();
|
||||
@ -89,8 +89,8 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
toAdd.put(new StringWrapper("*"), DBFunc.everyone);
|
||||
HashSet<UUID> all = UUIDHandler.getAllUUIDS();
|
||||
PS.debug("&aFast mode UUID caching enabled!");
|
||||
File playerdataFolder = new File(container, world + File.separator + "playerdata");
|
||||
String[] dat = playerdataFolder.list(new FilenameFilter() {
|
||||
File playerDataFolder = new File(container, world + File.separator + "playerdata");
|
||||
String[] dat = playerDataFolder.list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File f, String s) {
|
||||
return s.endsWith(".dat");
|
||||
@ -103,7 +103,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
try {
|
||||
UUID uuid = UUID.fromString(s);
|
||||
if (check || all.remove(uuid)) {
|
||||
File file = new File(playerdataFolder + File.separator + current);
|
||||
File file = new File(playerDataFolder + File.separator + current);
|
||||
InputSupplier<FileInputStream> is = com.google.common.io.Files.newInputStreamSupplier(file);
|
||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||
@ -137,11 +137,11 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
worlds.add("world");
|
||||
HashSet<UUID> uuids = new HashSet<>();
|
||||
HashSet<String> names = new HashSet<>();
|
||||
File playerdataFolder = null;
|
||||
File playerDataFolder = null;
|
||||
for (String worldName : worlds) {
|
||||
// Getting UUIDs
|
||||
playerdataFolder = new File(container, worldName + File.separator + "playerdata");
|
||||
String[] dat = playerdataFolder.list(new FilenameFilter() {
|
||||
playerDataFolder = new File(container, worldName + File.separator + "playerdata");
|
||||
String[] dat = playerDataFolder.list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File f, String s) {
|
||||
return s.endsWith(".dat");
|
||||
@ -154,7 +154,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
UUID uuid = UUID.fromString(s);
|
||||
uuids.add(uuid);
|
||||
} catch (Exception e) {
|
||||
PS.debug(C.PREFIX + "Invalid playerdata: " + current);
|
||||
PS.debug(C.PREFIX + "Invalid PlayerData: " + current);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -176,7 +176,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
for (UUID uuid : uuids) {
|
||||
try {
|
||||
File file = new File(playerdataFolder + File.separator + uuid.toString() + ".dat");
|
||||
File file = new File(playerDataFolder + File.separator + uuid.toString() + ".dat");
|
||||
if (!file.exists()) {
|
||||
continue;
|
||||
}
|
||||
@ -199,7 +199,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
toAdd.put(new StringWrapper(name), uuid);
|
||||
} catch (Throwable e) {
|
||||
PS.debug(C.PREFIX + "&6Invalid playerdata: " + uuid.toString() + ".dat");
|
||||
PS.debug(C.PREFIX + "&6Invalid PlayerData: " + uuid.toString() + ".dat");
|
||||
}
|
||||
}
|
||||
for (String name : names) {
|
||||
|
@ -151,7 +151,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
|
||||
@Override
|
||||
public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
|
||||
PS.debug(C.PREFIX + "UUID for '" + name + "' was null. We'll cache this from the mojang servers!");
|
||||
PS.debug(C.PREFIX + "UUID for '" + name + "' was null. We'll cache this from the Mojang servers!");
|
||||
if (ifFetch == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* Creates an empty {@link FileConfiguration} with no default values.
|
||||
*/
|
||||
public FileConfiguration() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -35,7 +34,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
*
|
||||
* @param defaults Default value provider
|
||||
*/
|
||||
public FileConfiguration(final Configuration defaults) {
|
||||
public FileConfiguration(Configuration defaults) {
|
||||
super(defaults);
|
||||
}
|
||||
|
||||
@ -54,13 +53,13 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* any reason.
|
||||
* @throws IllegalArgumentException Thrown when file is null.
|
||||
*/
|
||||
public void save(final File file) throws IOException {
|
||||
public void save(File file) throws IOException {
|
||||
if (file == null) {
|
||||
throw new NullPointerException("File cannot be null");
|
||||
}
|
||||
file.getParentFile().mkdirs();
|
||||
|
||||
final String data = saveToString();
|
||||
String data = saveToString();
|
||||
|
||||
try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
|
||||
writer.write(data);
|
||||
@ -82,7 +81,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* any reason.
|
||||
* @throws IllegalArgumentException Thrown when file is null.
|
||||
*/
|
||||
public void save(final String file) throws IOException {
|
||||
public void save(String file) throws IOException {
|
||||
if (file == null) {
|
||||
throw new NullPointerException("File cannot be null");
|
||||
}
|
||||
@ -116,12 +115,12 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* a valid Configuration.
|
||||
* @throws IllegalArgumentException Thrown when file is null.
|
||||
*/
|
||||
public void load(final File file) throws IOException, InvalidConfigurationException {
|
||||
public void load(File file) throws IOException, InvalidConfigurationException {
|
||||
if (file == null) {
|
||||
throw new NullPointerException("File cannot be null");
|
||||
}
|
||||
|
||||
final FileInputStream stream = new FileInputStream(file);
|
||||
FileInputStream stream = new FileInputStream(file);
|
||||
|
||||
load(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||
}
|
||||
@ -139,9 +138,9 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* represent a valid Configuration
|
||||
* @throws IllegalArgumentException thrown when reader is null
|
||||
*/
|
||||
public void load(final Reader reader) throws IOException, InvalidConfigurationException {
|
||||
public void load(Reader reader) throws IOException, InvalidConfigurationException {
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
try (BufferedReader input = reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader)) {
|
||||
String line;
|
||||
@ -173,7 +172,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* a valid Configuration.
|
||||
* @throws IllegalArgumentException Thrown when file is null.
|
||||
*/
|
||||
public void load(final String file) throws IOException, InvalidConfigurationException {
|
||||
public void load(String file) throws IOException, InvalidConfigurationException {
|
||||
if (file == null) {
|
||||
throw new NullPointerException("File cannot be null");
|
||||
}
|
||||
@ -196,7 +195,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* invalid.
|
||||
* @throws IllegalArgumentException Thrown if contents is null.
|
||||
*/
|
||||
public abstract void loadFromString(final String contents) throws InvalidConfigurationException;
|
||||
public abstract void loadFromString(String contents) throws InvalidConfigurationException;
|
||||
|
||||
/**
|
||||
* Compiles the header for this {@link FileConfiguration} and returns the
|
||||
@ -212,10 +211,10 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
|
||||
@Override
|
||||
public FileConfigurationOptions options() {
|
||||
if (options == null) {
|
||||
options = new FileConfigurationOptions(this);
|
||||
if (this.options == null) {
|
||||
this.options = new FileConfigurationOptions(this);
|
||||
}
|
||||
|
||||
return (FileConfigurationOptions) options;
|
||||
return (FileConfigurationOptions) this.options;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
||||
* The {@code TAG_Byte_Array} tag.
|
||||
*/
|
||||
public final class ByteArrayTag extends Tag {
|
||||
|
||||
private final byte[] value;
|
||||
|
||||
/**
|
||||
@ -11,8 +12,7 @@ public final class ByteArrayTag extends Tag {
|
||||
*
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ByteArrayTag(final byte[] value) {
|
||||
super();
|
||||
public ByteArrayTag(byte[] value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ -22,29 +22,29 @@ public final class ByteArrayTag extends Tag {
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ByteArrayTag(final String name, final byte[] value) {
|
||||
public ByteArrayTag(String name, byte[] value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder hex = new StringBuilder();
|
||||
for (final byte b : value) {
|
||||
final String hexDigits = Integer.toHexString(b).toUpperCase();
|
||||
StringBuilder hex = new StringBuilder();
|
||||
for (byte b : this.value) {
|
||||
String hexDigits = Integer.toHexString(b).toUpperCase();
|
||||
if (hexDigits.length() == 1) {
|
||||
hex.append("0");
|
||||
}
|
||||
hex.append(hexDigits).append(" ");
|
||||
}
|
||||
final String name = getName();
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if ((name != null) && !name.equals("")) {
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Byte_Array" + append + ": " + hex;
|
||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
||||
* The {@code TAG_Byte} tag.
|
||||
*/
|
||||
public final class ByteTag extends Tag {
|
||||
|
||||
private final byte value;
|
||||
|
||||
/**
|
||||
@ -11,8 +12,7 @@ public final class ByteTag extends Tag {
|
||||
*
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ByteTag(final byte value) {
|
||||
super();
|
||||
public ByteTag(byte value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ -22,23 +22,23 @@ public final class ByteTag extends Tag {
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ByteTag(final String name, final byte value) {
|
||||
public ByteTag(String name, byte value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Byte getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final String name = getName();
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if ((name != null) && !name.equals("")) {
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Byte" + append + ": " + value;
|
||||
return "TAG_Byte" + append + ": " + this.value;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ public final class CompoundTag extends Tag {
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public CompoundTag(Map<String, Tag> value) {
|
||||
super();
|
||||
this.value = Collections.unmodifiableMap(value);
|
||||
}
|
||||
|
||||
@ -374,7 +373,7 @@ public final class CompoundTag extends Tag {
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if ((name != null) && !name.equals("")) {
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
StringBuilder bldr = new StringBuilder();
|
||||
|
@ -9,13 +9,14 @@ import java.util.Map;
|
||||
* Helps create compound tags.
|
||||
*/
|
||||
public class CompoundTagBuilder {
|
||||
|
||||
private final Map<String, Tag> entries;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
CompoundTagBuilder() {
|
||||
entries = new HashMap<String, Tag>();
|
||||
this.entries = new HashMap<String, Tag>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -23,9 +24,9 @@ public class CompoundTagBuilder {
|
||||
*
|
||||
* @param value the value
|
||||
*/
|
||||
CompoundTagBuilder(final Map<String, Tag> value) {
|
||||
CompoundTagBuilder(Map<String, Tag> value) {
|
||||
checkNotNull(value);
|
||||
entries = value;
|
||||
this.entries = value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,10 +46,10 @@ public class CompoundTagBuilder {
|
||||
*
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder put(final String key, final Tag value) {
|
||||
public CompoundTagBuilder put(String key, Tag value) {
|
||||
checkNotNull(key);
|
||||
checkNotNull(value);
|
||||
entries.put(key, value);
|
||||
this.entries.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -60,7 +61,7 @@ public class CompoundTagBuilder {
|
||||
*
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putByteArray(final String key, final byte[] value) {
|
||||
public CompoundTagBuilder putByteArray(String key, byte[] value) {
|
||||
return put(key, new ByteArrayTag(key, value));
|
||||
}
|
||||
|
||||
@ -72,7 +73,7 @@ public class CompoundTagBuilder {
|
||||
*
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putByte(final String key, final byte value) {
|
||||
public CompoundTagBuilder putByte(String key, byte value) {
|
||||
return put(key, new ByteTag(key, value));
|
||||
}
|
||||
|
||||
@ -84,7 +85,7 @@ public class CompoundTagBuilder {
|
||||
*
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putDouble(final String key, final double value) {
|
||||
public CompoundTagBuilder putDouble(String key, double value) {
|
||||
return put(key, new DoubleTag(key, value));
|
||||
}
|
||||
|
||||
@ -96,7 +97,7 @@ public class CompoundTagBuilder {
|
||||
*
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putFloat(final String key, final float value) {
|
||||
public CompoundTagBuilder putFloat(String key, float value) {
|
||||
return put(key, new FloatTag(key, value));
|
||||
}
|
||||
|
||||
@ -108,7 +109,7 @@ public class CompoundTagBuilder {
|
||||
*
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putIntArray(final String key, final int[] value) {
|
||||
public CompoundTagBuilder putIntArray(String key, int[] value) {
|
||||
return put(key, new IntArrayTag(key, value));
|
||||
}
|
||||
|
||||
@ -120,7 +121,7 @@ public class CompoundTagBuilder {
|
||||
*
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putInt(final String key, final int value) {
|
||||
public CompoundTagBuilder putInt(String key, int value) {
|
||||
return put(key, new IntTag(key, value));
|
||||
}
|
||||
|
||||
@ -132,7 +133,7 @@ public class CompoundTagBuilder {
|
||||
*
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putLong(final String key, final long value) {
|
||||
public CompoundTagBuilder putLong(String key, long value) {
|
||||
return put(key, new LongTag(key, value));
|
||||
}
|
||||
|
||||
@ -144,7 +145,7 @@ public class CompoundTagBuilder {
|
||||
*
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putShort(final String key, final short value) {
|
||||
public CompoundTagBuilder putShort(String key, short value) {
|
||||
return put(key, new ShortTag(key, value));
|
||||
}
|
||||
|
||||
@ -156,7 +157,7 @@ public class CompoundTagBuilder {
|
||||
*
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putString(final String key, final String value) {
|
||||
public CompoundTagBuilder putString(String key, String value) {
|
||||
return put(key, new StringTag(key, value));
|
||||
}
|
||||
|
||||
@ -167,9 +168,9 @@ public class CompoundTagBuilder {
|
||||
*
|
||||
* @return this object
|
||||
*/
|
||||
public CompoundTagBuilder putAll(final Map<String, ? extends Tag> value) {
|
||||
public CompoundTagBuilder putAll(Map<String, ? extends Tag> value) {
|
||||
checkNotNull(value);
|
||||
for (final Map.Entry<String, ? extends Tag> entry : value.entrySet()) {
|
||||
for (Map.Entry<String, ? extends Tag> entry : value.entrySet()) {
|
||||
put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return this;
|
||||
@ -181,7 +182,7 @@ public class CompoundTagBuilder {
|
||||
* @return the new compound tag
|
||||
*/
|
||||
public CompoundTag build() {
|
||||
return new CompoundTag(new HashMap<String, Tag>(entries));
|
||||
return new CompoundTag(new HashMap<String, Tag>(this.entries));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,7 +192,7 @@ public class CompoundTagBuilder {
|
||||
*
|
||||
* @return the created compound tag
|
||||
*/
|
||||
public CompoundTag build(final String name) {
|
||||
return new CompoundTag(name, new HashMap<String, Tag>(entries));
|
||||
public CompoundTag build(String name) {
|
||||
return new CompoundTag(name, new HashMap<String, Tag>(this.entries));
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
||||
* The {@code TAG_Double} tag.
|
||||
*/
|
||||
public final class DoubleTag extends Tag {
|
||||
|
||||
private final double value;
|
||||
|
||||
/**
|
||||
@ -11,8 +12,7 @@ public final class DoubleTag extends Tag {
|
||||
*
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public DoubleTag(final double value) {
|
||||
super();
|
||||
public DoubleTag(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ -22,23 +22,23 @@ public final class DoubleTag extends Tag {
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public DoubleTag(final String name, final double value) {
|
||||
public DoubleTag(String name, double value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final String name = getName();
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if ((name != null) && !name.equals("")) {
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Double" + append + ": " + value;
|
||||
return "TAG_Double" + append + ": " + this.value;
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@ package com.intellectualcrafters.jnbt;
|
||||
* The {@code TAG_End} tag.
|
||||
*/
|
||||
public final class EndTag extends Tag {
|
||||
|
||||
/**
|
||||
* Creates the tag.
|
||||
*/
|
||||
public EndTag() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
||||
* The {@code TAG_Float} tag.
|
||||
*/
|
||||
public final class FloatTag extends Tag {
|
||||
|
||||
private final float value;
|
||||
|
||||
/**
|
||||
@ -11,8 +12,7 @@ public final class FloatTag extends Tag {
|
||||
*
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public FloatTag(final float value) {
|
||||
super();
|
||||
public FloatTag(float value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ -22,23 +22,23 @@ public final class FloatTag extends Tag {
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public FloatTag(final String name, final float value) {
|
||||
public FloatTag(String name, float value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final String name = getName();
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if ((name != null) && !name.equals("")) {
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Float" + append + ": " + value;
|
||||
return "TAG_Float" + append + ": " + this.value;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* The {@code TAG_Int_Array} tag.
|
||||
*/
|
||||
public final class IntArrayTag extends Tag {
|
||||
|
||||
private final int[] value;
|
||||
|
||||
/**
|
||||
@ -13,8 +14,7 @@ public final class IntArrayTag extends Tag {
|
||||
*
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public IntArrayTag(final int[] value) {
|
||||
super();
|
||||
public IntArrayTag(int[] value) {
|
||||
checkNotNull(value);
|
||||
this.value = value;
|
||||
}
|
||||
@ -25,7 +25,7 @@ public final class IntArrayTag extends Tag {
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public IntArrayTag(final String name, final int[] value) {
|
||||
public IntArrayTag(String name, int[] value) {
|
||||
super(name);
|
||||
checkNotNull(value);
|
||||
this.value = value;
|
||||
@ -33,22 +33,22 @@ public final class IntArrayTag extends Tag {
|
||||
|
||||
@Override
|
||||
public int[] getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder hex = new StringBuilder();
|
||||
for (final int b : value) {
|
||||
final String hexDigits = Integer.toHexString(b).toUpperCase();
|
||||
StringBuilder hex = new StringBuilder();
|
||||
for (int b : this.value) {
|
||||
String hexDigits = Integer.toHexString(b).toUpperCase();
|
||||
if (hexDigits.length() == 1) {
|
||||
hex.append("0");
|
||||
}
|
||||
hex.append(hexDigits).append(" ");
|
||||
}
|
||||
final String name = getName();
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if ((name != null) && !name.equals("")) {
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Int_Array" + append + ": " + hex;
|
||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
||||
* The {@code TAG_Int} tag.
|
||||
*/
|
||||
public final class IntTag extends Tag {
|
||||
|
||||
private final int value;
|
||||
|
||||
/**
|
||||
@ -11,8 +12,7 @@ public final class IntTag extends Tag {
|
||||
*
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public IntTag(final int value) {
|
||||
super();
|
||||
public IntTag(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ -22,23 +22,23 @@ public final class IntTag extends Tag {
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public IntTag(final String name, final int value) {
|
||||
public IntTag(String name, int value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final String name = getName();
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if ((name != null) && !name.equals("")) {
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Int" + append + ": " + value;
|
||||
return "TAG_Int" + append + ": " + this.value;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import java.util.NoSuchElementException;
|
||||
* The {@code TAG_List} tag.
|
||||
*/
|
||||
public final class ListTag extends Tag {
|
||||
|
||||
private final Class<? extends Tag> type;
|
||||
private final List<Tag> value;
|
||||
|
||||
@ -19,8 +20,7 @@ public final class ListTag extends Tag {
|
||||
* @param type the type of tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ListTag(final Class<? extends Tag> type, final List<? extends Tag> value) {
|
||||
super();
|
||||
public ListTag(Class<? extends Tag> type, List<? extends Tag> value) {
|
||||
checkNotNull(value);
|
||||
this.type = type;
|
||||
this.value = Collections.unmodifiableList(value);
|
||||
@ -33,7 +33,7 @@ public final class ListTag extends Tag {
|
||||
* @param type the type of tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ListTag(final String name, final Class<? extends Tag> type, final List<? extends Tag> value) {
|
||||
public ListTag(String name, Class<? extends Tag> type, List<? extends Tag> value) {
|
||||
super(name);
|
||||
checkNotNull(value);
|
||||
this.type = type;
|
||||
@ -46,12 +46,12 @@ public final class ListTag extends Tag {
|
||||
* @return The type of item in this list.
|
||||
*/
|
||||
public Class<? extends Tag> getType() {
|
||||
return type;
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tag> getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +61,7 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return a new list tag
|
||||
*/
|
||||
public ListTag setValue(final List<Tag> list) {
|
||||
public ListTag setValue(List<Tag> list) {
|
||||
return new ListTag(getName(), getType(), list);
|
||||
}
|
||||
|
||||
@ -72,10 +72,10 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return the tag or null
|
||||
*/
|
||||
public Tag getIfExists(final int index) {
|
||||
public Tag getIfExists(int index) {
|
||||
try {
|
||||
return value.get(index);
|
||||
} catch (final NoSuchElementException e) {
|
||||
return this.value.get(index);
|
||||
} catch (NoSuchElementException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -88,8 +88,8 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return a byte array
|
||||
*/
|
||||
public byte[] getByteArray(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public byte[] getByteArray(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteArrayTag) {
|
||||
return ((ByteArrayTag) tag).getValue();
|
||||
} else {
|
||||
@ -105,8 +105,8 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return a byte
|
||||
*/
|
||||
public byte getByte(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public byte getByte(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
} else {
|
||||
@ -122,8 +122,8 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return a double
|
||||
*/
|
||||
public double getDouble(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public double getDouble(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof DoubleTag) {
|
||||
return ((DoubleTag) tag).getValue();
|
||||
} else {
|
||||
@ -139,8 +139,8 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return a double
|
||||
*/
|
||||
public double asDouble(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public double asDouble(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
} else if (tag instanceof ShortTag) {
|
||||
@ -166,8 +166,8 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return a float
|
||||
*/
|
||||
public float getFloat(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public float getFloat(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof FloatTag) {
|
||||
return ((FloatTag) tag).getValue();
|
||||
} else {
|
||||
@ -183,8 +183,8 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return an int array
|
||||
*/
|
||||
public int[] getIntArray(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public int[] getIntArray(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof IntArrayTag) {
|
||||
return ((IntArrayTag) tag).getValue();
|
||||
} else {
|
||||
@ -200,8 +200,8 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return an int
|
||||
*/
|
||||
public int getInt(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public int getInt(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof IntTag) {
|
||||
return ((IntTag) tag).getValue();
|
||||
} else {
|
||||
@ -217,8 +217,8 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return an int
|
||||
*/
|
||||
public int asInt(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public int asInt(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
} else if (tag instanceof ShortTag) {
|
||||
@ -244,8 +244,8 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return a list of tags
|
||||
*/
|
||||
public List<Tag> getList(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public List<Tag> getList(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ListTag) {
|
||||
return ((ListTag) tag).getValue();
|
||||
} else {
|
||||
@ -261,12 +261,12 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return a tag list instance
|
||||
*/
|
||||
public ListTag getListTag(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public ListTag getListTag(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ListTag) {
|
||||
return (ListTag) tag;
|
||||
} else {
|
||||
return new ListTag(StringTag.class, Collections.<Tag> emptyList());
|
||||
return new ListTag(StringTag.class, Collections.<Tag>emptyList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,10 +282,10 @@ public final class ListTag extends Tag {
|
||||
* @return a list of tags
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Tag> List<T> getList(final int index, final Class<T> listType) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public <T extends Tag> List<T> getList(int index, Class<T> listType) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ListTag) {
|
||||
final ListTag listTag = (ListTag) tag;
|
||||
ListTag listTag = (ListTag) tag;
|
||||
if (listTag.getType().equals(listType)) {
|
||||
return (List<T>) listTag.getValue();
|
||||
} else {
|
||||
@ -304,8 +304,8 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return a long
|
||||
*/
|
||||
public long getLong(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public long getLong(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof LongTag) {
|
||||
return ((LongTag) tag).getValue();
|
||||
} else {
|
||||
@ -321,8 +321,8 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return a long
|
||||
*/
|
||||
public long asLong(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public long asLong(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ByteTag) {
|
||||
return ((ByteTag) tag).getValue();
|
||||
} else if (tag instanceof ShortTag) {
|
||||
@ -348,8 +348,8 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return a short
|
||||
*/
|
||||
public short getShort(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public short getShort(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof ShortTag) {
|
||||
return ((ShortTag) tag).getValue();
|
||||
} else {
|
||||
@ -365,8 +365,8 @@ public final class ListTag extends Tag {
|
||||
*
|
||||
* @return a string
|
||||
*/
|
||||
public String getString(final int index) {
|
||||
final Tag tag = getIfExists(index);
|
||||
public String getString(int index) {
|
||||
Tag tag = getIfExists(index);
|
||||
if (tag instanceof StringTag) {
|
||||
return ((StringTag) tag).getValue();
|
||||
} else {
|
||||
@ -376,14 +376,16 @@ public final class ListTag extends Tag {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final String name = getName();
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if ((name != null) && !name.equals("")) {
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
final StringBuilder bldr = new StringBuilder();
|
||||
bldr.append("TAG_List").append(append).append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
|
||||
for (final Tag t : value) {
|
||||
StringBuilder bldr = new StringBuilder();
|
||||
bldr.append("TAG_List").append(append).append(": ").append(this.value.size()).append(" entries of type ")
|
||||
.append(NBTUtils.getTypeName(this.type))
|
||||
.append("\r\n{\r\n");
|
||||
for (Tag t : this.value) {
|
||||
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
|
||||
}
|
||||
bldr.append("}");
|
||||
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||
* Helps create list tags.
|
||||
*/
|
||||
public class ListTagBuilder {
|
||||
|
||||
private final Class<? extends Tag> type;
|
||||
private final List<Tag> entries;
|
||||
|
||||
@ -19,10 +20,10 @@ public class ListTagBuilder {
|
||||
*
|
||||
* @param type of tag contained in this list
|
||||
*/
|
||||
ListTagBuilder(final Class<? extends Tag> type) {
|
||||
ListTagBuilder(Class<? extends Tag> type) {
|
||||
checkNotNull(type);
|
||||
this.type = type;
|
||||
entries = new ArrayList<Tag>();
|
||||
this.entries = new ArrayList<Tag>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,7 +33,7 @@ public class ListTagBuilder {
|
||||
*
|
||||
* @return a new builder
|
||||
*/
|
||||
public static ListTagBuilder create(final Class<? extends Tag> type) {
|
||||
public static ListTagBuilder create(Class<? extends Tag> type) {
|
||||
return new ListTagBuilder(type);
|
||||
}
|
||||
|
||||
@ -45,18 +46,18 @@ public class ListTagBuilder {
|
||||
* @return a new builder
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <T extends Tag> ListTagBuilder createWith(final T... entries) {
|
||||
public static <T extends Tag> ListTagBuilder createWith(T... entries) {
|
||||
checkNotNull(entries);
|
||||
if (entries.length == 0) {
|
||||
throw new IllegalArgumentException("This method needs an array of at least one entry");
|
||||
}
|
||||
final Class<? extends Tag> type = entries[0].getClass();
|
||||
Class<? extends Tag> type = entries[0].getClass();
|
||||
for (int i = 1; i < entries.length; i++) {
|
||||
if (!type.isInstance(entries[i])) {
|
||||
throw new IllegalArgumentException("An array of different tag types was provided");
|
||||
}
|
||||
}
|
||||
final ListTagBuilder builder = new ListTagBuilder(type);
|
||||
ListTagBuilder builder = new ListTagBuilder(type);
|
||||
builder.addAll(Arrays.asList(entries));
|
||||
return builder;
|
||||
}
|
||||
@ -68,12 +69,12 @@ public class ListTagBuilder {
|
||||
*
|
||||
* @return this object
|
||||
*/
|
||||
public ListTagBuilder add(final Tag value) {
|
||||
public ListTagBuilder add(Tag value) {
|
||||
checkNotNull(value);
|
||||
if (!type.isInstance(value)) {
|
||||
throw new IllegalArgumentException(value.getClass().getCanonicalName() + " is not of expected type " + type.getCanonicalName());
|
||||
if (!this.type.isInstance(value)) {
|
||||
throw new IllegalArgumentException(value.getClass().getCanonicalName() + " is not of expected type " + this.type.getCanonicalName());
|
||||
}
|
||||
entries.add(value);
|
||||
this.entries.add(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -84,9 +85,9 @@ public class ListTagBuilder {
|
||||
*
|
||||
* @return this object
|
||||
*/
|
||||
public ListTagBuilder addAll(final Collection<? extends Tag> value) {
|
||||
public ListTagBuilder addAll(Collection<? extends Tag> value) {
|
||||
checkNotNull(value);
|
||||
for (final Tag v : value) {
|
||||
for (Tag v : value) {
|
||||
add(v);
|
||||
}
|
||||
return this;
|
||||
@ -98,7 +99,7 @@ public class ListTagBuilder {
|
||||
* @return the new list tag
|
||||
*/
|
||||
public ListTag build() {
|
||||
return new ListTag(type, new ArrayList<Tag>(entries));
|
||||
return new ListTag(this.type, new ArrayList<Tag>(this.entries));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,7 +109,7 @@ public class ListTagBuilder {
|
||||
*
|
||||
* @return the created list tag
|
||||
*/
|
||||
public ListTag build(final String name) {
|
||||
return new ListTag(name, type, new ArrayList<Tag>(entries));
|
||||
public ListTag build(String name) {
|
||||
return new ListTag(name, this.type, new ArrayList<Tag>(this.entries));
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
||||
* The {@code TAG_Long} tag.
|
||||
*/
|
||||
public final class LongTag extends Tag {
|
||||
|
||||
private final long value;
|
||||
|
||||
/**
|
||||
@ -11,8 +12,7 @@ public final class LongTag extends Tag {
|
||||
*
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public LongTag(final long value) {
|
||||
super();
|
||||
public LongTag(long value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ -22,23 +22,23 @@ public final class LongTag extends Tag {
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public LongTag(final String name, final long value) {
|
||||
public LongTag(String name, long value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final String name = getName();
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if ((name != null) && !name.equals("")) {
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Long" + append + ": " + value;
|
||||
return "TAG_Long" + append + ": " + this.value;
|
||||
}
|
||||
}
|
||||
|
@ -9,13 +9,15 @@ import java.nio.charset.StandardCharsets;
|
||||
public final class NBTConstants {
|
||||
|
||||
public static final Charset CHARSET = StandardCharsets.UTF_8;
|
||||
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6, TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9,
|
||||
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2, TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6,
|
||||
TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9,
|
||||
TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11;
|
||||
|
||||
/**
|
||||
* Default private constructor.
|
||||
*/
|
||||
private NBTConstants() {}
|
||||
private NBTConstants() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a type ID to its corresponding {@link Tag} class.
|
||||
@ -26,7 +28,7 @@ public final class NBTConstants {
|
||||
*
|
||||
* @throws IllegalArgumentException thrown if the tag ID is not valid
|
||||
*/
|
||||
public static Class<? extends Tag> getClassFromType(final int id) {
|
||||
public static Class<? extends Tag> getClassFromType(int id) {
|
||||
switch (id) {
|
||||
case TYPE_END:
|
||||
return EndTag.class;
|
||||
|
@ -15,6 +15,7 @@ import java.util.Map;
|
||||
* may be found at @linktourl http://www.minecraft.net/docs/NBT.txt"> http://www.minecraft.net/docs/NBT.txt.
|
||||
*/
|
||||
public final class NBTInputStream implements Closeable {
|
||||
|
||||
private final DataInputStream is;
|
||||
|
||||
private int count;
|
||||
@ -26,7 +27,7 @@ public final class NBTInputStream implements Closeable {
|
||||
*
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
public NBTInputStream(final InputStream is) {
|
||||
public NBTInputStream(InputStream is) {
|
||||
this.is = new DataInputStream(is);
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ public final class NBTInputStream implements Closeable {
|
||||
*
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*/
|
||||
public Tag readTag(final int maxDepth) throws IOException {
|
||||
public Tag readTag(int maxDepth) throws IOException {
|
||||
return readTag(0, maxDepth);
|
||||
}
|
||||
|
||||
@ -61,16 +62,16 @@ public final class NBTInputStream implements Closeable {
|
||||
*
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*/
|
||||
private Tag readTag(final int depth, final int maxDepth) throws IOException {
|
||||
if ((count++) > maxDepth) {
|
||||
throw new IOException("Exceeds max depth: " + count);
|
||||
private Tag readTag(int depth, int maxDepth) throws IOException {
|
||||
if (this.count++ > maxDepth) {
|
||||
throw new IOException("Exceeds max depth: " + this.count);
|
||||
}
|
||||
final int type = is.readByte() & 0xFF;
|
||||
int type = this.is.readByte() & 0xFF;
|
||||
String name;
|
||||
if (type != NBTConstants.TYPE_END) {
|
||||
final int nameLength = is.readShort() & 0xFFFF;
|
||||
final byte[] nameBytes = new byte[nameLength];
|
||||
is.readFully(nameBytes);
|
||||
int nameLength = this.is.readShort() & 0xFFFF;
|
||||
byte[] nameBytes = new byte[nameLength];
|
||||
this.is.readFully(nameBytes);
|
||||
name = new String(nameBytes, NBTConstants.CHARSET);
|
||||
} else {
|
||||
name = "";
|
||||
@ -89,11 +90,11 @@ public final class NBTInputStream implements Closeable {
|
||||
*
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*/
|
||||
private Tag readTagPayload(final int type, final String name, final int depth, final int maxDepth) throws IOException {
|
||||
if ((count++) > maxDepth) {
|
||||
throw new IOException("Exceeds max depth: " + count);
|
||||
private Tag readTagPayload(int type, String name, int depth, int maxDepth) throws IOException {
|
||||
if (this.count++ > maxDepth) {
|
||||
throw new IOException("Exceeds max depth: " + this.count);
|
||||
}
|
||||
count++;
|
||||
this.count++;
|
||||
switch (type) {
|
||||
case NBTConstants.TYPE_END:
|
||||
if (depth == 0) {
|
||||
@ -102,54 +103,54 @@ public final class NBTInputStream implements Closeable {
|
||||
return new EndTag();
|
||||
}
|
||||
case NBTConstants.TYPE_BYTE:
|
||||
return new ByteTag(name, is.readByte());
|
||||
return new ByteTag(name, this.is.readByte());
|
||||
case NBTConstants.TYPE_SHORT:
|
||||
return new ShortTag(name, is.readShort());
|
||||
return new ShortTag(name, this.is.readShort());
|
||||
case NBTConstants.TYPE_INT:
|
||||
return new IntTag(name, is.readInt());
|
||||
return new IntTag(name, this.is.readInt());
|
||||
case NBTConstants.TYPE_LONG:
|
||||
return new LongTag(name, is.readLong());
|
||||
return new LongTag(name, this.is.readLong());
|
||||
case NBTConstants.TYPE_FLOAT:
|
||||
return new FloatTag(name, is.readFloat());
|
||||
return new FloatTag(name, this.is.readFloat());
|
||||
case NBTConstants.TYPE_DOUBLE:
|
||||
return new DoubleTag(name, is.readDouble());
|
||||
return new DoubleTag(name, this.is.readDouble());
|
||||
case NBTConstants.TYPE_BYTE_ARRAY:
|
||||
int length = is.readInt();
|
||||
int length = this.is.readInt();
|
||||
|
||||
// Max depth
|
||||
if ((count += length) > maxDepth) {
|
||||
throw new IOException("Exceeds max depth: " + count);
|
||||
if ((this.count += length) > maxDepth) {
|
||||
throw new IOException("Exceeds max depth: " + this.count);
|
||||
//
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[length];
|
||||
is.readFully(bytes);
|
||||
this.is.readFully(bytes);
|
||||
return new ByteArrayTag(name, bytes);
|
||||
case NBTConstants.TYPE_STRING:
|
||||
length = is.readShort();
|
||||
length = this.is.readShort();
|
||||
|
||||
// Max depth
|
||||
if ((count += length) > maxDepth) {
|
||||
throw new IOException("Exceeds max depth: " + count);
|
||||
if ((this.count += length) > maxDepth) {
|
||||
throw new IOException("Exceeds max depth: " + this.count);
|
||||
//
|
||||
}
|
||||
|
||||
bytes = new byte[length];
|
||||
is.readFully(bytes);
|
||||
this.is.readFully(bytes);
|
||||
return new StringTag(name, new String(bytes, NBTConstants.CHARSET));
|
||||
case NBTConstants.TYPE_LIST:
|
||||
final int childType = is.readByte();
|
||||
length = is.readInt();
|
||||
int childType = this.is.readByte();
|
||||
length = this.is.readInt();
|
||||
|
||||
// Max depth
|
||||
if ((count += length) > maxDepth) {
|
||||
throw new IOException("Exceeds max depth: " + count);
|
||||
if ((this.count += length) > maxDepth) {
|
||||
throw new IOException("Exceeds max depth: " + this.count);
|
||||
//
|
||||
}
|
||||
|
||||
final List<Tag> tagList = new ArrayList<Tag>();
|
||||
List<Tag> tagList = new ArrayList<Tag>();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
final Tag tag = readTagPayload(childType, "", depth + 1, maxDepth);
|
||||
Tag tag = readTagPayload(childType, "", depth + 1, maxDepth);
|
||||
if (tag instanceof EndTag) {
|
||||
throw new IOException("TAG_End not permitted in a list.");
|
||||
}
|
||||
@ -157,9 +158,9 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
return new ListTag(name, NBTUtils.getTypeClass(childType), tagList);
|
||||
case NBTConstants.TYPE_COMPOUND:
|
||||
final Map<String, Tag> tagMap = new HashMap<String, Tag>();
|
||||
Map<String, Tag> tagMap = new HashMap<String, Tag>();
|
||||
while (true) {
|
||||
final Tag tag = readTag(depth + 1, maxDepth);
|
||||
Tag tag = readTag(depth + 1, maxDepth);
|
||||
if (tag instanceof EndTag) {
|
||||
break;
|
||||
} else {
|
||||
@ -168,15 +169,15 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
return new CompoundTag(name, tagMap);
|
||||
case NBTConstants.TYPE_INT_ARRAY:
|
||||
length = is.readInt();
|
||||
length = this.is.readInt();
|
||||
// Max depth
|
||||
if ((count += length) > maxDepth) {
|
||||
throw new IOException("Exceeds max depth: " + count);
|
||||
if ((this.count += length) > maxDepth) {
|
||||
throw new IOException("Exceeds max depth: " + this.count);
|
||||
}
|
||||
//
|
||||
final int[] data = new int[length];
|
||||
int[] data = new int[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
data[i] = is.readInt();
|
||||
data[i] = this.is.readInt();
|
||||
}
|
||||
return new IntArrayTag(name, data);
|
||||
default:
|
||||
@ -186,6 +187,6 @@ public final class NBTInputStream implements Closeable {
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
is.close();
|
||||
this.is.close();
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import java.util.List;
|
||||
* @author Graham Edgecombe
|
||||
*/
|
||||
public final class NBTOutputStream implements Closeable {
|
||||
|
||||
/**
|
||||
* The output stream.
|
||||
*/
|
||||
|
@ -6,10 +6,12 @@ import java.util.Map;
|
||||
* A class which contains NBT-related utility methods.
|
||||
*/
|
||||
public final class NBTUtils {
|
||||
|
||||
/**
|
||||
* Default private constructor.
|
||||
*/
|
||||
private NBTUtils() {}
|
||||
private NBTUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type name of a tag.
|
||||
@ -18,7 +20,7 @@ public final class NBTUtils {
|
||||
*
|
||||
* @return The type name.
|
||||
*/
|
||||
public static String getTypeName(final Class<? extends Tag> clazz) {
|
||||
public static String getTypeName(Class<? extends Tag> clazz) {
|
||||
if (clazz.equals(ByteArrayTag.class)) {
|
||||
return "TAG_Byte_Array";
|
||||
} else if (clazz.equals(ByteTag.class)) {
|
||||
@ -57,7 +59,7 @@ public final class NBTUtils {
|
||||
*
|
||||
* @throws IllegalArgumentException if the tag class is invalid.
|
||||
*/
|
||||
public static int getTypeCode(final Class<? extends Tag> clazz) {
|
||||
public static int getTypeCode(Class<? extends Tag> clazz) {
|
||||
if (clazz.equals(ByteArrayTag.class)) {
|
||||
return NBTConstants.TYPE_BYTE_ARRAY;
|
||||
} else if (clazz.equals(ByteTag.class)) {
|
||||
@ -96,7 +98,7 @@ public final class NBTUtils {
|
||||
*
|
||||
* @throws IllegalArgumentException if the tag type is invalid.
|
||||
*/
|
||||
public static Class<? extends Tag> getTypeClass(final int type) {
|
||||
public static Class<? extends Tag> getTypeClass(int type) {
|
||||
switch (type) {
|
||||
case NBTConstants.TYPE_END:
|
||||
return EndTag.class;
|
||||
@ -137,11 +139,12 @@ public final class NBTUtils {
|
||||
*
|
||||
* @return child tag
|
||||
*/
|
||||
public static <T extends Tag> T getChildTag(final Map<String, Tag> items, final String key, final Class<T> expected) throws IllegalArgumentException {
|
||||
public static <T extends Tag> T getChildTag(Map<String, Tag> items, String key, Class<T> expected)
|
||||
throws IllegalArgumentException {
|
||||
if (!items.containsKey(key)) {
|
||||
throw new IllegalArgumentException("Missing a \"" + key + "\" tag");
|
||||
}
|
||||
final Tag tag = items.get(key);
|
||||
Tag tag = items.get(key);
|
||||
if (!expected.isInstance(tag)) {
|
||||
throw new IllegalArgumentException(key + " tag is not of tag type " + expected.getName());
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
||||
* The {@code TAG_Short} tag.
|
||||
*/
|
||||
public final class ShortTag extends Tag {
|
||||
|
||||
private final short value;
|
||||
|
||||
/**
|
||||
@ -11,8 +12,7 @@ public final class ShortTag extends Tag {
|
||||
*
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ShortTag(final short value) {
|
||||
super();
|
||||
public ShortTag(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ -22,23 +22,23 @@ public final class ShortTag extends Tag {
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public ShortTag(final String name, final short value) {
|
||||
public ShortTag(String name, short value) {
|
||||
super(name);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final String name = getName();
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if ((name != null) && !name.equals("")) {
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Short" + append + ": " + value;
|
||||
return "TAG_Short" + append + ": " + this.value;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* The {@code TAG_String} tag.
|
||||
*/
|
||||
public final class StringTag extends Tag {
|
||||
|
||||
private final String value;
|
||||
|
||||
/**
|
||||
@ -13,8 +14,7 @@ public final class StringTag extends Tag {
|
||||
*
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public StringTag(final String value) {
|
||||
super();
|
||||
public StringTag(String value) {
|
||||
checkNotNull(value);
|
||||
this.value = value;
|
||||
}
|
||||
@ -25,7 +25,7 @@ public final class StringTag extends Tag {
|
||||
* @param name the name of the tag
|
||||
* @param value the value of the tag
|
||||
*/
|
||||
public StringTag(final String name, final String value) {
|
||||
public StringTag(String name, String value) {
|
||||
super(name);
|
||||
checkNotNull(value);
|
||||
this.value = value;
|
||||
@ -33,16 +33,16 @@ public final class StringTag extends Tag {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final String name = getName();
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if ((name != null) && !name.equals("")) {
|
||||
if (name != null && !name.equals("")) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_String" + append + ": " + value;
|
||||
return "TAG_String" + append + ": " + this.value;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ package com.intellectualcrafters.jnbt;
|
||||
* Represents a NBT tag.
|
||||
*/
|
||||
public abstract class Tag {
|
||||
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
@ -31,7 +32,7 @@ public abstract class Tag {
|
||||
* @return the name of this tag
|
||||
*/
|
||||
public final String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ public class JSONArray {
|
||||
* Construct an empty JSONArray.
|
||||
*/
|
||||
public JSONArray() {
|
||||
myArrayList = new ArrayList<Object>();
|
||||
this.myArrayList = new ArrayList<Object>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,7 +56,7 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If there is a syntax error.
|
||||
*/
|
||||
public JSONArray(final JSONTokener x) throws JSONException {
|
||||
public JSONArray(JSONTokener x) throws JSONException {
|
||||
this();
|
||||
if (x.nextClean() != '[') {
|
||||
throw x.syntaxError("A JSONArray text must start with '['");
|
||||
@ -66,10 +66,10 @@ public class JSONArray {
|
||||
for (;;) {
|
||||
if (x.nextClean() == ',') {
|
||||
x.back();
|
||||
myArrayList.add(JSONObject.NULL);
|
||||
this.myArrayList.add(JSONObject.NULL);
|
||||
} else {
|
||||
x.back();
|
||||
myArrayList.add(x.nextValue());
|
||||
this.myArrayList.add(x.nextValue());
|
||||
}
|
||||
switch (x.nextClean()) {
|
||||
case ',':
|
||||
@ -95,7 +95,7 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If there is a syntax error.
|
||||
*/
|
||||
public JSONArray(final String source) throws JSONException {
|
||||
public JSONArray(String source) throws JSONException {
|
||||
this(new JSONTokener(source));
|
||||
}
|
||||
|
||||
@ -104,11 +104,11 @@ public class JSONArray {
|
||||
*
|
||||
* @param collection A Collection.
|
||||
*/
|
||||
public JSONArray(final Collection<Object> collection) {
|
||||
myArrayList = new ArrayList<Object>();
|
||||
public JSONArray(Collection<Object> collection) {
|
||||
this.myArrayList = new ArrayList<Object>();
|
||||
if (collection != null) {
|
||||
for (final Object aCollection : collection) {
|
||||
myArrayList.add(JSONObject.wrap(aCollection));
|
||||
for (Object aCollection : collection) {
|
||||
this.myArrayList.add(JSONObject.wrap(aCollection));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -118,10 +118,10 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If not an array.
|
||||
*/
|
||||
public JSONArray(final Object array) throws JSONException {
|
||||
public JSONArray(Object array) throws JSONException {
|
||||
this();
|
||||
if (array.getClass().isArray()) {
|
||||
final int length = Array.getLength(array);
|
||||
int length = Array.getLength(array);
|
||||
for (int i = 0; i < length; i += 1) {
|
||||
this.put(JSONObject.wrap(Array.get(array, i)));
|
||||
}
|
||||
@ -139,8 +139,8 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If there is no value for the index.
|
||||
*/
|
||||
public Object get(final int index) throws JSONException {
|
||||
final Object object = opt(index);
|
||||
public Object get(int index) throws JSONException {
|
||||
Object object = opt(index);
|
||||
if (object == null) {
|
||||
throw new JSONException("JSONArray[" + index + "] not found.");
|
||||
}
|
||||
@ -156,8 +156,8 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If there is no value for the index or if the value is not convertible to boolean.
|
||||
*/
|
||||
public boolean getBoolean(final int index) throws JSONException {
|
||||
final Object object = get(index);
|
||||
public boolean getBoolean(int index) throws JSONException {
|
||||
Object object = get(index);
|
||||
if (object.equals(Boolean.FALSE) || ((object instanceof String) && ((String) object).equalsIgnoreCase("false"))) {
|
||||
return false;
|
||||
} else if (object.equals(Boolean.TRUE) || ((object instanceof String) && ((String) object).equalsIgnoreCase("true"))) {
|
||||
@ -175,8 +175,8 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If the key is not found or if the value cannot be converted to a number.
|
||||
*/
|
||||
public double getDouble(final int index) throws JSONException {
|
||||
final Object object = get(index);
|
||||
public double getDouble(int index) throws JSONException {
|
||||
Object object = get(index);
|
||||
try {
|
||||
return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object);
|
||||
} catch (NumberFormatException e) {
|
||||
@ -193,8 +193,8 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If the key is not found or if the value is not a number.
|
||||
*/
|
||||
public int getInt(final int index) throws JSONException {
|
||||
final Object object = get(index);
|
||||
public int getInt(int index) throws JSONException {
|
||||
Object object = get(index);
|
||||
try {
|
||||
return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object);
|
||||
} catch (NumberFormatException e) {
|
||||
@ -211,8 +211,8 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If there is no value for the index. or if the value is not a JSONArray
|
||||
*/
|
||||
public JSONArray getJSONArray(final int index) throws JSONException {
|
||||
final Object object = get(index);
|
||||
public JSONArray getJSONArray(int index) throws JSONException {
|
||||
Object object = get(index);
|
||||
if (object instanceof JSONArray) {
|
||||
return (JSONArray) object;
|
||||
}
|
||||
@ -228,8 +228,8 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If there is no value for the index or if the value is not a JSONObject
|
||||
*/
|
||||
public JSONObject getJSONObject(final int index) throws JSONException {
|
||||
final Object object = get(index);
|
||||
public JSONObject getJSONObject(int index) throws JSONException {
|
||||
Object object = get(index);
|
||||
if (object instanceof JSONObject) {
|
||||
return (JSONObject) object;
|
||||
}
|
||||
@ -245,8 +245,8 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If the key is not found or if the value cannot be converted to a number.
|
||||
*/
|
||||
public long getLong(final int index) throws JSONException {
|
||||
final Object object = get(index);
|
||||
public long getLong(int index) throws JSONException {
|
||||
Object object = get(index);
|
||||
try {
|
||||
return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object);
|
||||
} catch (NumberFormatException e) {
|
||||
@ -263,8 +263,8 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If there is no string value for the index.
|
||||
*/
|
||||
public String getString(final int index) throws JSONException {
|
||||
final Object object = get(index);
|
||||
public String getString(int index) throws JSONException {
|
||||
Object object = get(index);
|
||||
if (object instanceof String) {
|
||||
return (String) object;
|
||||
}
|
||||
@ -278,7 +278,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return true if the value at the index is null, or if there is no value.
|
||||
*/
|
||||
public boolean isNull(final int index) {
|
||||
public boolean isNull(int index) {
|
||||
return JSONObject.NULL.equals(opt(index));
|
||||
}
|
||||
|
||||
@ -292,14 +292,14 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If the array contains an invalid number.
|
||||
*/
|
||||
public String join(final String separator) throws JSONException {
|
||||
final int len = length();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
public String join(String separator) throws JSONException {
|
||||
int len = length();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < len; i += 1) {
|
||||
if (i > 0) {
|
||||
sb.append(separator);
|
||||
}
|
||||
sb.append(JSONObject.valueToString(myArrayList.get(i)));
|
||||
sb.append(JSONObject.valueToString(this.myArrayList.get(i)));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
@ -310,7 +310,7 @@ public class JSONArray {
|
||||
* @return The length (or size).
|
||||
*/
|
||||
public int length() {
|
||||
return myArrayList.size();
|
||||
return this.myArrayList.size();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -320,8 +320,8 @@ public class JSONArray {
|
||||
*
|
||||
* @return An object value, or null if there is no object at that index.
|
||||
*/
|
||||
public Object opt(final int index) {
|
||||
return ((index < 0) || (index >= length())) ? null : myArrayList.get(index);
|
||||
public Object opt(int index) {
|
||||
return ((index < 0) || (index >= length())) ? null : this.myArrayList.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -332,7 +332,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return The truth.
|
||||
*/
|
||||
public boolean optBoolean(final int index) {
|
||||
public boolean optBoolean(int index) {
|
||||
return this.optBoolean(index, false);
|
||||
}
|
||||
|
||||
@ -345,7 +345,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return The truth.
|
||||
*/
|
||||
public boolean optBoolean(final int index, final boolean defaultValue) {
|
||||
public boolean optBoolean(int index, boolean defaultValue) {
|
||||
try {
|
||||
return getBoolean(index);
|
||||
} catch (JSONException e) {
|
||||
@ -361,7 +361,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return The value.
|
||||
*/
|
||||
public double optDouble(final int index) {
|
||||
public double optDouble(int index) {
|
||||
return this.optDouble(index, Double.NaN);
|
||||
}
|
||||
|
||||
@ -374,7 +374,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return The value.
|
||||
*/
|
||||
public double optDouble(final int index, final double defaultValue) {
|
||||
public double optDouble(int index, double defaultValue) {
|
||||
try {
|
||||
return getDouble(index);
|
||||
} catch (JSONException e) {
|
||||
@ -390,7 +390,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return The value.
|
||||
*/
|
||||
public int optInt(final int index) {
|
||||
public int optInt(int index) {
|
||||
return this.optInt(index, 0);
|
||||
}
|
||||
|
||||
@ -403,7 +403,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return The value.
|
||||
*/
|
||||
public int optInt(final int index, final int defaultValue) {
|
||||
public int optInt(int index, int defaultValue) {
|
||||
try {
|
||||
return getInt(index);
|
||||
} catch (JSONException e) {
|
||||
@ -418,8 +418,8 @@ public class JSONArray {
|
||||
*
|
||||
* @return A JSONArray value, or null if the index has no value, or if the value is not a JSONArray.
|
||||
*/
|
||||
public JSONArray optJSONArray(final int index) {
|
||||
final Object o = opt(index);
|
||||
public JSONArray optJSONArray(int index) {
|
||||
Object o = opt(index);
|
||||
return o instanceof JSONArray ? (JSONArray) o : null;
|
||||
}
|
||||
|
||||
@ -431,8 +431,8 @@ public class JSONArray {
|
||||
*
|
||||
* @return A JSONObject value.
|
||||
*/
|
||||
public JSONObject optJSONObject(final int index) {
|
||||
final Object o = opt(index);
|
||||
public JSONObject optJSONObject(int index) {
|
||||
Object o = opt(index);
|
||||
return o instanceof JSONObject ? (JSONObject) o : null;
|
||||
}
|
||||
|
||||
@ -444,7 +444,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return The value.
|
||||
*/
|
||||
public long optLong(final int index) {
|
||||
public long optLong(int index) {
|
||||
return this.optLong(index, 0);
|
||||
}
|
||||
|
||||
@ -457,7 +457,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return The value.
|
||||
*/
|
||||
public long optLong(final int index, final long defaultValue) {
|
||||
public long optLong(int index, long defaultValue) {
|
||||
try {
|
||||
return getLong(index);
|
||||
} catch (JSONException e) {
|
||||
@ -467,13 +467,13 @@ public class JSONArray {
|
||||
|
||||
/**
|
||||
* Get the optional string value associated with an index. It returns an empty string if there is no value at that
|
||||
* index. If the value is not a string and is not null, then it is coverted to a string.
|
||||
* index. If the value is not a string and is not null, then it is converted to a string.
|
||||
*
|
||||
* @param index The index must be between 0 and length() - 1.
|
||||
*
|
||||
* @return A String value.
|
||||
*/
|
||||
public String optString(final int index) {
|
||||
public String optString(int index) {
|
||||
return this.optString(index, "");
|
||||
}
|
||||
|
||||
@ -485,8 +485,8 @@ public class JSONArray {
|
||||
*
|
||||
* @return A String value.
|
||||
*/
|
||||
public String optString(final int index, final String defaultValue) {
|
||||
final Object object = opt(index);
|
||||
public String optString(int index, String defaultValue) {
|
||||
Object object = opt(index);
|
||||
return JSONObject.NULL.equals(object) ? defaultValue : object.toString();
|
||||
}
|
||||
|
||||
@ -497,7 +497,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return this.
|
||||
*/
|
||||
public JSONArray put(final boolean value) {
|
||||
public JSONArray put(boolean value) {
|
||||
this.put(value ? Boolean.TRUE : Boolean.FALSE);
|
||||
return this;
|
||||
}
|
||||
@ -509,7 +509,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return this.
|
||||
*/
|
||||
public JSONArray put(final Collection<Object> value) {
|
||||
public JSONArray put(Collection<Object> value) {
|
||||
this.put(new JSONArray(value));
|
||||
return this;
|
||||
}
|
||||
@ -523,8 +523,8 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException if the value is not finite.
|
||||
*/
|
||||
public JSONArray put(final double value) throws JSONException {
|
||||
final Double d = value;
|
||||
public JSONArray put(double value) throws JSONException {
|
||||
Double d = value;
|
||||
JSONObject.testValidity(d);
|
||||
this.put(d);
|
||||
return this;
|
||||
@ -537,7 +537,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return this.
|
||||
*/
|
||||
public JSONArray put(final int value) {
|
||||
public JSONArray put(int value) {
|
||||
this.put(Integer.valueOf(value));
|
||||
return this;
|
||||
}
|
||||
@ -549,7 +549,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return this.
|
||||
*/
|
||||
public JSONArray put(final long value) {
|
||||
public JSONArray put(long value) {
|
||||
this.put(Long.valueOf(value));
|
||||
return this;
|
||||
}
|
||||
@ -561,7 +561,7 @@ public class JSONArray {
|
||||
*
|
||||
* @return this.
|
||||
*/
|
||||
public JSONArray put(final Map<String, Object> value) {
|
||||
public JSONArray put(Map<String, Object> value) {
|
||||
this.put(new JSONObject(value));
|
||||
return this;
|
||||
}
|
||||
@ -574,8 +574,8 @@ public class JSONArray {
|
||||
*
|
||||
* @return this.
|
||||
*/
|
||||
public JSONArray put(final Object value) {
|
||||
myArrayList.add(value);
|
||||
public JSONArray put(Object value) {
|
||||
this.myArrayList.add(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -590,7 +590,7 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If the index is negative.
|
||||
*/
|
||||
public JSONArray put(final int index, final boolean value) throws JSONException {
|
||||
public JSONArray put(int index, boolean value) throws JSONException {
|
||||
this.put(index, value ? Boolean.TRUE : Boolean.FALSE);
|
||||
return this;
|
||||
}
|
||||
@ -605,7 +605,7 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If the index is negative or if the value is not finite.
|
||||
*/
|
||||
public JSONArray put(final int index, final Collection<Object> value) throws JSONException {
|
||||
public JSONArray put(int index, Collection<Object> value) throws JSONException {
|
||||
this.put(index, new JSONArray(value));
|
||||
return this;
|
||||
}
|
||||
@ -621,7 +621,7 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If the index is negative or if the value is not finite.
|
||||
*/
|
||||
public JSONArray put(final int index, final double value) throws JSONException {
|
||||
public JSONArray put(int index, double value) throws JSONException {
|
||||
this.put(index, new Double(value));
|
||||
return this;
|
||||
}
|
||||
@ -637,7 +637,7 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If the index is negative.
|
||||
*/
|
||||
public JSONArray put(final int index, final int value) throws JSONException {
|
||||
public JSONArray put(int index, int value) throws JSONException {
|
||||
this.put(index, Integer.valueOf(value));
|
||||
return this;
|
||||
}
|
||||
@ -653,7 +653,7 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If the index is negative.
|
||||
*/
|
||||
public JSONArray put(final int index, final long value) throws JSONException {
|
||||
public JSONArray put(int index, long value) throws JSONException {
|
||||
this.put(index, Long.valueOf(value));
|
||||
return this;
|
||||
}
|
||||
@ -668,7 +668,7 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If the index is negative or if the the value is an invalid number.
|
||||
*/
|
||||
public JSONArray put(final int index, final Map<String, Object> value) throws JSONException {
|
||||
public JSONArray put(int index, Map<String, Object> value) throws JSONException {
|
||||
this.put(index, new JSONObject(value));
|
||||
return this;
|
||||
}
|
||||
@ -685,13 +685,13 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If the index is negative or if the the value is an invalid number.
|
||||
*/
|
||||
public JSONArray put(final int index, final Object value) throws JSONException {
|
||||
public JSONArray put(int index, Object value) throws JSONException {
|
||||
JSONObject.testValidity(value);
|
||||
if (index < 0) {
|
||||
throw new JSONException("JSONArray[" + index + "] not found.");
|
||||
}
|
||||
if (index < length()) {
|
||||
myArrayList.set(index, value);
|
||||
this.myArrayList.set(index, value);
|
||||
} else {
|
||||
while (index != length()) {
|
||||
this.put(JSONObject.NULL);
|
||||
@ -708,8 +708,8 @@ public class JSONArray {
|
||||
*
|
||||
* @return The value that was associated with the index, or null if there was no value.
|
||||
*/
|
||||
public Object remove(final int index) {
|
||||
return (index >= 0) && (index < length()) ? myArrayList.remove(index) : null;
|
||||
public Object remove(int index) {
|
||||
return (index >= 0) && (index < length()) ? this.myArrayList.remove(index) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -719,17 +719,17 @@ public class JSONArray {
|
||||
*
|
||||
* @return true if they are equal
|
||||
*/
|
||||
public boolean similar(final Object other) {
|
||||
public boolean similar(Object other) {
|
||||
if (!(other instanceof JSONArray)) {
|
||||
return false;
|
||||
}
|
||||
final int len = length();
|
||||
int len = length();
|
||||
if (len != ((JSONArray) other).length()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < len; i += 1) {
|
||||
final Object valueThis = get(i);
|
||||
final Object valueOther = ((JSONArray) other).get(i);
|
||||
Object valueThis = get(i);
|
||||
Object valueOther = ((JSONArray) other).get(i);
|
||||
if (valueThis instanceof JSONObject) {
|
||||
if (!((JSONObject) valueThis).similar(valueOther)) {
|
||||
return false;
|
||||
@ -754,11 +754,11 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException If any of the names are null.
|
||||
*/
|
||||
public JSONObject toJSONObject(final JSONArray names) throws JSONException {
|
||||
public JSONObject toJSONObject(JSONArray names) throws JSONException {
|
||||
if ((names == null) || (names.length() == 0) || (length() == 0)) {
|
||||
return null;
|
||||
}
|
||||
final JSONObject jo = new JSONObject();
|
||||
JSONObject jo = new JSONObject();
|
||||
for (int i = 0; i < names.length(); i += 1) {
|
||||
jo.put(names.getString(i), opt(i));
|
||||
}
|
||||
@ -795,8 +795,8 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
public String toString(final int indentFactor) throws JSONException {
|
||||
final StringWriter sw = new StringWriter();
|
||||
public String toString(int indentFactor) throws JSONException {
|
||||
StringWriter sw = new StringWriter();
|
||||
synchronized (sw.getBuffer()) {
|
||||
return this.write(sw, indentFactor, 0).toString();
|
||||
}
|
||||
@ -811,7 +811,7 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
public Writer write(final Writer writer) throws JSONException {
|
||||
public Writer write(Writer writer) throws JSONException {
|
||||
return this.write(writer, 0, 0);
|
||||
}
|
||||
|
||||
@ -827,15 +827,15 @@ public class JSONArray {
|
||||
*
|
||||
* @throws JSONException
|
||||
*/
|
||||
Writer write(final Writer writer, final int indentFactor, final int indent) throws JSONException {
|
||||
Writer write(Writer writer, int indentFactor, int indent) throws JSONException {
|
||||
try {
|
||||
boolean commanate = false;
|
||||
final int length = length();
|
||||
int length = length();
|
||||
writer.write('[');
|
||||
if (length == 1) {
|
||||
JSONObject.writeValue(writer, myArrayList.get(0), indentFactor, indent);
|
||||
JSONObject.writeValue(writer, this.myArrayList.get(0), indentFactor, indent);
|
||||
} else if (length != 0) {
|
||||
final int newindent = indent + indentFactor;
|
||||
int newindent = indent + indentFactor;
|
||||
for (int i = 0; i < length; i += 1) {
|
||||
if (commanate) {
|
||||
writer.write(',');
|
||||
@ -844,7 +844,7 @@ public class JSONArray {
|
||||
writer.write('\n');
|
||||
}
|
||||
JSONObject.indent(writer, newindent);
|
||||
JSONObject.writeValue(writer, myArrayList.get(i), indentFactor, newindent);
|
||||
JSONObject.writeValue(writer, this.myArrayList.get(i), indentFactor, newindent);
|
||||
commanate = true;
|
||||
}
|
||||
if (indentFactor > 0) {
|
||||
@ -854,7 +854,7 @@ public class JSONArray {
|
||||
}
|
||||
writer.write(']');
|
||||
return writer;
|
||||
} catch (final IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
}
|
||||
|
@ -24,26 +24,26 @@ public interface IPlotMain {
|
||||
|
||||
/**
|
||||
* Log a message to console.
|
||||
* @param message
|
||||
* @param message The message to log
|
||||
*/
|
||||
void log(String message);
|
||||
|
||||
/**
|
||||
* Get the `PlotSquared` directory.
|
||||
* @return
|
||||
* @return The plugin directory
|
||||
*/
|
||||
File getDirectory();
|
||||
|
||||
/**
|
||||
* Get the directory containing all the worlds.
|
||||
* @return
|
||||
* @return The directory containing the worlds
|
||||
*/
|
||||
File getWorldContainer();
|
||||
|
||||
/**
|
||||
* Wrap a player into a PlotPlayer object.
|
||||
* @param player
|
||||
* @return
|
||||
* @param player The player to convert to a PlotPlayer
|
||||
* @return A PlotPlayer
|
||||
*/
|
||||
PlotPlayer wrapPlayer(Object player);
|
||||
|
||||
@ -69,20 +69,20 @@ public interface IPlotMain {
|
||||
int[] getServerVersion();
|
||||
|
||||
/**
|
||||
* Get the nms package prefix.
|
||||
* @return
|
||||
* Get the NMS package prefix.
|
||||
* @return The NMS package prefix
|
||||
*/
|
||||
String getNMSPackage();
|
||||
|
||||
/**
|
||||
* Get the schematic handler.
|
||||
* @return
|
||||
* @return The {@link SchematicHandler}
|
||||
*/
|
||||
SchematicHandler initSchematicHandler();
|
||||
|
||||
/**
|
||||
* Get the schematic handler.
|
||||
* @return
|
||||
* Get the Chat Manager.
|
||||
* @return The {@link ChatManager}
|
||||
*/
|
||||
ChatManager initChatManager();
|
||||
|
||||
@ -176,24 +176,27 @@ public interface IPlotMain {
|
||||
|
||||
/**
|
||||
* If a world is already loaded, set the generator (use NMS if required).
|
||||
* @param world
|
||||
* @param world The world to set the generator
|
||||
*/
|
||||
void setGenerator(String world);
|
||||
|
||||
/**
|
||||
* Get the {@link UUIDHandlerImplementation} which will cache and provide UUIDs.
|
||||
* Get the {@link UUIDHandlerImplementation} which will cache and
|
||||
* provide UUIDs.
|
||||
* @return
|
||||
*/
|
||||
UUIDHandlerImplementation initUUIDHandler();
|
||||
|
||||
/**
|
||||
* Get the {@link InventoryUtil} class (used for implementation specific inventory guis).
|
||||
* Get the {@link InventoryUtil} class (used for implementation specific
|
||||
* inventory guis).
|
||||
* @return
|
||||
*/
|
||||
InventoryUtil initInventoryUtil();
|
||||
|
||||
/**
|
||||
* Run the converter for the implementation (not necessarily PlotMe, just any plugin that we can convert from).
|
||||
* Run the converter for the implementation (not necessarily PlotMe, just
|
||||
* any plugin that we can convert from).
|
||||
* @return
|
||||
*/
|
||||
boolean initPlotMeConverter();
|
||||
@ -212,26 +215,23 @@ public interface IPlotMain {
|
||||
*/
|
||||
GeneratorWrapper<?> getGenerator(String world, String name);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param generator
|
||||
* @return
|
||||
*/
|
||||
GeneratorWrapper<?> wrapPlotGenerator(IndependentPlotGenerator generator);
|
||||
|
||||
/**
|
||||
* Register the chunk processor which will clean out chunks that have too many blockstates or entities.
|
||||
* Register the chunk processor which will clean out chunks that have too
|
||||
* many blockstates or entities.
|
||||
*/
|
||||
void registerChunkProcessor();
|
||||
|
||||
/**
|
||||
* Register the world initialization events (used to keep track of worlds being generated).
|
||||
* Register the world initialization events (used to keep track of worlds
|
||||
* being generated).
|
||||
*/
|
||||
void registerWorldEvents();
|
||||
|
||||
/**
|
||||
* Get the name of the server.
|
||||
* @return
|
||||
* @return The server name
|
||||
*/
|
||||
String getServerName();
|
||||
|
||||
|
@ -53,6 +53,7 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||
import com.plotsquared.listener.WESubscriber;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -89,11 +90,11 @@ import java.util.zip.ZipInputStream;
|
||||
public class PS {
|
||||
|
||||
private static PS instance;
|
||||
private final HashSet<Integer> plotareaHashCheck = new HashSet<>();
|
||||
private final HashSet<Integer> plotAreaHashCheck = new HashSet<>();
|
||||
/**
|
||||
* All plot areas mapped by world (quick world access).
|
||||
*/
|
||||
private final HashMap<String, PlotArea[]> plotareamap = new HashMap<>();
|
||||
private final HashMap<String, PlotArea[]> plotAreaMap = new HashMap<>();
|
||||
/**
|
||||
* All plot areas mapped by location (quick location based access).
|
||||
*/
|
||||
@ -112,7 +113,7 @@ public class PS {
|
||||
public TaskManager TASK;
|
||||
public WorldEdit worldedit;
|
||||
public URL update;
|
||||
private boolean plotareaHasCollision = false;
|
||||
private boolean plotAreaHasCollision = false;
|
||||
/**
|
||||
* All plot areas (quick global access).
|
||||
*/
|
||||
@ -132,7 +133,7 @@ public class PS {
|
||||
*/
|
||||
public PS(IPlotMain imp_class, String platform) {
|
||||
try {
|
||||
instance = this;
|
||||
PS.instance = this;
|
||||
this.thread = Thread.currentThread();
|
||||
SetupUtils.generators = new HashMap<>();
|
||||
this.IMP = imp_class;
|
||||
@ -150,16 +151,16 @@ public class PS {
|
||||
this.version = this.IMP.getPluginVersion();
|
||||
this.platform = platform;
|
||||
if (getJavaVersion() < 1.7) {
|
||||
log(C.CONSOLE_JAVA_OUTDATED_1_7);
|
||||
PS.log(C.CONSOLE_JAVA_OUTDATED_1_7);
|
||||
this.IMP.disable();
|
||||
return;
|
||||
}
|
||||
if (getJavaVersion() < 1.8) {
|
||||
log(C.CONSOLE_JAVA_OUTDATED_1_8);
|
||||
PS.log(C.CONSOLE_JAVA_OUTDATED_1_8);
|
||||
}
|
||||
this.TASK = this.IMP.getTaskManager();
|
||||
if (!C.ENABLED.s().isEmpty()) {
|
||||
log(C.ENABLED);
|
||||
PS.log(C.ENABLED);
|
||||
}
|
||||
setupConfigs();
|
||||
this.translationFile = new File(this.IMP.getDirectory() + File.separator + "translations" + File.separator + "PlotSquared.use_THIS.yml");
|
||||
@ -187,7 +188,7 @@ public class PS {
|
||||
if (Settings.METRICS) {
|
||||
this.IMP.startMetrics();
|
||||
} else {
|
||||
log(C.CONSOLE_PLEASE_ENABLE_METRICS);
|
||||
PS.log(C.CONSOLE_PLEASE_ENABLE_METRICS);
|
||||
}
|
||||
if (Settings.CHUNK_PROCESSOR) {
|
||||
this.IMP.registerChunkProcessor();
|
||||
@ -197,7 +198,7 @@ public class PS {
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PS.debug("Starting UUID caching");
|
||||
debug("Starting UUID caching");
|
||||
UUIDHandler.startCaching(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -224,11 +225,11 @@ public class PS {
|
||||
@Override
|
||||
public void run() {
|
||||
if (PS.this.IMP.initPlotMeConverter()) {
|
||||
log("&c=== IMPORTANT ===");
|
||||
log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
||||
log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
||||
log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
||||
log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the "
|
||||
PS.log("&c=== IMPORTANT ===");
|
||||
PS.log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
||||
PS.log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
||||
PS.log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
||||
PS.log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the "
|
||||
+ "'settings.yml'");
|
||||
}
|
||||
}
|
||||
@ -274,9 +275,10 @@ public class PS {
|
||||
if (url != null) {
|
||||
PS.this.update = url;
|
||||
} else if (PS.this.lastVersion == null) {
|
||||
log("&aThanks for installing PlotSquared!");
|
||||
} else if (!PS.get().checkVersion(PS.this.lastVersion, PS.this.version)) {
|
||||
log("&aThanks for updating from " + StringMan.join(PS.this.lastVersion, ".") + " to " + StringMan.join(PS.this.version, ".")
|
||||
PS.log("&aThanks for installing PlotSquared!");
|
||||
} else if (!get().checkVersion(PS.this.lastVersion, PS.this.version)) {
|
||||
PS.log("&aThanks for updating from " + StringMan.join(PS.this.lastVersion, ".") + " to " + StringMan
|
||||
.join(PS.this.version, ".")
|
||||
+ "!");
|
||||
DBFunc.dbManager.updateTables(PS.this.lastVersion);
|
||||
}
|
||||
@ -302,11 +304,11 @@ public class PS {
|
||||
continue;
|
||||
}
|
||||
if (!WorldUtil.IMP.isWorld(world)) {
|
||||
PS.debug("&c`" + world + "` was not properly loaded - PlotSquared will now try to load it properly: ");
|
||||
PS.debug(
|
||||
debug("&c`" + world + "` was not properly loaded - PlotSquared will now try to load it properly: ");
|
||||
debug(
|
||||
"&8 - &7Are you trying to delete this world? Remember to remove it from the settings.yml, bukkit.yml and "
|
||||
+ "multiverse worlds.yml");
|
||||
PS.debug("&8 - &7Your world management plugin may be faulty (or non existant)");
|
||||
debug("&8 - &7Your world management plugin may be faulty (or non existent)");
|
||||
PS.this.IMP.setGenerator(world);
|
||||
}
|
||||
}
|
||||
@ -334,7 +336,7 @@ public class PS {
|
||||
* @return the instance created by IPlotMain
|
||||
*/
|
||||
public static PS get() {
|
||||
return instance;
|
||||
return PS.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -344,7 +346,7 @@ public class PS {
|
||||
* @see IPlotMain#log(String)
|
||||
*/
|
||||
public static void log(Object message) {
|
||||
get().IMP.log(StringMan.getString(message));
|
||||
PS.get().IMP.log(StringMan.getString(message));
|
||||
}
|
||||
|
||||
public static void stacktrace() {
|
||||
@ -359,7 +361,7 @@ public class PS {
|
||||
*/
|
||||
public static void debug(Object message) {
|
||||
if (Settings.DEBUG) {
|
||||
log(message);
|
||||
PS.log(message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -441,14 +443,14 @@ public class PS {
|
||||
int hash = world.hashCode();
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
if (hash == area.worldhash) {
|
||||
if (area.contains(location.getX(), location.getZ()) && (!this.plotareaHasCollision || world.equals(area.worldname))) {
|
||||
if (area.contains(location.getX(), location.getZ()) && (!this.plotAreaHasCollision || world.equals(area.worldname))) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
PlotArea[] areas = this.plotareamap.get(location.getWorld());
|
||||
PlotArea[] areas = this.plotAreaMap.get(location.getWorld());
|
||||
if (areas == null) {
|
||||
return null;
|
||||
}
|
||||
@ -480,7 +482,7 @@ public class PS {
|
||||
}
|
||||
|
||||
public PlotArea getPlotArea(String world, String id) {
|
||||
PlotArea[] areas = this.plotareamap.get(world);
|
||||
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||
if (areas == null) {
|
||||
return null;
|
||||
}
|
||||
@ -499,7 +501,7 @@ public class PS {
|
||||
}
|
||||
|
||||
public PlotArea getPlotAreaAbs(String world, String id) {
|
||||
PlotArea[] areas = this.plotareamap.get(world);
|
||||
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||
if (areas == null) {
|
||||
return null;
|
||||
}
|
||||
@ -513,7 +515,7 @@ public class PS {
|
||||
|
||||
public PlotArea getPlotAreaByString(String search) {
|
||||
String[] split = search.split(";|,");
|
||||
PlotArea[] areas = this.plotareamap.get(split[0]);
|
||||
PlotArea[] areas = this.plotAreaMap.get(split[0]);
|
||||
if (areas == null) {
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
if (area.worldname.equalsIgnoreCase(split[0])) {
|
||||
@ -570,14 +572,14 @@ public class PS {
|
||||
int hash = world.hashCode();
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
if (hash == area.worldhash) {
|
||||
if (area.contains(location.getX(), location.getZ()) && (!this.plotareaHasCollision || world.equals(area.worldname))) {
|
||||
if (area.contains(location.getX(), location.getZ()) && (!this.plotAreaHasCollision || world.equals(area.worldname))) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
PlotArea[] areas = this.plotareamap.get(location.getWorld());
|
||||
PlotArea[] areas = this.plotAreaMap.get(location.getWorld());
|
||||
if (areas == null) {
|
||||
return null;
|
||||
}
|
||||
@ -630,13 +632,13 @@ public class PS {
|
||||
if (plotArea.TYPE == 2) {
|
||||
plots = this.plots_tmp.get(plotArea.worldname);
|
||||
if (plots != null) {
|
||||
Iterator<Entry<PlotId, Plot>> iter = plots.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Entry<PlotId, Plot> next = iter.next();
|
||||
Iterator<Entry<PlotId, Plot>> iterator = plots.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Entry<PlotId, Plot> next = iterator.next();
|
||||
PlotId id = next.getKey();
|
||||
if (plotArea.contains(id)) {
|
||||
next.getValue().setArea(plotArea);
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -652,12 +654,12 @@ public class PS {
|
||||
if (plotArea.TYPE == 2) {
|
||||
clusters = this.clusters_tmp.get(plotArea.worldname);
|
||||
if (clusters != null) {
|
||||
Iterator<PlotCluster> iter = clusters.iterator();
|
||||
while (iter.hasNext()) {
|
||||
PlotCluster next = iter.next();
|
||||
Iterator<PlotCluster> iterator = clusters.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
PlotCluster next = iterator.next();
|
||||
if (next.intersects(plotArea.getMin(), plotArea.getMax())) {
|
||||
next.setArea(plotArea);
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -672,7 +674,7 @@ public class PS {
|
||||
localAreas.add(plotArea);
|
||||
globalAreas.add(plotArea);
|
||||
this.plotAreas = globalAreas.toArray(new PlotArea[globalAreas.size()]);
|
||||
this.plotareamap.put(plotArea.worldname, localAreas.toArray(new PlotArea[localAreas.size()]));
|
||||
this.plotAreaMap.put(plotArea.worldname, localAreas.toArray(new PlotArea[localAreas.size()]));
|
||||
QuadMap<PlotArea> map = this.plotAreaGrid.get(plotArea.worldname);
|
||||
if (map == null) {
|
||||
map = new QuadMap<PlotArea>(Integer.MAX_VALUE, 0, 0) {
|
||||
@ -697,10 +699,10 @@ public class PS {
|
||||
areas.remove(area);
|
||||
this.plotAreas = areas.toArray(new PlotArea[areas.size()]);
|
||||
if (areas.isEmpty()) {
|
||||
this.plotareamap.remove(area.worldname);
|
||||
this.plotAreaMap.remove(area.worldname);
|
||||
this.plotAreaGrid.remove(area.worldname);
|
||||
} else {
|
||||
this.plotareamap.put(area.worldname, areas.toArray(new PlotArea[areas.size()]));
|
||||
this.plotAreaMap.put(area.worldname, areas.toArray(new PlotArea[areas.size()]));
|
||||
this.plotAreaGrid.get(area.worldname).remove(area);
|
||||
}
|
||||
setPlotsTmp(area);
|
||||
@ -922,26 +924,26 @@ public class PS {
|
||||
|
||||
@Deprecated
|
||||
public ArrayList<Plot> sortPlotsByTimestamp(Collection<Plot> plots) {
|
||||
int hardmax = 256000;
|
||||
int hardMax = 256000;
|
||||
int max = 0;
|
||||
int overflowSize = 0;
|
||||
for (Plot plot : plots) {
|
||||
int hash = MathMan.getPositiveId(plot.hashCode());
|
||||
if (hash > max) {
|
||||
if (hash >= hardmax) {
|
||||
if (hash >= hardMax) {
|
||||
overflowSize++;
|
||||
} else {
|
||||
max = hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
hardmax = Math.min(hardmax, max);
|
||||
Plot[] cache = new Plot[hardmax + 1];
|
||||
hardMax = Math.min(hardMax, max);
|
||||
Plot[] cache = new Plot[hardMax + 1];
|
||||
List<Plot> overflow = new ArrayList<>(overflowSize);
|
||||
ArrayList<Plot> extra = new ArrayList<>();
|
||||
for (Plot plot : plots) {
|
||||
int hash = MathMan.getPositiveId(plot.hashCode());
|
||||
if (hash < hardmax) {
|
||||
if (hash < hardMax) {
|
||||
if (hash >= 0) {
|
||||
cache[hash] = plot;
|
||||
} else {
|
||||
@ -1025,17 +1027,17 @@ public class PS {
|
||||
|
||||
/**
|
||||
* Sort a collection of plots by world (with a priority world), then by hashcode.
|
||||
* @param myplots
|
||||
* @param myPlots
|
||||
* @param type The sorting method to use for each world (timestamp, or hash)
|
||||
* @param priorityArea Use null, "world", or "gibberish" if you want default world order
|
||||
* @return ArrayList of plot
|
||||
*/
|
||||
public ArrayList<Plot> sortPlots(Collection<Plot> myplots, SortType type, final PlotArea priorityArea) {
|
||||
public ArrayList<Plot> sortPlots(Collection<Plot> myPlots, SortType type, final PlotArea priorityArea) {
|
||||
// group by world
|
||||
// sort each
|
||||
HashMap<PlotArea, Collection<Plot>> map = new HashMap<>();
|
||||
int totalSize = getPlotCount();
|
||||
if (myplots.size() == totalSize) {
|
||||
if (myPlots.size() == totalSize) {
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
map.put(area, area.getPlots());
|
||||
}
|
||||
@ -1045,7 +1047,7 @@ public class PS {
|
||||
}
|
||||
Collection<Plot> lastList = null;
|
||||
PlotArea lastWorld = null;
|
||||
for (Plot plot : myplots) {
|
||||
for (Plot plot : myPlots) {
|
||||
if (lastWorld == plot.getArea()) {
|
||||
lastList.add(plot);
|
||||
} else {
|
||||
@ -1065,7 +1067,7 @@ public class PS {
|
||||
return a.hashCode() - b.hashCode();
|
||||
}
|
||||
});
|
||||
ArrayList<Plot> toReturn = new ArrayList<>(myplots.size());
|
||||
ArrayList<Plot> toReturn = new ArrayList<>(myPlots.size());
|
||||
for (PlotArea area : areas) {
|
||||
switch (type) {
|
||||
case CREATION_DATE:
|
||||
@ -1137,15 +1139,15 @@ public class PS {
|
||||
* @return Set of plot
|
||||
*/
|
||||
public Set<Plot> getPlots(String world, UUID uuid) {
|
||||
ArrayList<Plot> myplots = new ArrayList<>();
|
||||
ArrayList<Plot> myPlots = new ArrayList<>();
|
||||
for (Plot plot : getPlots(world)) {
|
||||
if (plot.hasOwner()) {
|
||||
if (plot.isOwnerAbs(uuid)) {
|
||||
myplots.add(plot);
|
||||
myPlots.add(plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new HashSet<>(myplots);
|
||||
return new HashSet<>(myPlots);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1175,7 +1177,7 @@ public class PS {
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isPlotWorld(String world) {
|
||||
return this.plotareamap.containsKey(world);
|
||||
return this.plotAreaMap.containsKey(world);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1190,7 +1192,7 @@ public class PS {
|
||||
return false;
|
||||
case 1:
|
||||
PlotArea a = this.plotAreas[0];
|
||||
return world.hashCode() == a.worldhash && (!this.plotareaHasCollision || a.worldname.equals(world));
|
||||
return world.hashCode() == a.worldhash && (!this.plotAreaHasCollision || a.worldname.equals(world));
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
@ -1200,13 +1202,13 @@ public class PS {
|
||||
case 8:
|
||||
int hash = world.hashCode();
|
||||
for (PlotArea area : this.plotAreas) {
|
||||
if (area.worldhash == hash && (!this.plotareaHasCollision || area.worldname.equals(world))) {
|
||||
if (area.worldhash == hash && (!this.plotAreaHasCollision || area.worldname.equals(world))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
default:
|
||||
return this.plotareamap.containsKey(world);
|
||||
return this.plotAreaMap.containsKey(world);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1248,16 +1250,16 @@ public class PS {
|
||||
* @return Set of Plot
|
||||
*/
|
||||
public Set<Plot> getPlots(final UUID uuid) {
|
||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
||||
final ArrayList<Plot> myPlots = new ArrayList<>();
|
||||
foreachPlot(new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(Plot value) {
|
||||
if (value.isOwnerAbs(uuid)) {
|
||||
myplots.add(value);
|
||||
myPlots.add(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
return new HashSet<>(myplots);
|
||||
return new HashSet<>(myPlots);
|
||||
}
|
||||
|
||||
public Set<Plot> getBasePlots(final UUID uuid) {
|
||||
@ -1274,21 +1276,21 @@ public class PS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plots for a UUID
|
||||
* @param uuid
|
||||
* Get the plots for a UUID.
|
||||
* @param uuid The UUID of the owner
|
||||
* @return Set of Plot
|
||||
*/
|
||||
public Set<Plot> getPlotsAbs(final UUID uuid) {
|
||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
||||
final ArrayList<Plot> myPlots = new ArrayList<>();
|
||||
foreachPlot(new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(Plot value) {
|
||||
if (value.isOwnerAbs(uuid)) {
|
||||
myplots.add(value);
|
||||
myPlots.add(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
return new HashSet<>(myplots);
|
||||
return new HashSet<>(myPlots);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1332,16 +1334,16 @@ public class PS {
|
||||
if (world.equals("CheckingPlotSquaredGenerator")) {
|
||||
return;
|
||||
}
|
||||
if (!this.plotareaHasCollision && !this.plotareaHashCheck.add(world.hashCode())) {
|
||||
this.plotareaHasCollision = true;
|
||||
if (!this.plotAreaHasCollision && !this.plotAreaHashCheck.add(world.hashCode())) {
|
||||
this.plotAreaHasCollision = true;
|
||||
}
|
||||
Set<String> worlds = this.config.contains("worlds") ? this.config.getConfigurationSection("worlds").getKeys(false) : new HashSet<String>();
|
||||
String path = "worlds." + world;
|
||||
ConfigurationSection worldSection = this.config.getConfigurationSection(path);
|
||||
int type = worldSection != null ? worldSection.getInt("generator.type") : 0;
|
||||
if (type == 0) {
|
||||
if (this.plotareamap.containsKey(world)) {
|
||||
PS.debug("World possibly already loaded: " + world);
|
||||
if (this.plotAreaMap.containsKey(world)) {
|
||||
debug("World possibly already loaded: " + world);
|
||||
return;
|
||||
}
|
||||
IndependentPlotGenerator pg;
|
||||
@ -1367,10 +1369,10 @@ public class PS {
|
||||
// Conventional plot generator
|
||||
PlotArea plotArea = pg.getNewPlotArea(world, null, null, null);
|
||||
PlotManager plotManager = pg.getNewPlotManager();
|
||||
log(C.PREFIX + "&aDetected world load for '" + world + "'");
|
||||
log(C.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + pg);
|
||||
log(C.PREFIX + "&3 - plotworld: &7" + plotArea.getClass().getName());
|
||||
log(C.PREFIX + "&3 - manager: &7" + plotManager.getClass().getName());
|
||||
PS.log(C.PREFIX + "&aDetected world load for '" + world + "'");
|
||||
PS.log(C.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + pg);
|
||||
PS.log(C.PREFIX + "&3 - plotworld: &7" + plotArea.getClass().getName());
|
||||
PS.log(C.PREFIX + "&3 - manager: &7" + plotManager.getClass().getName());
|
||||
if (!this.config.contains(path)) {
|
||||
this.config.createSection(path);
|
||||
worldSection = this.config.getConfigurationSection(path);
|
||||
@ -1392,11 +1394,11 @@ public class PS {
|
||||
}
|
||||
ConfigurationSection areasSection = worldSection.getConfigurationSection("areas");
|
||||
if (areasSection == null) {
|
||||
if (this.plotareamap.containsKey(world)) {
|
||||
PS.debug("World possibly already loaded: " + world);
|
||||
if (this.plotAreaMap.containsKey(world)) {
|
||||
debug("World possibly already loaded: " + world);
|
||||
return;
|
||||
}
|
||||
log(C.PREFIX + "&aDetected world load for '" + world + "'");
|
||||
PS.log(C.PREFIX + "&aDetected world load for '" + world + "'");
|
||||
String gen_string = worldSection.getString("generator.plugin", "PlotSquared");
|
||||
if (type == 2) {
|
||||
Set<PlotCluster> clusters = this.clusters_tmp != null ? this.clusters_tmp.get(world) : new HashSet<PlotCluster>();
|
||||
@ -1412,7 +1414,7 @@ public class PS {
|
||||
worldSection.createSection("areas." + fullId);
|
||||
DBFunc.replaceWorld(world, world + ";" + name, pos1, pos2); // NPE
|
||||
|
||||
log(C.PREFIX + "&3 - " + name + "-" + pos1 + "-" + pos2);
|
||||
PS.log(C.PREFIX + "&3 - " + name + "-" + pos1 + "-" + pos2);
|
||||
GeneratorWrapper<?> areaGen = this.IMP.getGenerator(world, gen_string);
|
||||
if (areaGen == null) {
|
||||
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
|
||||
@ -1425,10 +1427,10 @@ public class PS {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log(C.PREFIX + "&c | &9generator: &7" + baseGenerator + ">" + areaGen);
|
||||
log(C.PREFIX + "&c | &9plotworld: &7" + pa);
|
||||
log(C.PREFIX + "&c | &9manager: &7" + pa);
|
||||
log(C.PREFIX + "&cNote: &7Area created for cluster:" + name + " (invalid or old configuration?)");
|
||||
PS.log(C.PREFIX + "&c | &9generator: &7" + baseGenerator + ">" + areaGen);
|
||||
PS.log(C.PREFIX + "&c | &9plotworld: &7" + pa);
|
||||
PS.log(C.PREFIX + "&c | &9manager: &7" + pa);
|
||||
PS.log(C.PREFIX + "&cNote: &7Area created for cluster:" + name + " (invalid or old configuration?)");
|
||||
areaGen.getPlotGenerator().initialize(pa);
|
||||
areaGen.augment(pa);
|
||||
toLoad.add(pa);
|
||||
@ -1450,9 +1452,9 @@ public class PS {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log(C.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + areaGen);
|
||||
log(C.PREFIX + "&3 - plotworld: &7" + pa);
|
||||
log(C.PREFIX + "&3 - manager: &7" + pa.getPlotManager());
|
||||
PS.log(C.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + areaGen);
|
||||
PS.log(C.PREFIX + "&3 - plotworld: &7" + pa);
|
||||
PS.log(C.PREFIX + "&3 - manager: &7" + pa.getPlotManager());
|
||||
areaGen.getPlotGenerator().initialize(pa);
|
||||
areaGen.augment(pa);
|
||||
addPlotArea(pa);
|
||||
@ -1462,7 +1464,7 @@ public class PS {
|
||||
throw new IllegalArgumentException("Invalid type for multi-area world. Expected `2`, got `" + type + "`");
|
||||
}
|
||||
for (String areaId : areasSection.getKeys(false)) {
|
||||
log(C.PREFIX + "&3 - " + areaId);
|
||||
PS.log(C.PREFIX + "&3 - " + areaId);
|
||||
int i1 = areaId.indexOf("-");
|
||||
int i2 = areaId.indexOf(";");
|
||||
if (i1 == -1 || i2 == -1) {
|
||||
@ -1524,10 +1526,10 @@ public class PS {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log(C.PREFIX + "&aDetected area load for '" + world + "'");
|
||||
log(C.PREFIX + "&c | &9generator: &7" + baseGenerator + ">" + areaGen);
|
||||
log(C.PREFIX + "&c | &9plotworld: &7" + pa);
|
||||
log(C.PREFIX + "&c | &9manager: &7" + pa.getPlotManager());
|
||||
PS.log(C.PREFIX + "&aDetected area load for '" + world + "'");
|
||||
PS.log(C.PREFIX + "&c | &9generator: &7" + baseGenerator + ">" + areaGen);
|
||||
PS.log(C.PREFIX + "&c | &9plotworld: &7" + pa);
|
||||
PS.log(C.PREFIX + "&c | &9manager: &7" + pa.getPlotManager());
|
||||
areaGen.getPlotGenerator().initialize(pa);
|
||||
areaGen.augment(pa);
|
||||
addPlotArea(pa);
|
||||
@ -1550,7 +1552,7 @@ public class PS {
|
||||
for (String element : split) {
|
||||
String[] pair = element.split("=");
|
||||
if (pair.length != 2) {
|
||||
log("&cNo value provided for: &7" + element);
|
||||
PS.log("&cNo value provided for: &7" + element);
|
||||
return false;
|
||||
}
|
||||
String key = pair[0].toLowerCase();
|
||||
@ -1559,52 +1561,44 @@ public class PS {
|
||||
try {
|
||||
switch (key) {
|
||||
case "s":
|
||||
case "size": {
|
||||
case "size":
|
||||
this.config.set(base + "plot.size", Configuration.INTEGER.parseString(value).shortValue());
|
||||
break;
|
||||
}
|
||||
case "g":
|
||||
case "gap": {
|
||||
case "gap":
|
||||
this.config.set(base + "road.width", Configuration.INTEGER.parseString(value).shortValue());
|
||||
break;
|
||||
}
|
||||
case "h":
|
||||
case "height": {
|
||||
case "height":
|
||||
this.config.set(base + "road.height", Configuration.INTEGER.parseString(value).shortValue());
|
||||
this.config.set(base + "plot.height", Configuration.INTEGER.parseString(value).shortValue());
|
||||
this.config.set(base + "wall.height", Configuration.INTEGER.parseString(value).shortValue());
|
||||
break;
|
||||
}
|
||||
case "f":
|
||||
case "floor": {
|
||||
case "floor":
|
||||
this.config.set(base + "plot.floor",
|
||||
new ArrayList<>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
|
||||
break;
|
||||
}
|
||||
case "m":
|
||||
case "main": {
|
||||
case "main":
|
||||
this.config.set(base + "plot.filling",
|
||||
new ArrayList<>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
|
||||
break;
|
||||
}
|
||||
case "w":
|
||||
case "wall": {
|
||||
case "wall":
|
||||
this.config.set(base + "wall.filling", Configuration.BLOCK.parseString(value).toString());
|
||||
break;
|
||||
}
|
||||
case "b":
|
||||
case "border": {
|
||||
case "border":
|
||||
this.config.set(base + "wall.block", Configuration.BLOCK.parseString(value).toString());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
log("&cKey not found: &7" + element);
|
||||
default:
|
||||
PS.log("&cKey not found: &7" + element);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log("&cInvalid value: &7" + value + " in arg " + element);
|
||||
PS.log("&cInvalid value: &7" + value + " in arg " + element);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1660,9 +1654,9 @@ public class PS {
|
||||
} catch (IOException e) {
|
||||
MainUtil.sendMessage(sender, "Failed to update PlotSquared");
|
||||
MainUtil.sendMessage(sender, " - Please update manually");
|
||||
log("============ Stacktrace ============");
|
||||
PS.log("============ Stacktrace ============");
|
||||
e.printStackTrace();
|
||||
log("====================================");
|
||||
PS.log("====================================");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1716,7 +1710,7 @@ public class PS {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log("&cCould not save " + file);
|
||||
PS.log("&cCould not save " + file);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1754,7 +1748,7 @@ public class PS {
|
||||
DBFunc.close();
|
||||
UUIDHandler.handleShutdown();
|
||||
} catch (NullPointerException e) {
|
||||
log("&cCould not close database connection!");
|
||||
PS.log("&cCould not close database connection!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1764,8 +1758,8 @@ public class PS {
|
||||
public void setupDatabase() {
|
||||
try {
|
||||
if (Settings.DB.USE_MONGO) {
|
||||
log(C.PREFIX + "MongoDB is not yet implemented");
|
||||
log(C.PREFIX + "&cNo storage type is set!");
|
||||
PS.log(C.PREFIX + "MongoDB is not yet implemented");
|
||||
PS.log(C.PREFIX + "&cNo storage type is set!");
|
||||
this.IMP.disable();
|
||||
return;
|
||||
}
|
||||
@ -1775,7 +1769,7 @@ public class PS {
|
||||
} else if (Settings.DB.USE_SQLITE) {
|
||||
this.database = new SQLite(this.IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db");
|
||||
} else {
|
||||
log(C.PREFIX + "&cNo storage type is set!");
|
||||
PS.log(C.PREFIX + "&cNo storage type is set!");
|
||||
this.IMP.disable();
|
||||
return;
|
||||
}
|
||||
@ -1784,18 +1778,18 @@ public class PS {
|
||||
this.plots_tmp = DBFunc.getPlots();
|
||||
this.clusters_tmp = DBFunc.getClusters();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
log(C.PREFIX + "&cFailed to open DATABASE connection. The plugin will disable itself.");
|
||||
PS.log(C.PREFIX + "&cFailed to open DATABASE connection. The plugin will disable itself.");
|
||||
if (Settings.DB.USE_MONGO) {
|
||||
log("$4MONGO");
|
||||
PS.log("$4MONGO");
|
||||
} else if (Settings.DB.USE_MYSQL) {
|
||||
log("$4MYSQL");
|
||||
PS.log("$4MYSQL");
|
||||
} else if (Settings.DB.USE_SQLITE) {
|
||||
log("$4SQLITE");
|
||||
PS.log("$4SQLITE");
|
||||
}
|
||||
log("&d==== Here is an ugly stacktrace, if you are interested in those things ===");
|
||||
PS.log("&d==== Here is an ugly stacktrace, if you are interested in those things ===");
|
||||
e.printStackTrace();
|
||||
log("&d==== End of stacktrace ====");
|
||||
log("&6Please go to the PlotSquared 'storage.yml' and configure the database correctly.");
|
||||
PS.log("&d==== End of stacktrace ====");
|
||||
PS.log("&6Please go to the PlotSquared 'storage.yml' and configure the database correctly.");
|
||||
this.IMP.disable();
|
||||
}
|
||||
}
|
||||
@ -1995,15 +1989,15 @@ public class PS {
|
||||
if (keep > 0 || ignore > 0) {
|
||||
options.put("clear.auto.threshold", 1);
|
||||
options.put("clear.auto.enabled", false);
|
||||
log("&cIMPORTANT MESSAGE ABOUT THIS UPDATE!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
log("&cSorry for all the exclamation marks, but this could be important.");
|
||||
log("&cPlot clearing has changed to a new system that requires calibration.");
|
||||
log("&cThis is how it will work: ");
|
||||
log("&c - Players will rate plots");
|
||||
log("&c - When enough plots are rated, you can run /plot debugexec calibrate-analysis");
|
||||
log("&c - You can decide the (rough) percentage of expired plots to clear");
|
||||
log("&c - To just clear all expired plot, ignore this and set: &7threshold: -1");
|
||||
log("&cMore information:&7 https://github.com/IntellectualSites/PlotSquared/wiki/Plot-analysis:");
|
||||
PS.log("&cIMPORTANT MESSAGE ABOUT THIS UPDATE!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
PS.log("&cSorry for all the exclamation marks, but this could be important.");
|
||||
PS.log("&cPlot clearing has changed to a new system that requires calibration.");
|
||||
PS.log("&cThis is how it will work: ");
|
||||
PS.log("&c - Players will rate plots");
|
||||
PS.log("&c - When enough plots are rated, you can run /plot debugexec calibrate-analysis");
|
||||
PS.log("&c - You can decide the (rough) percentage of expired plots to clear");
|
||||
PS.log("&c - To just clear all expired plot, ignore this and set: &7threshold: -1");
|
||||
PS.log("&cMore information:&7 https://github.com/IntellectualSites/PlotSquared/wiki/Plot-analysis:");
|
||||
} else {
|
||||
options.put("clear.auto.threshold", Settings.CLEAR_THRESHOLD);
|
||||
}
|
||||
@ -2171,7 +2165,7 @@ public class PS {
|
||||
Settings.MAX_AUTO_SIZE = this.config.getInt("claim.max-auto-area");
|
||||
Settings.MAX_PLOTS = this.config.getInt("max_plots");
|
||||
if (Settings.MAX_PLOTS > 32767) {
|
||||
log("&c`max_plots` Is set too high! This is a per player setting and does not need to be very large.");
|
||||
PS.log("&c`max_plots` Is set too high! This is a per player setting and does not need to be very large.");
|
||||
Settings.MAX_PLOTS = 32767;
|
||||
}
|
||||
Settings.GLOBAL_LIMIT = this.config.getBoolean("global_limit");
|
||||
@ -2179,7 +2173,7 @@ public class PS {
|
||||
// Misc
|
||||
Settings.DEBUG = this.config.getBoolean("debug");
|
||||
if (Settings.DEBUG) {
|
||||
log(C.PREFIX + "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
|
||||
PS.log(C.PREFIX + "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
|
||||
}
|
||||
Settings.CONSOLE_COLOR = this.config.getBoolean("console.color");
|
||||
if (!this.config.getBoolean("chat.fancy") || !checkVersion(this.IMP.getServerVersion(), 1, 8, 0)) {
|
||||
@ -2200,7 +2194,7 @@ public class PS {
|
||||
public void setupConfigs() {
|
||||
File folder = new File(this.IMP.getDirectory() + File.separator + "config");
|
||||
if (!folder.exists() && !folder.mkdirs()) {
|
||||
log(C.PREFIX + "&cFailed to create the /plugins/config folder. Please create it manually.");
|
||||
PS.log(C.PREFIX + "&cFailed to create the /plugins/config folder. Please create it manually.");
|
||||
}
|
||||
try {
|
||||
this.styleFile = new File(this.IMP.getDirectory() + File.separator + "translations" + File.separator + "style.yml");
|
||||
@ -2209,50 +2203,50 @@ public class PS {
|
||||
this.styleFile.getParentFile().mkdirs();
|
||||
}
|
||||
if (!this.styleFile.createNewFile()) {
|
||||
log("Could not create the style file, please create \"translations/style.yml\" manually");
|
||||
PS.log("Could not create the style file, please create \"translations/style.yml\" manually");
|
||||
}
|
||||
}
|
||||
this.style = YamlConfiguration.loadConfiguration(this.styleFile);
|
||||
setupStyle();
|
||||
} catch (IOException err) {
|
||||
err.printStackTrace();
|
||||
log("failed to save style.yml");
|
||||
PS.log("failed to save style.yml");
|
||||
}
|
||||
try {
|
||||
this.configFile = new File(this.IMP.getDirectory() + File.separator + "config" + File.separator + "settings.yml");
|
||||
if (!this.configFile.exists()) {
|
||||
if (!this.configFile.createNewFile()) {
|
||||
log("Could not create the settings file, please create \"settings.yml\" manually.");
|
||||
PS.log("Could not create the settings file, please create \"settings.yml\" manually.");
|
||||
}
|
||||
}
|
||||
this.config = YamlConfiguration.loadConfiguration(this.configFile);
|
||||
setupConfig();
|
||||
} catch (IOException err_trans) {
|
||||
log("Failed to save settings.yml");
|
||||
PS.log("Failed to save settings.yml");
|
||||
}
|
||||
try {
|
||||
this.storageFile = new File(this.IMP.getDirectory() + File.separator + "config" + File.separator + "storage.yml");
|
||||
if (!this.storageFile.exists()) {
|
||||
if (!this.storageFile.createNewFile()) {
|
||||
log("Could not the storage settings file, please create \"storage.yml\" manually.");
|
||||
PS.log("Could not the storage settings file, please create \"storage.yml\" manually.");
|
||||
}
|
||||
}
|
||||
this.storage = YamlConfiguration.loadConfiguration(this.storageFile);
|
||||
setupStorage();
|
||||
} catch (IOException err_trans) {
|
||||
log("Failed to save storage.yml");
|
||||
PS.log("Failed to save storage.yml");
|
||||
}
|
||||
try {
|
||||
this.commandsFile = new File(this.IMP.getDirectory() + File.separator + "config" + File.separator + "commands.yml");
|
||||
if (!this.commandsFile.exists()) {
|
||||
if (!this.commandsFile.createNewFile()) {
|
||||
log("Could not the storage settings file, please create \"commands.yml\" manually.");
|
||||
PS.log("Could not the storage settings file, please create \"commands.yml\" manually.");
|
||||
}
|
||||
}
|
||||
this.commands = YamlConfiguration.loadConfiguration(this.commandsFile);
|
||||
setupStorage();
|
||||
} catch (IOException err_trans) {
|
||||
log("Failed to save commands.yml");
|
||||
PS.log("Failed to save commands.yml");
|
||||
}
|
||||
try {
|
||||
this.style.save(this.styleFile);
|
||||
@ -2260,7 +2254,7 @@ public class PS {
|
||||
this.storage.save(this.storageFile);
|
||||
this.commands.save(this.commandsFile);
|
||||
} catch (IOException e) {
|
||||
log("Configuration file saving failed");
|
||||
PS.log("Configuration file saving failed");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -2297,7 +2291,7 @@ public class PS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Show startup debug information
|
||||
* Show startup debug information.
|
||||
*/
|
||||
private void showDebug() {
|
||||
if (Settings.DEBUG) {
|
||||
@ -2312,7 +2306,7 @@ public class PS {
|
||||
settings.put("Schematics Save Path", "" + Settings.SCHEMATIC_SAVE_PATH);
|
||||
settings.put("API Location", "" + Settings.API_URL);
|
||||
for (Entry<String, String> setting : settings.entrySet()) {
|
||||
log(C.PREFIX + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
|
||||
PS.log(C.PREFIX + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2335,7 +2329,7 @@ public class PS {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the java version
|
||||
* Get the java version.
|
||||
* @return Java version as a double
|
||||
*/
|
||||
public double getJavaVersion() {
|
||||
@ -2378,7 +2372,7 @@ public class PS {
|
||||
}
|
||||
|
||||
public void foreachPlotArea(String world, RunnableVal<PlotArea> runnable) {
|
||||
PlotArea[] array = this.plotareamap.get(world);
|
||||
PlotArea[] array = this.plotAreaMap.get(world);
|
||||
if (array == null) {
|
||||
return;
|
||||
}
|
||||
@ -2404,7 +2398,7 @@ public class PS {
|
||||
}
|
||||
|
||||
public int getPlotAreaCount(String world) {
|
||||
return this.plotareamap.size();
|
||||
return this.plotAreaMap.size();
|
||||
}
|
||||
|
||||
public Set<PlotArea> getPlotAreas() {
|
||||
@ -2419,15 +2413,15 @@ public class PS {
|
||||
*/
|
||||
@Deprecated
|
||||
public Set<String> getPlotWorldStrings() {
|
||||
HashSet<String> set = new HashSet<>(this.plotareamap.size());
|
||||
for (Entry<String, PlotArea[]> entry : this.plotareamap.entrySet()) {
|
||||
HashSet<String> set = new HashSet<>(this.plotAreaMap.size());
|
||||
for (Entry<String, PlotArea[]> entry : this.plotAreaMap.entrySet()) {
|
||||
set.add(entry.getKey());
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
public boolean isAugmented(String world) {
|
||||
PlotArea[] areas = this.plotareamap.get(world);
|
||||
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||
if (areas == null) {
|
||||
return false;
|
||||
}
|
||||
@ -2443,7 +2437,7 @@ public class PS {
|
||||
* @return Collection of PlotArea objects
|
||||
*/
|
||||
public Set<PlotArea> getPlotAreas(String world) {
|
||||
PlotArea[] areas = this.plotareamap.get(world);
|
||||
PlotArea[] areas = this.plotAreaMap.get(world);
|
||||
if (areas == null) {
|
||||
return new HashSet<>(0);
|
||||
}
|
||||
|
@ -51,17 +51,16 @@ public class Area extends SubCommand {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "c":
|
||||
case "setup":
|
||||
case "create": {
|
||||
case "create":
|
||||
if (!Permissions.hasPermission(plr, "plots.area.create")) {
|
||||
C.NO_PERMISSION.send(plr, "plots.area.create");
|
||||
return false;
|
||||
}
|
||||
switch (args.length) {
|
||||
case 1: {
|
||||
case 1:
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
case 2: {
|
||||
case 2:
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "pos1": { // Set position 1
|
||||
HybridPlotWorld area = plr.getMeta("area_create_area");
|
||||
@ -69,14 +68,14 @@ public class Area extends SubCommand {
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
Location loc = plr.getLocation();
|
||||
plr.setMeta("area_pos1", loc);
|
||||
C.SET_ATTRIBUTE.send(plr, "area_pos1", loc.getX() + "," + loc.getZ());
|
||||
Location location = plr.getLocation();
|
||||
plr.setMeta("area_pos1", location);
|
||||
C.SET_ATTRIBUTE.send(plr, "area_pos1", location.getX() + "," + location.getZ());
|
||||
MainUtil.sendMessage(plr, "You will now set pos2: /plot area create pos2"
|
||||
+ "\nNote: The chosen plot size may result in the created area not exactly matching your second position.");
|
||||
return true;
|
||||
}
|
||||
case "pos2": { // Set position 2 and finish creation for type=2 (partial)
|
||||
case "pos2": // Set position 2 and finish creation for type=2 (partial)
|
||||
final HybridPlotWorld area = plr.getMeta("area_create_area");
|
||||
if (area == null) {
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
@ -86,17 +85,17 @@ public class Area extends SubCommand {
|
||||
Location pos2 = plr.getMeta("area_pos1");
|
||||
int dx = Math.abs(pos1.getX() - pos2.getX());
|
||||
int dz = Math.abs(pos1.getZ() - pos2.getZ());
|
||||
int numx = Math.max(1, (dx + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
||||
int numz = Math.max(1, (dz + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
||||
int ddx = dx - (numx * area.SIZE - area.ROAD_WIDTH);
|
||||
int ddz = dz - (numz * area.SIZE - area.ROAD_WIDTH);
|
||||
int numX = Math.max(1, (dx + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
||||
int numZ = Math.max(1, (dz + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
||||
int ddx = dx - (numX * area.SIZE - area.ROAD_WIDTH);
|
||||
int ddz = dz - (numZ * area.SIZE - area.ROAD_WIDTH);
|
||||
int bx = Math.min(pos1.getX(), pos2.getX()) + ddx;
|
||||
int bz = Math.min(pos1.getZ(), pos2.getZ()) + ddz;
|
||||
int tx = Math.max(pos1.getX(), pos2.getX()) - ddx;
|
||||
int tz = Math.max(pos1.getZ(), pos2.getZ()) - ddz;
|
||||
int lower = (area.ROAD_WIDTH & 1) == 0 ? area.ROAD_WIDTH / 2 - 1 : area.ROAD_WIDTH / 2;
|
||||
final int offsetx = bx - (area.ROAD_WIDTH == 0 ? 0 : lower);
|
||||
final int offsetz = bz - (area.ROAD_WIDTH == 0 ? 0 : lower);
|
||||
final int offsetX = bx - (area.ROAD_WIDTH == 0 ? 0 : lower);
|
||||
final int offsetZ = bz - (area.ROAD_WIDTH == 0 ? 0 : lower);
|
||||
final RegionWrapper region = new RegionWrapper(bx, tx, bz, tz);
|
||||
Set<PlotArea> areas = PS.get().getPlotAreas(area.worldname, region);
|
||||
if (!areas.isEmpty()) {
|
||||
@ -109,7 +108,7 @@ public class Area extends SubCommand {
|
||||
object.terrain = area.TERRAIN;
|
||||
object.type = area.TYPE;
|
||||
object.min = new PlotId(1, 1);
|
||||
object.max = new PlotId(numx, numz);
|
||||
object.max = new PlotId(numX, numZ);
|
||||
object.plotManager = "PlotSquared";
|
||||
object.setupGenerator = "PlotSquared";
|
||||
object.step = area.getSettingNodes();
|
||||
@ -117,11 +116,11 @@ public class Area extends SubCommand {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (offsetx != 0) {
|
||||
PS.get().config.set(path + ".road.offset.x", offsetx);
|
||||
if (offsetX != 0) {
|
||||
PS.get().config.set(path + ".road.offset.x", offsetX);
|
||||
}
|
||||
if (offsetz != 0) {
|
||||
PS.get().config.set(path + ".road.offset.z", offsetz);
|
||||
if (offsetZ != 0) {
|
||||
PS.get().config.set(path + ".road.offset.z", offsetZ);
|
||||
}
|
||||
final String world = SetupUtils.manager.setupWorld(object);
|
||||
if (WorldUtil.IMP.isWorld(world)) {
|
||||
@ -148,8 +147,6 @@ public class Area extends SubCommand {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
default: // Start creation
|
||||
final SetupObject object = new SetupObject();
|
||||
String[] split = args[1].split(":");
|
||||
@ -180,61 +177,51 @@ public class Area extends SubCommand {
|
||||
}
|
||||
switch (pair[0].toLowerCase()) {
|
||||
case "s":
|
||||
case "size": {
|
||||
case "size":
|
||||
pa.PLOT_WIDTH = Integer.parseInt(pair[1]);
|
||||
pa.SIZE = (short) (pa.PLOT_WIDTH + pa.ROAD_WIDTH);
|
||||
break;
|
||||
}
|
||||
case "g":
|
||||
case "gap": {
|
||||
case "gap":
|
||||
pa.ROAD_WIDTH = Integer.parseInt(pair[1]);
|
||||
pa.SIZE = (short) (pa.PLOT_WIDTH + pa.ROAD_WIDTH);
|
||||
break;
|
||||
}
|
||||
case "h":
|
||||
case "height": {
|
||||
case "height":
|
||||
int value = Integer.parseInt(pair[1]);
|
||||
pa.PLOT_HEIGHT = value;
|
||||
pa.ROAD_HEIGHT = value;
|
||||
pa.WALL_HEIGHT = value;
|
||||
break;
|
||||
}
|
||||
case "f":
|
||||
case "floor": {
|
||||
case "floor":
|
||||
pa.TOP_BLOCK = Configuration.BLOCKLIST.parseString(pair[1]);
|
||||
break;
|
||||
}
|
||||
case "m":
|
||||
case "main": {
|
||||
case "main":
|
||||
pa.MAIN_BLOCK = Configuration.BLOCKLIST.parseString(pair[1]);
|
||||
break;
|
||||
}
|
||||
case "w":
|
||||
case "wall": {
|
||||
case "wall":
|
||||
pa.WALL_FILLING = Configuration.BLOCK.parseString(pair[1]);
|
||||
break;
|
||||
}
|
||||
case "b":
|
||||
case "border": {
|
||||
case "border":
|
||||
pa.WALL_BLOCK = Configuration.BLOCK.parseString(pair[1]);
|
||||
break;
|
||||
}
|
||||
case "terrain": {
|
||||
case "terrain":
|
||||
pa.TERRAIN = Integer.parseInt(pair[1]);
|
||||
object.terrain = pa.TERRAIN;
|
||||
break;
|
||||
}
|
||||
case "type": {
|
||||
case "type":
|
||||
pa.TYPE = Integer.parseInt(pair[1]);
|
||||
object.type = pa.TYPE;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pa.TYPE != 2) {
|
||||
if (WorldUtil.IMP.isWorld(pa.worldname)) {
|
||||
C.SETUP_WORLD_TAKEN.send(plr, pa.worldname);
|
||||
@ -292,7 +279,6 @@ public class Area extends SubCommand {
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "i":
|
||||
case "info": {
|
||||
if (!Permissions.hasPermission(plr, "plots.area.info")) {
|
||||
@ -349,7 +335,7 @@ public class Area extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
case "l":
|
||||
case "list": {
|
||||
case "list":
|
||||
if (!Permissions.hasPermission(plr, "plots.area.list")) {
|
||||
C.NO_PERMISSION.send(plr, "plots.area.list");
|
||||
return false;
|
||||
@ -407,7 +393,6 @@ public class Area extends SubCommand {
|
||||
}
|
||||
}, "/plot area list", C.AREA_LIST_HEADER_PAGED.s());
|
||||
return true;
|
||||
}
|
||||
case "regen":
|
||||
case "regenerate": {
|
||||
if (!Permissions.hasPermission(plr, "plots.area.regen")) {
|
||||
@ -435,7 +420,7 @@ public class Area extends SubCommand {
|
||||
case "v":
|
||||
case "teleport":
|
||||
case "visit":
|
||||
case "tp": {
|
||||
case "tp":
|
||||
if (!Permissions.hasPermission(plr, "plots.area.tp")) {
|
||||
C.NO_PERMISSION.send(plr, "plots.area.tp");
|
||||
return false;
|
||||
@ -460,9 +445,8 @@ public class Area extends SubCommand {
|
||||
}
|
||||
plr.teleport(center);
|
||||
return true;
|
||||
}
|
||||
case "delete":
|
||||
case "remove": {
|
||||
case "remove":
|
||||
MainUtil.sendMessage(plr, "$1World creation settings may be stored in multiple locations:"
|
||||
+ "\n$3 - $2Bukkit bukkit.yml"
|
||||
+ "\n$3 - $2PlotSquared settings.yml"
|
||||
@ -470,7 +454,6 @@ public class Area extends SubCommand {
|
||||
+ "\n$1Stop the server and delete it from these locations.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
return false;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class BO3 extends SubCommand {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Location loc = plr.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
if (plot == null || !plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.bo3")) {
|
||||
@ -40,21 +40,18 @@ public class BO3 extends SubCommand {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "output":
|
||||
case "save":
|
||||
case "export": {
|
||||
case "export":
|
||||
return BO3Handler.saveBO3(plr, plot);
|
||||
}
|
||||
case "paste":
|
||||
case "load":
|
||||
case "import":
|
||||
case "input": {
|
||||
case "input":
|
||||
// TODO NOT IMPLEMENTED YET
|
||||
MainUtil.sendMessage(plr, "NOT IMPLEMENTED YET!!!");
|
||||
return false;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
noArgs(plr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@ -237,9 +238,9 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
HashSet<Plot> existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2());
|
||||
HashSet<Plot> newplots = area.getPlotSelectionOwned(pos1, pos2);
|
||||
HashSet<Plot> newPlots = area.getPlotSelectionOwned(pos1, pos2);
|
||||
HashSet<Plot> removed = (HashSet<Plot>) existing.clone();
|
||||
removed.removeAll(newplots);
|
||||
removed.removeAll(newPlots);
|
||||
// Check expand / shrink
|
||||
if (!removed.isEmpty()) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.resize.shrink")) {
|
||||
@ -247,8 +248,8 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
newplots.removeAll(existing);
|
||||
if (!newplots.isEmpty()) {
|
||||
newPlots.removeAll(existing);
|
||||
if (!newPlots.isEmpty()) {
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.resize.expand")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.resize.expand");
|
||||
return false;
|
||||
@ -544,7 +545,7 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
case "sh":
|
||||
case "setspawn":
|
||||
case "sethome": {
|
||||
case "sethome":
|
||||
if (!Permissions.hasPermission(plr, "plots.cluster.sethome")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome");
|
||||
return false;
|
||||
@ -575,7 +576,6 @@ public class Cluster extends SubCommand {
|
||||
DBFunc.setPosition(cluster, relative.getX() + "," + relative.getY() + "," + relative.getZ());
|
||||
return MainUtil.sendMessage(plr, C.POSITION_SET);
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_AVAILABLE_ARGS);
|
||||
return false;
|
||||
}
|
||||
|
@ -3,19 +3,15 @@ package com.intellectualcrafters.plot.commands;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-03.
|
||||
*
|
||||
|
||||
*/
|
||||
public class CommandPermission {
|
||||
|
||||
/**
|
||||
* Permission Node
|
||||
* Permission Node.
|
||||
*/
|
||||
public final String permission;
|
||||
|
||||
/**
|
||||
* Command Permission
|
||||
* @param permission Command Permission
|
||||
*/
|
||||
public CommandPermission(String permission) {
|
||||
@ -23,7 +19,8 @@ public class CommandPermission {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player Does the player have the permission?
|
||||
* Check the permissions of a player.
|
||||
* @param player The player to check permissions for
|
||||
*
|
||||
* @return true of player has the required permission node
|
||||
*/
|
||||
|
@ -10,6 +10,7 @@ import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@ -29,7 +30,7 @@ public class Condense extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
if ((args.length != 2) && (args.length != 3)) {
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
MainUtil.sendMessage(plr, "/plot condense <area> <start|stop|info> [radius]");
|
||||
return false;
|
||||
}
|
||||
@ -44,7 +45,7 @@ public class Condense extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "/plot condense " + area.toString() + " start <radius>");
|
||||
return false;
|
||||
}
|
||||
if (TASK) {
|
||||
if (Condense.TASK) {
|
||||
MainUtil.sendMessage(plr, "TASK ALREADY STARTED");
|
||||
return false;
|
||||
}
|
||||
@ -55,13 +56,13 @@ public class Condense extends SubCommand {
|
||||
int radius = Integer.parseInt(args[2]);
|
||||
ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlots(area));
|
||||
// remove non base plots
|
||||
Iterator<Plot> iter = plots.iterator();
|
||||
Iterator<Plot> iterator = plots.iterator();
|
||||
int maxSize = 0;
|
||||
ArrayList<Integer> sizes = new ArrayList<>();
|
||||
while (iter.hasNext()) {
|
||||
Plot plot = iter.next();
|
||||
while (iterator.hasNext()) {
|
||||
Plot plot = iterator.next();
|
||||
if (!plot.isBasePlot()) {
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
int size = plot.getConnectedPlots().size();
|
||||
@ -90,7 +91,7 @@ public class Condense extends SubCommand {
|
||||
}
|
||||
}
|
||||
int size = allPlots.size();
|
||||
int minimumRadius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
||||
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
|
||||
if (radius < minimumRadius) {
|
||||
MainUtil.sendMessage(plr, "RADIUS TOO SMALL");
|
||||
return false;
|
||||
@ -98,7 +99,7 @@ public class Condense extends SubCommand {
|
||||
List<PlotId> toMove = new ArrayList<>(getPlots(allPlots, radius));
|
||||
final List<PlotId> free = new ArrayList<>();
|
||||
PlotId start = new PlotId(0, 0);
|
||||
while ((start.x <= minimumRadius) && (start.y <= minimumRadius)) {
|
||||
while (start.x <= minimumRadius && start.y <= minimumRadius) {
|
||||
Plot plot = area.getPlotAbs(start);
|
||||
if (plot != null && !plot.hasOwner()) {
|
||||
free.add(plot.getId());
|
||||
@ -113,11 +114,11 @@ public class Condense extends SubCommand {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!TASK) {
|
||||
if (!Condense.TASK) {
|
||||
MainUtil.sendMessage(plr, "TASK CANCELLED.");
|
||||
}
|
||||
if (allPlots.isEmpty()) {
|
||||
TASK = false;
|
||||
Condense.TASK = false;
|
||||
MainUtil.sendMessage(plr, "TASK COMPLETE. PLEASE VERIFY THAT NO NEW PLOTS HAVE BEEN CLAIMED DURING TASK.");
|
||||
return;
|
||||
}
|
||||
@ -146,7 +147,7 @@ public class Condense extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (free.isEmpty()) {
|
||||
TASK = false;
|
||||
Condense.TASK = false;
|
||||
MainUtil.sendMessage(plr, "TASK FAILED. NO FREE PLOTS FOUND!");
|
||||
return;
|
||||
}
|
||||
@ -155,20 +156,19 @@ public class Condense extends SubCommand {
|
||||
}
|
||||
}
|
||||
};
|
||||
TASK = true;
|
||||
Condense.TASK = true;
|
||||
TaskManager.runTaskAsync(run);
|
||||
return true;
|
||||
}
|
||||
case "stop": {
|
||||
if (!TASK) {
|
||||
case "stop":
|
||||
if (!Condense.TASK) {
|
||||
MainUtil.sendMessage(plr, "TASK ALREADY STOPPED");
|
||||
return false;
|
||||
}
|
||||
TASK = false;
|
||||
Condense.TASK = false;
|
||||
MainUtil.sendMessage(plr, "TASK STOPPED");
|
||||
return true;
|
||||
}
|
||||
case "info": {
|
||||
case "info":
|
||||
if (args.length == 2) {
|
||||
MainUtil.sendMessage(plr, "/plot condense " + area.toString() + " info <radius>");
|
||||
return false;
|
||||
@ -180,7 +180,7 @@ public class Condense extends SubCommand {
|
||||
int radius = Integer.parseInt(args[2]);
|
||||
Collection<Plot> plots = area.getPlots();
|
||||
int size = plots.size();
|
||||
int minimumRadius = (int) Math.ceil((Math.sqrt(size) / 2) + 1);
|
||||
int minimumRadius = (int) Math.ceil(Math.sqrt(size) / 2 + 1);
|
||||
if (radius < minimumRadius) {
|
||||
MainUtil.sendMessage(plr, "RADIUS TOO SMALL");
|
||||
return false;
|
||||
@ -197,7 +197,6 @@ public class Condense extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "&e - Radius is measured in plot width");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(plr, "/plot condense " + area.worldname + " <start|stop|info> [radius]");
|
||||
return false;
|
||||
}
|
||||
@ -205,7 +204,7 @@ public class Condense extends SubCommand {
|
||||
public Set<PlotId> getPlots(Collection<Plot> plots, int radius) {
|
||||
HashSet<PlotId> outside = new HashSet<>();
|
||||
for (Plot plot : plots) {
|
||||
if ((plot.getId().x > radius) || (plot.getId().x < -radius) || (plot.getId().y > radius) || (plot.getId().y < -radius)) {
|
||||
if (plot.getId().x > radius || plot.getId().x < -radius || plot.getId().y > radius || plot.getId().y < -radius) {
|
||||
outside.add(plot.getId());
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class Database extends SubCommand {
|
||||
com.intellectualcrafters.plot.database.Database implementation;
|
||||
String prefix = "";
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "import": {
|
||||
case "import":
|
||||
if (args.length < 2) {
|
||||
MainUtil.sendMessage(player, "/plot database import [sqlite file] [prefix]");
|
||||
return false;
|
||||
@ -90,7 +90,7 @@ public class Database extends SubCommand {
|
||||
}
|
||||
MainUtil.sendMessage(player, "&6Starting...");
|
||||
implementation = new SQLite(file.getPath());
|
||||
SQLManager manager = new SQLManager(implementation, (args.length == 3) ? args[2] : "", true);
|
||||
SQLManager manager = new SQLManager(implementation, args.length == 3 ? args[2] : "", true);
|
||||
HashMap<String, HashMap<PlotId, Plot>> map = manager.getPlots();
|
||||
plots = new ArrayList<>();
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
||||
@ -122,7 +122,6 @@ public class Database extends SubCommand {
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
case "mysql":
|
||||
if (args.length < 6) {
|
||||
return MainUtil.sendMessage(player, "/plot database mysql [host] [port] [username] [password] [database] {prefix}");
|
||||
@ -148,7 +147,7 @@ public class Database extends SubCommand {
|
||||
}
|
||||
try {
|
||||
SQLManager manager = new SQLManager(implementation, prefix, true);
|
||||
insertPlots(manager, plots, player);
|
||||
Database.insertPlots(manager, plots, player);
|
||||
return true;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
MainUtil.sendMessage(player, "$1Failed to save plots, read stacktrace for info");
|
||||
|
@ -95,7 +95,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
plot.owner = uuid;
|
||||
plots.add(plot);
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, " - &cInvalid playername: " + plot.getId() + " : " + line);
|
||||
MainUtil.sendMessage(plr, " - &cInvalid PlayerName: " + plot.getId() + " : " + line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
@ -18,22 +19,24 @@ public class GenerateDocs {
|
||||
public static void main(String[] args) {
|
||||
new WE_Anywhere();
|
||||
List<Command> commands = MainCommand.getInstance().getCommands();
|
||||
log("### Want to document some commands?");
|
||||
log(" - This page is automatically generated");
|
||||
log(" - Fork the project and add a javadoc comment to one of the command classes");
|
||||
log(" - Then do a pull request and it will be added to this page");
|
||||
log("");
|
||||
log("# Contents");
|
||||
GenerateDocs.log("### Want to document some commands?");
|
||||
GenerateDocs.log(" - This page is automatically generated");
|
||||
GenerateDocs.log(" - Fork the project and add a javadoc comment to one of the command classes");
|
||||
GenerateDocs.log(" - Then do a pull request and it will be added to this page");
|
||||
GenerateDocs.log("");
|
||||
GenerateDocs.log("# Contents");
|
||||
for (CommandCategory category : CommandCategory.values()) {
|
||||
log("###### " + category.name());
|
||||
GenerateDocs.log("###### " + category.name());
|
||||
for (Command command : MainCommand.getInstance().getCommands(category, null)) {
|
||||
log(" - [/plot " + command.getId() + "](https://github.com/IntellectualSites/PlotSquared/wiki/Commands#" + command.getId() + ") ");
|
||||
GenerateDocs
|
||||
.log(" - [/plot " + command.getId() + "](https://github.com/IntellectualSites/PlotSquared/wiki/Commands#" + command.getId()
|
||||
+ ") ");
|
||||
}
|
||||
log("");
|
||||
GenerateDocs.log("");
|
||||
}
|
||||
log("# Commands");
|
||||
GenerateDocs.log("# Commands");
|
||||
for (Command command : commands) {
|
||||
printCommand(command);
|
||||
GenerateDocs.printCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,62 +49,60 @@ public class GenerateDocs {
|
||||
String source =
|
||||
"https://github.com/IntellectualSites/PlotSquared/tree/master/Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz
|
||||
+ ".java";
|
||||
log("## [" + name.toUpperCase() + "](" + source + ") ");
|
||||
GenerateDocs.log("## [" + name.toUpperCase() + "](" + source + ") ");
|
||||
|
||||
File file = new File("Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz + ".java");
|
||||
List<String> lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
|
||||
List<String> perms = getPerms(name, lines);
|
||||
List<String> usages = getUsage(name, lines);
|
||||
String comment = getComments(lines);
|
||||
List<String> perms = GenerateDocs.getPerms(name, lines);
|
||||
List<String> usages = GenerateDocs.getUsage(name, lines);
|
||||
String comment = GenerateDocs.getComments(lines);
|
||||
|
||||
log("#### Description");
|
||||
log("`" + command.getDescription() + "`");
|
||||
GenerateDocs.log("#### Description");
|
||||
GenerateDocs.log("`" + command.getDescription() + "`");
|
||||
if (!comment.isEmpty()) {
|
||||
log("##### Comments");
|
||||
log("``` java");
|
||||
log(comment);
|
||||
log("```");
|
||||
GenerateDocs.log("##### Comments");
|
||||
GenerateDocs.log("``` java");
|
||||
GenerateDocs.log(comment);
|
||||
GenerateDocs.log("```");
|
||||
}
|
||||
|
||||
log("#### Usage ");
|
||||
{
|
||||
GenerateDocs.log("#### Usage ");
|
||||
String mainUsage = command.getUsage().replaceAll("\\{label\\}", "plot");
|
||||
if (!usages.isEmpty() && !usages.get(0).equalsIgnoreCase(mainUsage)) {
|
||||
log("##### Primary ");
|
||||
log(" - `" + mainUsage + "` ");
|
||||
log("");
|
||||
log("##### Other ");
|
||||
log(" - `" + StringMan.join(usages, "`\n - `") + "` ");
|
||||
log("");
|
||||
GenerateDocs.log("##### Primary ");
|
||||
GenerateDocs.log(" - `" + mainUsage + "` ");
|
||||
GenerateDocs.log("");
|
||||
GenerateDocs.log("##### Other ");
|
||||
GenerateDocs.log(" - `" + StringMan.join(usages, "`\n - `") + "` ");
|
||||
GenerateDocs.log("");
|
||||
} else {
|
||||
log("`" + mainUsage + "` ");
|
||||
}
|
||||
GenerateDocs.log("`" + mainUsage + "` ");
|
||||
}
|
||||
|
||||
if (command.getRequiredType() != RequiredType.NONE) {
|
||||
log("#### Required callers");
|
||||
log("`" + command.getRequiredType().name() + "`");
|
||||
GenerateDocs.log("#### Required callers");
|
||||
GenerateDocs.log("`" + command.getRequiredType().name() + "`");
|
||||
}
|
||||
|
||||
List<String> aliases = command.getAliases();
|
||||
if (!aliases.isEmpty()) {
|
||||
log("#### Aliases");
|
||||
log("`" + StringMan.getString(command.getAliases()) + "`");
|
||||
GenerateDocs.log("#### Aliases");
|
||||
GenerateDocs.log("`" + StringMan.getString(command.getAliases()) + "`");
|
||||
}
|
||||
|
||||
log("#### Permissions");
|
||||
GenerateDocs.log("#### Permissions");
|
||||
if (!perms.isEmpty()) {
|
||||
log("##### Primary");
|
||||
log(" - `" + command.getPermission() + "` ");
|
||||
log("");
|
||||
log("##### Other");
|
||||
log(" - `" + StringMan.join(perms, "`\n - `") + "`");
|
||||
log("");
|
||||
GenerateDocs.log("##### Primary");
|
||||
GenerateDocs.log(" - `" + command.getPermission() + "` ");
|
||||
GenerateDocs.log("");
|
||||
GenerateDocs.log("##### Other");
|
||||
GenerateDocs.log(" - `" + StringMan.join(perms, "`\n - `") + "`");
|
||||
GenerateDocs.log("");
|
||||
} else {
|
||||
log("`" + command.getPermission() + "` ");
|
||||
GenerateDocs.log("`" + command.getPermission() + "` ");
|
||||
}
|
||||
log("***");
|
||||
log("");
|
||||
GenerateDocs.log("***");
|
||||
GenerateDocs.log("");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -189,11 +190,10 @@ public class GenerateDocs {
|
||||
}
|
||||
switch (cmd.toLowerCase()) {
|
||||
case "auto":
|
||||
case "claim": {
|
||||
case "claim":
|
||||
perms.add("plots.plot.<#>");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new ArrayList<>(perms);
|
||||
}
|
||||
|
||||
|
@ -30,11 +30,10 @@ public class Help extends Command {
|
||||
@Override
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
switch (args.length) {
|
||||
case 0: {
|
||||
case 0:
|
||||
displayHelp(player, null, 0);
|
||||
return;
|
||||
}
|
||||
case 1: {
|
||||
case 1:
|
||||
if (MathMan.isInteger(args[0])) {
|
||||
try {
|
||||
displayHelp(player, null, Integer.parseInt(args[0]));
|
||||
@ -45,8 +44,7 @@ public class Help extends Command {
|
||||
displayHelp(player, args[0], 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 2: {
|
||||
case 2:
|
||||
if (MathMan.isInteger(args[1])) {
|
||||
try {
|
||||
displayHelp(player, args[1], Integer.parseInt(args[1]));
|
||||
@ -55,12 +53,10 @@ public class Help extends Command {
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void displayHelp(PlotPlayer player, String cat, int page) {
|
||||
CommandCategory catEnum = null;
|
||||
|
@ -10,6 +10,7 @@ import com.intellectualcrafters.plot.util.CommentManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -23,7 +24,7 @@ import java.util.List;
|
||||
public class Inbox extends SubCommand {
|
||||
|
||||
public void displayComments(PlotPlayer player, List<PlotComment> oldComments, int page) {
|
||||
if ((oldComments == null) || oldComments.isEmpty()) {
|
||||
if (oldComments == null || oldComments.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.INBOX_EMPTY);
|
||||
return;
|
||||
}
|
||||
@ -38,7 +39,7 @@ public class Inbox extends SubCommand {
|
||||
page = totalPages;
|
||||
}
|
||||
// Only display 12 per page
|
||||
int max = (page * 12) + 12;
|
||||
int max = page * 12 + 12;
|
||||
if (max > comments.length) {
|
||||
max = comments.length;
|
||||
}
|
||||
@ -112,7 +113,7 @@ public class Inbox extends SubCommand {
|
||||
final int page;
|
||||
if (args.length > 1) {
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "delete": {
|
||||
case "delete":
|
||||
if (!inbox.canModify(plot, player)) {
|
||||
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
||||
return false;
|
||||
@ -149,8 +150,7 @@ public class Inbox extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "clear": {
|
||||
case "clear":
|
||||
if (!inbox.canModify(plot, player)) {
|
||||
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
||||
}
|
||||
@ -161,8 +161,7 @@ public class Inbox extends SubCommand {
|
||||
}
|
||||
MainUtil.sendMessage(player, C.COMMENT_REMOVED, "*");
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
try {
|
||||
page = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
@ -170,7 +169,6 @@ public class Inbox extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
page = 1;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class Info extends SubCommand {
|
||||
args = new String[]{args[1]};
|
||||
}
|
||||
}
|
||||
if ((args.length == 1) && args[0].equalsIgnoreCase("inv")) {
|
||||
if (args.length == 1 && args[0].equalsIgnoreCase("inv")) {
|
||||
PlotInventory inv = new PlotInventory(player) {
|
||||
@Override
|
||||
public boolean onClick(int index) {
|
||||
@ -95,13 +95,9 @@ public class Info extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
boolean hasOwner = plot.hasOwner();
|
||||
boolean containsEveryone;
|
||||
boolean trustedEveryone;
|
||||
// Wildcard player {added}
|
||||
{
|
||||
containsEveryone = plot.getTrusted().contains(DBFunc.everyone);
|
||||
trustedEveryone = plot.getMembers().contains(DBFunc.everyone);
|
||||
}
|
||||
boolean containsEveryone = plot.getTrusted().contains(DBFunc.everyone);
|
||||
boolean trustedEveryone = plot.getMembers().contains(DBFunc.everyone);
|
||||
// Unclaimed?
|
||||
if (!hasOwner && !containsEveryone && !trustedEveryone) {
|
||||
MainUtil.sendMessage(player, C.PLOT_INFO_UNCLAIMED, plot.getId().x + ";" + plot.getId().y);
|
||||
|
@ -26,6 +26,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -39,8 +40,8 @@ import java.util.UUID;
|
||||
public class ListCmd extends SubCommand {
|
||||
|
||||
private String[] getArgumentList(PlotPlayer player) {
|
||||
java.util.List<String> args = new ArrayList<>();
|
||||
if ((EconHandler.manager != null) && Permissions.hasPermission(player, "plots.list.forsale")) {
|
||||
List<String> args = new ArrayList<>();
|
||||
if (EconHandler.manager != null && Permissions.hasPermission(player, "plots.list.forsale")) {
|
||||
args.add("forsale");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.list.mine")) {
|
||||
@ -105,14 +106,14 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
java.util.List<Plot> plots = null;
|
||||
List<Plot> plots = null;
|
||||
|
||||
String world = plr.getLocation().getWorld();
|
||||
PlotArea area = plr.getApplicablePlotArea();
|
||||
String arg = args[0].toLowerCase();
|
||||
boolean sort = true;
|
||||
switch (arg) {
|
||||
case "mine": {
|
||||
case "mine":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.mine")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.mine");
|
||||
return false;
|
||||
@ -120,8 +121,7 @@ public class ListCmd extends SubCommand {
|
||||
sort = false;
|
||||
plots = PS.get().sortPlotsByTemp(PS.get().getBasePlots(plr));
|
||||
break;
|
||||
}
|
||||
case "shared": {
|
||||
case "shared":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.shared")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.shared");
|
||||
return false;
|
||||
@ -133,8 +133,7 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "world": {
|
||||
case "world":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.world")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world");
|
||||
return false;
|
||||
@ -145,16 +144,14 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
plots = new ArrayList<>(PS.get().getPlots(world));
|
||||
break;
|
||||
}
|
||||
case "expired": {
|
||||
case "expired":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.expired")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.expired");
|
||||
return false;
|
||||
}
|
||||
plots = ExpireManager.IMP == null ? new ArrayList<Plot>() : new ArrayList<>(ExpireManager.IMP.getPendingExpired());
|
||||
break;
|
||||
}
|
||||
case "area": {
|
||||
case "area":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.area")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.area");
|
||||
return false;
|
||||
@ -165,16 +162,14 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
plots = area == null ? new ArrayList<Plot>() : new ArrayList<>(area.getPlots());
|
||||
break;
|
||||
}
|
||||
case "all": {
|
||||
case "all":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.all")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.all");
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PS.get().getPlots());
|
||||
break;
|
||||
}
|
||||
case "done": {
|
||||
case "done":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.done")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.done");
|
||||
return false;
|
||||
@ -203,8 +198,7 @@ public class ListCmd extends SubCommand {
|
||||
});
|
||||
sort = false;
|
||||
break;
|
||||
}
|
||||
case "top": {
|
||||
case "top":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.top")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.top");
|
||||
return false;
|
||||
@ -233,7 +227,7 @@ public class ListCmd extends SubCommand {
|
||||
v2 /= p2s;
|
||||
v2 += p2s;
|
||||
}
|
||||
if ((v2 == v1) && (v2 != 0)) {
|
||||
if (v2 == v1 && v2 != 0) {
|
||||
return p2s - p1s;
|
||||
}
|
||||
return (int) Math.signum(v2 - v1);
|
||||
@ -241,8 +235,7 @@ public class ListCmd extends SubCommand {
|
||||
});
|
||||
sort = false;
|
||||
break;
|
||||
}
|
||||
case "forsale": {
|
||||
case "forsale":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.forsale")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.forsale");
|
||||
return false;
|
||||
@ -258,8 +251,7 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "unowned": {
|
||||
case "unowned":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.unowned")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unowned");
|
||||
return false;
|
||||
@ -271,8 +263,7 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "unknown": {
|
||||
case "unknown":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.unknown")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unknown");
|
||||
return false;
|
||||
@ -287,8 +278,7 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "fuzzy": {
|
||||
case "fuzzy":
|
||||
if (!Permissions.hasPermission(plr, "plots.list.fuzzy")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.fuzzy");
|
||||
return false;
|
||||
@ -301,8 +291,7 @@ public class ListCmd extends SubCommand {
|
||||
plots = MainUtil.getPlotsBySearch(term);
|
||||
sort = false;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
if (PS.get().hasPlotArea(args[0])) {
|
||||
if (!Permissions.hasPermission(plr, "plots.list.world")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world");
|
||||
@ -332,7 +321,6 @@ public class ListCmd extends SubCommand {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plots == null) {
|
||||
sendMessage(plr, C.DID_YOU_MEAN, new StringComparison<>(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch());
|
||||
@ -347,13 +335,13 @@ public class ListCmd extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void displayPlots(final PlotPlayer player, java.util.List<Plot> plots, int pageSize, int page, PlotArea area,
|
||||
public void displayPlots(final PlotPlayer player, List<Plot> plots, int pageSize, int page, PlotArea area,
|
||||
String[] args, boolean sort) {
|
||||
// Header
|
||||
Iterator<Plot> iter = plots.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (!iter.next().isBasePlot()) {
|
||||
iter.remove();
|
||||
Iterator<Plot> iterator = plots.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (!iterator.next().isBasePlot()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
if (sort) {
|
||||
|
@ -65,9 +65,9 @@ public class Load extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.LOAD_NULL);
|
||||
return false;
|
||||
}
|
||||
String schem;
|
||||
String schematic;
|
||||
try {
|
||||
schem = schematics.get(Integer.parseInt(args[0]) - 1);
|
||||
schematic = schematics.get(Integer.parseInt(args[0]) - 1);
|
||||
} catch (NumberFormatException e) {
|
||||
// use /plot load <index>
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(1, " + schematics.size() + ")");
|
||||
@ -75,7 +75,7 @@ public class Load extends SubCommand {
|
||||
}
|
||||
final URL url;
|
||||
try {
|
||||
url = new URL(Settings.WEB_URL + "saves/" + plr.getUUID() + "/" + schem + ".schematic");
|
||||
url = new URL(Settings.WEB_URL + "saves/" + plr.getUUID() + "/" + schematic + ".schematic");
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(plr, C.LOAD_FAILED);
|
||||
@ -140,8 +140,8 @@ public class Load extends SubCommand {
|
||||
List<String> schematics = player.getMeta("plot_schematics");
|
||||
for (int i = 0; i < Math.min(schematics.size(), 32); i++) {
|
||||
try {
|
||||
String schem = schematics.get(i);
|
||||
String[] split = schem.split("_");
|
||||
String schematic = schematics.get(i);
|
||||
String[] split = schematic.split("_");
|
||||
if (split.length != 6) {
|
||||
continue;
|
||||
}
|
||||
|
@ -47,54 +47,48 @@ public class Purge extends SubCommand {
|
||||
}
|
||||
switch (split[0].toLowerCase()) {
|
||||
case "world":
|
||||
case "w": {
|
||||
case "w":
|
||||
world = split[1];
|
||||
break;
|
||||
}
|
||||
case "area":
|
||||
case "a": {
|
||||
case "a":
|
||||
area = PS.get().getPlotAreaByString(split[1]);
|
||||
if (area == null) {
|
||||
C.NOT_VALID_PLOT_WORLD.send(plr, split[1]);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "plotid":
|
||||
case "id": {
|
||||
case "id":
|
||||
id = PlotId.fromString(split[1]);
|
||||
if (id == null) {
|
||||
C.NOT_VALID_PLOT_ID.send(plr, split[1]);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "owner":
|
||||
case "o": {
|
||||
case "o":
|
||||
owner = UUIDHandler.getUUID(split[1], null);
|
||||
if (owner == null) {
|
||||
C.INVALID_PLAYER.send(plr, split[1]);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "shared":
|
||||
case "s": {
|
||||
case "s":
|
||||
added = UUIDHandler.getUUID(split[1], null);
|
||||
if (added == null) {
|
||||
C.INVALID_PLAYER.send(plr, split[1]);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "unknown":
|
||||
case "?":
|
||||
case "u": {
|
||||
case "u":
|
||||
unknown = Boolean.parseBoolean(split[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
final HashSet<Plot> toDelete = new HashSet<>();
|
||||
for (Plot plot : PS.get().getBasePlots()) {
|
||||
if (world != null && !plot.getArea().worldname.equalsIgnoreCase(world)) {
|
||||
@ -121,8 +115,8 @@ public class Purge extends SubCommand {
|
||||
}
|
||||
if (PS.get().plots_tmp != null) {
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : PS.get().plots_tmp.entrySet()) {
|
||||
String worldname = entry.getKey();
|
||||
if (world != null && !world.equalsIgnoreCase(worldname)) {
|
||||
String worldName = entry.getKey();
|
||||
if (world != null && !world.equalsIgnoreCase(worldName)) {
|
||||
continue;
|
||||
}
|
||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
|
@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@ -87,7 +88,7 @@ public class Rate extends SubCommand {
|
||||
sendMessage(player, C.RATING_NOT_DONE);
|
||||
return false;
|
||||
}
|
||||
if ((Settings.RATING_CATEGORIES != null) && !Settings.RATING_CATEGORIES.isEmpty()) {
|
||||
if (Settings.RATING_CATEGORIES != null && !Settings.RATING_CATEGORIES.isEmpty()) {
|
||||
final Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -154,7 +155,7 @@ public class Rate extends SubCommand {
|
||||
}
|
||||
String arg = args[0];
|
||||
final int rating;
|
||||
if (MathMan.isInteger(arg) && (arg.length() < 3) && !arg.isEmpty()) {
|
||||
if (MathMan.isInteger(arg) && arg.length() < 3 && !arg.isEmpty()) {
|
||||
rating = Integer.parseInt(arg);
|
||||
if (rating > 10 || rating < 1) {
|
||||
sendMessage(player, C.RATING_NOT_VALID);
|
||||
|
@ -9,6 +9,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
@ -63,7 +64,7 @@ public class Remove extends SubCommand {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "*": {
|
||||
case "*":
|
||||
ArrayList<UUID> toRemove = new ArrayList<>();
|
||||
HashSet<UUID> all = new HashSet<>();
|
||||
all.addAll(plot.getMembers());
|
||||
@ -79,7 +80,6 @@ public class Remove extends SubCommand {
|
||||
plot.removeMember(uuid);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UUID uuid = UUIDHandler.getUUID(args[0], null);
|
||||
if (uuid != null) {
|
||||
|
@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -174,7 +175,7 @@ public class SchematicCmd extends SubCommand {
|
||||
break;
|
||||
}
|
||||
case "export":
|
||||
case "save": {
|
||||
case "save":
|
||||
if (!Permissions.hasPermission(plr, "plots.schematic.save")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.save");
|
||||
return false;
|
||||
@ -214,12 +215,10 @@ public class SchematicCmd extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "&7Starting export...");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@ -159,7 +160,6 @@ public class Set extends SubCommand {
|
||||
return this.component.onCommand(plr, Arrays.copyOfRange(args, 0, args.length));
|
||||
}
|
||||
// flag
|
||||
{
|
||||
AbstractFlag af;
|
||||
try {
|
||||
af = new AbstractFlag(args[0].toLowerCase());
|
||||
@ -176,7 +176,6 @@ public class Set extends SubCommand {
|
||||
MainCommand.onCommand(plr, ("flag set " + args[0] + a.toString()).split(" "));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return noArgs(plr);
|
||||
}
|
||||
}
|
||||
|
@ -28,18 +28,16 @@ public class SetHome extends SetCommand {
|
||||
base.setHome(null);
|
||||
return MainUtil.sendMessage(plr, C.POSITION_UNSET);
|
||||
}
|
||||
case "": {
|
||||
case "":
|
||||
Plot base = plot.getBasePlot(false);
|
||||
Location bot = base.getBottomAbs();
|
||||
Location loc = plr.getLocationFull();
|
||||
BlockLoc rel = new BlockLoc(loc.getX() - bot.getX(), loc.getY(), loc.getZ() - bot.getZ(), loc.getYaw(), loc.getPitch());
|
||||
base.setHome(rel);
|
||||
return MainUtil.sendMessage(plr, C.POSITION_SET);
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
MainUtil.sendMessage(plr, C.HOME_ARGUMENT);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ public class Setup extends SubCommand {
|
||||
}
|
||||
int index = object.current;
|
||||
switch (index) {
|
||||
case 0: { // choose generator
|
||||
if ((args.length != 1) || !SetupUtils.generators.containsKey(args[0])) {
|
||||
case 0: // choose generator
|
||||
if (args.length != 1 || !SetupUtils.generators.containsKey(args[0])) {
|
||||
String prefix = "\n&8 - &7";
|
||||
MainUtil.sendMessage(plr, "&cYou must choose a generator!" + prefix + StringMan.join(SetupUtils.generators.keySet(), prefix)
|
||||
.replaceAll("PlotSquared", "&2PlotSquared"));
|
||||
@ -89,8 +89,7 @@ public class Setup extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation"
|
||||
+ "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial);
|
||||
break;
|
||||
}
|
||||
case 1: { // choose world type
|
||||
case 1: // choose world type
|
||||
List<String> allTypes = Arrays.asList("default", "augmented", "partial");
|
||||
List<String> allDesc = Arrays.asList("Standard plot generation", "Plot generation with vanilla terrain",
|
||||
"Vanilla with clusters of plots");
|
||||
@ -100,7 +99,7 @@ public class Setup extends SubCommand {
|
||||
}
|
||||
types.add("augmented");
|
||||
types.add("partial");
|
||||
if ((args.length != 1) || !types.contains(args[0].toLowerCase())) {
|
||||
if (args.length != 1 || !types.contains(args[0].toLowerCase())) {
|
||||
MainUtil.sendMessage(plr, "&cYou must choose a world type!");
|
||||
for (String type : types) {
|
||||
int i = allTypes.indexOf(type);
|
||||
@ -157,8 +156,7 @@ public class Setup extends SubCommand {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: { // area id
|
||||
case 2: // area id
|
||||
if (!StringMan.isAlphanumericUnd(args[0])) {
|
||||
MainUtil.sendMessage(plr, "&cThe area id must be alphanumerical!");
|
||||
return false;
|
||||
@ -173,8 +171,7 @@ public class Setup extends SubCommand {
|
||||
object.current++;
|
||||
MainUtil.sendMessage(plr, "&6What should be the minimum Plot Id?");
|
||||
break;
|
||||
}
|
||||
case 3: { // min
|
||||
case 3: // min
|
||||
object.min = PlotId.fromString(args[0]);
|
||||
if (object.min == null) {
|
||||
MainUtil.sendMessage(plr, "&cYou must choose a valid minimum PlotId!");
|
||||
@ -183,8 +180,7 @@ public class Setup extends SubCommand {
|
||||
object.current++;
|
||||
MainUtil.sendMessage(plr, "&6What should be the maximum Plot Id?");
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
case 4:
|
||||
// max
|
||||
PlotId id = PlotId.fromString(args[0]);
|
||||
if (id == null) {
|
||||
@ -203,10 +199,9 @@ public class Setup extends SubCommand {
|
||||
+ "\n&8 - &7ROAD&8 - &7Terrain separated by roads"
|
||||
+ "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||
break;
|
||||
}
|
||||
case 5: { // Choose terrain
|
||||
List<String> terrain = Arrays.asList("none", "ore", "road", "all");
|
||||
if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) {
|
||||
if (args.length != 1 || !terrain.contains(args[0].toLowerCase())) {
|
||||
MainUtil.sendMessage(plr, "&cYou must choose the terrain!"
|
||||
+ "\n&8 - &2NONE&8 - &7No terrain at all"
|
||||
+ "\n&8 - &7ORE&8 - &7Just some ore veins and trees"
|
||||
@ -225,7 +220,7 @@ public class Setup extends SubCommand {
|
||||
step.getDefaultValue() + "");
|
||||
break;
|
||||
}
|
||||
case 6: { // world setup
|
||||
case 6: // world setup
|
||||
if (object.setup_index == object.step.length) {
|
||||
MainUtil.sendMessage(plr, "&6What do you want your world to be called?");
|
||||
object.setup_index = 0;
|
||||
@ -257,8 +252,7 @@ public class Setup extends SubCommand {
|
||||
step.getDefaultValue() + "");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case 7: {
|
||||
case 7:
|
||||
if (args.length != 1) {
|
||||
MainUtil.sendMessage(plr, "&cYou need to choose a world name!");
|
||||
return false;
|
||||
@ -288,7 +282,6 @@ public class Setup extends SubCommand {
|
||||
}
|
||||
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -20,16 +20,16 @@ public class Target extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
Location ploc = plr.getLocation();
|
||||
if (!ploc.isPlotArea()) {
|
||||
Location plrLocation = plr.getLocation();
|
||||
if (!plrLocation.isPlotArea()) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
Plot target = null;
|
||||
if (StringMan.isEqualIgnoreCaseToAny(args[0], "near", "nearest")) {
|
||||
int distance = Integer.MAX_VALUE;
|
||||
for (Plot plot : PS.get().getPlots(ploc.getWorld())) {
|
||||
double current = plot.getCenter().getEuclideanDistanceSquared(ploc);
|
||||
for (Plot plot : PS.get().getPlots(plrLocation.getWorld())) {
|
||||
double current = plot.getCenter().getEuclideanDistanceSquared(plrLocation);
|
||||
if (current < distance) {
|
||||
distance = (int) current;
|
||||
target = plot;
|
||||
|
@ -14,6 +14,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@ -164,9 +165,9 @@ public class Trim extends SubCommand {
|
||||
plr.sendMessage("Trim done!");
|
||||
return;
|
||||
}
|
||||
Iterator<ChunkLoc> iter = nonViable.iterator();
|
||||
ChunkLoc mcr = iter.next();
|
||||
iter.remove();
|
||||
Iterator<ChunkLoc> iterator = nonViable.iterator();
|
||||
ChunkLoc mcr = iterator.next();
|
||||
iterator.remove();
|
||||
int cbx = mcr.x << 5;
|
||||
int cbz = mcr.z << 5;
|
||||
// get all 1024 chunks
|
||||
|
@ -9,6 +9,7 @@ import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -44,15 +45,14 @@ public class Visit extends SubCommand {
|
||||
int page = Integer.MIN_VALUE;
|
||||
Collection<Plot> unsorted = null;
|
||||
switch (args.length) {
|
||||
case 2: {
|
||||
case 2:
|
||||
if (!MathMan.isInteger(args[1])) {
|
||||
sendMessage(player, C.NOT_VALID_NUMBER, "(1, ∞)");
|
||||
sendMessage(player, C.COMMAND_SYNTAX, "/plot visit " + args[0] + " [#]");
|
||||
return false;
|
||||
}
|
||||
page = Integer.parseInt(args[1]);
|
||||
}
|
||||
case 1: {
|
||||
case 1:
|
||||
UUID user = UUIDHandler.getCachedUUID(args[0], null);
|
||||
if (page == Integer.MIN_VALUE && user == null && MathMan.isInteger(args[0])) {
|
||||
page = Integer.parseInt(args[0]);
|
||||
@ -68,16 +68,13 @@ public class Visit extends SubCommand {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0: {
|
||||
case 0:
|
||||
page = 1;
|
||||
unsorted = PS.get().getPlots(player);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
|
||||
}
|
||||
}
|
||||
if (page == Integer.MIN_VALUE) {
|
||||
page = 1;
|
||||
}
|
||||
@ -85,10 +82,10 @@ public class Visit extends SubCommand {
|
||||
sendMessage(player, C.FOUND_NO_PLOTS);
|
||||
return false;
|
||||
}
|
||||
Iterator<Plot> iter = unsorted.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (!iter.next().isBasePlot()) {
|
||||
iter.remove();
|
||||
Iterator<Plot> iterator = unsorted.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (!iterator.next().isBasePlot()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
if (page < 1 || page > unsorted.size()) {
|
||||
|
@ -33,14 +33,14 @@ public class DBFunc {
|
||||
public static AbstractDB dbManager;
|
||||
|
||||
public static void movePlot(Plot originalPlot, Plot newPlot) {
|
||||
if ((originalPlot.temp == -1) || (newPlot.temp == -1)) {
|
||||
if (originalPlot.temp == -1 || newPlot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.movePlot(originalPlot, newPlot);
|
||||
DBFunc.dbManager.movePlot(originalPlot, newPlot);
|
||||
}
|
||||
|
||||
public static void validatePlots(Set<Plot> plots) {
|
||||
dbManager.validateAllPlots(plots);
|
||||
DBFunc.dbManager.validateAllPlots(plots);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,7 +74,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setOwner(plot, uuid);
|
||||
DBFunc.dbManager.setOwner(plot, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,7 +83,7 @@ public class DBFunc {
|
||||
* @param plots List containing all plot objects
|
||||
*/
|
||||
public static void createPlotsAndData(ArrayList<Plot> plots, Runnable whenDone) {
|
||||
dbManager.createPlotsAndData(plots, whenDone);
|
||||
DBFunc.dbManager.createPlotsAndData(plots, whenDone);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -95,7 +95,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.createPlot(plot);
|
||||
DBFunc.dbManager.createPlot(plot);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,7 +107,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.createPlotAndSettings(plot, whenDone);
|
||||
DBFunc.dbManager.createPlotAndSettings(plot, whenDone);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,7 +116,7 @@ public class DBFunc {
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void createTables(String database) throws Exception {
|
||||
dbManager.createTables();
|
||||
DBFunc.dbManager.createTables();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,7 +128,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.delete(plot);
|
||||
DBFunc.dbManager.delete(plot);
|
||||
plot.temp = -1;
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.deleteRatings(plot);
|
||||
DBFunc.dbManager.deleteRatings(plot);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,7 +151,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.deleteHelpers(plot);
|
||||
DBFunc.dbManager.deleteHelpers(plot);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -162,7 +162,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.deleteTrusted(plot);
|
||||
DBFunc.dbManager.deleteTrusted(plot);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,7 +173,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.deleteDenied(plot);
|
||||
DBFunc.dbManager.deleteDenied(plot);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,7 +184,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.deleteComments(plot);
|
||||
DBFunc.dbManager.deleteComments(plot);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,11 +199,11 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.deleteSettings(plot);
|
||||
DBFunc.dbManager.deleteSettings(plot);
|
||||
}
|
||||
|
||||
public static void delete(PlotCluster toDelete) {
|
||||
dbManager.delete(toDelete);
|
||||
DBFunc.dbManager.delete(toDelete);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,7 +216,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.createPlotSettings(id, plot);
|
||||
DBFunc.dbManager.createPlotSettings(id, plot);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,32 +227,32 @@ public class DBFunc {
|
||||
* @return ID
|
||||
*/
|
||||
public static int getId(Plot plot) {
|
||||
return dbManager.getId(plot);
|
||||
return DBFunc.dbManager.getId(plot);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Plots
|
||||
*/
|
||||
public static HashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
||||
return dbManager.getPlots();
|
||||
return DBFunc.dbManager.getPlots();
|
||||
}
|
||||
|
||||
public static void setMerged(Plot plot, boolean[] merged) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setMerged(plot, merged);
|
||||
DBFunc.dbManager.setMerged(plot, merged);
|
||||
}
|
||||
|
||||
public static void setFlags(Plot plot, Collection<Flag> flags) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setFlags(plot, flags);
|
||||
DBFunc.dbManager.setFlags(plot, flags);
|
||||
}
|
||||
|
||||
public static void setFlags(PlotCluster cluster, Collection<Flag> flags) {
|
||||
dbManager.setFlags(cluster, flags);
|
||||
DBFunc.dbManager.setFlags(cluster, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -263,15 +263,15 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setAlias(plot, alias);
|
||||
DBFunc.dbManager.setAlias(plot, alias);
|
||||
}
|
||||
|
||||
public static void purgeIds(Set<Integer> uniqueIds) {
|
||||
dbManager.purgeIds(uniqueIds);
|
||||
DBFunc.dbManager.purgeIds(uniqueIds);
|
||||
}
|
||||
|
||||
public static void purge(PlotArea area, Set<PlotId> plotIds) {
|
||||
dbManager.purge(area, plotIds);
|
||||
DBFunc.dbManager.purge(area, plotIds);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -282,7 +282,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setPosition(plot, position);
|
||||
DBFunc.dbManager.setPosition(plot, position);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -290,17 +290,17 @@ public class DBFunc {
|
||||
* @param comment
|
||||
*/
|
||||
public static void removeComment(Plot plot, PlotComment comment) {
|
||||
if ((plot != null) && (plot.temp == -1)) {
|
||||
if (plot != null && plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.removeComment(plot, comment);
|
||||
DBFunc.dbManager.removeComment(plot, comment);
|
||||
}
|
||||
|
||||
public static void clearInbox(Plot plot, String inbox) {
|
||||
if ((plot != null) && (plot.temp == -1)) {
|
||||
if (plot != null && plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.clearInbox(plot, inbox);
|
||||
DBFunc.dbManager.clearInbox(plot, inbox);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -308,20 +308,20 @@ public class DBFunc {
|
||||
* @param comment
|
||||
*/
|
||||
public static void setComment(Plot plot, PlotComment comment) {
|
||||
if ((plot != null) && (plot.temp == -1)) {
|
||||
if (plot != null && plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setComment(plot, comment);
|
||||
DBFunc.dbManager.setComment(plot, comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param plot
|
||||
*/
|
||||
public static void getComments(Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone) {
|
||||
if ((plot != null) && (plot.temp == -1)) {
|
||||
if (plot != null && plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.getComments(plot, inbox, whenDone);
|
||||
DBFunc.dbManager.getComments(plot, inbox, whenDone);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -332,7 +332,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.removeTrusted(plot, uuid);
|
||||
DBFunc.dbManager.removeTrusted(plot, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -340,14 +340,14 @@ public class DBFunc {
|
||||
* @param uuid
|
||||
*/
|
||||
public static void removeHelper(PlotCluster cluster, UUID uuid) {
|
||||
dbManager.removeHelper(cluster, uuid);
|
||||
DBFunc.dbManager.removeHelper(cluster, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cluster
|
||||
*/
|
||||
public static void createCluster(PlotCluster cluster) {
|
||||
dbManager.createCluster(cluster);
|
||||
DBFunc.dbManager.createCluster(cluster);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -356,7 +356,7 @@ public class DBFunc {
|
||||
* @param max
|
||||
*/
|
||||
public static void resizeCluster(PlotCluster current, PlotId min, PlotId max) {
|
||||
dbManager.resizeCluster(current, min, max);
|
||||
DBFunc.dbManager.resizeCluster(current, min, max);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -367,7 +367,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.removeMember(plot, uuid);
|
||||
DBFunc.dbManager.removeMember(plot, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -376,7 +376,7 @@ public class DBFunc {
|
||||
* @param uuid
|
||||
*/
|
||||
public static void removeInvited(PlotCluster cluster, UUID uuid) {
|
||||
dbManager.removeInvited(cluster, uuid);
|
||||
DBFunc.dbManager.removeInvited(cluster, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -387,11 +387,11 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setTrusted(plot, uuid);
|
||||
DBFunc.dbManager.setTrusted(plot, uuid);
|
||||
}
|
||||
|
||||
public static void setHelper(PlotCluster cluster, UUID uuid) {
|
||||
dbManager.setHelper(cluster, uuid);
|
||||
DBFunc.dbManager.setHelper(cluster, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -402,11 +402,11 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setMember(plot, uuid);
|
||||
DBFunc.dbManager.setMember(plot, uuid);
|
||||
}
|
||||
|
||||
public static void setInvited(PlotCluster cluster, UUID uuid) {
|
||||
dbManager.setInvited(cluster, uuid);
|
||||
DBFunc.dbManager.setInvited(cluster, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -417,7 +417,7 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.removeDenied(plot, uuid);
|
||||
DBFunc.dbManager.removeDenied(plot, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -428,33 +428,33 @@ public class DBFunc {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setDenied(plot, uuid);
|
||||
DBFunc.dbManager.setDenied(plot, uuid);
|
||||
}
|
||||
|
||||
public static HashMap<UUID, Integer> getRatings(Plot plot) {
|
||||
if (plot.temp == -1) {
|
||||
return new HashMap<>(0);
|
||||
}
|
||||
return dbManager.getRatings(plot);
|
||||
return DBFunc.dbManager.getRatings(plot);
|
||||
}
|
||||
|
||||
public static void setRating(Plot plot, UUID rater, int value) {
|
||||
if (plot.temp == -1) {
|
||||
return;
|
||||
}
|
||||
dbManager.setRating(plot, rater, value);
|
||||
DBFunc.dbManager.setRating(plot, rater, value);
|
||||
}
|
||||
|
||||
public static HashMap<String, Set<PlotCluster>> getClusters() {
|
||||
return dbManager.getClusters();
|
||||
return DBFunc.dbManager.getClusters();
|
||||
}
|
||||
|
||||
public static void setPosition(PlotCluster cluster, String position) {
|
||||
dbManager.setPosition(cluster, position);
|
||||
DBFunc.dbManager.setPosition(cluster, position);
|
||||
}
|
||||
|
||||
public static void replaceWorld(String oldWorld, String newWorld, PlotId min, PlotId max) {
|
||||
dbManager.replaceWorld(oldWorld, newWorld, min, max);
|
||||
DBFunc.dbManager.replaceWorld(oldWorld, newWorld, min, max);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -463,10 +463,10 @@ public class DBFunc {
|
||||
* @param now
|
||||
*/
|
||||
public static void replaceUUID(UUID old, UUID now) {
|
||||
dbManager.replaceUUID(old, now);
|
||||
DBFunc.dbManager.replaceUUID(old, now);
|
||||
}
|
||||
|
||||
public static void close() {
|
||||
dbManager.close();
|
||||
DBFunc.dbManager.close();
|
||||
}
|
||||
}
|
||||
|
@ -40,9 +40,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public class SQLManager implements AbstractDB {
|
||||
// Public final
|
||||
public final String SET_OWNER;
|
||||
@ -187,11 +185,11 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBatch(PreparedStatement stmt) {
|
||||
public void addBatch(PreparedStatement statement) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PreparedStatement stmt) {
|
||||
public void execute(PreparedStatement statement) {
|
||||
}
|
||||
|
||||
};
|
||||
@ -221,11 +219,11 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBatch(PreparedStatement stmt) {
|
||||
public void addBatch(PreparedStatement statement) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PreparedStatement stmt) {
|
||||
public void execute(PreparedStatement statement) {
|
||||
}
|
||||
|
||||
};
|
||||
@ -252,11 +250,11 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBatch(PreparedStatement stmt) {
|
||||
public void addBatch(PreparedStatement statement) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PreparedStatement stmt) {
|
||||
public void execute(PreparedStatement statement) {
|
||||
}
|
||||
|
||||
};
|
||||
@ -294,7 +292,7 @@ public class SQLManager implements AbstractDB {
|
||||
this.connection.setAutoCommit(false);
|
||||
}
|
||||
String method = null;
|
||||
PreparedStatement stmt = null;
|
||||
PreparedStatement statement = null;
|
||||
UniqueStatement task = null;
|
||||
UniqueStatement lastTask = null;
|
||||
for (Entry<Plot, Queue<UniqueStatement>> entry : this.plotTasks.entrySet()) {
|
||||
@ -306,22 +304,22 @@ public class SQLManager implements AbstractDB {
|
||||
task = this.plotTasks.get(plot).remove();
|
||||
count++;
|
||||
if (task != null) {
|
||||
if (task._method == null || !task._method.equals(method)) {
|
||||
if (stmt != null) {
|
||||
lastTask.execute(stmt);
|
||||
stmt.close();
|
||||
if (task.method == null || !task.method.equals(method)) {
|
||||
if (statement != null) {
|
||||
lastTask.execute(statement);
|
||||
statement.close();
|
||||
}
|
||||
method = task._method;
|
||||
stmt = task.get();
|
||||
method = task.method;
|
||||
statement = task.get();
|
||||
}
|
||||
task.set(stmt);
|
||||
task.addBatch(stmt);
|
||||
task.set(statement);
|
||||
task.addBatch(statement);
|
||||
}
|
||||
lastTask = task;
|
||||
}
|
||||
if (stmt != null && task != null) {
|
||||
task.execute(stmt);
|
||||
stmt.close();
|
||||
if (statement != null && task != null) {
|
||||
task.execute(statement);
|
||||
statement.close();
|
||||
}
|
||||
}
|
||||
if (!this.playerTasks.isEmpty()) {
|
||||
@ -330,7 +328,7 @@ public class SQLManager implements AbstractDB {
|
||||
this.connection.setAutoCommit(false);
|
||||
}
|
||||
String method = null;
|
||||
PreparedStatement stmt = null;
|
||||
PreparedStatement statement = null;
|
||||
UniqueStatement task = null;
|
||||
UniqueStatement lastTask = null;
|
||||
for (Entry<UUID, Queue<UniqueStatement>> entry : this.playerTasks.entrySet()) {
|
||||
@ -342,22 +340,22 @@ public class SQLManager implements AbstractDB {
|
||||
task = this.playerTasks.get(uuid).remove();
|
||||
count++;
|
||||
if (task != null) {
|
||||
if (task._method == null || !task._method.equals(method)) {
|
||||
if (stmt != null) {
|
||||
lastTask.execute(stmt);
|
||||
stmt.close();
|
||||
if (task.method == null || !task.method.equals(method)) {
|
||||
if (statement != null) {
|
||||
lastTask.execute(statement);
|
||||
statement.close();
|
||||
}
|
||||
method = task._method;
|
||||
stmt = task.get();
|
||||
method = task.method;
|
||||
statement = task.get();
|
||||
}
|
||||
task.set(stmt);
|
||||
task.addBatch(stmt);
|
||||
task.set(statement);
|
||||
task.addBatch(statement);
|
||||
}
|
||||
lastTask = task;
|
||||
}
|
||||
if (stmt != null && task != null) {
|
||||
task.execute(stmt);
|
||||
stmt.close();
|
||||
if (statement != null && task != null) {
|
||||
task.execute(statement);
|
||||
statement.close();
|
||||
}
|
||||
}
|
||||
if (!this.clusterTasks.isEmpty()) {
|
||||
@ -366,7 +364,7 @@ public class SQLManager implements AbstractDB {
|
||||
this.connection.setAutoCommit(false);
|
||||
}
|
||||
String method = null;
|
||||
PreparedStatement stmt = null;
|
||||
PreparedStatement statement = null;
|
||||
UniqueStatement task = null;
|
||||
UniqueStatement lastTask = null;
|
||||
for (Entry<PlotCluster, Queue<UniqueStatement>> entry : this.clusterTasks.entrySet()) {
|
||||
@ -378,22 +376,22 @@ public class SQLManager implements AbstractDB {
|
||||
task = this.clusterTasks.get(cluster).remove();
|
||||
count++;
|
||||
if (task != null) {
|
||||
if (task._method == null || !task._method.equals(method)) {
|
||||
if (stmt != null) {
|
||||
lastTask.execute(stmt);
|
||||
stmt.close();
|
||||
if (task.method == null || !task.method.equals(method)) {
|
||||
if (statement != null) {
|
||||
lastTask.execute(statement);
|
||||
statement.close();
|
||||
}
|
||||
method = task._method;
|
||||
stmt = task.get();
|
||||
method = task.method;
|
||||
statement = task.get();
|
||||
}
|
||||
task.set(stmt);
|
||||
task.addBatch(stmt);
|
||||
task.set(statement);
|
||||
task.addBatch(statement);
|
||||
}
|
||||
lastTask = task;
|
||||
}
|
||||
if (stmt != null && task != null) {
|
||||
task.execute(stmt);
|
||||
stmt.close();
|
||||
if (statement != null && task != null) {
|
||||
task.execute(statement);
|
||||
statement.close();
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
@ -614,7 +612,7 @@ public class SQLManager implements AbstractDB {
|
||||
try {
|
||||
stmt.setString(i * 5 + 3, plot.owner.toString());
|
||||
} catch (SQLException e) {
|
||||
stmt.setString(i * 5 + 3, everyone.toString());
|
||||
stmt.setString(i * 5 + 3, AbstractDB.everyone.toString());
|
||||
}
|
||||
stmt.setString(i * 5 + 4, plot.getArea().toString());
|
||||
stmt.setTimestamp(i * 5 + 5, new Timestamp(plot.getTimestamp()));
|
||||
@ -628,7 +626,7 @@ public class SQLManager implements AbstractDB {
|
||||
try {
|
||||
stmt.setString(i * 6 + 4, plot.owner.toString());
|
||||
} catch (SQLException e1) {
|
||||
stmt.setString(i * 6 + 4, everyone.toString());
|
||||
stmt.setString(i * 6 + 4, AbstractDB.everyone.toString());
|
||||
}
|
||||
stmt.setString(i * 6 + 5, plot.getArea().toString());
|
||||
stmt.setTimestamp(i * 6 + 6, new Timestamp(plot.getTimestamp()));
|
||||
@ -989,14 +987,14 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PreparedStatement stmt) {
|
||||
public void execute(PreparedStatement statement) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBatch(PreparedStatement stmt) throws SQLException {
|
||||
stmt.executeUpdate();
|
||||
ResultSet keys = stmt.getGeneratedKeys();
|
||||
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||
statement.executeUpdate();
|
||||
ResultSet keys = statement.getGeneratedKeys();
|
||||
if (keys.next()) {
|
||||
plot.temp = keys.getInt(1);
|
||||
}
|
||||
@ -1476,8 +1474,9 @@ public class SQLManager implements AbstractDB {
|
||||
if (this.mySQL && !PS.get().checkVersion(oldVersion, 3, 3, 2)) {
|
||||
try (Statement stmt = this.connection.createStatement()) {
|
||||
stmt.executeUpdate("ALTER TABLE `" + this.prefix + "plots` DROP INDEX `unique_alias`");
|
||||
} catch (SQLException ignore) {
|
||||
//ignored
|
||||
}
|
||||
catch (SQLException ignore) {}
|
||||
}
|
||||
DatabaseMetaData data = this.connection.getMetaData();
|
||||
ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot_plot_id");
|
||||
@ -1599,7 +1598,7 @@ public class SQLManager implements AbstractDB {
|
||||
*/
|
||||
@Override
|
||||
public HashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
||||
HashMap<String, HashMap<PlotId, Plot>> newplots = new HashMap<>();
|
||||
HashMap<String, HashMap<PlotId, Plot>> newPlots = new HashMap<>();
|
||||
HashMap<Integer, Plot> plots = new HashMap<>();
|
||||
try {
|
||||
HashSet<String> areas = new HashSet<>();
|
||||
@ -1660,7 +1659,7 @@ public class SQLManager implements AbstractDB {
|
||||
long time = timestamp.getTime();
|
||||
Plot p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(), new HashSet<UUID>(), "", null, null, null,
|
||||
new boolean[]{false, false, false, false}, time, id);
|
||||
HashMap<PlotId, Plot> map = newplots.get(areaid);
|
||||
HashMap<PlotId, Plot> map = newPlots.get(areaid);
|
||||
if (map != null) {
|
||||
Plot last = map.put(p.getId(), p);
|
||||
if (last != null) {
|
||||
@ -1675,7 +1674,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
} else {
|
||||
map = new HashMap<>();
|
||||
newplots.put(areaid, map);
|
||||
newPlots.put(areaid, map);
|
||||
map.put(p.getId(), p);
|
||||
}
|
||||
plots.put(id, p);
|
||||
@ -1872,9 +1871,9 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
boolean invalidPlot = false;
|
||||
for (Entry<String, AtomicInteger> entry : noExist.entrySet()) {
|
||||
String worldname = entry.getKey();
|
||||
String worldName = entry.getKey();
|
||||
invalidPlot = true;
|
||||
PS.debug("&c[WARNING] Found " + entry.getValue().intValue() + " plots in DB for non existant world; '" + worldname + "'.");
|
||||
PS.debug("&c[WARNING] Found " + entry.getValue().intValue() + " plots in DB for non existent world; '" + worldName + "'.");
|
||||
}
|
||||
if (invalidPlot) {
|
||||
PS.debug("&c[WARNING] - Please create the world/s or remove the plots using the purge command");
|
||||
@ -1883,7 +1882,7 @@ public class SQLManager implements AbstractDB {
|
||||
PS.debug("&7[WARN] " + "Failed to load plots.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return newplots;
|
||||
return newPlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2072,9 +2071,9 @@ public class SQLManager implements AbstractDB {
|
||||
e.printStackTrace();
|
||||
PS.debug("&c[ERROR] " + "FAILED TO PURGE AREA '" + area + "'!");
|
||||
}
|
||||
for (Iterator<PlotId> iter = plots.iterator(); iter.hasNext(); ) {
|
||||
PlotId plotId = iter.next();
|
||||
iter.remove();
|
||||
for (Iterator<PlotId> iterator = plots.iterator(); iterator.hasNext(); ) {
|
||||
PlotId plotId = iterator.next();
|
||||
iterator.remove();
|
||||
PlotId id = new PlotId(plotId.x, plotId.y);
|
||||
area.removePlot(id);
|
||||
}
|
||||
@ -2178,7 +2177,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PreparedStatement stmt) {
|
||||
public void execute(PreparedStatement statement) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -2480,11 +2479,12 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PreparedStatement stmt) {}
|
||||
public void execute(PreparedStatement statement) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBatch(PreparedStatement stmt) throws SQLException {
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
|
||||
Map<String, byte[]> metaMap = new HashMap<>();
|
||||
|
||||
@ -2673,7 +2673,7 @@ public class SQLManager implements AbstractDB {
|
||||
for (Entry<String, Integer> entry : noExist.entrySet()) {
|
||||
String a = entry.getKey();
|
||||
invalidPlot = true;
|
||||
PS.debug("&c[WARNING] Found " + noExist.get(a) + " clusters in DB for non existant area; '" + a + "'.");
|
||||
PS.debug("&c[WARNING] Found " + noExist.get(a) + " clusters in DB for non existent area; '" + a + "'.");
|
||||
}
|
||||
if (invalidPlot) {
|
||||
PS.debug("&c[WARNING] - Please create the world/s or remove the clusters using the purge command");
|
||||
@ -2782,14 +2782,14 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PreparedStatement stmt) {
|
||||
public void execute(PreparedStatement statement) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBatch(PreparedStatement stmt) throws SQLException {
|
||||
stmt.executeUpdate();
|
||||
ResultSet keys = stmt.getGeneratedKeys();
|
||||
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||
statement.executeUpdate();
|
||||
ResultSet keys = statement.getGeneratedKeys();
|
||||
if (keys.next()) {
|
||||
cluster.temp = keys.getInt(1);
|
||||
}
|
||||
@ -2943,29 +2943,29 @@ public class SQLManager implements AbstractDB {
|
||||
if (plot.temp == -1) {
|
||||
continue;
|
||||
}
|
||||
HashMap<PlotId, Plot> worldplots = database.get(plot.getArea().toString());
|
||||
if (worldplots == null) {
|
||||
HashMap<PlotId, Plot> worldPlots = database.get(plot.getArea().toString());
|
||||
if (worldPlots == null) {
|
||||
PS.debug("&8 - &7Creating plot (1): " + plot);
|
||||
toCreate.add(plot);
|
||||
continue;
|
||||
}
|
||||
Plot dataplot = worldplots.remove(plot.getId());
|
||||
if (dataplot == null) {
|
||||
Plot dataPlot = worldPlots.remove(plot.getId());
|
||||
if (dataPlot == null) {
|
||||
PS.debug("&8 - &7Creating plot (2): " + plot);
|
||||
toCreate.add(plot);
|
||||
continue;
|
||||
}
|
||||
// owner
|
||||
if (!plot.owner.equals(dataplot.owner)) {
|
||||
if (!plot.owner.equals(dataPlot.owner)) {
|
||||
PS.debug("&8 - &7Setting owner: " + plot + " -> " + MainUtil.getName(plot.owner));
|
||||
setOwner(plot, plot.owner);
|
||||
}
|
||||
// trusted
|
||||
if (!plot.getTrusted().equals(dataplot.getTrusted())) {
|
||||
if (!plot.getTrusted().equals(dataPlot.getTrusted())) {
|
||||
HashSet<UUID> toAdd = (HashSet<UUID>) plot.getTrusted().clone();
|
||||
HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getTrusted().clone();
|
||||
HashSet<UUID> toRemove = (HashSet<UUID>) dataPlot.getTrusted().clone();
|
||||
toRemove.removeAll(plot.getTrusted());
|
||||
toAdd.removeAll(dataplot.getTrusted());
|
||||
toAdd.removeAll(dataPlot.getTrusted());
|
||||
PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " trusted for: " + plot);
|
||||
if (!toRemove.isEmpty()) {
|
||||
for (UUID uuid : toRemove) {
|
||||
@ -2978,11 +2978,11 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!plot.getMembers().equals(dataplot.getMembers())) {
|
||||
if (!plot.getMembers().equals(dataPlot.getMembers())) {
|
||||
HashSet<UUID> toAdd = (HashSet<UUID>) plot.getMembers().clone();
|
||||
HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getMembers().clone();
|
||||
HashSet<UUID> toRemove = (HashSet<UUID>) dataPlot.getMembers().clone();
|
||||
toRemove.removeAll(plot.getMembers());
|
||||
toAdd.removeAll(dataplot.getMembers());
|
||||
toAdd.removeAll(dataPlot.getMembers());
|
||||
PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " members for: " + plot);
|
||||
if (!toRemove.isEmpty()) {
|
||||
for (UUID uuid : toRemove) {
|
||||
@ -2995,11 +2995,11 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!plot.getDenied().equals(dataplot.getDenied())) {
|
||||
if (!plot.getDenied().equals(dataPlot.getDenied())) {
|
||||
HashSet<UUID> toAdd = (HashSet<UUID>) plot.getDenied().clone();
|
||||
HashSet<UUID> toRemove = (HashSet<UUID>) dataplot.getDenied().clone();
|
||||
HashSet<UUID> toRemove = (HashSet<UUID>) dataPlot.getDenied().clone();
|
||||
toRemove.removeAll(plot.getDenied());
|
||||
toAdd.removeAll(dataplot.getDenied());
|
||||
toAdd.removeAll(dataPlot.getDenied());
|
||||
PS.debug("&8 - &7Correcting " + (toAdd.size() + toRemove.size()) + " denied for: " + plot);
|
||||
if (!toRemove.isEmpty()) {
|
||||
for (UUID uuid : toRemove) {
|
||||
@ -3013,13 +3013,13 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
}
|
||||
boolean[] pm = plot.getMerged();
|
||||
boolean[] dm = dataplot.getMerged();
|
||||
boolean[] dm = dataPlot.getMerged();
|
||||
if (pm[0] != dm[0] || pm[1] != dm[1]) {
|
||||
PS.debug("&8 - &7Correcting merge for: " + plot);
|
||||
setMerged(dataplot, plot.getMerged());
|
||||
setMerged(dataPlot, plot.getMerged());
|
||||
}
|
||||
HashMap<String, Flag> pf = plot.getFlags();
|
||||
HashMap<String, Flag> df = dataplot.getFlags();
|
||||
HashMap<String, Flag> df = dataPlot.getFlags();
|
||||
if (!pf.isEmpty() && !df.isEmpty()) {
|
||||
if (pf.size() != df.size() || !StringMan.isEqual(StringMan.joinOrdered(pf.values(), ","), StringMan.joinOrdered(df.values(), ","))) {
|
||||
PS.debug("&8 - &7Correcting flags for: " + plot);
|
||||
@ -3146,18 +3146,18 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
public abstract class UniqueStatement {
|
||||
|
||||
public String _method;
|
||||
public String method;
|
||||
|
||||
public UniqueStatement(String method) {
|
||||
this._method = method;
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public void addBatch(PreparedStatement stmt) throws SQLException {
|
||||
stmt.addBatch();
|
||||
public void addBatch(PreparedStatement statement) throws SQLException {
|
||||
statement.addBatch();
|
||||
}
|
||||
|
||||
public void execute(PreparedStatement stmt) throws SQLException {
|
||||
stmt.executeBatch();
|
||||
public void execute(PreparedStatement statement) throws SQLException {
|
||||
statement.executeBatch();
|
||||
}
|
||||
|
||||
public abstract PreparedStatement get() throws SQLException;
|
||||
|
@ -11,7 +11,7 @@ public abstract class StmtMod<T> {
|
||||
|
||||
public String getCreateMySQL(int size, String query, int params) {
|
||||
StringBuilder statement = new StringBuilder(query);
|
||||
for (int i = 0; i < (size - 1); i++) {
|
||||
for (int i = 0; i < size - 1; i++) {
|
||||
statement.append("(" + StringMan.repeat(",?", params).substring(1) + "),");
|
||||
}
|
||||
statement.append("(" + StringMan.repeat(",?", params).substring(1) + ")");
|
||||
@ -21,7 +21,7 @@ public abstract class StmtMod<T> {
|
||||
public String getCreateSQLite(int size, String query, int params) {
|
||||
StringBuilder statement = new StringBuilder(query);
|
||||
String modParams = StringMan.repeat(",?", params).substring(1);
|
||||
for (int i = 0; i < (size - 1); i++) {
|
||||
for (int i = 0; i < size - 1; i++) {
|
||||
statement.append("UNION SELECT " + modParams + " ");
|
||||
}
|
||||
return statement.toString();
|
||||
|
@ -12,7 +12,7 @@ public class AbstractFlag {
|
||||
public final String key;
|
||||
public final FlagValue<?> value;
|
||||
|
||||
public AbstractFlag(final String key) {
|
||||
public AbstractFlag(String key) {
|
||||
this(key, new FlagValue.StringValue());
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ public class AbstractFlag {
|
||||
* The key must be alphabetical characters and <= 16 characters in length
|
||||
* @param key
|
||||
*/
|
||||
public AbstractFlag(final String key, final FlagValue<?> value) {
|
||||
public AbstractFlag(String key, FlagValue<?> value) {
|
||||
if (!StringMan.isAlpha(key.replaceAll("_", "").replaceAll("-", ""))) {
|
||||
throw new IllegalArgumentException("Flag must be alphabetic characters");
|
||||
}
|
||||
@ -37,23 +37,23 @@ public class AbstractFlag {
|
||||
}
|
||||
|
||||
public boolean isList() {
|
||||
return value instanceof FlagValue.ListValue;
|
||||
return this.value instanceof FlagValue.ListValue;
|
||||
}
|
||||
|
||||
public Object parseValueRaw(final String value) {
|
||||
public Object parseValueRaw(String value) {
|
||||
try {
|
||||
return this.value.parse(value);
|
||||
} catch (final Exception e) {
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString(final Object t) {
|
||||
return value.toString(t);
|
||||
public String toString(Object t) {
|
||||
return this.value.toString(t);
|
||||
}
|
||||
|
||||
public String getValueDesc() {
|
||||
return value.getDescription();
|
||||
return this.value.getDescription();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -62,28 +62,28 @@ public class AbstractFlag {
|
||||
* @return String
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return key;
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return key.hashCode();
|
||||
return this.key.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object other) {
|
||||
public boolean equals(Object other) {
|
||||
if (other == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof AbstractFlag)) {
|
||||
return false;
|
||||
}
|
||||
final AbstractFlag otherObj = (AbstractFlag) other;
|
||||
return otherObj.key.equals(key);
|
||||
AbstractFlag otherObj = (AbstractFlag) other;
|
||||
return otherObj.key.equals(this.key);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@ -26,7 +27,7 @@ public abstract class FlagValue<T> {
|
||||
}
|
||||
|
||||
public boolean validValue(Object value) {
|
||||
return (value != null) && (value.getClass() == this.clazz);
|
||||
return value != null && value.getClass() == this.clazz;
|
||||
}
|
||||
|
||||
public String toString(Object t) {
|
||||
@ -59,20 +60,17 @@ public abstract class FlagValue<T> {
|
||||
case "1":
|
||||
case "yes":
|
||||
case "allow":
|
||||
case "true": {
|
||||
case "true":
|
||||
return true;
|
||||
}
|
||||
case "0":
|
||||
case "no":
|
||||
case "deny":
|
||||
case "false": {
|
||||
case "false":
|
||||
return false;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
@ -291,7 +289,7 @@ public abstract class FlagValue<T> {
|
||||
return new PlotBlock(id, data);
|
||||
} catch (Exception e) {
|
||||
StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(t);
|
||||
if ((value == null) || (value.match > 1)) {
|
||||
if (value == null || value.match > 1) {
|
||||
return null;
|
||||
}
|
||||
return value.best;
|
||||
@ -339,7 +337,7 @@ public abstract class FlagValue<T> {
|
||||
block = new PlotBlock(id, data);
|
||||
} catch (Exception e) {
|
||||
StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(t);
|
||||
if ((value == null) || (value.match > 1)) {
|
||||
if (value == null || value.match > 1) {
|
||||
continue;
|
||||
}
|
||||
block = value.best;
|
||||
|
@ -20,39 +20,31 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
@Override
|
||||
public boolean setComponent(PlotArea plotworld, PlotId plotid, String component, PlotBlock[] blocks) {
|
||||
switch (component) {
|
||||
case "floor": {
|
||||
case "floor":
|
||||
setFloor(plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "wall": {
|
||||
case "wall":
|
||||
setWallFilling(plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "all": {
|
||||
case "all":
|
||||
setAll(plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "air": {
|
||||
case "air":
|
||||
setAir(plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "main": {
|
||||
case "main":
|
||||
setMain(plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "middle": {
|
||||
case "middle":
|
||||
setMiddle(plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "outline": {
|
||||
case "outline":
|
||||
setOutline(plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "border": {
|
||||
case "border":
|
||||
setWall(plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -459,6 +451,6 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
plot = plot.getBasePlot(false);
|
||||
Location bot = plot.getBottomAbs();
|
||||
return new com.intellectualcrafters.plot.object.Location(plotworld.worldname, bot.getX() - 1, dpw.ROAD_HEIGHT + 1, bot.getZ() - 2);
|
||||
return new Location(plotworld.worldname, bot.getX() - 1, dpw.ROAD_HEIGHT + 1, bot.getZ() - 2);
|
||||
}
|
||||
}
|
||||
|
@ -172,23 +172,24 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
|
||||
public void setupSchematics() {
|
||||
this.G_SCH = new HashMap<>();
|
||||
File schem1File = MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname + "/sideroad.schematic");
|
||||
File schem2File =
|
||||
File schematic1File =
|
||||
MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname + "/sideroad.schematic");
|
||||
File schematic2File =
|
||||
MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname + "/intersection.schematic");
|
||||
File schem3File = MainUtil.getFile(PS.get().IMP.getDirectory(), "schematics/GEN_ROAD_SCHEMATIC/" + this.worldname + "/plot.schematic");
|
||||
Schematic schem1 = SchematicHandler.manager.getSchematic(schem1File);
|
||||
Schematic schem2 = SchematicHandler.manager.getSchematic(schem2File);
|
||||
Schematic schem3 = SchematicHandler.manager.getSchematic(schem3File);
|
||||
Schematic schematic1 = SchematicHandler.manager.getSchematic(schematic1File);
|
||||
Schematic schematic2 = SchematicHandler.manager.getSchematic(schematic2File);
|
||||
Schematic schematic3 = SchematicHandler.manager.getSchematic(schem3File);
|
||||
int shift = this.ROAD_WIDTH / 2;
|
||||
int oddshift = 0;
|
||||
if ((this.ROAD_WIDTH & 1) != 0) {
|
||||
oddshift = 1;
|
||||
}
|
||||
if (schem3 != null) {
|
||||
if (schematic3 != null) {
|
||||
this.PLOT_SCHEMATIC = true;
|
||||
short[] ids = schem3.getIds();
|
||||
byte[] datas = schem3.getDatas();
|
||||
Dimension d3 = schem3.getSchematicDimension();
|
||||
short[] ids = schematic3.getIds();
|
||||
byte[] datas = schematic3.getDatas();
|
||||
Dimension d3 = schematic3.getSchematicDimension();
|
||||
short w3 = (short) d3.getX();
|
||||
short l3 = (short) d3.getZ();
|
||||
short h3 = (short) d3.getY();
|
||||
@ -214,7 +215,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
}
|
||||
}
|
||||
}
|
||||
HashSet<PlotItem> items = schem3.getItems();
|
||||
HashSet<PlotItem> items = schematic3.getItems();
|
||||
if (items != null) {
|
||||
this.G_SCH_STATE = new HashMap<>();
|
||||
for (PlotItem item : items) {
|
||||
@ -235,7 +236,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (schem1 == null || schem2 == null || this.ROAD_WIDTH == 0) {
|
||||
if (schematic1 == null || schematic2 == null || this.ROAD_WIDTH == 0) {
|
||||
PS.debug(C.PREFIX + "&3 - schematic: &7false");
|
||||
return;
|
||||
}
|
||||
@ -243,17 +244,17 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
// Do not populate road if using schematic population
|
||||
this.ROAD_BLOCK = new PlotBlock(this.ROAD_BLOCK.id, (byte) 0);
|
||||
|
||||
short[] ids1 = schem1.getIds();
|
||||
byte[] datas1 = schem1.getDatas();
|
||||
short[] ids1 = schematic1.getIds();
|
||||
byte[] datas1 = schematic1.getDatas();
|
||||
|
||||
short[] ids2 = schem2.getIds();
|
||||
byte[] datas2 = schem2.getDatas();
|
||||
short[] ids2 = schematic2.getIds();
|
||||
byte[] datas2 = schematic2.getDatas();
|
||||
|
||||
Dimension d1 = schem1.getSchematicDimension();
|
||||
Dimension d1 = schematic1.getSchematicDimension();
|
||||
short w1 = (short) d1.getX();
|
||||
short l1 = (short) d1.getZ();
|
||||
short h1 = (short) d1.getY();
|
||||
Dimension d2 = schem2.getSchematicDimension();
|
||||
Dimension d2 = schematic2.getSchematicDimension();
|
||||
short w2 = (short) d2.getX();
|
||||
short l2 = (short) d2.getZ();
|
||||
short h2 = (short) d2.getY();
|
||||
@ -293,9 +294,9 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
x += this.SIZE;
|
||||
}
|
||||
if (rotate) {
|
||||
byte newdata = rotate(id, data);
|
||||
if (data != 0 || newdata != 0) {
|
||||
data = newdata;
|
||||
byte newData = rotate(id, data);
|
||||
if (data != 0 || newData != 0) {
|
||||
data = newData;
|
||||
}
|
||||
}
|
||||
int pair = MathMan.pair(x, z);
|
||||
|
@ -223,9 +223,9 @@ public abstract class HybridUtils {
|
||||
}
|
||||
if (chunks.size() < 1024) {
|
||||
if (!regions.isEmpty()) {
|
||||
Iterator<ChunkLoc> iter = regions.iterator();
|
||||
ChunkLoc loc = iter.next();
|
||||
iter.remove();
|
||||
Iterator<ChunkLoc> iterator = regions.iterator();
|
||||
ChunkLoc loc = iterator.next();
|
||||
iterator.remove();
|
||||
PS.debug("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)");
|
||||
PS.debug(" - Remaining: " + regions.size());
|
||||
chunks.addAll(getChunks(loc));
|
||||
@ -237,9 +237,9 @@ public abstract class HybridUtils {
|
||||
if (System.currentTimeMillis() - baseTime - last.get() > 2000 && last.get() != 0) {
|
||||
last.set(0);
|
||||
PS.debug(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
|
||||
Iterator<ChunkLoc> iter = chunks.iterator();
|
||||
final ChunkLoc chunk = iter.next();
|
||||
iter.remove();
|
||||
Iterator<ChunkLoc> iterator = chunks.iterator();
|
||||
final ChunkLoc chunk = iterator.next();
|
||||
iterator.remove();
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -252,9 +252,9 @@ public abstract class HybridUtils {
|
||||
}
|
||||
if (System.currentTimeMillis() - baseTime - last.get() < 1500 && last.get() != 0) {
|
||||
while (System.currentTimeMillis() < diff && !chunks.isEmpty()) {
|
||||
Iterator<ChunkLoc> iter = chunks.iterator();
|
||||
final ChunkLoc chunk = iter.next();
|
||||
iter.remove();
|
||||
Iterator<ChunkLoc> iterator = chunks.iterator();
|
||||
final ChunkLoc chunk = iterator.next();
|
||||
iterator.remove();
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -267,9 +267,9 @@ public abstract class HybridUtils {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Iterator<ChunkLoc> iter = regions.iterator();
|
||||
ChunkLoc loc = iter.next();
|
||||
iter.remove();
|
||||
Iterator<ChunkLoc> iterator = regions.iterator();
|
||||
ChunkLoc loc = iterator.next();
|
||||
iterator.remove();
|
||||
PS.debug("&c[ERROR]&7 Could not update '" + area.worldname + "/region/r." + loc.x + "." + loc.z
|
||||
+ ".mca' (Corrupt chunk?)");
|
||||
int sx = loc.x << 5;
|
||||
@ -311,12 +311,12 @@ public abstract class HybridUtils {
|
||||
int tz = sz - 1;
|
||||
int ty = get_ey(world, sx, ex, bz, tz, sy);
|
||||
|
||||
Set<RegionWrapper> sideroad = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ey, sz, ez)));
|
||||
Set<RegionWrapper> sideRoad = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ey, sz, ez)));
|
||||
final Set<RegionWrapper> intersection = new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ty, bz, tz)));
|
||||
|
||||
final String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot
|
||||
.getArea().toString() + File.separator;
|
||||
SchematicHandler.manager.getCompoundTag(world, sideroad, new RunnableVal<CompoundTag>() {
|
||||
SchematicHandler.manager.getCompoundTag(world, sideRoad, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run(CompoundTag value) {
|
||||
SchematicHandler.manager.save(value, dir + "sideroad.schematic");
|
||||
|
@ -28,9 +28,9 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
whenDone.run();
|
||||
return;
|
||||
}
|
||||
Iterator<RegionWrapper> iter = regions.iterator();
|
||||
RegionWrapper region = iter.next();
|
||||
iter.remove();
|
||||
Iterator<RegionWrapper> iterator = regions.iterator();
|
||||
RegionWrapper region = iterator.next();
|
||||
iterator.remove();
|
||||
Location pos1 = new Location(plot.getArea().worldname, region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(plot.getArea().worldname, region.maxX, region.maxY, region.maxZ);
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, false, this);
|
||||
|
@ -11,8 +11,8 @@ public abstract class SquarePlotWorld extends GridPlotWorld {
|
||||
public int ROAD_OFFSET_X = 0;
|
||||
public int ROAD_OFFSET_Z = 0;
|
||||
|
||||
public SquarePlotWorld(String worldname, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||
super(worldname, id, generator, min, max);
|
||||
public SquarePlotWorld(String worldName, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||
super(worldName, id, generator, min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,12 +81,12 @@ public class PlotAnalysis {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Iterator<Plot> iter = plots.iterator();
|
||||
Iterator<Plot> iterator = plots.iterator();
|
||||
PS.debug(" - $1Reducing " + plots.size() + " plots to those with sufficient data");
|
||||
while (iter.hasNext()) {
|
||||
Plot plot = iter.next();
|
||||
while (iterator.hasNext()) {
|
||||
Plot plot = iterator.next();
|
||||
if (plot.getSettings().ratings == null || plot.getSettings().getRatings().isEmpty()) {
|
||||
iter.remove();
|
||||
iterator.remove();
|
||||
} else {
|
||||
plot.addRunning();
|
||||
}
|
||||
@ -393,7 +393,7 @@ public class PlotAnalysis {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get correllation coefficient.
|
||||
* Get correlation coefficient.
|
||||
* @return
|
||||
*/
|
||||
public static double getCC(int n, int sum) {
|
||||
|
@ -72,8 +72,8 @@ public abstract class PlotArea {
|
||||
private ConcurrentHashMap<String, Object> meta;
|
||||
private QuadMap<PlotCluster> clusters;
|
||||
|
||||
public PlotArea(String worldname, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||
this.worldname = worldname;
|
||||
public PlotArea(String worldName, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||
this.worldname = worldName;
|
||||
this.id = id;
|
||||
this.manager = generator != null ? generator.getNewPlotManager() : null;
|
||||
this.generator = generator;
|
||||
@ -87,7 +87,7 @@ public abstract class PlotArea {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
this.worldhash = worldname.hashCode();
|
||||
this.worldhash = worldName.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -303,7 +303,7 @@ public abstract class PlotArea {
|
||||
public abstract void loadConfiguration(ConfigurationSection config);
|
||||
|
||||
/**
|
||||
* Saving core plotarea settings
|
||||
* Saving core PlotArea settings
|
||||
*
|
||||
* @param config Configuration Section
|
||||
*/
|
||||
@ -457,16 +457,16 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
public Set<Plot> getPlotsAbs(final UUID uuid) {
|
||||
final HashSet<Plot> myplots = new HashSet<>();
|
||||
final HashSet<Plot> myPlots = new HashSet<>();
|
||||
foreachPlotAbs(new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(Plot value) {
|
||||
if (value.owner.equals(uuid)) {
|
||||
myplots.add(value);
|
||||
myPlots.add(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
return myplots;
|
||||
return myPlots;
|
||||
}
|
||||
|
||||
public Set<Plot> getPlots(UUID uuid) {
|
||||
@ -595,14 +595,14 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
public Set<Plot> getBasePlots() {
|
||||
HashSet<Plot> myplots = new HashSet<>(getPlots());
|
||||
Iterator<Plot> iter = myplots.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (!iter.next().isBasePlot()) {
|
||||
iter.remove();
|
||||
HashSet<Plot> myPlots = new HashSet<>(getPlots());
|
||||
Iterator<Plot> iterator = myPlots.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (!iterator.next().isBasePlot()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return myplots;
|
||||
return myPlots;
|
||||
}
|
||||
|
||||
public void foreachPlotAbs(RunnableVal<Plot> run) {
|
||||
|
@ -18,7 +18,7 @@ public class Rating {
|
||||
public Rating(int value) {
|
||||
this.initial = value;
|
||||
this.ratingMap = new HashMap<>();
|
||||
if ((Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 1)) {
|
||||
if (Settings.RATING_CATEGORIES != null && Settings.RATING_CATEGORIES.size() > 1) {
|
||||
if (value < 10) {
|
||||
for (String ratingCategory : Settings.RATING_CATEGORIES) {
|
||||
this.ratingMap.put(ratingCategory, value);
|
||||
@ -27,7 +27,7 @@ public class Rating {
|
||||
return;
|
||||
}
|
||||
for (String ratingCategory : Settings.RATING_CATEGORIES) {
|
||||
this.ratingMap.put(ratingCategory, (value % 10) - 1);
|
||||
this.ratingMap.put(ratingCategory, value % 10 - 1);
|
||||
value = value / 10;
|
||||
}
|
||||
} else {
|
||||
@ -66,7 +66,7 @@ public class Rating {
|
||||
if (!this.changed) {
|
||||
return this.initial;
|
||||
}
|
||||
if ((Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 1)) {
|
||||
if (Settings.RATING_CATEGORIES != null && Settings.RATING_CATEGORIES.size() > 1) {
|
||||
int val = 0;
|
||||
for (int i = 0; i < Settings.RATING_CATEGORIES.size(); i++) {
|
||||
val += (i + 1) * Math.pow(10, this.ratingMap.get(Settings.RATING_CATEGORIES.get(i)));
|
||||
|
@ -8,16 +8,16 @@ public class RegionWrapper {
|
||||
public final int minZ;
|
||||
public final int maxZ;
|
||||
|
||||
public RegionWrapper(final int minX, final int maxX, final int minZ, final int maxZ) {
|
||||
public RegionWrapper(int minX, int maxX, int minZ, int maxZ) {
|
||||
this.maxX = maxX;
|
||||
this.minX = minX;
|
||||
this.maxZ = maxZ;
|
||||
this.minZ = minZ;
|
||||
minY = 0;
|
||||
maxY = 256;
|
||||
this.minY = 0;
|
||||
this.maxY = 256;
|
||||
}
|
||||
|
||||
public RegionWrapper(final int minX, final int maxX, final int minY, final int maxY, final int minZ, final int maxZ) {
|
||||
public RegionWrapper(int minX, int maxX, int minY, int maxY, int minZ, int maxZ) {
|
||||
this.maxX = maxX;
|
||||
this.minX = minX;
|
||||
this.maxZ = maxZ;
|
||||
@ -26,12 +26,12 @@ public class RegionWrapper {
|
||||
this.maxY = maxY;
|
||||
}
|
||||
|
||||
public boolean isIn(final int x, final int y, final int z) {
|
||||
return x >= minX && x <= maxX && z >= minZ && z <= maxZ && y >= minY && y <= maxY;
|
||||
public boolean isIn(int x, int y, int z) {
|
||||
return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ && y >= this.minY && y <= this.maxY;
|
||||
}
|
||||
|
||||
public boolean isIn(final int x, final int z) {
|
||||
return x >= minX && x <= maxX && z >= minZ && z <= maxZ;
|
||||
public boolean isIn(int x, int z) {
|
||||
return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ;
|
||||
}
|
||||
|
||||
public boolean intersects(RegionWrapper other) {
|
||||
@ -40,7 +40,7 @@ public class RegionWrapper {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return minX + 13 * maxX + 23 * minZ + 39 * maxZ;
|
||||
return this.minX + 13 * this.maxX + 23 * this.minZ + 39 * this.maxZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,19 +53,20 @@ public class RegionWrapper {
|
||||
}
|
||||
if (obj instanceof RegionWrapper) {
|
||||
RegionWrapper other = (RegionWrapper) obj;
|
||||
return minX == other.minX && minZ == other.minZ && minY == other.minY && maxX == other.maxX && maxZ == other.maxZ && maxY == other.maxY;
|
||||
return this.minX == other.minX && this.minZ == other.minZ && this.minY == other.minY && this.maxX == other.maxX && this.maxZ == other.maxZ
|
||||
&& this.maxY == other.maxY;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return minX + "->" + maxX + "," + minZ + "->" + maxZ;
|
||||
return this.minX + "->" + this.maxX + "," + this.minZ + "->" + this.maxZ;
|
||||
}
|
||||
|
||||
public Location[] getCorners(String world) {
|
||||
Location pos1 = new Location(world, minX, minY, minZ);
|
||||
Location pos2 = new Location(world, maxX, maxY, maxZ);
|
||||
Location pos1 = new Location(world, this.minX, this.minY, this.minZ);
|
||||
Location pos2 = new Location(world, this.maxX, this.maxY, this.maxZ);
|
||||
return new Location[] { pos1, pos2 };
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public abstract class RunnableVal<T> implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
run(value);
|
||||
run(this.value);
|
||||
}
|
||||
|
||||
public abstract void run(T value);
|
||||
|
@ -13,7 +13,7 @@ public abstract class RunnableVal2<T, U> implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
run(value1, value2);
|
||||
run(this.value1, this.value2);
|
||||
}
|
||||
|
||||
public abstract void run(T value1, U value2);
|
||||
|
@ -128,14 +128,14 @@ public class ExpireManager {
|
||||
}
|
||||
final Runnable task = this;
|
||||
long start = System.currentTimeMillis();
|
||||
Iterator<Plot> iter = plots.iterator();
|
||||
while (iter.hasNext() && System.currentTimeMillis() - start < 2) {
|
||||
Iterator<Plot> iterator = plots.iterator();
|
||||
while (iterator.hasNext() && System.currentTimeMillis() - start < 2) {
|
||||
if (ExpireManager.this.running != 2) {
|
||||
ExpireManager.this.running = 0;
|
||||
return;
|
||||
}
|
||||
final Plot plot = iter.next();
|
||||
iter.remove();
|
||||
final Plot plot = iterator.next();
|
||||
iterator.remove();
|
||||
if (!isExpired(plot)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -222,37 +222,33 @@ public class MainUtil {
|
||||
case "week":
|
||||
case "weeks":
|
||||
case "wks":
|
||||
case "w": {
|
||||
case "w":
|
||||
|
||||
time += 604800 * nums;
|
||||
}
|
||||
case "days":
|
||||
case "day":
|
||||
case "d": {
|
||||
case "d":
|
||||
time += 86400 * nums;
|
||||
}
|
||||
case "hour":
|
||||
case "hr":
|
||||
case "hrs":
|
||||
case "hours":
|
||||
case "h": {
|
||||
case "h":
|
||||
time += 3600 * nums;
|
||||
}
|
||||
case "minutes":
|
||||
case "minute":
|
||||
case "mins":
|
||||
case "min":
|
||||
case "m": {
|
||||
case "m":
|
||||
time += 60 * nums;
|
||||
}
|
||||
case "seconds":
|
||||
case "second":
|
||||
case "secs":
|
||||
case "sec":
|
||||
case "s": {
|
||||
case "s":
|
||||
time += nums;
|
||||
}
|
||||
}
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
@ -277,19 +273,19 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of plot ids within a selection
|
||||
* Get a list of plot ids within a selection.
|
||||
* @param pos1
|
||||
* @param pos2
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<PlotId> getPlotSelectionIds(PlotId pos1, PlotId pos2) {
|
||||
ArrayList<PlotId> myplots = new ArrayList<>();
|
||||
ArrayList<PlotId> myPlots = new ArrayList<>();
|
||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||
myplots.add(new PlotId(x, y));
|
||||
myPlots.add(new PlotId(x, y));
|
||||
}
|
||||
}
|
||||
return myplots;
|
||||
return myPlots;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -346,7 +342,7 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fuzzy plot search with spaces separating terms<br>
|
||||
* Fuzzy plot search with spaces separating terms.
|
||||
* - Terms: type, alias, world, owner, trusted, member
|
||||
* @param search
|
||||
* @return
|
||||
@ -421,7 +417,7 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plot from a string<br>
|
||||
* Get the plot from a string.
|
||||
* @param player Provides a context for what world to search in. Prefixing the term with 'world_name;' will override this context.
|
||||
* @param arg The search term
|
||||
* @param message If a message should be sent to the player if a plot cannot be found
|
||||
@ -533,13 +529,13 @@ public class MainUtil {
|
||||
* @param world
|
||||
* @param pos1
|
||||
* @param pos2
|
||||
* @param newblock
|
||||
* @param newBlock
|
||||
*/
|
||||
public static void setSimpleCuboidAsync(String world, Location pos1, Location pos2, PlotBlock newblock) {
|
||||
public static void setSimpleCuboidAsync(String world, Location pos1, Location pos2, PlotBlock newBlock) {
|
||||
for (int y = pos1.getY(); y <= Math.min(255, pos2.getY()); y++) {
|
||||
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
|
||||
SetQueue.IMP.setBlock(world, x, y, z, newblock);
|
||||
SetQueue.IMP.setBlock(world, x, y, z, newBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,37 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
public class MathMan {
|
||||
public static double getMean(final int[] array) {
|
||||
|
||||
private static final int ATAN2_BITS = 7;
|
||||
private static final int ATAN2_BITS2 = ATAN2_BITS << 1;
|
||||
private static final int ATAN2_MASK = ~(-1 << ATAN2_BITS2);
|
||||
private static final int ATAN2_COUNT = ATAN2_MASK + 1;
|
||||
private static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT);
|
||||
private static final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1);
|
||||
private static final float[] atan2 = new float[ATAN2_COUNT];
|
||||
|
||||
static {
|
||||
for (int i = 0; i < ATAN2_DIM; i++) {
|
||||
for (int j = 0; j < ATAN2_DIM; j++) {
|
||||
float x0 = (float) i / ATAN2_DIM;
|
||||
float y0 = (float) j / ATAN2_DIM;
|
||||
|
||||
atan2[(j * ATAN2_DIM) + i] = (float) Math.atan2(y0, x0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static double getMean(int[] array) {
|
||||
double count = 0;
|
||||
for (final int i : array) {
|
||||
for (int i : array) {
|
||||
count += i;
|
||||
}
|
||||
return count / array.length;
|
||||
}
|
||||
|
||||
public static double getMean(final double[] array) {
|
||||
public static double getMean(double[] array) {
|
||||
double count = 0;
|
||||
for (final double i : array) {
|
||||
for (double i : array) {
|
||||
count += i;
|
||||
}
|
||||
return count / array.length;
|
||||
@ -35,12 +55,12 @@ public class MathMan {
|
||||
* @param pitch
|
||||
* @return
|
||||
*/
|
||||
public static float[] getDirection(final float yaw, final float pitch) {
|
||||
final double pitch_sin = Math.sin(pitch);
|
||||
return new float[] { (float) (pitch_sin * Math.cos(yaw)), (float) (pitch_sin * Math.sin(yaw)), (float) Math.cos(pitch) };
|
||||
public static float[] getDirection(float yaw, float pitch) {
|
||||
double pitch_sin = Math.sin(pitch);
|
||||
return new float[]{(float) (pitch_sin * Math.cos(yaw)), (float) (pitch_sin * Math.sin(yaw)), (float) Math.cos(pitch)};
|
||||
}
|
||||
|
||||
public static int roundInt(final double value) {
|
||||
public static int roundInt(double value) {
|
||||
return (int) (value < 0 ? (value == (int) value) ? value : value - 1 : value);
|
||||
}
|
||||
|
||||
@ -51,31 +71,9 @@ public class MathMan {
|
||||
* @param z
|
||||
* @return
|
||||
*/
|
||||
public static float[] getPitchAndYaw(final float x, final float y, final float z) {
|
||||
final float distance = sqrtApprox((z * z) + (x * x));
|
||||
return new float[] { atan2(y, distance), atan2(x, z) };
|
||||
}
|
||||
|
||||
private static final int ATAN2_BITS = 7;
|
||||
|
||||
private static final int ATAN2_BITS2 = ATAN2_BITS << 1;
|
||||
private static final int ATAN2_MASK = ~(-1 << ATAN2_BITS2);
|
||||
private static final int ATAN2_COUNT = ATAN2_MASK + 1;
|
||||
private static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT);
|
||||
|
||||
private static final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1);
|
||||
|
||||
private static final float[] atan2 = new float[ATAN2_COUNT];
|
||||
|
||||
static {
|
||||
for (int i = 0; i < ATAN2_DIM; i++) {
|
||||
for (int j = 0; j < ATAN2_DIM; j++) {
|
||||
final float x0 = (float) i / ATAN2_DIM;
|
||||
final float y0 = (float) j / ATAN2_DIM;
|
||||
|
||||
atan2[(j * ATAN2_DIM) + i] = (float) Math.atan2(y0, x0);
|
||||
}
|
||||
}
|
||||
public static float[] getPitchAndYaw(float x, float y, float z) {
|
||||
float distance = sqrtApprox((z * z) + (x * x));
|
||||
return new float[]{atan2(y, distance), atan2(x, z)};
|
||||
}
|
||||
|
||||
public static final float atan2(float y, float x) {
|
||||
@ -104,24 +102,24 @@ public class MathMan {
|
||||
add = 0.0f;
|
||||
}
|
||||
|
||||
final float invDiv = 1.0f / (((x < y) ? y : x) * INV_ATAN2_DIM_MINUS_1);
|
||||
float invDiv = 1.0f / (((x < y) ? y : x) * INV_ATAN2_DIM_MINUS_1);
|
||||
|
||||
final int xi = (int) (x * invDiv);
|
||||
final int yi = (int) (y * invDiv);
|
||||
int xi = (int) (x * invDiv);
|
||||
int yi = (int) (y * invDiv);
|
||||
|
||||
return (atan2[(yi * ATAN2_DIM) + xi] + add) * mul;
|
||||
}
|
||||
|
||||
public static float sqrtApprox(final float f) {
|
||||
public static float sqrtApprox(float f) {
|
||||
return f * Float.intBitsToFloat(0x5f375a86 - (Float.floatToIntBits(f) >> 1));
|
||||
}
|
||||
|
||||
public static double sqrtApprox(final double d) {
|
||||
public static double sqrtApprox(double d) {
|
||||
return Double.longBitsToDouble(((Double.doubleToLongBits(d) - (1l << 52)) >> 1) + (1l << 61));
|
||||
}
|
||||
|
||||
public static float invSqrt(float x) {
|
||||
final float xhalf = 0.5f * x;
|
||||
float xhalf = 0.5f * x;
|
||||
int i = Float.floatToIntBits(x);
|
||||
i = 0x5f3759df - (i >> 1);
|
||||
x = Float.intBitsToFloat(i);
|
||||
@ -129,18 +127,18 @@ public class MathMan {
|
||||
return x;
|
||||
}
|
||||
|
||||
public static int getPositiveId(final int i) {
|
||||
public static int getPositiveId(int i) {
|
||||
if (i < 0) {
|
||||
return (-i * 2) - 1;
|
||||
}
|
||||
return i * 2;
|
||||
}
|
||||
|
||||
public static boolean isInteger(final String str) {
|
||||
public static boolean isInteger(String str) {
|
||||
if (str == null) {
|
||||
return false;
|
||||
}
|
||||
final int length = str.length();
|
||||
int length = str.length();
|
||||
if (length == 0) {
|
||||
return false;
|
||||
}
|
||||
@ -152,7 +150,7 @@ public class MathMan {
|
||||
i = 1;
|
||||
}
|
||||
for (; i < length; i++) {
|
||||
final char c = str.charAt(i);
|
||||
char c = str.charAt(i);
|
||||
if ((c <= '/') || (c >= ':')) {
|
||||
return false;
|
||||
}
|
||||
@ -160,37 +158,37 @@ public class MathMan {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static double getSD(final double[] array, final double av) {
|
||||
public static double getSD(double[] array, double av) {
|
||||
double sd = 0;
|
||||
for (final double element : array) {
|
||||
for (double element : array) {
|
||||
sd += Math.pow(Math.abs(element - av), 2);
|
||||
}
|
||||
return Math.sqrt(sd / array.length);
|
||||
}
|
||||
|
||||
public static double getSD(final int[] array, final double av) {
|
||||
public static double getSD(int[] array, double av) {
|
||||
double sd = 0;
|
||||
for (final int element : array) {
|
||||
for (int element : array) {
|
||||
sd += Math.pow(Math.abs(element - av), 2);
|
||||
}
|
||||
return Math.sqrt(sd / array.length);
|
||||
}
|
||||
|
||||
public static int mod(final int x, final int y) {
|
||||
public static int mod(int x, int y) {
|
||||
if (isPowerOfTwo(y)) {
|
||||
return x & (y - 1);
|
||||
}
|
||||
return x % y;
|
||||
}
|
||||
|
||||
public static int unsignedmod(final int x, final int y) {
|
||||
public static int unsignedmod(int x, int y) {
|
||||
if (isPowerOfTwo(y)) {
|
||||
return x & (y - 1);
|
||||
}
|
||||
return x % y;
|
||||
}
|
||||
|
||||
public static boolean isPowerOfTwo(final int x) {
|
||||
public static boolean isPowerOfTwo(int x) {
|
||||
return (x & (x - 1)) == 0;
|
||||
}
|
||||
}
|
||||
|
@ -162,10 +162,10 @@ public abstract class SchematicHandler {
|
||||
}
|
||||
}
|
||||
|
||||
Dimension demensions = schematic.getSchematicDimension();
|
||||
final int WIDTH = demensions.getX();
|
||||
final int LENGTH = demensions.getZ();
|
||||
final int HEIGHT = demensions.getY();
|
||||
Dimension dimension = schematic.getSchematicDimension();
|
||||
final int WIDTH = dimension.getX();
|
||||
final int LENGTH = dimension.getZ();
|
||||
final int HEIGHT = dimension.getY();
|
||||
// Validate dimensions
|
||||
RegionWrapper region = plot.getLargestRegion();
|
||||
if (((region.maxX - region.minX + xOffset + 1) < WIDTH) || ((region.maxZ - region.minZ + zOffset + 1) < LENGTH) || (HEIGHT
|
||||
@ -469,7 +469,7 @@ public abstract class SchematicHandler {
|
||||
return schem;
|
||||
}
|
||||
|
||||
public abstract void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schem);
|
||||
public abstract void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schematic);
|
||||
|
||||
/**
|
||||
* Get a schematic
|
||||
@ -616,11 +616,11 @@ public abstract class SchematicHandler {
|
||||
* Create a compound tag from blocks
|
||||
* - Untested
|
||||
* @param blocks
|
||||
* @param blockdata
|
||||
* @param blockData
|
||||
* @param dimension
|
||||
* @return
|
||||
*/
|
||||
public CompoundTag createTag(byte[] blocks, byte[] blockdata, Dimension dimension) {
|
||||
public CompoundTag createTag(byte[] blocks, byte[] blockData, Dimension dimension) {
|
||||
HashMap<String, Tag> schematic = new HashMap<>();
|
||||
schematic.put("Width", new ShortTag("Width", (short) dimension.getX()));
|
||||
schematic.put("Length", new ShortTag("Length", (short) dimension.getZ()));
|
||||
@ -633,7 +633,7 @@ public abstract class SchematicHandler {
|
||||
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
|
||||
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
|
||||
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||
schematic.put("Data", new ByteArrayTag("Data", blockdata));
|
||||
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
||||
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, new ArrayList<Tag>()));
|
||||
return new CompoundTag("Schematic", schematic);
|
||||
|
@ -42,21 +42,6 @@ public class StringMan {
|
||||
return count;
|
||||
}
|
||||
|
||||
public Collection match(Collection col, String startsWith) {
|
||||
if (col == null) {
|
||||
return null;
|
||||
}
|
||||
startsWith = startsWith.toLowerCase();
|
||||
Iterator iter = col.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Object item = iter.next();
|
||||
if (item == null || !item.toString().toLowerCase().startsWith(startsWith)) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
return col;
|
||||
}
|
||||
|
||||
public static String getString(Object obj) {
|
||||
if (obj == null) {
|
||||
return "null";
|
||||
@ -279,4 +264,19 @@ public class StringMan {
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public Collection match(Collection col, String startsWith) {
|
||||
if (col == null) {
|
||||
return null;
|
||||
}
|
||||
startsWith = startsWith.toLowerCase();
|
||||
Iterator iterator = col.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Object item = iterator.next();
|
||||
if (item == null || !item.toString().toLowerCase().startsWith(startsWith)) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
return col;
|
||||
}
|
||||
}
|
||||
|
@ -88,14 +88,14 @@ public abstract class TaskManager {
|
||||
* @param whenDone
|
||||
*/
|
||||
public static <T> void objectTask(Collection<T> objects, final RunnableVal<T> task, final Runnable whenDone) {
|
||||
final Iterator<T> iter = objects.iterator();
|
||||
final Iterator<T> iterator = objects.iterator();
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
long start = System.currentTimeMillis();
|
||||
boolean hasNext;
|
||||
while ((hasNext = iter.hasNext()) && System.currentTimeMillis() - start < 5) {
|
||||
task.value = iter.next();
|
||||
while ((hasNext = iterator.hasNext()) && System.currentTimeMillis() - start < 5) {
|
||||
task.value = iterator.next();
|
||||
task.run();
|
||||
}
|
||||
if (!hasNext) {
|
||||
|
@ -26,7 +26,7 @@ public abstract class WorldUtil {
|
||||
|
||||
public abstract String getMainWorld();
|
||||
|
||||
public abstract boolean isWorld(String worldname);
|
||||
public abstract boolean isWorld(String worldName);
|
||||
|
||||
public abstract String[] getSign(Location location);
|
||||
|
||||
|
@ -14,6 +14,7 @@ import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -101,8 +102,8 @@ public abstract class Command {
|
||||
}
|
||||
|
||||
public String getFullId() {
|
||||
if (parent != null && parent.getParent() != null) {
|
||||
return parent.getFullId() + "." + id;
|
||||
if (this.parent != null && this.parent.getParent() != null) {
|
||||
return this.parent.getFullId() + "." + this.id;
|
||||
}
|
||||
return this.id;
|
||||
}
|
||||
@ -118,16 +119,16 @@ public abstract class Command {
|
||||
}
|
||||
|
||||
public List<Command> getCommands(CommandCategory cat, PlotPlayer player) {
|
||||
List<Command> cmds = getCommands(player);
|
||||
List<Command> commands = getCommands(player);
|
||||
if (cat != null) {
|
||||
Iterator<Command> iter = cmds.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (iter.next().category != cat) {
|
||||
iter.remove();
|
||||
Iterator<Command> iterator = commands.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (iterator.next().category != cat) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
return cmds;
|
||||
return commands;
|
||||
}
|
||||
|
||||
public List<Command> getCommands() {
|
||||
@ -301,9 +302,8 @@ public abstract class Command {
|
||||
}
|
||||
// Command recommendation
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
|
||||
{
|
||||
List<Command> cmds = getCommands(player);
|
||||
if (cmds.isEmpty()) {
|
||||
List<Command> commands = getCommands(player);
|
||||
if (commands.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.DID_YOU_MEAN, MainCommand.getInstance().help.getUsage());
|
||||
return;
|
||||
}
|
||||
@ -313,7 +313,7 @@ public abstract class Command {
|
||||
}
|
||||
String[] allargs = setargs.toArray(new String[setargs.size()]);
|
||||
int best = 0;
|
||||
for (Command current : cmds) {
|
||||
for (Command current : commands) {
|
||||
int match = getMatch(allargs, current);
|
||||
if (match > best) {
|
||||
cmd = current;
|
||||
@ -323,7 +323,6 @@ public abstract class Command {
|
||||
cmd = new StringComparison<>(args[0], this.allCommands).getMatchObject();
|
||||
}
|
||||
MainUtil.sendMessage(player, C.DID_YOU_MEAN, cmd.getUsage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
String[] newArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
@ -335,7 +334,7 @@ public abstract class Command {
|
||||
|
||||
public boolean checkArgs(PlotPlayer player, String[] args) {
|
||||
Argument<?>[] reqArgs = getRequiredArguments();
|
||||
if ((reqArgs != null) && (reqArgs.length > 0)) {
|
||||
if (reqArgs != null && reqArgs.length > 0) {
|
||||
boolean failed = args.length < reqArgs.length;
|
||||
String[] baseSplit = getCommandString().split(" ");
|
||||
String[] fullSplit = getUsage().split(" ");
|
||||
|
@ -13,6 +13,7 @@ import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
|
||||
@ -81,7 +82,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
case 29:
|
||||
case 33:
|
||||
case 151:
|
||||
case 178: {
|
||||
case 178:
|
||||
if (this.BSblocked) {
|
||||
return false;
|
||||
}
|
||||
@ -96,7 +97,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
||||
field.setAccessible(true);
|
||||
field.set(this.parent, new com.sk89q.worldedit.extent.NullExtent());
|
||||
field.set(this.parent, new NullExtent());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -107,8 +108,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
return super.setBlock(location, block);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
@ -118,7 +118,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
try {
|
||||
Field field = AbstractDelegateExtent.class.getDeclaredField("extent");
|
||||
field.setAccessible(true);
|
||||
field.set(this.parent, new com.sk89q.worldedit.extent.NullExtent());
|
||||
field.set(this.parent, new NullExtent());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -208,15 +208,14 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
case 189:
|
||||
case 190:
|
||||
case 191:
|
||||
case 192: {
|
||||
case 192:
|
||||
if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
|
||||
SetQueue.IMP.setBlock(this.world, x, y, z, id);
|
||||
} else {
|
||||
super.setBlock(location, block);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
default:
|
||||
if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
|
||||
SetQueue.IMP.setBlock(this.world, x, y, z, new PlotBlock((short) id, (byte) block.getData()));
|
||||
} else {
|
||||
@ -224,10 +223,8 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
|
@ -315,11 +315,11 @@ public class SpongeMain implements IPlotMain {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGenerator(String worldname) {
|
||||
World world = SpongeUtil.getWorld(worldname);
|
||||
public void setGenerator(String worldName) {
|
||||
World world = SpongeUtil.getWorld(worldName);
|
||||
if (world == null) {
|
||||
// create world
|
||||
ConfigurationSection worldConfig = PS.get().config.getConfigurationSection("worlds." + worldname);
|
||||
ConfigurationSection worldConfig = PS.get().config.getConfigurationSection("worlds." + worldName);
|
||||
String manager = worldConfig.getString("generator.plugin", "PlotSquared");
|
||||
String generator = worldConfig.getString("generator.init", manager);
|
||||
|
||||
@ -331,15 +331,15 @@ public class SpongeMain implements IPlotMain {
|
||||
setup.type = type;
|
||||
setup.terrain = terrain;
|
||||
setup.step = new ConfigurationNode[0];
|
||||
setup.world = worldname;
|
||||
setup.world = worldName;
|
||||
SetupUtils.manager.setupWorld(setup);
|
||||
} else {
|
||||
throw new IllegalArgumentException("World already loaded: " + worldname + "???");
|
||||
throw new IllegalArgumentException("World already loaded: " + worldName + "???");
|
||||
}
|
||||
WorldGenerator wg = world.getWorldGenerator();
|
||||
GenerationPopulator gen = wg.getBaseGenerationPopulator();
|
||||
if (gen instanceof SpongePlotGenerator) {
|
||||
PS.get().loadWorld(worldname, (SpongePlotGenerator) gen);
|
||||
PS.get().loadWorld(worldName, (SpongePlotGenerator) gen);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!");
|
||||
}
|
||||
|
@ -1,10 +1,9 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
|
||||
public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
@ -13,43 +12,43 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot
|
||||
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot.
|
||||
*
|
||||
* @param player That was teleported
|
||||
* @param from Start location
|
||||
* @param plot Plot to which the player was teleported
|
||||
*/
|
||||
public PlayerTeleportToPlotEvent(final Player player, final Location from, final Plot plot) {
|
||||
public PlayerTeleportToPlotEvent(Player player, Location from, Plot plot) {
|
||||
super(player);
|
||||
this.from = from;
|
||||
this.plot = plot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the from location
|
||||
* Get the from location.
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public Location getFrom() {
|
||||
return from;
|
||||
return this.from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plot involved
|
||||
* Get the plot involved.
|
||||
*
|
||||
* @return Plot
|
||||
*/
|
||||
public Plot getPlot() {
|
||||
return plot;
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
cancelled = cancel;
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,9 @@ public class SpongeAugmentedGenerator implements GenerationPopulator {
|
||||
public static SpongeAugmentedGenerator get(World world) {
|
||||
WorldGenerator wg = world.getWorldGenerator();
|
||||
List<GenerationPopulator> populators = wg.getGenerationPopulators();
|
||||
for (GenerationPopulator poplator : populators) {
|
||||
if (poplator instanceof SpongeAugmentedGenerator) {
|
||||
return (SpongeAugmentedGenerator) poplator;
|
||||
for (GenerationPopulator populator : populators) {
|
||||
if (populator instanceof SpongeAugmentedGenerator) {
|
||||
return (SpongeAugmentedGenerator) populator;
|
||||
}
|
||||
}
|
||||
if (generator == null) {
|
||||
@ -38,12 +38,12 @@ public class SpongeAugmentedGenerator implements GenerationPopulator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(final World world, final MutableBlockVolume terrain, final ImmutableBiomeArea biome) {
|
||||
public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeArea biome) {
|
||||
Vector3i min = terrain.getBlockMin();
|
||||
final int bx = min.getX();
|
||||
final int bz = min.getZ();
|
||||
final int cx = bx >> 4;
|
||||
final int cz = bz >> 4;
|
||||
int bx = min.getX();
|
||||
int bz = min.getZ();
|
||||
int cx = bx >> 4;
|
||||
int cz = bz >> 4;
|
||||
AugmentedUtils.generate(world.getName(), cx, cz, new LazyResult<PlotChunk<?>>() {
|
||||
@Override
|
||||
public PlotChunk<?> create() {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user