Compare commits

..

64 Commits

Author SHA1 Message Date
b7ebde874f Clean gradle target directory 2016-03-31 21:27:29 -04:00
8978d3b9a7 Update Gradle to 2.12 2016-03-31 16:45:07 -04:00
b909792d6a typo in disable titles 2016-04-01 06:54:28 +11:00
4a7112a0a5 Various
Add some 1.9 blocks to chest content with schematic paste
Restructure tileentity placement from schematic (will soon add signs
etc)
Prepare for release 3.3.3
2016-04-01 04:23:26 +11:00
edd18a7178 Various
- Fix some block change issues (for some reason sending a chunk would
sometimes reset any recent changes)
- Send chunk changes for relight command
- Have kick cmd kick the player from the server if they are kicked from
the spawn plot
- Plot size checks for downloading
- Fix some potential integer overflow issues for large plots (>64K x
64K)
- Fix some edge cases for plot move/copy
2016-03-31 20:49:00 +11:00
dbdd9f9e5a Merge pull request #1026 from manuelgu/feature/fixes
Fixes and cleanup
2016-03-31 20:42:31 +11:00
25dfc34695 Comma-separate plot area list again 2016-03-30 15:25:25 +02:00
ea17ba8e46 Fix sponge conflicts 2016-03-30 15:09:00 +02:00
6fc8bf587b Comma-separate list of plot worlds 2016-03-30 14:43:16 +02:00
429fed2ab3 Fix target command
Threw an exception when you didnt pass an argument
2016-03-30 14:43:04 +02:00
510b9a47dc Formatting 2016-03-30 14:42:41 +02:00
44e11e9c6b Add command to list all available scripts
Additional debugexec subcommand
2016-03-30 14:42:34 +02:00
95d03e878c Cancel potion throw 2016-03-30 13:41:13 +11:00
dca2696782 Forgot wall height 2016-03-30 13:26:23 +11:00
1e93398fd8 Cancel lingering potion splash
Cancelling the event still doesn't stop the animation.
2016-03-30 13:23:31 +11:00
1f6ad47a79 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java
2016-03-30 12:12:19 +11:00
312ad4c48c fix index 2016-03-30 12:09:55 +11:00
31d346a587 Minor code cleanup
Plus an optimization
2016-03-29 17:00:07 -04:00
6007f040cd OCD 2016-03-29 15:47:59 -04:00
d0622eb87d PlotAPI doc and code cleaning 2016-03-29 14:35:40 -04:00
6ebfd426c3 Just "height" would have made more sense 2016-03-30 05:14:51 +11:00
bbe43f782c Fix nested command configuration 2016-03-30 04:47:47 +11:00
560ebf412b Relight command 2016-03-30 04:34:48 +11:00
df630f9be1 Remove outdated copyright notice at the top of each file
- No license is the same as all rights reserved
- There's already a license at the root of the project
- The message was not in most files. easier to remove it
- Support link isn't valid
- No longer just the bukkit API
2016-03-30 02:50:13 +11:00
578e884be7 Merge pull request #1025 from manuelgu/master
Cleanup
2016-03-29 20:08:33 +11:00
22f56d4da6 Remove ChatColor
Sponge support
2016-03-29 10:57:27 +02:00
745f9c4858 Buy 2016-03-29 19:52:57 +11:00
5f2856e0ea Cleanup
Consistent use of String[] instead of String...
Removed unused variables
2016-03-29 10:47:56 +02:00
d9c6d04b46 Debug PlotMe conversion (temporary) 2016-03-29 19:13:48 +11:00
8244086840 Merge pull request #1024 from dmodoomsirius/master
Revert "have clean help delete the output directory"
2016-03-29 19:13:00 +11:00
e282998765 Revert "have clean help delete the output directory"
This reverts commit afa9935a7a.
2016-03-29 04:11:25 -04:00
bd633c0150 Merge pull request #1023 from dmodoomsirius/master
Give the ability to clean the output directory
2016-03-29 19:00:57 +11:00
5ec6bc62ca Merge branch 'master' of https://github.com/dmodoomsirius/PlotSquared 2016-03-29 03:59:42 -04:00
afa9935a7a have clean help delete the output directory
to make things nice and clean
2016-03-29 03:59:12 -04:00
512ae38392 Fix plot kick args 2016-03-29 18:57:35 +11:00
19ef76de33 Oh, and this 2016-03-29 18:51:10 +11:00
638f267498 Remove required args for visit 2016-03-29 18:48:07 +11:00
bc8becae8e Check for null 2016-03-29 18:47:04 +11:00
6f9af04274 Cleanup BukkitChunkManager 2016-03-29 18:44:04 +11:00
75a70bcff4 Merge pull request #1022 from EvilOlaf/patch-1
Missing brackets
2016-03-29 18:11:12 +11:00
30043fd1c1 Missing brackets
very (VERY!) minor change ^^
2016-03-29 09:10:24 +02:00
ef4438889b Fix plot move 2016-03-29 18:09:40 +11:00
9bd3f2cbfd Fix plot list add 2016-03-29 17:56:48 +11:00
eed8cbec5a Fixes #1015 2016-03-29 17:39:29 +11:00
5f8a55568c Fix plot rate categories 2016-03-29 17:21:58 +11:00
5275d4ec62 Fix "cleanup" breaking plugin again 2016-03-29 17:13:19 +11:00
30dc20b3b3 Fix "Fixes #1015" not resetting the home location.
Resetting involves clearing the current value i.e. so it respects
whatever is set in the config, if that value is changed.
2016-03-29 17:06:58 +11:00
32ba55baf5 Code cleanup and Optimizations 2016-03-29 00:56:44 -04:00
49d18b9229 Code cleanup 2016-03-28 23:26:44 -04:00
a8fd6d00d0 Sorry for the versioning confusion 2016-03-28 23:23:56 -04:00
b1fa258688 Code cleanup 2016-03-28 19:30:55 -04:00
874da8c5bc Merge pull request #1019 from manuelgu/master
Fixes #1018
2016-03-28 18:17:45 -04:00
76e2b1f416 Code cleanup
maybe a bug fix or two
2016-03-28 17:31:40 -04:00
83fa310fbb Fix ArrayIndexOutOfBoundsExceptions
Occured for /plot trust and /plot add
2016-03-28 23:18:29 +02:00
8d4f042abc Cleanup of code 2016-03-28 13:28:21 -04:00
feee63b3af Fix DebugLoadTest 2016-03-28 13:02:20 -04:00
c4f5905252 Merge pull request #1016 from manuelgu/master
Fixes #1015
2016-03-28 11:25:33 -04:00
c2e48bb95b Fixes #1015 2016-03-28 16:27:32 +02:00
d9c0ec27b0 Fixes #774 2016-03-28 23:04:08 +11:00
dcd1a50a0c default tab completion + plot chat for merged plots 2016-03-28 22:52:29 +11:00
b6bdb02fa2 Merge pull request #1012 from manuelgu/master
Update Plugin command to show correct versions
2016-03-28 07:23:07 -04:00
8f0de80755 Update Plugin command to show correct version
Not using PS.get().update but rather reading from the GitHub releases. Can be changed if needed/wanted
2016-03-28 11:29:58 +02:00
978be89e52 Fix bug causing the Updater to not work. 2016-03-27 23:48:24 -04:00
93ef066d7b 3.3.3-SNAPSHOT Beginning
Sponge Gradle Changes
2016-03-27 18:55:57 -04:00
256 changed files with 4519 additions and 6693 deletions

View File

