From 3ffb182a3cebf8c034d16b5478ee15037d7bf3c8 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 12 Oct 2014 00:37:36 -0700 Subject: [PATCH] yo yo yo testing some new formatting rules + bug fixes --- .../plot/AbstractFlag.java | 3 +- .../src/com/intellectualcrafters/plot/C.java | 520 +++++++------- .../plot/Configuration.java | 53 +- .../plot/ConfigurationNode.java | 7 +- .../plot/ConsoleColors.java | 40 +- .../com/intellectualcrafters/plot/Flag.java | 3 +- .../plot/FlagManager.java | 3 +- .../intellectualcrafters/plot/LSetCube.java | 15 +- .../com/intellectualcrafters/plot/Lag.java | 15 +- .../com/intellectualcrafters/plot/Logger.java | 22 +- .../intellectualcrafters/plot/Metrics.java | 224 +++--- .../com/intellectualcrafters/plot/PWE.java | 45 +- .../plot/PlayerFunctions.java | 55 +- .../com/intellectualcrafters/plot/Plot.java | 50 +- .../plot/PlotGenerator.java | 8 +- .../intellectualcrafters/plot/PlotHelper.java | 162 ++--- .../plot/PlotHomePosition.java | 15 +- .../intellectualcrafters/plot/PlotMain.java | 658 ++++++++---------- .../plot/PlotManager.java | 18 +- .../plot/PlotSettings.java | 24 +- .../plot/PlotSquaredException.java | 3 +- .../intellectualcrafters/plot/PlotWorld.java | 86 +-- .../com/intellectualcrafters/plot/RUtils.java | 20 +- .../plot/ReflectionUtils.java | 101 +-- .../plot/SchematicHandler.java | 50 +- .../plot/SetBlockFast.java | 16 +- .../intellectualcrafters/plot/Settings.java | 14 +- .../com/intellectualcrafters/plot/Title.java | 115 ++- .../plot/UUIDHandler.java | 86 +-- .../plot/api/PlotAPI.java | 126 ++-- .../plot/commands/Auto.java | 81 +-- .../plot/commands/Camera.java | 9 +- .../plot/commands/Claim.java | 37 +- .../plot/commands/Clear.java | 14 +- .../plot/commands/Command.java | 18 +- .../plot/commands/CommandPermission.java | 16 +- .../plot/commands/Copy.java | 14 +- .../plot/commands/Debug.java | 50 +- .../plot/commands/Delete.java | 26 +- .../plot/commands/Denied.java | 97 ++- .../plot/commands/Help.java | 14 +- .../plot/commands/Helpers.java | 85 ++- .../plot/commands/Home.java | 74 +- .../plot/commands/Info.java | 51 +- .../plot/commands/Inventory.java | 31 +- .../plot/commands/Kick.java | 26 +- .../plot/commands/MainCommand.java | 77 +- .../plot/commands/Merge.java | 69 +- .../plot/commands/Rate.java | 6 +- .../plot/commands/Reload.java | 20 +- .../plot/commands/Schematic.java | 12 +- .../plot/commands/Set.java | 131 ++-- .../plot/commands/SetOwner.java | 14 +- .../plot/commands/Setup.java | 90 ++- .../plot/commands/SubCommand.java | 27 +- .../plot/commands/TP.java | 31 +- .../plot/commands/Trusted.java | 85 ++- .../plot/commands/Unlink.java | 32 +- .../plot/commands/Visit.java | 20 +- .../plot/commands/list.java | 149 ++-- .../plot/commands/plugin.java | 67 +- .../plot/database/DBFunc.java | 453 ++++++------ .../plot/database/Database.java | 10 +- .../plot/database/MySQL.java | 17 +- .../plot/database/PlotMeConverter.java | 291 ++++---- .../plot/database/SQLite.java | 21 +- .../plot/events/PlayerClaimPlotEvent.java | 12 +- .../plot/events/PlayerPlotDeniedEvent.java | 3 +- .../plot/events/PlayerPlotHelperEvent.java | 3 +- .../plot/events/PlayerPlotTrustedEvent.java | 3 +- .../events/PlayerTeleportToPlotEvent.java | 15 +- .../plot/events/PlotClearEvent.java | 12 +- .../plot/events/PlotDeleteEvent.java | 12 +- .../plot/events/PlotFlagAddEvent.java | 12 +- .../plot/events/PlotFlagRemoveEvent.java | 12 +- .../plot/events/PlotMergeEvent.java | 12 +- .../plot/events/PlotUnlinkEvent.java | 12 +- .../plot/generator/DefaultPlotManager.java | 460 +++--------- .../plot/generator/DefaultPlotWorld.java | 76 +- .../plot/generator/WorldGenerator.java | 316 ++++----- .../plot/generator/XPopulator.java | 297 +++----- .../plot/listeners/PlayerEvents.java | 381 +++++----- .../plot/listeners/WorldEditListener.java | 58 +- .../plot/listeners/WorldGuardListener.java | 71 +- .../plot/uuid/NameFetcher.java | 11 +- .../plot/uuid/UUIDFetcher.java | 21 +- .../intellectualsites/web/IndexHandler.java | 35 +- .../com/intellectualsites/web/PlotWeb.java | 3 +- .../web/ResourceHandler.java | 25 +- .../src/com/intellectualsites/web/Test.java | 3 +- 90 files changed, 2880 insertions(+), 3807 deletions(-) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/AbstractFlag.java b/PlotSquared/src/com/intellectualcrafters/plot/AbstractFlag.java index 591c32f62..9b1c942b9 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/AbstractFlag.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/AbstractFlag.java @@ -18,8 +18,7 @@ public class AbstractFlag { */ public AbstractFlag(String key) { if (!StringUtils.isAlpha(key)) { - throw new IllegalArgumentException( - "Flag must be alphabetic characters"); + throw new IllegalArgumentException("Flag must be alphabetic characters"); } if (key.length() > 16) { throw new IllegalArgumentException("Key must be <= 16 characters"); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/C.java b/PlotSquared/src/com/intellectualcrafters/plot/C.java index ead9b513d..9d2c9115a 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/C.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/C.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = C.java - * >> Generated by: Citymonstret at 2014-08-09 01:43 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = C.java >> Generated by: Citymonstret at 2014-08-09 01:43 */ package com.intellectualcrafters.plot; @@ -15,271 +14,274 @@ import org.bukkit.ChatColor; * Captions class. * * @author Citymonstret - * */ public enum C { /* * Ratings */ - RATING_NOT_VALID("&cYou need to specify a number between 1 and 10"), RATING_ALREADY_EXISTS( - "&cYou have already rated plot &c%s"), RATING_APPLIED( - "&cYou successfully rated plot &6%s"), RATING_NOT_YOUR_OWN( - "&cYou cannot rate your own plot"), RATING_NOT_OWNED( - "&cYou cannot rate a plot that is not claimed by anyone"), + RATING_NOT_VALID("&cYou need to specify a number between 1 and 10"), + RATING_ALREADY_EXISTS("&cYou have already rated plot &c%s"), + RATING_APPLIED("&cYou successfully rated plot &6%s"), + RATING_NOT_YOUR_OWN("&cYou cannot rate your own plot"), + RATING_NOT_OWNED("&cYou cannot rate a plot that is not claimed by anyone"), /* * Economy Stuff */ - CANNOT_AFFORD_PLOT("&cYou cannot afford to buy this plot. It costs &6%s"), CANNOT_AFFORD_MERGE( - "&cYou cannot afford to merge the plots. It costs &6%s"), ADDED_BALANCE( - "&6%s &chas been added to your balance"), REMOVED_BALANCE( - "&6%s &chas been taken from your balance"), + CANNOT_AFFORD_PLOT("&cYou cannot afford to buy this plot. It costs &6%s"), + CANNOT_AFFORD_MERGE("&cYou cannot afford to merge the plots. It costs &6%s"), + ADDED_BALANCE("&6%s &chas been added to your balance"), + REMOVED_BALANCE("&6%s &chas been taken from your balance"), /* * Setup Stuff */ - SETUP_INIT("&6PlotSquared Setup -> Setup a new plotworld"), SETUP_STEP( - "&cStep &6%s&c: %s &c"), SETUP_INVALID_ARG( - "&c%s is not a valid argument for step %s. To cancel setup use: /plot setup cancel"), SETUP_VALID_ARG( - "&cValue &6%s &cset for step %s"), SETUP_FINISHED( - "&cFinished setup for world &c%s.\n&4If you are using MULTIVERSE or MULTIWORLD the world should have just been created. Otherwise you will need to add the world manually through the bukkit.yml"), SETUP_WORLD_TAKEN( - "&c%s is already a registered plotworld"), SETUP_MISSING_WORLD( - "&cYou need to specify a world name (&6/p setup &l{world}&6 {generator}&c)\n&6Additional commands:\n&c - &6/p setup \n&c - &6/p setup back\n&c - &6/p setup cancel"), SETUP_MISSING_GENERATOR( - "&cYou need to specify a generator (&6/p setup {world} &l{generator}&r&c)\n&6Additional commands:\n&c - &6/p setup \n&c - &6/p setup back\n&c - &6/p setup cancel"), SETUP_INVALID_GENERATOR( - "&cIncalid generator. Possible options: %generators%"), - /* - * Schematic Stuff - */ - SCHEMATIC_MISSING_ARG( - "&cYou need to specify an argument. Possible values: &6test {name}"), SCHEMATIC_INVALID( - "&cThat is not a valid schematic. Reason: &c%s"), SCHEMATIC_VALID( - "&cThat's a valid schematic"), SCHEMATIC_PASTE_FAILED( - "&cFailed to paste schematic"), SCHEMATIC_PASTE_SUCCESS( - "&cSchematic pasted successfully"), - /* - * Title Stuff - */ - TITLE_ENTERED_PLOT("You entered plot %s"), TITLE_ENTERED_PLOT_COLOR("GOLD"), TITLE_ENTERED_PLOT_SUB( - "Owned by %s"), TITLE_ENTERED_PLOT_SUB_COLOR("RED"), TITLE_LEFT_PLOT( - "You entered plot %s"), TITLE_LEFT_PLOT_COLOR("GOLD"), TITLE_LEFT_PLOT_SUB( - "Owned by %s"), TITLE_LEFT_PLOT_SUB_COLOR("RED"), - /* - * Core Stuff - */ - PREFIX("&c[&6&lPlot&c] "), ENABLED("&6Plots are now enabled"), EXAMPLE_MESSAGE( - "&cThis is an example message &k!!!"), - /* - * Reload - */ - RELOADED_CONFIGS("&6The translation files has been reloaded"), RELOAD_FAILED( - "&cFailed to reload the translations file"), - /* - * BarAPI - */ - BOSSBAR_CLEARING("&cClearing plot: &6%id%"), - /* - * Alias - */ - ALIAS_SET_TO("&cPlot alias set to &6%alias%"), MISSING_ALIAS( - "&cYou need to specify the alias"), ALIAS_IS_TAKEN( - "&cThat alias is already taken"), - /* - * Position - */ - MISSING_POSITION( - "&cYou need to specify a position. Possible values: &6default&c, &6center"), POSITION_SET( - "&cPlot home position set"), INVALID_POSITION( - "&cThat is not a valid position value"), - /* - * Time - */ - TIME_FORMAT("&6%hours%, %min%, %sec%"), - /* - * Permission - */ - NO_SCHEMATIC_PERMISSION( - "&cYou don't have the permission required to use schematic &6%s"), NO_PERMISSION( - "&cYou don't have the permissions required to use this command."), NO_PLOT_PERMS( - "&cYou don't have the permissions to do that in this plot"), CANT_CLAIM_MORE_PLOTS( - "&cYou can't claim more plots."), YOU_BE_DENIED( - "&cYou are not allowed to enter this plot"), + SETUP_INIT("&6PlotSquared Setup -> Setup a new plotworld"), + SETUP_STEP("&cStep &6%s&c: %s &c"), + SETUP_INVALID_ARG("&c%s is not a valid argument for step %s. To cancel setup use: /plot setup cancel"), + SETUP_VALID_ARG("&cValue &6%s &cset for step %s"), + SETUP_FINISHED("&cFinished setup for world &c%s.\n&4If you are using MULTIVERSE or MULTIWORLD the world should have just been created. Otherwise you will need to add the world manually through the bukkit.yml"), + SETUP_WORLD_TAKEN("&c%s is already a registered plotworld"), + SETUP_MISSING_WORLD("&cYou need to specify a world name (&6/p setup &l{world}&6 {generator}&c)\n&6Additional commands:\n&c - &6/p setup \n&c - &6/p setup back\n&c - &6/p setup cancel"), + SETUP_MISSING_GENERATOR("&cYou need to specify a generator (&6/p setup {world} &l{generator}&r&c)\n&6Additional commands:\n&c - &6/p setup \n&c - &6/p setup back\n&c - &6/p setup cancel"), + SETUP_INVALID_GENERATOR("&cIncalid generator. Possible options: %s"), + /* + * Schematic Stuff + */ + SCHEMATIC_MISSING_ARG("&cYou need to specify an argument. Possible values: &6test {name}"), + SCHEMATIC_INVALID("&cThat is not a valid schematic. Reason: &c%s"), + SCHEMATIC_VALID("&cThat's a valid schematic"), + SCHEMATIC_PASTE_FAILED("&cFailed to paste schematic"), + SCHEMATIC_PASTE_SUCCESS("&cSchematic pasted successfully"), + /* + * Title Stuff + */ + TITLE_ENTERED_PLOT("You entered plot %s"), + TITLE_ENTERED_PLOT_COLOR("GOLD"), + TITLE_ENTERED_PLOT_SUB("Owned by %s"), + TITLE_ENTERED_PLOT_SUB_COLOR("RED"), + TITLE_LEFT_PLOT("You entered plot %s"), + TITLE_LEFT_PLOT_COLOR("GOLD"), + TITLE_LEFT_PLOT_SUB("Owned by %s"), + TITLE_LEFT_PLOT_SUB_COLOR("RED"), + /* + * Core Stuff + */ + PREFIX("&c[&6&lPlot&c] "), + ENABLED("&6Plots are now enabled"), + EXAMPLE_MESSAGE("&cThis is an example message &k!!!"), + /* + * Reload + */ + RELOADED_CONFIGS("&6The translation files has been reloaded"), + RELOAD_FAILED("&cFailed to reload the translations file"), + /* + * BarAPI + */ + BOSSBAR_CLEARING("&cClearing plot: &6%id%"), + /* + * Alias + */ + ALIAS_SET_TO("&cPlot alias set to &6%alias%"), + MISSING_ALIAS("&cYou need to specify the alias"), + ALIAS_IS_TAKEN("&cThat alias is already taken"), + /* + * Position + */ + MISSING_POSITION("&cYou need to specify a position. Possible values: &6default&c, &6center"), + POSITION_SET("&cPlot home position set"), + INVALID_POSITION("&cThat is not a valid position value"), + /* + * Time + */ + TIME_FORMAT("&6%hours%, %min%, %sec%"), + /* + * Permission + */ + NO_SCHEMATIC_PERMISSION("&cYou don't have the permission required to use schematic &6%s"), + NO_PERMISSION("&cYou don't have the permissions required to use this command."), + NO_PLOT_PERMS("&cYou don't have the permissions to do that in this plot"), + CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."), + YOU_BE_DENIED("&cYou are not allowed to enter this plot"), - NO_PERM_MERGE("&cYou are not the owner of the plot: &6%plot%"), UNLINK_REQUIRED( - "&cAn unlink is required to do this."), UNLINK_IMPOSSIBLE( - "&cYou can only unlink a mega-plot"), NO_MERGE_TO_MEGA( - "&cMega plots cannot be merged into. Please merge from the desired mega plot."), - /* - * Commands - */ - NOT_VALID_SUBCOMMAND("&cThat is not a valid subcommand."), NO_COMMANDS( - "&cI'm sorry, but you're not permitted to use any subcommands."), SUBCOMMAND_SET_OPTIONS_HEADER( - "&cPossible Values: "), - /* - * Player not found - */ - INVALID_PLAYER("&cPlayer not found: &6%player%."), - /* + NO_PERM_MERGE("&cYou are not the owner of the plot: &6%plot%"), + UNLINK_REQUIRED("&cAn unlink is required to do this."), + UNLINK_IMPOSSIBLE("&cYou can only unlink a mega-plot"), + NO_MERGE_TO_MEGA("&cMega plots cannot be merged into. Please merge from the desired mega plot."), + /* + * Commands + */ + NOT_VALID_SUBCOMMAND("&cThat is not a valid subcommand."), + NO_COMMANDS("&cI'm sorry, but you're not permitted to use any subcommands."), + SUBCOMMAND_SET_OPTIONS_HEADER("&cPossible Values: "), + /* + * Player not found + */ + INVALID_PLAYER("&cPlayer not found: &6%player%."), + /* * */ - COMMAND_WENT_WRONG("&cSomething went wrong when executing that command..."), - /* - * No {plot} - */ - NOT_IN_PLOT("&cYou're not in a plot"), NOT_IN_PLOT_WORLD( - "&cYou're not in a plot world"), NOT_VALID_WORLD( - "&cThat is not a valid world (case sensitive)"), NOT_VALID_PLOT_WORLD( - "&cThat is not a valid plot world (case sensitive)"), NO_PLOTS( - "&cYou don't have any plots"), - /* - * Block List - */ - NOT_VALID_BLOCK_LIST_HEADER( - "&cThat's not a valid block. Valid blocks are:\\n"), BLOCK_LIST_ITEM( - " &6%mat%&c,"), BLOCK_LIST_SEPARATER("&6,&c "), - /* - * Biome - */ - NEED_BIOME("&cYou've got to specify a biome"), BIOME_SET_TO( - "&cPlot biome set to &c"), - /* - * Teleport / Entry - */ - TELEPORTED_TO_PLOT("&6You have been teleported"), - /* - * Set Block - */ - SET_BLOCK_ACTION_FINISHED("&6The last setblock action is now finished."), - /* - * Debug - */ - DEUBG_HEADER("&6Debug Information\\n"), DEBUG_SECTION("&c>> &6&l%val%"), DEBUG_LINE( - "&c>> &6%var%&c:&6 %val%\\n"), - /* - * Invalid - */ - NOT_VALID_DATA("&cThat's not a valid data id."), NOT_VALID_BLOCK( - "&cThat's not a valid block."), NOT_VALID_NUMBER( - "&cThat's not a valid number"), NOT_VALID_PLOT_ID( - "&cThat's not a valid plot id."), NOT_YOUR_PLOT( - "&cThat is not your plot."), NO_SUCH_PLOT("&cThere is no such plot"), PLAYER_HAS_NOT_BEEN_ON( - "&cThat player hasn't been in the plotworld"), FOUND_NO_PLOTS( - "&cFound no plots with your search query"), - /* - * Camera - */ - CAMERA_STARTED("&cYou have entered camera mode for plot &6%s"), CAMERA_STOPPED( - "&cYou are no longer in camera mode"), - /* - * Need - */ - NEED_PLOT_NUMBER("&cYou've got to specify a plot number or alias"), NEED_BLOCK( - "&cYou've got to specify a block"), NEED_PLOT_ID( - "&cYou've got to specify a plot id."), NEED_USER( - "&cYou need to specify a username"), - /* - * Info - */ - PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"), PLOT_INFO( - "plot ID: &6%id%&c, plot Alias: &6%alias%&c, plot Owner: &6%owner%&c, plot Biome: &6%biome%&c, plot Time: &6%time%&c, plot Weather: &6%weather%&c, plot Helpers:&6%helpers%&c, plot Trusted:&6%trusted%&c, plot Denied:&6%denied%&c, plot Rating: &6%rating%, &cplot flags: &6%flags%"), PLOT_USER_LIST( - " &6%user%&c,"), - /* - * Generating - */ - GENERATING_FLOOR( - "&6Started generating floor from your settings. It will take %time%"), GENERATING_WALL( - "&6Started generating wall from your settings"), GENERATING_WALL_FILLING( - "&cStarted generating wall filling from your settings."), - /* - * Clearing - */ - CLEARING_PLOT("&cClearing plot."), CLEARING_DONE( - "&6Done, took &a%time%&6 ms!"), CLEARING_DONE_PACKETS( - "&6(&a%time% &6ms for packets)"), - /* - * Claiming - */ - PLOT_NOT_CLAIMED("&cCannot claim plot"), PLOT_IS_CLAIMED( - "&cThis plot is already claimed"), CLAIMED( - "&6You successfully claimed the plot"), - /* - * List - */ - PLOT_LIST_HEADER("&6List of %word% plots"), PLOT_LIST_ITEM( - "&c>> &6%id% &c- &6%owner%"), PLOT_LIST_FOOTER( - "&c>> &6%word% a total of &c%num% &6claimed %plot%."), - /* - * Left - */ - LEFT_PLOT("&cYou left a plot"), - /* - * Wait - */ - WAIT_FOR_TIMER( - "&cA setblock timer is bound to either the current plot or you. Please wait for it to finish"), - /* - * Chat - */ - PLOT_CHAT_FORMAT("&c[&6Plot Chat&c][&6%plot_id%&c] &6%sender%&c: &6%msg%"), - /* - * Denied - */ - DENIED_REMOVED("&cYou successfully undenied the player from this plot"), DENIED_ADDED( - "&cYou successfully denied the player from this plot"), DENIED_NEED_ARGUMENT( - "&cArguments are missing. &6/plot denied add {name} &cor &6/plot helpers remove {name}"), WAS_NOT_DENIED( - "&cThat player was not denied on this plot"), - /* - * Rain - */ - NEED_ON_OFF("&cYou need to specify a value. Possible values: &6on&c, &6off"), SETTING_UPDATED( - "&cYou successfully updated the setting"), - /* - * Flag - */ - NEED_KEY("&cPossible values: &6%values%"), NOT_VALID_FLAG( - "&cThat is not a valid flag"), NOT_VALID_VALUE( - "&cFlag values must be alphanumerical"), FLAG_NOT_IN_PLOT( - "&cThe plot does not have that flag"), FLAG_NOT_REMOVED( - "&cThe flag could not be removed"), FLAG_NOT_ADDED( - "&cThe flag could not be added"), FLAG_REMOVED( - "&6Successfully removed flag"), FLAG_ADDED( - "&6Successfully added flag"), - /* - * Helper - */ - HELPER_ADDED("&6You successfully added a helper to the plot"), HELPER_REMOVED( - "&6You successfully removed a helper from the plot"), HELPER_NEED_ARGUMENT( - "&cArguments are missing. &6/plot helpers add {name} &cor &6/plot helpers remove {name}"), WAS_NOT_ADDED( - "&cThat player was not added as a helper on this plot"), - /* - * Trusted - */ - TRUSTED_ADDED("&6You successfully added a trusted user to the plot"), TRUSTED_REMOVED( - "&6You successfully removed a trusted user from the plot"), TRUSTED_NEED_ARGUMENT( - "&cArguments are missing. &6/plot trusted add {name} &cor &6/plot trusted remove {name}"), T_WAS_NOT_ADDED( - "&cThat player was not added as a trusted user on this plot"), - /* - * Set Owner - */ - SET_OWNER("&6You successfully set the plot owner"), - /* - * Signs - */ - OWNER_SIGN_LINE_1("&cID: &6%id%"), OWNER_SIGN_LINE_2("&cOwner:"), OWNER_SIGN_LINE_3( - "&6%plr%"), OWNER_SIGN_LINE_4("&2Claimed"), - /* - * Help - */ - HELP_CATEGORY("&6Current Category&c: &l%category%"), HELP_INFO( - "&6You need to specify a help category"), HELP_INFO_ITEM( - "&6/plots help %category% &c- &6%category_desc%"), HELP_PAGE( - "&c>> &6%usage% &c[&6%alias%&c] &c- &6%desc%"), HELP_HEADER( - "&6Help for Plots"), - /* - * Direction - */ - DIRECTION("&6Current direction: %dir%"), - /* - * Custom - */ - CUSTOM_STRING("-"); + COMMAND_WENT_WRONG("&cSomething went wrong when executing that command..."), + /* + * No {plot} + */ + NOT_IN_PLOT("&cYou're not in a plot"), + NOT_IN_PLOT_WORLD("&cYou're not in a plot world"), + NOT_VALID_WORLD("&cThat is not a valid world (case sensitive)"), + NOT_VALID_PLOT_WORLD("&cThat is not a valid plot world (case sensitive)"), + NO_PLOTS("&cYou don't have any plots"), + /* + * Block List + */ + NOT_VALID_BLOCK_LIST_HEADER("&cThat's not a valid block. Valid blocks are:\\n"), + BLOCK_LIST_ITEM(" &6%mat%&c,"), + BLOCK_LIST_SEPARATER("&6,&c "), + /* + * Biome + */ + NEED_BIOME("&cYou've got to specify a biome"), + BIOME_SET_TO("&cPlot biome set to &c"), + /* + * Teleport / Entry + */ + TELEPORTED_TO_PLOT("&6You have been teleported"), + /* + * Set Block + */ + SET_BLOCK_ACTION_FINISHED("&6The last setblock action is now finished."), + /* + * Debug + */ + DEUBG_HEADER("&6Debug Information\\n"), + DEBUG_SECTION("&c>> &6&l%val%"), + DEBUG_LINE("&c>> &6%var%&c:&6 %val%\\n"), + /* + * Invalid + */ + NOT_VALID_DATA("&cThat's not a valid data id."), + NOT_VALID_BLOCK("&cThat's not a valid block."), + NOT_VALID_NUMBER("&cThat's not a valid number"), + NOT_VALID_PLOT_ID("&cThat's not a valid plot id."), + NOT_YOUR_PLOT("&cThat is not your plot."), + NO_SUCH_PLOT("&cThere is no such plot"), + PLAYER_HAS_NOT_BEEN_ON("&cThat player hasn't been in the plotworld"), + FOUND_NO_PLOTS("&cFound no plots with your search query"), + /* + * Camera + */ + CAMERA_STARTED("&cYou have entered camera mode for plot &6%s"), + CAMERA_STOPPED("&cYou are no longer in camera mode"), + /* + * Need + */ + NEED_PLOT_NUMBER("&cYou've got to specify a plot number or alias"), + NEED_BLOCK("&cYou've got to specify a block"), + NEED_PLOT_ID("&cYou've got to specify a plot id."), + NEED_USER("&cYou need to specify a username"), + /* + * Info + */ + PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"), + PLOT_INFO("plot ID: &6%id%&c, plot Alias: &6%alias%&c, plot Owner: &6%owner%&c, plot Biome: &6%biome%&c, plot Time: &6%time%&c, plot Weather: &6%weather%&c, plot Helpers:&6%helpers%&c, plot Trusted:&6%trusted%&c, plot Denied:&6%denied%&c, plot Rating: &6%rating%, &cplot flags: &6%flags%"), + PLOT_USER_LIST(" &6%user%&c,"), + /* + * Generating + */ + GENERATING_FLOOR("&6Started generating floor from your settings. It will take %time%"), + GENERATING_WALL("&6Started generating wall from your settings"), + GENERATING_WALL_FILLING("&cStarted generating wall filling from your settings."), + /* + * Clearing + */ + CLEARING_PLOT("&cClearing plot."), + CLEARING_DONE("&6Done, took &a%time%&6 ms!"), + CLEARING_DONE_PACKETS("&6(&a%time% &6ms for packets)"), + /* + * Claiming + */ + PLOT_NOT_CLAIMED("&cCannot claim plot"), + PLOT_IS_CLAIMED("&cThis plot is already claimed"), + CLAIMED("&6You successfully claimed the plot"), + /* + * List + */ + PLOT_LIST_HEADER("&6List of %word% plots"), + PLOT_LIST_ITEM("&c>> &6%id% &c- &6%owner%"), + PLOT_LIST_FOOTER("&c>> &6%word% a total of &c%num% &6claimed %plot%."), + /* + * Left + */ + LEFT_PLOT("&cYou left a plot"), + /* + * Wait + */ + WAIT_FOR_TIMER("&cA setblock timer is bound to either the current plot or you. Please wait for it to finish"), + /* + * Chat + */ + PLOT_CHAT_FORMAT("&c[&6Plot Chat&c][&6%plot_id%&c] &6%sender%&c: &6%msg%"), + /* + * Denied + */ + DENIED_REMOVED("&cYou successfully undenied the player from this plot"), + DENIED_ADDED("&cYou successfully denied the player from this plot"), + DENIED_NEED_ARGUMENT("&cArguments are missing. &6/plot denied add {name} &cor &6/plot helpers remove {name}"), + WAS_NOT_DENIED("&cThat player was not denied on this plot"), + /* + * Rain + */ + NEED_ON_OFF("&cYou need to specify a value. Possible values: &6on&c, &6off"), + SETTING_UPDATED("&cYou successfully updated the setting"), + /* + * Flag + */ + NEED_KEY("&cPossible values: &6%values%"), + NOT_VALID_FLAG("&cThat is not a valid flag"), + NOT_VALID_VALUE("&cFlag values must be alphanumerical"), + FLAG_NOT_IN_PLOT("&cThe plot does not have that flag"), + FLAG_NOT_REMOVED("&cThe flag could not be removed"), + FLAG_NOT_ADDED("&cThe flag could not be added"), + FLAG_REMOVED("&6Successfully removed flag"), + FLAG_ADDED("&6Successfully added flag"), + /* + * Helper + */ + HELPER_ADDED("&6You successfully added a helper to the plot"), + HELPER_REMOVED("&6You successfully removed a helper from the plot"), + HELPER_NEED_ARGUMENT("&cArguments are missing. &6/plot helpers add {name} &cor &6/plot helpers remove {name}"), + WAS_NOT_ADDED("&cThat player was not added as a helper on this plot"), + /* + * Trusted + */ + TRUSTED_ADDED("&6You successfully added a trusted user to the plot"), + TRUSTED_REMOVED("&6You successfully removed a trusted user from the plot"), + TRUSTED_NEED_ARGUMENT("&cArguments are missing. &6/plot trusted add {name} &cor &6/plot trusted remove {name}"), + T_WAS_NOT_ADDED("&cThat player was not added as a trusted user on this plot"), + /* + * Set Owner + */ + SET_OWNER("&6You successfully set the plot owner"), + /* + * Signs + */ + OWNER_SIGN_LINE_1("&cID: &6%id%"), + OWNER_SIGN_LINE_2("&cOwner:"), + OWNER_SIGN_LINE_3("&6%plr%"), + OWNER_SIGN_LINE_4("&2Claimed"), + /* + * Help + */ + HELP_CATEGORY("&6Current Category&c: &l%category%"), + HELP_INFO("&6You need to specify a help category"), + HELP_INFO_ITEM("&6/plots help %category% &c- &6%category_desc%"), + HELP_PAGE("&c>> &6%usage% &c[&6%alias%&c] &c- &6%desc%"), + HELP_HEADER("&6Help for Plots"), + /* + * Direction + */ + DIRECTION("&6Current direction: %dir%"), + /* + * Custom + */ + CUSTOM_STRING("-"); /** * Default */ @@ -309,7 +311,8 @@ public enum C { this.d = d; if (PlotMain.translations == null) { this.s = d; - } else { + } + else { this.s = PlotMain.translations.getString(this.toString()); } if (this.s == null) { @@ -340,7 +343,6 @@ public enum C { } /** - * * @return translated and color decoded */ public String translated() { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Configuration.java b/PlotSquared/src/com/intellectualcrafters/plot/Configuration.java index aaa88cfc6..2bbb26e7a 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Configuration.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Configuration.java @@ -36,7 +36,8 @@ public class Configuration { try { Integer.parseInt(string); return true; - } catch (Exception e) { + } + catch (Exception e) { return false; } } @@ -53,7 +54,8 @@ public class Configuration { try { Boolean.parseBoolean(string); return true; - } catch (Exception e) { + } + catch (Exception e) { return false; } } @@ -70,7 +72,8 @@ public class Configuration { try { Double.parseDouble(string); return true; - } catch (Exception e) { + } + catch (Exception e) { return false; } } @@ -87,17 +90,18 @@ public class Configuration { try { Biome.valueOf(string.toUpperCase()); return true; - } catch (Exception e) { + } + catch (Exception e) { return false; } } @Override public Object parseString(String string) { - for (Biome biome:Biome.values()) { - if (biome.name().equals(string.toUpperCase())) { - return biome; - } + for (Biome biome : Biome.values()) { + if (biome.name().equals(string.toUpperCase())) { + return biome; + } } return Biome.FOREST; } @@ -116,11 +120,13 @@ public class Configuration { String[] split = string.split(":"); Short.parseShort(split[0]); Short.parseShort(split[1]); - } else { + } + else { Short.parseShort(string); } return true; - } catch (Exception e) { + } + catch (Exception e) { return false; } } @@ -129,9 +135,9 @@ public class Configuration { public Object parseString(String string) { if (string.contains(":")) { String[] split = string.split(":"); - return new PlotBlock(Short.parseShort(split[0]), - Byte.parseByte(split[1])); - } else { + return new PlotBlock(Short.parseShort(split[0]), Byte.parseByte(split[1])); + } + else { return new PlotBlock(Short.parseShort(string), (byte) 0); } } @@ -151,12 +157,14 @@ public class Configuration { String[] split = block.split(":"); Short.parseShort(split[0]); Short.parseShort(split[1]); - } else { + } + else { Short.parseShort(block); } } return true; - } catch (Exception e) { + } + catch (Exception e) { return false; } } @@ -166,13 +174,12 @@ public class Configuration { String[] blocks = string.split(","); PlotBlock[] values = new PlotBlock[blocks.length]; for (int i = 0; i < blocks.length; i++) { - if (string.contains(":")) { - String[] split = string.split(":"); - values[i] = new PlotBlock(Short.parseShort(split[0]), - Byte.parseByte(split[1])); - } else { - values[i] = new PlotBlock(Short.parseShort(string), - (byte) 0); + if (blocks[i].contains(":")) { + String[] split = blocks[i].split(":"); + values[i] = new PlotBlock(Short.parseShort(split[0]), Byte.parseByte(split[1])); + } + else { + values[i] = new PlotBlock(Short.parseShort(blocks[i]), (byte) 0); } } return values; @@ -189,10 +196,8 @@ public class Configuration { }; /** - * * Create your own SettingValue object to make the management of plotworld * configuration easier - * */ public static abstract class SettingValue { private String type; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/ConfigurationNode.java b/PlotSquared/src/com/intellectualcrafters/plot/ConfigurationNode.java index f84d80ff0..f69e15cf0 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/ConfigurationNode.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/ConfigurationNode.java @@ -13,8 +13,8 @@ public class ConfigurationNode { private Object value; private SettingValue type; - public ConfigurationNode(String constant, Object default_value, - String description, SettingValue type, boolean required) { + public ConfigurationNode(String constant, Object default_value, String description, SettingValue type, + boolean required) { this.constant = constant; this.default_value = default_value; this.description = description; @@ -33,7 +33,8 @@ public class ConfigurationNode { return false; } return true; - } catch (Exception e) { + } + catch (Exception e) { return false; } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/ConsoleColors.java b/PlotSquared/src/com/intellectualcrafters/plot/ConsoleColors.java index a14759fc1..b256b58bb 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/ConsoleColors.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/ConsoleColors.java @@ -8,10 +8,18 @@ import org.bukkit.ChatColor; public class ConsoleColors { static enum ConsoleColor { - RESET("\u001B[0m"), BLACK("\u001B[30m"), RED("\u001B[31m"), GREEN( - "\u001B[32m"), YELLOW("\u001B[33m"), BLUE("\u001B[34m"), PURPLE( - "\u001B[35m"), CYAN("\u001B[36m"), WHITE("\u001B[37m"), BOLD( - "\033[1m"), UNDERLINE("\033[0m"), ITALIC("\033[3m"); + RESET("\u001B[0m"), + BLACK("\u001B[30m"), + RED("\u001B[31m"), + GREEN("\u001B[32m"), + YELLOW("\u001B[33m"), + BLUE("\u001B[34m"), + PURPLE("\u001B[35m"), + CYAN("\u001B[36m"), + WHITE("\u001B[37m"), + BOLD("\033[1m"), + UNDERLINE("\033[0m"), + ITALIC("\033[3m"); private String win; private String lin; @@ -44,28 +52,8 @@ public class ConsoleColors { */ public static String fromString(String input) { - input = input.replaceAll("&0", fromChatColor(ChatColor.BLACK)) - .replaceAll("&1", fromChatColor(ChatColor.DARK_BLUE)) - .replaceAll("&2", fromChatColor(ChatColor.DARK_GREEN)) - .replaceAll("&3", fromChatColor(ChatColor.DARK_AQUA)) - .replaceAll("&4", fromChatColor(ChatColor.DARK_RED)) - .replaceAll("&5", fromChatColor(ChatColor.DARK_PURPLE)) - .replaceAll("&6", fromChatColor(ChatColor.GOLD)) - .replaceAll("&7", fromChatColor(ChatColor.GRAY)) - .replaceAll("&8", fromChatColor(ChatColor.DARK_GRAY)) - .replaceAll("&9", fromChatColor(ChatColor.BLUE)) - .replaceAll("&a", fromChatColor(ChatColor.GREEN)) - .replaceAll("&b", fromChatColor(ChatColor.AQUA)) - .replaceAll("&c", fromChatColor(ChatColor.RED)) - .replaceAll("&d", fromChatColor(ChatColor.LIGHT_PURPLE)) - .replaceAll("&e", fromChatColor(ChatColor.YELLOW)) - .replaceAll("&f", fromChatColor(ChatColor.WHITE)) - .replaceAll("&k", fromChatColor(ChatColor.MAGIC)) - .replaceAll("&l", fromChatColor(ChatColor.BOLD)) - .replaceAll("&m", fromChatColor(ChatColor.STRIKETHROUGH)) - .replaceAll("&n", fromChatColor(ChatColor.UNDERLINE)) - .replaceAll("&o", fromChatColor(ChatColor.ITALIC)) - .replaceAll("&r", fromChatColor(ChatColor.RESET)); + input = + input.replaceAll("&0", fromChatColor(ChatColor.BLACK)).replaceAll("&1", fromChatColor(ChatColor.DARK_BLUE)).replaceAll("&2", fromChatColor(ChatColor.DARK_GREEN)).replaceAll("&3", fromChatColor(ChatColor.DARK_AQUA)).replaceAll("&4", fromChatColor(ChatColor.DARK_RED)).replaceAll("&5", fromChatColor(ChatColor.DARK_PURPLE)).replaceAll("&6", fromChatColor(ChatColor.GOLD)).replaceAll("&7", fromChatColor(ChatColor.GRAY)).replaceAll("&8", fromChatColor(ChatColor.DARK_GRAY)).replaceAll("&9", fromChatColor(ChatColor.BLUE)).replaceAll("&a", fromChatColor(ChatColor.GREEN)).replaceAll("&b", fromChatColor(ChatColor.AQUA)).replaceAll("&c", fromChatColor(ChatColor.RED)).replaceAll("&d", fromChatColor(ChatColor.LIGHT_PURPLE)).replaceAll("&e", fromChatColor(ChatColor.YELLOW)).replaceAll("&f", fromChatColor(ChatColor.WHITE)).replaceAll("&k", fromChatColor(ChatColor.MAGIC)).replaceAll("&l", fromChatColor(ChatColor.BOLD)).replaceAll("&m", fromChatColor(ChatColor.STRIKETHROUGH)).replaceAll("&n", fromChatColor(ChatColor.UNDERLINE)).replaceAll("&o", fromChatColor(ChatColor.ITALIC)).replaceAll("&r", fromChatColor(ChatColor.RESET)); return input + "\u001B[0m"; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Flag.java b/PlotSquared/src/com/intellectualcrafters/plot/Flag.java index 3aaf23b84..b153d0387 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Flag.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Flag.java @@ -78,8 +78,7 @@ public class Flag { return false; } Flag other = (Flag) obj; - return (this.key.getKey().equals(other.key.getKey()) && this.value - .equals(other.value)); + return (this.key.getKey().equals(other.key.getKey()) && this.value.equals(other.value)); } @Override diff --git a/PlotSquared/src/com/intellectualcrafters/plot/FlagManager.java b/PlotSquared/src/com/intellectualcrafters/plot/FlagManager.java index f38715ca6..d50deabd1 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/FlagManager.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/FlagManager.java @@ -85,7 +85,8 @@ public class FlagManager { String[] split = flagstrings.get(i).split(";"); if (split.length == 1) { flags[i] = new Flag(getFlag(split[0], true), ""); - } else { + } + else { flags[i] = new Flag(getFlag(split[0], true), split[1]); } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/LSetCube.java b/PlotSquared/src/com/intellectualcrafters/plot/LSetCube.java index 9733792a6..bb560fa5e 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/LSetCube.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/LSetCube.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = LSetCube.java - * >> Generated by: Citymonstret at 2014-08-09 01:43 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = LSetCube.java >> Generated by: Citymonstret at 2014-08-09 01:43 */ package com.intellectualcrafters.plot; @@ -15,7 +14,6 @@ import org.bukkit.Location; * Cube utilities * * @author Citymonstret - * */ public class LSetCube { @@ -97,7 +95,6 @@ public class LSetCube { private Location current; /** - * * @param cube */ public LCycler(LSetCube cube) { @@ -107,7 +104,6 @@ public class LSetCube { } /** - * * @return */ public boolean hasNext() { @@ -117,7 +113,6 @@ public class LSetCube { } /** - * * @return */ public Location getNext() { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Lag.java b/PlotSquared/src/com/intellectualcrafters/plot/Lag.java index cc5679d4a..c84e10b28 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Lag.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Lag.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Lag.java - * >> Generated by: Citymonstret at 2014-08-09 01:43 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Lag.java >> Generated by: Citymonstret at 2014-08-09 01:43 */ package com.intellectualcrafters.plot; @@ -13,7 +12,6 @@ package com.intellectualcrafters.plot; * TPS and Lag Checker. * * @author Citymonstret - * */ public class Lag implements Runnable { @@ -37,8 +35,7 @@ public class Lag implements Runnable { * @return server tick per second */ public static double getTPS() { - return Math.round(getTPS(100)) > 20.0D ? 20.0D : Math - .round(getTPS(100)); + return Math.round(getTPS(100)) > 20.0D ? 20.0D : Math.round(getTPS(100)); } /** diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Logger.java b/PlotSquared/src/com/intellectualcrafters/plot/Logger.java index f79155ef9..67c7b0872 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Logger.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Logger.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Logger.java - * >> Generated by: Citymonstret at 2014-08-09 01:43 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Logger.java >> Generated by: Citymonstret at 2014-08-09 01:43 */ package com.intellectualcrafters.plot; @@ -21,7 +20,6 @@ import java.util.Date; * Logging of errors and debug messages. * * @author Citymonstret - * */ public class Logger { @@ -38,14 +36,16 @@ public class Logger { entries.add(line); } reader.close(); - } catch (IOException e) { - PlotMain.sendConsoleSenderMessage(C.PREFIX.s() - + "File setup error Logger#setup"); + } + catch (IOException e) { + PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "File setup error Logger#setup"); } } public enum LogLevel { - GENERAL("General"), WARNING("Warning"), DANGER("Danger"); + GENERAL("General"), + WARNING("Warning"), + DANGER("Danger"); private String name; LogLevel(String name) { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Metrics.java b/PlotSquared/src/com/intellectualcrafters/plot/Metrics.java index 568313fe1..af3fda2cd 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Metrics.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Metrics.java @@ -2,30 +2,31 @@ package com.intellectualcrafters.plot; /* * Copyright 2011-2013 Tyler Blair. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and contributors and should not be interpreted as representing official policies, - * either expressed or implied, of anybody else. + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are + * those of the authors and contributors and should not be interpreted as + * representing official policies, either expressed or implied, of anybody else. */ import java.io.BufferedReader; @@ -79,8 +80,7 @@ public class Metrics { /** * All of the custom graphs to submit to metrics */ - private final Set graphs = Collections - .synchronizedSet(new HashSet()); + private final Set graphs = Collections.synchronizedSet(new HashSet()); /** * The plugin configuration file */ @@ -113,16 +113,14 @@ public class Metrics { this.plugin = plugin; // load the config this.configurationFile = getConfigFile(); - this.configuration = YamlConfiguration - .loadConfiguration(this.configurationFile); + this.configuration = YamlConfiguration.loadConfiguration(this.configurationFile); // add some defaults this.configuration.addDefault("opt-out", false); this.configuration.addDefault("guid", UUID.randomUUID().toString()); this.configuration.addDefault("debug", false); // Do we need to create the file? if (this.configuration.get("guid", null) == null) { - this.configuration.options().header("http://mcstats.org") - .copyDefaults(true); + this.configuration.options().header("http://mcstats.org").copyDefaults(true); this.configuration.save(this.configurationFile); } // Load the guid then @@ -185,52 +183,50 @@ public class Metrics { return true; } // Begin hitting the server with glorious data - this.task = this.plugin.getServer().getScheduler() - .runTaskTimerAsynchronously(this.plugin, new Runnable() { - private boolean firstPost = true; + this.task = this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, new Runnable() { + private boolean firstPost = true; - @Override - public void run() { - try { - // This has to be synchronized or it can collide - // with - // the disable method. - synchronized (Metrics.this.optOutLock) { - // Disable Task, if it is running and the - // server - // owner decided to opt-out - if (isOptOut() - && (Metrics.this.task != null)) { - Metrics.this.task.cancel(); - Metrics.this.task = null; - // Tell all plotters to stop gathering - // information. - for (Graph graph : Metrics.this.graphs) { - graph.onOptOut(); - } - } - } - // We use the inverse of firstPost because if it - // is the - // first time we are posting, - // it is not a interval ping, so it evaluates to - // FALSE - // Each time thereafter it will evaluate to - // TRUE, i.e - // PING! - postPlugin(!this.firstPost); - // After the first post we set firstPost to - // false - // Each post thereafter will be a ping - this.firstPost = false; - } catch (IOException e) { - if (Metrics.this.debug) { - Bukkit.getLogger().log(Level.INFO, - "[Metrics] " + e.getMessage()); + @Override + public void run() { + try { + // This has to be synchronized or it can collide + // with + // the disable method. + synchronized (Metrics.this.optOutLock) { + // Disable Task, if it is running and the + // server + // owner decided to opt-out + if (isOptOut() && (Metrics.this.task != null)) { + Metrics.this.task.cancel(); + Metrics.this.task = null; + // Tell all plotters to stop gathering + // information. + for (Graph graph : Metrics.this.graphs) { + graph.onOptOut(); } } } - }, 0, PING_INTERVAL * 1200); + // We use the inverse of firstPost because if it + // is the + // first time we are posting, + // it is not a interval ping, so it evaluates to + // FALSE + // Each time thereafter it will evaluate to + // TRUE, i.e + // PING! + postPlugin(!this.firstPost); + // After the first post we set firstPost to + // false + // Each post thereafter will be a ping + this.firstPost = false; + } + catch (IOException e) { + if (Metrics.this.debug) { + Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage()); + } + } + } + }, 0, PING_INTERVAL * 1200); return true; } } @@ -245,16 +241,16 @@ public class Metrics { try { // Reload the metrics file this.configuration.load(getConfigFile()); - } catch (IOException ex) { + } + catch (IOException ex) { if (this.debug) { - Bukkit.getLogger().log(Level.INFO, - "[Metrics] " + ex.getMessage()); + Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); } return true; - } catch (InvalidConfigurationException ex) { + } + catch (InvalidConfigurationException ex) { if (this.debug) { - Bukkit.getLogger().log(Level.INFO, - "[Metrics] " + ex.getMessage()); + Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); } return true; } @@ -335,10 +331,10 @@ public class Metrics { PluginDescriptionFile description = this.plugin.getDescription(); String pluginName = description.getName(); boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if - // online - // mode - // is - // enabled + // online + // mode + // is + // enabled String pluginVersion = description.getVersion(); String serverVersion = Bukkit.getVersion(); int playersOnline = Bukkit.getServer().getOnlinePlayers().length; @@ -388,8 +384,7 @@ public class Metrics { StringBuilder graphJson = new StringBuilder(); graphJson.append('{'); for (Plotter plotter : graph.getPlotters()) { - appendJSONPair(graphJson, plotter.getColumnName(), - Integer.toString(plotter.getValue())); + appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue())); } graphJson.append('}'); if (!firstGraph) { @@ -406,15 +401,15 @@ public class Metrics { // close json json.append('}'); // Create the url - URL url = new URL(BASE_URL - + String.format(REPORT_URL, urlEncode(pluginName))); + URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName))); // Connect to the website URLConnection connection; // Mineshafter creates a socks proxy, so we can safely bypass it // It does not reroute POST requests so we need to go around it if (isMineshafterPresent()) { connection = url.openConnection(Proxy.NO_PROXY); - } else { + } + else { connection = url.openConnection(); } byte[] uncompressed = json.toString().getBytes(); @@ -423,40 +418,37 @@ public class Metrics { connection.addRequestProperty("User-Agent", "MCStats/" + REVISION); connection.addRequestProperty("Content-Type", "application/json"); connection.addRequestProperty("Content-Encoding", "gzip"); - connection.addRequestProperty("Content-Length", - Integer.toString(compressed.length)); + connection.addRequestProperty("Content-Length", Integer.toString(compressed.length)); connection.addRequestProperty("Accept", "application/json"); connection.addRequestProperty("Connection", "close"); connection.setDoOutput(true); if (this.debug) { - System.out.println("[Metrics] Prepared request for " + pluginName - + " uncompressed=" + uncompressed.length + " compressed=" - + compressed.length); + System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + + " compressed=" + compressed.length); } // Write the data OutputStream os = connection.getOutputStream(); os.write(compressed); os.flush(); // Now read the response - final BufferedReader reader = new BufferedReader(new InputStreamReader( - connection.getInputStream())); + final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String response = reader.readLine(); // close resources os.close(); reader.close(); - if ((response == null) || response.startsWith("ERR") - || response.startsWith("7")) { + if ((response == null) || response.startsWith("ERR") || response.startsWith("7")) { if (response == null) { response = "null"; - } else if (response.startsWith("7")) { - response = response - .substring(response.startsWith("7,") ? 2 : 1); } + else + if (response.startsWith("7")) { + response = response.substring(response.startsWith("7,") ? 2 : 1); + } throw new IOException(response); - } else { + } + else { // Is this the first update this hour? - if (response.equals("1") - || response.contains("This is your first update this hour")) { + if (response.equals("1") || response.contains("This is your first update this hour")) { synchronized (this.graphs) { final Iterator iter = this.graphs.iterator(); while (iter.hasNext()) { @@ -482,13 +474,16 @@ public class Metrics { try { gzos = new GZIPOutputStream(baos); gzos.write(input.getBytes("UTF-8")); - } catch (IOException e) { + } + catch (IOException e) { e.printStackTrace(); - } finally { + } + finally { if (gzos != null) { try { gzos.close(); - } catch (IOException ignore) { + } + catch (IOException ignore) { } } } @@ -505,7 +500,8 @@ public class Metrics { try { Class.forName("mineshafter.MineServer"); return true; - } catch (Exception e) { + } + catch (Exception e) { return false; } } @@ -518,15 +514,15 @@ public class Metrics { * @param value * @throws UnsupportedEncodingException */ - private static void appendJSONPair(StringBuilder json, String key, - String value) throws UnsupportedEncodingException { + private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException { boolean isValueNumeric = false; try { if (value.equals("0") || !value.endsWith("0")) { Double.parseDouble(value); isValueNumeric = true; } - } catch (NumberFormatException e) { + } + catch (NumberFormatException e) { isValueNumeric = false; } if (json.charAt(json.length() - 1) != '{') { @@ -536,7 +532,8 @@ public class Metrics { json.append(':'); if (isValueNumeric) { json.append(value); - } else { + } + else { json.append(escapeJSON(value)); } } @@ -574,7 +571,8 @@ public class Metrics { if (chr < ' ') { String t = "000" + Integer.toHexString(chr); builder.append("\\u" + t.substring(t.length() - 4)); - } else { + } + else { builder.append(chr); } break; @@ -591,8 +589,7 @@ public class Metrics { * the text to encode * @return the encoded text, as UTF-8 */ - private static String urlEncode(final String text) - throws UnsupportedEncodingException { + private static String urlEncode(final String text) throws UnsupportedEncodingException { return URLEncoder.encode(text, "UTF-8"); } @@ -738,8 +735,7 @@ public class Metrics { return false; } final Plotter plotter = (Plotter) object; - return plotter.name.equals(this.name) - && (plotter.getValue() == getValue()); + return plotter.name.equals(this.name) && (plotter.getValue() == getValue()); } } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PWE.java b/PlotSquared/src/com/intellectualcrafters/plot/PWE.java index 834c89afa..4ce136aeb 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PWE.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PWE.java @@ -13,9 +13,7 @@ import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.regions.CuboidRegion; /** - * * @author Citymonstret - * */ public class PWE { @@ -24,7 +22,8 @@ public class PWE { LocalSession s; if (PlotMain.worldEdit == null) { s = WorldEdit.getInstance().getSession(p.getName()); - } else { + } + else { s = PlotMain.worldEdit.getSession(p); } @@ -33,33 +32,29 @@ public class PWE { Plot plot = PlotMain.getPlots(l.getWorld()).get(id); if (plot != null) { boolean r; - r = (plot.getOwner() != null) - && plot.getOwner().equals(p.getUniqueId()) - || plot.helpers.contains(DBFunc.everyone) - || plot.helpers.contains(p.getUniqueId()); + r = + (plot.getOwner() != null) && plot.getOwner().equals(p.getUniqueId()) + || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()); if (!r) { if (p.hasPermission("plots.worldedit.bypass")) { removeMask(p, s); return; } - } else { + } + else { World w = p.getWorld(); Location bloc = PlotHelper.getPlotBottomLoc(w, plot.id); Location tloc = PlotHelper.getPlotTopLoc(w, plot.id); - Vector bvec = new Vector(bloc.getBlockX() + 1, - bloc.getBlockY() + 1, bloc.getBlockZ() + 1); - Vector tvec = new Vector(tloc.getBlockX(), - tloc.getBlockY(), tloc.getBlockZ()); + Vector bvec = new Vector(bloc.getBlockX() + 1, bloc.getBlockY() + 1, bloc.getBlockZ() + 1); + Vector tvec = new Vector(tloc.getBlockX(), tloc.getBlockY(), tloc.getBlockZ()); - LocalWorld lw = PlotMain.worldEdit.wrapPlayer(p) - .getWorld(); + LocalWorld lw = PlotMain.worldEdit.wrapPlayer(p).getWorld(); CuboidRegion region = new CuboidRegion(lw, bvec, tvec); - com.sk89q.worldedit.masks.RegionMask mask = new com.sk89q.worldedit.masks.RegionMask( - region); + com.sk89q.worldedit.masks.RegionMask mask = new com.sk89q.worldedit.masks.RegionMask(region); s.setMask(mask); return; @@ -70,10 +65,10 @@ public class PWE { BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p); Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69); - s.setMask(new com.sk89q.worldedit.masks.RegionMask( - new CuboidRegion(plr.getWorld(), p1, p2))); + s.setMask(new com.sk89q.worldedit.masks.RegionMask(new CuboidRegion(plr.getWorld(), p1, p2))); } - } catch (Exception e) { + } + catch (Exception e) { // throw new // PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, // "WorldEdit == Null?"); @@ -84,7 +79,8 @@ public class PWE { try { com.sk89q.worldedit.masks.Mask mask = s.getMask(); return mask == null; - } catch (Throwable e) { + } + catch (Throwable e) { return true; } } @@ -92,7 +88,8 @@ public class PWE { public static void removeMask(Player p, LocalSession s) { try { s.setMask(null); - } catch (Throwable e) { + } + catch (Throwable e) { com.sk89q.worldedit.masks.Mask mask = null; s.setMask(mask); } @@ -103,11 +100,13 @@ public class PWE { LocalSession s; if (PlotMain.worldEdit == null) { s = WorldEdit.getInstance().getSession(p.getName()); - } else { + } + else { s = PlotMain.worldEdit.getSession(p); } removeMask(p, s); - } catch (Exception e) { + } + catch (Exception e) { // throw new // PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, // "WorldEdit == Null?"); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlayerFunctions.java b/PlotSquared/src/com/intellectualcrafters/plot/PlayerFunctions.java index 74e2db2b6..3a6fa9fcc 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlayerFunctions.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlayerFunctions.java @@ -1,10 +1,10 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlayerFunctions.java - * >> Generated by: Citymonstret at 2014-08-09 01:43 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlayerFunctions.java >> Generated by: Citymonstret at 2014-08-09 + * 01:43 */ package com.intellectualcrafters.plot; @@ -28,13 +28,11 @@ import org.bukkit.entity.Player; * Functions involving players, plots and locations. * * @author Citymonstret - * */ @SuppressWarnings("javadoc") public class PlayerFunctions { /** - * * @param player * player * @return @@ -44,7 +42,6 @@ public class PlayerFunctions { } /** - * * @param plot * plot * @return @@ -56,8 +53,7 @@ public class PlayerFunctions { return (lp - cu) > 30l; } - public static ArrayList getPlotSelectionIds(World world, - PlotId pos1, PlotId pos2) { + public static ArrayList getPlotSelectionIds(World world, PlotId pos1, PlotId pos2) { ArrayList myplots = new ArrayList(); for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { @@ -70,38 +66,25 @@ public class PlayerFunctions { public static Plot getBottomPlot(World world, Plot plot) { if (plot.settings.getMerged(0)) { - return getBottomPlot( - world, - PlotMain.getPlots(world).get( - new PlotId(plot.id.x, plot.id.y - 1))); + return getBottomPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y - 1))); } if (plot.settings.getMerged(3)) { - return getBottomPlot( - world, - PlotMain.getPlots(world).get( - new PlotId(plot.id.x - 1, plot.id.y))); + return getBottomPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x - 1, plot.id.y))); } return plot; } public static Plot getTopPlot(World world, Plot plot) { if (plot.settings.getMerged(2)) { - return getTopPlot( - world, - PlotMain.getPlots(world).get( - new PlotId(plot.id.x, plot.id.y + 1))); + return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1))); } if (plot.settings.getMerged(1)) { - return getTopPlot( - world, - PlotMain.getPlots(world).get( - new PlotId(plot.id.x + 1, plot.id.y))); + return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x + 1, plot.id.y))); } return plot; } /** - * * @param loc * @return */ @@ -126,17 +109,14 @@ public class PlayerFunctions { } /** - * * @param player * @param plot */ public static void togglePlotWeather(Player player, Plot plot) { - player.setPlayerWeather(plot.settings.getRain() ? WeatherType.DOWNFALL - : WeatherType.CLEAR); + player.setPlayerWeather(plot.settings.getRain() ? WeatherType.DOWNFALL : WeatherType.CLEAR); } /** - * * @param player * @param plot */ @@ -145,7 +125,6 @@ public class PlayerFunctions { } /** - * * @param player * @return */ @@ -164,8 +143,7 @@ public class PlayerFunctions { return plots.get(id); } } - return new Plot(id, null, Biome.FOREST, new ArrayList(), - new ArrayList(), world.getName()); + return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), world.getName()); } @@ -180,7 +158,6 @@ public class PlayerFunctions { } /** - * * @param plr * @return */ @@ -197,7 +174,6 @@ public class PlayerFunctions { } /** - * * @param plr * @return */ @@ -210,7 +186,6 @@ public class PlayerFunctions { } /** - * * @param p * @return */ @@ -220,7 +195,6 @@ public class PlayerFunctions { } /** - * * @return PlotMain.getPlots(); * @deprecated */ @@ -252,8 +226,7 @@ public class PlayerFunctions { if ((msg.length() == 0) || msg.equalsIgnoreCase("")) { return; } - sendMessageWrapped(plr, - ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg)); + sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg)); } /** diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Plot.java b/PlotSquared/src/com/intellectualcrafters/plot/Plot.java index 88e3bb21c..3e5825735 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Plot.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Plot.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Plot.java - * >> Generated by: Citymonstret at 2014-08-09 01:43 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Plot.java >> Generated by: Citymonstret at 2014-08-09 01:43 */ package com.intellectualcrafters.plot; @@ -23,7 +22,6 @@ import com.intellectualcrafters.plot.database.DBFunc; * The plot class * * @author Citymonstret - * */ @SuppressWarnings("javadoc") public class Plot implements Cloneable { @@ -78,8 +76,7 @@ public class Plot implements Cloneable { * @param helpers * @param denied */ - public Plot(PlotId id, UUID owner, Biome plotBiome, - ArrayList helpers, ArrayList denied, String world) { + public Plot(PlotId id, UUID owner, Biome plotBiome, ArrayList helpers, ArrayList denied, String world) { this.id = id; this.settings = new PlotSettings(this); this.settings.setBiome(plotBiome); @@ -110,11 +107,9 @@ public class Plot implements Cloneable { * @param time * @param merged */ - public Plot(PlotId id, UUID owner, Biome plotBiome, - ArrayList helpers, ArrayList trusted, - ArrayList denied, boolean changeTime, long time, - boolean rain, String alias, PlotHomePosition position, - Flag[] flags, String world, boolean[] merged) { + public Plot(PlotId id, UUID owner, Biome plotBiome, ArrayList helpers, ArrayList trusted, + ArrayList denied, boolean changeTime, long time, boolean rain, String alias, + PlotHomePosition position, Flag[] flags, String world, boolean[] merged) { this.id = id; this.settings = new PlotSettings(this); this.settings.setBiome(plotBiome); @@ -132,7 +127,8 @@ public class Plot implements Cloneable { this.delete = false; if (flags != null) { this.settings.setFlags(flags); - } else { + } + else { this.settings.setFlags(new Flag[0]); } this.world = world; @@ -164,16 +160,10 @@ public class Plot implements Cloneable { */ public boolean hasRights(Player player) { return player.hasPermission("plots.admin") - || ((this.helpers != null) && this.helpers - .contains(DBFunc.everyone)) - || ((this.helpers != null) && this.helpers.contains(player - .getUniqueId())) - || ((this.owner != null) && this.owner.equals(player - .getUniqueId())) - || ((this.owner != null) && (this.trusted != null) - && (Bukkit.getPlayer(this.owner) != null) && (this.trusted - .contains(player.getUniqueId()) || this.trusted - .contains(DBFunc.everyone))); + || ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) + || ((this.helpers != null) && this.helpers.contains(player.getUniqueId())) + || ((this.owner != null) && this.owner.equals(player.getUniqueId())) + || ((this.owner != null) && (this.trusted != null) && (Bukkit.getPlayer(this.owner) != null) && (this.trusted.contains(player.getUniqueId()) || this.trusted.contains(DBFunc.everyone))); } /** @@ -184,14 +174,11 @@ public class Plot implements Cloneable { */ public boolean deny_entry(Player player) { return (this.denied != null) - && ((this.denied.contains(DBFunc.everyone) && !this - .hasRights(player)) || (!this.hasRights(player) && this.denied - .contains(player.getUniqueId()))); + && ((this.denied.contains(DBFunc.everyone) && !this.hasRights(player)) || (!this.hasRights(player) && this.denied.contains(player.getUniqueId()))); } /** * Get the UUID of the owner - * */ public UUID getOwner() { return this.owner; @@ -199,7 +186,6 @@ public class Plot implements Cloneable { /** * Get the plot ID - * */ public PlotId getId() { return this.id; @@ -207,7 +193,6 @@ public class Plot implements Cloneable { /** * Get the plot World - * */ public World getWorld() { return Bukkit.getWorld(this.world); @@ -222,7 +207,8 @@ public class Plot implements Cloneable { public Object clone() throws CloneNotSupportedException { try { return super.clone(); - } catch (CloneNotSupportedException e) { + } + catch (CloneNotSupportedException e) { return null; } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotGenerator.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotGenerator.java index 1ccf2dd76..d485975f9 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotGenerator.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotGenerator.java @@ -3,10 +3,10 @@ package com.intellectualcrafters.plot; import org.bukkit.generator.ChunkGenerator; public abstract class PlotGenerator extends ChunkGenerator { - - public PlotGenerator(String world) { - PlotMain.loadWorld(world, this); - } + + public PlotGenerator(String world) { + PlotMain.loadWorld(world, this); + } public abstract PlotWorld getNewPlotWorld(String world); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java index 768d1d4b8..a4e021e97 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlotHelper.java - * >> Generated by: Citymonstret at 2014-08-09 01:43 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlotHelper.java >> Generated by: Citymonstret at 2014-08-09 01:43 */ package com.intellectualcrafters.plot; @@ -35,7 +34,6 @@ import com.intellectualcrafters.plot.database.DBFunc; * plot functions * * @author Citymonstret - * */ public class PlotHelper { public static boolean canSetFast = false; @@ -62,16 +60,14 @@ public class PlotHelper { return id; } - public static boolean mergePlots(Player plr, World world, - ArrayList plotIds) { + public static boolean mergePlots(Player plr, World world, ArrayList plotIds) { PlotWorld plotworld = PlotMain.getWorldSettings(world); if (PlotMain.useEconomy && plotworld.USE_ECONOMY) { double cost = plotIds.size() * plotworld.MERGE_PRICE; if (cost > 0d) { Economy economy = PlotMain.economy; if (economy.getBalance(plr) < cost) { - PlayerFunctions.sendMessage(plr, C.CANNOT_AFFORD_MERGE, "" - + cost); + PlayerFunctions.sendMessage(plr, C.CANNOT_AFFORD_MERGE, "" + cost); return false; } economy.withdrawPlayer(plr, cost); @@ -116,14 +112,12 @@ public class PlotHelper { if (lx) { if (ly) { - if (!plot.settings.getMerged(1) - || !plot.settings.getMerged(2)) { + if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) { manager.removeRoadSouthEast(plotworld, plot); } } if (!plot.settings.getMerged(1)) { - Plot plot2 = PlotMain.getPlots(world).get( - new PlotId(x + 1, y)); + Plot plot2 = PlotMain.getPlots(world).get(new PlotId(x + 1, y)); mergePlot(world, plot, plot2); plot.settings.setMerged(1, true); plot2.settings.setMerged(3, true); @@ -131,8 +125,7 @@ public class PlotHelper { } if (ly) { if (!plot.settings.getMerged(2)) { - Plot plot2 = PlotMain.getPlots(world).get( - new PlotId(x, y + 1)); + Plot plot2 = PlotMain.getPlots(world).get(new PlotId(x, y + 1)); mergePlot(world, plot, plot2); plot.settings.setMerged(2, true); plot2.settings.setMerged(0, true); @@ -167,7 +160,8 @@ public class PlotHelper { greaterPlot.settings.setMerged(0, true); manager.removeRoadSouth(plotworld, lesserPlot); } - } else { + } + else { if (!lesserPlot.settings.getMerged(1)) { lesserPlot.settings.setMerged(1, true); greaterPlot.settings.setMerged(3, true); @@ -217,12 +211,9 @@ public class PlotHelper { String id = p.id.y + ";" + p.id.x; Sign sign = (Sign) bs.getState(); sign.setLine(0, C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id)); - sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id) - .replaceAll("%plr%", plr.getName())); - sign.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id) - .replaceAll("%plr%", plr.getName())); - sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id) - .replaceAll("%plr%", plr.getName())); + sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); + sign.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); + sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); sign.update(true); } @@ -247,14 +238,12 @@ public class PlotHelper { public static void setBlock(Block block, PlotBlock plotblock) { if (canSetFast) { - if (block.getTypeId() != plotblock.id - && plotblock.data != block.getData()) { + if (block.getTypeId() != plotblock.id && plotblock.data != block.getData()) { try { - SetBlockFast.set(block.getWorld(), block.getX(), - block.getY(), block.getZ(), plotblock.id, - plotblock.data); + SetBlockFast.set(block.getWorld(), block.getX(), block.getY(), block.getZ(), plotblock.id, plotblock.data); return; - } catch (NoSuchMethodException e) { + } + catch (NoSuchMethodException e) { canSetFast = false; } } @@ -263,10 +252,12 @@ public class PlotHelper { if (block.getTypeId() != plotblock.id) { block.setTypeId(plotblock.id); } - } else { + } + else { if (block.getTypeId() == plotblock.id) { block.setData(plotblock.data); - } else { + } + else { block.setTypeIdAndData(plotblock.id, plotblock.data, false); } } @@ -297,29 +288,25 @@ public class PlotHelper { PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id; PlotId top = PlayerFunctions.getTopPlot(world, plot).id; merge = false; - plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId( - bot.x, bot.y - 1), new PlotId(top.x, top.y)); + plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); if (ownsPlots(world, plots, player, 0)) { merge = true; mergePlots(world, plots); continue; } - plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId( - bot.x, bot.y), new PlotId(top.x + 1, top.y)); + plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); if (ownsPlots(world, plots, player, 1)) { merge = true; mergePlots(world, plots); continue; } - plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId( - bot.x, bot.y), new PlotId(top.x, top.y + 1)); + plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); if (ownsPlots(world, plots, player, 2)) { merge = true; mergePlots(world, plots); continue; } - plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId( - bot.x - 1, bot.y), new PlotId(top.x, top.y)); + plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); if (ownsPlots(world, plots, player, 3)) { merge = true; mergePlots(world, plots); @@ -331,24 +318,20 @@ public class PlotHelper { } } - private static boolean ownsPlots(World world, ArrayList plots, - Player player, int dir) { + private static boolean ownsPlots(World world, ArrayList plots, Player player, int dir) { PlotId id_min = plots.get(0); PlotId id_max = plots.get(plots.size() - 1); for (PlotId myid : plots) { Plot myplot = PlotMain.getPlots(world).get(myid); - if ((myplot == null) || !myplot.hasOwner() - || !(myplot.getOwner().equals(player.getUniqueId()))) { + if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(player.getUniqueId()))) { return false; } PlotId top = PlayerFunctions.getTopPlot(world, myplot).id; - if (((top.x > id_max.x) && (dir != 1)) - || ((top.y > id_max.y) && (dir != 2))) { + if (((top.x > id_max.x) && (dir != 1)) || ((top.y > id_max.y) && (dir != 2))) { return false; } PlotId bot = PlayerFunctions.getBottomPlot(world, myplot).id; - if (((bot.x < id_min.x) && (dir != 3)) - || ((bot.y < id_min.y) && (dir != 0))) { + if (((bot.x < id_min.x) && (dir != 3)) || ((bot.y < id_min.y) && (dir != 0))) { return false; } } @@ -357,9 +340,8 @@ public class PlotHelper { public static boolean createPlot(Player player, Plot plot) { World w = plot.getWorld(); - Plot p = new Plot(plot.id, player.getUniqueId(), - plot.settings.getBiome(), new ArrayList(), - new ArrayList(), w.getName()); + Plot p = + new Plot(plot.id, player.getUniqueId(), plot.settings.getBiome(), new ArrayList(), new ArrayList(), w.getName()); PlotMain.updatePlot(p); DBFunc.createPlot(p); DBFunc.createPlotSettings(DBFunc.getId(w.getName(), p.id), p); @@ -558,8 +540,7 @@ public class PlotHelper { public static ArrayList runners_p = new ArrayList(); public static HashMap runners = new HashMap(); - public static void adjustWallFilling(final Player requester, - final Plot plot, PlotBlock block) { + public static void adjustWallFilling(final Player requester, final Plot plot, PlotBlock block) { if (runners.containsKey(plot)) { PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER); return; @@ -573,8 +554,7 @@ public class PlotHelper { PlayerFunctions.sendMessage(requester, C.SET_BLOCK_ACTION_FINISHED); } - public static void setFloor(final Player requester, final Plot plot, - PlotBlock[] blocks) { + public static void setFloor(final Player requester, final Plot plot, PlotBlock[] blocks) { if (runners.containsKey(plot)) { PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER); return; @@ -595,8 +575,7 @@ public class PlotHelper { public static short[] getBlock(String block) { if (block.contains(":")) { String[] split = block.split(":"); - return new short[] { Short.parseShort(split[0]), - Short.parseShort(split[1]) }; + return new short[] { Short.parseShort(split[0]), Short.parseShort(split[1]) }; } return new short[] { Short.parseShort(block), 0 }; } @@ -605,16 +584,15 @@ public class PlotHelper { final Location pos1 = getPlotBottomLoc(world, plot.id).add(1, 0, 1); final Location pos2 = getPlotTopLoc(world, plot.id); for (int i = (pos1.getBlockX() / 16) * 16; i < (16 + ((pos2.getBlockX() / 16) * 16)); i += 16) { - for (int j = (pos1.getBlockZ() / 16) * 16; j < (16 + ((pos2 - .getBlockZ() / 16) * 16)); j += 16) { + for (int j = (pos1.getBlockZ() / 16) * 16; j < (16 + ((pos2.getBlockZ() / 16) * 16)); j += 16) { Chunk chunk = world.getChunkAt(i, j); for (Entity entity : chunk.getEntities()) { PlotId id = PlayerFunctions.getPlot(entity.getLocation()); if ((id != null) && id.equals(plot.id)) { if (entity instanceof Player) { - PlotMain.teleportPlayer((Player) entity, - entity.getLocation(), plot); - } else { + PlotMain.teleportPlayer((Player) entity, entity.getLocation(), plot); + } + else { entity.remove(); } } @@ -650,8 +628,7 @@ public class PlotHelper { clearAllEntities(world, plot, false); PlotManager manager = PlotMain.getPlotManager(world); - Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id) - .add(1, 0, 1); + Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); final int prime = 31; int h = 1; @@ -667,10 +644,8 @@ public class PlotHelper { removeSign(requester, plot); setSign(requester, plot); - PlayerFunctions.sendMessage( - requester, - C.CLEARING_DONE.s().replaceAll("%time%", - "" + ((System.nanoTime() - start) / 1000000.0))); + PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", "" + + ((System.nanoTime() - start) / 1000000.0))); if (canSetFast) { refreshPlotChunks(world, plot); // SetBlockFast.update(requester); @@ -678,8 +653,7 @@ public class PlotHelper { return; } - public static void setCuboid(World world, Location pos1, Location pos2, - PlotBlock[] blocks) { + public static void setCuboid(World world, Location pos1, Location pos2, PlotBlock[] blocks) { if (!canSetFast) { for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { @@ -687,15 +661,14 @@ public class PlotHelper { int i = random(blocks.length); PlotBlock newblock = blocks[i]; Block block = world.getBlockAt(x, y, z); - if (!((block.getTypeId() == newblock.id) && (block - .getData() == newblock.data))) { - block.setTypeIdAndData(newblock.id, newblock.data, - false); + if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) { + block.setTypeIdAndData(newblock.id, newblock.data, false); } } } } - } else { + } + else { try { for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { @@ -703,21 +676,19 @@ public class PlotHelper { int i = random(blocks.length); PlotBlock newblock = blocks[i]; Block block = world.getBlockAt(x, y, z); - if (!((block.getTypeId() == newblock.id) && (block - .getData() == newblock.data))) { - SetBlockFast.set(world, x, y, z, newblock.id, - newblock.data); + if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) { + SetBlockFast.set(world, x, y, z, newblock.id, newblock.data); } } } } - } catch (Exception e) { + } + catch (Exception e) { } } } - public static void setSimpleCuboid(World world, Location pos1, - Location pos2, PlotBlock newblock) { + public static void setSimpleCuboid(World world, Location pos1, Location pos2, PlotBlock newblock) { if (!canSetFast) { for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { @@ -729,20 +700,21 @@ public class PlotHelper { } } } - } else { + } + else { try { for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) { Block block = world.getBlockAt(x, y, z); if (!((block.getTypeId() == newblock.id))) { - SetBlockFast.set(world, x, y, z, newblock.id, - (byte) 0); + SetBlockFast.set(world, x, y, z, newblock.id, (byte) 0); } } } } - } catch (Exception e) { + } + catch (Exception e) { } } @@ -768,13 +740,14 @@ public class PlotHelper { public static Location getPlotHome(World w, PlotId plotid) { PlotMain.getWorldSettings(w); if (getPlot(w, plotid).settings.getPosition() == PlotHomePosition.DEFAULT) { - int x = getPlotBottomLoc(w, plotid).getBlockX() - + (getPlotTopLoc(w, plotid).getBlockX() - getPlotBottomLoc( - w, plotid).getBlockX()); + int x = + getPlotBottomLoc(w, plotid).getBlockX() + + (getPlotTopLoc(w, plotid).getBlockX() - getPlotBottomLoc(w, plotid).getBlockX()); int z = getPlotBottomLoc(w, plotid).getBlockZ() - 2; int y = w.getHighestBlockYAt(x, z); return new Location(w, x, y + 2, z); - } else { + } + else { World world = w; Location bot, top; @@ -823,8 +796,7 @@ public class PlotHelper { } public static int getPlotWidth(World world, PlotId id) { - return getPlotTopLoc(world, id).getBlockX() - - getPlotBottomLoc(world, id).getBlockX(); + return getPlotTopLoc(world, id).getBlockX() - getPlotBottomLoc(world, id).getBlockX(); } public static Location getPlotTopLoc(World world, PlotId id) { @@ -854,8 +826,7 @@ public class PlotHelper { if (PlotMain.getPlots(world).containsKey(id)) { return PlotMain.getPlots(world).get(id); } - return new Plot(id, null, Biome.FOREST, new ArrayList(), - new ArrayList(), world.getName()); + return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), world.getName()); } public static Plot getCurrentPlot(Location loc) { @@ -866,7 +837,6 @@ public class PlotHelper { if (PlotMain.getPlots(loc.getWorld()).containsKey(id)) { return PlotMain.getPlots(loc.getWorld()).get(id); } - return new Plot(id, null, Biome.FOREST, new ArrayList(), - new ArrayList(), loc.getWorld().getName()); + return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), loc.getWorld().getName()); } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotHomePosition.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotHomePosition.java index b72e29c6f..c4229f593 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotHomePosition.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotHomePosition.java @@ -1,10 +1,10 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlotHomePosition.java - * >> Generated by: Citymonstret at 2014-08-09 01:44 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlotHomePosition.java >> Generated by: Citymonstret at 2014-08-09 + * 01:44 */ package com.intellectualcrafters.plot; @@ -13,7 +13,8 @@ package com.intellectualcrafters.plot; * Created by Citymonstret on 2014-08-05. */ public enum PlotHomePosition { - CENTER("Center", 'c'), DEFAULT("Default", 'd'); + CENTER("Center", 'c'), + DEFAULT("Default", 'd'); private String string; private char ch; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java index 4b705580a..bb093cb13 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Main.java - * >> Generated by: Citymonstret at 2014-08-09 01:43 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Main.java >> Generated by: Citymonstret at 2014-08-09 01:43 */ package com.intellectualcrafters.plot; @@ -125,13 +124,12 @@ public class PlotMain extends JavaPlugin { @SuppressWarnings("deprecation") public static void checkForExpiredPlots() { final JavaPlugin plugin = PlotMain.getMain(); - Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin, - new Runnable() { - @Override - public void run() { - checkExpired(plugin, true); - } - }, 0l, 12 * 60 * 60 * 20l); + Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() { + @Override + public void run() { + checkExpired(plugin, true); + } + }, 0l, 12 * 60 * 60 * 20l); } /** @@ -175,7 +173,8 @@ public class PlotMain extends JavaPlugin { boolean hasperm = false; if (player.hasPermission(perm)) { hasperm = true; - } else { + } + else { String[] nodes = perm.split("\\."); StringBuilder n = new StringBuilder(); for (int i = 0; i < (nodes.length - 1); i++) { @@ -246,7 +245,6 @@ public class PlotMain extends JavaPlugin { } /** - * * @param player * @return */ @@ -266,7 +264,6 @@ public class PlotMain extends JavaPlugin { } /** - * * @param world * @param player * @return @@ -285,7 +282,6 @@ public class PlotMain extends JavaPlugin { } /** - * * @param world * @return */ @@ -304,7 +300,6 @@ public class PlotMain extends JavaPlugin { } /** - * * @return */ public static String[] getPlotWorldsString() { @@ -312,7 +307,6 @@ public class PlotMain extends JavaPlugin { } /** - * * @param world * @return */ @@ -321,7 +315,6 @@ public class PlotMain extends JavaPlugin { } /** - * * @param world * @return */ @@ -333,7 +326,6 @@ public class PlotMain extends JavaPlugin { } /** - * * @param world * @return */ @@ -345,7 +337,6 @@ public class PlotMain extends JavaPlugin { } /** - * * @param world * @return */ @@ -357,7 +348,6 @@ public class PlotMain extends JavaPlugin { } /** - * * @param world * @return */ @@ -369,7 +359,6 @@ public class PlotMain extends JavaPlugin { } /** - * * @param world * @return set containing the plots for a world */ @@ -406,20 +395,25 @@ public class PlotMain extends JavaPlugin { } /** - * TODO: Implement better system The whole point of this system is to - * recycle old plots So why not just allow users to claim old plots, and try - * to hide the fact that the are owned. Reduce amount of expired plots: - On - * /plot auto - allow claiming of old plot, clear it so the user doesn't - * know - On /plot info, - show that the plot is expired and allowed to be - * claimed - * - * Have the task run less often: - Run the task when there are very little, - * or no players online (great for small servers) - Run the task at startup - * (also only useful for small servers) - * - * Also, in terms of faster code: - Have an array of plots, sorted by expiry - * time. - Add new plots to the end. - The task then only needs to go - * through the first few plots + * TODO: Implement better system The whole point of this system is to + * recycle old plots
+ * So why not just allow users to claim old plots, and try to hide the fact + * that the are owned.
+ *
+ * Reduce amount of expired plots:
+ * - On /plot
+ * auto
+ * - allow claiming of old plot, clear it so the user doesn't know
+ * - On /plot info,
+ * - show that the plot is expired and allowed to be claimed Have the task + * run less often:
+ * - Run the task when there are very little, or no players online (great + * for small servers)
+ * - Run the task at startup (also only useful for small servers)
+ * Also, in terms of faster code:
+ * - Have an array of plots, sorted by expiry time.
+ * - Add new plots to the end.
+ * - The task then only needs to go through the first few plots * * @param plugin * Plugin @@ -443,13 +437,12 @@ public class PlotMain extends JavaPlugin { } int days = (int) (lastPlayed / (1000 * 60 * 60 * 24)); if (days >= Settings.AUTO_CLEAR_DAYS) { - PlotDeleteEvent event = new PlotDeleteEvent( - world, plot.id); - Bukkit.getServer().getPluginManager() - .callEvent(event); + PlotDeleteEvent event = new PlotDeleteEvent(world, plot.id); + Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { event.setCancelled(true); - } else { + } + else { DBFunc.delete(world, plot); } } @@ -458,18 +451,18 @@ public class PlotMain extends JavaPlugin { } } }); - } else { + } + else { for (String world : getPlotWorldsString()) { if (PlotMain.plots.containsKey(world)) { for (Plot plot : PlotMain.plots.get(world).values()) { if (PlayerFunctions.hasExpired(plot)) { - PlotDeleteEvent event = new PlotDeleteEvent(world, - plot.id); - Bukkit.getServer().getPluginManager() - .callEvent(event); + PlotDeleteEvent event = new PlotDeleteEvent(world, plot.id); + Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { event.setCancelled(true); - } else { + } + else { DBFunc.delete(world, plot); } } @@ -480,22 +473,19 @@ public class PlotMain extends JavaPlugin { } private void setupLogger() { - File log = new File(getMain().getDataFolder() + File.separator + "logs" - + File.separator + "plots.log"); + File log = new File(getMain().getDataFolder() + File.separator + "logs" + File.separator + "plots.log"); if (!log.exists()) { try { - if (!new File(getMain().getDataFolder() + File.separator - + "logs").mkdirs()) { - sendConsoleSenderMessage(C.PREFIX.s() - + "&cFailed to create logs folder. Do it manually."); + if (!new File(getMain().getDataFolder() + File.separator + "logs").mkdirs()) { + sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to create logs folder. Do it manually."); } if (log.createNewFile()) { FileWriter writer = new FileWriter(log); - writer.write("Created at: " + new Date().toString() - + "\n\n\n"); + writer.write("Created at: " + new Date().toString() + "\n\n\n"); writer.close(); } - } catch (IOException e) { + } + catch (IOException e) { e.printStackTrace(); } @@ -505,8 +495,7 @@ public class PlotMain extends JavaPlugin { } private static double getJavaVersion() { - return Double.parseDouble(System - .getProperty("java.specification.version")); + return Double.parseDouble(System.getProperty("java.specification.version")); } /** @@ -519,10 +508,8 @@ public class PlotMain extends JavaPlugin { // Check for outdated java version. if (getJavaVersion() < 1.7) { - sendConsoleSenderMessage(C.PREFIX.s() - + "&cYour java version is outdated. Please update to at least 1.7."); - sendConsoleSenderMessage(C.PREFIX.s() - + "&cURL: &6https://java.com/en/download/index.jsp"); + sendConsoleSenderMessage(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7."); + sendConsoleSenderMessage(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp"); Bukkit.getPluginManager().disablePlugin(this); return; } @@ -534,9 +521,9 @@ public class PlotMain extends JavaPlugin { Metrics metrics = new Metrics(this); metrics.start(); sendConsoleSenderMessage(C.PREFIX.s() + "&6Metrics enabled."); - } catch (Exception e) { - sendConsoleSenderMessage(C.PREFIX.s() - + "&cFailed to load up metrics."); + } + catch (Exception e) { + sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to load up metrics."); } } @@ -549,85 +536,90 @@ public class PlotMain extends JavaPlugin { } if (Settings.DB.USE_MYSQL) { try { - mySQL = new MySQL(this, Settings.DB.HOST_NAME, - Settings.DB.PORT, Settings.DB.DATABASE, - Settings.DB.USER, Settings.DB.PASSWORD); + mySQL = + new MySQL(this, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD); connection = mySQL.openConnection(); { DatabaseMetaData meta = connection.getMetaData(); ResultSet res = meta.getTables(null, null, "plot", null); if (!res.next()) { DBFunc.createTables("mysql", true); - } else { + } + else { res = meta.getTables(null, null, "plot_trusted", null); if (!res.next()) { DBFunc.createTables("mysql", false); - } else { - res = meta.getTables(null, null, "plot_ratings", - null); + } + else { + res = meta.getTables(null, null, "plot_ratings", null); if (!res.next()) { DBFunc.createTables("mysql", false); } } } } - } catch (ClassNotFoundException | SQLException e) { + } + catch (ClassNotFoundException | SQLException e) { Logger.add(LogLevel.DANGER, "MySQL connection failed."); - System.out - .print("\u001B[31m[Plots] MySQL is not setup correctly. The plugin will disable itself.\u001B[0m"); - System.out - .print("\u001B[36m==== Here is an ugly stacktrace if you are interested in those things ====\u001B[0m"); + System.out.print("\u001B[31m[Plots] MySQL is not setup correctly. The plugin will disable itself.\u001B[0m"); + System.out.print("\u001B[36m==== Here is an ugly stacktrace if you are interested in those things ====\u001B[0m"); e.printStackTrace(); Bukkit.getPluginManager().disablePlugin(this); return; } plots = DBFunc.getPlots(); - } else if (Settings.DB.USE_MONGO) { - sendConsoleSenderMessage(C.PREFIX.s() - + "MongoDB is not yet implemented"); - } else if (Settings.DB.USE_SQLITE) { - try { - connection = new SQLite(this, Settings.DB.SQLITE_DB + ".db") - .openConnection(); - { - DatabaseMetaData meta = connection.getMetaData(); - ResultSet res = meta.getTables(null, null, "plot", null); - if (!res.next()) { - DBFunc.createTables("sqlite", true); - } else { - res = meta.getTables(null, null, "plot_trusted", null); - if (!res.next()) { - DBFunc.createTables("sqlite", false); - } else { - res = meta.getTables(null, null, "plot_ratings", - null); + } + else + if (Settings.DB.USE_MONGO) { + sendConsoleSenderMessage(C.PREFIX.s() + "MongoDB is not yet implemented"); + } + else + if (Settings.DB.USE_SQLITE) { + try { + connection = new SQLite(this, Settings.DB.SQLITE_DB + ".db").openConnection(); + { + DatabaseMetaData meta = connection.getMetaData(); + ResultSet res = meta.getTables(null, null, "plot", null); if (!res.next()) { - DBFunc.createTables("sqlite", false); + DBFunc.createTables("sqlite", true); + } + else { + res = meta.getTables(null, null, "plot_trusted", null); + if (!res.next()) { + DBFunc.createTables("sqlite", false); + } + else { + res = meta.getTables(null, null, "plot_ratings", null); + if (!res.next()) { + DBFunc.createTables("sqlite", false); + } + } } } } + catch (ClassNotFoundException | SQLException e) { + Logger.add(LogLevel.DANGER, "SQLite connection failed"); + sendConsoleSenderMessage(C.PREFIX.s() + + "&cFailed to open SQLite connection. The plugin will disable itself."); + sendConsoleSenderMessage("&9==== Here is an ugly stacktrace, if you are interested in those things ==="); + e.printStackTrace(); + Bukkit.getPluginManager().disablePlugin(this); + return; + } + plots = DBFunc.getPlots(); + } + else { + Logger.add(LogLevel.DANGER, "No storage type is set."); + sendConsoleSenderMessage(C.PREFIX + "&cNo storage type is set!"); + getServer().getPluginManager().disablePlugin(this); + return; } - } catch (ClassNotFoundException | SQLException e) { - Logger.add(LogLevel.DANGER, "SQLite connection failed"); - sendConsoleSenderMessage(C.PREFIX.s() - + "&cFailed to open SQLite connection. The plugin will disable itself."); - sendConsoleSenderMessage("&9==== Here is an ugly stacktrace, if you are interested in those things ==="); - e.printStackTrace(); - Bukkit.getPluginManager().disablePlugin(this); - return; - } - plots = DBFunc.getPlots(); - } else { - Logger.add(LogLevel.DANGER, "No storage type is set."); - sendConsoleSenderMessage(C.PREFIX + "&cNo storage type is set!"); - getServer().getPluginManager().disablePlugin(this); - return; - } if (getServer().getPluginManager().getPlugin("PlotMe") != null) { try { new PlotMeConverter(this).runAsync(); - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); } } @@ -650,22 +642,17 @@ public class PlotMain extends JavaPlugin { getServer().getPluginManager().registerEvents(camera, this); } if (getServer().getPluginManager().getPlugin("BarAPI") != null) { - barAPI = (BarAPI) getServer().getPluginManager() - .getPlugin("BarAPI"); + barAPI = (BarAPI) getServer().getPluginManager().getPlugin("BarAPI"); } if (getServer().getPluginManager().getPlugin("WorldEdit") != null) { - worldEdit = (WorldEditPlugin) getServer().getPluginManager() - .getPlugin("WorldEdit"); - getServer().getPluginManager().registerEvents( - new WorldEditListener(), this); + worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); + getServer().getPluginManager().registerEvents(new WorldEditListener(), this); } if (Settings.WORLDGUARD) { if (getServer().getPluginManager().getPlugin("WorldGuard") != null) { - worldGuard = (WorldGuardPlugin) getServer().getPluginManager() - .getPlugin("WorldGuard"); + worldGuard = (WorldGuardPlugin) getServer().getPluginManager().getPlugin("WorldGuard"); worldGuardListener = new WorldGuardListener(this); - getServer().getPluginManager().registerEvents( - worldGuardListener, this); + getServer().getPluginManager().registerEvents(worldGuardListener, this); } } if (Settings.AUTO_CLEAR) { @@ -673,26 +660,24 @@ public class PlotMain extends JavaPlugin { checkForExpiredPlots(); } if (getServer().getPluginManager().getPlugin("Vault") != null) { - RegisteredServiceProvider economyProvider = getServer() - .getServicesManager().getRegistration( - net.milkbowl.vault.economy.Economy.class); + RegisteredServiceProvider economyProvider = + getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); if (economyProvider != null) { economy = economyProvider.getProvider(); } useEconomy = (economy != null); } - getServer().getScheduler().scheduleSyncRepeatingTask(this, new Lag(), - 100L, 1L); + getServer().getScheduler().scheduleSyncRepeatingTask(this, new Lag(), 100L, 1L); if (Web.ENABLED) { - sendConsoleSenderMessage(C.PREFIX.s() - + "Web Is not implemented yet. Please bear with us."); + sendConsoleSenderMessage(C.PREFIX.s() + "Web Is not implemented yet. Please bear with us."); } try { new SetBlockFast(); PlotHelper.canSetFast = true; - } catch (Exception e) { + } + catch (Exception e) { PlotHelper.canSetFast = false; } @@ -738,28 +723,20 @@ public class PlotMain extends JavaPlugin { */ public static void sendConsoleSenderMessage(String string) { if (getMain().getServer().getConsoleSender() == null) { - System.out.println(ChatColor.stripColor(ConsoleColors - .fromString(string))); - } else { - getMain() - .getServer() - .getConsoleSender() - .sendMessage( - ChatColor.translateAlternateColorCodes('&', string)); + System.out.println(ChatColor.stripColor(ConsoleColors.fromString(string))); + } + else { + getMain().getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', string)); } } public static boolean teleportPlayer(Player player, Location from, Plot plot) { - PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, - from, plot); + PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, plot); Bukkit.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { - Location location = PlotHelper.getPlotHome( - Bukkit.getWorld(plot.world), plot); - if ((location.getBlockX() >= 29999999) - || (location.getBlockX() <= -29999999) - || (location.getBlockZ() >= 299999999) - || (location.getBlockZ() <= -29999999)) { + Location location = PlotHelper.getPlotHome(Bukkit.getWorld(plot.world), plot); + if ((location.getBlockX() >= 29999999) || (location.getBlockX() <= -29999999) + || (location.getBlockZ() >= 299999999) || (location.getBlockZ() <= -29999999)) { event.setCancelled(true); return false; } @@ -787,8 +764,7 @@ public class PlotMain extends JavaPlugin { * message */ public static void Broadcast(C c) { - Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', - C.PREFIX.s() + c.s())); + Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + c.s())); } /** @@ -812,8 +788,7 @@ public class PlotMain extends JavaPlugin { PlayerFunctions.sendMessage(player, c); } } - System.out.println(ChatColor.stripColor(ChatColor - .translateAlternateColorCodes('&', C.PREFIX.s() + c.s()))); + System.out.println(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + c.s()))); } public static void reloadTranslations() throws IOException { @@ -825,8 +800,7 @@ public class PlotMain extends JavaPlugin { return 0; } OfflinePlayer player; - if (((player = Bukkit.getOfflinePlayer(uuid)) == null) - || !player.hasPlayedBefore()) { + if (((player = Bukkit.getOfflinePlayer(uuid)) == null) || !player.hasPlayedBefore()) { return 0; } return player.getLastPlayed(); @@ -837,47 +811,48 @@ public class PlotMain extends JavaPlugin { */ @SuppressWarnings("deprecation") public static void configs() { - File folder = new File(getMain().getDataFolder() + File.separator - + "config"); + File folder = new File(getMain().getDataFolder() + File.separator + "config"); if (!folder.exists() && !folder.mkdirs()) { sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to create the /plugins/config folder. Please create it manually."); } try { - configFile = new File(getMain().getDataFolder() + File.separator - + "config" + File.separator + "settings.yml"); + configFile = + new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "settings.yml"); if (!configFile.exists()) { configFile.createNewFile(); } config = YamlConfiguration.loadConfiguration(configFile); setupConfig(); - } catch (Exception err_trans) { + } + catch (Exception err_trans) { Logger.add(LogLevel.DANGER, "Failed to save settings.yml"); System.out.println("Failed to save settings.yml"); } try { - storageFile = new File(getMain().getDataFolder() + File.separator - + "config" + File.separator + "storage.yml"); + storageFile = + new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "storage.yml"); if (!storageFile.exists()) { storageFile.createNewFile(); } storage = YamlConfiguration.loadConfiguration(storageFile); setupStorage(); - } catch (Exception err_trans) { + } + catch (Exception err_trans) { Logger.add(LogLevel.DANGER, "Failed to save storage.yml"); System.out.println("Failed to save storage.yml"); } try { - translationsFile = new File(getMain().getDataFolder() - + File.separator + "config" + File.separator - + "translations.yml"); + translationsFile = + new File(getMain().getDataFolder() + File.separator + "config" + File.separator + + "translations.yml"); if (!translationsFile.exists()) { translationsFile.createNewFile(); } - translations = YamlConfiguration - .loadConfiguration(translationsFile); + translations = YamlConfiguration.loadConfiguration(translationsFile); setupTranslations(); - } catch (Exception err_trans) { + } + catch (Exception err_trans) { Logger.add(LogLevel.DANGER, "Failed to save translations.yml"); System.out.println("Failed to save translations.yml"); } @@ -886,7 +861,8 @@ public class PlotMain extends JavaPlugin { config.save(configFile); storage.save(storageFile); translations.save(translationsFile); - } catch (IOException e) { + } + catch (IOException e) { Logger.add(LogLevel.DANGER, "Configuration file saving failed"); e.printStackTrace(); } @@ -922,8 +898,7 @@ public class PlotMain extends JavaPlugin { settings.put("Auto Clear Days", "" + Settings.AUTO_CLEAR_DAYS); for (Entry setting : settings.entrySet()) { sendConsoleSenderMessage(C.PREFIX.s() - + String.format("&cKey: &6%s&c, Value: &6%s", - setting.getKey(), setting.getValue())); + + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue())); } } } @@ -933,145 +908,108 @@ public class PlotMain extends JavaPlugin { */ @SuppressWarnings("deprecation") public static void killAllEntities() { - Bukkit.getScheduler().scheduleAsyncRepeatingTask(getMain(), - new Runnable() { - Location location; - long ticked = 0l; - long error = 0l; - { - sendConsoleSenderMessage(C.PREFIX.s() - + "KillAllEntities started."); - } + Bukkit.getScheduler().scheduleAsyncRepeatingTask(getMain(), new Runnable() { + Location location; + long ticked = 0l; + long error = 0l; + { + sendConsoleSenderMessage(C.PREFIX.s() + "KillAllEntities started."); + } - @Override - public void run() { - if (this.ticked > 36000l) { - this.ticked = 0l; - sendConsoleSenderMessage(C.PREFIX.s() - + "KillAllEntities has been running for 60 minutes. Errors: " - + this.error); - this.error = 0l; + @Override + public void run() { + if (this.ticked > 36000l) { + this.ticked = 0l; + sendConsoleSenderMessage(C.PREFIX.s() + "KillAllEntities has been running for 60 minutes. Errors: " + + this.error); + this.error = 0l; + } + for (String w : getPlotWorlds()) { + getWorldSettings(w); + World world = Bukkit.getServer().getWorld(w); + try { + if (world.getLoadedChunks().length < 1) { + continue; } - for (String w : getPlotWorlds()) { - getWorldSettings(w); - World world = Bukkit.getServer().getWorld(w); - try { - if (world.getLoadedChunks().length < 1) { + for (Chunk chunk : world.getLoadedChunks()) { + Entity[] entities = chunk.getEntities(); + for (int i = entities.length - 1; i >= 0; i--) { + Entity entity = entities[i]; + + if ((entity instanceof Player) || PlayerEvents.isInPlot(entity.getLocation())) { continue; } - for (Chunk chunk : world.getLoadedChunks()) { - Entity[] entities = chunk.getEntities(); - for (int i = entities.length - 1; i >= 0; i--) { - Entity entity = entities[i]; - if (!(entity instanceof Player)) { - this.location = entity - .getLocation(); - if (!PlayerEvents - .isInPlot(this.location)) { - boolean tamed = false; - if (Settings.MOB_PATHFINDING) { - if (entity instanceof Tameable) { - Tameable tameable = (Tameable) entity; - if (tameable.isTamed()) { - tamed = true; - } - } else if (entity instanceof LivingEntity) { - LivingEntity livingEntity = ((LivingEntity) entity); - if (livingEntity - .getCustomName() != null) { - tamed = true; - } - } - if (tamed) { - boolean found = false; - int radius = 1; - int dir = 0; - int x = this.location - .getBlockX(); - int y = this.location - .getBlockY(); - int z = this.location - .getBlockZ(); - while (!found - && (radius < 4)) { - Location pos; - switch (dir) { - case 0: - pos = new Location( - world, - x - + radius, - y, z); - dir++; - break; - case 1: - pos = new Location( - world, - x, - y, - z - + radius); - dir++; - break; - case 2: - pos = new Location( - world, - x - - radius, - y, z); - dir++; - break; - case 3: - pos = new Location( - world, - x, - y, - z - - radius); - dir = 0; - radius++; - break; - default: - pos = this.location; - break; - } - if (PlayerEvents - .isInPlot(pos)) { - entity.teleport(pos - .add(0.5, - 0, - 0.5)); - found = true; - break; - } - } - // Welp! how did this - // entity get - // here? - entity.teleport(this.location - .subtract(this.location - .getDirection() - .normalize() - .multiply( - 2))); - } - } - if (!tamed) { - entity.remove(); - } - } + boolean tamed = false; + if (Settings.MOB_PATHFINDING) { + if (entity instanceof Tameable) { + Tameable tameable = (Tameable) entity; + if (tameable.isTamed()) { + tamed = true; } } + else + if (entity instanceof LivingEntity) { + LivingEntity livingEntity = ((LivingEntity) entity); + if (livingEntity.getCustomName() != null) { + tamed = true; + } + } + if (!tamed) { + entity.remove(); + continue; + } + boolean found = false; + int radius = 1; + int dir = 0; + int x = this.location.getBlockX(); + int y = this.location.getBlockY(); + int z = this.location.getBlockZ(); + while (!found && (radius < 4)) { + Location pos; + switch (dir) { + case 0: + pos = new Location(world, x + radius, y, z); + dir++; + break; + case 1: + pos = new Location(world, x, y, z + radius); + dir++; + break; + case 2: + pos = new Location(world, x - radius, y, z); + dir++; + break; + case 3: + pos = new Location(world, x, y, z - radius); + dir = 0; + radius++; + break; + default: + pos = this.location; + break; + + } + if (PlayerEvents.isInPlot(pos)) { + entity.teleport(pos.add(0.5, 0, 0.5)); + found = true; + break; + } + } + entity.teleport(this.location.subtract(this.location.getDirection().normalize().multiply(2))); } - } catch (Exception e) { - ++this.error; - } finally { - ++this.ticked; } } } - }, 0l, 2l); + catch (Exception e) { + ++this.error; + } + finally { + ++this.ticked; + } + } + } + }, 0l, 2l); } /** @@ -1099,8 +1037,7 @@ public class PlotMain extends JavaPlugin { } Settings.DEBUG = config.getBoolean("debug"); if (Settings.DEBUG) { - sendConsoleSenderMessage(C.PREFIX.s() - + "&6Debug Mode Enabled (Default). Edit the config to turn this off."); + sendConsoleSenderMessage(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off."); } Web.ENABLED = config.getBoolean("web.enabled"); Web.PORT = config.getInt("web.port"); @@ -1129,68 +1066,70 @@ public class PlotMain extends JavaPlugin { try { config.save(PlotMain.configFile); - } catch (IOException e) { + } + catch (IOException e) { PlotMain.sendConsoleSenderMessage("&c[Warning] PlotSquared failed to save the configuration&7 (settings.yml may differ from the one in memory)\n - To force a save from console use /plots save"); } } - + public static void loadWorld(String world, ChunkGenerator generator) { - if (getWorldSettings(world)!=null) { - return; - } - Set worlds; - if (config.contains("worlds")) { - worlds = config.getConfigurationSection("worlds").getKeys(false); - } else { - worlds = new HashSet(); - } - if (generator!=null && generator instanceof PlotGenerator) { - sendConsoleSenderMessage(C.PREFIX.s() - + "&aDetected world load for '" + world + "'."); - PlotGenerator plotgen = (PlotGenerator) generator; - PlotWorld plotworld = plotgen.getNewPlotWorld(world); - PlotManager manager = plotgen.getPlotManager(); + if (getWorldSettings(world) != null) { + return; + } + Set worlds; + if (config.contains("worlds")) { + worlds = config.getConfigurationSection("worlds").getKeys(false); + } + else { + worlds = new HashSet(); + } + if (generator != null && generator instanceof PlotGenerator) { + sendConsoleSenderMessage(C.PREFIX.s() + "&aDetected world load for '" + world + "'."); + PlotGenerator plotgen = (PlotGenerator) generator; + PlotWorld plotworld = plotgen.getNewPlotWorld(world); + PlotManager manager = plotgen.getPlotManager(); - if (!config.contains("worlds." + world)) { - config.createSection("worlds." + world); - } - plotworld.saveConfiguration(config.getConfigurationSection("worlds." + world)); + if (!config.contains("worlds." + world)) { + config.createSection("worlds." + world); + } + plotworld.saveConfiguration(config.getConfigurationSection("worlds." + world)); - plotworld.loadDefaultConfiguration(config.getConfigurationSection("worlds." + world)); - - try { - config.save(configFile); - } catch (IOException e) { - e.printStackTrace(); - } + plotworld.loadDefaultConfiguration(config.getConfigurationSection("worlds." + world)); - addPlotWorld(world, plotworld, manager); + try { + config.save(configFile); + } + catch (IOException e) { + e.printStackTrace(); + } - } else { - if (worlds.contains(world)) { - sendConsoleSenderMessage("&cWorld '" - + world - + "' in settings.yml is not using PlotSquared generator!"); - - PlotWorld plotworld = new DefaultPlotWorld(world); - PlotManager manager = new DefaultPlotManager(); - - if (!config.contains("worlds." + world)) { - config.createSection("worlds." + world); - } - plotworld.saveConfiguration(config.getConfigurationSection("worlds." + world)); + addPlotWorld(world, plotworld, manager); - plotworld.loadConfiguration(config.getConfigurationSection("worlds." + world)); - - try { - config.save(configFile); - } catch (IOException e) { - e.printStackTrace(); - } + } + else { + if (worlds.contains(world)) { + sendConsoleSenderMessage("&cWorld '" + world + "' in settings.yml is not using PlotSquared generator!"); - addPlotWorld(world, plotworld, manager); - } - } + PlotWorld plotworld = new DefaultPlotWorld(world); + PlotManager manager = new DefaultPlotManager(); + + if (!config.contains("worlds." + world)) { + config.createSection("worlds." + world); + } + plotworld.saveConfiguration(config.getConfigurationSection("worlds." + world)); + + plotworld.loadConfiguration(config.getConfigurationSection("worlds." + world)); + + try { + config.save(configFile); + } + catch (IOException e) { + e.printStackTrace(); + } + + addPlotWorld(world, plotworld, manager); + } + } } /** @@ -1251,13 +1190,15 @@ public class PlotMain extends JavaPlugin { Logger.add(LogLevel.GENERAL, "Logger disabled"); try { Logger.write(); - } catch (IOException e1) { + } + catch (IOException e1) { e1.printStackTrace(); } try { connection.close(); mySQL.closeConnection(); - } catch (NullPointerException | SQLException e) { + } + catch (NullPointerException | SQLException e) { if (connection != null) { Logger.add(LogLevel.DANGER, "Could not close mysql connection"); } @@ -1268,8 +1209,7 @@ public class PlotMain extends JavaPlugin { */ } - public static void addPlotWorld(String world, PlotWorld plotworld, - PlotManager manager) { + public static void addPlotWorld(String world, PlotWorld plotworld, PlotManager manager) { worlds.put(world, plotworld); managers.put(world, manager); if (!plots.containsKey(world)) { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotManager.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotManager.java index 3e9f1ab65..02b0def96 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotManager.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotManager.java @@ -18,12 +18,10 @@ public abstract class PlotManager { public abstract PlotId getPlotId(PlotWorld plotworld, Location loc); - public abstract boolean isInPlotAbs(PlotWorld plotworld, Location loc, - PlotId plotid); + public abstract boolean isInPlotAbs(PlotWorld plotworld, Location loc, PlotId plotid); // If you have a circular plot, just return the corner if it were a square - public abstract Location getPlotBottomLocAbs(PlotWorld plotworld, - PlotId plotid); + public abstract Location getPlotBottomLocAbs(PlotWorld plotworld, PlotId plotid); // the same applies here public abstract Location getPlotTopLocAbs(PlotWorld plotworld, PlotId plotid); @@ -34,19 +32,16 @@ public abstract class PlotManager { public abstract boolean clearPlot(Player player, Plot plot); - public abstract Location getSignLoc(Player player, PlotWorld plotworld, - Plot plot); + public abstract Location getSignLoc(Player player, PlotWorld plotworld, Plot plot); /* * Plot set functions (return false if you do not support the specific set * method) */ - public abstract boolean setWall(Player player, PlotWorld plotworld, - PlotId plotid, PlotBlock block); + public abstract boolean setWall(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock block); - public abstract boolean setFloor(Player player, PlotWorld plotworld, - PlotId plotid, PlotBlock[] block); + public abstract boolean setFloor(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock[] block); public abstract boolean setBiome(Player player, Plot plot, Biome biome); @@ -66,7 +61,6 @@ public abstract class PlotManager { public abstract boolean removeRoadSouthEast(PlotWorld plotworld, Plot plot); - public abstract boolean finishPlotMerge(World world, PlotWorld plotworld, - ArrayList plotIds); + public abstract boolean finishPlotMerge(World world, PlotWorld plotworld, ArrayList plotIds); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotSettings.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotSettings.java index e2b414456..1006a873c 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotSettings.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotSettings.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlotSettings.java - * >> Generated by: Citymonstret at 2014-08-09 01:44 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlotSettings.java >> Generated by: Citymonstret at 2014-08-09 01:44 */ package com.intellectualcrafters.plot; @@ -19,7 +18,6 @@ import org.bukkit.block.Biome; * plot settings * * @author Citymonstret - * */ public class PlotSettings { /** @@ -92,7 +90,6 @@ public class PlotSettings { } /** - * * @param b */ public void setBiome(Biome b) { @@ -100,7 +97,6 @@ public class PlotSettings { } /** - * * @param b */ public void setTimeChange(boolean b) { @@ -108,7 +104,6 @@ public class PlotSettings { } /** - * * @param l */ public void setTime(long l) { @@ -116,7 +111,6 @@ public class PlotSettings { } /** - * * @return * @deprecated */ @@ -126,7 +120,6 @@ public class PlotSettings { } /** - * * @return */ public boolean getRain() { @@ -138,7 +131,6 @@ public class PlotSettings { } /** - * * @return */ public long getTime() { @@ -146,7 +138,6 @@ public class PlotSettings { } /** - * * @return */ public boolean getChangeTime() { @@ -154,7 +145,6 @@ public class PlotSettings { } /** - * * @param alias */ public void setAlias(String alias) { @@ -162,7 +152,6 @@ public class PlotSettings { } /** - * * @param flag */ public void addFlag(Flag flag) { @@ -174,7 +163,6 @@ public class PlotSettings { } /** - * * @param flags */ public void setFlags(Flag[] flags) { @@ -182,7 +170,6 @@ public class PlotSettings { } /** - * * @return */ public Set getFlags() { @@ -190,7 +177,6 @@ public class PlotSettings { } /** - * * @param flag * @return */ diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotSquaredException.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotSquaredException.java index 2de367dfd..3414f3e2c 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotSquaredException.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotSquaredException.java @@ -7,8 +7,7 @@ public class PlotSquaredException extends RuntimeException { public PlotSquaredException(PlotError error, String details) { super("PlotError >> " + error.getHeader() + ": " + details); - PlotMain.sendConsoleSenderMessage("&cPlotError &6>> &c" - + error.getHeader() + ": &6" + details); + PlotMain.sendConsoleSenderMessage("&cPlotError &6>> &c" + error.getHeader() + ": &6" + details); } public static enum PlotError { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java index 519e0312c..1a7b1dc44 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java @@ -97,28 +97,18 @@ public abstract class PlotWorld { // TODO make this configurable // make non static and static_default_valu + add config option - public static ArrayList BLOCKS = new ArrayList( - Arrays.asList(new Material[] { ACACIA_STAIRS, BEACON, BEDROCK, - BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, - BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON, - CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, - COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS, - DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, - DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE, - ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, - FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, - GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, - HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, - JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE, - LEAVES, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER, - MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK, - NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN, - PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE, - QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND, - SANDSTONE_STAIRS, SMOOTH_BRICK, SMOOTH_STAIRS, SNOW_BLOCK, - SOUL_SAND, SPONGE, SPRUCE_WOOD_STAIRS, STONE, WOOD, - WOOD_STAIRS, WORKBENCH, WOOL, getMaterial(44), - getMaterial(126) })); + public static ArrayList BLOCKS = new ArrayList(Arrays.asList(new Material[] { ACACIA_STAIRS, + BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE, + CAKE_BLOCK, CAULDRON, CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, COBBLESTONE, COBBLESTONE_STAIRS, + COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER, + EMERALD_BLOCK, EMERALD_ORE, ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, FURNACE, GLOWSTONE, + GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, HUGE_MUSHROOM_2, + IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE, LEAVES, + LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER, MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK, + NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN, PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE, + QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND, SANDSTONE_STAIRS, SMOOTH_BRICK, SMOOTH_STAIRS, SNOW_BLOCK, + SOUL_SAND, SPONGE, SPRUCE_WOOD_STAIRS, STONE, WOOD, WOOD_STAIRS, WORKBENCH, WOOL, getMaterial(44), + getMaterial(126) })); public boolean AUTO_MERGE; public static boolean AUTO_MERGE_DEFAULT = false; @@ -172,12 +162,10 @@ public abstract class PlotWorld { public void loadDefaultConfiguration(ConfigurationSection config) { this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning"); this.AUTO_MERGE = config.getBoolean("plot.auto_merge"); - this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config - .getString("plot.biome")); + this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config.getString("plot.biome")); this.SCHEMATIC_ON_CLAIM = config.getBoolean("schematic.on_claim"); this.SCHEMATIC_FILE = config.getString("schematic.file"); - this.SCHEMATIC_CLAIM_SPECIFY = config - .getBoolean("schematic.specify_on_claim"); + this.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("schematic.specify_on_claim"); this.SCHEMATICS = config.getStringList("schematic.schematics"); this.USE_ECONOMY = config.getBoolean("economy.use"); this.PLOT_PRICE = config.getDouble("economy.prices.claim"); @@ -187,7 +175,7 @@ public abstract class PlotWorld { this.DEFAULT_FLAGS = config.getStringList("flags.default"); loadConfiguration(config); } - + public abstract void loadConfiguration(ConfigurationSection config); public void saveConfiguration(ConfigurationSection config) { @@ -195,22 +183,22 @@ public abstract class PlotWorld { /* * Saving core plotworld settings */ - - HashMap options = new HashMap(); - - options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT); - options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT); - options.put("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT.toString()); - options.put("schematic.on_claim", PlotWorld.SCHEMATIC_ON_CLAIM_DEFAULT); - options.put("schematic.file", PlotWorld.SCHEMATIC_FILE_DEFAULT); - options.put("schematic.specify_on_claim", PlotWorld.SCHEMATIC_CLAIM_SPECIFY_DEFAULT); - options.put("schematic.schematics", PlotWorld.SCHEMATICS_DEFAULT); - options.put("economy.use", PlotWorld.USE_ECONOMY_DEFAULT); - options.put("economy.prices.claim", PlotWorld.PLOT_PRICE_DEFAULT); - options.put("economy.prices.merge", PlotWorld.MERGE_PRICE_DEFAULT); - options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT); - options.put("chat.enabled", PlotWorld.PLOT_CHAT_DEFAULT); - options.put("flags.default", PlotWorld.DEFAULT_FLAGS_DEFAULT); + + HashMap options = new HashMap(); + + options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT); + options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT); + options.put("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT.toString()); + options.put("schematic.on_claim", PlotWorld.SCHEMATIC_ON_CLAIM_DEFAULT); + options.put("schematic.file", PlotWorld.SCHEMATIC_FILE_DEFAULT); + options.put("schematic.specify_on_claim", PlotWorld.SCHEMATIC_CLAIM_SPECIFY_DEFAULT); + options.put("schematic.schematics", PlotWorld.SCHEMATICS_DEFAULT); + options.put("economy.use", PlotWorld.USE_ECONOMY_DEFAULT); + options.put("economy.prices.claim", PlotWorld.PLOT_PRICE_DEFAULT); + options.put("economy.prices.merge", PlotWorld.MERGE_PRICE_DEFAULT); + options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT); + options.put("chat.enabled", PlotWorld.PLOT_CHAT_DEFAULT); + options.put("flags.default", PlotWorld.DEFAULT_FLAGS_DEFAULT); ConfigurationNode[] settings = getSettingNodes(); @@ -220,11 +208,11 @@ public abstract class PlotWorld { for (ConfigurationNode setting : settings) { options.put(setting.getConstant(), setting.getType().parseObject(setting.getValue())); } - - for (String option:options.keySet()) { - if (!config.contains(option)) { - config.set(option, options.get(option)); - } + + for (String option : options.keySet()) { + if (!config.contains(option)) { + config.set(option, options.get(option)); + } } } @@ -237,4 +225,4 @@ public abstract class PlotWorld { * @return ConfigurationNode[] */ public abstract ConfigurationNode[] getSettingNodes(); -} \ No newline at end of file +} diff --git a/PlotSquared/src/com/intellectualcrafters/plot/RUtils.java b/PlotSquared/src/com/intellectualcrafters/plot/RUtils.java index 427e0fad5..2796ac98a 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/RUtils.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/RUtils.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = RUtils.java - * >> Generated by: Citymonstret at 2014-08-09 01:44 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = RUtils.java >> Generated by: Citymonstret at 2014-08-09 01:44 */ package com.intellectualcrafters.plot; @@ -16,7 +15,6 @@ import org.bukkit.entity.Player; * Random utilities * * @author Citymonstret - * */ public class RUtils { @@ -43,12 +41,14 @@ public class RUtils { String s_h = (int) h + " " + ((int) h != 1 ? "hours" : "hour"); String s_m = (int) m + " " + ((int) m != 1 ? "minutes" : "minute"); String s_s = (int) s + " " + ((int) s != 1 ? "seconds" : "second"); - return string.replaceAll("%sec%", s_s).replaceAll("%min%", s_m) - .replaceAll("%hours%", s_h); + return string.replaceAll("%sec%", s_s).replaceAll("%min%", s_m).replaceAll("%hours%", s_h); } enum Direction { - SOUTH(0), EAST(1), NORTH(2), WEST(3); + SOUTH(0), + EAST(1), + NORTH(2), + WEST(3); private int i; Direction(int i) { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/ReflectionUtils.java b/PlotSquared/src/com/intellectualcrafters/plot/ReflectionUtils.java index e9796b46f..4b75ea561 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/ReflectionUtils.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/ReflectionUtils.java @@ -27,8 +27,7 @@ public class ReflectionUtils { /** check server version and class names */ static { if (Bukkit.getServer() != null) { - if (Bukkit.getVersion().contains("MCPC") - || Bukkit.getVersion().contains("Forge")) { + if (Bukkit.getVersion().contains("MCPC") || Bukkit.getVersion().contains("Forge")) { forge = true; } Server server = Bukkit.getServer(); @@ -39,8 +38,7 @@ public class ReflectionUtils { preClassB += "." + verB; } try { - Method getHandle = bukkitServerClass - .getDeclaredMethod("getHandle"); + Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle"); Object handle = getHandle.invoke(server); Class handleServerClass = handle.getClass(); pas = handleServerClass.getName().split("\\."); @@ -48,7 +46,8 @@ public class ReflectionUtils { String verM = pas[3]; preClassM += "." + verM; } - } catch (Exception ignored) { + } + catch (Exception ignored) { } } } @@ -73,11 +72,11 @@ public class ReflectionUtils { public static RefClass getRefClass(String... classes) { for (String className : classes) { try { - className = className.replace("{cb}", preClassB) - .replace("{nms}", preClassM) - .replace("{nm}", "net.minecraft"); + className = + className.replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft"); return getRefClass(Class.forName(className)); - } catch (ClassNotFoundException ignored) { + } + catch (ClassNotFoundException ignored) { } } throw new RuntimeException("no class found"); @@ -135,27 +134,30 @@ public class ReflectionUtils { * @throws RuntimeException * if method not found */ - public RefMethod getMethod(String name, Object... types) - throws NoSuchMethodException { + public RefMethod getMethod(String name, Object... types) throws NoSuchMethodException { try { Class[] classes = new Class[types.length]; int i = 0; for (Object e : types) { if (e instanceof Class) { classes[i++] = (Class) e; - } else if (e instanceof RefClass) { - classes[i++] = ((RefClass) e).getRealClass(); - } else { - classes[i++] = e.getClass(); } + else + if (e instanceof RefClass) { + classes[i++] = ((RefClass) e).getRealClass(); + } + else { + classes[i++] = e.getClass(); + } } try { return new RefMethod(this.clazz.getMethod(name, classes)); - } catch (NoSuchMethodException ignored) { - return new RefMethod(this.clazz.getDeclaredMethod(name, - classes)); } - } catch (Exception e) { + catch (NoSuchMethodException ignored) { + return new RefMethod(this.clazz.getDeclaredMethod(name, classes)); + } + } + catch (Exception e) { throw new RuntimeException(e); } } @@ -176,20 +178,23 @@ public class ReflectionUtils { for (Object e : types) { if (e instanceof Class) { classes[i++] = (Class) e; - } else if (e instanceof RefClass) { - classes[i++] = ((RefClass) e).getRealClass(); - } else { - classes[i++] = e.getClass(); } + else + if (e instanceof RefClass) { + classes[i++] = ((RefClass) e).getRealClass(); + } + else { + classes[i++] = e.getClass(); + } } try { - return new RefConstructor( - this.clazz.getConstructor(classes)); - } catch (NoSuchMethodException ignored) { - return new RefConstructor( - this.clazz.getDeclaredConstructor(classes)); + return new RefConstructor(this.clazz.getConstructor(classes)); } - } catch (Exception e) { + catch (NoSuchMethodException ignored) { + return new RefConstructor(this.clazz.getDeclaredConstructor(classes)); + } + } + catch (Exception e) { throw new RuntimeException(e); } } @@ -209,16 +214,20 @@ public class ReflectionUtils { for (Object e : types) { if (e instanceof Class) { classes[t++] = (Class) e; - } else if (e instanceof RefClass) { - classes[t++] = ((RefClass) e).getRealClass(); - } else { - classes[t++] = e.getClass(); } + else + if (e instanceof RefClass) { + classes[t++] = ((RefClass) e).getRealClass(); + } + else { + classes[t++] = e.getClass(); + } } List methods = new ArrayList<>(); Collections.addAll(methods, this.clazz.getMethods()); Collections.addAll(methods, this.clazz.getDeclaredMethods()); - findMethod: for (Method m : methods) { + findMethod: + for (Method m : methods) { Class[] methodTypes = m.getParameterTypes(); if (methodTypes.length != classes.length) { continue; @@ -305,8 +314,7 @@ public class ReflectionUtils { public RefConstructor findConstructor(int number) { List constructors = new ArrayList<>(); Collections.addAll(constructors, this.clazz.getConstructors()); - Collections.addAll(constructors, - this.clazz.getDeclaredConstructors()); + Collections.addAll(constructors, this.clazz.getDeclaredConstructors()); for (Constructor m : constructors) { if (m.getParameterTypes().length == number) { return new RefConstructor(m); @@ -328,10 +336,12 @@ public class ReflectionUtils { try { try { return new RefField(this.clazz.getField(name)); - } catch (NoSuchFieldException ignored) { + } + catch (NoSuchFieldException ignored) { return new RefField(this.clazz.getDeclaredField(name)); } - } catch (Exception e) { + } + catch (Exception e) { throw new RuntimeException(e); } } @@ -427,7 +437,8 @@ public class ReflectionUtils { public Object call(Object... params) { try { return this.method.invoke(null, params); - } catch (Exception e) { + } + catch (Exception e) { throw new RuntimeException(e); } } @@ -451,7 +462,8 @@ public class ReflectionUtils { public Object call(Object... params) { try { return RefMethod.this.method.invoke(this.e, params); - } catch (Exception e) { + } + catch (Exception e) { throw new RuntimeException(e); } } @@ -495,7 +507,8 @@ public class ReflectionUtils { public Object create(Object... params) { try { return this.constructor.newInstance(params); - } catch (Exception e) { + } + catch (Exception e) { throw new RuntimeException(e); } } @@ -557,7 +570,8 @@ public class ReflectionUtils { public void set(Object param) { try { RefField.this.field.set(this.e, param); - } catch (Exception e) { + } + catch (Exception e) { throw new RuntimeException(e); } } @@ -570,7 +584,8 @@ public class ReflectionUtils { public Object get() { try { return RefField.this.field.get(this.e); - } catch (Exception e) { + } + catch (Exception e) { throw new RuntimeException(e); } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/SchematicHandler.java b/PlotSquared/src/com/intellectualcrafters/plot/SchematicHandler.java index bcfc377f5..c502d1290 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/SchematicHandler.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/SchematicHandler.java @@ -31,19 +31,17 @@ public class SchematicHandler { return false; } try { - EditSession session = new EditSession(new BukkitWorld( - location.getWorld()), 999999999); - CuboidClipboard clipboard = CuboidClipboard.loadSchematic(schematic - .getFile()); - Location l1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), - plot.getId()); + EditSession session = new EditSession(new BukkitWorld(location.getWorld()), 999999999); + CuboidClipboard clipboard = CuboidClipboard.loadSchematic(schematic.getFile()); + Location l1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId()); PlotHelper.getPlotTopLoc(plot.getWorld(), plot.getId()); int x = l1.getBlockX() + 1; int z = l1.getBlockZ() + 1; int y = location.getWorld().getHighestBlockYAt(x, z); Vector v1 = new Vector(x, y + 1, z); clipboard.paste(session, v1, true); - } catch (Exception e) { + } + catch (Exception e) { return false; } return true; @@ -51,35 +49,30 @@ public class SchematicHandler { public Schematic getSchematic(String name) { { - File parent = new File(JavaPlugin.getPlugin(PlotMain.class) - .getDataFolder() + File.separator + "schematics"); + File parent = + new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics"); if (!parent.exists()) { parent.mkdir(); } } - File file = new File(JavaPlugin.getPlugin(PlotMain.class) - .getDataFolder() - + File.separator - + "schematics" - + File.separator + name + ".schematic"); + File file = + new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics" + + File.separator + name + ".schematic"); if (!file.exists()) { - PlotMain.sendConsoleSenderMessage(file.toString() - + " doesn't exist"); + PlotMain.sendConsoleSenderMessage(file.toString() + " doesn't exist"); return null; } Schematic schematic = null; try { InputStream iStream = new FileInputStream(file); - NBTInputStream stream = new NBTInputStream(new GZIPInputStream( - iStream)); + NBTInputStream stream = new NBTInputStream(new GZIPInputStream(iStream)); CompoundTag tag = (CompoundTag) stream.readTag(); Map tagMap = tag.getValue(); byte[] addId = new byte[0]; if (tagMap.containsKey("AddBlocks")) { - addId = ByteArrayTag.class.cast(tagMap.get("AddBlocks")) - .getValue(); + addId = ByteArrayTag.class.cast(tagMap.get("AddBlocks")).getValue(); } short width = ShortTag.class.cast(tagMap.get("Width")).getValue(); @@ -94,12 +87,14 @@ public class SchematicHandler { for (int index = 0; index < b.length; index++) { if ((index >> 1) >= addId.length) { // No corresponding - // AddBlocks index + // AddBlocks index blocks[index] = (short) (b[index] & 0xFF); - } else { + } + else { if ((index & 1) == 0) { blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (b[index] & 0xFF)); - } else { + } + else { blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (b[index] & 0xFF)); } } @@ -112,10 +107,12 @@ public class SchematicHandler { } schematic = new Schematic(collection, dimension, file); - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); return null; - } finally { + } + finally { return schematic; } } @@ -125,8 +122,7 @@ public class SchematicHandler { private Dimension schematicDimension; private File file; - public Schematic(DataCollection[] blockCollection, - Dimension schematicDimension, File file) { + public Schematic(DataCollection[] blockCollection, Dimension schematicDimension, File file) { this.blockCollection = blockCollection; this.schematicDimension = schematicDimension; this.file = file; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/SetBlockFast.java b/PlotSquared/src/com/intellectualcrafters/plot/SetBlockFast.java index c520befc5..9ac39712d 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/SetBlockFast.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/SetBlockFast.java @@ -8,10 +8,8 @@ import com.intellectualcrafters.plot.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.ReflectionUtils.RefMethod; /** - * * SetBlockFast class
* Used to do fast world editing - * */ public class SetBlockFast { @@ -27,15 +25,12 @@ public class SetBlockFast { public SetBlockFast() throws NoSuchMethodException { methodGetHandle = classCraftWorld.getMethod("getHandle"); - methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, - int.class); - methodA = classChunk.getMethod("a", int.class, int.class, int.class, - classBlock, int.class); + methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class); + methodA = classChunk.getMethod("a", int.class, int.class, int.class, classBlock, int.class); methodGetById = classBlock.getMethod("getById", int.class); } - public static boolean set(org.bukkit.World world, int x, int y, int z, - int blockId, byte data) throws NoSuchMethodException { + public static boolean set(org.bukkit.World world, int x, int y, int z, int blockId, byte data) throws NoSuchMethodException { Object w = methodGetHandle.of(world).call(); Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4); @@ -48,9 +43,8 @@ public class SetBlockFast { int distance = Bukkit.getViewDistance() + 1; for (int cx = -distance; cx < distance; cx++) { for (int cz = -distance; cz < distance; cz++) { - player.getWorld().refreshChunk( - player.getLocation().getChunk().getX() + cx, - player.getLocation().getChunk().getZ() + cz); + player.getWorld().refreshChunk(player.getLocation().getChunk().getX() + cx, player.getLocation().getChunk().getZ() + + cz); } } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Settings.java b/PlotSquared/src/com/intellectualcrafters/plot/Settings.java index ba35b500b..eeeaa96fd 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Settings.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Settings.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Settings.java - * >> Generated by: Citymonstret at 2014-08-09 01:44 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Settings.java >> Generated by: Citymonstret at 2014-08-09 01:44 */ package com.intellectualcrafters.plot; @@ -13,7 +12,6 @@ package com.intellectualcrafters.plot; * Updater and DB settings * * @author Citymonstret - * * @author Empire92 */ public class Settings { @@ -50,7 +48,6 @@ public class Settings { * Update settings * * @author Citymonstret - * */ public static String URL = "http://dev.bukkit.org/bukkit-plugins/plotsquared/"; @@ -78,7 +75,6 @@ public class Settings { * Database settings * * @author Citymonstret - * */ public static class DB { public static boolean USE_MONGO = false; /* diff --git a/PlotSquared/src/com/intellectualcrafters/plot/Title.java b/PlotSquared/src/com/intellectualcrafters/plot/Title.java index c07c05ecc..9459b3a38 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/Title.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/Title.java @@ -80,8 +80,7 @@ public class Title { * @param fadeOutTime * Fade out time */ - public Title(String title, String subtitle, int fadeInTime, int stayTime, - int fadeOutTime) { + public Title(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) { this.title = title; this.subtitle = subtitle; this.fadeInTime = fadeInTime; @@ -170,59 +169,44 @@ public class Title { * Player */ public void send(Player player) { - if ((getProtocolVersion(player) >= 47) && isSpigot() - && (this.packetTitle != null)) { + if ((getProtocolVersion(player) >= 47) && isSpigot() && (this.packetTitle != null)) { // First reset previous settings resetTitle(player); try { // Send timings first Object handle = getHandle(player); - Object connection = getField(handle.getClass(), - "playerConnection").get(handle); + Object connection = getField(handle.getClass(), "playerConnection").get(handle); Object[] actions = this.packetActions.getEnumConstants(); - Method sendPacket = getMethod(connection.getClass(), - "sendPacket"); - Object packet = this.packetTitle.getConstructor( - this.packetActions, Integer.TYPE, Integer.TYPE, - Integer.TYPE).newInstance(actions[2], - this.fadeInTime * (this.ticks ? 1 : 20), - this.stayTime * (this.ticks ? 1 : 20), - this.fadeOutTime * (this.ticks ? 1 : 20)); + Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + Object packet = + this.packetTitle.getConstructor(this.packetActions, Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(actions[2], 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)) { + if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) { sendPacket.invoke(connection, packet); } // Send title - Object serialized = getMethod(this.nmsChatSerializer, "a", - String.class).invoke( - null, - "{text:\"" - + ChatColor.translateAlternateColorCodes('&', - this.title) + "\",color:" + Object serialized = + getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, "{text:\"" + + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}"); - packet = this.packetTitle.getConstructor(this.packetActions, - getNMSClass("IChatBaseComponent")).newInstance( - actions[0], serialized); + packet = + this.packetTitle.getConstructor(this.packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[0], serialized); sendPacket.invoke(connection, packet); if (!this.subtitle.equals("")) { // Send subtitle if present - serialized = getMethod(this.nmsChatSerializer, "a", - String.class).invoke( - null, - "{text:\"" - + ChatColor.translateAlternateColorCodes( - '&', this.subtitle) + "\",color:" - + this.subtitleColor.name().toLowerCase() - + "}"); - packet = this.packetTitle.getConstructor( - this.packetActions, - getNMSClass("IChatBaseComponent")).newInstance( - actions[1], serialized); + serialized = + getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, "{text:\"" + + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + + this.subtitleColor.name().toLowerCase() + "}"); + packet = + this.packetTitle.getConstructor(this.packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[1], serialized); sendPacket.invoke(connection, packet); } - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); } } @@ -248,15 +232,13 @@ public class Title { try { // Send timings first Object handle = getHandle(player); - Object connection = getField(handle.getClass(), - "playerConnection").get(handle); + Object connection = getField(handle.getClass(), "playerConnection").get(handle); Object[] actions = this.packetActions.getEnumConstants(); - Method sendPacket = getMethod(connection.getClass(), - "sendPacket"); - Object packet = this.packetTitle.getConstructor( - this.packetActions).newInstance(actions[3]); + Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[3]); sendPacket.invoke(connection, packet); - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); } } @@ -273,15 +255,13 @@ public class Title { try { // Send timings first Object handle = getHandle(player); - Object connection = getField(handle.getClass(), - "playerConnection").get(handle); + Object connection = getField(handle.getClass(), "playerConnection").get(handle); Object[] actions = this.packetActions.getEnumConstants(); - Method sendPacket = getMethod(connection.getClass(), - "sendPacket"); - Object packet = this.packetTitle.getConstructor( - this.packetActions).newInstance(actions[4]); + Method sendPacket = getMethod(connection.getClass(), "sendPacket"); + Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[4]); sendPacket.invoke(connection, packet); - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); } } @@ -298,14 +278,13 @@ public class Title { int version = 0; try { Object handle = getHandle(player); - Object connection = getField(handle.getClass(), "playerConnection") - .get(handle); + Object connection = getField(handle.getClass(), "playerConnection").get(handle); Object networkManager = getValue("networkManager", connection); - version = (Integer) getMethod("getVersion", - networkManager.getClass()).invoke(networkManager); + version = (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager); return version; - } catch (Exception ex) { + } + catch (Exception ex) { // ex.printStackTrace(); <-- spammy console } return version; @@ -330,7 +309,8 @@ public class Title { private Class getClass(String namespace) { try { return Class.forName(namespace); - } catch (Exception e) { + } + catch (Exception e) { return null; } } @@ -346,8 +326,7 @@ public class Title { } private Class getPrimitiveType(Class clazz) { - return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES - .get(clazz) : clazz; + return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz; } private Class[] toPrimitiveTypeArray(Class[] classes) { @@ -374,14 +353,14 @@ public class Title { private Object getHandle(Object obj) { try { return getMethod("getHandle", obj.getClass()).invoke(obj); - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); return null; } } - private Method getMethod(String name, Class clazz, - Class... paramTypes) { + private Method getMethod(String name, Class clazz, Class... paramTypes) { Class[] t = toPrimitiveTypeArray(paramTypes); for (Method m : clazz.getMethods()) { Class[] types = toPrimitiveTypeArray(m.getParameterTypes()); @@ -402,7 +381,8 @@ public class Title { Class clazz = null; try { clazz = Class.forName(fullName); - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); } return clazz; @@ -413,7 +393,8 @@ public class Title { Field field = clazz.getDeclaredField(name); field.setAccessible(true); return field; - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); return null; } @@ -421,9 +402,7 @@ public class Title { private Method getMethod(Class clazz, String name, Class... args) { for (Method m : clazz.getMethods()) { - if (m.getName().equals(name) - && ((args.length == 0) || ClassListEqual(args, - m.getParameterTypes()))) { + if (m.getName().equals(name) && ((args.length == 0) || ClassListEqual(args, m.getParameterTypes()))) { m.setAccessible(true); return m; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/UUIDHandler.java b/PlotSquared/src/com/intellectualcrafters/plot/UUIDHandler.java index 8c94c585f..b80ec5bbf 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/UUIDHandler.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/UUIDHandler.java @@ -18,8 +18,8 @@ import com.intellectualcrafters.plot.uuid.UUIDFetcher; public class UUIDHandler { - private static boolean online = Bukkit.getServer().getOnlineMode(); - + private static boolean online = Bukkit.getServer().getOnlineMode(); + private static BiMap uuidMap = HashBiMap.create(); public static boolean uuidExists(UUID uuid) { @@ -35,43 +35,35 @@ public class UUIDHandler { } /** - * * @param plugin */ public static void startFetch(JavaPlugin plugin) { - plugin.getServer().getScheduler() - .runTaskAsynchronously(plugin, new Runnable() { - @Override - public void run() { - OfflinePlayer[] offlinePlayers = Bukkit - .getOfflinePlayers(); - int length = offlinePlayers.length; - long start = System.currentTimeMillis(); + plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { + @Override + public void run() { + OfflinePlayer[] offlinePlayers = Bukkit.getOfflinePlayers(); + int length = offlinePlayers.length; + long start = System.currentTimeMillis(); - String name; - UUID uuid; - for (OfflinePlayer player : offlinePlayers) { - uuid = player.getUniqueId(); - if (!uuidExists(uuid)) { - name = player.getName(); - add(name, uuid); - } - } - - long time = System.currentTimeMillis() - start; - PlotMain.sendConsoleSenderMessage("&cFinished caching of offlineplayers! Took &6" - + time - + "&cms, &6" - + length - + " &cUUID's were cached" - + " and there is now a grand total of &6" - + uuidMap.size() + " &ccached."); + String name; + UUID uuid; + for (OfflinePlayer player : offlinePlayers) { + uuid = player.getUniqueId(); + if (!uuidExists(uuid)) { + name = player.getName(); + add(name, uuid); } - }); + } + + long time = System.currentTimeMillis() - start; + PlotMain.sendConsoleSenderMessage("&cFinished caching of offlineplayers! Took &6" + time + "&cms, &6" + + length + " &cUUID's were cached" + " and there is now a grand total of &6" + uuidMap.size() + + " &ccached."); + } + }); } /** - * * @param name * @return */ @@ -91,33 +83,33 @@ public class UUIDHandler { UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name)); uuid = fetcher.call().get(name); add(name, uuid); - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); } - } else { + } + else { return getUuidOfflineMode(name); } return null; } /** - * * @param uuid * @return */ private static String loopSearch(UUID uuid) { - return uuidMap.inverse().get(uuid); + return uuidMap.inverse().get(uuid); } /** - * * @param uuid * @return */ public static String getName(UUID uuid) { - if (uuidExists(uuid)) { - return loopSearch(uuid); - } + if (uuidExists(uuid)) { + return loopSearch(uuid); + } String name; if ((name = getNameOnlinePlayer(uuid)) != null) { return name; @@ -131,29 +123,28 @@ public class UUIDHandler { name = fetcher.call().get(uuid); add(name, uuid); return name; - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); } - } else { + } + else { return "unknown"; } return ""; } /** - * * @param name * @return */ private static UUID getUuidOfflineMode(String name) { - UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name) - .getBytes(Charsets.UTF_8)); + UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)); add(name, uuid); return uuid; } /** - * * @param uuid * @return */ @@ -168,7 +159,6 @@ public class UUIDHandler { } /** - * * @param uuid * @return */ @@ -183,7 +173,6 @@ public class UUIDHandler { } /** - * * @param name * @return */ @@ -198,12 +187,11 @@ public class UUIDHandler { } /** - * * @param name * @return */ private static UUID getUuidOfflinePlayer(String name) { - UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)); + UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)); add(name, uuid); return uuid; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/api/PlotAPI.java b/PlotSquared/src/com/intellectualcrafters/plot/api/PlotAPI.java index eda11daf5..b89bac7f0 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/api/PlotAPI.java @@ -1,15 +1,13 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlotAPI.java - * >> Generated by: Citymonstret at 2014-08-09 01:44 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlotAPI.java >> Generated by: Citymonstret at 2014-08-09 01:44 */ package com.intellectualcrafters.plot.api; - import java.util.ArrayList; import java.util.Set; @@ -40,35 +38,35 @@ import com.intellectualcrafters.plot.commands.SubCommand; */ @SuppressWarnings({ "unused", "javadoc" }) public class PlotAPI { - + private static PlotHelper plotHelper; private static PlayerFunctions playerFunctions; private static FlagManager flagManager; private static SchematicHandler schematicHandler; private static C c; - + // Methods/fields in PlotMain class - // PlotMain.config; - // PlotMain.storage - // PlotMain.translations - // PlotMain.addPlotWorld(world, plotworld, manager); - // - // PlotMain.checkForExpiredPlots(); - // PlotMain.killAllEntities(); - // - // PlotMain.createConfiguration(plotworld); - // PlotMain.getPlots() - // PlotMain.getPlots(player) - // PlotMain.getPlots(world) - // PlotMain.getPlots(world, player) - // PlotMain.getWorldPlots(world) - // PlotMain.getPlotWorlds() - // PlotMain.isPlotWorld(world) - // PlotMain.removePlot(world, id, callEvent) - // PlotMain.teleportPlayer(player, from, plot) - // PlotMain.updatePlot(plot); - + // PlotMain.config; + // PlotMain.storage + // PlotMain.translations + // PlotMain.addPlotWorld(world, plotworld, manager); + // + // PlotMain.checkForExpiredPlots(); + // PlotMain.killAllEntities(); + // + // PlotMain.createConfiguration(plotworld); + // PlotMain.getPlots() + // PlotMain.getPlots(player) + // PlotMain.getPlots(world) + // PlotMain.getPlots(world, player) + // PlotMain.getWorldPlots(world) + // PlotMain.getPlotWorlds() + // PlotMain.isPlotWorld(world) + // PlotMain.removePlot(world, id, callEvent) + // PlotMain.teleportPlayer(player, from, plot) + // PlotMain.updatePlot(plot); + // To access plotMain stuff. private PlotMain plotMain; // Reference @@ -82,18 +80,17 @@ public class PlotAPI { public PlotAPI(JavaPlugin plugin) { this.plotMain = JavaPlugin.getPlugin(PlotMain.class); } - + /** * Get the main class for this plugin
- * - Contains a lot of fields and methods - * - not very well organized + * - Contains a lot of fields and methods - not very well organized * * @return */ public PlotMain getMain() { return plotMain; } - + /** * PlotHelper class contains useful methods relating to plots. * @@ -102,26 +99,26 @@ public class PlotAPI { public PlotHelper getPlotHelper() { return plotHelper; } - + /** - * PlayerFunctions class contains useful methods relating to players - * - Some player/plot methods are here as well + * PlayerFunctions class contains useful methods relating to players - Some + * player/plot methods are here as well * * @return */ public PlayerFunctions getPlayerFunctions() { return playerFunctions; } - + /** - * FlagManager class contains methods relating to plot flags + * FlagManager class contains methods relating to plot flags * * @return */ public FlagManager getFlagManager() { return flagManager; } - + /** * SchematicHandler class contains methods related to pasting schematics * @@ -130,7 +127,7 @@ public class PlotAPI { public SchematicHandler getSchematicHandler() { return schematicHandler; } - + /** * C class contains all the captions from the translations.yml file. * @@ -139,10 +136,10 @@ public class PlotAPI { public C getCaptions() { return c; } - + /** - * Get the plot manager for a world. - * - Most of these methods can be accessed through the PlotHelper + * Get the plot manager for a world. - Most of these methods can be accessed + * through the PlotHelper * * @param world * @return @@ -150,44 +147,44 @@ public class PlotAPI { public PlotManager getPlotManager(World world) { return PlotMain.getPlotManager(world); } - + /** - * 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 - * @return + * @return */ public PlotManager getPlotManager(String world) { return PlotMain.getPlotManager(world); } - + /** - * Get the settings for a world (settings bundled in PlotWorld class) - * - You will need to downcast for the specific settings a Generator has. - * e.g. DefaultPlotWorld class implements PlotWorld + * Get the settings for a world (settings bundled in PlotWorld class) - You + * will need to downcast for the specific settings a Generator has. e.g. + * DefaultPlotWorld class implements PlotWorld * * @param world * (to get settings of) - * @return PlotWorld class for that world ! will return null if not a plot world - * world + * @return PlotWorld class for that world ! will return null if not a plot + * world world */ public PlotWorld getWorldSettings(World world) { return PlotMain.getWorldSettings(world); } - + /** * Get the settings for a world (settings bundled in PlotWorld class) * * @param world * (to get settings of) - * @return PlotWorld class for that world ! will return null if not a plot world - * world + * @return PlotWorld class for that world ! will return null if not a plot + * world world */ public PlotWorld getWorldSettings(String world) { return PlotMain.getWorldSettings(world); } - + /** * Send a message to a player. * @@ -200,8 +197,7 @@ public class PlotAPI { } /** - * Send a message to a player. - * - Supports color codes + * Send a message to a player. - Supports color codes * * @param player * @param string @@ -211,8 +207,7 @@ public class PlotAPI { } /** - * Send a message to the console. - * - Supports color codes + * Send a message to the console. - Supports color codes * * @param msg */ @@ -287,8 +282,7 @@ public class PlotAPI { * @return true if player has a plot, false if not. */ public boolean hasPlot(World world, Player player) { - return (getPlots(world, player, true) != null) - && (getPlots(world, player, true).length > 0); + return (getPlots(world, player, true) != null) && (getPlots(world, player, true).length > 0); } /** @@ -306,7 +300,8 @@ public class PlotAPI { if ((plot.owner != null) && (plot.owner == plr.getUniqueId())) { pPlots.add(plot); } - } else { + } + else { if (plot.hasRights(plr)) { pPlots.add(plot); } @@ -354,8 +349,7 @@ public class PlotAPI { */ public Location[] getLocations(Plot p) { World world = Bukkit.getWorld(p.world); - return new Location[] { PlotHelper.getPlotBottomLoc(world, p.id), - PlotHelper.getPlotTopLoc(world, p.id), + return new Location[] { PlotHelper.getPlotBottomLoc(world, p.id), PlotHelper.getPlotTopLoc(world, p.id), PlotHelper.getPlotHome(world, p.id) }; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java index 121e52240..5368d5bae 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Auto.java - * >> Generated by: Citymonstret at 2014-08-09 01:40 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Auto.java >> Generated by: Citymonstret at 2014-08-09 01:40 */ package com.intellectualcrafters.plot.commands; @@ -25,8 +24,7 @@ import com.intellectualcrafters.plot.PlotWorld; @SuppressWarnings("deprecation") public class Auto extends SubCommand { public Auto() { - super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", - CommandCategory.CLAIMING); + super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING); } // TODO auto claim a mega plot!!!!!!!!!!!! @@ -38,10 +36,12 @@ public class Auto extends SubCommand { String schematic = ""; if (PlotMain.getPlotWorlds().length == 1) { world = Bukkit.getWorld(PlotMain.getPlotWorlds()[0]); - } else { + } + else { if (PlotMain.isPlotWorld(plr.getWorld())) { world = plr.getWorld(); - } else { + } + else { PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); return false; } @@ -61,20 +61,21 @@ public class Auto extends SubCommand { if (args.length > 1) { schematic = args[1]; } - } catch (Exception e) { + } + catch (Exception e) { schematic = args[0]; // PlayerFunctions.sendMessage(plr, // "&cError: Invalid size (X,Y)"); // return false; } - } else { + } + else { schematic = args[0]; // PlayerFunctions.sendMessage(plr, C.NO_PERMISSION); // return false; } } - if (PlayerFunctions.getPlayerPlotCount(world, plr) >= PlayerFunctions - .getAllowedPlots(plr)) { + if (PlayerFunctions.getPlayerPlotCount(world, plr) >= PlayerFunctions.getAllowedPlots(plr)) { PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); return false; } @@ -95,14 +96,11 @@ public class Auto extends SubCommand { if (!schematic.equals("")) { if (pWorld.SCHEMATIC_CLAIM_SPECIFY) { if (pWorld.SCHEMATICS.contains(schematic.toLowerCase())) { - sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " - + schematic); + sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); return true; } - if (!plr.hasPermission("plots.claim." + schematic) - && !plr.hasPermission("plots.admin")) { - PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, - schematic); + if (!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) { + PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); return true; } } @@ -120,44 +118,49 @@ public class Auto extends SubCommand { } if ((z < q) && ((z - x) < q)) { z++; - } else if (x < q) { - x++; - z = q - 100; - } else { - q += 100; - x = q; - z = q; } + else + if (x < q) { + x++; + z = q - 100; + } + else { + q += 100; + x = q; + z = q; + } } - } else { + } + else { while (!br) { PlotId start = new PlotId(x, z); PlotId end = new PlotId((x + size_x) - 1, (z + size_z) - 1); if (isUnowned(world, start, end)) { for (int i = start.x; i <= end.x; i++) { for (int j = start.y; j <= end.y; j++) { - Plot plot = PlotHelper.getPlot(world, new PlotId(i, - j)); + Plot plot = PlotHelper.getPlot(world, new PlotId(i, j)); boolean teleport = ((i == end.x) && (j == end.y)); Claim.claimPlot(plr, plot, teleport); } } - if (!PlotHelper.mergePlots(plr, world, PlayerFunctions - .getPlotSelectionIds(world, start, end))) { + if (!PlotHelper.mergePlots(plr, world, PlayerFunctions.getPlotSelectionIds(world, start, end))) { return false; } br = true; } if ((z < q) && ((z - x) < q)) { z += size_z; - } else if (x < q) { - x += size_x; - z = q - 100; - } else { - q += 100; - x = q; - z = q; } + else + if (x < q) { + x += size_x; + z = q - 100; + } + else { + q += 100; + x = q; + z = q; + } } } return true; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Camera.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Camera.java index 51641dec9..c3b4e79dd 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Camera.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Camera.java @@ -26,8 +26,7 @@ public class Camera extends SubCommand implements Listener { private CameraAPI api; public Camera() { - super("camera", "plots.camera", "Go into camera mode", "camera", "c", - CommandCategory.TELEPORT); + super("camera", "plots.camera", "Go into camera mode", "camera", "c", CommandCategory.TELEPORT); this.api = CameraAPI.getInstance(); this.travelers = new ArrayList(); } @@ -48,8 +47,7 @@ public class Camera extends SubCommand implements Listener { return true; } this.api.travel(getController(player, plot)); - PlayerFunctions.sendMessage(player, C.CAMERA_STARTED, plot.getId().x - + ";" + plot.getId().y); + PlayerFunctions.sendMessage(player, C.CAMERA_STARTED, plot.getId().x + ";" + plot.getId().y); this.travelers.add(player.getName()); return true; } @@ -87,8 +85,7 @@ public class Camera extends SubCommand implements Listener { loc4.setYaw(((2 / 4.0F) * 360.0F) - 0.5F); loc2.setYaw(((0 / 4.0F) * 360.0F) - 0.5F); loc5 = loc1.clone(); - CameraController controller = this.api.createController(player, - seconds, loc1, loc2, loc3, loc4, loc5); + CameraController controller = this.api.createController(player, seconds, loc1, loc2, loc3, loc4, loc5); return controller; } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java index db475cd88..772bb272a 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Claim.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Claim.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -25,15 +24,12 @@ import com.intellectualcrafters.plot.SchematicHandler; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; /** - * * @author Citymonstret - * */ public class Claim extends SubCommand { public Claim() { - super(Command.CLAIM, "Claim the current plot you're standing on.", - "claim", CommandCategory.CLAIMING); + super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING); } @Override @@ -46,8 +42,7 @@ public class Claim extends SubCommand { PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); return true; } - if (PlayerFunctions.getPlayerPlotCount(plr.getWorld(), plr) >= PlayerFunctions - .getAllowedPlots(plr)) { + if (PlayerFunctions.getPlayerPlotCount(plr.getWorld(), plr) >= PlayerFunctions.getAllowedPlots(plr)) { PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); return true; } @@ -72,14 +67,11 @@ public class Claim extends SubCommand { if (!schematic.equals("")) { if (world.SCHEMATIC_CLAIM_SPECIFY) { if (!world.SCHEMATICS.contains(schematic.toLowerCase())) { - sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " - + schematic); + sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); return true; } - if (!plr.hasPermission("plots.claim." + schematic) - && !plr.hasPermission("plots.admin")) { - PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, - schematic); + if (!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) { + PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); return true; } } @@ -97,8 +89,7 @@ public class Claim extends SubCommand { return claimPlot(player, plot, teleport, ""); } - public static boolean claimPlot(Player player, Plot plot, boolean teleport, - String schematic) { + public static boolean claimPlot(Player player, Plot plot, boolean teleport, String schematic) { PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { @@ -114,7 +105,8 @@ public class Claim extends SubCommand { SchematicHandler.Schematic sch; if (schematic.equals("")) { sch = handler.getSchematic(world.SCHEMATIC_FILE); - } else { + } + else { sch = handler.getSchematic(schematic); if (sch == null) { sch = handler.getSchematic(world.SCHEMATIC_FILE); @@ -122,8 +114,7 @@ public class Claim extends SubCommand { } handler.paste(player.getLocation(), sch, plot); } - plot.settings.setFlags(FlagManager.parseFlags(PlotMain - .getWorldSettings(player.getWorld()).DEFAULT_FLAGS)); + plot.settings.setFlags(FlagManager.parseFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS)); } return event.isCancelled(); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Clear.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Clear.java index 63a341a06..bf0844c47 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Clear.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Clear.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Clear.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -31,8 +30,7 @@ public class Clear extends SubCommand { return false; } Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals( - plr.getUniqueId())) + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java index 7279e477e..14d8d6394 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Command.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Command.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Command.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -108,7 +107,6 @@ public enum Command { private CommandPermission permission; /** - * * @param command */ Command(String command) { @@ -118,7 +116,6 @@ public enum Command { } /** - * * @param command * @param permission */ @@ -129,7 +126,6 @@ public enum Command { } /** - * * @param command * @param alias */ @@ -140,7 +136,6 @@ public enum Command { } /** - * * @param Command * @param alias * @param permission @@ -152,7 +147,6 @@ public enum Command { } /** - * * @return */ public String getCommand() { @@ -160,7 +154,6 @@ public enum Command { } /** - * * @return */ public String getAlias() { @@ -168,7 +161,6 @@ public enum Command { } /** - * * @return */ public CommandPermission getPermission() { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/CommandPermission.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/CommandPermission.java index 8c0053f3f..d5427bec9 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/CommandPermission.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/CommandPermission.java @@ -1,10 +1,10 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = CommandPermission.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = CommandPermission.java >> Generated by: Citymonstret at 2014-08-09 + * 01:41 */ package com.intellectualcrafters.plot.commands; @@ -31,12 +31,10 @@ public class CommandPermission { } /** - * * @param player * @return */ public boolean hasPermission(Player player) { - return player.hasPermission(this.permission) - || player.hasPermission("plots.admin"); + return player.hasPermission(this.permission) || player.hasPermission("plots.admin"); } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Copy.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Copy.java index 32a254a4c..05eefd37b 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Copy.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Copy.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Clear.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -31,8 +30,7 @@ public class Copy extends SubCommand { return false; } Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals( - plr.getUniqueId())) + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Debug.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Debug.java index a74b6fa08..9cf52c2d3 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Debug.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Debug.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Debug.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Debug.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -34,8 +33,7 @@ public class Debug extends SubCommand { // private extends SubCommand^Implements {Command, Information} from // >>\\S.txt6\\ public Debug() { - super(Command.DEBUG, "Show debug information", "debug [msg]", - CommandCategory.INFO); + super(Command.DEBUG, "Show debug information", "debug [msg]", CommandCategory.INFO); { /** * This. @@ -82,36 +80,25 @@ public class Debug extends SubCommand { information.append(header); information.append(getSection(section, "Lag / TPS")); information.append(getLine(line, "Ticks Per Second", Lag.getTPS())); - information.append(getLine(line, "Lag Percentage", - (int) Lag.getPercentage() + "%")); - information.append(getLine(line, "TPS Percentage", - (int) Lag.getFullPercentage() + "%")); + information.append(getLine(line, "Lag Percentage", (int) Lag.getPercentage() + "%")); + information.append(getLine(line, "TPS Percentage", (int) Lag.getFullPercentage() + "%")); information.append(getSection(section, "PlotWorld")); information.append(getLine(line, "Plot Worlds", worlds)); - information.append(getLine(line, "Owned Plots", PlotMain.getPlots() - .size())); + information.append(getLine(line, "Owned Plots", PlotMain.getPlots().size())); // information.append(getLine(line, "PlotWorld Size", // PlotHelper.getWorldFolderSize() + "MB")); for (String world : PlotMain.getPlotWorlds()) { - information.append(getLine(line, "World: " + world + " size", - PlotHelper.getWorldFolderSize(Bukkit.getWorld(world)))); + information.append(getLine(line, "World: " + world + " size", PlotHelper.getWorldFolderSize(Bukkit.getWorld(world)))); } - information.append(getLine(line, "Entities", - PlotHelper.getEntities(plr.getWorld()))); - information.append(getLine(line, "Loaded Tile Entities", - PlotHelper.getTileEntities(plr.getWorld()))); - information.append(getLine(line, "Loaded Chunks", - PlotHelper.getLoadedChunks(plr.getWorld()))); + information.append(getLine(line, "Entities", PlotHelper.getEntities(plr.getWorld()))); + information.append(getLine(line, "Loaded Tile Entities", PlotHelper.getTileEntities(plr.getWorld()))); + information.append(getLine(line, "Loaded Chunks", PlotHelper.getLoadedChunks(plr.getWorld()))); information.append(getSection(section, "RAM")); - information.append(getLine(line, "Free Ram", RUtils.getFreeRam() - + "MB")); - information.append(getLine(line, "Total Ram", RUtils.getTotalRam() - + "MB")); + information.append(getLine(line, "Free Ram", RUtils.getFreeRam() + "MB")); + information.append(getLine(line, "Total Ram", RUtils.getTotalRam() + "MB")); information.append(getSection(section, "Messages")); - information.append(getLine(line, "Total Messages", - C.values().length)); - information.append(getLine(line, "View all captions", - "/plot debug msg")); + information.append(getLine(line, "Total Messages", C.values().length)); + information.append(getLine(line, "View all captions", "/plot debug msg")); } /** * {function:: SEND_MESSAGE |local player -> plr|local string -> @@ -128,8 +115,7 @@ public class Debug extends SubCommand { } private String getLine(String line, String var, Object val) { - return line.replaceAll("%var%", var).replaceAll("%val%", "" + val) - + "\n"; + return line.replaceAll("%var%", var).replaceAll("%val%", "" + val) + "\n"; } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Delete.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Delete.java index f33e2e58b..dfb07a3d5 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Delete.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Delete.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Delete.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Delete.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -27,8 +26,7 @@ import com.intellectualcrafters.plot.database.DBFunc; public class Delete extends SubCommand { public Delete() { - super(Command.DELETE, "Delete a plot", "delete", - CommandCategory.ACTIONS); + super(Command.DELETE, "Delete a plot", "delete", CommandCategory.ACTIONS); } @Override @@ -38,13 +36,11 @@ public class Delete extends SubCommand { return false; } Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals( - PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED); return false; } - if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals( - plr.getUniqueId()))) + if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))) && !plr.hasPermission("plots.admin")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; @@ -58,13 +54,13 @@ public class Delete extends SubCommand { sendMessage(plr, C.ADDED_BALANCE, c + ""); } } - boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, - true); + boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true); if (result) { PlotHelper.removeSign(plr, plot); plot.clear(plr); DBFunc.delete(plr.getWorld().getName(), plot); - } else { + } + else { PlayerFunctions.sendMessage(plr, "Plot clearing has been denied."); } return true; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Denied.java index b3909e1a5..42afa0dfd 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Denied.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Denied.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Denied.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -28,8 +27,7 @@ import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent; public class Denied extends SubCommand { public Denied() { - super(Command.DENIED, "Manage plot helpers", - "denied {add|remove} {player}", CommandCategory.ACTIONS); + super(Command.DENIED, "Manage plot helpers", "denied {add|remove} {player}", CommandCategory.ACTIONS); } @Override @@ -51,8 +49,7 @@ public class Denied extends SubCommand { if (args[1].equalsIgnoreCase("*")) { UUID uuid = DBFunc.everyone; plot.addDenied(uuid); - DBFunc.setDenied(plr.getWorld().getName(), plot, - Bukkit.getOfflinePlayer(args[1])); + DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); PlayerFunctions.sendMessage(plr, C.DENIED_ADDED); return true; } @@ -67,60 +64,54 @@ public class Denied extends SubCommand { */ UUID uuid = UUIDHandler.getUUID(args[1]); plot.addDenied(uuid); - DBFunc.setDenied(plr.getWorld().getName(), plot, - Bukkit.getOfflinePlayer(args[1])); - PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, - uuid, true); + DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); + PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true); Bukkit.getPluginManager().callEvent(event); PlayerFunctions.sendMessage(plr, C.DENIED_ADDED); - if ((Bukkit.getPlayer(uuid) != null) - && Bukkit.getPlayer(uuid).isOnline()) { - Plot pl = PlayerFunctions.getCurrentPlot(Bukkit - .getPlayer((uuid))); + if ((Bukkit.getPlayer(uuid) != null) && Bukkit.getPlayer(uuid).isOnline()) { + Plot pl = PlayerFunctions.getCurrentPlot(Bukkit.getPlayer((uuid))); if (pl.id == plot.id) { - PlayerFunctions.sendMessage(Bukkit.getPlayer(uuid), - C.YOU_BE_DENIED); - Bukkit.getPlayer(uuid).teleport( - Bukkit.getPlayer(uuid).getWorld() - .getSpawnLocation()); + PlayerFunctions.sendMessage(Bukkit.getPlayer(uuid), C.YOU_BE_DENIED); + Bukkit.getPlayer(uuid).teleport(Bukkit.getPlayer(uuid).getWorld().getSpawnLocation()); } } - } else if (args[0].equalsIgnoreCase("remove")) { - if (args[1].equalsIgnoreCase("*")) { - UUID uuid = DBFunc.everyone; - if (!plot.denied.contains(uuid)) { - PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); + } + else + if (args[0].equalsIgnoreCase("remove")) { + if (args[1].equalsIgnoreCase("*")) { + UUID uuid = DBFunc.everyone; + if (!plot.denied.contains(uuid)) { + PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); + return true; + } + plot.removeDenied(uuid); + DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); + PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED); return true; } + /* + * if (!hasBeenOnServer(args[1])) { + * PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON); + * return true; } UUID uuid = null; if + * (Bukkit.getPlayer(args[1])!=null) { uuid = + * Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = + * Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if + * (!plot.denied.contains(uuid)) { + * PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); return + * true; } if (uuid == null) { PlayerFunctions.sendMessage(plr, + * C.PLAYER_HAS_NOT_BEEN_ON); return true; } + */ + UUID uuid = UUIDHandler.getUUID(args[1]); plot.removeDenied(uuid); - DBFunc.removeDenied(plr.getWorld().getName(), plot, - Bukkit.getOfflinePlayer(args[1])); + DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); + PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, false); + Bukkit.getPluginManager().callEvent(event); PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED); + } + else { + PlayerFunctions.sendMessage(plr, C.DENIED_NEED_ARGUMENT); return true; } - /* - * if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr, - * C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if - * (Bukkit.getPlayer(args[1])!=null) { uuid = - * Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = - * Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if - * (!plot.denied.contains(uuid)) { PlayerFunctions.sendMessage(plr, - * C.WAS_NOT_ADDED); return true; } if (uuid == null) { - * PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON); - * return true; } - */ - UUID uuid = UUIDHandler.getUUID(args[1]); - plot.removeDenied(uuid); - DBFunc.removeDenied(plr.getWorld().getName(), plot, - Bukkit.getOfflinePlayer(args[1])); - PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, - uuid, false); - Bukkit.getPluginManager().callEvent(event); - PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED); - } else { - PlayerFunctions.sendMessage(plr, C.DENIED_NEED_ARGUMENT); - return true; - } return true; } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Help.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Help.java index 9fe5651d5..8ddf03b30 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Help.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Help.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Help.java - * >> Generated by: Citymonstret at 2014-08-11 17:32 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Help.java >> Generated by: Citymonstret at 2014-08-11 17:32 */ package com.intellectualcrafters.plot.commands; @@ -16,8 +15,7 @@ import org.bukkit.entity.Player; */ public class Help extends SubCommand { public Help() { - super("help", "", "Get this help menu", "help", "he", - SubCommand.CommandCategory.INFO); + super("help", "", "Get this help menu", "help", "he", SubCommand.CommandCategory.INFO); } @Override diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Helpers.java index 54abdf9c3..80089522d 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Helpers.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Helpers.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Helpers.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -25,8 +24,7 @@ import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent; public class Helpers extends SubCommand { public Helpers() { - super(Command.HELPERS, "Manage plot helpers", - "helpers {add|remove} {player}", CommandCategory.ACTIONS); + super(Command.HELPERS, "Manage plot helpers", "helpers {add|remove} {player}", CommandCategory.ACTIONS); } @Override @@ -48,8 +46,7 @@ public class Helpers extends SubCommand { if (args[1].equalsIgnoreCase("*")) { UUID uuid = DBFunc.everyone; plot.addHelper(uuid); - DBFunc.setHelper(plr.getWorld().getName(), plot, - Bukkit.getOfflinePlayer(args[1])); + DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); PlayerFunctions.sendMessage(plr, C.HELPER_ADDED); return true; } @@ -64,48 +61,48 @@ public class Helpers extends SubCommand { */ UUID uuid = UUIDHandler.getUUID(args[1]); plot.addHelper(uuid); - DBFunc.setHelper(plr.getWorld().getName(), plot, - Bukkit.getOfflinePlayer(args[1])); - PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, - uuid, true); + DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); + PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true); Bukkit.getPluginManager().callEvent(event); PlayerFunctions.sendMessage(plr, C.HELPER_ADDED); - } else if (args[0].equalsIgnoreCase("remove")) { - if (args[1].equalsIgnoreCase("*")) { - UUID uuid = DBFunc.everyone; - if (!plot.helpers.contains(uuid)) { - PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); + } + else + if (args[0].equalsIgnoreCase("remove")) { + if (args[1].equalsIgnoreCase("*")) { + UUID uuid = DBFunc.everyone; + if (!plot.helpers.contains(uuid)) { + PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); + return true; + } + plot.removeHelper(uuid); + DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); + PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED); return true; } + /* + * if (!hasBeenOnServer(args[1])) { + * PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON); + * return true; } UUID uuid = null; if + * (Bukkit.getPlayer(args[1]) != null) { uuid = + * Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = + * Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid == + * null) { PlayerFunctions.sendMessage(plr, + * C.PLAYER_HAS_NOT_BEEN_ON); return true; } if + * (!plot.helpers.contains(uuid)) { + * PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); return + * true; } + */ + UUID uuid = UUIDHandler.getUUID(args[1]); plot.removeHelper(uuid); - DBFunc.removeHelper(plr.getWorld().getName(), plot, - Bukkit.getOfflinePlayer(args[1])); + DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); + PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, false); + Bukkit.getPluginManager().callEvent(event); PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED); + } + else { + PlayerFunctions.sendMessage(plr, C.HELPER_NEED_ARGUMENT); return true; } - /* - * if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr, - * C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if - * (Bukkit.getPlayer(args[1]) != null) { uuid = - * Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = - * Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid == - * null) { PlayerFunctions.sendMessage(plr, - * C.PLAYER_HAS_NOT_BEEN_ON); return true; } if - * (!plot.helpers.contains(uuid)) { PlayerFunctions.sendMessage(plr, - * C.WAS_NOT_ADDED); return true; } - */ - UUID uuid = UUIDHandler.getUUID(args[1]); - plot.removeHelper(uuid); - DBFunc.removeHelper(plr.getWorld().getName(), plot, - Bukkit.getOfflinePlayer(args[1])); - PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, - uuid, false); - Bukkit.getPluginManager().callEvent(event); - PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED); - } else { - PlayerFunctions.sendMessage(plr, C.HELPER_NEED_ARGUMENT); - return true; - } return true; } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Home.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Home.java index 6aefd3656..326909614 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Home.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Home.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Home.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -17,21 +16,17 @@ import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.PlotMain; /** - * * @author Citymonstret - * */ public class Home extends SubCommand { public Home() { - super(Command.HOME, "Go to your plot", "home {id|alias}", - CommandCategory.TELEPORT); + super(Command.HOME, "Go to your plot", "home {id|alias}", CommandCategory.TELEPORT); } private Plot isAlias(String a) { for (Plot p : PlotMain.getPlots()) { - if ((p.settings.getAlias().length() > 0) - && p.settings.getAlias().equalsIgnoreCase(a)) { + if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) { return p; } } @@ -44,38 +39,41 @@ public class Home extends SubCommand { if (plots.length == 1) { PlotMain.teleportPlayer(plr, plr.getLocation(), plots[0]); return true; - } else if (plots.length > 1) { - if (args.length < 1) { - args = new String[] { "1" }; - } - int id = 0; - try { - id = Integer.parseInt(args[0]); - } catch (Exception e) { - Plot temp; - if ((temp = isAlias(args[0])) != null) { - if (temp.hasOwner()) { - if (temp.getOwner().equals(plr.getUniqueId())) { - PlotMain.teleportPlayer(plr, plr.getLocation(), - temp); - return true; + } + else + if (plots.length > 1) { + if (args.length < 1) { + args = new String[] { "1" }; + } + int id = 0; + try { + id = Integer.parseInt(args[0]); + } + catch (Exception e) { + Plot temp; + if ((temp = isAlias(args[0])) != null) { + if (temp.hasOwner()) { + if (temp.getOwner().equals(plr.getUniqueId())) { + PlotMain.teleportPlayer(plr, plr.getLocation(), temp); + return true; + } } + PlayerFunctions.sendMessage(plr, C.NOT_YOUR_PLOT); + return false; } - PlayerFunctions.sendMessage(plr, C.NOT_YOUR_PLOT); + PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); + return true; + } + if ((id > (plots.length)) || (id < 1)) { + PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); return false; } - PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); + PlotMain.teleportPlayer(plr, plr.getLocation(), plots[id - 1]); return true; } - if ((id > (plots.length)) || (id < 1)) { - PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); - return false; + else { + PlayerFunctions.sendMessage(plr, C.NO_PLOTS); + return true; } - PlotMain.teleportPlayer(plr, plr.getLocation(), plots[id - 1]); - return true; - } else { - PlayerFunctions.sendMessage(plr, C.NO_PLOTS); - return true; - } } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java index fb969e55f..fbc8a01f4 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Info.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Info.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Info.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -27,9 +26,7 @@ import com.intellectualcrafters.plot.UUIDHandler; import com.intellectualcrafters.plot.database.DBFunc; /** - * * @author Citymonstret - * */ public class Info extends SubCommand { @@ -55,20 +52,21 @@ public class Info extends SubCommand { { if (plot.helpers == null) { containsEveryone = false; - } else { + } + else { containsEveryone = plot.helpers.contains(DBFunc.everyone); } if (plot.trusted == null) { trustedEveryone = false; - } else { + } + else { trustedEveryone = plot.trusted.contains(DBFunc.everyone); } } // Unclaimed? if (!hasOwner && !containsEveryone && !trustedEveryone) { - PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, - plot.id.x + ";" + plot.id.y); + PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, plot.id.x + ";" + plot.id.y); return true; } @@ -83,27 +81,19 @@ public class Info extends SubCommand { } String info = C.PLOT_INFO.s(); - info = info.replaceAll( - "%alias%", - plot.settings.getAlias().length() > 0 ? plot.settings - .getAlias() : "none"); + info = info.replaceAll("%alias%", plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none"); info = info.replaceAll("%id%", plot.id.toString()); info = info.replaceAll("%biome%", getBiomeAt(plot).toString()); info = info.replaceAll("%owner%", owner); - info = info.replaceAll("%time%", - plot.settings.getChangeTime() ? plot.settings.getTime() + "" - : "default"); - info = info.replaceAll("%weather%", plot.settings.getRain() ? "rain" - : "default"); + info = info.replaceAll("%time%", plot.settings.getChangeTime() ? plot.settings.getTime() + "" : "default"); + info = info.replaceAll("%weather%", plot.settings.getRain() ? "rain" : "default"); info = info.replaceAll("%helpers%", getPlayerList(plot.helpers)); info = info.replaceAll("%trusted%", getPlayerList(plot.trusted)); info = info.replaceAll("%denied%", getPlayerList(plot.denied)); info = info.replaceAll("%rating%", "" + DBFunc.getRatings(plot)); - info = info - .replaceAll( - "%flags%", - StringUtils.join(plot.settings.getFlags(), "").length() > 0 ? StringUtils - .join(plot.settings.getFlags(), ",") : "none"); + info = + info.replaceAll("%flags%", StringUtils.join(plot.settings.getFlags(), "").length() > 0 + ? StringUtils.join(plot.settings.getFlags(), ",") : "none"); // PlayerFunctions.sendMessage(player, // PlayerFunctions.getTopPlot(player.getWorld(), plot).id.toString()); // PlayerFunctions.sendMessage(player, @@ -121,9 +111,9 @@ public class Info extends SubCommand { StringBuilder list = new StringBuilder(); for (int x = 0; x < l.size(); x++) { if ((x + 1) == l.size()) { - list.append(c.replace("%user%", getPlayerName(l.get(x))) - .replace(",", "")); - } else { + list.append(c.replace("%user%", getPlayerName(l.get(x))).replace(",", "")); + } + else { list.append(c.replace("%user%", getPlayerName(l.get(x)))); } } @@ -134,8 +124,7 @@ public class Info extends SubCommand { if (uuid == null) { return "unknown"; } - if (uuid.equals(DBFunc.everyone) - || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) { + if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) { return "everyone"; } /* diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Inventory.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Inventory.java index a3b7278d7..358c21478 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Inventory.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Inventory.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Inventory.java - * >> Generated by: Citymonstret at 2014-08-10 13:57 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Inventory.java >> Generated by: Citymonstret at 2014-08-10 13:57 */ package com.intellectualcrafters.plot.commands; @@ -21,8 +20,7 @@ import org.bukkit.inventory.meta.ItemMeta; public class Inventory extends SubCommand { public Inventory() { - super("inventory", "plots.inventory", "Open a command inventory", - "inventory", "inv", CommandCategory.INFO); + super("inventory", "plots.inventory", "Open a command inventory", "inventory", "inv", CommandCategory.INFO); } @Override @@ -34,8 +32,7 @@ public class Inventory extends SubCommand { } } int size = 9 * (int) Math.ceil(cmds.size() / 9.0); - org.bukkit.inventory.Inventory inventory = Bukkit.createInventory(null, - size, "PlotSquared Commands"); + org.bukkit.inventory.Inventory inventory = Bukkit.createInventory(null, size, "PlotSquared Commands"); for (SubCommand cmd : cmds) { inventory.addItem(getItem(cmd)); } @@ -47,17 +44,13 @@ public class Inventory extends SubCommand { ItemStack stack = new ItemStack(Material.COMMAND); ItemMeta meta = stack.getItemMeta(); { - meta.setDisplayName(ChatColor.GREEN + cmd.cmd + ChatColor.DARK_GRAY - + " [" + ChatColor.GREEN + cmd.alias + ChatColor.DARK_GRAY - + "]"); + meta.setDisplayName(ChatColor.GREEN + cmd.cmd + ChatColor.DARK_GRAY + " [" + ChatColor.GREEN + cmd.alias + + ChatColor.DARK_GRAY + "]"); meta.setLore(new ArrayList() { { - add(ChatColor.RED + "Category: " + ChatColor.GOLD - + cmd.category.toString()); - add(ChatColor.RED + "Description: " + ChatColor.GOLD - + cmd.description); - add(ChatColor.RED + "Usage: " + ChatColor.GOLD + "/plot " - + cmd.usage); + add(ChatColor.RED + "Category: " + ChatColor.GOLD + cmd.category.toString()); + add(ChatColor.RED + "Description: " + ChatColor.GOLD + cmd.description); + add(ChatColor.RED + "Usage: " + ChatColor.GOLD + "/plot " + cmd.usage); } }); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Kick.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Kick.java index 24281d734..7e9185d0f 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Kick.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Kick.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Kick.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Kick.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -22,8 +21,7 @@ import com.intellectualcrafters.plot.Plot; public class Kick extends SubCommand { public Kick() { - super(Command.KICK, "Kick a player from your plot", "kick", - CommandCategory.ACTIONS); + super(Command.KICK, "Kick a player from your plot", "kick", CommandCategory.ACTIONS); } @Override @@ -33,8 +31,7 @@ public class Kick extends SubCommand { return false; } Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals( - plr.getUniqueId())) + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; @@ -44,17 +41,14 @@ public class Kick extends SubCommand { return false; } if (Bukkit.getPlayer(args[0]) != null) { - PlayerFunctions.sendMessage(plr, - C.INVALID_PLAYER.s().replaceAll("%player%", args[0])); + PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0])); return false; } Player player = Bukkit.getPlayer(args[0]); - if (!player.getWorld().equals(plr.getWorld()) - || !PlayerFunctions.isInPlot(player) + if (!player.getWorld().equals(plr.getWorld()) || !PlayerFunctions.isInPlot(player) || (PlayerFunctions.getCurrentPlot(player) == null) || !PlayerFunctions.getCurrentPlot(player).equals(plot)) { - PlayerFunctions.sendMessage(plr, - C.INVALID_PLAYER.s().replaceAll("%player%", args[0])); + PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0])); return false; } player.teleport(player.getWorld().getSpawnLocation()); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/MainCommand.java index b85d2ff83..230cc2e8f 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/MainCommand.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = MainCommand.java - * >> Generated by: Citymonstret at 2014-08-09 01:42 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = MainCommand.java >> Generated by: Citymonstret at 2014-08-09 01:42 */ package com.intellectualcrafters.plot.commands; @@ -26,15 +25,12 @@ import com.intellectualcrafters.plot.PlotMain; * PlotMain command class * * @author Citymonstret - * */ public class MainCommand implements CommandExecutor { - private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), - new Auto(), new Home(), new Visit(), new TP(), new Set(), - new Clear(), new Delete(), new SetOwner(), new Denied(), - new Helpers(), new Trusted(), new Info(), new list(), new Help(), - new Debug(), new Schematic(), new plugin(), new Inventory(), + private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Auto(), new Home(), new Visit(), + new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), + new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup() }; public static ArrayList subCommands = new ArrayList() { @@ -49,16 +45,15 @@ public class MainCommand implements CommandExecutor { } @Override - public boolean onCommand(CommandSender sender, Command cmd, - String commandLabel, String[] args) { + public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (!(sender instanceof Player)) { if (args.length > 0) { if (args[0].equalsIgnoreCase("reload")) { new Reload().executeConsole(args); } - } else { - PlotMain.sendConsoleSenderMessage(C.PREFIX.s() - + C.HELP_HEADER.s()); + } + else { + PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + C.HELP_HEADER.s()); PlotMain.sendConsoleSenderMessage("&6/plots reload &c-&6 reloads the plugin"); } return false; @@ -68,28 +63,20 @@ public class MainCommand implements CommandExecutor { return no_permission(player); } if ((args.length < 1) - || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0] - .equalsIgnoreCase("he")))) { + || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) { if (args.length < 2) { StringBuilder builder = new StringBuilder(); builder.append(C.HELP_INFO.s()); - for (SubCommand.CommandCategory category : SubCommand.CommandCategory - .values()) { + for (SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) { builder.append("\n" - + C.HELP_INFO_ITEM - .s() - .replaceAll("%category%", - category.toString().toLowerCase()) - .replaceAll("%category_desc%", - category.toString())); + + C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString())); } PlayerFunctions.sendMessage(player, builder.toString()); return true; } String cat = args[1]; SubCommand.CommandCategory cato = null; - for (SubCommand.CommandCategory category : SubCommand.CommandCategory - .values()) { + for (SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) { if (cat.equalsIgnoreCase(category.toString())) { cato = category; break; @@ -98,15 +85,9 @@ public class MainCommand implements CommandExecutor { if (cato == null) { StringBuilder builder = new StringBuilder(); builder.append(C.HELP_INFO.s()); - for (SubCommand.CommandCategory category : SubCommand.CommandCategory - .values()) { + for (SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) { builder.append("\n" - + C.HELP_INFO_ITEM - .s() - .replaceAll("%category%", - category.toString().toLowerCase()) - .replaceAll("%category_desc%", - category.toString())); + + C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString())); } PlayerFunctions.sendMessage(player, builder.toString()); return true; @@ -117,17 +98,18 @@ public class MainCommand implements CommandExecutor { } PlayerFunctions.sendMessage(player, help.toString()); return true; - } else { + } + else { for (SubCommand command : subCommands) { - if (command.cmd.equalsIgnoreCase(args[0]) - || command.alias.equalsIgnoreCase(args[0])) { + if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.equalsIgnoreCase(args[0])) { String[] arguments = new String[args.length - 1]; for (int x = 1; x < args.length; x++) { arguments[x - 1] = args[x]; } if (command.permission.hasPermission(player)) { return command.execute(player, arguments); - } else { + } + else { return no_permission(player); } } @@ -137,23 +119,18 @@ public class MainCommand implements CommandExecutor { return false; } - public static ArrayList helpMenu(Player player, - final SubCommand.CommandCategory category) { + public static ArrayList helpMenu(Player player, final SubCommand.CommandCategory category) { ArrayList help = new ArrayList() { { add(t(C.HELP_HEADER.s())); - add(t(C.HELP_CATEGORY.s().replaceAll("%category%", - category.toString()))); + add(t(C.HELP_CATEGORY.s().replaceAll("%category%", category.toString()))); } }; for (SubCommand cmd : subCommands) { - if (cmd.permission.hasPermission(player) - && (cmd.category == category)) { + if (cmd.permission.hasPermission(player) && (cmd.category == category)) { String s = t(C.HELP_PAGE.s()); s = s.replaceAll("%alias%", cmd.alias); - s = s.replaceAll("%usage%", - cmd.usage.contains("plot") ? cmd.usage : "/plot " - + cmd.usage); + s = s.replaceAll("%usage%", cmd.usage.contains("plot") ? cmd.usage : "/plot " + cmd.usage); s = s.replaceAll("%cmd%", cmd.cmd); s = s.replaceAll("%desc%", cmd.description); help.add(s); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Merge.java index e6f2ec72e..8c86a5afa 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Merge.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Merge.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Merge.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -29,20 +28,15 @@ import com.intellectualcrafters.plot.SetBlockFast; import com.intellectualcrafters.plot.events.PlotMergeEvent; /** - * * @author Citymonstret - * */ public class Merge extends SubCommand { - public static String[] values = new String[] { "north", "east", "south", - "west" }; + public static String[] values = new String[] { "north", "east", "south", "west" }; public static String[] aliases = new String[] { "n", "e", "s", "w" }; public Merge() { - super(Command.MERGE, - "Merge the plot you are standing on with another plot.", - "merge", CommandCategory.ACTIONS); + super(Command.MERGE, "Merge the plot you are standing on with another plot.", "merge", CommandCategory.ACTIONS); } public static String direction(float yaw) { @@ -83,35 +77,22 @@ public class Merge extends SubCommand { return false; } if (args.length < 1) { - PlayerFunctions.sendMessage( - plr, - C.SUBCOMMAND_SET_OPTIONS_HEADER.s() - + StringUtils.join(values, - C.BLOCK_LIST_SEPARATER.s())); - PlayerFunctions.sendMessage( - plr, - C.DIRECTION.s().replaceAll("%dir%", - direction(plr.getLocation().getYaw()))); + PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s())); + PlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw()))); return false; } int direction = -1; for (int i = 0; i < values.length; i++) { - if (args[0].equalsIgnoreCase(values[i]) - || args[0].equalsIgnoreCase(aliases[i])) { + if (args[0].equalsIgnoreCase(values[i]) || args[0].equalsIgnoreCase(aliases[i])) { direction = i; break; } } if (direction == -1) { - PlayerFunctions.sendMessage( - plr, - C.SUBCOMMAND_SET_OPTIONS_HEADER.s() - + StringUtils.join(values, - C.BLOCK_LIST_SEPARATER.s())); - PlayerFunctions.sendMessage( - plr, - C.DIRECTION.s().replaceAll("%dir%", - direction(plr.getLocation().getYaw()))); + PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s())); + PlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw()))); return false; } World world = plr.getWorld(); @@ -120,30 +101,28 @@ public class Merge extends SubCommand { ArrayList plots; switch (direction) { case 0: // north = -y - plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), - new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); + plots = + PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); break; case 1: // east = +x - plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), - new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); + plots = + PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); break; case 2: // south = +y - plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), - new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); + plots = + PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); break; case 3: // west = -x - plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), - new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); + plots = + PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); break; default: return false; } for (PlotId myid : plots) { Plot myplot = PlotMain.getPlots(world).get(myid); - if ((myplot == null) || !myplot.hasOwner() - || !(myplot.getOwner().equals(plr.getUniqueId()))) { - PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s() - .replaceAll("%plot%", myid.toString())); + if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(plr.getUniqueId()))) { + PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); return false; } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Rate.java index 2429f8004..4d30ef690 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Rate.java @@ -17,8 +17,7 @@ public class Rate extends SubCommand { */ public Rate() { - super("rate", "plots.rate", "Rate the plot", "rate {0-10}", "rt", - CommandCategory.ACTIONS); + super("rate", "plots.rate", "Rate the plot", "rate {0-10}", "rt", CommandCategory.ACTIONS); } @Override @@ -65,7 +64,8 @@ public class Rate extends SubCommand { boolean success = false; if (success) { sendMessage(plr, C.RATING_APPLIED, plot.getId().toString()); - } else { + } + else { sendMessage(plr, C.COMMAND_WENT_WRONG); } return true; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Reload.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Reload.java index 1eee8214f..2a547e2f8 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Reload.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Reload.java - * >> Generated by: Citymonstret at 2014-08-09 01:42 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Reload.java >> Generated by: Citymonstret at 2014-08-09 01:42 */ package com.intellectualcrafters.plot.commands; @@ -21,8 +20,7 @@ import com.intellectualcrafters.plot.PlotMain; public class Reload extends SubCommand { public Reload() { - super("reload", "plots.admin", "Reload configurations", "", "reload", - CommandCategory.INFO); + super("reload", "plots.admin", "Reload configurations", "", "reload", CommandCategory.INFO); } @Override @@ -30,10 +28,12 @@ public class Reload extends SubCommand { try { PlotMain.reloadTranslations(); PlotMain.BroadcastWithPerms(C.RELOADED_CONFIGS); - } catch (Exception e) { + } + catch (Exception e) { if (plr != null) { PlayerFunctions.sendMessage(plr, C.RELOAD_FAILED); - } else { + } + else { PlotMain.sendConsoleSenderMessage(C.RELOAD_FAILED); } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Schematic.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Schematic.java index a0ddc090d..48d995a21 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Schematic.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Schematic.java @@ -11,8 +11,7 @@ import com.intellectualcrafters.plot.SchematicHandler; public class Schematic extends SubCommand { public Schematic() { - super("schematic", "plots.admin", "Schematic Command", - "schematic {arg}", "sch", CommandCategory.ACTIONS); + super("schematic", "plots.admin", "Schematic Command", "schematic {arg}", "sch", CommandCategory.ACTIONS); } @Override @@ -36,11 +35,11 @@ public class Schematic extends SubCommand { } file = args[1]; schematic = new SchematicHandler().getSchematic(file); - boolean s = new SchematicHandler().paste(plr.getLocation(), - schematic, PlayerFunctions.getCurrentPlot(plr)); + boolean s = new SchematicHandler().paste(plr.getLocation(), schematic, PlayerFunctions.getCurrentPlot(plr)); if (s) { sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS); - } else { + } + else { sendMessage(plr, C.SCHEMATIC_PASTE_FAILED); } break; @@ -66,8 +65,7 @@ public class Schematic extends SubCommand { int length = PlotHelper.getPlotWidth(plr.getWorld(), plot.id); if ((l1 != length) || (l2 != length)) { - sendMessage(plr, C.SCHEMATIC_INVALID, String.format( - "Wrong size (x: %s, z: %d) vs %d ", l1, l2, length)); + sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length)); break; } sendMessage(plr, C.SCHEMATIC_VALID); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java index 5acdba638..72fa7c10b 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Set.java - * >> Generated by: Citymonstret at 2014-08-09 01:42 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Set.java >> Generated by: Citymonstret at 2014-08-09 01:42 */ package com.intellectualcrafters.plot.commands; @@ -36,21 +35,17 @@ import com.intellectualcrafters.plot.events.PlotFlagAddEvent; import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent; /** - * * @author Citymonstret - * */ public class Set extends SubCommand { public Set() { - super(Command.SET, "Set a plot value", "set {arg} {value...}", - CommandCategory.ACTIONS); + super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS); } - public static String[] values = new String[] { "biome", "wall", - "wall_filling", "floor", "alias", "home", "rain", "flag" }; - public static String[] aliases = new String[] { "b", "w", "wf", "f", "a", - "h", "r", "fl" }; + public static String[] values = new String[] { "biome", "wall", "wall_filling", "floor", "alias", "home", "rain", + "flag" }; + public static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "r", "fl" }; @SuppressWarnings("deprecation") @Override @@ -89,28 +84,20 @@ public class Set extends SubCommand { if (args[0].equalsIgnoreCase("flag")) { if (args.length < 2) { - String message = StringUtils.join(FlagManager.getFlags(), - "&c, &6"); + String message = StringUtils.join(FlagManager.getFlags(), "&c, &6"); if (PlotMain.worldGuardListener != null) { if (message.equals("")) { - message = StringUtils - .join(PlotMain.worldGuardListener.str_flags, - "&c, &6"); - } else { - message += "," - + StringUtils.join( - PlotMain.worldGuardListener.str_flags, - "&c, &6"); + message = StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6"); + } + else { + message += "," + StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6"); } } - PlayerFunctions.sendMessage(plr, - C.NEED_KEY.s().replaceAll("%values%", message)); + PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message)); return false; } - if (!FlagManager.getFlags().contains(args[1].toLowerCase()) - && (PlotMain.worldGuardListener != null) - && !PlotMain.worldGuardListener.str_flags.contains(args[1] - .toLowerCase())) { + if (!FlagManager.getFlags().contains(args[1].toLowerCase()) && (PlotMain.worldGuardListener != null) + && !PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG); return false; } @@ -121,10 +108,8 @@ public class Set extends SubCommand { if (args.length == 2) { if (plot.settings.getFlag(args[1].toLowerCase()) == null) { if (PlotMain.worldGuardListener != null) { - if (PlotMain.worldGuardListener.str_flags - .contains(args[1].toLowerCase())) { - PlotMain.worldGuardListener.removeFlag(plr, - plr.getWorld(), plot, args[1]); + if (PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) { + PlotMain.worldGuardListener.removeFlag(plr, plr.getWorld(), plot, args[1]); return false; } } @@ -145,22 +130,17 @@ public class Set extends SubCommand { newflags.remove(oldFlag); } plot.settings.setFlags(newflags.toArray(new Flag[0])); - DBFunc.setFlags(plr.getWorld().getName(), plot, - newflags.toArray(new Flag[0])); + DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0])); PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED); return true; } try { - String value = StringUtils.join( - Arrays.copyOfRange(args, 2, args.length), " "); - if ((FlagManager.getFlag(args[1].toLowerCase()) == null) - && (PlotMain.worldGuardListener != null)) { - PlotMain.worldGuardListener.addFlag(plr, plr.getWorld(), - plot, args[1], value); + String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); + if ((FlagManager.getFlag(args[1].toLowerCase()) == null) && (PlotMain.worldGuardListener != null)) { + PlotMain.worldGuardListener.addFlag(plr, plr.getWorld(), plot, args[1], value); return false; } - Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), - true), value); + Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), value); PlotFlagAddEvent event = new PlotFlagAddEvent(flag, plot); Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { @@ -169,11 +149,11 @@ public class Set extends SubCommand { return false; } plot.settings.addFlag(flag); - DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings - .getFlags().toArray(new Flag[0])); + DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags().toArray(new Flag[0])); PlayerFunctions.sendMessage(plr, C.FLAG_ADDED); return true; - } catch (Exception e) { + } + catch (Exception e) { PlayerFunctions.sendMessage(plr, "&c" + e.getMessage()); return false; } @@ -195,7 +175,8 @@ public class Set extends SubCommand { if (PlayerFunctions.getCurrentPlot(plr).id == plot.id) { if (b) { p.setPlayerWeather(WeatherType.DOWNFALL); - } else { + } + else { p.resetPlayerWeather(); } } @@ -218,8 +199,7 @@ public class Set extends SubCommand { PlayerFunctions.sendMessage(plr, C.INVALID_POSITION); return false; } - DBFunc.setPosition(plr.getWorld().getName(), plot, - position.toString()); + DBFunc.setPosition(plr.getWorld().getName(), plot, position.toString()); PlayerFunctions.sendMessage(plr, C.POSITION_SET); return true; } @@ -241,8 +221,7 @@ public class Set extends SubCommand { } } DBFunc.setAlias(plr.getWorld().getName(), plot, alias); - PlayerFunctions.sendMessage(plr, - C.ALIAS_SET_TO.s().replaceAll("%alias%", alias)); + PlayerFunctions.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias)); return true; } if (args[0].equalsIgnoreCase("biome")) { @@ -258,13 +237,11 @@ public class Set extends SubCommand { } } if (biome == null) { - PlayerFunctions.sendMessage(plr, - getBiomeList(Arrays.asList(Biome.values()))); + PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values()))); return true; } PlotHelper.setBiome(plr.getWorld(), plot, biome); - PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() - + biome.toString().toLowerCase()); + PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase()); return true; } if (args[0].equalsIgnoreCase("wall")) { @@ -285,8 +262,7 @@ public class Set extends SubCommand { } } if (material == null) { - PlayerFunctions - .sendMessage(plr, getBlockList(PlotWorld.BLOCKS)); + PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS)); return true; } byte data = 0; @@ -294,14 +270,14 @@ public class Set extends SubCommand { if (args.length > 2) { try { data = (byte) Integer.parseInt(args[2]); - } catch (Exception e) { + } + catch (Exception e) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA); return true; } } PlayerFunctions.sendMessage(plr, C.GENERATING_WALL); - PlotHelper.adjustWall(plr, plot, - new PlotBlock((short) material.getId(), data)); + PlotHelper.adjustWall(plr, plot, new PlotBlock((short) material.getId(), data)); return true; } if (args[0].equalsIgnoreCase("floor")) { @@ -316,8 +292,7 @@ public class Set extends SubCommand { } // @SuppressWarnings("unchecked") - ArrayList materials = (ArrayList) PlotWorld.BLOCKS - .clone(); + ArrayList materials = (ArrayList) PlotWorld.BLOCKS.clone(); materials.add(Material.AIR); // String[] strings = args[1].split(","); @@ -345,10 +320,12 @@ public class Set extends SubCommand { if (ss.length == 1) { blocks[index] = new PlotBlock((short) m.getId(), (byte) 0); - } else { + } + else { try { b = (byte) Integer.parseInt(ss[1]); - } catch (Exception e) { + } + catch (Exception e) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA); return true; } @@ -377,8 +354,7 @@ public class Set extends SubCommand { } } if (material == null) { - PlayerFunctions - .sendMessage(plr, getBlockList(PlotWorld.BLOCKS)); + PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS)); return true; } byte data = 0; @@ -386,13 +362,13 @@ public class Set extends SubCommand { if (args.length > 2) { try { data = (byte) Integer.parseInt(args[2]); - } catch (Exception e) { + } + catch (Exception e) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA); return true; } } - PlotHelper.adjustWallFilling(plr, plot, new PlotBlock( - (short) material.getId(), data)); + PlotHelper.adjustWallFilling(plr, plot, new PlotBlock((short) material.getId(), data)); return true; } StringBuilder builder = new StringBuilder(); @@ -403,18 +379,15 @@ public class Set extends SubCommand { } private String getMaterial(Material m) { - return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM - .s().replaceAll("%mat%", m.toString().toLowerCase())); + return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", m.toString().toLowerCase())); } private String getBiome(Biome b) { - return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM - .s().replaceAll("%mat%", b.toString().toLowerCase())); + return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", b.toString().toLowerCase())); } private String getString(String s) { - return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM - .s().replaceAll("%mat%", s)); + return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s)); } private String getArgumentList(String[] strings) { @@ -427,8 +400,7 @@ public class Set extends SubCommand { private String getBiomeList(List biomes) { StringBuilder builder = new StringBuilder(); - builder.append(ChatColor.translateAlternateColorCodes('&', - C.NOT_VALID_BLOCK_LIST_HEADER.s())); + builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s())); for (Biome b : biomes) { builder.append(getBiome(b)); } @@ -437,8 +409,7 @@ public class Set extends SubCommand { private String getBlockList(List blocks) { StringBuilder builder = new StringBuilder(); - builder.append(ChatColor.translateAlternateColorCodes('&', - C.NOT_VALID_BLOCK_LIST_HEADER.s())); + builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s())); for (Material b : blocks) { builder.append(getMaterial(b)); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/SetOwner.java index b759ac1d1..8510d5ae2 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/SetOwner.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = SetOwner.java - * >> Generated by: Citymonstret at 2014-08-09 01:42 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = SetOwner.java >> Generated by: Citymonstret at 2014-08-09 01:42 */ package com.intellectualcrafters.plot.commands; @@ -24,8 +23,7 @@ import com.intellectualcrafters.plot.database.DBFunc; public class SetOwner extends SubCommand { public SetOwner() { - super("setowner", "plots.admin", "Set the plot owner", - "setowner {player}", "so", CommandCategory.ACTIONS); + super("setowner", "plots.admin", "Set the plot owner", "setowner {player}", "so", CommandCategory.ACTIONS); } /* diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java index 8b5cbb61d..b340aa822 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java @@ -39,7 +39,7 @@ public class Setup extends SubCommand implements Listener { this.step = plotworld.getSettingNodes(); this.plugin = plugin; } - + public String getPlugin() { return this.plugin; } @@ -54,8 +54,7 @@ public class Setup extends SubCommand implements Listener { } public Setup() { - super("setup", "plots.admin", "Setup a PlotWorld", "setup {world}", - "setup", CommandCategory.ACTIONS); + super("setup", "plots.admin", "Setup a PlotWorld", "setup {world}", "setup", CommandCategory.ACTIONS); } @Override @@ -68,23 +67,25 @@ public class Setup extends SubCommand implements Listener { ConfigurationNode[] steps = object.step; String world = object.world; for (ConfigurationNode step : steps) { - PlotMain.config.set( - "worlds." + world + "." + step.getConstant(), - step.getValue()); + PlotMain.config.set("worlds." + world + "." + step.getConstant(), step.getValue()); } try { PlotMain.config.save(PlotMain.configFile); - } catch (IOException e) { + } + catch (IOException e) { e.printStackTrace(); } - + // Creating the worlds if (object.getPlugin().equals("Multiverse-Core")) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create "+world+" normal -g "+object.plugin); - } - else if (object.getPlugin().equals("MultiWorld")) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create "+world+" plugin:"+object.plugin); + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + + " normal -g " + object.plugin); } + else + if (object.getPlugin().equals("MultiWorld")) { + Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + + " plugin:" + object.plugin); + } sendMessage(plr, C.SETUP_FINISHED, object.world); setupMap.remove(plr.getName()); @@ -93,11 +94,11 @@ public class Setup extends SubCommand implements Listener { } ConfigurationNode step = object.step[object.current]; if (args.length < 1) { - sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", - step.getDescription(), step.getType().getType(), - step.getDefaultValue() + ""); + sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + + ""); return true; - } else { + } + else { if (args[0].equalsIgnoreCase("cancel")) { setupMap.remove(plr.getName()); PlayerFunctions.sendMessage(plr, "&cCancelled setup."); @@ -107,21 +108,19 @@ public class Setup extends SubCommand implements Listener { if (object.current > 0) { object.current--; step = object.step[object.current]; - sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", - step.getDescription(), step.getType().getType(), - step.getDefaultValue() + ""); + sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + + ""); return true; - } else { - sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", - step.getDescription(), step.getType().getType(), - step.getDefaultValue() + ""); + } + else { + sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + + ""); return true; } } boolean valid = step.isValid(args[0]); if (valid) { - sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(), - args[0]); + sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(), args[0]); step.setValue(args[0]); object.current++; if (object.getCurrent() == object.getMax()) { @@ -129,20 +128,19 @@ public class Setup extends SubCommand implements Listener { return true; } step = object.step[object.current]; - sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", - step.getDescription(), step.getType().getType(), - step.getDefaultValue() + ""); + sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + + ""); return true; - } else { - sendMessage(plr, C.SETUP_INVALID_ARG, args[0], - step.getConstant()); - sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", - step.getDescription(), step.getType().getType(), - step.getDefaultValue() + ""); + } + else { + sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant()); + sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + + ""); return true; } } - } else { + } + else { if (args.length < 1) { sendMessage(plr, C.SETUP_MISSING_WORLD); return true; @@ -156,32 +154,31 @@ public class Setup extends SubCommand implements Listener { sendMessage(plr, C.SETUP_WORLD_TAKEN, world); return true; } - + if (PlotMain.getWorldSettings(world) != null) { sendMessage(plr, C.SETUP_WORLD_TAKEN, world); return true; } - + ArrayList generators = new ArrayList(); - + ChunkGenerator generator = null; - + for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { if (plugin.isEnabled()) { - ChunkGenerator currentGen = plugin.getDefaultWorldGenerator("world", ""); - if (currentGen != null) { + if (plugin.getDefaultWorldGenerator("world", "") != null) { String name = plugin.getDescription().getName(); generators.add(name); if (args[1].equals(name)) { - generator = currentGen; + generator = plugin.getDefaultWorldGenerator(world, ""); break; } } - + } } if (generator == null) { - sendMessage(plr, C.SETUP_INVALID_GENERATOR, StringUtils.join(generators,C.BLOCK_LIST_SEPARATER.s())); + sendMessage(plr, C.SETUP_INVALID_GENERATOR, StringUtils.join(generators, C.BLOCK_LIST_SEPARATER.s())); return true; } PlotWorld plotworld; @@ -196,9 +193,8 @@ public class Setup extends SubCommand implements Listener { sendMessage(plr, C.SETUP_INIT); SetupObject object = setupMap.get(plr.getName()); ConfigurationNode step = object.step[object.current]; - sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", - step.getDescription(), step.getType().getType(), - step.getDefaultValue() + ""); + sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + + ""); return true; } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/SubCommand.java index a7d3bb11d..2b912dcc1 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/SubCommand.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = SubCommand.java - * >> Generated by: Citymonstret at 2014-08-09 01:42 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = SubCommand.java >> Generated by: Citymonstret at 2014-08-09 01:42 */ package com.intellectualcrafters.plot.commands; @@ -18,7 +17,6 @@ import com.intellectualcrafters.plot.PlayerFunctions; * SubCommand class * * @author Citymonstret - * */ public abstract class SubCommand { @@ -47,7 +45,6 @@ public abstract class SubCommand { public CommandCategory category; /** - * * @param cmd * Command /plot {cmd} <-- That! * @param permission @@ -61,8 +58,8 @@ public abstract class SubCommand { * @param category * CommandCategory. Pick whichever closests to what you want. */ - public SubCommand(String cmd, String permission, String description, - String usage, String alias, CommandCategory category) { + public SubCommand(String cmd, String permission, String description, String usage, String alias, + CommandCategory category) { this.cmd = cmd; this.permission = new CommandPermission(permission); this.description = description; @@ -72,7 +69,6 @@ public abstract class SubCommand { } /** - * * @param command * Command /plot {cmd} <-- That! * @param description @@ -82,8 +78,7 @@ public abstract class SubCommand { * @param category * CommandCategory. Pick whichever closests to what you want. */ - public SubCommand(Command command, String description, String usage, - CommandCategory category) { + public SubCommand(Command command, String description, String usage, CommandCategory category) { this.cmd = command.getCommand(); this.permission = command.getPermission(); this.alias = command.getAlias(); @@ -119,8 +114,10 @@ public abstract class SubCommand { } public enum CommandCategory { - CLAIMING("Claiming"), TELEPORT("Teleportation"), ACTIONS("Actions"), INFO( - "Information"); + CLAIMING("Claiming"), + TELEPORT("Teleportation"), + ACTIONS("Actions"), + INFO("Information"); private String name; CommandCategory(String name) { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/TP.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/TP.java index 0373a5e99..a5bce6467 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/TP.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/TP.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = TP.java - * >> Generated by: Citymonstret at 2014-08-09 01:42 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = TP.java >> Generated by: Citymonstret at 2014-08-09 01:42 */ package com.intellectualcrafters.plot.commands; @@ -22,15 +21,12 @@ import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.PlotMain; /** - * * @author Citymonstret - * */ public class TP extends SubCommand { public TP() { - super(Command.TP, "Teleport to a plot", "tp {alias|id}", - CommandCategory.TELEPORT); + super(Command.TP, "Teleport to a plot", "tp {alias|id}", CommandCategory.TELEPORT); } @Override @@ -57,12 +53,11 @@ public class TP extends SubCommand { return true; } try { - plotid = new PlotId(Integer.parseInt(id.split(";")[0]), - Integer.parseInt(id.split(";")[1])); - PlotMain.teleportPlayer(plr, plr.getLocation(), - PlotHelper.getPlot(world, plotid)); + plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1])); + PlotMain.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid)); return true; - } catch (Exception e) { + } + catch (Exception e) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); } return false; @@ -79,16 +74,14 @@ public class TP extends SubCommand { } Player player = Bukkit.getPlayer(a); if (player != null) { - Plot[] plots = PlotMain.getPlots(world, player) - .toArray(new Plot[0]); + Plot[] plots = PlotMain.getPlots(world, player).toArray(new Plot[0]); if (plots.length > index) { return plots[index]; } return null; } for (Plot p : PlotMain.getPlots(world).values()) { - if ((p.settings.getAlias().length() > 0) - && p.settings.getAlias().equalsIgnoreCase(a)) { + if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) { return p; } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Trusted.java index 743f82eaf..1a0c32107 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Trusted.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Trusted.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Trusted.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -25,8 +24,7 @@ import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent; public class Trusted extends SubCommand { public Trusted() { - super(Command.TRUSTED, "Manage trusted users for a plot", - "trusted {add|remove} {player}", CommandCategory.ACTIONS); + super(Command.TRUSTED, "Manage trusted users for a plot", "trusted {add|remove} {player}", CommandCategory.ACTIONS); } @Override @@ -48,8 +46,7 @@ public class Trusted extends SubCommand { if (args[1].equalsIgnoreCase("*")) { UUID uuid = DBFunc.everyone; plot.addTrusted(uuid); - DBFunc.setTrusted(plr.getWorld().getName(), plot, - Bukkit.getOfflinePlayer(args[1])); + DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED); return true; } @@ -64,48 +61,48 @@ public class Trusted extends SubCommand { */ UUID uuid = UUIDHandler.getUUID(args[1]); plot.addTrusted(uuid); - DBFunc.setTrusted(plr.getWorld().getName(), plot, - Bukkit.getOfflinePlayer(args[1])); - PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, - plot, uuid, true); + DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); + PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true); Bukkit.getPluginManager().callEvent(event); PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED); - } else if (args[0].equalsIgnoreCase("remove")) { - if (args[1].equalsIgnoreCase("*")) { - UUID uuid = DBFunc.everyone; - if (!plot.trusted.contains(uuid)) { - PlayerFunctions.sendMessage(plr, C.T_WAS_NOT_ADDED); + } + else + if (args[0].equalsIgnoreCase("remove")) { + if (args[1].equalsIgnoreCase("*")) { + UUID uuid = DBFunc.everyone; + if (!plot.trusted.contains(uuid)) { + PlayerFunctions.sendMessage(plr, C.T_WAS_NOT_ADDED); + return true; + } + plot.removeTrusted(uuid); + DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); + PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED); return true; } + /* + * if (!hasBeenOnServer(args[1])) { + * PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON); + * return true; } UUID uuid = null; if + * (Bukkit.getPlayer(args[1]) != null) { uuid = + * Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = + * Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid == + * null) { PlayerFunctions.sendMessage(plr, + * C.PLAYER_HAS_NOT_BEEN_ON); return true; } if + * (!plot.trusted.contains(uuid)) { + * PlayerFunctions.sendMessage(plr, C.T_WAS_NOT_ADDED); return + * true; } + */ + UUID uuid = UUIDHandler.getUUID(args[1]); plot.removeTrusted(uuid); - DBFunc.removeTrusted(plr.getWorld().getName(), plot, - Bukkit.getOfflinePlayer(args[1])); + DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); + PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, false); + Bukkit.getPluginManager().callEvent(event); PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED); + } + else { + PlayerFunctions.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); return true; } - /* - * if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr, - * C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if - * (Bukkit.getPlayer(args[1]) != null) { uuid = - * Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = - * Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid == - * null) { PlayerFunctions.sendMessage(plr, - * C.PLAYER_HAS_NOT_BEEN_ON); return true; } if - * (!plot.trusted.contains(uuid)) { PlayerFunctions.sendMessage(plr, - * C.T_WAS_NOT_ADDED); return true; } - */ - UUID uuid = UUIDHandler.getUUID(args[1]); - plot.removeTrusted(uuid); - DBFunc.removeTrusted(plr.getWorld().getName(), plot, - Bukkit.getOfflinePlayer(args[1])); - PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, - plot, uuid, false); - Bukkit.getPluginManager().callEvent(event); - PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED); - } else { - PlayerFunctions.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT); - return true; - } return true; } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Unlink.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Unlink.java index 5afd4ce9f..16db71c13 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Unlink.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Unlink.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Unlink.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Unlink.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -32,8 +31,7 @@ import com.intellectualcrafters.plot.events.PlotUnlinkEvent; public class Unlink extends SubCommand { public Unlink() { - super(Command.UNLINK, "Unlink a mega-plot", "unlink", - CommandCategory.ACTIONS); + super(Command.UNLINK, "Unlink a mega-plot", "unlink", CommandCategory.ACTIONS); } @Override @@ -43,22 +41,19 @@ public class Unlink extends SubCommand { return true; } Plot plot = PlayerFunctions.getCurrentPlot(plr); - if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals( - plr.getUniqueId())) + if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return true; } - if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals( - PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { + if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { PlayerFunctions.sendMessage(plr, C.UNLINK_IMPOSSIBLE); return true; } World world = plr.getWorld(); PlotId pos1 = PlayerFunctions.getBottomPlot(world, plot).id; PlotId pos2 = PlayerFunctions.getTopPlot(world, plot).id; - ArrayList ids = PlayerFunctions.getPlotSelectionIds(world, - pos1, pos2); + ArrayList ids = PlayerFunctions.getPlotSelectionIds(world, pos1, pos2); PlotUnlinkEvent event = new PlotUnlinkEvent(world, ids); @@ -79,10 +74,8 @@ public class Unlink extends SubCommand { myplot.denied = plot.denied; } myplot.deny_entry = plot.deny_entry; - myplot.settings.setMerged(new boolean[] { false, false, false, - false }); - DBFunc.setMerged(world.getName(), myplot, - myplot.settings.getMerged()); + myplot.settings.setMerged(new boolean[] { false, false, false, false }); + DBFunc.setMerged(world.getName(), myplot, myplot.settings.getMerged()); } PlotManager manager = PlotMain.getPlotManager(world); PlotWorld plotworld = PlotMain.getWorldSettings(world); @@ -111,7 +104,8 @@ public class Unlink extends SubCommand { try { SetBlockFast.update(plr); - } catch (Exception e) { + } + catch (Exception e) { } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Visit.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Visit.java index 7ac0fabf5..8f07300c7 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Visit.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = Visit.java - * >> Generated by: Citymonstret at 2014-08-09 01:42 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = Visit.java >> Generated by: Citymonstret at 2014-08-09 01:42 */ package com.intellectualcrafters.plot.commands; @@ -23,8 +22,7 @@ import com.intellectualcrafters.plot.PlotMain; public class Visit extends SubCommand { public Visit() { - super("visit", "plots.visit", "Visit someones plot", - "visit {player} [#]", "v", CommandCategory.TELEPORT); + super("visit", "plots.visit", "Visit someones plot", "visit {player} [#]", "v", CommandCategory.TELEPORT); } public List getPlots(UUID uuid) { @@ -45,8 +43,7 @@ public class Visit extends SubCommand { return true; } String username = args[0]; - List plots = getPlots(Bukkit.getOfflinePlayer(username) - .getUniqueId()); + List plots = getPlots(Bukkit.getOfflinePlayer(username).getUniqueId()); if (plots.isEmpty()) { PlayerFunctions.sendMessage(plr, C.FOUND_NO_PLOTS); return true; @@ -59,7 +56,8 @@ public class Visit extends SubCommand { int i; try { i = Integer.parseInt(args[1]); - } catch (Exception e) { + } + catch (Exception e) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); return true; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/list.java index 0e1921bbe..ae29c8a5e 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/list.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = list.java - * >> Generated by: Citymonstret at 2014-08-09 01:41 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = list.java >> Generated by: Citymonstret at 2014-08-09 01:41 */ package com.intellectualcrafters.plot.commands; @@ -23,15 +22,12 @@ import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.UUIDHandler; /** - * * @author Citymonstret - * */ public class list extends SubCommand { public list() { - super(Command.LIST, "List all plots", "list {mine|all|world}", - CommandCategory.INFO); + super(Command.LIST, "List all plots", "list {mine|all|world}", CommandCategory.INFO); } @Override @@ -39,22 +35,16 @@ public class list extends SubCommand { if (args.length < 1) { StringBuilder builder = new StringBuilder(); builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s()); - builder.append(getArgumentList(new String[] { "mine", "shared", - "world", "all" })); + builder.append(getArgumentList(new String[] { "mine", "shared", "world", "all" })); PlayerFunctions.sendMessage(plr, builder.toString()); return true; } if (args[0].equalsIgnoreCase("mine")) { StringBuilder string = new StringBuilder(); - string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "your") - + "\n"); + string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "your") + "\n"); int idx = 0; for (Plot p : PlotMain.getPlots(plr)) { - string.append(C.PLOT_LIST_ITEM - .s() - .replaceAll("%id%", - p.id.x + ";" + p.id.y + ";" + p.world) - .replaceAll("%owner%", getName(p.owner)) + string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id%", p.id.x + ";" + p.id.y + ";" + p.world).replaceAll("%owner%", getName(p.owner)) + "\n"); idx++; } @@ -62,79 +52,57 @@ public class list extends SubCommand { PlayerFunctions.sendMessage(plr, C.NO_PLOTS); return true; } - string.append(C.PLOT_LIST_FOOTER.s() - .replaceAll("%word%", "You have") - .replaceAll("%num%", idx + "") - .replaceAll("%plot%", idx == 1 ? "plot" : "plots")); + string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "You have").replaceAll("%num%", idx + "").replaceAll("%plot%", idx == 1 + ? "plot" : "plots")); PlayerFunctions.sendMessage(plr, string.toString()); return true; - } else if (args[0].equalsIgnoreCase("shared")) { - StringBuilder string = new StringBuilder(); - string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") - + "\n"); - for (Plot p : PlotMain.getPlots()) { - if (p.helpers.contains(plr.getUniqueId())) { - string.append(C.PLOT_LIST_ITEM - .s() - .replaceAll("%id%", - p.id.x + ";" + p.id.y + ";" + p.world) - .replaceAll("%owner%", getName(p.owner)) - + "\n"); - } - } - string.append(C.PLOT_LIST_FOOTER - .s() - .replaceAll("%word%", "There is") - .replaceAll("%num%", PlotMain.getPlots().size() + "") - .replaceAll("%plot%", - PlotMain.getPlots().size() == 1 ? "plot" : "plots")); - PlayerFunctions.sendMessage(plr, string.toString()); - return true; - } else if (args[0].equalsIgnoreCase("all")) { - StringBuilder string = new StringBuilder(); - string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") - + "\n"); - for (Plot p : PlotMain.getPlots()) { - string.append(C.PLOT_LIST_ITEM - .s() - .replaceAll("%id%", - p.id.x + ";" + p.id.y + ";" + p.world) - .replaceAll("%owner%", getName(p.owner)) - + "\n"); - } - string.append(C.PLOT_LIST_FOOTER - .s() - .replaceAll("%word%", "There is") - .replaceAll("%num%", PlotMain.getPlots().size() + "") - .replaceAll("%plot%", - PlotMain.getPlots().size() == 1 ? "plot" : "plots")); - PlayerFunctions.sendMessage(plr, string.toString()); - return true; - } else if (args[0].equalsIgnoreCase("world")) { - StringBuilder string = new StringBuilder(); - string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") - + "\n"); - HashMap plots = PlotMain.getPlots(plr.getWorld()); - for (Plot p : plots.values()) { - string.append(C.PLOT_LIST_ITEM - .s() - .replaceAll("%id%", - p.id.x + ";" + p.id.y + ";" + p.world) - .replaceAll("%owner%", getName(p.owner)) - + "\n"); - } - string.append(C.PLOT_LIST_FOOTER - .s() - .replaceAll("%word%", "There is") - .replaceAll("%num%", plots.values().size() + "") - .replaceAll("%plot%", - plots.values().size() == 1 ? "plot" : "plots")); - PlayerFunctions.sendMessage(plr, string.toString()); - return true; - } else { - execute(plr); - return false; } + else + if (args[0].equalsIgnoreCase("shared")) { + StringBuilder string = new StringBuilder(); + string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") + "\n"); + for (Plot p : PlotMain.getPlots()) { + if (p.helpers.contains(plr.getUniqueId())) { + string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id%", p.id.x + ";" + p.id.y + ";" + p.world).replaceAll("%owner%", getName(p.owner)) + + "\n"); + } + } + string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", PlotMain.getPlots().size() + + "").replaceAll("%plot%", PlotMain.getPlots().size() == 1 ? "plot" : "plots")); + PlayerFunctions.sendMessage(plr, string.toString()); + return true; + } + else + if (args[0].equalsIgnoreCase("all")) { + StringBuilder string = new StringBuilder(); + string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") + "\n"); + for (Plot p : PlotMain.getPlots()) { + string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id%", p.id.x + ";" + p.id.y + ";" + p.world).replaceAll("%owner%", getName(p.owner)) + + "\n"); + } + string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", PlotMain.getPlots().size() + + "").replaceAll("%plot%", PlotMain.getPlots().size() == 1 ? "plot" : "plots")); + PlayerFunctions.sendMessage(plr, string.toString()); + return true; + } + else + if (args[0].equalsIgnoreCase("world")) { + StringBuilder string = new StringBuilder(); + string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") + "\n"); + HashMap plots = PlotMain.getPlots(plr.getWorld()); + for (Plot p : plots.values()) { + string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id%", p.id.x + ";" + p.id.y + ";" + p.world).replaceAll("%owner%", getName(p.owner)) + + "\n"); + } + string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", plots.values().size() + + "").replaceAll("%plot%", plots.values().size() == 1 ? "plot" : "plots")); + PlayerFunctions.sendMessage(plr, string.toString()); + return true; + } + else { + execute(plr); + return false; + } } private static String getName(UUID id) { @@ -157,8 +125,7 @@ public class list extends SubCommand { } private String getString(String s) { - return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM - .s().replaceAll("%mat%", s)); + return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s)); } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/plugin.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/plugin.java index dfa0c7f9d..f020b6464 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/plugin.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/plugin.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = plugin.java - * >> Generated by: Citymonstret at 2014-08-09 01:42 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = plugin.java >> Generated by: Citymonstret at 2014-08-09 01:42 */ package com.intellectualcrafters.plot.commands; @@ -25,45 +24,35 @@ import com.intellectualcrafters.plot.PlotMain; public class plugin extends SubCommand { public plugin() { - super("plugin", "plots.use", "Show plugin information", "plugin", "pl", - CommandCategory.INFO); + super("plugin", "plots.use", "Show plugin information", "plugin", "pl", CommandCategory.INFO); } @Override public boolean execute(final Player plr, String... args) { - Bukkit.getScheduler().runTaskAsynchronously( - JavaPlugin.getPlugin(PlotMain.class), new Runnable() { - @Override - public void run() { - ArrayList strings = new ArrayList() { - { - String downloads = getInfo("https://intellectualsites.com/spigot_api.php?method=downloads&url=http://www.spigotmc.org/resources/plotsquared.1177/"), version = getInfo("https://intellectualsites.com/spigot_api.php?method=version&resource=1177"); - add(String.format( - "&c>> &6PlotSquared (Version: %s)", - PlotMain.getMain().getDescription() - .getVersion())); - add(String - .format("&c>> &6Made by Citymonstret and Empire92")); - add(String - .format("&c>> &6Download at &lhttp://i-s.link/ps")); - add(String.format( - "&c>> &cNewest Version (Spigot): %s", - version)); - add(String.format( - "&c>> &cTotal Downloads (Spigot): %s", - downloads)); - } - }; - for (String s : strings) { - PlayerFunctions.sendMessage(plr, s); - } + Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() { + @Override + public void run() { + ArrayList strings = new ArrayList() { + { + String downloads = + getInfo("https://intellectualsites.com/spigot_api.php?method=downloads&url=http://www.spigotmc.org/resources/plotsquared.1177/"), version = + getInfo("https://intellectualsites.com/spigot_api.php?method=version&resource=1177"); + add(String.format("&c>> &6PlotSquared (Version: %s)", PlotMain.getMain().getDescription().getVersion())); + add(String.format("&c>> &6Made by Citymonstret and Empire92")); + add(String.format("&c>> &6Download at &lhttp://i-s.link/ps")); + add(String.format("&c>> &cNewest Version (Spigot): %s", version)); + add(String.format("&c>> &cTotal Downloads (Spigot): %s", downloads)); } - }); + }; + for (String s : strings) { + PlayerFunctions.sendMessage(plr, s); + } + } + }); return true; } /** - * * @param link * @return */ @@ -71,15 +60,15 @@ public class plugin extends SubCommand { try { URLConnection connection = new URL(link).openConnection(); connection.addRequestProperty("User-Agent", "Mozilla/4.0"); - BufferedReader reader = new BufferedReader(new InputStreamReader( - connection.getInputStream())); + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String document = "", line; while ((line = reader.readLine()) != null) { document += (line + "\n"); } reader.close(); return document; - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); return ""; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java index f84691267..f8841aff6 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = DBFunc.java - * >> Generated by: Citymonstret at 2014-08-09 01:43 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = DBFunc.java >> Generated by: Citymonstret at 2014-08-09 01:43 */ package com.intellectualcrafters.plot.database; @@ -53,17 +52,17 @@ public class DBFunc { @Override public void run() { try { - PreparedStatement statement = connection - .prepareStatement("UPDATE `plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ? "); + PreparedStatement statement = + connection.prepareStatement("UPDATE `plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ? "); statement.setString(1, uuid.toString()); statement.setInt(2, plot.id.x); statement.setInt(3, plot.id.y); statement.executeUpdate(); statement.close(); - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); - Logger.add(LogLevel.DANGER, "Could not set owner for plot " - + plot.id); + Logger.add(LogLevel.DANGER, "Could not set owner for plot " + plot.id); } } }); @@ -73,8 +72,8 @@ public class DBFunc { HashMap> stored = new HashMap>(); HashMap> helpers = new HashMap>(); try { - PreparedStatement stmt = connection - .prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z`, `world` FROM `plot`"); + PreparedStatement stmt = + connection.prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z`, `world` FROM `plot`"); ResultSet result = stmt.executeQuery(); while (result.next()) { int id = result.getInt("id"); @@ -87,7 +86,8 @@ public class DBFunc { } stored.get(world).put(new PlotId(idx, idz), id); } - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); } @@ -107,8 +107,7 @@ public class DBFunc { // add plot settings Integer[] ids = helpers.keySet().toArray(new Integer[0]); - StringBuilder statement = new StringBuilder( - "INSERT INTO `plot_settings` (`plot_plot_id`) values "); + StringBuilder statement = new StringBuilder("INSERT INTO `plot_settings` (`plot_plot_id`) values "); for (int i = 0; i < (ids.length - 1); i++) { statement.append("(?),"); } @@ -121,14 +120,14 @@ public class DBFunc { } stmt.executeUpdate(); stmt.close(); - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); } // add plot helpers String prefix = ""; - statement = new StringBuilder( - "INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) values "); + statement = new StringBuilder("INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) values "); for (Integer id : helpers.keySet()) { for (UUID helper : helpers.get(id)) { statement.append(prefix + "(?, ?)"); @@ -151,7 +150,8 @@ public class DBFunc { } stmt.executeUpdate(); stmt.close(); - } catch (SQLException e) { + } + catch (SQLException e) { Logger.add(LogLevel.WARNING, "Failed to set helper for plots"); e.printStackTrace(); } @@ -166,8 +166,8 @@ public class DBFunc { if (plots.size() == 0) { return; } - StringBuilder statement = new StringBuilder( - "INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) values "); + StringBuilder statement = + new StringBuilder("INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) values "); for (int i = 0; i < (plots.size() - 1); i++) { statement.append("(?, ?, ?, ?),"); @@ -186,7 +186,8 @@ public class DBFunc { } stmt.executeUpdate(); stmt.close(); - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); Logger.add(LogLevel.DANGER, "Failed to save plots!"); } @@ -200,15 +201,16 @@ public class DBFunc { public static void createPlot(Plot plot) { PreparedStatement stmt = null; try { - stmt = connection - .prepareStatement("INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) VALUES(?, ?, ?, ?)"); + stmt = + connection.prepareStatement("INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) VALUES(?, ?, ?, ?)"); stmt.setInt(1, plot.id.x); stmt.setInt(2, plot.id.y); stmt.setString(3, plot.owner.toString()); stmt.setString(4, plot.world); stmt.executeUpdate(); stmt.close(); - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); Logger.add(LogLevel.DANGER, "Failed to save plot " + plot.id); } @@ -219,81 +221,52 @@ public class DBFunc { * * @throws SQLException */ - public static void createTables(String database, boolean add_constraint) - throws SQLException { + public static void createTables(String database, boolean add_constraint) throws SQLException { boolean mysql = database.equals("mysql"); Statement stmt = connection.createStatement(); if (mysql) { - stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot` (" - + "`id` INT(11) NOT NULL AUTO_INCREMENT," - + "`plot_id_x` INT(11) NOT NULL," - + "`plot_id_z` INT(11) NOT NULL," - + "`owner` VARCHAR(45) NOT NULL," - + "`world` VARCHAR(45) NOT NULL," - + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," - + "PRIMARY KEY (`id`)" + stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT," + + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_denied` (" - + "`plot_plot_id` INT(11) NOT NULL," - + "`user_uuid` VARCHAR(40) NOT NULL" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` (" - + "`plot_plot_id` INT(11) NOT NULL," - + "`user_uuid` VARCHAR(40) NOT NULL" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` (" - + "`plot_plot_id` INT(11) NOT NULL," - + "`user_uuid` VARCHAR(40) NOT NULL" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" - + " `plot_plot_id` INT(11) NOT NULL," - + " `biome` VARCHAR(45) DEFAULT 'FOREST'," - + " `rain` INT(1) DEFAULT 0," - + " `custom_time` TINYINT(1) DEFAULT '0'," - + " `time` INT(11) DEFAULT '8000'," - + " `deny_entry` TINYINT(1) DEFAULT '0'," - + " `alias` VARCHAR(50) DEFAULT NULL," - + " `flags` VARCHAR(512) DEFAULT NULL," - + " `merged` INT(11) DEFAULT NULL," - + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," - + " PRIMARY KEY (`plot_plot_id`)," - + " UNIQUE KEY `unique_alias` (`alias`)" - + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)," + + " UNIQUE KEY `unique_alias` (`alias`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_ratings` ( `plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); if (add_constraint) { stmt.addBatch("ALTER TABLE `plot_settings` ADD CONSTRAINT `plot_settings_ibfk_1` FOREIGN KEY (`plot_plot_id`) REFERENCES `plot` (`id`) ON DELETE CASCADE"); } - } else { - stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot` (" - + "`id` INTEGER(11) PRIMARY KEY," - + "`plot_id_x` INT(11) NOT NULL," - + "`plot_id_z` INT(11) NOT NULL," - + "`owner` VARCHAR(45) NOT NULL," - + "`world` VARCHAR(45) NOT NULL," + } + else { + stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot` (" + "`id` INTEGER(11) PRIMARY KEY," + + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_denied` (" - + "`plot_plot_id` INT(11) NOT NULL," + stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` (" - + "`plot_plot_id` INT(11) NOT NULL," + stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` (" - + "`plot_plot_id` INT(11) NOT NULL," + stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")"); - stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" - + " `plot_plot_id` INT(11) NOT NULL," - + " `biome` VARCHAR(45) DEFAULT 'FOREST'," - + " `rain` INT(1) DEFAULT 0," - + " `custom_time` TINYINT(1) DEFAULT '0'," - + " `time` INT(11) DEFAULT '8000'," - + " `deny_entry` TINYINT(1) DEFAULT '0'," - + " `alias` VARCHAR(50) DEFAULT NULL," - + " `flags` VARCHAR(512) DEFAULT NULL," - + " `merged` INT(11) DEFAULT NULL," - + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," - + " PRIMARY KEY (`plot_plot_id`)" + ")"); + stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")"); stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))"); } stmt.executeBatch(); @@ -314,30 +287,26 @@ public class DBFunc { PreparedStatement stmt = null; int id = getId(world, plot.id); try { - stmt = connection - .prepareStatement("DELETE FROM `plot_settings` WHERE `plot_plot_id` = ?"); + stmt = connection.prepareStatement("DELETE FROM `plot_settings` WHERE `plot_plot_id` = ?"); stmt.setInt(1, id); stmt.executeUpdate(); stmt.close(); - stmt = connection - .prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ?"); + stmt = connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ?"); stmt.setInt(1, id); stmt.executeUpdate(); stmt.close(); - stmt = connection - .prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = ?"); + stmt = connection.prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = ?"); stmt.setInt(1, id); stmt.executeUpdate(); stmt.close(); - stmt = connection - .prepareStatement("DELETE FROM `plot` WHERE `id` = ?"); + stmt = connection.prepareStatement("DELETE FROM `plot` WHERE `id` = ?"); stmt.setInt(1, id); stmt.executeUpdate(); stmt.close(); - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); - Logger.add(LogLevel.DANGER, "Failed to delete plot " - + plot.id); + Logger.add(LogLevel.DANGER, "Failed to delete plot " + plot.id); } } }); @@ -355,13 +324,12 @@ public class DBFunc { public void run() { PreparedStatement stmt = null; try { - stmt = connection - .prepareStatement("INSERT INTO `plot_settings`(`plot_plot_id`) VALUES(" - + "?)"); + stmt = connection.prepareStatement("INSERT INTO `plot_settings`(`plot_plot_id`) VALUES(" + "?)"); stmt.setInt(1, id); stmt.executeUpdate(); stmt.close(); - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); } @@ -372,8 +340,8 @@ public class DBFunc { public static int getId(String world, PlotId id2) { PreparedStatement stmt = null; try { - stmt = connection - .prepareStatement("SELECT `id` FROM `plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC"); + stmt = + connection.prepareStatement("SELECT `id` FROM `plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC"); stmt.setInt(1, id2.x); stmt.setInt(2, id2.y); stmt.setString(3, world); @@ -384,7 +352,8 @@ public class DBFunc { } stmt.close(); return id; - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); } return Integer.MAX_VALUE; @@ -417,36 +386,27 @@ public class DBFunc { boolean execute = rs.next(); if (execute) { Statement statement = connection.createStatement(); - statement - .addBatch("ALTER IGNORE TABLE `plot` ADD `plot_id_x` int(11) DEFAULT 0"); - statement - .addBatch("ALTER IGNORE TABLE `plot` ADD `plot_id_z` int(11) DEFAULT 0"); - statement - .addBatch("UPDATE `plot` SET\n" - + " `plot_id_x` = IF(" - + " LOCATE(';', `plot_id`) > 0," - + " SUBSTRING(`plot_id`, 1, LOCATE(';', `plot_id`) - 1)," - + " `plot_id`" - + " )," - + " `plot_id_z` = IF(" - + " LOCATE(';', `plot_id`) > 0," - + " SUBSTRING(`plot_id`, LOCATE(';', `plot_id`) + 1)," - + " NULL" + " )"); + statement.addBatch("ALTER IGNORE TABLE `plot` ADD `plot_id_x` int(11) DEFAULT 0"); + statement.addBatch("ALTER IGNORE TABLE `plot` ADD `plot_id_z` int(11) DEFAULT 0"); + statement.addBatch("UPDATE `plot` SET\n" + " `plot_id_x` = IF(" + + " LOCATE(';', `plot_id`) > 0," + + " SUBSTRING(`plot_id`, 1, LOCATE(';', `plot_id`) - 1)," + " `plot_id`" + + " )," + " `plot_id_z` = IF(" + " LOCATE(';', `plot_id`) > 0," + + " SUBSTRING(`plot_id`, LOCATE(';', `plot_id`) + 1)," + " NULL" + " )"); statement.addBatch("ALTER TABLE `plot` DROP `plot_id`"); - statement - .addBatch("ALTER IGNORE TABLE `plot_settings` ADD `flags` VARCHAR(512) DEFAULT NULL"); + statement.addBatch("ALTER IGNORE TABLE `plot_settings` ADD `flags` VARCHAR(512) DEFAULT NULL"); statement.executeBatch(); statement.close(); } rs = data.getColumns(null, null, "plot_settings", "merged"); if (!rs.next()) { Statement statement = connection.createStatement(); - statement - .addBatch("ALTER TABLE `plot_settings` ADD `merged` int(11) DEFAULT NULL"); + statement.addBatch("ALTER TABLE `plot_settings` ADD `merged` int(11) DEFAULT NULL"); statement.executeBatch(); statement.close(); } - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); } HashMap> plots = new HashMap>(); @@ -455,19 +415,16 @@ public class DBFunc { Set worlds = new HashSet(); if (PlotMain.config.contains("worlds")) { - worlds = PlotMain.config.getConfigurationSection("worlds") - .getKeys(false); + worlds = PlotMain.config.getConfigurationSection("worlds").getKeys(false); } stmt = connection.createStatement(); - ResultSet r = stmt - .executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world` FROM `plot`"); + ResultSet r = stmt.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world` FROM `plot`"); PlotId plot_id; int id; Plot p; while (r.next()) { - plot_id = new PlotId(r.getInt("plot_id_x"), - r.getInt("plot_id_z")); + plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z")); id = r.getInt("id"); String worldname = r.getString("world"); HashMap settings = getSettings(id); @@ -476,18 +433,18 @@ public class DBFunc { String[] flags_string; if (settings.get("flags") == null) { flags_string = new String[] {}; - } else { + } + else { flags_string = ((String) settings.get("flags")).split(","); } Flag[] flags = new Flag[flags_string.length]; for (int i = 0; i < flags.length; i++) { if (flags_string[i].contains(":")) { String[] split = flags_string[i].split(":"); - flags[i] = new Flag( - FlagManager.getFlag(split[0], true), split[1]); - } else { - flags[i] = new Flag(FlagManager.getFlag( - flags_string[i], true), ""); + flags[i] = new Flag(FlagManager.getFlag(split[0], true), split[1]); + } + else { + flags[i] = new Flag(FlagManager.getFlag(flags_string[i], true), ""); } } ArrayList helpers = plotHelpers(id); @@ -505,7 +462,8 @@ public class DBFunc { boolean rain; try { rain = (int) settings.get("rain") == 1 ? true : false; - } catch (Exception e) { + } + catch (Exception e) { rain = false; } String alias = (String) settings.get("alias"); @@ -513,48 +471,44 @@ public class DBFunc { alias = ""; } PlotHomePosition position = null; - for (PlotHomePosition plotHomePosition : PlotHomePosition - .values()) { + for (PlotHomePosition plotHomePosition : PlotHomePosition.values()) { if (settings.get("position") == null) { position = PlotHomePosition.DEFAULT; break; } - if (plotHomePosition.isMatching((String) settings - .get("position"))) { + if (plotHomePosition.isMatching((String) settings.get("position"))) { position = plotHomePosition; } } if (position == null) { position = PlotHomePosition.DEFAULT; } - int merged_int = settings.get("merged") == null ? 0 - : (int) settings.get("merged"); + int merged_int = settings.get("merged") == null ? 0 : (int) settings.get("merged"); boolean[] merged = new boolean[4]; for (int i = 0; i < 4; i++) { merged[3 - i] = (merged_int & (1 << i)) != 0; } - p = new Plot(plot_id, owner, plotBiome, helpers, trusted, - denied, /* changeTime */false, time, rain, alias, - position, flags, worldname, merged); + p = + new Plot(plot_id, owner, plotBiome, helpers, trusted, denied, /* changeTime */false, time, rain, alias, position, flags, worldname, merged); if (plots.containsKey(worldname)) { plots.get(worldname).put((plot_id), p); - } else { + } + else { if (worlds.contains(p.world)) { HashMap map = new HashMap(); map.put((plot_id), p); plots.put(worldname, map); - } else { - PlotMain.sendConsoleSenderMessage("&cPlot '" - + p.id - + "' in DB for world '" - + p.world + } + else { + PlotMain.sendConsoleSenderMessage("&cPlot '" + p.id + "' in DB for world '" + p.world + "' does not exist! Please create this world, or remove the plots from the DB!"); } } } stmt.close(); - } catch (SQLException e) { + } + catch (SQLException e) { Logger.add(LogLevel.WARNING, "Failed to load plots."); e.printStackTrace(); } @@ -565,31 +519,29 @@ public class DBFunc { * @param plot * @param rain */ - public static void setWeather(final String world, final Plot plot, - final boolean rain) { + public static void setWeather(final String world, final Plot plot, final boolean rain) { plot.settings.setRain(rain); runTask(new Runnable() { @Override public void run() { try { int weather = rain ? 1 : 0; - PreparedStatement stmt = connection - .prepareStatement("UPDATE `plot_settings` SET `rain` = ? WHERE `plot_plot_id` = ?"); + PreparedStatement stmt = + connection.prepareStatement("UPDATE `plot_settings` SET `rain` = ? WHERE `plot_plot_id` = ?"); stmt.setInt(1, weather); stmt.setInt(2, getId(world, plot.id)); stmt.execute(); stmt.close(); - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); - Logger.add(LogLevel.WARNING, - "Could not set weather for plot " + plot.id); + Logger.add(LogLevel.WARNING, "Could not set weather for plot " + plot.id); } } }); } - public static void setMerged(final String world, final Plot plot, - final boolean[] merged) { + public static void setMerged(final String world, final Plot plot, final boolean[] merged) { plot.settings.setMerged(merged); runTask(new Runnable() { @Override @@ -599,23 +551,22 @@ public class DBFunc { for (int i = 0; i < 4; ++i) { n = (n << 1) + (merged[i] ? 1 : 0); } - PreparedStatement stmt = connection - .prepareStatement("UPDATE `plot_settings` SET `merged` = ? WHERE `plot_plot_id` = ?"); + PreparedStatement stmt = + connection.prepareStatement("UPDATE `plot_settings` SET `merged` = ? WHERE `plot_plot_id` = ?"); stmt.setInt(1, n); stmt.setInt(2, getId(world, plot.id)); stmt.execute(); stmt.close(); - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); - Logger.add(LogLevel.WARNING, - "Could not set merged for plot " + plot.id); + Logger.add(LogLevel.WARNING, "Could not set merged for plot " + plot.id); } } }); } - public static void setFlags(final String world, final Plot plot, - final Flag[] flags) { + public static void setFlags(final String world, final Plot plot, final Flag[] flags) { plot.settings.setFlags(flags); final StringBuilder flag_string = new StringBuilder(); int i = 0; @@ -630,16 +581,16 @@ public class DBFunc { @Override public void run() { try { - PreparedStatement stmt = connection - .prepareStatement("UPDATE `plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?"); + PreparedStatement stmt = + connection.prepareStatement("UPDATE `plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?"); stmt.setString(1, flag_string.toString()); stmt.setInt(2, getId(world, plot.id)); stmt.execute(); stmt.close(); - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); - Logger.add(LogLevel.WARNING, "Could not set flag for plot " - + plot.id); + Logger.add(LogLevel.WARNING, "Could not set flag for plot " + plot.id); } } }); @@ -649,23 +600,22 @@ public class DBFunc { * @param plot * @param alias */ - public static void setAlias(final String world, final Plot plot, - final String alias) { + public static void setAlias(final String world, final Plot plot, final String alias) { plot.settings.setAlias(alias); runTask(new Runnable() { @Override public void run() { PreparedStatement stmt = null; try { - stmt = connection - .prepareStatement("UPDATE `plot_settings` SET `alias` = ? WHERE `plot_plot_id` = ?"); + stmt = + connection.prepareStatement("UPDATE `plot_settings` SET `alias` = ? WHERE `plot_plot_id` = ?"); stmt.setString(1, alias); stmt.setInt(2, getId(world, plot.id)); stmt.executeUpdate(); stmt.close(); - } catch (SQLException e) { - Logger.add(LogLevel.WARNING, - "Failed to set alias for plot " + plot.id); + } + catch (SQLException e) { + Logger.add(LogLevel.WARNING, "Failed to set alias for plot " + plot.id); e.printStackTrace(); } @@ -677,31 +627,29 @@ public class DBFunc { * @param r */ private static void runTask(Runnable r) { - PlotMain.getMain().getServer().getScheduler() - .runTaskAsynchronously(PlotMain.getMain(), r); + PlotMain.getMain().getServer().getScheduler().runTaskAsynchronously(PlotMain.getMain(), r); } /** * @param plot * @param position */ - public static void setPosition(final String world, final Plot plot, - final String position) { + public static void setPosition(final String world, final Plot plot, final String position) { plot.settings.setPosition(PlotHomePosition.valueOf(position)); runTask(new Runnable() { @Override public void run() { PreparedStatement stmt = null; try { - stmt = connection - .prepareStatement("UPDATE `plot_settings` SET `position` = ? WHERE `plot_plot_id` = ?"); + stmt = + connection.prepareStatement("UPDATE `plot_settings` SET `position` = ? WHERE `plot_plot_id` = ?"); stmt.setString(1, position); stmt.setInt(2, getId(world, plot.id)); stmt.executeUpdate(); stmt.close(); - } catch (SQLException e) { - Logger.add(LogLevel.WARNING, - "Failed to set position for plot " + plot.id); + } + catch (SQLException e) { + Logger.add(LogLevel.WARNING, "Failed to set position for plot " + plot.id); e.printStackTrace(); } } @@ -716,8 +664,7 @@ public class DBFunc { HashMap h = new HashMap(); PreparedStatement stmt = null; try { - stmt = connection - .prepareStatement("SELECT * FROM `plot_settings` WHERE `plot_plot_id` = ?"); + stmt = connection.prepareStatement("SELECT * FROM `plot_settings` WHERE `plot_plot_id` = ?"); stmt.setInt(1, id); ResultSet r = stmt.executeQuery(); String var; @@ -753,9 +700,9 @@ public class DBFunc { } stmt.close(); ; - } catch (SQLException e) { - Logger.add(LogLevel.WARNING, "Failed to load settings for plot: " - + id); + } + catch (SQLException e) { + Logger.add(LogLevel.WARNING, "Failed to load settings for plot: " + id); e.printStackTrace(); } return h; @@ -774,8 +721,7 @@ public class DBFunc { ArrayList l = new ArrayList(); PreparedStatement stmt = null; try { - stmt = connection - .prepareStatement("SELECT `user_uuid` FROM `plot_denied` WHERE `plot_plot_id` = ?"); + stmt = connection.prepareStatement("SELECT `user_uuid` FROM `plot_denied` WHERE `plot_plot_id` = ?"); stmt.setInt(1, id); ResultSet r = stmt.executeQuery(); UUID u; @@ -784,7 +730,8 @@ public class DBFunc { l.add(u); } stmt.close(); - } catch (Exception e) { + } + catch (Exception e) { Logger.add(LogLevel.DANGER, "Failed to load denied for plot: " + id); e.printStackTrace(); } @@ -800,18 +747,16 @@ public class DBFunc { Statement stmt = null; try { stmt = connection.createStatement(); - ResultSet r = stmt - .executeQuery("SELECT `user_uuid` FROM `plot_helpers` WHERE `plot_plot_id` = " - + id); + ResultSet r = stmt.executeQuery("SELECT `user_uuid` FROM `plot_helpers` WHERE `plot_plot_id` = " + id); UUID u; while (r.next()) { u = UUID.fromString(r.getString("user_uuid")); l.add(u); } stmt.close(); - } catch (SQLException e) { - Logger.add(LogLevel.WARNING, "Failed to load helpers for plot: " - + id); + } + catch (SQLException e) { + Logger.add(LogLevel.WARNING, "Failed to load helpers for plot: " + id); e.printStackTrace(); } return l; @@ -826,18 +771,16 @@ public class DBFunc { Statement stmt = null; try { stmt = connection.createStatement(); - ResultSet r = stmt - .executeQuery("SELECT `user_uuid` FROM `plot_trusted` WHERE `plot_plot_id` = " - + id); + ResultSet r = stmt.executeQuery("SELECT `user_uuid` FROM `plot_trusted` WHERE `plot_plot_id` = " + id); UUID u; while (r.next()) { u = UUID.fromString(r.getString("user_uuid")); l.add(u); } stmt.close(); - } catch (SQLException e) { - Logger.add(LogLevel.WARNING, - "Failed to load trusted users for plot: " + id); + } + catch (SQLException e) { + Logger.add(LogLevel.WARNING, "Failed to load trusted users for plot: " + id); e.printStackTrace(); } return l; @@ -847,22 +790,21 @@ public class DBFunc { * @param plot * @param player */ - public static void removeHelper(final String world, final Plot plot, - final OfflinePlayer player) { + public static void removeHelper(final String world, final Plot plot, final OfflinePlayer player) { runTask(new Runnable() { @Override public void run() { try { - PreparedStatement statement = connection - .prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?"); + PreparedStatement statement = + connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?"); statement.setInt(1, getId(world, plot.id)); statement.setString(2, player.getUniqueId().toString()); statement.executeUpdate(); statement.close(); - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); - Logger.add(LogLevel.WARNING, - "Failed to remove helper for plot " + plot.id); + Logger.add(LogLevel.WARNING, "Failed to remove helper for plot " + plot.id); } } }); @@ -872,22 +814,21 @@ public class DBFunc { * @param plot * @param player */ - public static void removeTrusted(final String world, final Plot plot, - final OfflinePlayer player) { + public static void removeTrusted(final String world, final Plot plot, final OfflinePlayer player) { runTask(new Runnable() { @Override public void run() { try { - PreparedStatement statement = connection - .prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = ? AND `user_uuid` = ?"); + PreparedStatement statement = + connection.prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = ? AND `user_uuid` = ?"); statement.setInt(1, getId(world, plot.id)); statement.setString(2, player.getUniqueId().toString()); statement.executeUpdate(); statement.close(); - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); - Logger.add(LogLevel.WARNING, - "Failed to remove trusted user for plot " + plot.id); + Logger.add(LogLevel.WARNING, "Failed to remove trusted user for plot " + plot.id); } } }); @@ -897,21 +838,20 @@ public class DBFunc { * @param plot * @param player */ - public static void setHelper(final String world, final Plot plot, - final OfflinePlayer player) { + public static void setHelper(final String world, final Plot plot, final OfflinePlayer player) { runTask(new Runnable() { @Override public void run() { try { - PreparedStatement statement = connection - .prepareStatement("INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)"); + PreparedStatement statement = + connection.prepareStatement("INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)"); statement.setInt(1, getId(world, plot.id)); statement.setString(2, player.getUniqueId().toString()); statement.executeUpdate(); statement.close(); - } catch (SQLException e) { - Logger.add(LogLevel.WARNING, - "Failed to set helper for plot " + plot.id); + } + catch (SQLException e) { + Logger.add(LogLevel.WARNING, "Failed to set helper for plot " + plot.id); e.printStackTrace(); } } @@ -922,21 +862,20 @@ public class DBFunc { * @param plot * @param player */ - public static void setTrusted(final String world, final Plot plot, - final OfflinePlayer player) { + public static void setTrusted(final String world, final Plot plot, final OfflinePlayer player) { runTask(new Runnable() { @Override public void run() { try { - PreparedStatement statement = connection - .prepareStatement("INSERT INTO `plot_trusted` (`plot_plot_id`, `user_uuid`) VALUES(?,?)"); + PreparedStatement statement = + connection.prepareStatement("INSERT INTO `plot_trusted` (`plot_plot_id`, `user_uuid`) VALUES(?,?)"); statement.setInt(1, getId(world, plot.id)); statement.setString(2, player.getUniqueId().toString()); statement.executeUpdate(); statement.close(); - } catch (SQLException e) { - Logger.add(LogLevel.WARNING, - "Failed to set plot trusted for plot " + plot.id); + } + catch (SQLException e) { + Logger.add(LogLevel.WARNING, "Failed to set plot trusted for plot " + plot.id); e.printStackTrace(); } } @@ -947,22 +886,21 @@ public class DBFunc { * @param plot * @param player */ - public static void removeDenied(final String world, final Plot plot, - final OfflinePlayer player) { + public static void removeDenied(final String world, final Plot plot, final OfflinePlayer player) { runTask(new Runnable() { @Override public void run() { try { - PreparedStatement statement = connection - .prepareStatement("DELETE FROM `plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?"); + PreparedStatement statement = + connection.prepareStatement("DELETE FROM `plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?"); statement.setInt(1, getId(world, plot.id)); statement.setString(2, player.getUniqueId().toString()); statement.executeUpdate(); statement.close(); - } catch (SQLException e) { + } + catch (SQLException e) { e.printStackTrace(); - Logger.add(LogLevel.WARNING, - "Failed to remove denied for plot " + plot.id); + Logger.add(LogLevel.WARNING, "Failed to remove denied for plot " + plot.id); } } }); @@ -972,21 +910,20 @@ public class DBFunc { * @param plot * @param player */ - public static void setDenied(final String world, final Plot plot, - final OfflinePlayer player) { + public static void setDenied(final String world, final Plot plot, final OfflinePlayer player) { runTask(new Runnable() { @Override public void run() { try { - PreparedStatement statement = connection - .prepareStatement("INSERT INTO `plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)"); + PreparedStatement statement = + connection.prepareStatement("INSERT INTO `plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)"); statement.setInt(1, getId(world, plot.id)); statement.setString(2, player.getUniqueId().toString()); statement.executeUpdate(); statement.close(); - } catch (SQLException e) { - Logger.add(LogLevel.WARNING, - "Failed to set denied for plot " + plot.id); + } + catch (SQLException e) { + Logger.add(LogLevel.WARNING, "Failed to set denied for plot " + plot.id); e.printStackTrace(); } } @@ -995,8 +932,8 @@ public class DBFunc { public static double getRatings(final Plot plot) { try { - PreparedStatement statement = connection - .prepareStatement("SELECT AVG(`rating`) AS `rating` FROM `plot_ratings` WHERE `plot_plot_id` = ? "); + PreparedStatement statement = + connection.prepareStatement("SELECT AVG(`rating`) AS `rating` FROM `plot_ratings` WHERE `plot_plot_id` = ? "); statement.setInt(1, getId(plot.getWorld().getName(), plot.id)); ResultSet set = statement.executeQuery(); double rating = 0; @@ -1005,9 +942,9 @@ public class DBFunc { } statement.close(); return rating; - } catch (SQLException e) { - Logger.add(LogLevel.WARNING, "Failed to fetch rating for plot " - + plot.getId().toString()); + } + catch (SQLException e) { + Logger.add(LogLevel.WARNING, "Failed to fetch rating for plot " + plot.getId().toString()); e.printStackTrace(); } return 0.0d; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/Database.java b/PlotSquared/src/com/intellectualcrafters/plot/database/Database.java index 88c48556d..206ac256e 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/Database.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/Database.java @@ -39,8 +39,7 @@ public abstract class Database { * @throws ClassNotFoundException * if the driver cannot be found */ - public abstract Connection openConnection() throws SQLException, - ClassNotFoundException; + public abstract Connection openConnection() throws SQLException, ClassNotFoundException; /** * Checks if a connection is open with the database @@ -69,7 +68,6 @@ public abstract class Database { /** * Executes a SQL Query
- * * If the connection is closed, it will be opened * * @param query @@ -80,8 +78,7 @@ public abstract class Database { * @throws ClassNotFoundException * If the driver cannot be found; see {@link #openConnection()} */ - public abstract ResultSet querySQL(String query) throws SQLException, - ClassNotFoundException; + public abstract ResultSet querySQL(String query) throws SQLException, ClassNotFoundException; /** * Executes an Update SQL Query
@@ -96,6 +93,5 @@ public abstract class Database { * @throws ClassNotFoundException * If the driver cannot be found; see {@link #openConnection()} */ - public abstract int updateSQL(String query) throws SQLException, - ClassNotFoundException; + public abstract int updateSQL(String query) throws SQLException, ClassNotFoundException; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/MySQL.java b/PlotSquared/src/com/intellectualcrafters/plot/database/MySQL.java index 0e70c3843..9393b6cfd 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/MySQL.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/MySQL.java @@ -39,8 +39,7 @@ public class MySQL extends Database { * @param password * Password */ - public MySQL(Plugin plugin, String hostname, String port, String database, - String username, String password) { + public MySQL(Plugin plugin, String hostname, String port, String database, String username, String password) { super(plugin); this.hostname = hostname; this.port = port; @@ -51,15 +50,13 @@ public class MySQL extends Database { } @Override - public Connection openConnection() throws SQLException, - ClassNotFoundException { + public Connection openConnection() throws SQLException, ClassNotFoundException { if (checkConnection()) { return this.connection; } Class.forName("com.mysql.jdbc.Driver"); - this.connection = DriverManager.getConnection("jdbc:mysql://" - + this.hostname + ":" + this.port + "/" + this.database, - this.user, this.password); + this.connection = + DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password); return this.connection; } @@ -83,8 +80,7 @@ public class MySQL extends Database { } @Override - public ResultSet querySQL(String query) throws SQLException, - ClassNotFoundException { + public ResultSet querySQL(String query) throws SQLException, ClassNotFoundException { if (checkConnection()) { openConnection(); } @@ -97,8 +93,7 @@ public class MySQL extends Database { } @Override - public int updateSQL(String query) throws SQLException, - ClassNotFoundException { + public int updateSQL(String query) throws SQLException, ClassNotFoundException { if (checkConnection()) { openConnection(); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java index 04e804e01..905cba147 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -33,180 +33,143 @@ public class PlotMeConverter { final PrintStream stream = new PrintStream("converter_log.txt"); - Bukkit.getScheduler().runTaskAsynchronously(this.plugin, - new Runnable() { - @Override - public void run() { - PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has started"); - PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Caching playerdata..."); - ArrayList createdPlots = new ArrayList(); - boolean online = Bukkit.getServer().getOnlineMode(); - for (World world : Bukkit.getWorlds()) { - HashMap plots = PlotManager - .getPlots(world); - if (plots != null) { - PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '" - + plots.size() - + "' plots for world '" - + world.getName() + "'"); - - PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting " - + plots.size() - + " plots for '" - + world.toString() + "'..."); - for (Plot plot : plots.values()) { - ArrayList psAdded = new ArrayList<>(); - ArrayList psTrusted = new ArrayList<>(); - ArrayList psDenied = new ArrayList<>(); - if (world == null) { - world = Bukkit.getWorld("world"); - } - long eR3040bl230 = 22392948l; - try { - if (online) { - PlayerList denied = null; - PlayerList added = null; - Field fAdded = plot - .getClass() - .getDeclaredField("allowed"); - Field fDenied = plot.getClass() - .getDeclaredField("denied"); - fAdded.setAccessible(true); - fDenied.setAccessible(true); - added = (PlayerList) fAdded - .get(plot); - denied = (PlayerList) fDenied - .get(plot); - for (Map.Entry set : added - .getAllPlayers().entrySet()) { - if ((set.getValue() != null) - || set.getKey().equals( - "*")) { - if (set.getKey() - .equalsIgnoreCase( - "*") - || set.getValue() - .toString() - .equals("*")) { - psAdded.add(DBFunc.everyone); - continue; - } - } - if (set.getValue() != null) { - psAdded.add(set.getValue()); - } - } - for (Map.Entry set : denied - .getAllPlayers().entrySet()) { - if ((set.getValue() != null) - || set.getKey().equals( - "*")) { - if (set.getKey() - .equals("*") - || set.getValue() - .toString() - .equals("*")) { - psDenied.add(DBFunc.everyone); - continue; - } - } - if (set.getValue() != null) { - psDenied.add(set.getValue()); - } - } - } else { - for (String user : plot - .getAllowed().split(",")) { - if (user.equals("*")) { - psAdded.add(DBFunc.everyone); - } else { - UUID uuid = UUID - .nameUUIDFromBytes(("OfflinePlayer:" + user) - .getBytes(Charsets.UTF_8)); - psAdded.add(uuid); - } - } - try { - for (String user : plot - .getDenied().split(",")) { - if (user.equals("*")) { - psDenied.add(DBFunc.everyone); - } else { - UUID uuid = UUID - .nameUUIDFromBytes(("OfflinePlayer:" + user) - .getBytes(Charsets.UTF_8)); - psDenied.add(uuid); - } - } - } catch (Throwable e) { + Bukkit.getScheduler().runTaskAsynchronously(this.plugin, new Runnable() { + @Override + public void run() { + PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has started"); + PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Caching playerdata..."); + ArrayList createdPlots = + new ArrayList(); + boolean online = Bukkit.getServer().getOnlineMode(); + for (World world : Bukkit.getWorlds()) { + HashMap plots = PlotManager.getPlots(world); + if (plots != null) { + PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '" + plots.size() + + "' plots for world '" + world.getName() + "'"); + PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting " + plots.size() + + " plots for '" + world.toString() + "'..."); + for (Plot plot : plots.values()) { + ArrayList psAdded = new ArrayList<>(); + ArrayList psTrusted = new ArrayList<>(); + ArrayList psDenied = new ArrayList<>(); + if (world == null) { + world = Bukkit.getWorld("world"); + } + long eR3040bl230 = 22392948l; + try { + if (online) { + PlayerList denied = null; + PlayerList added = null; + Field fAdded = plot.getClass().getDeclaredField("allowed"); + Field fDenied = plot.getClass().getDeclaredField("denied"); + fAdded.setAccessible(true); + fDenied.setAccessible(true); + added = (PlayerList) fAdded.get(plot); + denied = (PlayerList) fDenied.get(plot); + for (Map.Entry set : added.getAllPlayers().entrySet()) { + if ((set.getValue() != null) || set.getKey().equals("*")) { + if (set.getKey().equalsIgnoreCase("*") + || set.getValue().toString().equals("*")) { + psAdded.add(DBFunc.everyone); + continue; } } - } catch (Throwable e) { - e.printStackTrace(); - eR3040bl230 = 232000499888388747l; - } finally { - eR3040bl230 = 232999304998392004l; + if (set.getValue() != null) { + psAdded.add(set.getValue()); + } } - stream.println(eR3040bl230); - PlotId id = new PlotId( - Integer.parseInt(plot.id.split(";")[0]), - Integer.parseInt(plot.id.split(";")[1])); - com.intellectualcrafters.plot.Plot pl = null; - if (online) { - pl = new com.intellectualcrafters.plot.Plot( - id, plot.getOwnerId(), plot - .getBiome(), psAdded, - psTrusted, psDenied, false, - 8000l, false, "", - PlotHomePosition.DEFAULT, null, - world.getName(), new boolean[] { - false, false, false, - false }); - } else { - String owner = plot.getOwner(); - pl = new com.intellectualcrafters.plot.Plot( - id, - UUID.nameUUIDFromBytes(("OfflinePlayer:" + owner) - .getBytes(Charsets.UTF_8)), - plot.getBiome(), psAdded, - psTrusted, psDenied, false, - 8000l, false, "", - PlotHomePosition.DEFAULT, null, - world.getName(), new boolean[] { - false, false, false, - false }); + for (Map.Entry set : denied.getAllPlayers().entrySet()) { + if ((set.getValue() != null) || set.getKey().equals("*")) { + if (set.getKey().equals("*") || set.getValue().toString().equals("*")) { + psDenied.add(DBFunc.everyone); + continue; + } + } + if (set.getValue() != null) { + psDenied.add(set.getValue()); + } } + } + else { + for (String user : plot.getAllowed().split(",")) { + if (user.equals("*")) { + psAdded.add(DBFunc.everyone); + } + else { + UUID uuid = + UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8)); + psAdded.add(uuid); + } + } + try { + for (String user : plot.getDenied().split(",")) { + if (user.equals("*")) { + psDenied.add(DBFunc.everyone); + } + else { + UUID uuid = + UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8)); + psDenied.add(uuid); + } + } + } + catch (Throwable e) { - // TODO createPlot doesn't add helpers / - // denied - // users - if (pl != null) { - createdPlots.add(pl); } } } - } - PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating plot DB"); - DBFunc.createPlots(createdPlots); - PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating settings/helpers DB"); - DBFunc.createAllSettingsAndHelpers(createdPlots); - stream.close(); - PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has finished"); - // TODO disable PlotMe -> Unload all plot worlds, change - // the - // generator, restart the server automatically - // Possibly use multiverse / multiworld if it's to - // difficult - // modifying a world's generator while the server is - // running - // Should really do that? Would seem pretty bad from our - // side + - // bukkit wouldn't approve + catch (Throwable e) { + e.printStackTrace(); + eR3040bl230 = 232000499888388747l; + } + finally { + eR3040bl230 = 232999304998392004l; + } + stream.println(eR3040bl230); + PlotId id = + new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1])); + com.intellectualcrafters.plot.Plot pl = null; + if (online) { + pl = + new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { + false, false, false, false }); + } + else { + String owner = plot.getOwner(); + pl = + new com.intellectualcrafters.plot.Plot(id, UUID.nameUUIDFromBytes(("OfflinePlayer:" + owner).getBytes(Charsets.UTF_8)), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { + false, false, false, false }); + } - Bukkit.getPluginManager().disablePlugin( - PlotMeConverter.this.plugin); + // TODO createPlot doesn't add helpers / + // denied + // users + if (pl != null) { + createdPlots.add(pl); + } + } } - }); + } + PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating plot DB"); + DBFunc.createPlots(createdPlots); + PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating settings/helpers DB"); + DBFunc.createAllSettingsAndHelpers(createdPlots); + stream.close(); + PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has finished"); + // TODO disable PlotMe -> Unload all plot worlds, change + // the + // generator, restart the server automatically + // Possibly use multiverse / multiworld if it's to + // difficult + // modifying a world's generator while the server is + // running + // Should really do that? Would seem pretty bad from our + // side + + // bukkit wouldn't approve + + Bukkit.getPluginManager().disablePlugin(PlotMeConverter.this.plugin); + } + }); } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/SQLite.java b/PlotSquared/src/com/intellectualcrafters/plot/database/SQLite.java index 78402e4f6..78fe58323 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/SQLite.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/SQLite.java @@ -36,8 +36,7 @@ public class SQLite extends Database { } @Override - public Connection openConnection() throws SQLException, - ClassNotFoundException { + public Connection openConnection() throws SQLException, ClassNotFoundException { if (checkConnection()) { return this.connection; } @@ -48,15 +47,15 @@ public class SQLite extends Database { if (!(file.exists())) { try { file.createNewFile(); - } catch (IOException e) { - this.plugin.getLogger().log(Level.SEVERE, - "Unable to create database!"); + } + catch (IOException e) { + this.plugin.getLogger().log(Level.SEVERE, "Unable to create database!"); } } Class.forName("org.sqlite.JDBC"); - this.connection = DriverManager.getConnection("jdbc:sqlite:" - + this.plugin.getDataFolder().toPath().toString() + "/" - + this.dbLocation); + this.connection = + DriverManager.getConnection("jdbc:sqlite:" + this.plugin.getDataFolder().toPath().toString() + "/" + + this.dbLocation); return this.connection; } @@ -80,8 +79,7 @@ public class SQLite extends Database { } @Override - public ResultSet querySQL(String query) throws SQLException, - ClassNotFoundException { + public ResultSet querySQL(String query) throws SQLException, ClassNotFoundException { if (checkConnection()) { openConnection(); } @@ -94,8 +92,7 @@ public class SQLite extends Database { } @Override - public int updateSQL(String query) throws SQLException, - ClassNotFoundException { + public int updateSQL(String query) throws SQLException, ClassNotFoundException { if (checkConnection()) { openConnection(); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java index d4bc95b41..f6345e3e4 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerClaimPlotEvent.java @@ -1,10 +1,10 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlayerClaimPlotEvent.java - * >> Generated by: Citymonstret at 2014-08-09 15:21 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlayerClaimPlotEvent.java >> Generated by: Citymonstret at + * 2014-08-09 15:21 */ package com.intellectualcrafters.plot.events; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java index f6c90eeb0..bc72a4a90 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotDeniedEvent.java @@ -28,8 +28,7 @@ public class PlayerPlotDeniedEvent extends Event { * @param player * @param added */ - public PlayerPlotDeniedEvent(Player initiator, Plot plot, UUID player, - boolean added) { + public PlayerPlotDeniedEvent(Player initiator, Plot plot, UUID player, boolean added) { this.initiator = initiator; this.plot = plot; this.added = added; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java index d4d24c4d2..3eedfbad0 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotHelperEvent.java @@ -27,8 +27,7 @@ public class PlayerPlotHelperEvent extends Event { * @param player * @param added */ - public PlayerPlotHelperEvent(Player initiator, Plot plot, UUID player, - boolean added) { + public PlayerPlotHelperEvent(Player initiator, Plot plot, UUID player, boolean added) { this.initiator = initiator; this.plot = plot; this.added = added; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java index bacb8804f..142a9f84d 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerPlotTrustedEvent.java @@ -27,8 +27,7 @@ public class PlayerPlotTrustedEvent extends Event { * @param player * @param added */ - public PlayerPlotTrustedEvent(Player initiator, Plot plot, UUID player, - boolean added) { + public PlayerPlotTrustedEvent(Player initiator, Plot plot, UUID player, boolean added) { this.initiator = initiator; this.plot = plot; this.added = added; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java index 3ca03053b..6ab6acc8d 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlayerTeleportToPlotEvent.java @@ -1,10 +1,10 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlayerTeleportToPlotEvent.java - * >> Generated by: Citymonstret at 2014-08-09 14:57 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlayerTeleportToPlotEvent.java >> Generated by: Citymonstret at + * 2014-08-09 14:57 */ package com.intellectualcrafters.plot.events; @@ -20,8 +20,7 @@ import com.intellectualcrafters.plot.Plot; /** * Called when a player teleports to a plot */ -public class PlayerTeleportToPlotEvent extends PlayerEvent implements - Cancellable { +public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private Location from; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotClearEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotClearEvent.java index 5b6a6751c..7ea9c3165 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotClearEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotClearEvent.java @@ -1,10 +1,10 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlotClearEvent.java - * >> Generated by: Citymonstret at 2014-08-09 15:21 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlotClearEvent.java >> Generated by: Citymonstret at 2014-08-09 + * 15:21 */ package com.intellectualcrafters.plot.events; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotDeleteEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotDeleteEvent.java index 106af2d87..e605bba35 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotDeleteEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotDeleteEvent.java @@ -1,10 +1,10 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlotDeleteEvent.java - * >> Generated by: Citymonstret at 2014-08-09 15:21 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlotDeleteEvent.java >> Generated by: Citymonstret at 2014-08-09 + * 15:21 */ package com.intellectualcrafters.plot.events; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java index b3ba5a98c..16ffada92 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagAddEvent.java @@ -1,10 +1,10 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlayerClaimPlotEvent.java - * >> Generated by: Citymonstret at 2014-08-09 15:21 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlayerClaimPlotEvent.java >> Generated by: Citymonstret at + * 2014-08-09 15:21 */ package com.intellectualcrafters.plot.events; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java index 5c9724df2..34294fb42 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotFlagRemoveEvent.java @@ -1,10 +1,10 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlayerClaimPlotEvent.java - * >> Generated by: Citymonstret at 2014-08-09 15:21 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlayerClaimPlotEvent.java >> Generated by: Citymonstret at + * 2014-08-09 15:21 */ package com.intellectualcrafters.plot.events; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotMergeEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotMergeEvent.java index c04af33b4..8335054c5 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotMergeEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotMergeEvent.java @@ -1,10 +1,10 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlayerClaimPlotEvent.java - * >> Generated by: Citymonstret at 2014-08-09 15:21 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlayerClaimPlotEvent.java >> Generated by: Citymonstret at + * 2014-08-09 15:21 */ package com.intellectualcrafters.plot.events; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java index 24d24eaf7..5197a7ca5 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/events/PlotUnlinkEvent.java @@ -1,10 +1,10 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlayerClaimPlotEvent.java - * >> Generated by: Citymonstret at 2014-08-09 15:21 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlayerClaimPlotEvent.java >> Generated by: Citymonstret at + * 2014-08-09 15:21 */ package com.intellectualcrafters.plot.events; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/generator/DefaultPlotManager.java b/PlotSquared/src/com/intellectualcrafters/plot/generator/DefaultPlotManager.java index 0668d9ffe..742e594a2 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/generator/DefaultPlotManager.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/generator/DefaultPlotManager.java @@ -21,17 +21,14 @@ import com.intellectualcrafters.plot.PlotWorld; public class DefaultPlotManager extends PlotManager { /** - * Default implementation of getting a plot at a given location - * - * For a simplified explanation of the math involved: - Get the current - * coords - shift these numbers down to something relatable for a single - * plot (similar to reducing trigonometric functions down to the first - * quadrant) - e.g. If the plot size is 20 blocks, and we are at x=25, it's - * equivalent to x=5 for that specific plot - * - * From this, and knowing how thick the road is, we can say whether x=5 is - * road, or plot. The number of shifts done, is also counted, and this - * number gives us the PlotId + * Default implementation of getting a plot at a given location For a + * simplified explanation of the math involved: - Get the current coords - + * shift these numbers down to something relatable for a single plot + * (similar to reducing trigonometric functions down to the first quadrant) + * - e.g. If the plot size is 20 blocks, and we are at x=25, it's equivalent + * to x=5 for that specific plot From this, and knowing how thick the road + * is, we can say whether x=5 is road, or plot. The number of shifts done, + * is also counted, and this number gives us the PlotId */ @Override public PlotId getPlotIdAbs(PlotWorld plotworld, Location loc) { @@ -49,7 +46,8 @@ public class DefaultPlotManager extends PlotManager { int pathWidthLower; if ((dpw.ROAD_WIDTH % 2) == 0) { pathWidthLower = (int) (Math.floor(dpw.ROAD_WIDTH / 2) - 1); - } else { + } + else { pathWidthLower = (int) Math.floor(dpw.ROAD_WIDTH / 2); } @@ -98,7 +96,8 @@ public class DefaultPlotManager extends PlotManager { int pathWidthLower; if ((dpw.ROAD_WIDTH % 2) == 0) { pathWidthLower = (int) (Math.floor(dpw.ROAD_WIDTH / 2) - 1); - } else { + } + else { pathWidthLower = (int) Math.floor(dpw.ROAD_WIDTH / 2); } @@ -123,8 +122,7 @@ public class DefaultPlotManager extends PlotManager { boolean eastWest = (rx <= pathWidthLower) || (rx > end); if (northSouth && eastWest) { // This means you are in the intersection - PlotId id = PlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, - dpw.ROAD_WIDTH)); + PlotId id = PlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, dpw.ROAD_WIDTH)); Plot plot = PlotMain.getPlots(loc.getWorld()).get(id); if (plot == null) { return null; @@ -137,8 +135,7 @@ public class DefaultPlotManager extends PlotManager { if (northSouth) { // You are on a road running West to East (yeah, I named the var // poorly) - PlotId id = PlayerFunctions.getPlotAbs(loc - .add(0, 0, dpw.ROAD_WIDTH)); + PlotId id = PlayerFunctions.getPlotAbs(loc.add(0, 0, dpw.ROAD_WIDTH)); Plot plot = PlotMain.getPlots(loc.getWorld()).get(id); if (plot == null) { return null; @@ -150,8 +147,7 @@ public class DefaultPlotManager extends PlotManager { } if (eastWest) { // This is the road separating an Eastern and Western plot - PlotId id = PlayerFunctions.getPlotAbs(loc - .add(dpw.ROAD_WIDTH, 0, 0)); + PlotId id = PlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, 0)); Plot plot = PlotMain.getPlots(loc.getWorld()).get(id); if (plot == null) { return null; @@ -193,10 +189,8 @@ public class DefaultPlotManager extends PlotManager { int px = plotid.x; int pz = plotid.y; - int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; - int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; + int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; + int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; return new Location(Bukkit.getWorld(plotworld.worldname), x, 1, z); } @@ -211,10 +205,8 @@ public class DefaultPlotManager extends PlotManager { int px = plotid.x; int pz = plotid.y; - int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; - int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; + int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; + int z = (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1; return new Location(Bukkit.getWorld(plotworld.worldname), x, 256, z); } @@ -223,46 +215,26 @@ public class DefaultPlotManager extends PlotManager { * Clearing the plot needs to only consider removing the blocks - This * implementation has used the SetCuboid function, as it is fast, and uses * NMS code - It also makes use of the fact that deleting chunks is a lot - * faster than block updates - * - * This code is very messy, but you don't need to do something quite as - * complex unless you happen to have 512x512 sized plots + * faster than block updates This code is very messy, but you don't need to + * do something quite as complex unless you happen to have 512x512 sized + * plots */ @Override public boolean clearPlot(Player player, Plot plot) { World world = player.getWorld(); - DefaultPlotWorld dpw = ((DefaultPlotWorld) PlotMain - .getWorldSettings(world)); + DefaultPlotWorld dpw = ((DefaultPlotWorld) PlotMain.getWorldSettings(world)); - final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add( - 1, 0, 1); + final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1); final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); PlotBlock[] plotfloor = dpw.TOP_BLOCK; PlotBlock[] filling = dpw.TOP_BLOCK; if ((pos2.getBlockX() - pos1.getBlockX()) < 16) { - PlotHelper.setSimpleCuboid( - world, - new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), - new Location(world, pos2.getBlockX() + 1, 1, pos2 - .getBlockZ() + 1), new PlotBlock((short) 7, - (byte) 0)); - PlotHelper.setSimpleCuboid( - world, - new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, - pos1.getBlockZ()), - new Location(world, pos2.getBlockX() + 1, world - .getMaxHeight() + 1, pos2.getBlockZ() + 1), - new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), - 1, pos1.getBlockZ()), - new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, - pos2.getBlockZ() + 1), filling); - PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), - dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, - pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, - pos2.getBlockZ() + 1), plotfloor); + PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling); + PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor); return true; } int startX = (pos1.getBlockX() / 16) * 16; @@ -279,73 +251,45 @@ public class DefaultPlotManager extends PlotManager { Location max = null; for (int i = startX; i < chunkX; i += 16) { for (int j = startZ; j < chunkZ; j += 16) { - Plot plot1 = PlotHelper.getCurrentPlot(new Location(world, i, - 0, j)); - if ((plot1 != null) && (plot1.getId() != plot.getId()) - && plot1.hasOwner()) { + Plot plot1 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j)); + if ((plot1 != null) && (plot1.getId() != plot.getId()) && plot1.hasOwner()) { break; } - Plot plot2 = PlotHelper.getCurrentPlot(new Location(world, - i + 15, 0, j)); - if ((plot2 != null) && (plot2.getId() != plot.getId()) - && plot2.hasOwner()) { + Plot plot2 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j)); + if ((plot2 != null) && (plot2.getId() != plot.getId()) && plot2.hasOwner()) { break; } - Plot plot3 = PlotHelper.getCurrentPlot(new Location(world, - i + 15, 0, j + 15)); - if ((plot3 != null) && (plot3.getId() != plot.getId()) - && plot3.hasOwner()) { + Plot plot3 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15)); + if ((plot3 != null) && (plot3.getId() != plot.getId()) && plot3.hasOwner()) { break; } - Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i, - 0, j + 15)); - if ((plot4 != null) && (plot4.getId() != plot.getId()) - && plot4.hasOwner()) { + Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j + 15)); + if ((plot4 != null) && (plot4.getId() != plot.getId()) && plot4.hasOwner()) { break; } - Plot plot5 = PlotHelper.getCurrentPlot(new Location(world, - i + 15, 0, j + 15)); - if ((plot5 != null) && (plot5.getId() != plot.getId()) - && plot5.hasOwner()) { + Plot plot5 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15)); + if ((plot5 != null) && (plot5.getId() != plot.getId()) && plot5.hasOwner()) { break; } if (min == null) { - min = new Location(world, Math.max(i - 1, plotMinX), 0, - Math.max(j - 1, plotMinZ)); - max = new Location(world, Math.min(i + 16, plotMaxX), 0, - Math.min(j + 16, plotMaxZ)); - } else if ((max.getBlockZ() < (j + 15)) - || (max.getBlockX() < (i + 15))) { - max = new Location(world, Math.min(i + 16, plotMaxX), 0, - Math.min(j + 16, plotMaxZ)); + min = new Location(world, Math.max(i - 1, plotMinX), 0, Math.max(j - 1, plotMinZ)); + max = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ)); } + else + if ((max.getBlockZ() < (j + 15)) || (max.getBlockX() < (i + 15))) { + max = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ)); + } world.regenerateChunk(i / 16, j / 16); } } if (min == null) { - PlotHelper.setSimpleCuboid( - world, - new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), - new Location(world, pos2.getBlockX() + 1, 1, pos2 - .getBlockZ() + 1), new PlotBlock((short) 7, - (byte) 0)); - PlotHelper.setSimpleCuboid( - world, - new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, - pos1.getBlockZ()), - new Location(world, pos2.getBlockX() + 1, world - .getMaxHeight() + 1, pos2.getBlockZ() + 1), - new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), - 1, pos1.getBlockZ()), - new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, - pos2.getBlockZ() + 1), filling); - PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), - dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, - pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, - pos2.getBlockZ() + 1), plotfloor); - } else { + PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + PlotHelper.setSimpleCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, world.getMaxHeight() + 1, pos2.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling); + PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getBlockZ() + 1), plotfloor); + } + else { if (min.getBlockX() < plotMinX) { min.setX(plotMinX); @@ -360,161 +304,45 @@ public class DefaultPlotManager extends PlotManager { max.setZ(plotMaxZ); } - PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, - plotMinZ), - new Location(world, min.getBlockX() + 1, 1, - min.getBlockZ() + 1), new PlotBlock((short) 7, - (byte) 0)); - PlotHelper - .setSimpleCuboid( - world, - new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, - plotMinZ), - new Location(world, min.getBlockX() + 1, world - .getMaxHeight() + 1, min.getBlockZ() + 1), - new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, - plotMinZ), new Location(world, min.getBlockX() + 1, - dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), filling); - PlotHelper.setCuboid(world, new Location(world, plotMinX, - dpw.PLOT_HEIGHT, plotMinZ), - new Location(world, min.getBlockX() + 1, - dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), - plotfloor); + PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), filling); + PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); - PlotHelper.setSimpleCuboid(world, - new Location(world, min.getBlockX(), 0, plotMinZ), - new Location(world, max.getBlockX() + 1, 1, - min.getBlockZ() + 1), new PlotBlock((short) 7, - (byte) 0)); - PlotHelper.setSimpleCuboid(world, - new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, - plotMinZ), new Location(world, max.getBlockX() + 1, - world.getMaxHeight() + 1, min.getBlockZ() + 1), - new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, - plotMinZ), new Location(world, max.getBlockX() + 1, - dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling); - PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), - dpw.PLOT_HEIGHT, plotMinZ), - new Location(world, max.getBlockX() + 1, - dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), - plotfloor); + PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, plotMinZ), new Location(world, max.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling); + PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); - PlotHelper.setSimpleCuboid(world, - new Location(world, max.getBlockX(), 0, plotMinZ), - new Location(world, plotMaxX + 1, 1, min.getBlockZ() + 1), - new PlotBlock((short) 7, (byte) 0)); - PlotHelper.setSimpleCuboid(world, - new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, - plotMinZ), - new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, - min.getBlockZ() + 1), new PlotBlock((short) 0, - (byte) 0)); - PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, - plotMinZ), new Location(world, plotMaxX + 1, - dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling); - PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), - dpw.PLOT_HEIGHT, plotMinZ), new Location(world, - plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), - plotfloor); + PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, min.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling); + PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), plotfloor); - PlotHelper - .setSimpleCuboid( - world, - new Location(world, plotMinX, 0, min.getBlockZ()), - new Location(world, min.getBlockX() + 1, 1, max - .getBlockZ() + 1), new PlotBlock((short) 7, - (byte) 0)); - PlotHelper.setSimpleCuboid( - world, - new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min - .getBlockZ()), - new Location(world, min.getBlockX() + 1, world - .getMaxHeight() + 1, max.getBlockZ() + 1), - new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(world, - new Location(world, plotMinX, 1, min.getBlockZ()), - new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, - max.getBlockZ() + 1), filling); - PlotHelper.setCuboid(world, new Location(world, plotMinX, - dpw.PLOT_HEIGHT, min.getBlockZ()), - new Location(world, min.getBlockX() + 1, - dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), - plotfloor); + PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, max.getBlockZ() + 1), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling); + PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor); - PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, - max.getBlockZ()), new Location(world, min.getBlockX() + 1, - 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); - PlotHelper.setSimpleCuboid( - world, - new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max - .getBlockZ()), - new Location(world, min.getBlockX() + 1, world - .getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock( - (short) 0, (byte) 0)); - PlotHelper.setCuboid(world, - new Location(world, plotMinX, 1, max.getBlockZ()), - new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, - plotMaxZ + 1), filling); - PlotHelper.setCuboid(world, new Location(world, plotMinX, - dpw.PLOT_HEIGHT, max.getBlockZ()), - new Location(world, min.getBlockX() + 1, - dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); + PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); - PlotHelper.setSimpleCuboid(world, - new Location(world, min.getBlockX(), 0, max.getBlockZ()), - new Location(world, max.getBlockX() + 1, 1, plotMaxZ + 1), - new PlotBlock((short) 7, (byte) 0)); - PlotHelper.setSimpleCuboid( - world, - new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, - max.getBlockZ()), - new Location(world, max.getBlockX() + 1, world - .getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock( - (short) 0, (byte) 0)); - PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, - max.getBlockZ()), new Location(world, max.getBlockX() + 1, - dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); - PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), - dpw.PLOT_HEIGHT, max.getBlockZ()), - new Location(world, max.getBlockX() + 1, - dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); + PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, max.getBlockZ()), new Location(world, max.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); + PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); - PlotHelper.setSimpleCuboid(world, - new Location(world, max.getBlockX(), 0, min.getBlockZ()), - new Location(world, plotMaxX + 1, 1, max.getBlockZ() + 1), - new PlotBlock((short) 7, (byte) 0)); - PlotHelper.setSimpleCuboid(world, - new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, - max.getBlockZ()), new Location(world, plotMaxX + 1, - world.getMaxHeight() + 1, plotMaxZ + 1), - new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, - min.getBlockZ()), new Location(world, plotMaxX + 1, - dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling); - PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), - dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, - plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), - plotfloor); + PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, min.getBlockZ()), new Location(world, plotMaxX + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0)); + PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling); + PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1), plotfloor); - PlotHelper.setSimpleCuboid(world, - new Location(world, max.getBlockX(), 0, max.getBlockZ()), - new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), - new PlotBlock((short) 7, (byte) 0)); - PlotHelper.setSimpleCuboid(world, - new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, - max.getBlockZ()), new Location(world, plotMaxX + 1, - world.getMaxHeight() + 1, plotMaxZ + 1), - new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, - max.getBlockZ()), new Location(world, plotMaxX + 1, - dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); - PlotHelper - .setCuboid(world, new Location(world, max.getBlockX(), - dpw.PLOT_HEIGHT, max.getBlockZ()), new Location( - world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, - plotMaxZ + 1), plotfloor); + PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0)); + PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, plotMaxX + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling); + PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor); } return true; } @@ -526,25 +354,20 @@ public class DefaultPlotManager extends PlotManager { public Location getSignLoc(Player player, PlotWorld plotworld, Plot plot) { DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld; World world = player.getWorld(); - return new Location(world, PlotHelper.getPlotBottomLoc(world, plot.id) - .getBlockX(), dpw.ROAD_HEIGHT + 1, PlotHelper.getPlotBottomLoc( - world, plot.id).getBlockZ() - 1); + return new Location(world, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX(), dpw.ROAD_HEIGHT + 1, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1); } @Override - public boolean setFloor(Player player, PlotWorld plotworld, PlotId plotid, - PlotBlock[] blocks) { + public boolean setFloor(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock[] blocks) { World world = player.getWorld(); - final Location pos1 = PlotHelper.getPlotBottomLoc(world, plotid).add(1, - 0, 1); + final Location pos1 = PlotHelper.getPlotBottomLoc(world, plotid).add(1, 0, 1); final Location pos2 = PlotHelper.getPlotTopLoc(world, plotid); PlotHelper.setCuboid(world, pos1, pos2, blocks); return true; } @Override - public boolean setWall(Player player, PlotWorld plotworld, PlotId plotid, - PlotBlock plotblock) { + public boolean setWall(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock plotblock) { DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld; World w = player.getWorld(); @@ -629,30 +452,15 @@ public class DefaultPlotManager extends PlotManager { int sz = pos1.getBlockZ() - 1; int ez = pos2.getBlockZ() + 2; - PlotHelper - .setSimpleCuboid( - w, - new Location(w, sx, Math.min(dpw.WALL_HEIGHT, - dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, - ex + 1, 257 + 1, ez), new PlotBlock((short) 0, - (byte) 0)); + PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setSimpleCuboid(w, new Location(w, sx, 1, sz + 1), - new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), - dpw.WALL_FILLING); - PlotHelper.setSimpleCuboid(w, new Location(w, sx, dpw.WALL_HEIGHT + 1, - sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 2, ez), - dpw.WALL_BLOCK); + PlotHelper.setSimpleCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING); + PlotHelper.setSimpleCuboid(w, new Location(w, sx, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK); - PlotHelper.setSimpleCuboid(w, new Location(w, ex, 1, sz + 1), - new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), - dpw.WALL_FILLING); - PlotHelper.setSimpleCuboid(w, new Location(w, ex, dpw.WALL_HEIGHT + 1, - sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 2, ez), - dpw.WALL_BLOCK); + PlotHelper.setSimpleCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING); + PlotHelper.setSimpleCuboid(w, new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 2, ez), dpw.WALL_BLOCK); - PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), - new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); + PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); return true; } @@ -670,30 +478,15 @@ public class DefaultPlotManager extends PlotManager { int sx = pos1.getBlockX() - 1; int ex = pos2.getBlockX() + 2; - PlotHelper - .setSimpleCuboid( - w, - new Location(w, sx, Math.min(dpw.WALL_HEIGHT, - dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, - ex + 1, 257, ez), new PlotBlock((short) 0, - (byte) 0)); + PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz), - new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), - dpw.WALL_FILLING); - PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, - dpw.WALL_HEIGHT + 1, sz), new Location(w, ex, - dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK); + PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING); + PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK); - PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, ez), - new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), - dpw.WALL_FILLING); - PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, - dpw.WALL_HEIGHT + 1, ez), new Location(w, ex, - dpw.WALL_HEIGHT + 2, ez + 1), dpw.WALL_BLOCK); + PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING); + PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 2, ez + 1), dpw.WALL_BLOCK); - PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), - new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); + PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); return true; } @@ -710,11 +503,8 @@ public class DefaultPlotManager extends PlotManager { int sz = pos2.getBlockZ() + 1; int ez = (sz + dpw.ROAD_WIDTH) - 1; - PlotHelper.setSimpleCuboid(w, new Location(w, sx, dpw.ROAD_HEIGHT + 1, - sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock( - (short) 0, (byte) 0)); - PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), - new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); + PlotHelper.setSimpleCuboid(w, new Location(w, sx, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK); return true; } @@ -732,16 +522,9 @@ public class DefaultPlotManager extends PlotManager { int sz = pos1.getBlockZ(); int ez = pos2.getBlockZ() + 1; - PlotHelper.setSimpleCuboid(w, - new Location(w, sx, - Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), - new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, - (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, - ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); - PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), - new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), - dpw.TOP_BLOCK); + PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); + PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); return true; } @@ -759,16 +542,9 @@ public class DefaultPlotManager extends PlotManager { int sx = pos1.getBlockX(); int ex = pos2.getBlockX() + 1; - PlotHelper.setSimpleCuboid(w, - new Location(w, sx, - Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), - new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, - (byte) 0)); - PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, - ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); - PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), - new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), - dpw.TOP_BLOCK); + PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK); + PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1), dpw.TOP_BLOCK); return true; } @@ -785,15 +561,10 @@ public class DefaultPlotManager extends PlotManager { int sz = loc.getBlockZ() + 1; int ez = (sz + dpw.ROAD_WIDTH) - 1; - PlotHelper.setSimpleCuboid(world, new Location(world, sx, - dpw.ROAD_HEIGHT + 1, sz), new Location(world, ex + 1, 257, - ez + 1), new PlotBlock((short) 0, (byte) 0)); + PlotHelper.setSimpleCuboid(world, new Location(world, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(world, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0)); - PlotHelper.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), - new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK); - PlotHelper.setCuboid(world, new Location(world, sx + 1, - dpw.ROAD_HEIGHT, sz + 1), new Location(world, ex, - dpw.ROAD_HEIGHT + 1, ez), dpw.TOP_BLOCK); + PlotHelper.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK); + PlotHelper.setCuboid(world, new Location(world, sx + 1, dpw.ROAD_HEIGHT, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.TOP_BLOCK); return true; } @@ -802,8 +573,7 @@ public class DefaultPlotManager extends PlotManager { * (OPTIONAL)(UNFINISHED) */ @Override - public boolean finishPlotMerge(World world, PlotWorld plotworld, - ArrayList plotIds) { + public boolean finishPlotMerge(World world, PlotWorld plotworld, ArrayList plotIds) { // TODO set plot wall @@ -815,16 +585,12 @@ public class DefaultPlotManager extends PlotManager { PlotBlock block = dpw.WALL_BLOCK; Location megaPlotBot = PlotHelper.getPlotBottomLoc(world, pos1); - Location megaPlotTop = PlotHelper.getPlotTopLoc(world, pos2).add(1, 0, - 1); + Location megaPlotTop = PlotHelper.getPlotTopLoc(world, pos2).add(1, 0, 1); for (int x = megaPlotBot.getBlockX(); x <= megaPlotTop.getBlockX(); x++) { for (int z = megaPlotBot.getBlockZ(); z <= megaPlotTop.getBlockZ(); z++) { - if ((z == megaPlotBot.getBlockZ()) - || (z == megaPlotTop.getBlockZ()) - || (x == megaPlotBot.getBlockX()) + if ((z == megaPlotBot.getBlockZ()) || (z == megaPlotTop.getBlockZ()) || (x == megaPlotBot.getBlockX()) || (x == megaPlotTop.getBlockX())) { - world.getBlockAt(x, dpw.WALL_HEIGHT + 1, z) - .setTypeIdAndData(block.id, block.data, false); + world.getBlockAt(x, dpw.WALL_HEIGHT + 1, z).setTypeIdAndData(block.id, block.data, false); } } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/generator/DefaultPlotWorld.java b/PlotSquared/src/com/intellectualcrafters/plot/generator/DefaultPlotWorld.java index d2bdbb053..2b15f8fa1 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/generator/DefaultPlotWorld.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/generator/DefaultPlotWorld.java @@ -68,8 +68,7 @@ public class DefaultPlotWorld extends PlotWorld { /** * Default main block: 1 */ - public static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock( - (short) 1, (byte) 0) }; + public static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 1, (byte) 0) }; /** * Top blocks */ @@ -77,8 +76,7 @@ public class DefaultPlotWorld extends PlotWorld { /** * Default top blocks: {"2"} */ - public static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock( - (short) 2, (byte) 0) }; + public static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 2, (byte) 0) }; /** * Wall block @@ -96,8 +94,7 @@ public class DefaultPlotWorld extends PlotWorld { /** * Default wall filling: 1 */ - public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, - (byte) 0); + public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0); /** * Road stripes @@ -106,8 +103,7 @@ public class DefaultPlotWorld extends PlotWorld { /** * Default road stripes: 35 */ - public static PlotBlock ROAD_STRIPES_DEFAULT = new PlotBlock((short) 98, - (byte) 0); + public static PlotBlock ROAD_STRIPES_DEFAULT = new PlotBlock((short) 98, (byte) 0); /** * enable road stripes */ @@ -120,8 +116,7 @@ public class DefaultPlotWorld extends PlotWorld { /** * Default road block: 155 */ - public static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155, - (byte) 0); + public static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155, (byte) 0); /* * Here we are just calling the super method, nothing special @@ -142,32 +137,19 @@ public class DefaultPlotWorld extends PlotWorld { @Override public ConfigurationNode[] getSettingNodes() { // TODO return a set of configuration nodes (used for setup command) - return new ConfigurationNode[] { - new ConfigurationNode("plot.height", DefaultPlotWorld.PLOT_HEIGHT_DEFAULT, - "Plot height", Configuration.INTEGER, true), - new ConfigurationNode("plot.width", DefaultPlotWorld.PLOT_WIDTH_DEFAULT, - "Plot width", Configuration.INTEGER, true), - new ConfigurationNode("plot.filling", DefaultPlotWorld.MAIN_BLOCK_DEFAULT, - "Plot block", Configuration.BLOCKLIST, true), - new ConfigurationNode("plot.floor", DefaultPlotWorld.TOP_BLOCK_DEFAULT, - "Plot floor block", Configuration.BLOCKLIST, true), - new ConfigurationNode("wall.block", DefaultPlotWorld.WALL_BLOCK_DEFAULT, - "Top wall block", Configuration.BLOCK, true), - new ConfigurationNode("road.width", DefaultPlotWorld.ROAD_WIDTH_DEFAULT, - "Road width", Configuration.INTEGER, true), - new ConfigurationNode("road.height", DefaultPlotWorld.ROAD_HEIGHT_DEFAULT, - "Road height", Configuration.INTEGER, true), - new ConfigurationNode("road.enable_stripes", - DefaultPlotWorld.ROAD_STRIPES_ENABLED_DEFAULT, "Enable road stripes", - Configuration.BOOLEAN, true), - new ConfigurationNode("road.block", DefaultPlotWorld.ROAD_BLOCK_DEFAULT, - "Road block", Configuration.BLOCK, true), - new ConfigurationNode("road.stripes", DefaultPlotWorld.ROAD_STRIPES_DEFAULT, - "Road stripe block", Configuration.BLOCK, true), - new ConfigurationNode("wall.filling", DefaultPlotWorld.WALL_FILLING_DEFAULT, - "Wall filling block", Configuration.BLOCK, true), - new ConfigurationNode("wall.height", DefaultPlotWorld.WALL_HEIGHT_DEFAULT, - "Wall height", Configuration.INTEGER, true), }; + return new ConfigurationNode[] { + new ConfigurationNode("plot.height", DefaultPlotWorld.PLOT_HEIGHT_DEFAULT, "Plot height", Configuration.INTEGER, true), + new ConfigurationNode("plot.width", DefaultPlotWorld.PLOT_WIDTH_DEFAULT, "Plot width", Configuration.INTEGER, true), + new ConfigurationNode("plot.filling", DefaultPlotWorld.MAIN_BLOCK_DEFAULT, "Plot block", Configuration.BLOCKLIST, true), + new ConfigurationNode("plot.floor", DefaultPlotWorld.TOP_BLOCK_DEFAULT, "Plot floor block", Configuration.BLOCKLIST, true), + new ConfigurationNode("wall.block", DefaultPlotWorld.WALL_BLOCK_DEFAULT, "Top wall block", Configuration.BLOCK, true), + new ConfigurationNode("road.width", DefaultPlotWorld.ROAD_WIDTH_DEFAULT, "Road width", Configuration.INTEGER, true), + new ConfigurationNode("road.height", DefaultPlotWorld.ROAD_HEIGHT_DEFAULT, "Road height", Configuration.INTEGER, true), + new ConfigurationNode("road.enable_stripes", DefaultPlotWorld.ROAD_STRIPES_ENABLED_DEFAULT, "Enable road stripes", Configuration.BOOLEAN, true), + new ConfigurationNode("road.block", DefaultPlotWorld.ROAD_BLOCK_DEFAULT, "Road block", Configuration.BLOCK, true), + new ConfigurationNode("road.stripes", DefaultPlotWorld.ROAD_STRIPES_DEFAULT, "Road stripe block", Configuration.BLOCK, true), + new ConfigurationNode("wall.filling", DefaultPlotWorld.WALL_FILLING_DEFAULT, "Wall filling block", Configuration.BLOCK, true), + new ConfigurationNode("wall.height", DefaultPlotWorld.WALL_HEIGHT_DEFAULT, "Wall height", Configuration.INTEGER, true), }; } /* @@ -179,23 +161,17 @@ public class DefaultPlotWorld extends PlotWorld { public void loadConfiguration(ConfigurationSection config) { this.PLOT_HEIGHT = config.getInt("plot.height"); this.PLOT_WIDTH = config.getInt("plot.width"); - this.MAIN_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST - .parseString(StringUtils.join( - config.getStringList("plot.filling"), ',')); - this.TOP_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST - .parseString(StringUtils.join( - config.getStringList("plot.floor"), ',')); - this.WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config - .getString("wall.block")); + this.MAIN_BLOCK = + (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.filling"), ',')); + this.TOP_BLOCK = + (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.floor"), ',')); + this.WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block")); this.ROAD_WIDTH = config.getInt("road.width"); this.ROAD_HEIGHT = config.getInt("road.height"); this.ROAD_STRIPES_ENABLED = config.getBoolean("road.enable_stripes"); - this.ROAD_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config - .getString("road.block")); - this.ROAD_STRIPES = (PlotBlock) Configuration.BLOCK.parseString(config - .getString("road.stripes")); - this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config - .getString("wall.filling")); + this.ROAD_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.block")); + this.ROAD_STRIPES = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.stripes")); + this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.filling")); this.WALL_HEIGHT = config.getInt("wall.height"); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/generator/WorldGenerator.java b/PlotSquared/src/com/intellectualcrafters/plot/generator/WorldGenerator.java index 177ed085e..79a1ed591 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/generator/WorldGenerator.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/generator/WorldGenerator.java @@ -15,16 +15,12 @@ import com.intellectualcrafters.plot.PlotManager; import com.intellectualcrafters.plot.PlotWorld; /** - * * @auther Empire92 - * @author Citymonstret - * - * The default generator is very messy, as we have decided to try - * externalize all calculations from within the loop. - You will see a - * lot of slower implementations have a single for loop. - This is + * @author Citymonstret The default generator is very messy, as we have decided + * to try externalize all calculations from within the loop. - You will + * see a lot of slower implementations have a single for loop. - This is * perfectly fine to do, it will just mean world generation may take * somewhat longer - * */ public class WorldGenerator extends PlotGenerator { /** @@ -59,8 +55,9 @@ public class WorldGenerator extends PlotGenerator { final PlotBlock[] filling; /** - * Return the plot manager for this type of generator, or create one - * For square plots you may as well use the default plot manager which comes with PlotSquared + * Return the plot manager for this type of generator, or create one For + * square plots you may as well use the default plot manager which comes + * with PlotSquared */ @Override public PlotManager getPlotManager() { @@ -71,14 +68,13 @@ public class WorldGenerator extends PlotGenerator { } /** - * Get a new plotworld class - * For square plots you can use the DefaultPlotWorld class which comes with PlotSquared - * + * Get a new plotworld class For square plots you can use the + * DefaultPlotWorld class which comes with PlotSquared */ @Override public PlotWorld getNewPlotWorld(String world) { - this.plotworld = new DefaultPlotWorld(world); - return this.plotworld; + this.plotworld = new DefaultPlotWorld(world); + return this.plotworld; } /** @@ -122,7 +118,8 @@ public class WorldGenerator extends PlotGenerator { private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks) { if (blocks.length == 1) { setCuboidRegion(x1, x2, y1, y2, z1, z2, blocks[0]); - } else { + } + else { for (int x = x1; x < x2; x++) { for (int z = z1; z < z2; z++) { for (int y = y1; y < y2; y++) { @@ -148,9 +145,9 @@ public class WorldGenerator extends PlotGenerator { * Initialize variables, and create plotworld object used in calculations */ public WorldGenerator(String world) { - super(world); + super(world); this.plotsize = this.plotworld.PLOT_WIDTH; - + this.pathsize = this.plotworld.ROAD_WIDTH; this.floor1 = this.plotworld.ROAD_BLOCK; @@ -201,20 +198,21 @@ public class WorldGenerator extends PlotGenerator { */ @Override public short[][] generateExtBlockSections(World world, Random random, int cx, int cz, BiomeGrid biomes) { - - int maxY = world.getMaxHeight(); - this.result = new short[maxY / 16][]; - + + int maxY = world.getMaxHeight(); + this.result = new short[maxY / 16][]; + final int prime = 31; int h = 1; h = (prime * h) + cx; h = (prime * h) + cz; this.state = h; - + double pathWidthLower; if ((this.pathsize % 2) == 0) { pathWidthLower = Math.floor(this.pathsize / 2) - 1; - } else { + } + else { pathWidthLower = Math.floor(this.pathsize / 2); } cx = (cx % this.size) + (8 * this.size); @@ -231,7 +229,7 @@ public class WorldGenerator extends PlotGenerator { if (roadStartZ >= this.size) { roadStartZ -= this.size; } - + // BOTTOM (1/1 cuboids) for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { @@ -241,34 +239,27 @@ public class WorldGenerator extends PlotGenerator { } // ROAD (0/24) The following is an inefficient placeholder as it is too // much work to finish it - if ((this.pathsize > 16) - && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) + if ((this.pathsize > 16) && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) && !((roadStartX < 16) && (roadStartZ < 16)) && (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) { setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1); return this.result; } if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) { - int start = Math.max((16 - plotMinZ - this.pathsize) + 1, - (16 - roadStartZ) + 1); - int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) - + this.pathsize); + int start = Math.max((16 - plotMinZ - this.pathsize) + 1, (16 - roadStartZ) + 1); + int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) + this.pathsize); if ((start >= 0) && (start <= 16) && (end < 0)) { end = 16; } - setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0), - Math.min(16, end), this.floor1); + setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0), Math.min(16, end), this.floor1); } if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) { - int start = Math.max((16 - plotMinX - this.pathsize) + 1, - (16 - roadStartX) + 1); - int end = Math.min(16 - plotMinX - 1, (16 - roadStartX) - + this.pathsize); + int start = Math.max((16 - plotMinX - this.pathsize) + 1, (16 - roadStartX) + 1); + int end = Math.min(16 - plotMinX - 1, (16 - roadStartX) + this.pathsize); if ((start >= 0) && (start <= 16) && (end < 0)) { end = 16; } - setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1, - this.roadheight + 1, 0, 16, this.floor1); + setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1, this.roadheight + 1, 0, 16, this.floor1); } // ROAD STRIPES @@ -278,88 +269,84 @@ public class WorldGenerator extends PlotGenerator { int start, end; if ((plotMinX + 2) <= 16) { start = 16 - plotMinX - 1; - } else { + } + else { start = 16; } if ((roadStartX - 1) <= 16) { end = (16 - roadStartX) + 1; - } else { + } + else { end = 0; } if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { start = 0; } - setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, - 16 - value, (16 - value) + 1, this.floor2); // - setCuboidRegion(start, 16, this.wallheight, - this.wallheight + 1, 16 - value, (16 - value) + 1, - this.floor2); // + setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, 16 - value, (16 - value) + 1, this.floor2); // + setCuboidRegion(start, 16, this.wallheight, this.wallheight + 1, 16 - value, (16 - value) + 1, this.floor2); // } if ((plotMinX + 2) <= 16) { int value = (plotMinX + 2); int start, end; if ((plotMinZ + 2) <= 16) { start = 16 - plotMinZ - 1; - } else { + } + else { start = 16; } if ((roadStartZ - 1) <= 16) { end = (16 - roadStartZ) + 1; - } else { + } + else { end = 0; } if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { start = 0; } - setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight, - this.wallheight + 1, 0, end, this.floor2); // - setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight, - this.wallheight + 1, start, 16, this.floor2); // + setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight, this.wallheight + 1, 0, end, this.floor2); // + setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight, this.wallheight + 1, start, 16, this.floor2); // } if ((roadStartZ <= 16) && (roadStartZ > 1)) { int val = roadStartZ; int start, end; if ((plotMinX + 2) <= 16) { start = 16 - plotMinX - 1; - } else { + } + else { start = 16; } if ((roadStartX - 1) <= 16) { end = (16 - roadStartX) + 1; - } else { + } + else { end = 0; } if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { start = 0; } - setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, - (16 - val) + 1, (16 - val) + 2, this.floor2); - setCuboidRegion(start, 16, this.wallheight, - this.wallheight + 1, (16 - val) + 1, (16 - val) + 2, - this.floor2); + setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2); + setCuboidRegion(start, 16, this.wallheight, this.wallheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2); } if ((roadStartX <= 16) && (roadStartX > 1)) { int val = roadStartX; int start, end; if ((plotMinZ + 2) <= 16) { start = 16 - plotMinZ - 1; - } else { + } + else { start = 16; } if ((roadStartZ - 1) <= 16) { end = (16 - roadStartZ) + 1; - } else { + } + else { end = 0; } if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { start = 0; } - setCuboidRegion((16 - val) + 1, (16 - val) + 2, - this.wallheight, this.wallheight + 1, 0, end, - this.floor2); // - setCuboidRegion((16 - val) + 1, (16 - val) + 2, - this.wallheight, this.wallheight + 1, start, 16, - this.floor2); // + setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.wallheight, this.wallheight + 1, 0, end, this.floor2); // + setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.wallheight, this.wallheight + 1, start, 16, this.floor2); // } } @@ -367,81 +354,64 @@ public class WorldGenerator extends PlotGenerator { if (this.plotsize > 16) { if (roadStartX <= 16) { if (roadStartZ <= 16) { - setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, - 16 - roadStartZ, this.filling); - setCuboidRegion(0, 16 - roadStartX, this.plotheight, - this.plotheight + 1, 0, 16 - roadStartZ, - this.plotfloors); + setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling); + setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors); } if (plotMinZ <= 16) { - setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, - 16 - plotMinZ, 16, this.filling); - setCuboidRegion(0, 16 - roadStartX, this.plotheight, - this.plotheight + 1, 16 - plotMinZ, 16, - this.plotfloors); + setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling); + setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors); } - } else { + } + else { if (roadStartZ <= 16) { if (plotMinX > 16) { - setCuboidRegion(0, 16, 1, this.plotheight, 0, - 16 - roadStartZ, this.filling); - setCuboidRegion(0, 16, this.plotheight, - this.plotheight + 1, 0, 16 - roadStartZ, - this.plotfloors); + setCuboidRegion(0, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling); + setCuboidRegion(0, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors); } } } if (plotMinX <= 16) { if (plotMinZ <= 16) { - setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, - 16 - plotMinZ, 16, this.filling); - setCuboidRegion(16 - plotMinX, 16, this.plotheight, - this.plotheight + 1, 16 - plotMinZ, 16, - this.plotfloors); - } else { + setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling); + setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors); + } + else { int z = 16 - roadStartZ; if (z < 0) { z = 16; } - setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, - z, this.filling); - setCuboidRegion(16 - plotMinX, 16, this.plotheight, - this.plotheight + 1, 0, z, this.plotfloors); + setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, z, this.filling); + setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors); } if (roadStartZ <= 16) { - setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, - 16 - roadStartZ, this.filling); - setCuboidRegion(16 - plotMinX, 16, this.plotheight, - this.plotheight + 1, 0, 16 - roadStartZ, - this.plotfloors); - } else { + setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling); + setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors); + } + else { if (roadStartX <= 16) { if (plotMinZ > 16) { int x = 16 - roadStartX; if (x < 0) { x = 16; } - setCuboidRegion(0, x, 1, this.plotheight, 0, 16, - this.filling); - setCuboidRegion(0, x, this.plotheight, - this.plotheight + 1, 0, 16, this.plotfloors); + setCuboidRegion(0, x, 1, this.plotheight, 0, 16, this.filling); + setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, 16, this.plotfloors); } } } - } else { + } + else { if (plotMinZ <= 16) { if (roadStartX > 16) { int x = 16 - roadStartX; if (x < 0) { x = 16; } - setCuboidRegion(0, x, 1, this.plotheight, - 16 - plotMinZ, 16, this.filling); - setCuboidRegion(0, x, this.plotheight, - this.plotheight + 1, 16 - plotMinZ, 16, - this.plotfloors); + setCuboidRegion(0, x, 1, this.plotheight, 16 - plotMinZ, 16, this.filling); + setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors); } - } else { + } + else { if (roadStartZ > 16) { int x = 16 - roadStartX; if (x < 0) { @@ -452,50 +422,36 @@ public class WorldGenerator extends PlotGenerator { z = 16; } if (roadStartX > 16) { - setCuboidRegion(0, x, 1, this.plotheight, 0, z, - this.filling); - setCuboidRegion(0, x, this.plotheight, - this.plotheight + 1, 0, z, this.plotfloors); - } else { - setCuboidRegion(0, x, 1, this.plotheight, 0, z, - this.filling); - setCuboidRegion(0, x, this.plotheight, - this.plotheight + 1, 0, z, this.plotfloors); + setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling); + setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors); + } + else { + setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling); + setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors); } } } } - } else { + } + else { if (roadStartX <= 16) { if (roadStartZ <= 16) { - setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, - 16 - roadStartZ, this.filling); - setCuboidRegion(0, 16 - roadStartX, this.plotheight, - this.plotheight + 1, 0, 16 - roadStartZ, - this.plotfloors); + setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling); + setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors); } if (plotMinZ <= 16) { - setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, - 16 - plotMinZ, 16, this.filling); - setCuboidRegion(0, 16 - roadStartX, this.plotheight, - this.plotheight + 1, 16 - plotMinZ, 16, - this.plotfloors); + setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling); + setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors); } } if (plotMinX <= 16) { if (plotMinZ <= 16) { - setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, - 16 - plotMinZ, 16, this.filling); - setCuboidRegion(16 - plotMinX, 16, this.plotheight, - this.plotheight + 1, 16 - plotMinZ, 16, - this.plotfloors); + setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling); + setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors); } if (roadStartZ <= 16) { - setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, - 16 - roadStartZ, this.filling); - setCuboidRegion(16 - plotMinX, 16, this.plotheight, - this.plotheight + 1, 0, 16 - roadStartZ, - this.plotfloors); + setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling); + setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors); } } } @@ -506,107 +462,89 @@ public class WorldGenerator extends PlotGenerator { int start, end; if ((plotMinX + 2) <= 16) { start = 16 - plotMinX - 1; - } else { + } + else { start = 16; } if ((roadStartX - 1) <= 16) { end = (16 - roadStartX) + 1; - } else { + } + else { end = 0; } if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { start = 0; } - setCuboidRegion(0, end, 1, this.wallheight + 1, - 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling); - setCuboidRegion(0, end, this.wallheight + 1, - this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, - this.wall); - setCuboidRegion(start, 16, 1, this.wallheight + 1, - 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling); - setCuboidRegion(start, 16, this.wallheight + 1, - this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, - this.wall); + setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling); + setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall); + setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling); + setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall); } if ((plotMinX + 1) <= 16) { int start, end; if ((plotMinZ + 2) <= 16) { start = 16 - plotMinZ - 1; - } else { + } + else { start = 16; } if ((roadStartZ - 1) <= 16) { end = (16 - roadStartZ) + 1; - } else { + } + else { end = 0; } if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { start = 0; } - setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, - this.wallheight + 1, 0, end, this.wallfilling); - setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, - this.wallheight + 1, this.wallheight + 2, 0, end, - this.wall); - setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, - this.wallheight + 1, start, 16, this.wallfilling); - setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, - this.wallheight + 1, this.wallheight + 2, start, 16, - this.wall); + setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, 0, end, this.wallfilling); + setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, 0, end, this.wall); + setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, start, 16, this.wallfilling); + setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall); } if ((roadStartZ <= 16) && (roadStartZ > 0)) { int start, end; if ((plotMinX + 1) <= 16) { start = 16 - plotMinX; - } else { + } + else { start = 16; } if ((roadStartX + 1) <= 16) { end = (16 - roadStartX) + 1; - } else { + } + else { end = 0; } if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) { start = 0; } - setCuboidRegion(0, end, 1, this.wallheight + 1, - 16 - roadStartZ, (16 - roadStartZ) + 1, - this.wallfilling); - setCuboidRegion(0, end, this.wallheight + 1, - this.wallheight + 2, 16 - roadStartZ, - (16 - roadStartZ) + 1, this.wall); - setCuboidRegion(start, 16, 1, this.wallheight + 1, - 16 - roadStartZ, (16 - roadStartZ) + 1, - this.wallfilling); - setCuboidRegion(start, 16, this.wallheight + 1, - this.wallheight + 2, 16 - roadStartZ, - (16 - roadStartZ) + 1, this.wall); + setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling); + setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall); + setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling); + setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall); } if ((roadStartX <= 16) && (roadStartX > 0)) { int start, end; if ((plotMinZ + 1) <= 16) { start = 16 - plotMinZ; - } else { + } + else { start = 16; } if ((roadStartZ + 1) <= 16) { end = (16 - roadStartZ) + 1; - } else { + } + else { end = 0; } if (!(((plotMinZ + 1) <= 16) || ((roadStartZ + 1) <= 16))) { start = 0; } - setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, - this.wallheight + 1, 0, end, this.wallfilling); - setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, - this.wallheight + 1, this.roadheight + 2, 0, end, - this.wall); - setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, - this.wallheight + 1, start, 16, this.wallfilling); - setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, - this.wallheight + 1, this.wallheight + 2, start, 16, - this.wall); + setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, 0, end, this.wallfilling); + setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.roadheight + 2, 0, end, this.wall); + setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, start, 16, this.wallfilling); + setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall); } } // Return the chunk diff --git a/PlotSquared/src/com/intellectualcrafters/plot/generator/XPopulator.java b/PlotSquared/src/com/intellectualcrafters/plot/generator/XPopulator.java index e27cf1958..5bdbdd5fb 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/generator/XPopulator.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/generator/XPopulator.java @@ -11,9 +11,7 @@ import com.intellectualcrafters.plot.PlotBlock; import com.intellectualcrafters.plot.PlotWorld; /** - * * @author Citymonstret - * */ public class XPopulator extends BlockPopulator { @@ -46,8 +44,7 @@ public class XPopulator extends BlockPopulator { return (int) result; } - public void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, - PlotBlock block, World w) { + public void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock block, World w) { if (block.data == 0) { return; } @@ -60,11 +57,11 @@ public class XPopulator extends BlockPopulator { } } - private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, - int z2, PlotBlock[] blocks, World w) { + private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks, World w) { if (blocks.length == 1) { setCuboidRegion(x1, x2, y1, y2, z1, z2, blocks[0], w); - } else { + } + else { for (int x = x1; x < x2; x++) { for (int z = z1; z < z2; z++) { for (int y = y1; y < y2; y++) { @@ -82,8 +79,7 @@ public class XPopulator extends BlockPopulator { public short[] getBlock(String block) { if (block.contains(":")) { String[] split = block.split(":"); - return new short[] { Short.parseShort(split[0]), - Short.parseShort(split[1]) }; + return new short[] { Short.parseShort(split[0]), Short.parseShort(split[1]) }; } return new short[] { Short.parseShort(block), 0 }; } @@ -129,7 +125,8 @@ public class XPopulator extends BlockPopulator { if ((this.pathsize % 2) == 0) { this.pathWidthLower = Math.floor(this.pathsize / 2) - 1; - } else { + } + else { this.pathWidthLower = Math.floor(this.pathsize / 2); } } @@ -148,8 +145,8 @@ public class XPopulator extends BlockPopulator { this.Z = cz << 4; cx = (cx % this.size) + (8 * this.size); cz = (cz % this.size) + (8 * this.size); - double absX = ((((cx * 16) + 16) - this.pathWidthLower - 1) + (8 * this.size)), absZ = ((((cz * 16) + 16) - - this.pathWidthLower - 1) + (8 * this.size)); + double absX = ((((cx * 16) + 16) - this.pathWidthLower - 1) + (8 * this.size)), absZ = + ((((cz * 16) + 16) - this.pathWidthLower - 1) + (8 * this.size)); int plotMinX = (int) (((absX) % this.size)); int plotMinZ = (int) (((absZ) % this.size)); int roadStartX = (plotMinX + this.pathsize); @@ -163,36 +160,28 @@ public class XPopulator extends BlockPopulator { // ROADS - if ((this.pathsize > 16) - && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) + if ((this.pathsize > 16) && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) && !((roadStartX < 16) && (roadStartZ < 16)) && (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) { - setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1, - w); + setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1, w); return; } if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) { - int start = Math.max((16 - plotMinZ - this.pathsize) + 1, - (16 - roadStartZ) + 1); - int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) - + this.pathsize); + int start = Math.max((16 - plotMinZ - this.pathsize) + 1, (16 - roadStartZ) + 1); + int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) + this.pathsize); if ((start >= 0) && (start <= 16) && (end < 0)) { end = 16; } - setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0), - Math.min(16, end), this.floor1, w); + setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0), Math.min(16, end), this.floor1, w); } if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) { - int start = Math.max((16 - plotMinX - this.pathsize) + 1, - (16 - roadStartX) + 1); - int end = Math.min(16 - plotMinX - 1, (16 - roadStartX) - + this.pathsize); + int start = Math.max((16 - plotMinX - this.pathsize) + 1, (16 - roadStartX) + 1); + int end = Math.min(16 - plotMinX - 1, (16 - roadStartX) + this.pathsize); if ((start >= 0) && (start <= 16) && (end < 0)) { end = 16; } - setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1, - this.roadheight + 1, 0, 16, this.floor1, w); + setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1, this.roadheight + 1, 0, 16, this.floor1, w); } // STRIPES @@ -202,88 +191,84 @@ public class XPopulator extends BlockPopulator { int start, end; if ((plotMinX + 2) <= 16) { start = 16 - plotMinX - 1; - } else { + } + else { start = 16; } if ((roadStartX - 1) <= 16) { end = (16 - roadStartX) + 1; - } else { + } + else { end = 0; } if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { start = 0; } - setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, - 16 - value, (16 - value) + 1, this.floor2, w); // - setCuboidRegion(start, 16, this.roadheight, - this.roadheight + 1, 16 - value, (16 - value) + 1, - this.floor2, w); // + setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, 16 - value, (16 - value) + 1, this.floor2, w); // + setCuboidRegion(start, 16, this.roadheight, this.roadheight + 1, 16 - value, (16 - value) + 1, this.floor2, w); // } if ((plotMinX + 2) <= 16) { int value = (plotMinX + 2); int start, end; if ((plotMinZ + 2) <= 16) { start = 16 - plotMinZ - 1; - } else { + } + else { start = 16; } if ((roadStartZ - 1) <= 16) { end = (16 - roadStartZ) + 1; - } else { + } + else { end = 0; } if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { start = 0; } - setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight, - this.roadheight + 1, 0, end, this.floor2, w); // - setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight, - this.roadheight + 1, start, 16, this.floor2, w); // + setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight, this.roadheight + 1, 0, end, this.floor2, w); // + setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight, this.roadheight + 1, start, 16, this.floor2, w); // } if ((roadStartZ <= 16) && (roadStartZ > 1)) { int val = roadStartZ; int start, end; if ((plotMinX + 2) <= 16) { start = 16 - plotMinX - 1; - } else { + } + else { start = 16; } if ((roadStartX - 1) <= 16) { end = (16 - roadStartX) + 1; - } else { + } + else { end = 0; } if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { start = 0; } - setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, - (16 - val) + 1, (16 - val) + 2, this.floor2, w); - setCuboidRegion(start, 16, this.roadheight, - this.roadheight + 1, (16 - val) + 1, (16 - val) + 2, - this.floor2, w); + setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2, w); + setCuboidRegion(start, 16, this.roadheight, this.roadheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2, w); } if ((roadStartX <= 16) && (roadStartX > 1)) { int val = roadStartX; int start, end; if ((plotMinZ + 2) <= 16) { start = 16 - plotMinZ - 1; - } else { + } + else { start = 16; } if ((roadStartZ - 1) <= 16) { end = (16 - roadStartZ) + 1; - } else { + } + else { end = 0; } if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { start = 0; } - setCuboidRegion((16 - val) + 1, (16 - val) + 2, - this.roadheight, this.roadheight + 1, 0, end, - this.floor2, w); // - setCuboidRegion((16 - val) + 1, (16 - val) + 2, - this.roadheight, this.roadheight + 1, start, 16, - this.floor2, w); // + setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.roadheight, this.roadheight + 1, 0, end, this.floor2, w); // + setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.roadheight, this.roadheight + 1, start, 16, this.floor2, w); // } } // WALLS @@ -292,107 +277,89 @@ public class XPopulator extends BlockPopulator { int start, end; if ((plotMinX + 2) <= 16) { start = 16 - plotMinX - 1; - } else { + } + else { start = 16; } if ((roadStartX - 1) <= 16) { end = (16 - roadStartX) + 1; - } else { + } + else { end = 0; } if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { start = 0; } - setCuboidRegion(0, end, 1, this.wallheight + 1, - 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling, w); - setCuboidRegion(0, end, this.wallheight + 1, - this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, - this.wall, w); - setCuboidRegion(start, 16, 1, this.wallheight + 1, - 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling, w); - setCuboidRegion(start, 16, this.wallheight + 1, - this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, - this.wall, w); + setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling, w); + setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall, w); + setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling, w); + setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall, w); } if ((plotMinX + 1) <= 16) { int start, end; if ((plotMinZ + 2) <= 16) { start = 16 - plotMinZ - 1; - } else { + } + else { start = 16; } if ((roadStartZ - 1) <= 16) { end = (16 - roadStartZ) + 1; - } else { + } + else { end = 0; } if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { start = 0; } - setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, - this.wallheight + 1, 0, end, this.wallfilling, w); - setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, - this.wallheight + 1, this.wallheight + 2, 0, end, - this.wall, w); - setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, - this.wallheight + 1, start, 16, this.wallfilling, w); - setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, - this.wallheight + 1, this.wallheight + 2, start, 16, - this.wall, w); + setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, 0, end, this.wallfilling, w); + setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, 0, end, this.wall, w); + setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, start, 16, this.wallfilling, w); + setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall, w); } if ((roadStartZ <= 16) && (roadStartZ > 0)) { int start, end; if ((plotMinX + 1) <= 16) { start = 16 - plotMinX; - } else { + } + else { start = 16; } if ((roadStartX + 1) <= 16) { end = (16 - roadStartX) + 1; - } else { + } + else { end = 0; } if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) { start = 0; } - setCuboidRegion(0, end, 1, this.wallheight + 1, - 16 - roadStartZ, (16 - roadStartZ) + 1, - this.wallfilling, w); - setCuboidRegion(0, end, this.wallheight + 1, - this.wallheight + 2, 16 - roadStartZ, - (16 - roadStartZ) + 1, this.wall, w); - setCuboidRegion(start, 16, 1, this.wallheight + 1, - 16 - roadStartZ, (16 - roadStartZ) + 1, - this.wallfilling, w); - setCuboidRegion(start, 16, this.wallheight + 1, - this.wallheight + 2, 16 - roadStartZ, - (16 - roadStartZ) + 1, this.wall, w); + setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling, w); + setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall, w); + setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling, w); + setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall, w); } if ((roadStartX <= 16) && (roadStartX > 0)) { int start, end; if ((plotMinZ + 1) <= 16) { start = 16 - plotMinZ; - } else { + } + else { start = 16; } if ((roadStartZ + 1) <= 16) { end = (16 - roadStartZ) + 1; - } else { + } + else { end = 0; } if (!(((plotMinZ + 1) <= 16) || ((roadStartZ + 1) <= 16))) { start = 0; } - setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, - this.wallheight + 1, 0, end, this.wallfilling, w); - setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, - this.wallheight + 1, this.roadheight + 2, 0, end, - this.wall, w); - setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, - this.wallheight + 1, start, 16, this.wallfilling, w); - setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, - this.wallheight + 1, this.wallheight + 2, start, 16, - this.wall, w); + setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, 0, end, this.wallfilling, w); + setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.roadheight + 2, 0, end, this.wall, w); + setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, start, 16, this.wallfilling, w); + setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall, w); } } @@ -401,82 +368,64 @@ public class XPopulator extends BlockPopulator { if (this.plotsize > 16) { if (roadStartX <= 16) { if (roadStartZ <= 16) { - setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, - 16 - roadStartZ, this.filling, w); - setCuboidRegion(0, 16 - roadStartX, this.plotheight, - this.plotheight + 1, 0, 16 - roadStartZ, - this.plotfloors, w); + setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w); + setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w); } if (plotMinZ <= 16) { - setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, - 16 - plotMinZ, 16, this.filling, w); - setCuboidRegion(0, 16 - roadStartX, this.plotheight, - this.plotheight + 1, 16 - plotMinZ, 16, - this.plotfloors, w); + setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w); + setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w); } - } else { + } + else { if (roadStartZ <= 16) { if (plotMinX > 16) { - setCuboidRegion(0, 16, 1, this.plotheight, 0, - 16 - roadStartZ, this.filling, w); - setCuboidRegion(0, 16, this.plotheight, - this.plotheight + 1, 0, 16 - roadStartZ, - this.plotfloors, w); + setCuboidRegion(0, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w); + setCuboidRegion(0, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w); } } } if (plotMinX <= 16) { if (plotMinZ <= 16) { - setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, - 16 - plotMinZ, 16, this.filling, w); - setCuboidRegion(16 - plotMinX, 16, this.plotheight, - this.plotheight + 1, 16 - plotMinZ, 16, - this.plotfloors, w); - } else { + setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w); + setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w); + } + else { int z = 16 - roadStartZ; if (z < 0) { z = 16; } - setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, - z, this.filling, w); - setCuboidRegion(16 - plotMinX, 16, this.plotheight, - this.plotheight + 1, 0, z, this.plotfloors, w); + setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, z, this.filling, w); + setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors, w); } if (roadStartZ <= 16) { - setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, - 16 - roadStartZ, this.filling, w); - setCuboidRegion(16 - plotMinX, 16, this.plotheight, - this.plotheight + 1, 0, 16 - roadStartZ, - this.plotfloors, w); - } else { + setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w); + setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w); + } + else { if (roadStartX <= 16) { if (plotMinZ > 16) { int x = 16 - roadStartX; if (x < 0) { x = 16; } - setCuboidRegion(0, x, 1, this.plotheight, 0, 16, - this.filling, w); - setCuboidRegion(0, x, this.plotheight, - this.plotheight + 1, 0, 16, - this.plotfloors, w); + setCuboidRegion(0, x, 1, this.plotheight, 0, 16, this.filling, w); + setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, 16, this.plotfloors, w); } } } - } else { + } + else { if (plotMinZ <= 16) { if (roadStartX > 16) { int x = 16 - roadStartX; if (x < 0) { x = 16; } - setCuboidRegion(0, x, 1, this.plotheight, - 16 - plotMinZ, 16, this.filling, w); - setCuboidRegion(0, x, this.plotheight, - this.plotheight + 1, 16 - plotMinZ, 16, - this.plotfloors, w); + setCuboidRegion(0, x, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w); + setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w); } - } else { + } + else { if (roadStartZ > 16) { int x = 16 - roadStartX; if (x < 0) { @@ -487,52 +436,36 @@ public class XPopulator extends BlockPopulator { z = 16; } if (roadStartX > 16) { - setCuboidRegion(0, x, 1, this.plotheight, 0, z, - this.filling, w); - setCuboidRegion(0, x, this.plotheight, - this.plotheight + 1, 0, z, this.plotfloors, - w); - } else { - setCuboidRegion(0, x, 1, this.plotheight, 0, z, - this.filling, w); - setCuboidRegion(0, x, this.plotheight, - this.plotheight + 1, 0, z, this.plotfloors, - w); + setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling, w); + setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors, w); + } + else { + setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling, w); + setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors, w); } } } } - } else { + } + else { if (roadStartX <= 16) { if (roadStartZ <= 16) { - setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, - 16 - roadStartZ, this.filling, w); - setCuboidRegion(0, 16 - roadStartX, this.plotheight, - this.plotheight + 1, 0, 16 - roadStartZ, - this.plotfloors, w); + setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w); + setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w); } if (plotMinZ <= 16) { - setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, - 16 - plotMinZ, 16, this.filling, w); - setCuboidRegion(0, 16 - roadStartX, this.plotheight, - this.plotheight + 1, 16 - plotMinZ, 16, - this.plotfloors, w); + setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w); + setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w); } } if (plotMinX <= 16) { if (plotMinZ <= 16) { - setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, - 16 - plotMinZ, 16, this.filling, w); - setCuboidRegion(16 - plotMinX, 16, this.plotheight, - this.plotheight + 1, 16 - plotMinZ, 16, - this.plotfloors, w); + setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w); + setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w); } if (roadStartZ <= 16) { - setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, - 16 - roadStartZ, this.filling, w); - setCuboidRegion(16 - plotMinX, 16, this.plotheight, - this.plotheight + 1, 0, 16 - roadStartZ, - this.plotfloors, w); + setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w); + setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w); } } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 57b92d936..8fe3dff7f 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -1,10 +1,9 @@ /* - * Copyright (c) IntellectualCrafters - 2014. - * You are not allowed to distribute and/or monetize any of our intellectual property. - * IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. - * - * >> File = PlayerEvents.java - * >> Generated by: Citymonstret at 2014-08-09 01:43 + * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute + * and/or monetize any of our intellectual property. IntellectualCrafters is not + * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. + * + * >> File = PlayerEvents.java >> Generated by: Citymonstret at 2014-08-09 01:43 */ package com.intellectualcrafters.plot.listeners; @@ -90,10 +89,8 @@ public class PlayerEvents implements Listener { } public boolean enteredPlot(Location l1, Location l2) { - PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1 - .getBlockX(), 64, l1.getBlockZ())); - PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2 - .getBlockX(), 64, l2.getBlockZ())); + PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 64, l1.getBlockZ())); + PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 64, l2.getBlockZ())); if (p2 == null) { return false; } @@ -107,10 +104,8 @@ public class PlayerEvents implements Listener { } public boolean leftPlot(Location l1, Location l2) { - PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1 - .getBlockX(), 64, l1.getBlockZ())); - PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2 - .getBlockX(), 64, l2.getBlockZ())); + PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 64, l1.getBlockZ())); + PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 64, l2.getBlockZ())); if (p1 == null) { return false; } @@ -144,8 +139,7 @@ public class PlayerEvents implements Listener { if (PlotMain.getPlots(world).containsKey(id)) { return PlotMain.getPlots(world).get(id); } - return new Plot(id, null, Biome.FOREST, new ArrayList(), - new ArrayList(), loc.getWorld().getName()); + return new Plot(id, null, Biome.FOREST, new ArrayList(), new ArrayList(), loc.getWorld().getName()); } @EventHandler @@ -162,18 +156,17 @@ public class PlayerEvents implements Listener { } private void textures(Player p) { - if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) - && isPlotWorld(p.getWorld())) { + if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld())) { p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK); } } @EventHandler public void onChangeWorld(PlayerChangedWorldEvent event) { - if (isPlotWorld(event.getFrom()) - && (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) { + if (isPlotWorld(event.getFrom()) && (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) { event.getPlayer().setResourcePack(""); - } else { + } + else { textures(event.getPlayer()); } } @@ -181,14 +174,10 @@ public class PlayerEvents implements Listener { public void plotEntry(Player player, Plot plot) { if (plot.hasOwner()) { if (C.TITLE_ENTERED_PLOT.s().length() > 2) { - String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", - plot.getDisplayName()); - String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst( - "%s", getName(plot.owner)); - ChatColor sTitleMainColor = ChatColor - .valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()); - ChatColor sTitleSubColor = ChatColor - .valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()); + String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", plot.getDisplayName()); + String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)); + ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()); + ChatColor sTitleSubColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()); Title title = new Title(sTitleMain, sTitleSub, 10, 20, 10); title.setTitleColor(sTitleMainColor); title.setSubtitleColor(sTitleSubColor); @@ -196,8 +185,7 @@ public class PlayerEvents implements Listener { title.send(player); } { - PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent( - player, plot); + PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot); Bukkit.getPluginManager().callEvent(callEvent); } PlayerFunctions.sendMessage(player, plot.settings.getJoinMessage()); @@ -212,8 +200,7 @@ public class PlayerEvents implements Listener { public void plotExit(Player player, Plot plot) { { - PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, - plot); + PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot); Bukkit.getPluginManager().callEvent(callEvent); } player.resetPlayerTime(); @@ -221,14 +208,14 @@ public class PlayerEvents implements Listener { PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage()); } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGHEST, ignoreCancelled = true) public void PlayerMove(PlayerMoveEvent event) { try { Player player = event.getPlayer(); Location from = event.getFrom(); Location to = event.getTo(); - if ((from.getBlockX() != to.getBlockX()) - || (from.getBlockZ() != to.getBlockZ())) { + if ((from.getBlockX() != to.getBlockX()) || (from.getBlockZ() != to.getBlockZ())) { if (!isPlotWorld(player.getWorld())) { return; } @@ -240,17 +227,21 @@ public class PlayerEvents implements Listener { return; } plotEntry(player, plot); - } else if (leftPlot(event.getFrom(), event.getTo())) { - Plot plot = getCurrentPlot(event.getFrom()); - plotExit(player, plot); } + else + if (leftPlot(event.getFrom(), event.getTo())) { + Plot plot = getCurrentPlot(event.getFrom()); + plotExit(player, plot); + } } - } catch (Exception e) { + } + catch (Exception e) { // Gotta catch 'em all. } } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler( + priority = EventPriority.HIGHEST) public void onChat(AsyncPlayerChatEvent event) { World world = event.getPlayer().getWorld(); if (!isPlotWorld(world)) { @@ -275,13 +266,14 @@ public class PlayerEvents implements Listener { recipients.add(p); } } - format = format.replaceAll("%plot_id%", id.x + ";" + id.y) - .replaceAll("%sender%", sender).replaceAll("%msg%", message); + format = + format.replaceAll("%plot_id%", id.x + ";" + id.y).replaceAll("%sender%", sender).replaceAll("%msg%", message); format = ChatColor.translateAlternateColorCodes('&', format); event.setFormat(format); } - @EventHandler(priority = EventPriority.HIGH) + @EventHandler( + priority = EventPriority.HIGH) public void BlockDestroy(BlockBreakEvent event) { World world = event.getPlayer().getWorld(); if (!isPlotWorld(world)) { @@ -301,7 +293,8 @@ public class PlayerEvents implements Listener { } } - @EventHandler(priority = EventPriority.HIGH) + @EventHandler( + priority = EventPriority.HIGH) public void BlockCreate(BlockPlaceEvent event) { World world = event.getPlayer().getWorld(); if (!isPlotWorld(world)) { @@ -330,9 +323,10 @@ public class PlayerEvents implements Listener { event.setCancelled(true); } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onPeskyMobsChangeTheWorldLikeWTFEvent( // LOL! - EntityChangeBlockEvent event) { + EntityChangeBlockEvent event) { World world = event.getBlock().getWorld(); if (!isPlotWorld(world)) { return; @@ -342,29 +336,34 @@ public class PlayerEvents implements Listener { if (!(e instanceof org.bukkit.entity.FallingBlock)) { event.setCancelled(true); } - } else { + } + else { Block b = event.getBlock(); Player p = (Player) e; if (!isInPlot(b.getLocation())) { if (!p.hasPermission("plots.admin")) { event.setCancelled(true); } - } else { + } + else { Plot plot = getCurrentPlot(b.getLocation()); if (plot == null) { if (!p.hasPermission("plots.admin")) { event.setCancelled(true); } - } else if (!plot.hasRights(p)) { - if (!p.hasPermission("plots.admin")) { - event.setCancelled(true); - } } + else + if (!plot.hasRights(p)) { + if (!p.hasPermission("plots.admin")) { + event.setCancelled(true); + } + } } } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onEntityBlockForm(final EntityBlockFormEvent event) { World world = event.getBlock().getWorld(); if (!isPlotWorld(world)) { @@ -375,7 +374,8 @@ public class PlayerEvents implements Listener { } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onBS(final BlockSpreadEvent e) { Block b = e.getBlock(); if (isPlotWorld(b.getLocation())) { @@ -385,7 +385,8 @@ public class PlayerEvents implements Listener { } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onBF(final BlockFormEvent e) { Block b = e.getBlock(); if (isPlotWorld(b.getLocation())) { @@ -395,7 +396,8 @@ public class PlayerEvents implements Listener { } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onBD(final BlockDamageEvent e) { Block b = e.getBlock(); if (isPlotWorld(b.getLocation())) { @@ -405,7 +407,8 @@ public class PlayerEvents implements Listener { } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onFade(final BlockFadeEvent e) { Block b = e.getBlock(); if (isPlotWorld(b.getLocation())) { @@ -415,7 +418,8 @@ public class PlayerEvents implements Listener { } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onChange(final BlockFromToEvent e) { Block b = e.getToBlock(); if (isPlotWorld(b.getLocation())) { @@ -425,7 +429,8 @@ public class PlayerEvents implements Listener { } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onGrow(final BlockGrowEvent e) { Block b = e.getBlock(); if (isPlotWorld(b.getLocation())) { @@ -435,7 +440,8 @@ public class PlayerEvents implements Listener { } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockPistonExtend(final BlockPistonExtendEvent e) { if (isInPlot(e.getBlock().getLocation())) { @@ -445,13 +451,19 @@ public class PlayerEvents implements Listener { { if (e.getDirection() == BlockFace.EAST) { l = e.getBlock().getLocation().subtract(modifier, 0, 0); - } else if (e.getDirection() == BlockFace.NORTH) { - l = e.getBlock().getLocation().subtract(0, 0, modifier); - } else if (e.getDirection() == BlockFace.SOUTH) { - l = e.getBlock().getLocation().add(0, 0, modifier); - } else if (e.getDirection() == BlockFace.WEST) { - l = e.getBlock().getLocation().add(modifier, 0, 0); } + else + if (e.getDirection() == BlockFace.NORTH) { + l = e.getBlock().getLocation().subtract(0, 0, modifier); + } + else + if (e.getDirection() == BlockFace.SOUTH) { + l = e.getBlock().getLocation().add(0, 0, modifier); + } + else + if (e.getDirection() == BlockFace.WEST) { + l = e.getBlock().getLocation().add(modifier, 0, 0); + } if (!isInPlot(l)) { e.setCancelled(true); @@ -467,36 +479,43 @@ public class PlayerEvents implements Listener { if (!isInPlot(b.getLocation().subtract(1, 0, 0))) { e.setCancelled(true); } - } else if (e.getDirection() == BlockFace.NORTH) { - if (!isInPlot(b.getLocation().subtract(0, 0, 1))) { - e.setCancelled(true); - } - } else if (e.getDirection() == BlockFace.SOUTH) { - if (!isInPlot(b.getLocation().add(0, 0, 1))) { - e.setCancelled(true); - } - } else if (e.getDirection() == BlockFace.WEST) { - if (!isInPlot(b.getLocation().add(1, 0, 0))) { - e.setCancelled(true); - } } + else + if (e.getDirection() == BlockFace.NORTH) { + if (!isInPlot(b.getLocation().subtract(0, 0, 1))) { + e.setCancelled(true); + } + } + else + if (e.getDirection() == BlockFace.SOUTH) { + if (!isInPlot(b.getLocation().add(0, 0, 1))) { + e.setCancelled(true); + } + } + else + if (e.getDirection() == BlockFace.WEST) { + if (!isInPlot(b.getLocation().add(1, 0, 0))) { + e.setCancelled(true); + } + } } } } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockPistonRetract(final BlockPistonRetractEvent e) { Block b = e.getRetractLocation().getBlock(); - if (isPlotWorld(b.getLocation()) - && (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) { + if (isPlotWorld(b.getLocation()) && (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) { if (!isInPlot(b.getLocation())) { e.setCancelled(true); } } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onStructureGrow(final StructureGrowEvent e) { List blocks = e.getBlocks(); boolean remove = false; @@ -524,19 +543,19 @@ public class PlayerEvents implements Listener { } if (isInPlot(event.getClickedBlock().getLocation())) { Plot plot = getCurrentPlot(event.getClickedBlock().getLocation()); - + // They shouldn't be allowed to access other people's chests - -// if (new ArrayList<>(Arrays.asList(new Material[] { -// Material.STONE_BUTTON, Material.WOOD_BUTTON, -// Material.LEVER, Material.STONE_PLATE, Material.WOOD_PLATE, -// Material.CHEST, Material.TRAPPED_CHEST, Material.TRAP_DOOR, -// Material.WOOD_DOOR, Material.WOODEN_DOOR, -// Material.DISPENSER, Material.DROPPER -// -// })).contains(event.getClickedBlock().getType())) { -// return; -// } + + // if (new ArrayList<>(Arrays.asList(new Material[] { + // Material.STONE_BUTTON, Material.WOOD_BUTTON, + // Material.LEVER, Material.STONE_PLATE, Material.WOOD_PLATE, + // Material.CHEST, Material.TRAPPED_CHEST, Material.TRAP_DOOR, + // Material.WOOD_DOOR, Material.WOODEN_DOOR, + // Material.DISPENSER, Material.DROPPER + // + // })).contains(event.getClickedBlock().getType())) { + // return; + // } if (!plot.hasRights(event.getPlayer())) { event.setCancelled(true); } @@ -560,7 +579,8 @@ public class PlayerEvents implements Listener { } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockIgnite(final BlockIgniteEvent e) { if (e.getCause() == BlockIgniteEvent.IgniteCause.LIGHTNING) { e.setCancelled(true); @@ -574,25 +594,30 @@ public class PlayerEvents implements Listener { if (!p.hasPermission("plots.admin")) { e.setCancelled(true); } - } else { + } + else { Plot plot = getCurrentPlot(b.getLocation()); if (plot == null) { if (!p.hasPermission("plots.admin")) { e.setCancelled(true); } - } else if (!plot.hasRights(p)) { - if (!p.hasPermission("plots.admin")) { - e.setCancelled(true); - } } + else + if (!plot.hasRights(p)) { + if (!p.hasPermission("plots.admin")) { + e.setCancelled(true); + } + } } - } else { + } + else { e.setCancelled(true); } } } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onTeleport(PlayerTeleportEvent event) { Location f = event.getFrom(); @@ -602,64 +627,65 @@ public class PlayerEvents implements Listener { if (isInPlot(event.getTo())) { Plot plot = getCurrentPlot(event.getTo()); if (plot.deny_entry(event.getPlayer())) { - PlayerFunctions.sendMessage(event.getPlayer(), - C.YOU_BE_DENIED); + PlayerFunctions.sendMessage(event.getPlayer(), C.YOU_BE_DENIED); event.setCancelled(true); - } else { + } + else { if (enteredPlot(f, t)) { plotEntry(event.getPlayer(), plot); } } - } else { + } + else { if (leftPlot(f, t)) { Plot plot = getCurrentPlot(event.getTo()); plotExit(event.getPlayer(), plot); } } - if ((event.getTo().getBlockX() >= 29999999) - || (event.getTo().getBlockX() <= -29999999) - || (event.getTo().getBlockZ() >= 29999999) - || (event.getTo().getBlockZ() <= -29999999)) { + if ((event.getTo().getBlockX() >= 29999999) || (event.getTo().getBlockX() <= -29999999) + || (event.getTo().getBlockZ() >= 29999999) || (event.getTo().getBlockZ() <= -29999999)) { event.setCancelled(true); } } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onBucketEmpty(PlayerBucketEmptyEvent e) { if (!e.getPlayer().hasPermission("plots.admin")) { BlockFace bf = e.getBlockFace(); - Block b = e.getBlockClicked().getLocation() - .add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock(); + Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock(); if (isPlotWorld(b.getLocation())) { if (!isInPlot(b.getLocation())) { PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); e.setCancelled(true); - } else { + } + else { Plot plot = getCurrentPlot(b.getLocation()); if (plot == null) { - PlayerFunctions.sendMessage(e.getPlayer(), - C.NO_PERMISSION); - e.setCancelled(true); - } else if (!plot.hasRights(e.getPlayer())) { - PlayerFunctions.sendMessage(e.getPlayer(), - C.NO_PERMISSION); + PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); e.setCancelled(true); } + else + if (!plot.hasRights(e.getPlayer())) { + PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); + e.setCancelled(true); + } } } } } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler( + priority = EventPriority.HIGHEST) public void onInventoryClick(InventoryClickEvent event) { - if (event.getInventory().getName() - .equalsIgnoreCase("PlotSquared Commands")) { + if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) { event.setCancelled(true); } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onBucketFill(PlayerBucketFillEvent e) { if (!e.getPlayer().hasPermission("plots.admin")) { Block b = e.getBlockClicked(); @@ -667,23 +693,25 @@ public class PlayerEvents implements Listener { if (!isInPlot(b.getLocation())) { PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); e.setCancelled(true); - } else { + } + else { Plot plot = getCurrentPlot(b.getLocation()); if (plot == null) { - PlayerFunctions.sendMessage(e.getPlayer(), - C.NO_PERMISSION); - e.setCancelled(true); - } else if (!plot.hasRights(e.getPlayer())) { - PlayerFunctions.sendMessage(e.getPlayer(), - C.NO_PERMISSION); + PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); e.setCancelled(true); } + else + if (!plot.hasRights(e.getPlayer())) { + PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); + e.setCancelled(true); + } } } } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onHangingPlace(final HangingPlaceEvent e) { Block b = e.getBlock(); if (isPlotWorld(b.getLocation())) { @@ -693,24 +721,28 @@ public class PlayerEvents implements Listener { PlayerFunctions.sendMessage(p, C.NO_PERMISSION); e.setCancelled(true); } - } else { + } + else { Plot plot = getCurrentPlot(b.getLocation()); if (plot == null) { if (!p.hasPermission("plots.admin")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION); e.setCancelled(true); } - } else if (!plot.hasRights(p)) { - if (!p.hasPermission("plots.admin")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION); - e.setCancelled(true); - } } + else + if (!plot.hasRights(p)) { + if (!p.hasPermission("plots.admin")) { + PlayerFunctions.sendMessage(p, C.NO_PERMISSION); + e.setCancelled(true); + } + } } } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onHangingBreakByEntity(final HangingBreakByEntityEvent e) { Entity r = e.getRemover(); if (r instanceof Player) { @@ -722,25 +754,29 @@ public class PlayerEvents implements Listener { PlayerFunctions.sendMessage(p, C.NO_PERMISSION); e.setCancelled(true); } - } else { + } + else { Plot plot = getCurrentPlot(l); if (plot == null) { if (!p.hasPermission("plots.admin")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION); e.setCancelled(true); } - } else if (!plot.hasRights(p)) { - if (!p.hasPermission("plots.admin")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION); - e.setCancelled(true); - } } + else + if (!plot.hasRights(p)) { + if (!p.hasPermission("plots.admin")) { + PlayerFunctions.sendMessage(p, C.NO_PERMISSION); + e.setCancelled(true); + } + } } } } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerInteractEntity(final PlayerInteractEntityEvent e) { Location l = e.getRightClicked().getLocation(); if (isPlotWorld(l)) { @@ -750,24 +786,28 @@ public class PlayerEvents implements Listener { PlayerFunctions.sendMessage(p, C.NO_PERMISSION); e.setCancelled(true); } - } else { + } + else { Plot plot = getCurrentPlot(l); if (plot == null) { if (!p.hasPermission("plots.admin")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION); e.setCancelled(true); } - } else if (!plot.hasRights(p)) { - if (!p.hasPermission("plots.admin")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION); - e.setCancelled(true); - } } + else + if (!plot.hasRights(p)) { + if (!p.hasPermission("plots.admin")) { + PlayerFunctions.sendMessage(p, C.NO_PERMISSION); + e.setCancelled(true); + } + } } } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) { Location l = e.getEntity().getLocation(); Entity d = e.getDamager(); @@ -779,25 +819,29 @@ public class PlayerEvents implements Listener { PlayerFunctions.sendMessage(p, C.NO_PERMISSION); e.setCancelled(true); } - } else { + } + else { Plot plot = getCurrentPlot(l); if (plot == null) { if (!p.hasPermission("plots.admin")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION); e.setCancelled(true); } - } else if (!plot.hasRights(p)) { - if (!p.hasPermission("plots.admin")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION); - e.setCancelled(true); - } } + else + if (!plot.hasRights(p)) { + if (!p.hasPermission("plots.admin")) { + PlayerFunctions.sendMessage(p, C.NO_PERMISSION); + e.setCancelled(true); + } + } } } } } - @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerEggThrow(final PlayerEggThrowEvent e) { Location l = e.getEgg().getLocation(); if (isPlotWorld(l)) { @@ -807,19 +851,22 @@ public class PlayerEvents implements Listener { PlayerFunctions.sendMessage(p, C.NO_PERMISSION); e.setHatching(false); } - } else { + } + else { Plot plot = getCurrentPlot(l); if (plot == null) { if (!p.hasPermission("plots.admin")) { PlayerFunctions.sendMessage(p, C.NO_PERMISSION); e.setHatching(false); } - } else if (!plot.hasRights(p)) { - if (!p.hasPermission("plots.admin")) { - PlayerFunctions.sendMessage(p, C.NO_PERMISSION); - e.setHatching(false); - } } + else + if (!plot.hasRights(p)) { + if (!p.hasPermission("plots.admin")) { + PlayerFunctions.sendMessage(p, C.NO_PERMISSION); + e.setHatching(false); + } + } } } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldEditListener.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldEditListener.java index 79172d63e..3c03fdb4c 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -27,22 +27,19 @@ import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.database.DBFunc; /** - * * @author Citymonstret - * */ public class WorldEditListener implements Listener { - public final Set blockedcmds = new HashSet(Arrays.asList( - "/gmask", "//gmask", "/worldedit:gmask")); - public final Set restrictedcmds = new HashSet( - Arrays.asList("/up", "//up", "/worldedit:up")); + public final Set blockedcmds = new HashSet(Arrays.asList("/gmask", "//gmask", "/worldedit:gmask")); + public final Set restrictedcmds = new HashSet(Arrays.asList("/up", "//up", "/worldedit:up")); private boolean isPlotWorld(Location l) { return (PlotMain.isPlotWorld(l.getWorld())); } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.LOWEST, ignoreCancelled = true) public void onInteract(PlayerInteractEvent e) { Block b = e.getClickedBlock(); if (b == null) { @@ -54,27 +51,23 @@ public class WorldEditListener implements Listener { return; } p.getItemInHand(); - if ((p.getItemInHand() == null) - || (p.getItemInHand().getType() == Material.AIR)) { + if ((p.getItemInHand() == null) || (p.getItemInHand().getType() == Material.AIR)) { return; } Plot plot = PlotHelper.getCurrentPlot(b.getLocation()); if (plot != null) { - if ((plot != null) - && plot.hasOwner() - && (plot.helpers != null) - && (plot.helpers.contains(DBFunc.everyone) || plot.helpers - .contains(p.getUniqueId()))) { + if ((plot != null) && plot.hasOwner() && (plot.helpers != null) + && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) { PWE.setMask(p, l); } } } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerCommand(PlayerCommandPreprocessEvent e) { Player p = e.getPlayer(); - if (PlotMain.hasPermission(p, "plots.worldedit.bypass") - || !PlotMain.isPlotWorld(p.getWorld())) { + if (PlotMain.hasPermission(p, "plots.worldedit.bypass") || !PlotMain.isPlotWorld(p.getWorld())) { return; } String cmd = e.getMessage().toLowerCase(); @@ -84,17 +77,18 @@ public class WorldEditListener implements Listener { } if (this.restrictedcmds.contains(cmd)) { Plot plot = PlayerFunctions.getCurrentPlot(p); - if ((plot == null) - || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers - .contains(p.getUniqueId()))) { + if ((plot == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) { e.setCancelled(true); } - } else if (this.blockedcmds.contains(cmd)) { - e.setCancelled(true); } + else + if (this.blockedcmds.contains(cmd)) { + e.setCancelled(true); + } } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerJoin(final PlayerJoinEvent e) { Player p = e.getPlayer(); if (PlotMain.hasPermission(p, "plots.worldedit.bypass")) { @@ -103,12 +97,14 @@ public class WorldEditListener implements Listener { Location l = p.getLocation(); if (isPlotWorld(l)) { PWE.setMask(p, l); - } else { + } + else { PWE.removeMask(p); } } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerMove(final PlayerMoveEvent e) { Location t = e.getTo(); if (!isPlotWorld(t)) { @@ -117,8 +113,7 @@ public class WorldEditListener implements Listener { Location f = e.getFrom(); Player p = e.getPlayer(); - if ((f.getBlockX() != t.getBlockX()) - || (f.getBlockZ() != t.getBlockZ())) { + if ((f.getBlockX() != t.getBlockX()) || (f.getBlockZ() != t.getBlockZ())) { PlotId idF = PlayerFunctions.getPlot(f); PlotId idT = PlayerFunctions.getPlot(t); if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { @@ -130,7 +125,8 @@ public class WorldEditListener implements Listener { } } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPortal(PlayerPortalEvent e) { if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { return; @@ -152,7 +148,8 @@ public class WorldEditListener implements Listener { } } - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.LOWEST, ignoreCancelled = true) public void onTeleport(final PlayerTeleportEvent e) { if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { return; @@ -163,7 +160,8 @@ public class WorldEditListener implements Listener { if (!isPlotWorld(t)) { if (isPlotWorld(f)) { PWE.removeMask(p); - } else { + } + else { return; } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java index 3e5f2b46a..b27bf429e 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/listeners/WorldGuardListener.java @@ -50,19 +50,19 @@ public class WorldGuardListener implements Listener { manager.getRegion(plot.id.x + "-" + plot.id.y); for (Flag flag : this.flags) { if (flag.getName().equalsIgnoreCase(key)) { - requester.performCommand("region flag " - + (plot.id.x + "-" + plot.id.y) + " " + key); + requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key); } } - } catch (Exception e) { + } + catch (Exception e) { requester.setOp(op); - } finally { + } + finally { requester.setOp(op); } } - public void addFlag(Player requester, World world, Plot plot, String key, - String value) { + public void addFlag(Player requester, World world, Plot plot, String key, String value) { boolean op = requester.isOp(); requester.setOp(true); try { @@ -70,19 +70,20 @@ public class WorldGuardListener implements Listener { manager.getRegion(plot.id.x + "-" + plot.id.y); for (Flag flag : this.flags) { if (flag.getName().equalsIgnoreCase(key)) { - requester.performCommand("region flag " - + (plot.id.x + "-" + plot.id.y) + " " + key + " " - + value); + requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key + " " + value); } } - } catch (Exception e) { + } + catch (Exception e) { requester.setOp(op); - } finally { + } + finally { requester.setOp(op); } } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.MONITOR, ignoreCancelled = true) public void onMerge(PlotMergeEvent event) { Plot main = event.getPlot(); ArrayList plots = event.getPlots(); @@ -99,17 +100,12 @@ public class WorldGuardListener implements Listener { DefaultDomain members = region.getMembers(); manager.removeRegion(main.id.x + "-" + main.id.y); - Location location1 = PlotHelper - .getPlotBottomLocAbs(world, plots.get(0)); - Location location2 = PlotHelper.getPlotTopLocAbs(world, - plots.get(plots.size() - 1)); + Location location1 = PlotHelper.getPlotBottomLocAbs(world, plots.get(0)); + Location location2 = PlotHelper.getPlotTopLocAbs(world, plots.get(plots.size() - 1)); - BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, - location1.getBlockZ()); - BlockVector vector2 = new BlockVector(location2.getBlockX(), - world.getMaxHeight(), location2.getBlockZ()); - ProtectedRegion rg = new ProtectedCuboidRegion(main.id.x + "-" - + main.id.y, vector1, vector2); + BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ()); + BlockVector vector2 = new BlockVector(location2.getBlockX(), world.getMaxHeight(), location2.getBlockZ()); + ProtectedRegion rg = new ProtectedCuboidRegion(main.id.x + "-" + main.id.y, vector1, vector2); rg.setFlags(flags); @@ -120,7 +116,8 @@ public class WorldGuardListener implements Listener { manager.addRegion(rg); } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler( + priority = EventPriority.MONITOR, ignoreCancelled = true) public void onUnlink(PlotUnlinkEvent event) { World w = event.getWorld(); ArrayList plots = event.getPlots(); @@ -139,12 +136,9 @@ public class WorldGuardListener implements Listener { Location location1 = PlotHelper.getPlotBottomLocAbs(w, id); Location location2 = PlotHelper.getPlotTopLocAbs(w, id); - BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, - location1.getBlockZ()); - BlockVector vector2 = new BlockVector(location2.getBlockX(), - w.getMaxHeight(), location2.getBlockZ()); - ProtectedRegion rg = new ProtectedCuboidRegion(id.x + "-" + id.y, - vector1, vector2); + BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ()); + BlockVector vector2 = new BlockVector(location2.getBlockX(), w.getMaxHeight(), location2.getBlockZ()); + ProtectedRegion rg = new ProtectedCuboidRegion(id.x + "-" + id.y, vector1, vector2); rg.setFlags(flags); @@ -160,21 +154,16 @@ public class WorldGuardListener implements Listener { public void onPlotClaim(PlayerClaimPlotEvent event) { Player player = event.getPlayer(); Plot plot = event.getPlot(); - RegionManager manager = PlotMain.worldGuard.getRegionManager(plot - .getWorld()); + RegionManager manager = PlotMain.worldGuard.getRegionManager(plot.getWorld()); - Location location1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), - plot.getId()); - Location location2 = PlotHelper.getPlotTopLoc(plot.getWorld(), - plot.getId()); + Location location1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId()); + Location location2 = PlotHelper.getPlotTopLoc(plot.getWorld(), plot.getId()); - BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, - location1.getBlockZ()); - BlockVector vector2 = new BlockVector(location2.getBlockX(), plot - .getWorld().getMaxHeight(), location2.getBlockZ()); + BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ()); + BlockVector vector2 = + new BlockVector(location2.getBlockX(), plot.getWorld().getMaxHeight(), location2.getBlockZ()); - ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" - + plot.getId().y, vector1, vector2); + ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2); DefaultDomain owner = new DefaultDomain(); owner.addPlayer(PlotMain.worldGuard.wrapPlayer(player)); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/uuid/NameFetcher.java b/PlotSquared/src/com/intellectualcrafters/plot/uuid/NameFetcher.java index 6403ef129..e891d9ab5 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/uuid/NameFetcher.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/uuid/NameFetcher.java @@ -15,9 +15,7 @@ import org.json.simple.parser.JSONParser; import com.google.common.collect.ImmutableList; /** - * * @author - * */ public class NameFetcher implements Callable> { private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/"; @@ -35,11 +33,10 @@ public class NameFetcher implements Callable> { if (uuidStringMap.containsKey(uuid)) { continue; } - HttpURLConnection connection = (HttpURLConnection) new URL( - PROFILE_URL + uuid.toString().replace("-", "")) - .openConnection(); - JSONObject response = (JSONObject) this.jsonParser - .parse(new InputStreamReader(connection.getInputStream())); + HttpURLConnection connection = + (HttpURLConnection) new URL(PROFILE_URL + uuid.toString().replace("-", "")).openConnection(); + JSONObject response = + (JSONObject) this.jsonParser.parse(new InputStreamReader(connection.getInputStream())); String name = (String) response.get("name"); if (name == null) { continue; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/uuid/UUIDFetcher.java b/PlotSquared/src/com/intellectualcrafters/plot/uuid/UUIDFetcher.java index 614bc9e4c..002de2a2d 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/uuid/UUIDFetcher.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/uuid/UUIDFetcher.java @@ -40,15 +40,13 @@ public class UUIDFetcher implements Callable> { @Override public Map call() throws Exception { Map uuidMap = new HashMap(); - int requests = (int) Math - .ceil(this.names.size() / PROFILES_PER_REQUEST); + int requests = (int) Math.ceil(this.names.size() / PROFILES_PER_REQUEST); for (int i = 0; i < requests; i++) { HttpURLConnection connection = createConnection(); - String body = JSONArray.toJSONString(this.names.subList(i * 100, - Math.min((i + 1) * 100, this.names.size()))); + String body = + JSONArray.toJSONString(this.names.subList(i * 100, Math.min((i + 1) * 100, this.names.size()))); writeBody(connection, body); - JSONArray array = (JSONArray) this.jsonParser - .parse(new InputStreamReader(connection.getInputStream())); + JSONArray array = (JSONArray) this.jsonParser.parse(new InputStreamReader(connection.getInputStream())); for (Object profile : array) { JSONObject jsonProfile = (JSONObject) profile; String id = (String) jsonProfile.get("id"); @@ -63,8 +61,7 @@ public class UUIDFetcher implements Callable> { return uuidMap; } - private static void writeBody(HttpURLConnection connection, String body) - throws Exception { + private static void writeBody(HttpURLConnection connection, String body) throws Exception { OutputStream stream = connection.getOutputStream(); stream.write(body.getBytes()); stream.flush(); @@ -83,9 +80,8 @@ public class UUIDFetcher implements Callable> { } public static UUID getUUID(String id) { - return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) - + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" - + id.substring(20, 32)); + return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + + id.substring(16, 20) + "-" + id.substring(20, 32)); } public static byte[] toBytes(UUID uuid) { @@ -97,8 +93,7 @@ public class UUIDFetcher implements Callable> { public static UUID fromBytes(byte[] array) { if (array.length != 16) { - throw new IllegalArgumentException("Illegal byte array length: " - + array.length); + throw new IllegalArgumentException("Illegal byte array length: " + array.length); } ByteBuffer byteBuffer = ByteBuffer.wrap(array); long mostSignificant = byteBuffer.getLong(); diff --git a/PlotSquared/src/com/intellectualsites/web/IndexHandler.java b/PlotSquared/src/com/intellectualsites/web/IndexHandler.java index eeae18306..2eb358ff5 100644 --- a/PlotSquared/src/com/intellectualsites/web/IndexHandler.java +++ b/PlotSquared/src/com/intellectualsites/web/IndexHandler.java @@ -37,15 +37,13 @@ public class IndexHandler implements Container { if ((request.getInteger("page")) < 0) { } - if (((coverage = request.getTarget()) == null) - || coverage.equals("/")) { + if (((coverage = request.getTarget()) == null) || coverage.equals("/")) { coverage = "index"; } coverage = coverage.toLowerCase(); - List list = new ArrayList<>(Arrays.asList(new String[] { - "install", "index", "stylesheet" })); + List list = new ArrayList<>(Arrays.asList(new String[] { "install", "index", "stylesheet" })); if (!list.contains(coverage)) { coverage = "index"; @@ -57,33 +55,29 @@ public class IndexHandler implements Container { response.setDate("Date", time); response.setDate("Last-Modified", time); - ResourceHandler stylesheet = new ResourceHandler("stylesheet", - ResourceHandler.FileType.CSS, - this.plugin.getDataFolder()); + ResourceHandler stylesheet = + new ResourceHandler("stylesheet", ResourceHandler.FileType.CSS, this.plugin.getDataFolder()); String stylesheetHTML = stylesheet.getHTML(); stylesheet.done(); body.print(stylesheetHTML); - } else { + } + else { response.setValue("Content-Type", "html"); response.setValue("Server", "PlotWeb/1.0 (Simple 5.0)"); response.setDate("Date", time); response.setDate("Last-Modified", time); - ResourceHandler header = new ResourceHandler("header", - ResourceHandler.FileType.HTML, - this.plugin.getDataFolder()); - ResourceHandler footer = new ResourceHandler("footer", - ResourceHandler.FileType.HTML, - this.plugin.getDataFolder()); - ResourceHandler cPage = new ResourceHandler(coverage, - ResourceHandler.FileType.HTML, - this.plugin.getDataFolder()); + ResourceHandler header = + new ResourceHandler("header", ResourceHandler.FileType.HTML, this.plugin.getDataFolder()); + ResourceHandler footer = + new ResourceHandler("footer", ResourceHandler.FileType.HTML, this.plugin.getDataFolder()); + ResourceHandler cPage = + new ResourceHandler(coverage, ResourceHandler.FileType.HTML, this.plugin.getDataFolder()); - String headerHTML = header.getHTML().replace("@title", - this.title); + String headerHTML = header.getHTML().replace("@title", this.title); String footerHTML = footer.getHTML(); String cPageHTML = cPage.getHTML(); @@ -96,7 +90,8 @@ public class IndexHandler implements Container { body.print(footerHTML); } body.close(); - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); } } diff --git a/PlotSquared/src/com/intellectualsites/web/PlotWeb.java b/PlotSquared/src/com/intellectualsites/web/PlotWeb.java index 3a1c69e5e..fb9260710 100644 --- a/PlotSquared/src/com/intellectualsites/web/PlotWeb.java +++ b/PlotSquared/src/com/intellectualsites/web/PlotWeb.java @@ -34,8 +34,7 @@ public class PlotWeb { } public void start() throws Exception { - this.container = new IndexHandler(JavaPlugin.getPlugin(PlotMain.class), - this.title); + this.container = new IndexHandler(JavaPlugin.getPlugin(PlotMain.class), this.title); this.server = new ContainerServer(this.container); this.connection = new SocketConnection(this.server); this.address = new InetSocketAddress(this.port); diff --git a/PlotSquared/src/com/intellectualsites/web/ResourceHandler.java b/PlotSquared/src/com/intellectualsites/web/ResourceHandler.java index 1196b2d4c..ceb93fbf6 100644 --- a/PlotSquared/src/com/intellectualsites/web/ResourceHandler.java +++ b/PlotSquared/src/com/intellectualsites/web/ResourceHandler.java @@ -13,23 +13,22 @@ public class ResourceHandler { private File file; private BufferedReader reader; - public ResourceHandler(String filePath, FileType fileType, File folder) - throws Exception { + public ResourceHandler(String filePath, FileType fileType, File folder) throws Exception { if (fileType == FileType.CSS) { - this.file = new File(folder.toPath().toString() + File.separator - + "web" + File.separator + "css" + File.separator - + filePath + "." + fileType.toString()); - } else { - this.file = new File(folder.toPath().toString() + File.separator - + "web" + File.separator + filePath + "." - + fileType.toString()); + this.file = + new File(folder.toPath().toString() + File.separator + "web" + File.separator + "css" + + File.separator + filePath + "." + fileType.toString()); + } + else { + this.file = + new File(folder.toPath().toString() + File.separator + "web" + File.separator + filePath + "." + + fileType.toString()); } } public String getHTML() throws Exception { StringBuilder html = new StringBuilder(); - this.reader = new BufferedReader(new InputStreamReader( - new FileInputStream(this.file))); + this.reader = new BufferedReader(new InputStreamReader(new FileInputStream(this.file))); String line = ""; while ((line = this.reader.readLine()) != null) { html.append(line); @@ -42,7 +41,9 @@ public class ResourceHandler { } public static enum FileType { - CSS("css"), HTML("html"), JS("js"); + CSS("css"), + HTML("html"), + JS("js"); private String ext; diff --git a/PlotSquared/src/com/intellectualsites/web/Test.java b/PlotSquared/src/com/intellectualsites/web/Test.java index a6ba06daf..3691e3857 100644 --- a/PlotSquared/src/com/intellectualsites/web/Test.java +++ b/PlotSquared/src/com/intellectualsites/web/Test.java @@ -8,7 +8,8 @@ public class Test { public static void main(String[] args) { try { new PlotWeb("Test", 9000).start(); - } catch (Exception e) { + } + catch (Exception e) { e.printStackTrace(); } }