@ -1,24 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.api;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
@ -39,21 +18,21 @@ import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.util.BukkitUtil;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
* PlotSquared API<br>
* PlotSquared API.
* <br>
* @version API 3.3.1
* <br>
* Useful classes:<br>
* @see BukkitUtil
@ -62,32 +41,40 @@ import org.bukkit.plugin.java.JavaPlugin;
* @see com.intellectualcrafters.plot.object.Location
* @see PlotArea
* @see PS
* @version 3.3.3
>>>>>>> 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
@ -95,7 +82,7 @@ public class PlotAPI {
}
/**
* Get all plots
* Get all plots.
*
* @return all plots
*
@ -106,7 +93,7 @@ public class PlotAPI {
}
/**
* Return all plots for a player
* Return all plots for a player.
*
* @param player Player, whose plots to search for
*
@ -117,7 +104,7 @@ public class PlotAPI {
}
/**
* Add a plot world
* Add a plot world.
*
* @param plotArea Plot World Object
* @see PS#addPlotArea(PlotArea)
@ -127,6 +114,7 @@ public class PlotAPI {
}
/**
* Returns the PlotSquared configurations file.
* @return main configuration
*
* @see PS#config
@ -136,6 +124,7 @@ public class PlotAPI {
}
/**
* Get the PlotSquared storage file.
* @return storage configuration
*
* @see PS#storage
@ -145,8 +134,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
*
@ -157,12 +145,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
*
@ -181,7 +171,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
*
@ -197,7 +188,7 @@ public class PlotAPI {
*
* @return FlagManager
*
* @see com.intellectualcrafters.plot.flag.FlagManager
* @deprecated Use {@link FlagManager} directly
*/
@Deprecated
public FlagManager getFlagManager() {
@ -206,11 +197,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() {
@ -219,11 +208,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() {
@ -237,7 +226,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
*
@ -251,8 +241,7 @@ public class PlotAPI {
* Use C.[caption] instead
*
* @return C
*
* @see com.intellectualcrafters.plot.config.C
* @deprecated Use {@link C}
*/
@Deprecated
public C[] getCaptions() {
@ -260,7 +249,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
*
@ -277,6 +267,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<>();
@ -285,10 +280,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
*
@ -310,12 +305,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
@ -329,11 +325,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
@ -359,17 +355,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
@ -381,30 +376,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
*
@ -416,7 +411,7 @@ public class PlotAPI {
}
/**
* get all the currently registered flags
* get all the currently registered flags.
*
* @return array of Flag[]
*
@ -431,8 +426,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
*
@ -453,17 +448,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();
}
/**
@ -484,22 +479,23 @@ 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)
*/
@Deprecated
public boolean hasPlot(World world, Player player) {
return getPlots(world, player, true) != null && getPlots(world, player, true).length > 0;
return getPlots(world, player, true).length > 0;
}
/**
* 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) {
@ -510,12 +506,10 @@ public class PlotAPI {
if (plot.hasOwner() && plot.isOwner(uuid)) {
pPlots.add(plot);
}
} else {
if (plot.isAdded(uuid)) {
} else if (plot.isAdded(uuid)) {
pPlots.add(plot);
}
}
}
return pPlots.toArray(new Plot[pPlots.size()]);
}
@ -551,9 +545,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)
*
@ -565,9 +559,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
*
@ -576,27 +570,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
*
@ -605,14 +602,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
*
@ -621,12 +618,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
*
@ -638,7 +635,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
@ -649,7 +646,7 @@ public class PlotAPI {
}
/**
* Get the PlotSquared class
* Get the PlotSquared class.
*
* @return PlotSquared Class
*
@ -660,7 +657,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
@ -676,7 +673,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
@ -695,9 +692,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
*
@ -708,50 +705,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);

View File

@ -33,7 +33,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.commands.DebugUUID;
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
@ -43,6 +42,7 @@ import com.plotsquared.bukkit.listeners.ForceFieldListener;
import com.plotsquared.bukkit.listeners.PlayerEvents;
import com.plotsquared.bukkit.listeners.PlayerEvents183;
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
import com.plotsquared.bukkit.listeners.PlayerEvents_1_9;
import com.plotsquared.bukkit.listeners.PlotPlusListener;
import com.plotsquared.bukkit.listeners.WorldEvents;
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
@ -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,25 +153,28 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@Override
public void disable() {
if (THIS != null) {
if (BukkitMain.THIS != null) {
onDisable();
}
}
@Override
public int[] getPluginVersion() {
String[] split = getDescription().getVersion().split("\\.");
String version = getDescription().getVersion();
if (version.contains("-SNAPSHOT")) {
version = version.split("-SNAPSHOT")[0];
}
String[] split = version.split("\\.");
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
}
@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);
new DebugUUID();
plotCommand.setTabCompleter(bukkitCommand);
}
@Override
@ -221,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:
@ -232,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:
@ -275,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:
@ -317,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;
}
@ -331,7 +329,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}
}
}
}
} catch (Throwable e) {
e.printStackTrace();
}
@ -352,13 +349,17 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@Override
public void registerPlayerEvents() {
getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
PlayerEvents main = new PlayerEvents();
getServer().getPluginManager().registerEvents(main, this);
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this);
}
if (PS.get().checkVersion(getServerVersion(), 1, 8, 3)) {
getServer().getPluginManager().registerEvents(new PlayerEvents183(), this);
}
if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) {
getServer().getPluginManager().registerEvents(new PlayerEvents_1_9(main), this);
}
}
@Override
@ -380,7 +381,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;
}
@ -394,9 +395,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
if (econ.init()) {
return econ;
}
System.out.println("ECONOMY ENABLED!");
} catch (Throwable ignored) {
ignored.printStackTrace();
PS.debug("No economy detected!");
}
return null;
}

View File

@ -14,10 +14,10 @@ import java.util.Map;
*/
final class JsonString implements JsonRepresentedObject, ConfigurationSerializable {
private final String _value;
private final String value;
public JsonString(CharSequence value) {
this._value = value == null ? null : value.toString();
this.value = value == null ? null : value.toString();
}
public static JsonString deserialize(Map<String, Object> map) {
@ -30,18 +30,18 @@ final class JsonString implements JsonRepresentedObject, ConfigurationSerializab
}
public String getValue() {
return this._value;
return this.value;
}
@Override
public Map<String, Object> serialize() {
HashMap<String, Object> theSingleValue = new HashMap<>();
theSingleValue.put("stringValue", this._value);
theSingleValue.put("stringValue", this.value);
return theSingleValue;
}
@Override
public String toString() {
return this._value;
return this.value;
}
}

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.commands;
import com.intellectualcrafters.plot.PS;
@ -127,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");
@ -146,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) {
@ -306,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");

View File

@ -13,7 +13,7 @@ import java.sql.SQLException;
import java.util.Collections;
import java.util.HashMap;
public abstract class APlotMeConnector {
abstract class APlotMeConnector {
public abstract Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder);
@ -49,21 +49,23 @@ public abstract class APlotMeConnector {
PS.get().config.set("worlds." + actualWorldName + ".road.block", road);
int height = plotConfig.getInt("worlds." + world + ".RoadHeight"); //
PS.get().config.set("worlds." + actualWorldName + ".road.height", height);
PS.get().config.set("worlds." + actualWorldName + ".plot.height", height);
PS.get().config.set("worlds." + actualWorldName + ".wall.height", height);
}
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);
}

View File

@ -45,6 +45,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
}
} catch (SQLException | ClassNotFoundException ignored) {
//ignored
ignored.printStackTrace();
}
return null;
}
@ -128,13 +129,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
}
}
if (owner == null) {
if (!name.isEmpty()) {
owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
}
if (name.isEmpty()) {
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'");
missing++;
continue;
}
owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
}
}
} else {
UUIDHandler.add(new StringWrapper(name), owner);
@ -153,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());
}

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.database.plotme;
import com.intellectualcrafters.configuration.MemorySection;
@ -65,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;
@ -225,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"); //
@ -330,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 + "'...");
@ -364,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) {

View File

@ -44,6 +44,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
}
} catch (SQLException | ClassNotFoundException ignored) {
//ignored
ignored.printStackTrace();
}
return null;
}

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.flag.Flag;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Location;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.flag.Flag;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.flag.Flag;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.Plot;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.events;
import com.intellectualcrafters.plot.object.PlotArea;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.generator;
import com.intellectualcrafters.plot.PS;
@ -35,17 +15,16 @@ import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.SetQueue;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.block.GenChunk;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Set;
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
private final PlotChunk<Chunk> chunkSetter;
@ -77,6 +56,13 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
}
}
}
random.state = c.getX() << 16 | c.getZ() & 0xFFFF;
PlotArea area = PS.get().getPlotArea(world.getName(), null);
SetQueue.ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(area.worldname, c.getX(), c.getZ());
PlotChunk<?> chunk = SetQueue.IMP.queue.getChunk(wrap);
if (plotGenerator.populateChunk(chunk, area, random)) {
chunk.addToQueue();
}
}
});
this.chunkSetter = new GenChunk(null, null);
@ -194,6 +180,8 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
return this.platformGenerator;
}
@Override
public List<BlockPopulator> getDefaultPopulators(World world) {
try {
@ -224,7 +212,17 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
} catch (Exception e) {
e.printStackTrace();
}
return this.populators;
if (world == null) {
return populators;
}
ArrayList<BlockPopulator> toAdd = new ArrayList<BlockPopulator>();
List<BlockPopulator> existing = world.getPopulators();
for (BlockPopulator populator : populators) {
if (!existing.contains(populator)) {
toAdd.add(populator);
}
}
return toAdd;
}
@Override
@ -237,7 +235,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
result.grid = grid;
result.result = null;
result.result_data = null;
// Catch any exceptions (as exceptions usually thrown
// Catch any exceptions (as exceptions usually thrown)
try {
// Fill the result data if necessary
if (this.platformGenerator != this) {
@ -280,7 +278,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
result.result_data = new byte[16][];
result.grid = grid;
result.cd = null;
// Catch any exceptions (as exceptions usually thrown
// Catch any exceptions (as exceptions usually thrown)
try {
// Fill the result data
if (this.platformGenerator != this) {

View File

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

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.flag.FlagManager;

View File

@ -27,6 +27,7 @@ import com.plotsquared.bukkit.object.BukkitLazyBlock;
import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlayerBlockEventType;
import com.plotsquared.listener.PlotListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@ -89,6 +90,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
@ -118,15 +120,15 @@ import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector;
/**
* Player Events involving plots
* Player Events involving plots.
*
*/
public class PlayerEvents extends com.plotsquared.listener.PlotListener implements Listener {
public class PlayerEvents extends PlotListener implements Listener {
private boolean pistonBlocks = true;
private float lastRadius;
// To prevent recursion
private boolean tmp_teleport = true;
private boolean tmpTeleport = true;
public static void sendBlockChange(final org.bukkit.Location bloc, final Material type, final byte data) {
TaskManager.runTaskLater(new Runnable() {
@ -269,15 +271,38 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {
public void onProjectileLaunch(ProjectileLaunchEvent event) {
Projectile entity = event.getEntity();
if (!(entity instanceof ThrownPotion)) {
return;
}
ProjectileSource shooter = entity.getShooter();
if (!(shooter instanceof Player)) {
return;
}
ThrownPotion potion = (ThrownPotion) entity;
Location l = BukkitUtil.getLocation(potion);
if (!PS.get().hasPlotArea(l.getWorld())) {
return;
}
PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter);
Plot plot = l.getOwnedPlot();
if (plot != null && !plot.isAdded(pp.getUUID())) {
entity.remove();
event.setCancelled(true);
}
}
@EventHandler
public boolean onProjectileHit(ProjectileHitEvent event) {
Projectile entity = event.getEntity();
Location loc = BukkitUtil.getLocation(entity);
if (!PS.get().hasPlotArea(loc.getWorld())) {
return;
return true;
}
PlotArea area = loc.getPlotArea();
if (area == null) {
return;
return true;
}
Plot plot = area.getPlotAbs(loc);
//
@ -287,32 +312,36 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (plot == null) {
if (!Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_UNOWNED)) {
entity.remove();
return false;
}
return;
return true;
}
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
return;
return true;
}
entity.remove();
return false;
} else if (!(shooter instanceof Entity) && shooter != null) {
if (plot == null) {
entity.remove();
return;
return false;
}
Location sLoc = BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
if (!area.contains(sLoc.getX(), sLoc.getZ())) {
entity.remove();
return;
return false;
}
Plot sPlot = area.getOwnedPlotAbs(sLoc);
if (sPlot == null || !PlotHandler.sameOwners(plot, sPlot)) {
entity.remove();
return false;
}
}
return true;
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void PlayerCommand(PlayerCommandPreprocessEvent event) {
public void playerCommand(PlayerCommandPreprocessEvent event) {
String msg = event.getMessage().toLowerCase().replaceAll("/", "").trim();
if (msg.isEmpty()) {
return;
@ -433,7 +462,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void PlayerMove(PlayerMoveEvent event) {
public void playerMove(PlayerMoveEvent event) {
org.bukkit.Location from = event.getFrom();
org.bukkit.Location to = event.getTo();
int x2;
@ -542,7 +571,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (area == null || (!area.PLOT_CHAT && !plr.getAttribute("chat"))) {
return;
}
Plot plot = area.getPlotAbs(loc);
Plot plot = area.getPlot(loc);
if (plot == null) {
return;
}
@ -559,10 +588,13 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
String spy = event.getFormat();
spy = String.format(spy, sender, message);
pp.sendMessage(spy);
} else if (plot.equals(pp.getCurrentPlot())) {
} else {
Plot current = pp.getCurrentPlot();
if (current != null && current.getBasePlot(false).equals(plot)) {
recipients.add(((BukkitPlayer) pp).player);
}
}
}
String full = format.replaceAll("%plot_id%", id.x + ";" + id.y).replaceAll("%sender%", sender).replaceAll("%msg%", message);
full = ChatColor.translateAlternateColorCodes('&', full);
// format = format.replaceAll("%plot_id%", id.x + ";" + id.y).replaceAll("%sender%", "%s").replaceAll("%msg%", "%s");
@ -631,22 +663,22 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
@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");
@ -667,12 +699,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
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;
@ -830,14 +862,14 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
public void onChange(BlockFromToEvent e) {
Block from = e.getBlock();
Block to = e.getToBlock();
Location tloc = BukkitUtil.getLocation(to.getLocation());
PlotArea area = tloc.getPlotArea();
Location tLocation = BukkitUtil.getLocation(to.getLocation());
PlotArea area = tLocation.getPlotArea();
if (area == null) {
return;
}
Plot plot = area.getOwnedPlot(tloc);
Location floc = BukkitUtil.getLocation(from.getLocation());
if (!area.contains(floc.getX(), floc.getZ()) || !Objects.equals(plot, area.getOwnedPlot(floc)) || (plot != null && FlagManager
Plot plot = area.getOwnedPlot(tLocation);
Location fLocation = BukkitUtil.getLocation(from.getLocation());
if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation)) || (plot != null && FlagManager
.isPlotFlagTrue(plot, "disable-physics"))) {
e.setCancelled(true);
}
@ -1262,8 +1294,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
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());
@ -1377,7 +1409,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
case LIGHTNING:
case WITHER_SKULL:
case UNKNOWN:
// non moving / unremovable
// non moving / unmovable
return checkEntity(plot, "entity-cap");
case ITEM_FRAME:
case PAINTING:
@ -1535,17 +1567,17 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
} 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;
}
@ -1555,11 +1587,11 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
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;
}
@ -1589,18 +1621,18 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
Plot now = area.getPlotAbs(loc);
Plot lastPlot = pp.getMeta("lastplot");
if (now == null) {
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmp_teleport) {
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
this.tmp_teleport = false;
this.tmpTeleport = false;
player.teleport(from);
this.tmp_teleport = true;
this.tmpTeleport = true;
} else {
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
this.tmp_teleport = false;
this.tmpTeleport = false;
player.teleport(player.getWorld().getSpawnLocation());
this.tmp_teleport = true;
this.tmpTeleport = true;
}
}
event.setCancelled(true);
@ -1608,37 +1640,37 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
} else if (lastPlot != null && now.equals(lastPlot)) {
return;
} else if (!plotEntry(pp, now) && this.tmp_teleport) {
} else if (!plotEntry(pp, now) && this.tmpTeleport) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
this.tmp_teleport = false;
this.tmpTeleport = false;
player.teleport(from);
this.tmp_teleport = true;
this.tmpTeleport = true;
} else {
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
this.tmp_teleport = false;
this.tmpTeleport = false;
player.teleport(player.getWorld().getSpawnLocation());
this.tmp_teleport = true;
this.tmpTeleport = true;
}
}
event.setCancelled(true);
return;
}
Integer border = area.getBorder();
if (this.tmp_teleport) {
if (this.tmpTeleport) {
if (x2 > border) {
to.setX(border - 4);
this.tmp_teleport = false;
this.tmpTeleport = false;
player.teleport(event.getTo());
this.tmp_teleport = true;
this.tmpTeleport = true;
MainUtil.sendMessage(pp, C.BORDER);
return;
} else if (x2 < -border) {
to.setX(-border + 4);
this.tmp_teleport = false;
this.tmpTeleport = false;
player.teleport(event.getTo());
this.tmp_teleport = true;
this.tmpTeleport = true;
MainUtil.sendMessage(pp, C.BORDER);
return;
}
@ -1659,18 +1691,18 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
Plot now = area.getPlotAbs(loc);
Plot lastPlot = pp.getMeta("lastplot");
if (now == null) {
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmp_teleport) {
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
this.tmp_teleport = false;
this.tmpTeleport = false;
player.teleport(from);
this.tmp_teleport = true;
this.tmpTeleport = true;
} else {
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
this.tmp_teleport = false;
this.tmpTeleport = false;
player.teleport(player.getWorld().getSpawnLocation());
this.tmp_teleport = true;
this.tmpTeleport = true;
}
}
event.setCancelled(true);
@ -1678,36 +1710,36 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
} else if (lastPlot != null && now.equals(lastPlot)) {
return;
} else if (!plotEntry(pp, now) && this.tmp_teleport) {
} else if (!plotEntry(pp, now) && this.tmpTeleport) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
this.tmp_teleport = false;
this.tmpTeleport = false;
player.teleport(from);
this.tmp_teleport = true;
this.tmpTeleport = true;
} else {
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
this.tmp_teleport = false;
this.tmpTeleport = false;
player.teleport(player.getWorld().getSpawnLocation());
this.tmp_teleport = true;
this.tmpTeleport = true;
}
}
event.setCancelled(true);
return;
}
Integer border = area.getBorder();
if (this.tmp_teleport) {
if (this.tmpTeleport) {
if (z2 > border) {
to.setZ(border - 4);
this.tmp_teleport = false;
this.tmpTeleport = false;
player.teleport(event.getTo());
this.tmp_teleport = true;
this.tmpTeleport = true;
MainUtil.sendMessage(pp, C.BORDER);
} else if (z2 < -border) {
to.setZ(-border + 4);
this.tmp_teleport = false;
this.tmpTeleport = false;
player.teleport(event.getTo());
this.tmp_teleport = true;
this.tmpTeleport = true;
MainUtil.sendMessage(pp, C.BORDER);
}
}
@ -2030,11 +2062,16 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (!PS.get().hasPlotArea(l.getWorld())) {
return;
}
int count = 0;
for (LivingEntity victim : event.getAffectedEntities()) {
if (!entityDamage(damager, victim)) {
event.setIntensity(victim, 0);
count++;
}
}
if ((count > 0 && count == event.getAffectedEntities().size()) || !onProjectileHit(event)) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)

View File

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

View File

@ -0,0 +1,34 @@
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.Location;
import com.plotsquared.bukkit.util.BukkitUtil;
import org.bukkit.entity.LingeringPotion;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.LingeringPotionSplashEvent;
/**
* Created by Jesse on 3/30/2016.
*/
public class PlayerEvents_1_9 implements Listener {
private final PlayerEvents parent;
public PlayerEvents_1_9(PlayerEvents parent) {
this.parent = parent;
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPotionSplash(LingeringPotionSplashEvent event) {
LingeringPotion entity = event.getEntity();
Location l = BukkitUtil.getLocation(entity);
if (!PS.get().hasPlotArea(l.getWorld())) {
return;
}
if (!parent.onProjectileHit(event)) {
event.setCancelled(true);
}
}
}

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.flag.Flag;
@ -28,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;
@ -46,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<>();
@ -56,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();
@ -75,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();

View File

@ -1,6 +1,5 @@
package com.plotsquared.bukkit.object;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.EconHandler;
@ -8,14 +7,11 @@ import com.intellectualcrafters.plot.util.PlotGameMode;
import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.util.BukkitUtil;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.WeatherType;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.permissions.Permission;
import org.bukkit.plugin.PluginManager;
import java.util.UUID;
@ -28,8 +24,8 @@ public class BukkitPlayer extends PlotPlayer {
private long last = 0;
/**
* <p>Please do not use this method. Instead use BukkitUtil.getPlayer(Player),
* as it caches player objects.</p>
* <p>Please do not use this method. Instead use
* BukkitUtil.getPlayer(Player), as it caches player objects.</p>
* @param player
*/
public BukkitPlayer(Player player) {
@ -73,29 +69,6 @@ public class BukkitPlayer extends PlotPlayer {
return this.player.hasPermission(permission);
}
public Permission getPermission(String node) {
PluginManager manager = Bukkit.getPluginManager();
Permission perm = manager.getPermission(node);
if (perm == null) {
String[] nodes = node.split("\\.");
perm = new Permission(node);
StringBuilder n = new StringBuilder();
for (int i = 0; i < nodes.length - 1; i++) {
n.append(nodes[i]).append(".");
if (!node.equals(n + C.PERMISSION_STAR.s())) {
Permission parent = getPermission(n + C.PERMISSION_STAR.s());
if (parent != null) {
perm.addParent(parent, true);
}
}
}
manager.addPermission(perm);
}
manager.recalculatePermissionDefaults(perm);
perm.recalculatePermissibles();
return perm;
}
@Override
public void sendMessage(String message) {
this.player.sendMessage(message);
@ -166,7 +139,7 @@ public class BukkitPlayer extends PlotPlayer {
case SURVIVAL:
return PlotGameMode.SURVIVAL;
default:
return PlotGameMode.SURVIVAL;
return PlotGameMode.NOT_SET;
}
}

View File

@ -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);
@ -408,26 +399,22 @@ public class EntityWrapper {
Location loc = new Location(world, this.x + x_offset, this.y, this.z + z_offset);
loc.setYaw(this.yaw);
loc.setPitch(this.pitch);
if (this.type.isSpawnable()) {
if (!this.type.isSpawnable()) {
return null;
}
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 //
}
}

View File

@ -6,19 +6,20 @@ import com.intellectualcrafters.jnbt.ListTag;
import com.intellectualcrafters.jnbt.ShortTag;
import com.intellectualcrafters.jnbt.Tag;
import com.intellectualcrafters.plot.object.schematic.ItemType;
import com.intellectualcrafters.plot.object.schematic.PlotItem;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import com.plotsquared.bukkit.util.BukkitUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
public class StateWrapper {
@ -33,32 +34,52 @@ public class StateWrapper {
this.tag = tag;
}
public boolean restoreTag(short x, short y, short z, Schematic schematic) {
public boolean restoreTag(String worldName, int x, int y, int z) {
if (this.tag == null) {
return false;
}
switch (tag.getString("id").toLowerCase()) {
case "chest": {
List<Tag> itemsTag = this.tag.getListTag("Items").getValue();
int length = itemsTag.size();
short[] ids = new short[length];
byte[] datas = new byte[length];
byte[] amounts = new byte[length];
byte[] slots = new byte[length];
for (int i = 0; i < length; i++) {
Tag itemTag = itemsTag.get(i);
CompoundTag itemComp = (CompoundTag) itemTag;
short id = itemComp.getShort("id");
String idStr = itemComp.getString("id");
if (idStr != null && !MathMan.isInteger(idStr)) {
idStr = idStr.split(":")[0].toLowerCase();
idStr = idStr.split(":")[1].toLowerCase();
id = (short) ItemType.getId(idStr);
}
ids[i] = id;
datas[i] = (byte) itemComp.getShort("Damage");
amounts[i] = itemComp.getByte("Count");
slots[i] = itemComp.getByte("Slot");
}
if (length != 0) {
schematic.addItem(new PlotItem(x, y, z, ids, datas, amounts));
World world = BukkitUtil.getWorld(worldName);
Block block = world.getBlockAt(x, y, z);
if (block == null) {
return false;
}
BlockState state = block.getState();
if (state instanceof InventoryHolder) {
InventoryHolder holder = (InventoryHolder) state;
Inventory inv = holder.getInventory();
for (int i = 0; i < ids.length; i++) {
ItemStack item = new ItemStack(ids[i], amounts[i], datas[i]);
inv.addItem(item);
}
state.update(true);
return true;
} else {
}
}
}
return false;
}
public CompoundTag getTag() {

View File

@ -40,10 +40,9 @@ public class DefaultTitleManager {
private boolean ticks = false;
/**
* Create a new 1.8 title
* Create a new 1.8 title.
*
* @param title
* Title
* @param title Title
* @throws ClassNotFoundException
*/
public DefaultTitleManager(String title) throws ClassNotFoundException {
@ -52,12 +51,10 @@ public class DefaultTitleManager {
}
/**
* Create a new 1.8 title
* Create a new 1.8 title.
*
* @param title
* Title text
* @param subtitle
* Subtitle text
* @param title Title text
* @param subtitle Subtitle text
* @throws ClassNotFoundException
*/
public DefaultTitleManager(String title, String subtitle) throws ClassNotFoundException {
@ -118,10 +115,9 @@ public class DefaultTitleManager {
}
/**
* Load spigot and NMS classes
* @throws ClassNotFoundException
* Load spigot and NMS classes.
*/
private void loadClasses() throws ClassNotFoundException {
private void loadClasses() {
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
this.packetActions = Reflection.getNMSClass("EnumTitleAction");
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
@ -129,7 +125,7 @@ public class DefaultTitleManager {
}
/**
* Get title text
* Get title text.
*
* @return Title text
*/
@ -138,17 +134,16 @@ public class DefaultTitleManager {
}
/**
* Set title text
* Set title text.
*
* @param title
* Title
* @param title Title
*/
public void setTitle(String title) {
this.title = title;
}
/**
* Get subtitle text
* Get subtitle text.
*
* @return Subtitle text
*/

View File

@ -6,7 +6,6 @@ import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@ -53,12 +52,10 @@ public class DefaultTitleManager_183 {
}
/**
* Create a new 1.8 title
* Create a new 1.8 title.
*
* @param title
* Title text
* @param subtitle
* Subtitle text
* @param title Title text
* @param subtitle Subtitle text
* @throws ClassNotFoundException
*/
public DefaultTitleManager_183(String title, String subtitle) throws ClassNotFoundException {
@ -68,10 +65,9 @@ public class DefaultTitleManager_183 {
}
/**
* Copy 1.8 title
* Copy 1.8 title.
*
* @param title
* Title
* @param title Title
* @throws ClassNotFoundException
*/
public DefaultTitleManager_183(DefaultTitleManager_183 title) throws ClassNotFoundException {
@ -88,18 +84,13 @@ public class DefaultTitleManager_183 {
}
/**
* Create a new 1.8 title
* Create a new 1.8 title.
*
* @param title
* Title text
* @param subtitle
* Subtitle text
* @param fadeInTime
* Fade in time
* @param stayTime
* Stay on screen time
* @param fadeOutTime
* Fade out time
* @param title Title text
* @param subtitle Subtitle text
* @param fadeInTime Fade in time
* @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
* @throws ClassNotFoundException
*/
public DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) throws ClassNotFoundException {
@ -124,10 +115,9 @@ public class DefaultTitleManager_183 {
}
/**
* Load spigot and NMS classes
* @throws ClassNotFoundException
* Load spigot and NMS classes.
*/
private void loadClasses() throws ClassNotFoundException {
private void loadClasses() {
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
this.packetActions = Reflection.getNMSClass("PacketPlayOutTitle$EnumTitleAction");
@ -136,7 +126,7 @@ public class DefaultTitleManager_183 {
}
/**
* Get title text
* Get title text.
*
* @return Title text
*/
@ -145,17 +135,16 @@ public class DefaultTitleManager_183 {
}
/**
* Set title text
* Set title text.
*
* @param title
* Title
* @param title Title
*/
public void setTitle(String title) {
this.title = title;
}
/**
* Get subtitle text
* Get subtitle text.
*
* @return Subtitle text
*/
@ -164,37 +153,34 @@ public class DefaultTitleManager_183 {
}
/**
* Set subtitle text
* Set subtitle text.
*
* @param subtitle
* Subtitle text
* @param subtitle Subtitle text
*/
public void setSubtitle(String subtitle) {
this.subtitle = subtitle;
}
/**
* Set the title color
* Set the title color.
*
* @param color
* Chat color
* @param color Chat color
*/
public void setTitleColor(ChatColor color) {
this.titleColor = color;
}
/**
* Set the subtitle color
* Set the subtitle color.
*
* @param color
* Chat color
* @param color Chat color
*/
public void setSubtitleColor(ChatColor color) {
this.subtitleColor = color;
}
/**
* Set title fade in time
* Set title fade in time.
*
* @param time
* Time
@ -204,47 +190,42 @@ public class DefaultTitleManager_183 {
}
/**
* Set title fade out time
* Set title fade out time.
*
* @param time
* Time
* @param time Time
*/
public void setFadeOutTime(int time) {
this.fadeOutTime = time;
}
/**
* Set title stay time
* Set title stay time.
*
* @param time
* Time
* @param time Time
*/
public void setStayTime(int time) {
this.stayTime = time;
}
/**
* Set timings to ticks
* Set timings to ticks.
*/
public void setTimingsToTicks() {
this.ticks = true;
}
/**
* Set timings to seconds
* Set timings to seconds.
*/
public void setTimingsToSeconds() {
this.ticks = false;
}
/**
* Send the title to a player
* Send the title to a player.
*
* @param player
* Player
* @throws InvocationTargetException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @param player Player
* @throws Exception
*/
public void send(Player player) throws Exception {
if (this.packetTitle != null) {
@ -258,11 +239,7 @@ public class DefaultTitleManager_183 {
Object packet = this.packetTitle
.getConstructor(this.packetActions, this.chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE)
.newInstance(actions[2], null,
this.fadeInTime * (
this.ticks ? 1 : 20),
this.fadeInTime * (this.ticks ? 1 : 20),
this.stayTime * (this.ticks ? 1 : 20), this.fadeOutTime * (this.ticks ? 1 : 20));
// Send if set
if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) {
@ -285,7 +262,7 @@ public class DefaultTitleManager_183 {
}
/**
* Broadcast the title to all players
* Broadcast the title to all players.
* @throws Exception
*/
public void broadcast() throws Exception {
@ -295,12 +272,10 @@ public class DefaultTitleManager_183 {
}
/**
* Clear the title
* Clear the title.
*
* @param player
* Player
* @throws IllegalAccessException
* @throws IllegalArgumentException
* @param player Player
* @throws Exception
*/
public void clearTitle(Player player) throws Exception {
// Send timings first
@ -313,16 +288,10 @@ public class DefaultTitleManager_183 {
}
/**
* Reset the title settings
* Reset the title settings.
*
* @param player
* Player
* @throws SecurityException
* @throws NoSuchMethodException
* @throws InvocationTargetException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws InstantiationException
* @param player Player
* @throws Exception
*/
public void resetTitle(Player player) throws Exception {
// Send timings first

View File

@ -114,9 +114,8 @@ public class HackTitleManager {
/**
* Load spigot and NMS classes.
* @throws ClassNotFoundException Spigot Error.
*/
private void loadClasses() throws ClassNotFoundException {
private void loadClasses() {
this.packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle");
this.packetActions = getClass("org.spigotmc.ProtocolInjector$PacketTitle$Action");
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");

View File

@ -20,6 +20,14 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.bukkit.object.entity.EntityWrapper;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.DyeColor;
@ -33,7 +41,6 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand;
import org.bukkit.block.Chest;
import org.bukkit.block.CommandBlock;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.block.Dispenser;
@ -53,37 +60,30 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
public class BukkitChunkManager extends ChunkManager {
private static HashMap<BlockLoc, ItemStack[]> chestContents;
private static HashMap<BlockLoc, ItemStack[]> furnaceContents;
private static HashMap<BlockLoc, ItemStack[]> dispenserContents;
private static HashMap<BlockLoc, ItemStack[]> dropperContents;
private static HashMap<BlockLoc, ItemStack[]> brewingStandContents;
private static HashMap<BlockLoc, ItemStack[]> beaconContents;
private static HashMap<BlockLoc, ItemStack[]> hopperContents;
private static HashMap<BlockLoc, Short[]> furnaceTime;
private static HashMap<BlockLoc, Object[]> skullData;
private static HashMap<BlockLoc, Material> jukeboxDisc;
private static HashMap<BlockLoc, Short> brewTime;
private static HashMap<BlockLoc, EntityType> spawnerData;
private static HashMap<BlockLoc, String> cmdData;
private static HashMap<BlockLoc, String[]> signContents;
private static HashMap<BlockLoc, Note> noteBlockContents;
private static HashMap<BlockLoc, List<Pattern>> bannerPatterns;
private static HashMap<BlockLoc, DyeColor> bannerBase;
private static HashSet<EntityWrapper> entities;
private static HashMap<PlotLoc, PlotBlock[]> allBlocks;
public static class ContentMap {
public HashMap<BlockLoc, ItemStack[]> chestContents;
public HashMap<BlockLoc, ItemStack[]> furnaceContents;
public HashMap<BlockLoc, ItemStack[]> dispenserContents;
public HashMap<BlockLoc, ItemStack[]> dropperContents;
public HashMap<BlockLoc, ItemStack[]> brewingStandContents;
public HashMap<BlockLoc, ItemStack[]> beaconContents;
public HashMap<BlockLoc, ItemStack[]> hopperContents;
public HashMap<BlockLoc, Short[]> furnaceTime;
public HashMap<BlockLoc, Object[]> skullData;
public HashMap<BlockLoc, Material> jukeboxDisc;
public HashMap<BlockLoc, Short> brewTime;
public HashMap<BlockLoc, EntityType> spawnerData;
public HashMap<BlockLoc, String> cmdData;
public HashMap<BlockLoc, String[]> signContents;
public HashMap<BlockLoc, Note> noteBlockContents;
public HashMap<BlockLoc, List<Pattern>> bannerPatterns;
public HashMap<BlockLoc, DyeColor> bannerBase;
public HashSet<EntityWrapper> entities;
public HashMap<PlotLoc, PlotBlock[]> allBlocks;
public static void initMaps() {
public ContentMap() {
chestContents = new HashMap<>();
furnaceContents = new HashMap<>();
dispenserContents = new HashMap<>();
@ -105,11 +105,29 @@ public class BukkitChunkManager extends ChunkManager {
allBlocks = new HashMap<>();
}
public static boolean isIn(RegionWrapper region, int x, int z) {
return x >= region.minX && x <= region.maxX && z >= region.minZ && z <= region.maxZ;
public void saveRegion(World world, int x1, int x2, int z1, int z2) {
if (z1 > z2) {
int tmp = z1;
z1 = z2;
z2 = tmp;
}
if (x1 > x2) {
int tmp = x1;
x1 = x2;
x2 = tmp;
}
for (int x = x1; x <= x2; x++) {
for (int z = z1; z <= z2; z++) {
saveBlocks(world, 256, x, z, 0, 0, true);
}
}
}
public static void saveEntitiesOut(Chunk chunk, RegionWrapper region) {
public void saveEntitiesIn(Chunk chunk, RegionWrapper region) {
saveEntitiesIn(chunk, region, 0, 0, false);
}
public void saveEntitiesOut(Chunk chunk, RegionWrapper region) {
for (Entity entity : chunk.getEntities()) {
Location loc = BukkitUtil.getLocation(entity);
int x = loc.getX();
@ -125,11 +143,7 @@ public class BukkitChunkManager extends ChunkManager {
}
}
public static void saveEntitiesIn(Chunk chunk, RegionWrapper region) {
saveEntitiesIn(chunk, region, 0, 0, false);
}
public static void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ, boolean delete) {
public void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ, boolean delete) {
for (Entity entity : chunk.getEntities()) {
Location loc = BukkitUtil.getLocation(entity);
int x = loc.getX();
@ -152,7 +166,7 @@ public class BukkitChunkManager extends ChunkManager {
}
}
public static void restoreEntities(World world, int xOffset, int zOffset) {
public void restoreEntities(World world, int xOffset, int zOffset) {
for (EntityWrapper entity : entities) {
try {
entity.spawn(world, xOffset, zOffset);
@ -164,13 +178,13 @@ public class BukkitChunkManager extends ChunkManager {
entities.clear();
}
public static void restoreBlocks(World world, int xOffset, int zOffset) {
public void restoreBlocks(World world, int xOffset, int zOffset) {
for (Entry<BlockLoc, ItemStack[]> blockLocEntry : chestContents.entrySet()) {
try {
Block block =
world.getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y, blockLocEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof Chest) {
if (state instanceof InventoryHolder) {
InventoryHolder chest = (InventoryHolder) state;
chest.getInventory().setContents(blockLocEntry.getValue());
state.update(true);
@ -488,7 +502,7 @@ public class BukkitChunkManager extends ChunkManager {
}
}
public static void saveBlocks(World world, int maxY, int x, int z, int offsetX, int offsetZ, boolean storeNormal) {
public void saveBlocks(World world, int maxY, int x, int z, int offsetX, int offsetZ, boolean storeNormal) {
maxY = Math.min(255, maxY);
PlotBlock[] ids;
if (storeNormal) {
@ -499,10 +513,11 @@ public class BukkitChunkManager extends ChunkManager {
for (short y = 0; y <= maxY; y++) {
Block block = world.getBlockAt(x, y, z);
Material id = block.getType();
if (!id.equals(Material.AIR)) {
if (storeNormal) {
ids[y] = new PlotBlock((short) id.getId(), block.getData());
int typeId = id.getId();
ids[y] = new PlotBlock((short) typeId, typeId == 0 ? 0 : block.getData());
}
if (!id.equals(Material.AIR)) {
try {
BlockLoc bl = new BlockLoc(x + offsetX, y, z + offsetZ);
if (block.getState() instanceof InventoryHolder) {
@ -582,6 +597,11 @@ public class BukkitChunkManager extends ChunkManager {
PlotLoc loc = new PlotLoc(x + offsetX, z + offsetZ);
allBlocks.put(loc, ids);
}
}
public static boolean isIn(RegionWrapper region, int x, int z) {
return x >= region.minX && x <= region.maxX && z >= region.minZ && z <= region.maxZ;
}
private static byte getOrdinal(Object[] list, Object value) {
for (byte i = 0; i < list.length; i++) {
@ -592,14 +612,13 @@ public class BukkitChunkManager extends ChunkManager {
return 0;
}
public static void swapChunk(World world1, World world2, Chunk pos1, Chunk pos2, RegionWrapper r1,
RegionWrapper r2) {
initMaps();
public static ContentMap swapChunk(World world1, World world2, Chunk pos1, Chunk pos2, RegionWrapper r1, RegionWrapper r2) {
ContentMap map = new ContentMap();
int relX = r2.minX - r1.minX;
int relZ = r2.minZ - r1.minZ;
saveEntitiesIn(pos1, r1, relX, relZ, true);
saveEntitiesIn(pos2, r2, -relX, -relZ, true);
map.saveEntitiesIn(pos1, r1, relX, relZ, true);
map.saveEntitiesIn(pos2, r2, -relX, -relZ, true);
int sx = pos1.getX() << 4;
int sz = pos1.getZ() << 4;
@ -609,7 +628,7 @@ public class BukkitChunkManager extends ChunkManager {
for (int x = Math.max(r1.minX, sx); x <= Math.min(r1.maxX, sx + 15); x++) {
for (int z = Math.max(r1.minZ, sz); z <= Math.min(r1.maxZ, sz + 15); z++) {
saveBlocks(world1, 256, sx, sz, relX, relZ, false);
map.saveBlocks(world1, 256, sx, sz, relX, relZ, false);
for (int y = 0; y < 256; y++) {
Block block1 = world1.getBlockAt(x, y, z);
int id1 = block1.getTypeId();
@ -639,10 +658,7 @@ public class BukkitChunkManager extends ChunkManager {
}
}
}
while (SetQueue.IMP.forceChunkSet()) {
}
restoreBlocks(world1, 0, 0);
restoreEntities(world1, 0, 0);
return map;
}
@Override
@ -684,7 +700,7 @@ public class BukkitChunkManager extends ChunkManager {
final World newWorld = Bukkit.getWorld(newPos.getWorld());
final String newWorldName = newWorld.getName();
List<ChunkLoc> chunks = new ArrayList<>();
initMaps();
final ContentMap map = new ContentMap();
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
@Override
public void run(int[] value) {
@ -696,17 +712,17 @@ public class BukkitChunkManager extends ChunkManager {
int cxx = loc.x << 4;
int czz = loc.z << 4;
Chunk chunk = oldWorld.getChunkAt(loc.x, loc.z);
saveEntitiesIn(chunk, region);
map.saveEntitiesIn(chunk, region);
for (int x = bx & 15; x <= (tx & 15); x++) {
for (int z = bz & 15; z <= (tz & 15); z++) {
saveBlocks(oldWorld, 256, cxx + x, czz + z, relX, relZ, true);
map.saveBlocks(oldWorld, 256, cxx + x, czz + z, relX, relZ, true);
}
}
}
}, new Runnable() {
@Override
public void run() {
for (Entry<PlotLoc, PlotBlock[]> entry : allBlocks.entrySet()) {
for (Entry<PlotLoc, PlotBlock[]> entry : map.allBlocks.entrySet()) {
PlotLoc loc = entry.getKey();
PlotBlock[] blocks = entry.getValue();
for (int y = 0; y < blocks.length; y++) {
@ -716,34 +732,19 @@ public class BukkitChunkManager extends ChunkManager {
}
}
}
while (SetQueue.IMP.forceChunkSet()) {
}
restoreBlocks(newWorld, 0, 0);
restoreEntities(newWorld, relX, relZ);
SetQueue.IMP.addTask(new Runnable() {
@Override
public void run() {
map.restoreBlocks(newWorld, 0, 0);
map.restoreEntities(newWorld, relX, relZ);
TaskManager.runTask(whenDone);
}
});
}
}, 5);
return true;
}
public void saveRegion(World world, int x1, int x2, int z1, int z2) {
if (z1 > z2) {
int tmp = z1;
z1 = z2;
z2 = tmp;
}
if (x1 > x2) {
int tmp = x1;
x1 = x2;
x2 = tmp;
}
for (int x = x1; x <= x2; x++) {
for (int z = z1; z <= z2; z++) {
saveBlocks(world, 256, x, z, 0, 0, true);
}
}
}
@Override
public boolean regenerateRegion(final Location pos1, final Location pos2, final boolean ignoreAugment, final Runnable whenDone) {
final String world = pos1.getWorld();
@ -825,32 +826,32 @@ public class BukkitChunkManager extends ChunkManager {
} else {
zzt2 = zzt;
}
initMaps();
final ContentMap map = new ContentMap();
if (checkX1) {
saveRegion(worldObj, xxb, xxb2, zzb2, zzt2); //
map.saveRegion(worldObj, xxb, xxb2, zzb2, zzt2); //
}
if (checkX2) {
saveRegion(worldObj, xxt2, xxt, zzb2, zzt2); //
map.saveRegion(worldObj, xxt2, xxt, zzb2, zzt2); //
}
if (checkZ1) {
saveRegion(worldObj, xxb2, xxt2, zzb, zzb2); //
map.saveRegion(worldObj, xxb2, xxt2, zzb, zzb2); //
}
if (checkZ2) {
saveRegion(worldObj, xxb2, xxt2, zzt2, zzt); //
map.saveRegion(worldObj, xxb2, xxt2, zzt2, zzt); //
}
if (checkX1 && checkZ1) {
saveRegion(worldObj, xxb, xxb2, zzb, zzb2); //
map.saveRegion(worldObj, xxb, xxb2, zzb, zzb2); //
}
if (checkX2 && checkZ1) {
saveRegion(worldObj, xxt2, xxt, zzb, zzb2); // ?
map.saveRegion(worldObj, xxt2, xxt, zzb, zzb2); // ?
}
if (checkX1 && checkZ2) {
saveRegion(worldObj, xxb, xxb2, zzt2, zzt); // ?
map.saveRegion(worldObj, xxb, xxb2, zzt2, zzt); // ?
}
if (checkX2 && checkZ2) {
saveRegion(worldObj, xxt2, xxt, zzt2, zzt); //
map.saveRegion(worldObj, xxt2, xxt, zzt2, zzt); //
}
saveEntitiesOut(chunkObj, currentPlotClear);
map.saveEntitiesOut(chunkObj, currentPlotClear);
AugmentedUtils.bypass(ignoreAugment, new Runnable() {
@Override
public void run() {
@ -864,7 +865,7 @@ public class BukkitChunkManager extends ChunkManager {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
PlotLoc loc = new PlotLoc(bx + x, bz + z);
PlotBlock[] ids = allBlocks.get(loc);
PlotBlock[] ids = map.allBlocks.get(loc);
if (ids != null) {
for (int y = 0; y < Math.min(128, ids.length); y++) {
PlotBlock id = ids[y];
@ -887,8 +888,8 @@ public class BukkitChunkManager extends ChunkManager {
}, world, chunk);
}
});
restoreBlocks(worldObj, 0, 0);
restoreEntities(worldObj, 0, 0);
map.restoreBlocks(worldObj, 0, 0);
map.restoreEntities(worldObj, 0, 0);
}
if (!chunks.isEmpty()) {
TaskManager.runTaskLater(this, 1);
@ -938,24 +939,35 @@ public class BukkitChunkManager extends ChunkManager {
}
@Override
public void swap(Location bot1, Location top1, Location bot2, Location top2, Runnable whenDone) {
public void swap(Location bot1, Location top1, Location bot2, Location top2, final Runnable whenDone) {
RegionWrapper region1 = new RegionWrapper(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
RegionWrapper region2 = new RegionWrapper(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ());
World world1 = Bukkit.getWorld(bot1.getWorld());
World world2 = Bukkit.getWorld(bot2.getWorld());
final World world1 = Bukkit.getWorld(bot1.getWorld());
final World world2 = Bukkit.getWorld(bot2.getWorld());
int relX = bot2.getX() - bot1.getX();
int relZ = bot2.getZ() - bot1.getZ();
final ArrayDeque<ContentMap> maps = new ArrayDeque<>();
for (int x = bot1.getX() >> 4; x <= top1.getX() >> 4; x++) {
for (int z = bot1.getZ() >> 4; z <= top1.getZ() >> 4; z++) {
Chunk chunk1 = world1.getChunkAt(x, z);
Chunk chunk2 = world2.getChunkAt(x + (relX >> 4), z + (relZ >> 4));
swapChunk(world1, world2, chunk1, chunk2, region1, region2);
maps.add(swapChunk(world1, world2, chunk1, chunk2, region1, region2));
}
}
SetQueue.IMP.addTask(new Runnable() {
@Override
public void run() {
for (ContentMap map : maps) {
map.restoreBlocks(world1, 0, 0);
map.restoreEntities(world1, 0, 0);
TaskManager.runTaskLater(whenDone, 1);
}
}
});
}
@Override
public int[] countEntities(Plot plot) {

View File

@ -4,16 +4,17 @@ import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.bukkit.commands.DebugUUID;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class BukkitCommand implements CommandExecutor, TabCompleter {
public BukkitCommand() {
@ -25,7 +26,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
if (commandSender instanceof Player) {
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), args);
}
if (commandSender == null || commandSender.getClass() == Bukkit.getConsoleSender().getClass()) {
if (commandSender.getClass() == Bukkit.getConsoleSender().getClass()) {
return MainCommand.onCommand(ConsolePlayer.getConsole(), args);
}
@SuppressWarnings("deprecation")
@ -71,6 +72,6 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
for (Object o : objects) {
result.add(o.toString());
}
return result;
return result.size() == 0 ? null : result;
}
}

View File

@ -34,8 +34,7 @@ public class BukkitEconHandler extends EconHandler {
}
private boolean setupPermissions() {
RegisteredServiceProvider<Permission> permissionProvider =
Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
RegisteredServiceProvider<Permission> permissionProvider = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
if (permissionProvider != null) {
this.perms = permissionProvider.getProvider();
}
@ -43,8 +42,10 @@ public class BukkitEconHandler extends EconHandler {
}
private boolean setupEconomy() {
RegisteredServiceProvider<Economy> economyProvider =
Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
if (economyProvider != null) {
this.econ = economyProvider.getProvider();
}

View File

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

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util;
import com.intellectualcrafters.jnbt.ByteArrayTag;
@ -46,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;
/**
@ -65,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));
@ -134,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);
@ -165,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;
@ -239,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:
@ -276,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));
@ -295,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
@ -330,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 restoreTile(String world, CompoundTag ct, int x, int y, int z) {
new StateWrapper(ct).restoreTag(world, x, y, z);
}
}

View File

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

View File

@ -7,34 +7,34 @@ import org.bukkit.Bukkit;
public class BukkitTaskManager extends TaskManager {
@Override
public int taskRepeat(Runnable r, int interval) {
return BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, r, interval, interval);
public int taskRepeat(Runnable runnable, int interval) {
return BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, runnable, interval, interval);
}
@SuppressWarnings("deprecation")
@Override
public int taskRepeatAsync(Runnable r, int interval) {
return BukkitMain.THIS.getServer().getScheduler().scheduleAsyncRepeatingTask(BukkitMain.THIS, r, interval, interval);
public int taskRepeatAsync(Runnable runnable, int interval) {
return BukkitMain.THIS.getServer().getScheduler().scheduleAsyncRepeatingTask(BukkitMain.THIS, runnable, interval, interval);
}
@Override
public void taskAsync(Runnable r) {
BukkitMain.THIS.getServer().getScheduler().runTaskAsynchronously(BukkitMain.THIS, r).getTaskId();
public void taskAsync(Runnable runnable) {
BukkitMain.THIS.getServer().getScheduler().runTaskAsynchronously(BukkitMain.THIS, runnable).getTaskId();
}
@Override
public void task(Runnable r) {
BukkitMain.THIS.getServer().getScheduler().runTask(BukkitMain.THIS, r).getTaskId();
public void task(Runnable runnable) {
BukkitMain.THIS.getServer().getScheduler().runTask(BukkitMain.THIS, runnable).getTaskId();
}
@Override
public void taskLater(Runnable r, int delay) {
BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, r, delay).getTaskId();
public void taskLater(Runnable runnable, int delay) {
BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, runnable, delay).getTaskId();
}
@Override
public void taskLaterAsync(Runnable r, int delay) {
BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, r, delay);
public void taskLaterAsync(Runnable runnable, int delay) {
BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, runnable, delay);
}
@Override

View File

@ -12,6 +12,8 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.bukkit.object.BukkitPlayer;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
@ -32,9 +34,6 @@ import org.bukkit.material.Tree;
import org.bukkit.material.WoodenStep;
import org.bukkit.material.Wool;
import java.util.Arrays;
import java.util.List;
public class BukkitUtil extends WorldUtil {
private static String lastString = null;
@ -97,8 +96,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 +113,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 +123,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);
@ -157,6 +156,11 @@ public class BukkitUtil extends WorldUtil {
return null;
}
@Override
public Location getSpawn(PlotPlayer pp) {
return getLocation(((BukkitPlayer) pp).player.getBedSpawnLocation());
}
@Override
public Location getSpawn(String world) {
org.bukkit.Location temp = getWorld(world).getSpawnLocation();
@ -172,8 +176,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();
}

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.plotsquared.bukkit.util;
import com.intellectualcrafters.plot.PS;
@ -51,39 +31,39 @@ import java.util.zip.GZIPOutputStream;
public class Metrics {
/**
* The current revision number
* The current revision number.
*/
private final static int REVISION = 7;
private static final int REVISION = 7;
/**
* The base url of the metrics domain
* The base url of the metrics domain.
*/
private static final String BASE_URL = "http://report.mcstats.org";
/**
* The url used to report a server's status
* The url used to report a server's status.
*/
private static final String REPORT_URL = "/plugin/%s";
/**
* Interval of time to ping (in minutes)
* Interval of time to ping (in minutes).
*/
private static final int PING_INTERVAL = 15;
/**
* The plugin this metrics submits for
* The plugin this metrics submits for.
*/
private final Plugin plugin;
/**
* All of the custom graphs to submit to metrics
* All of the custom graphs to submit to metrics.
*/
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
/**
* Unique server id
* Unique server id.
*/
private final String guid;
/**
* Debug mode
* Debug mode.
*/
private final boolean debug;
/**
* The scheduled task
* The scheduled task.
*/
private volatile BukkitTask task = null;
@ -97,7 +77,7 @@ public class Metrics {
}
/**
* GZip compress a string of bytes
* GZip compress a string of bytes.
*
* @param input
*
@ -129,7 +109,6 @@ public class Metrics {
* @param key
* @param value
*
* @throws UnsupportedEncodingException
*/
private static void appendJSONPair(StringBuilder json, String key, String value) {
boolean isValueNumeric = false;
@ -342,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);

View File

@ -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.
@ -336,7 +336,7 @@ public class NbtFactory {
}
/**
* Search for the first publically and privately defined method of the given name and parameter count.
* Search for the first publicly and privately defined method of the given name and parameter count.
* @param requireMod - modifiers that are required.
* @param bannedMod - modifiers that are banned.
* @param clazz - a class to start with.
@ -366,7 +366,7 @@ public class NbtFactory {
}
/**
* Search for the first publically and privately defined field of the given name.
* Search for the first publicly and privately defined field of the given name.
* @param instance - an instance of the class with the field.
* @param clazz - an optional class to start with, or NULL to deduce it from instance.
* @param fieldName - the field name.
@ -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;
}

View File

@ -56,7 +56,7 @@ public class OfflinePlayerUtil {
return name;
}
Constructor gameProfileConstructor = makeConstructor(gameProfileClass, UUID.class, String.class);
if (gameProfileConstructor == null) { //Verson has string constructor
if (gameProfileConstructor == null) { //Version has string constructor
gameProfileConstructor = makeConstructor(gameProfileClass, String.class, String.class);
return callConstructor(gameProfileConstructor, id.toString(), name);
} else { //Version has uuid constructor

View File

@ -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> locs) {
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 : locs) {
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);

View File

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

View File

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

View File

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

View File

@ -34,7 +34,7 @@ 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;
@ -46,7 +46,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
private final RefField fieldWorld;
private final RefMethod methodGetIdArray;
private final RefMethod methodGetWorld;
private final RefField tileEntityUnload;
private final RefField tileEntityListTick;
public FastQueue_1_8_3() throws RuntimeException {
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
@ -63,9 +63,9 @@ public class FastQueue_1_8_3 extends SlowQueue {
this.methodGetIdArray = classChunkSection.getMethod("getIdArray");
this.methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class);
this.classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
this.tileEntityUnload = classWorld.getField("c");
this.tileEntityListTick = classWorld.getField("tileEntityList");
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,16 +129,14 @@ 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);
Field tileEntities = clazz.getDeclaredField("tileEntities");
Field entitySlices = clazz.getDeclaredField("entitySlices");
Object[] sections = (Object[]) sections1.get(c);
HashMap<?, ?> tiles = (HashMap<?, ?>) tileEntities.get(c);
Collection<Object> tilesUnload = (Collection<Object>) tileEntityUnload.of(w).get();
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
Method getX = null;
@ -146,6 +144,7 @@ public class FastQueue_1_8_3 extends SlowQueue {
Method getZ = null;
// Trim tiles
boolean removed = false;
Set<Entry<?, ?>> entrySet = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
Iterator<Entry<?, ?>> iterator = entrySet.iterator();
while (iterator.hasNext()) {
@ -167,10 +166,13 @@ public class FastQueue_1_8_3 extends SlowQueue {
continue;
}
if (array[k] != 0) {
tilesUnload.add(tile.getValue());
removed = true;
iterator.remove();
}
}
if (removed) {
((Collection) this.tileEntityListTick.of(w).get()).clear();
}
// Trim entities
for (int i = 0; i < 16; i++) {
@ -407,6 +409,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);
}
}

View File

@ -10,15 +10,13 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor;
import com.intellectualcrafters.plot.util.SetQueue;
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 java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
@ -36,8 +34,7 @@ import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
public class FastQueue_1_9 extends SlowQueue {
private final Object air;
private final SendChunk chunkSender;
private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
// private final HashMap<ChunkWrapper, Chunk> toUpdate = new HashMap<>();
private final RefMethod methodGetHandleChunk;
private final RefMethod methodInitLighting;
private final RefConstructor classBlockPositionConstructor;
@ -52,7 +49,8 @@ public class FastQueue_1_9 extends SlowQueue {
private final RefMethod methodGetCombinedId;
private final RefMethod methodGetByCombinedId;
private final RefMethod methodGetWorld;
private final RefField tileEntityUnload;
private final RefField tileEntityListTick;
public FastQueue_1_9() throws RuntimeException {
@ -63,7 +61,7 @@ public class FastQueue_1_9 extends SlowQueue {
RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
this.classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
RefClass classWorld = getRefClass("{nms}.World");
this.tileEntityUnload = classWorld.getField("tileEntityListUnload");
this.tileEntityListTick = classWorld.getField("tileEntityListTick");
this.methodGetWorld = classChunk.getMethod("getWorld");
this.methodW = classWorld.getMethod("w", classBlockPosition.getRealClass());
this.fieldSections = classChunk.getField("sections");
@ -79,63 +77,19 @@ public class FastQueue_1_9 extends SlowQueue {
this.methodAreNeighborsLoaded = classChunk.getMethod("areNeighborsLoaded", int.class);
this.classChunkSectionConstructor = classChunkSection.getConstructor(int.class, boolean.class, char[].class);
this.air = this.methodGetByCombinedId.call(0);
this.chunkSender = new SendChunk();
TaskManager.runTaskRepeat(new Runnable() {
@Override
public void run() {
if (FastQueue_1_9.this.toUpdate.isEmpty()) {
return;
}
int count = 0;
ArrayList<Chunk> chunks = new ArrayList<>();
Iterator<Entry<ChunkWrapper, Chunk>> i = FastQueue_1_9.this.toUpdate.entrySet().iterator();
while (i.hasNext() && count < 128) {
chunks.add(i.next().getValue());
i.remove();
count++;
}
if (count == 0) {
return;
}
update(chunks);
}
}, 1);
MainUtil.initCache();
}
public void update(Collection<Chunk> chunks) {
if (chunks.isEmpty()) {
return;
}
if (!MainUtil.canSendChunk) {
for (Chunk chunk : chunks) {
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
chunk.unload(true, true);
chunk.load();
}
return;
}
try {
this.chunkSender.sendChunk(chunks);
} catch (Throwable e) {
e.printStackTrace();
MainUtil.canSendChunk = false;
}
}
/**
* This should be overridden by any specialized queues
* @param plotChunk
*/
@Override
public void execute(PlotChunk<Chunk> plotChunk) {
FastChunk_1_9 fs = (FastChunk_1_9) plotChunk;
public void execute(final PlotChunk<Chunk> plotChunk) {
final FastChunk_1_9 fs = (FastChunk_1_9) plotChunk;
Chunk chunk = plotChunk.getChunk();
World world = chunk.getWorld();
ChunkWrapper wrapper = plotChunk.getChunkWrapper();
if (!this.toUpdate.containsKey(wrapper)) {
this.toUpdate.put(wrapper, chunk);
}
chunk.load(true);
try {
boolean flag = world.getEnvironment() == Environment.NORMAL;
@ -143,22 +97,21 @@ 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);
Field tf = clazz.getDeclaredField("tileEntities");
Field entitySlices = clazz.getDeclaredField("entitySlices");
Object[] sections = (Object[]) sf.get(c);
HashMap<?, ?> tiles = (HashMap<?, ?>) tf.get(c);
Collection<Object> tilesUnload = (Collection<Object>) tileEntityUnload.of(w).get();
Collection<?>[] entities = (Collection<?>[]) entitySlices.get(c);
Method xm = null;
Method ym = null;
Method zm = null;
// Trim tiles
boolean removed = false;
Set<Entry<?, ?>> entrySet = (Set<Entry<?, ?>>) (Set<?>) tiles.entrySet();
Iterator<Entry<?, ?>> iterator = entrySet.iterator();
while (iterator.hasNext()) {
@ -180,10 +133,13 @@ public class FastQueue_1_9 extends SlowQueue {
continue;
}
if (array[k] != 0) {
tilesUnload.add(tile.getValue());
removed = true;
iterator.remove();
}
}
if (removed) {
((Collection) this.tileEntityListTick.of(w).get()).clear();
}
// Trim entities
for (int i = 0; i < 16; i++) {
@ -230,7 +186,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 +194,6 @@ public class FastQueue_1_9 extends SlowQueue {
setType.call(x, y & 15, z, iBlock);
}
}
}
if (fill) {
fs.setCount(j, Short.MAX_VALUE);
}
@ -265,6 +220,12 @@ public class FastQueue_1_9 extends SlowQueue {
}
}
}
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
sendChunk(fs.getChunkWrapper().world, Arrays.asList(new ChunkLoc(fs.getX(), fs.getZ())));
}
}, 1);
}
public Object newChunkSection(int i, boolean flag, char[] ids) {
@ -306,7 +267,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 +275,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);
}
}
}
@ -443,7 +404,6 @@ public class FastQueue_1_9 extends SlowQueue {
if (section == null) {
return 0;
}
// Object array = getBlocks(section);
return getId(section, x, y, z);
}
@ -456,14 +416,7 @@ public class FastQueue_1_9 extends SlowQueue {
public void sendChunk(final String world, final Collection<ChunkLoc> locations) {
World worldObj = BukkitUtil.getWorld(world);
for (ChunkLoc loc : locations) {
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
this.toUpdate.remove(wrapper);
worldObj.refreshChunk(loc.x, loc.z);
}
TaskManager.runTaskLater(new Runnable() {
@Override
public void run() {
FastQueue_1_9.this.chunkSender.sendChunk(world, locations);
}
}, 1);
}
}

View File

@ -8,14 +8,13 @@ import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.PlotQueue;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
import org.bukkit.Chunk;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Chunk;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
public class SlowQueue implements PlotQueue<Chunk> {
@ -62,12 +61,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;

View File

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

View File

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

View File

@ -537,16 +537,16 @@ public class MemorySection implements ConfigurationSection {
@Override
public List<String> getStringList(String path) {
List<?> list = getList(path);
final List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<String> result = new ArrayList<>();
final List<String> result = new ArrayList<>();
for (Object object : list) {
if ((object instanceof String) || isPrimitiveWrapper(object)) {
for (final Object object : list) {
if ((object instanceof String) || (isPrimitiveWrapper(object))) {
result.add(String.valueOf(object));
}
}
@ -558,10 +558,6 @@ public class MemorySection implements ConfigurationSection {
public List<Integer> getIntegerList(String path) {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Integer> result = new ArrayList<>();
for (Object object : list) {
@ -586,10 +582,6 @@ public class MemorySection implements ConfigurationSection {
public List<Boolean> getBooleanList(String path) {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Boolean> result = new ArrayList<>();
for (Object object : list) {
@ -611,10 +603,6 @@ public class MemorySection implements ConfigurationSection {
public List<Double> getDoubleList(String path) {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Double> result = new ArrayList<>();
for (Object object : list) {
@ -639,10 +627,6 @@ public class MemorySection implements ConfigurationSection {
public List<Float> getFloatList(String path) {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Float> result = new ArrayList<>();
for (Object object : list) {
@ -667,10 +651,6 @@ public class MemorySection implements ConfigurationSection {
public List<Long> getLongList(String path) {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Long> result = new ArrayList<>();
for (Object object : list) {
@ -695,10 +675,6 @@ public class MemorySection implements ConfigurationSection {
public List<Byte> getByteList(String path) {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Byte> result = new ArrayList<>();
for (Object object : list) {
@ -723,10 +699,6 @@ public class MemorySection implements ConfigurationSection {
public List<Character> getCharacterList(String path) {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Character> result = new ArrayList<>();
for (Object object : list) {
@ -750,10 +722,6 @@ public class MemorySection implements ConfigurationSection {
public List<Short> getShortList(String path) {
List<?> list = getList(path);
if (list == null) {
return new ArrayList<>(0);
}
List<Short> result = new ArrayList<>();
for (Object object : list) {
@ -779,10 +747,6 @@ public class MemorySection implements ConfigurationSection {
List<?> list = getList(path);
List<Map<?, ?>> result = new ArrayList<>();
if (list == null) {
return result;
}
for (Object object : list) {
if (object instanceof Map) {
result.add((Map<?, ?>) object);

View File

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

View File

@ -1,34 +1,35 @@
package com.intellectualcrafters.configuration.file;
import java.util.LinkedHashMap;
import java.util.Map;
import org.yaml.snakeyaml.nodes.Node;
import org.yaml.snakeyaml.representer.Representer;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerializable;
import com.intellectualcrafters.configuration.serialization.ConfigurationSerialization;
import org.yaml.snakeyaml.nodes.Node;
import org.yaml.snakeyaml.representer.Representer;
import java.util.LinkedHashMap;
import java.util.Map;
public class YamlRepresenter extends Representer {
public YamlRepresenter() {
multiRepresenters.put(ConfigurationSection.class, new RepresentConfigurationSection());
multiRepresenters.put(ConfigurationSerializable.class, new RepresentConfigurationSerializable());
this.multiRepresenters.put(ConfigurationSection.class, new RepresentConfigurationSection());
this.multiRepresenters.put(ConfigurationSerializable.class, new RepresentConfigurationSerializable());
}
private class RepresentConfigurationSection extends RepresentMap {
@Override
public Node representData(final Object data) {
public Node representData(Object data) {
return super.representData(((ConfigurationSection) data).getValues(false));
}
}
private class RepresentConfigurationSerializable extends RepresentMap {
@Override
public Node representData(final Object data) {
final ConfigurationSerializable serializable = (ConfigurationSerializable) data;
final Map<String, Object> values = new LinkedHashMap<>();
public Node representData(Object data) {
ConfigurationSerializable serializable = (ConfigurationSerializable) data;
Map<String, Object> values = new LinkedHashMap<>();
values.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(serializable.getClass()));
values.putAll(serializable.serialize());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
import java.nio.charset.Charset;
@ -29,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.
@ -46,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;

View File

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

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
import java.io.Closeable;
@ -36,6 +16,7 @@ import java.util.List;
* @author Graham Edgecombe
*/
public final class NBTOutputStream implements Closeable {
/**
* The output stream.
*/
@ -48,7 +29,7 @@ public final class NBTOutputStream implements Closeable {
*
* @throws IOException if an I/O error occurs.
*/
public NBTOutputStream(final OutputStream os) {
public NBTOutputStream(OutputStream os) {
this.os = new DataOutputStream(os);
}
@ -59,13 +40,13 @@ public final class NBTOutputStream implements Closeable {
*
* @throws IOException if an I/O error occurs.
*/
public void writeTag(final Tag tag) throws IOException {
final int type = NBTUtils.getTypeCode(tag.getClass());
final String name = tag.getName();
final byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
os.writeByte(type);
os.writeShort(nameBytes.length);
os.write(nameBytes);
public void writeTag(Tag tag) throws IOException {
int type = NBTUtils.getTypeCode(tag.getClass());
String name = tag.getName();
byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
this.os.writeByte(type);
this.os.writeShort(nameBytes.length);
this.os.write(nameBytes);
if (type == NBTConstants.TYPE_END) {
throw new IOException("Named TAG_End not permitted.");
}
@ -79,8 +60,8 @@ public final class NBTOutputStream implements Closeable {
*
* @throws IOException if an I/O error occurs.
*/
private void writeTagPayload(final Tag tag) throws IOException {
final int type = NBTUtils.getTypeCode(tag.getClass());
private void writeTagPayload(Tag tag) throws IOException {
int type = NBTUtils.getTypeCode(tag.getClass());
switch (type) {
case NBTConstants.TYPE_END:
writeEndTagPayload((EndTag) tag);
@ -130,8 +111,8 @@ public final class NBTOutputStream implements Closeable {
*
* @throws IOException if an I/O error occurs.
*/
private void writeByteTagPayload(final ByteTag tag) throws IOException {
os.writeByte(tag.getValue());
private void writeByteTagPayload(ByteTag tag) throws IOException {
this.os.writeByte(tag.getValue());
}
/**
@ -141,10 +122,10 @@ public final class NBTOutputStream implements Closeable {
*
* @throws IOException if an I/O error occurs.
*/
private void writeByteArrayTagPayload(final ByteArrayTag tag) throws IOException {
final byte[] bytes = tag.getValue();
os.writeInt(bytes.length);
os.write(bytes);
private void writeByteArrayTagPayload(ByteArrayTag tag) throws IOException {
byte[] bytes = tag.getValue();
this.os.writeInt(bytes.length);
this.os.write(bytes);
}
/**
@ -154,11 +135,11 @@ public final class NBTOutputStream implements Closeable {
*
* @throws IOException if an I/O error occurs.
*/
private void writeCompoundTagPayload(final CompoundTag tag) throws IOException {
for (final Tag childTag : tag.getValue().values()) {
private void writeCompoundTagPayload(CompoundTag tag) throws IOException {
for (Tag childTag : tag.getValue().values()) {
writeTag(childTag);
}
os.writeByte((byte) 0); // end tag - better way?
this.os.writeByte((byte) 0); // end tag - better way?
}
/**
@ -168,13 +149,13 @@ public final class NBTOutputStream implements Closeable {
*
* @throws IOException if an I/O error occurs.
*/
private void writeListTagPayload(final ListTag tag) throws IOException {
final Class<? extends Tag> clazz = tag.getType();
final List<Tag> tags = tag.getValue();
final int size = tags.size();
os.writeByte(NBTUtils.getTypeCode(clazz));
os.writeInt(size);
for (final Tag tag1 : tags) {
private void writeListTagPayload(ListTag tag) throws IOException {
Class<? extends Tag> clazz = tag.getType();
List<Tag> tags = tag.getValue();
int size = tags.size();
this.os.writeByte(NBTUtils.getTypeCode(clazz));
this.os.writeInt(size);
for (Tag tag1 : tags) {
writeTagPayload(tag1);
}
}
@ -186,10 +167,10 @@ public final class NBTOutputStream implements Closeable {
*
* @throws IOException if an I/O error occurs.
*/
private void writeStringTagPayload(final StringTag tag) throws IOException {
final byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET);
os.writeShort(bytes.length);
os.write(bytes);
private void writeStringTagPayload(StringTag tag) throws IOException {
byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET);
this.os.writeShort(bytes.length);
this.os.write(bytes);
}
/**
@ -199,8 +180,8 @@ public final class NBTOutputStream implements Closeable {
*
* @throws IOException if an I/O error occurs.
*/
private void writeDoubleTagPayload(final DoubleTag tag) throws IOException {
os.writeDouble(tag.getValue());
private void writeDoubleTagPayload(DoubleTag tag) throws IOException {
this.os.writeDouble(tag.getValue());
}
/**
@ -210,8 +191,8 @@ public final class NBTOutputStream implements Closeable {
*
* @throws IOException if an I/O error occurs.
*/
private void writeFloatTagPayload(final FloatTag tag) throws IOException {
os.writeFloat(tag.getValue());
private void writeFloatTagPayload(FloatTag tag) throws IOException {
this.os.writeFloat(tag.getValue());
}
/**
@ -221,8 +202,8 @@ public final class NBTOutputStream implements Closeable {
*
* @throws IOException if an I/O error occurs.
*/
private void writeLongTagPayload(final LongTag tag) throws IOException {
os.writeLong(tag.getValue());
private void writeLongTagPayload(LongTag tag) throws IOException {
this.os.writeLong(tag.getValue());
}
/**
@ -232,8 +213,8 @@ public final class NBTOutputStream implements Closeable {
*
* @throws IOException if an I/O error occurs.
*/
private void writeIntTagPayload(final IntTag tag) throws IOException {
os.writeInt(tag.getValue());
private void writeIntTagPayload(IntTag tag) throws IOException {
this.os.writeInt(tag.getValue());
}
/**
@ -243,32 +224,30 @@ public final class NBTOutputStream implements Closeable {
*
* @throws IOException if an I/O error occurs.
*/
private void writeShortTagPayload(final ShortTag tag) throws IOException {
os.writeShort(tag.getValue());
private void writeShortTagPayload(ShortTag tag) throws IOException {
this.os.writeShort(tag.getValue());
}
/**
* Writes a <code>TAG_Empty</code> tag.
*
* @param tag The tag.
*
* @throws IOException if an I/O error occurs.
*/
private void writeEndTagPayload(final EndTag tag) {
private void writeEndTagPayload(EndTag tag) {
/* empty */
}
private void writeIntArrayTagPayload(final IntArrayTag tag) throws IOException {
final int[] data = tag.getValue();
os.writeInt(data.length);
for (final int element : data) {
os.writeInt(element);
private void writeIntArrayTagPayload(IntArrayTag tag) throws IOException {
int[] data = tag.getValue();
this.os.writeInt(data.length);
for (int element : data) {
this.os.writeInt(element);
}
}
@Override
public void close() throws IOException {
os.close();
this.os.close();
}
/**
@ -276,6 +255,6 @@ public final class NBTOutputStream implements Closeable {
* @throws IOException
*/
public void flush() throws IOException {
os.flush();
this.os.flush();
}
}

View File

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

View File

@ -1,29 +1,10 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
/**
* The {@code TAG_Short} tag.
*/
public final class ShortTag extends Tag {
private final short value;
/**
@ -31,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;
}
@ -42,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;
}
}

View File

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

View File

@ -1,29 +1,10 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.jnbt;
/**
* Represents a NBT tag.
*/
public abstract class Tag {
private final String name;
/**
@ -51,7 +32,7 @@ public abstract class Tag {
* @return the name of this tag
*/
public final String getName() {
return name;
return this.name;
}
/**

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
/**

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
import java.util.Iterator;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
import java.io.IOException;
@ -66,7 +46,7 @@ public class JSONArray {
* Construct an empty JSONArray.
*/
public JSONArray() {
myArrayList = new ArrayList<Object>();
this.myArrayList = new ArrayList<Object>();
}
/**
@ -76,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 '['");
@ -86,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 ',':
@ -115,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));
}
@ -124,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));
}
}
}
@ -138,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)));
}
@ -159,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.");
}
@ -176,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"))) {
@ -195,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) {
@ -213,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) {
@ -231,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;
}
@ -248,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;
}
@ -265,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) {
@ -283,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;
}
@ -298,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));
}
@ -312,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();
}
@ -330,7 +310,7 @@ public class JSONArray {
* @return The length (or size).
*/
public int length() {
return myArrayList.size();
return this.myArrayList.size();
}
/**
@ -340,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);
}
/**
@ -352,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);
}
@ -365,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) {
@ -381,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);
}
@ -394,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) {
@ -410,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);
}
@ -423,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) {
@ -438,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;
}
@ -451,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;
}
@ -464,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);
}
@ -477,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) {
@ -487,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, "");
}
@ -505,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();
}
@ -517,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;
}
@ -529,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;
}
@ -543,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;
@ -557,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;
}
@ -569,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;
}
@ -581,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;
}
@ -594,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;
}
@ -610,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;
}
@ -625,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;
}
@ -641,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;
}
@ -657,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;
}
@ -673,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;
}
@ -688,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;
}
@ -705,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);
@ -728,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;
}
/**
@ -739,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;
@ -774,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));
}
@ -815,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();
}
@ -831,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);
}
@ -847,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(',');
@ -864,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) {
@ -874,7 +854,7 @@ public class JSONArray {
}
writer.write(']');
return writer;
} catch (final IOException e) {
} catch (IOException e) {
throw new JSONException(e);
}
}

View File

@ -21,7 +21,7 @@ public class JSONML {
*
* @throws JSONException
*/
private static Object parse(final XMLTokener x, final boolean arrayForm, final JSONArray ja) throws JSONException {
private static Object parse(XMLTokener x, boolean arrayForm, JSONArray ja) throws JSONException {
String attribute;
char c;
String closeTag = null;
@ -114,9 +114,6 @@ public class JSONML {
if (token == null) {
token = x.nextToken();
}
if (token == null) {
throw x.syntaxError("Misshaped tag");
}
if (!(token instanceof String)) {
break;
}
@ -195,7 +192,7 @@ public class JSONML {
*
* @throws JSONException
*/
public static JSONArray toJSONArray(final String string) throws JSONException {
public static JSONArray toJSONArray(String string) throws JSONException {
return toJSONArray(new XMLTokener(string));
}
@ -212,7 +209,7 @@ public class JSONML {
*
* @throws JSONException
*/
public static JSONArray toJSONArray(final XMLTokener x) throws JSONException {
public static JSONArray toJSONArray(XMLTokener x) throws JSONException {
return (JSONArray) parse(x, true, null);
}
@ -230,7 +227,7 @@ public class JSONML {
*
* @throws JSONException
*/
public static JSONObject toJSONObject(final XMLTokener x) throws JSONException {
public static JSONObject toJSONObject(XMLTokener x) throws JSONException {
return (JSONObject) parse(x, false, null);
}
@ -248,7 +245,7 @@ public class JSONML {
*
* @throws JSONException
*/
public static JSONObject toJSONObject(final String string) throws JSONException {
public static JSONObject toJSONObject(String string) throws JSONException {
return toJSONObject(new XMLTokener(string));
}
@ -261,14 +258,14 @@ public class JSONML {
*
* @throws JSONException
*/
public static String toString(final JSONArray ja) throws JSONException {
public static String toString(JSONArray ja) throws JSONException {
int i;
JSONObject jo;
String key;
Iterator<String> keys;
int length;
Object object;
final StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder();
String tagName;
String value;
// Emit <tagName
@ -338,8 +335,8 @@ public class JSONML {
*
* @throws JSONException
*/
public static String toString(final JSONObject jo) throws JSONException {
final StringBuilder sb = new StringBuilder();
public static String toString(JSONObject jo) throws JSONException {
StringBuilder sb = new StringBuilder();
int i;
JSONArray ja;
String key;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.json;
import java.util.Enumeration;

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -46,7 +46,7 @@ public class Updater {
String str = readUrl("https://api.github.com/repos/IntellectualSites/PlotSquared/releases/latest");
JSONObject release = new JSONObject(str);
JSONArray assets = (JSONArray) release.get("assets");
String downloadURL = String.format("PlotSquared-%s%n.jar", PS.get().getPlatform());
String downloadURL = String.format("PlotSquared-%s.jar", PS.get().getPlatform());
for (int i = 0; i < assets.length(); i++) {
JSONObject asset = assets.getJSONObject(i);
String name = asset.getString("name");
@ -59,7 +59,6 @@ public class Updater {
} else {
version = new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), 0};
}
URL url = new URL(asset.getString("browser_download_url"));
// If current version >= update
if (PS.get().checkVersion(PS.get().getVersion(), version)) {
PS.debug("&7PlotSquared is already up to date!");
@ -68,7 +67,7 @@ public class Updater {
log("&6PlotSquared " + StringMan.join(split, ".") + " is available:");
log("&8 - &3Use: &7/plot update");
log("&8 - &3Or: &7" + downloadURL);
return url;
return new URL(asset.getString("browser_download_url"));
} catch (MalformedURLException e) {
e.printStackTrace();
log("&dCould not check for updates (1)");

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C;
@ -31,7 +11,6 @@ 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.UUID;
@CommandDeclaration(
@ -41,7 +20,7 @@ import java.util.UUID;
usage = "/plot add <player>",
category = CommandCategory.SETTINGS,
permission = "plots.add",
requiredType = RequiredType.NONE)
requiredType = RequiredType.PLAYER)
public class Add extends SubCommand {
public Add() {

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PS;

View File

@ -39,7 +39,7 @@ import java.util.Set;
description = "Create a new PlotArea",
aliases = "world",
usage = "/plot area <create|info|list|tp|regen>",
confirmation=true)
confirmation = true)
public class Area extends SubCommand {
@Override
@ -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)) {
@ -137,7 +136,7 @@ public class Area extends SubCommand {
}, null);
}
} else {
MainUtil.sendMessage(plr, "An error occured while creating the world: " + area.worldname);
MainUtil.sendMessage(plr, "An error occurred while creating the world: " + area.worldname);
}
}
};
@ -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);
@ -257,7 +244,7 @@ public class Area extends SubCommand {
C.SETUP_FINISHED.send(plr);
plr.teleport(WorldUtil.IMP.getSpawn(world));
} else {
MainUtil.sendMessage(plr, "An error occured while creating the world: " + pa.worldname);
MainUtil.sendMessage(plr, "An error occurred while creating the world: " + pa.worldname);
}
try {
PS.get().config.save(PS.get().configFile);
@ -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,8 +393,9 @@ public class Area extends SubCommand {
}
}, "/plot area list", C.AREA_LIST_HEADER_PAGED.s());
return true;
}
case "regen":
case "clear":
case "reset":
case "regenerate": {
if (!Permissions.hasPermission(plr, "plots.area.regen")) {
C.NO_PERMISSION.send(plr, "plots.area.regen");
@ -435,7 +422,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 +447,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 +456,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;
}

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C;
@ -180,7 +160,6 @@ public class Auto extends SubCommand {
return false;
}
plotarea.setMeta("lastPlot", new PlotId(0, 0));
boolean br = false;
while (true) {
PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
PlotId end = new PlotId(start.x + size_x - 1, start.y + size_z - 1);

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C;
@ -46,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")) {
@ -60,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;
}
}
}
}

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PS;
@ -31,7 +11,6 @@ import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.Set;
@CommandDeclaration(
@ -45,7 +24,7 @@ import java.util.Set;
public class Buy extends SubCommand {
@Override
public boolean onCommand(PlotPlayer plr, String... args) {
public boolean onCommand(PlotPlayer plr, String[] args) {
if (EconHandler.manager == null) {
return sendMessage(plr, C.ECON_DISABLED);
}
@ -101,9 +80,7 @@ public class Buy extends SubCommand {
}
FlagManager.removePlotFlag(plot, "price");
}
for (Plot current : plots) {
plot.setOwner(plr.getUUID());
}
MainUtil.sendMessage(plr, C.CLAIMED);
return true;
}

View File

@ -13,7 +13,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Chat extends SubCommand {
@Override
public boolean onCommand(PlotPlayer player, String... args) {
public boolean onCommand(PlotPlayer player, String[] args) {
MainCommand.getInstance().toggle.chat(this, player, new String[0], null, null);
return true;
}

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C;
@ -40,7 +20,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Claim extends SubCommand {
@Override
public boolean onCommand(PlotPlayer plr, String... args) {
public boolean onCommand(PlotPlayer plr, String[] args) {
String schematic = "";
if (args.length >= 1) {
schematic = args[0];

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C;
@ -32,7 +12,6 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.Set;
@CommandDeclaration(command = "clear",
@ -45,7 +24,7 @@ import java.util.Set;
public class Clear extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, String... args) {
public boolean onCommand(final PlotPlayer plr, String[] args) {
Location loc = plr.getLocation();
final Plot plot;
if (args.length == 1) {

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PS;
@ -50,7 +30,7 @@ import java.util.UUID;
public class Cluster extends SubCommand {
@Override
public boolean onCommand(PlotPlayer plr, String... args) {
public boolean onCommand(PlotPlayer plr, String[] args) {
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
if (args.length == 0) {
@ -258,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")) {
@ -268,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;
@ -565,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;
@ -596,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;
}

View File

@ -1,64 +1,55 @@
package com.intellectualcrafters.plot.commands;
/**
* CommandCategory
*
* CommandCategory.
*/
public enum CommandCategory {
/**
* Claiming CommandConfig
*
* Claiming CommandConfig.
* Such as: /plot claim
*/
CLAIMING("Claiming"),
/**
* Teleportation CommandConfig
*
* Teleportation CommandConfig.
* Such as: /plot visit
*/
TELEPORT("Teleport"),
/**
* Protection
* Protection.
*/
SETTINGS("Protection"),
/**
* Chat
* Chat.
*/
CHAT("Chat"),
/**
* Web
* Web.
*/
SCHEMATIC("Web"),
/**
* Cosmetic
* Cosmetic.
*/
APPEARANCE("Cosmetic"),
/**
* Information CommandConfig
*
* Information CommandConfig.
* Such as: /plot info
*/
INFO("Info"),
/**
* Debug CommandConfig
*
* Debug CommandConfig.
* Such as: /plot debug
*/
DEBUG("Debug"),
/**
* Administration commands
* Administration commands.
*/
ADMINISTRATION("Admin");
/**
* The category name (Readable)
* The category name (Readable).
*/
private final String name;
/**
* Constructor
* Constructor.
*
* @param name readable name
*/

View File

@ -1,41 +1,17 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
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) {
@ -43,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
*/

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C;

View File

@ -1,23 +1,3 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PS;
@ -49,8 +29,8 @@ public class Condense extends SubCommand {
public static boolean TASK = false;
@Override
public boolean onCommand(final PlotPlayer plr, String... args) {
if ((args.length != 2) && (args.length != 3)) {
public boolean onCommand(final PlotPlayer plr, String[] args) {
if (args.length != 2 && args.length != 3) {
MainUtil.sendMessage(plr, "/plot condense <area> <start|stop|info> [radius]");
return false;
}
@ -65,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;
}
@ -76,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();
@ -111,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;
@ -119,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());
@ -134,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;
}
@ -167,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;
}
@ -176,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;
@ -201,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;
@ -218,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;
}
@ -226,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());
}
}

Some files were not shown because too many files have changed in this diff Show More