testing some new formatting rules + bug fixes
This commit is contained in:
Jesse Boyd 2014-10-12 00:37:36 -07:00
parent 79e0459a3a
commit 3ffb182a3c
90 changed files with 2880 additions and 3807 deletions

View File

@ -18,8 +18,7 @@ public class AbstractFlag {
*/ */
public AbstractFlag(String key) { public AbstractFlag(String key) {
if (!StringUtils.isAlpha(key)) { if (!StringUtils.isAlpha(key)) {
throw new IllegalArgumentException( throw new IllegalArgumentException("Flag must be alphabetic characters");
"Flag must be alphabetic characters");
} }
if (key.length() > 16) { if (key.length() > 16) {
throw new IllegalArgumentException("Key must be <= 16 characters"); throw new IllegalArgumentException("Key must be <= 16 characters");

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = C.java * >> File = C.java >> Generated by: Citymonstret at 2014-08-09 01:43
* >> Generated by: Citymonstret at 2014-08-09 01:43
*/ */
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
@ -15,271 +14,274 @@ import org.bukkit.ChatColor;
* Captions class. * Captions class.
* *
* @author Citymonstret * @author Citymonstret
*
*/ */
public enum C { public enum C {
/* /*
* Ratings * Ratings
*/ */
RATING_NOT_VALID("&cYou need to specify a number between 1 and 10"), RATING_ALREADY_EXISTS( RATING_NOT_VALID("&cYou need to specify a number between 1 and 10"),
"&cYou have already rated plot &c%s"), RATING_APPLIED( RATING_ALREADY_EXISTS("&cYou have already rated plot &c%s"),
"&cYou successfully rated plot &6%s"), RATING_NOT_YOUR_OWN( RATING_APPLIED("&cYou successfully rated plot &6%s"),
"&cYou cannot rate your own plot"), RATING_NOT_OWNED( RATING_NOT_YOUR_OWN("&cYou cannot rate your own plot"),
"&cYou cannot rate a plot that is not claimed by anyone"), RATING_NOT_OWNED("&cYou cannot rate a plot that is not claimed by anyone"),
/* /*
* Economy Stuff * Economy Stuff
*/ */
CANNOT_AFFORD_PLOT("&cYou cannot afford to buy this plot. It costs &6%s"), CANNOT_AFFORD_MERGE( CANNOT_AFFORD_PLOT("&cYou cannot afford to buy this plot. It costs &6%s"),
"&cYou cannot afford to merge the plots. It costs &6%s"), ADDED_BALANCE( CANNOT_AFFORD_MERGE("&cYou cannot afford to merge the plots. It costs &6%s"),
"&6%s &chas been added to your balance"), REMOVED_BALANCE( ADDED_BALANCE("&6%s &chas been added to your balance"),
"&6%s &chas been taken from your balance"), REMOVED_BALANCE("&6%s &chas been taken from your balance"),
/* /*
* Setup Stuff * Setup Stuff
*/ */
SETUP_INIT("&6PlotSquared Setup -> Setup a new plotworld"), SETUP_STEP( SETUP_INIT("&6PlotSquared Setup -> Setup a new plotworld"),
"&cStep &6%s&c: %s &c<Expecting: &6%s&c, Default: &6%s&c>"), SETUP_INVALID_ARG( SETUP_STEP("&cStep &6%s&c: %s &c<Expecting: &6%s&c, Default: &6%s&c>"),
"&c%s is not a valid argument for step %s. To cancel setup use: /plot setup cancel"), SETUP_VALID_ARG( SETUP_INVALID_ARG("&c%s is not a valid argument for step %s. To cancel setup use: /plot setup cancel"),
"&cValue &6%s &cset for step %s"), SETUP_FINISHED( SETUP_VALID_ARG("&cValue &6%s &cset for step %s"),
"&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( 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"),
"&c%s is already a registered plotworld"), SETUP_MISSING_WORLD( SETUP_WORLD_TAKEN("&c%s is already a registered plotworld"),
"&cYou need to specify a world name (&6/p setup &l{world}&6 {generator}&c)\n&6Additional commands:\n&c - &6/p setup <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"), SETUP_MISSING_GENERATOR( 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 <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"),
"&cYou need to specify a generator (&6/p setup {world} &l{generator}&r&c)\n&6Additional commands:\n&c - &6/p setup <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"), SETUP_INVALID_GENERATOR( 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 <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"),
"&cIncalid generator. Possible options: %generators%"), SETUP_INVALID_GENERATOR("&cIncalid generator. Possible options: %s"),
/* /*
* Schematic Stuff * Schematic Stuff
*/ */
SCHEMATIC_MISSING_ARG( SCHEMATIC_MISSING_ARG("&cYou need to specify an argument. Possible values: &6test {name}"),
"&cYou need to specify an argument. Possible values: &6test {name}"), SCHEMATIC_INVALID( SCHEMATIC_INVALID("&cThat is not a valid schematic. Reason: &c%s"),
"&cThat is not a valid schematic. Reason: &c%s"), SCHEMATIC_VALID( SCHEMATIC_VALID("&cThat's a valid schematic"),
"&cThat's a valid schematic"), SCHEMATIC_PASTE_FAILED( SCHEMATIC_PASTE_FAILED("&cFailed to paste schematic"),
"&cFailed to paste schematic"), SCHEMATIC_PASTE_SUCCESS( SCHEMATIC_PASTE_SUCCESS("&cSchematic pasted successfully"),
"&cSchematic pasted successfully"), /*
/* * Title Stuff
* Title Stuff */
*/ TITLE_ENTERED_PLOT("You entered plot %s"),
TITLE_ENTERED_PLOT("You entered plot %s"), TITLE_ENTERED_PLOT_COLOR("GOLD"), TITLE_ENTERED_PLOT_SUB( TITLE_ENTERED_PLOT_COLOR("GOLD"),
"Owned by %s"), TITLE_ENTERED_PLOT_SUB_COLOR("RED"), TITLE_LEFT_PLOT( TITLE_ENTERED_PLOT_SUB("Owned by %s"),
"You entered plot %s"), TITLE_LEFT_PLOT_COLOR("GOLD"), TITLE_LEFT_PLOT_SUB( TITLE_ENTERED_PLOT_SUB_COLOR("RED"),
"Owned by %s"), TITLE_LEFT_PLOT_SUB_COLOR("RED"), TITLE_LEFT_PLOT("You entered plot %s"),
/* TITLE_LEFT_PLOT_COLOR("GOLD"),
* Core Stuff TITLE_LEFT_PLOT_SUB("Owned by %s"),
*/ TITLE_LEFT_PLOT_SUB_COLOR("RED"),
PREFIX("&c[&6&lPlot&c] "), ENABLED("&6Plots are now enabled"), EXAMPLE_MESSAGE( /*
"&cThis is an example message &k!!!"), * Core Stuff
/* */
* Reload PREFIX("&c[&6&lPlot&c] "),
*/ ENABLED("&6Plots are now enabled"),
RELOADED_CONFIGS("&6The translation files has been reloaded"), RELOAD_FAILED( EXAMPLE_MESSAGE("&cThis is an example message &k!!!"),
"&cFailed to reload the translations file"), /*
/* * Reload
* BarAPI */
*/ RELOADED_CONFIGS("&6The translation files has been reloaded"),
BOSSBAR_CLEARING("&cClearing plot: &6%id%"), RELOAD_FAILED("&cFailed to reload the translations file"),
/* /*
* Alias * BarAPI
*/ */
ALIAS_SET_TO("&cPlot alias set to &6%alias%"), MISSING_ALIAS( BOSSBAR_CLEARING("&cClearing plot: &6%id%"),
"&cYou need to specify the alias"), ALIAS_IS_TAKEN( /*
"&cThat alias is already taken"), * Alias
/* */
* Position ALIAS_SET_TO("&cPlot alias set to &6%alias%"),
*/ MISSING_ALIAS("&cYou need to specify the alias"),
MISSING_POSITION( ALIAS_IS_TAKEN("&cThat alias is already taken"),
"&cYou need to specify a position. Possible values: &6default&c, &6center"), POSITION_SET( /*
"&cPlot home position set"), INVALID_POSITION( * Position
"&cThat is not a valid position value"), */
/* MISSING_POSITION("&cYou need to specify a position. Possible values: &6default&c, &6center"),
* Time POSITION_SET("&cPlot home position set"),
*/ INVALID_POSITION("&cThat is not a valid position value"),
TIME_FORMAT("&6%hours%, %min%, %sec%"), /*
/* * Time
* Permission */
*/ TIME_FORMAT("&6%hours%, %min%, %sec%"),
NO_SCHEMATIC_PERMISSION( /*
"&cYou don't have the permission required to use schematic &6%s"), NO_PERMISSION( * 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( NO_SCHEMATIC_PERMISSION("&cYou don't have the permission required to use schematic &6%s"),
"&cYou can't claim more plots."), YOU_BE_DENIED( NO_PERMISSION("&cYou don't have the permissions required to use this command."),
"&cYou are not allowed to enter this plot"), 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( NO_PERM_MERGE("&cYou are not the owner of the plot: &6%plot%"),
"&cAn unlink is required to do this."), UNLINK_IMPOSSIBLE( UNLINK_REQUIRED("&cAn unlink is required to do this."),
"&cYou can only unlink a mega-plot"), NO_MERGE_TO_MEGA( UNLINK_IMPOSSIBLE("&cYou can only unlink a mega-plot"),
"&cMega plots cannot be merged into. Please merge from the desired mega plot."), NO_MERGE_TO_MEGA("&cMega plots cannot be merged into. Please merge from the desired mega plot."),
/* /*
* Commands * Commands
*/ */
NOT_VALID_SUBCOMMAND("&cThat is not a valid subcommand."), NO_COMMANDS( NOT_VALID_SUBCOMMAND("&cThat is not a valid subcommand."),
"&cI'm sorry, but you're not permitted to use any subcommands."), SUBCOMMAND_SET_OPTIONS_HEADER( NO_COMMANDS("&cI'm sorry, but you're not permitted to use any subcommands."),
"&cPossible Values: "), SUBCOMMAND_SET_OPTIONS_HEADER("&cPossible Values: "),
/* /*
* Player not found * Player not found
*/ */
INVALID_PLAYER("&cPlayer not found: &6%player%."), INVALID_PLAYER("&cPlayer not found: &6%player%."),
/* /*
* *
*/ */
COMMAND_WENT_WRONG("&cSomething went wrong when executing that command..."), COMMAND_WENT_WRONG("&cSomething went wrong when executing that command..."),
/* /*
* No {plot} * No {plot}
*/ */
NOT_IN_PLOT("&cYou're not in a plot"), NOT_IN_PLOT_WORLD( NOT_IN_PLOT("&cYou're not in a plot"),
"&cYou're not in a plot world"), NOT_VALID_WORLD( NOT_IN_PLOT_WORLD("&cYou're not in a plot world"),
"&cThat is not a valid world (case sensitive)"), NOT_VALID_PLOT_WORLD( NOT_VALID_WORLD("&cThat is not a valid world (case sensitive)"),
"&cThat is not a valid plot world (case sensitive)"), NO_PLOTS( NOT_VALID_PLOT_WORLD("&cThat is not a valid plot world (case sensitive)"),
"&cYou don't have any plots"), NO_PLOTS("&cYou don't have any plots"),
/* /*
* Block List * Block List
*/ */
NOT_VALID_BLOCK_LIST_HEADER( NOT_VALID_BLOCK_LIST_HEADER("&cThat's not a valid block. Valid blocks are:\\n"),
"&cThat's not a valid block. Valid blocks are:\\n"), BLOCK_LIST_ITEM( BLOCK_LIST_ITEM(" &6%mat%&c,"),
" &6%mat%&c,"), BLOCK_LIST_SEPARATER("&6,&c "), BLOCK_LIST_SEPARATER("&6,&c "),
/* /*
* Biome * Biome
*/ */
NEED_BIOME("&cYou've got to specify a biome"), BIOME_SET_TO( NEED_BIOME("&cYou've got to specify a biome"),
"&cPlot biome set to &c"), BIOME_SET_TO("&cPlot biome set to &c"),
/* /*
* Teleport / Entry * Teleport / Entry
*/ */
TELEPORTED_TO_PLOT("&6You have been teleported"), TELEPORTED_TO_PLOT("&6You have been teleported"),
/* /*
* Set Block * Set Block
*/ */
SET_BLOCK_ACTION_FINISHED("&6The last setblock action is now finished."), SET_BLOCK_ACTION_FINISHED("&6The last setblock action is now finished."),
/* /*
* Debug * Debug
*/ */
DEUBG_HEADER("&6Debug Information\\n"), DEBUG_SECTION("&c>> &6&l%val%"), DEBUG_LINE( DEUBG_HEADER("&6Debug Information\\n"),
"&c>> &6%var%&c:&6 %val%\\n"), DEBUG_SECTION("&c>> &6&l%val%"),
/* DEBUG_LINE("&c>> &6%var%&c:&6 %val%\\n"),
* Invalid /*
*/ * Invalid
NOT_VALID_DATA("&cThat's not a valid data id."), NOT_VALID_BLOCK( */
"&cThat's not a valid block."), NOT_VALID_NUMBER( NOT_VALID_DATA("&cThat's not a valid data id."),
"&cThat's not a valid number"), NOT_VALID_PLOT_ID( NOT_VALID_BLOCK("&cThat's not a valid block."),
"&cThat's not a valid plot id."), NOT_YOUR_PLOT( NOT_VALID_NUMBER("&cThat's not a valid number"),
"&cThat is not your plot."), NO_SUCH_PLOT("&cThere is no such plot"), PLAYER_HAS_NOT_BEEN_ON( NOT_VALID_PLOT_ID("&cThat's not a valid plot id."),
"&cThat player hasn't been in the plotworld"), FOUND_NO_PLOTS( NOT_YOUR_PLOT("&cThat is not your plot."),
"&cFound no plots with your search query"), NO_SUCH_PLOT("&cThere is no such plot"),
/* PLAYER_HAS_NOT_BEEN_ON("&cThat player hasn't been in the plotworld"),
* Camera FOUND_NO_PLOTS("&cFound no plots with your search query"),
*/ /*
CAMERA_STARTED("&cYou have entered camera mode for plot &6%s"), CAMERA_STOPPED( * Camera
"&cYou are no longer in camera mode"), */
/* CAMERA_STARTED("&cYou have entered camera mode for plot &6%s"),
* Need CAMERA_STOPPED("&cYou are no longer in camera mode"),
*/ /*
NEED_PLOT_NUMBER("&cYou've got to specify a plot number or alias"), NEED_BLOCK( * Need
"&cYou've got to specify a block"), NEED_PLOT_ID( */
"&cYou've got to specify a plot id."), NEED_USER( NEED_PLOT_NUMBER("&cYou've got to specify a plot number or alias"),
"&cYou need to specify a username"), NEED_BLOCK("&cYou've got to specify a block"),
/* NEED_PLOT_ID("&cYou've got to specify a plot id."),
* Info NEED_USER("&cYou need to specify a username"),
*/ /*
PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"), PLOT_INFO( * 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,"), 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%"),
* Generating PLOT_USER_LIST(" &6%user%&c,"),
*/ /*
GENERATING_FLOOR( * Generating
"&6Started generating floor from your settings. It will take %time%"), GENERATING_WALL( */
"&6Started generating wall from your settings"), GENERATING_WALL_FILLING( GENERATING_FLOOR("&6Started generating floor from your settings. It will take %time%"),
"&cStarted generating wall filling from your settings."), GENERATING_WALL("&6Started generating wall from your settings"),
/* GENERATING_WALL_FILLING("&cStarted generating wall filling from your settings."),
* Clearing /*
*/ * Clearing
CLEARING_PLOT("&cClearing plot."), CLEARING_DONE( */
"&6Done, took &a%time%&6 ms!"), CLEARING_DONE_PACKETS( CLEARING_PLOT("&cClearing plot."),
"&6(&a%time% &6ms for packets)"), CLEARING_DONE("&6Done, took &a%time%&6 ms!"),
/* CLEARING_DONE_PACKETS("&6(&a%time% &6ms for packets)"),
* Claiming /*
*/ * Claiming
PLOT_NOT_CLAIMED("&cCannot claim plot"), PLOT_IS_CLAIMED( */
"&cThis plot is already claimed"), CLAIMED( PLOT_NOT_CLAIMED("&cCannot claim plot"),
"&6You successfully claimed the plot"), PLOT_IS_CLAIMED("&cThis plot is already claimed"),
/* CLAIMED("&6You successfully claimed the plot"),
* List /*
*/ * List
PLOT_LIST_HEADER("&6List of %word% plots"), PLOT_LIST_ITEM( */
"&c>> &6%id% &c- &6%owner%"), PLOT_LIST_FOOTER( PLOT_LIST_HEADER("&6List of %word% plots"),
"&c>> &6%word% a total of &c%num% &6claimed %plot%."), PLOT_LIST_ITEM("&c>> &6%id% &c- &6%owner%"),
/* PLOT_LIST_FOOTER("&c>> &6%word% a total of &c%num% &6claimed %plot%."),
* Left /*
*/ * Left
LEFT_PLOT("&cYou left a plot"), */
/* LEFT_PLOT("&cYou left a plot"),
* Wait /*
*/ * Wait
WAIT_FOR_TIMER( */
"&cA setblock timer is bound to either the current plot or you. Please wait for it to finish"), WAIT_FOR_TIMER("&cA setblock timer is bound to either the current plot or you. Please wait for it to finish"),
/* /*
* Chat * Chat
*/ */
PLOT_CHAT_FORMAT("&c[&6Plot Chat&c][&6%plot_id%&c] &6%sender%&c: &6%msg%"), PLOT_CHAT_FORMAT("&c[&6Plot Chat&c][&6%plot_id%&c] &6%sender%&c: &6%msg%"),
/* /*
* Denied * Denied
*/ */
DENIED_REMOVED("&cYou successfully undenied the player from this plot"), DENIED_ADDED( DENIED_REMOVED("&cYou successfully undenied the player from this plot"),
"&cYou successfully denied the player from this plot"), DENIED_NEED_ARGUMENT( DENIED_ADDED("&cYou successfully denied the player from this plot"),
"&cArguments are missing. &6/plot denied add {name} &cor &6/plot helpers remove {name}"), WAS_NOT_DENIED( DENIED_NEED_ARGUMENT("&cArguments are missing. &6/plot denied add {name} &cor &6/plot helpers remove {name}"),
"&cThat player was not denied on this plot"), WAS_NOT_DENIED("&cThat player was not denied on this plot"),
/* /*
* Rain * Rain
*/ */
NEED_ON_OFF("&cYou need to specify a value. Possible values: &6on&c, &6off"), SETTING_UPDATED( NEED_ON_OFF("&cYou need to specify a value. Possible values: &6on&c, &6off"),
"&cYou successfully updated the setting"), SETTING_UPDATED("&cYou successfully updated the setting"),
/* /*
* Flag * Flag
*/ */
NEED_KEY("&cPossible values: &6%values%"), NOT_VALID_FLAG( NEED_KEY("&cPossible values: &6%values%"),
"&cThat is not a valid flag"), NOT_VALID_VALUE( NOT_VALID_FLAG("&cThat is not a valid flag"),
"&cFlag values must be alphanumerical"), FLAG_NOT_IN_PLOT( NOT_VALID_VALUE("&cFlag values must be alphanumerical"),
"&cThe plot does not have that flag"), FLAG_NOT_REMOVED( FLAG_NOT_IN_PLOT("&cThe plot does not have that flag"),
"&cThe flag could not be removed"), FLAG_NOT_ADDED( FLAG_NOT_REMOVED("&cThe flag could not be removed"),
"&cThe flag could not be added"), FLAG_REMOVED( FLAG_NOT_ADDED("&cThe flag could not be added"),
"&6Successfully removed flag"), FLAG_ADDED( FLAG_REMOVED("&6Successfully removed flag"),
"&6Successfully added flag"), FLAG_ADDED("&6Successfully added flag"),
/* /*
* Helper * Helper
*/ */
HELPER_ADDED("&6You successfully added a helper to the plot"), HELPER_REMOVED( HELPER_ADDED("&6You successfully added a helper to the plot"),
"&6You successfully removed a helper from the plot"), HELPER_NEED_ARGUMENT( HELPER_REMOVED("&6You successfully removed a helper from the plot"),
"&cArguments are missing. &6/plot helpers add {name} &cor &6/plot helpers remove {name}"), WAS_NOT_ADDED( HELPER_NEED_ARGUMENT("&cArguments are missing. &6/plot helpers add {name} &cor &6/plot helpers remove {name}"),
"&cThat player was not added as a helper on this plot"), WAS_NOT_ADDED("&cThat player was not added as a helper on this plot"),
/* /*
* Trusted * Trusted
*/ */
TRUSTED_ADDED("&6You successfully added a trusted user to the plot"), TRUSTED_REMOVED( TRUSTED_ADDED("&6You successfully added a trusted user to the plot"),
"&6You successfully removed a trusted user from the plot"), TRUSTED_NEED_ARGUMENT( TRUSTED_REMOVED("&6You successfully removed a trusted user from the plot"),
"&cArguments are missing. &6/plot trusted add {name} &cor &6/plot trusted remove {name}"), T_WAS_NOT_ADDED( TRUSTED_NEED_ARGUMENT("&cArguments are missing. &6/plot trusted add {name} &cor &6/plot trusted remove {name}"),
"&cThat player was not added as a trusted user on this plot"), T_WAS_NOT_ADDED("&cThat player was not added as a trusted user on this plot"),
/* /*
* Set Owner * Set Owner
*/ */
SET_OWNER("&6You successfully set the plot owner"), SET_OWNER("&6You successfully set the plot owner"),
/* /*
* Signs * Signs
*/ */
OWNER_SIGN_LINE_1("&cID: &6%id%"), OWNER_SIGN_LINE_2("&cOwner:"), OWNER_SIGN_LINE_3( OWNER_SIGN_LINE_1("&cID: &6%id%"),
"&6%plr%"), OWNER_SIGN_LINE_4("&2Claimed"), OWNER_SIGN_LINE_2("&cOwner:"),
/* OWNER_SIGN_LINE_3("&6%plr%"),
* Help OWNER_SIGN_LINE_4("&2Claimed"),
*/ /*
HELP_CATEGORY("&6Current Category&c: &l%category%"), HELP_INFO( * Help
"&6You need to specify a help category"), HELP_INFO_ITEM( */
"&6/plots help %category% &c- &6%category_desc%"), HELP_PAGE( HELP_CATEGORY("&6Current Category&c: &l%category%"),
"&c>> &6%usage% &c[&6%alias%&c] &c- &6%desc%"), HELP_HEADER( HELP_INFO("&6You need to specify a help category"),
"&6Help for Plots"), HELP_INFO_ITEM("&6/plots help %category% &c- &6%category_desc%"),
/* HELP_PAGE("&c>> &6%usage% &c[&6%alias%&c] &c- &6%desc%"),
* Direction HELP_HEADER("&6Help for Plots"),
*/ /*
DIRECTION("&6Current direction: %dir%"), * Direction
/* */
* Custom DIRECTION("&6Current direction: %dir%"),
*/ /*
CUSTOM_STRING("-"); * Custom
*/
CUSTOM_STRING("-");
/** /**
* Default * Default
*/ */
@ -309,7 +311,8 @@ public enum C {
this.d = d; this.d = d;
if (PlotMain.translations == null) { if (PlotMain.translations == null) {
this.s = d; this.s = d;
} else { }
else {
this.s = PlotMain.translations.getString(this.toString()); this.s = PlotMain.translations.getString(this.toString());
} }
if (this.s == null) { if (this.s == null) {
@ -340,7 +343,6 @@ public enum C {
} }
/** /**
*
* @return translated and color decoded * @return translated and color decoded
*/ */
public String translated() { public String translated() {

View File

@ -36,7 +36,8 @@ public class Configuration {
try { try {
Integer.parseInt(string); Integer.parseInt(string);
return true; return true;
} catch (Exception e) { }
catch (Exception e) {
return false; return false;
} }
} }
@ -53,7 +54,8 @@ public class Configuration {
try { try {
Boolean.parseBoolean(string); Boolean.parseBoolean(string);
return true; return true;
} catch (Exception e) { }
catch (Exception e) {
return false; return false;
} }
} }
@ -70,7 +72,8 @@ public class Configuration {
try { try {
Double.parseDouble(string); Double.parseDouble(string);
return true; return true;
} catch (Exception e) { }
catch (Exception e) {
return false; return false;
} }
} }
@ -87,17 +90,18 @@ public class Configuration {
try { try {
Biome.valueOf(string.toUpperCase()); Biome.valueOf(string.toUpperCase());
return true; return true;
} catch (Exception e) { }
catch (Exception e) {
return false; return false;
} }
} }
@Override @Override
public Object parseString(String string) { public Object parseString(String string) {
for (Biome biome:Biome.values()) { for (Biome biome : Biome.values()) {
if (biome.name().equals(string.toUpperCase())) { if (biome.name().equals(string.toUpperCase())) {
return biome; return biome;
} }
} }
return Biome.FOREST; return Biome.FOREST;
} }
@ -116,11 +120,13 @@ public class Configuration {
String[] split = string.split(":"); String[] split = string.split(":");
Short.parseShort(split[0]); Short.parseShort(split[0]);
Short.parseShort(split[1]); Short.parseShort(split[1]);
} else { }
else {
Short.parseShort(string); Short.parseShort(string);
} }
return true; return true;
} catch (Exception e) { }
catch (Exception e) {
return false; return false;
} }
} }
@ -129,9 +135,9 @@ public class Configuration {
public Object parseString(String string) { public Object parseString(String string) {
if (string.contains(":")) { if (string.contains(":")) {
String[] split = string.split(":"); String[] split = string.split(":");
return new PlotBlock(Short.parseShort(split[0]), return new PlotBlock(Short.parseShort(split[0]), Byte.parseByte(split[1]));
Byte.parseByte(split[1])); }
} else { else {
return new PlotBlock(Short.parseShort(string), (byte) 0); return new PlotBlock(Short.parseShort(string), (byte) 0);
} }
} }
@ -151,12 +157,14 @@ public class Configuration {
String[] split = block.split(":"); String[] split = block.split(":");
Short.parseShort(split[0]); Short.parseShort(split[0]);
Short.parseShort(split[1]); Short.parseShort(split[1]);
} else { }
else {
Short.parseShort(block); Short.parseShort(block);
} }
} }
return true; return true;
} catch (Exception e) { }
catch (Exception e) {
return false; return false;
} }
} }
@ -166,13 +174,12 @@ public class Configuration {
String[] blocks = string.split(","); String[] blocks = string.split(",");
PlotBlock[] values = new PlotBlock[blocks.length]; PlotBlock[] values = new PlotBlock[blocks.length];
for (int i = 0; i < blocks.length; i++) { for (int i = 0; i < blocks.length; i++) {
if (string.contains(":")) { if (blocks[i].contains(":")) {
String[] split = string.split(":"); String[] split = blocks[i].split(":");
values[i] = new PlotBlock(Short.parseShort(split[0]), values[i] = new PlotBlock(Short.parseShort(split[0]), Byte.parseByte(split[1]));
Byte.parseByte(split[1])); }
} else { else {
values[i] = new PlotBlock(Short.parseShort(string), values[i] = new PlotBlock(Short.parseShort(blocks[i]), (byte) 0);
(byte) 0);
} }
} }
return values; return values;
@ -189,10 +196,8 @@ public class Configuration {
}; };
/** /**
*
* Create your own SettingValue object to make the management of plotworld * Create your own SettingValue object to make the management of plotworld
* configuration easier * configuration easier
*
*/ */
public static abstract class SettingValue { public static abstract class SettingValue {
private String type; private String type;

View File

@ -13,8 +13,8 @@ public class ConfigurationNode {
private Object value; private Object value;
private SettingValue type; private SettingValue type;
public ConfigurationNode(String constant, Object default_value, public ConfigurationNode(String constant, Object default_value, String description, SettingValue type,
String description, SettingValue type, boolean required) { boolean required) {
this.constant = constant; this.constant = constant;
this.default_value = default_value; this.default_value = default_value;
this.description = description; this.description = description;
@ -33,7 +33,8 @@ public class ConfigurationNode {
return false; return false;
} }
return true; return true;
} catch (Exception e) { }
catch (Exception e) {
return false; return false;
} }
} }

View File

@ -8,10 +8,18 @@ import org.bukkit.ChatColor;
public class ConsoleColors { public class ConsoleColors {
static enum ConsoleColor { static enum ConsoleColor {
RESET("\u001B[0m"), BLACK("\u001B[30m"), RED("\u001B[31m"), GREEN( RESET("\u001B[0m"),
"\u001B[32m"), YELLOW("\u001B[33m"), BLUE("\u001B[34m"), PURPLE( BLACK("\u001B[30m"),
"\u001B[35m"), CYAN("\u001B[36m"), WHITE("\u001B[37m"), BOLD( RED("\u001B[31m"),
"\033[1m"), UNDERLINE("\033[0m"), ITALIC("\033[3m"); 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 win;
private String lin; private String lin;
@ -44,28 +52,8 @@ public class ConsoleColors {
*/ */
public static String fromString(String input) { public static String fromString(String input) {
input = input.replaceAll("&0", fromChatColor(ChatColor.BLACK)) input =
.replaceAll("&1", fromChatColor(ChatColor.DARK_BLUE)) 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));
.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"; return input + "\u001B[0m";
} }

View File

@ -78,8 +78,7 @@ public class Flag {
return false; return false;
} }
Flag other = (Flag) obj; Flag other = (Flag) obj;
return (this.key.getKey().equals(other.key.getKey()) && this.value return (this.key.getKey().equals(other.key.getKey()) && this.value.equals(other.value));
.equals(other.value));
} }
@Override @Override

View File

@ -85,7 +85,8 @@ public class FlagManager {
String[] split = flagstrings.get(i).split(";"); String[] split = flagstrings.get(i).split(";");
if (split.length == 1) { if (split.length == 1) {
flags[i] = new Flag(getFlag(split[0], true), ""); flags[i] = new Flag(getFlag(split[0], true), "");
} else { }
else {
flags[i] = new Flag(getFlag(split[0], true), split[1]); flags[i] = new Flag(getFlag(split[0], true), split[1]);
} }
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = LSetCube.java * >> File = LSetCube.java >> Generated by: Citymonstret at 2014-08-09 01:43
* >> Generated by: Citymonstret at 2014-08-09 01:43
*/ */
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
@ -15,7 +14,6 @@ import org.bukkit.Location;
* Cube utilities * Cube utilities
* *
* @author Citymonstret * @author Citymonstret
*
*/ */
public class LSetCube { public class LSetCube {
@ -97,7 +95,6 @@ public class LSetCube {
private Location current; private Location current;
/** /**
*
* @param cube * @param cube
*/ */
public LCycler(LSetCube cube) { public LCycler(LSetCube cube) {
@ -107,7 +104,6 @@ public class LSetCube {
} }
/** /**
*
* @return * @return
*/ */
public boolean hasNext() { public boolean hasNext() {
@ -117,7 +113,6 @@ public class LSetCube {
} }
/** /**
*
* @return * @return
*/ */
public Location getNext() { public Location getNext() {

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Lag.java * >> File = Lag.java >> Generated by: Citymonstret at 2014-08-09 01:43
* >> Generated by: Citymonstret at 2014-08-09 01:43
*/ */
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
@ -13,7 +12,6 @@ package com.intellectualcrafters.plot;
* TPS and Lag Checker. * TPS and Lag Checker.
* *
* @author Citymonstret * @author Citymonstret
*
*/ */
public class Lag implements Runnable { public class Lag implements Runnable {
@ -37,8 +35,7 @@ public class Lag implements Runnable {
* @return server tick per second * @return server tick per second
*/ */
public static double getTPS() { public static double getTPS() {
return Math.round(getTPS(100)) > 20.0D ? 20.0D : Math return Math.round(getTPS(100)) > 20.0D ? 20.0D : Math.round(getTPS(100));
.round(getTPS(100));
} }
/** /**

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Logger.java * >> File = Logger.java >> Generated by: Citymonstret at 2014-08-09 01:43
* >> Generated by: Citymonstret at 2014-08-09 01:43
*/ */
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
@ -21,7 +20,6 @@ import java.util.Date;
* Logging of errors and debug messages. * Logging of errors and debug messages.
* *
* @author Citymonstret * @author Citymonstret
*
*/ */
public class Logger { public class Logger {
@ -38,14 +36,16 @@ public class Logger {
entries.add(line); entries.add(line);
} }
reader.close(); reader.close();
} catch (IOException e) { }
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() catch (IOException e) {
+ "File setup error Logger#setup"); PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "File setup error Logger#setup");
} }
} }
public enum LogLevel { public enum LogLevel {
GENERAL("General"), WARNING("Warning"), DANGER("Danger"); GENERAL("General"),
WARNING("Warning"),
DANGER("Danger");
private String name; private String name;
LogLevel(String name) { LogLevel(String name) {

View File

@ -2,30 +2,31 @@ package com.intellectualcrafters.plot;
/* /*
* Copyright 2011-2013 Tyler Blair. All rights reserved. * Copyright 2011-2013 Tyler Blair. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without
* permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice,
* conditions and the following disclaimer. * this list of conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 2. Redistributions in binary form must reproduce the above copyright notice,
* of conditions and the following disclaimer in the documentation and/or other materials * this list of conditions and the following disclaimer in the documentation
* provided with the distribution. * and/or other materials provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED * 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 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * 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, * The views and conclusions contained in the software and documentation are
* either expressed or implied, of anybody else. * 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; import java.io.BufferedReader;
@ -79,8 +80,7 @@ public class Metrics {
/** /**
* All of the custom graphs to submit to metrics * All of the custom graphs to submit to metrics
*/ */
private final Set<Graph> graphs = Collections private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
.synchronizedSet(new HashSet<Graph>());
/** /**
* The plugin configuration file * The plugin configuration file
*/ */
@ -113,16 +113,14 @@ public class Metrics {
this.plugin = plugin; this.plugin = plugin;
// load the config // load the config
this.configurationFile = getConfigFile(); this.configurationFile = getConfigFile();
this.configuration = YamlConfiguration this.configuration = YamlConfiguration.loadConfiguration(this.configurationFile);
.loadConfiguration(this.configurationFile);
// add some defaults // add some defaults
this.configuration.addDefault("opt-out", false); this.configuration.addDefault("opt-out", false);
this.configuration.addDefault("guid", UUID.randomUUID().toString()); this.configuration.addDefault("guid", UUID.randomUUID().toString());
this.configuration.addDefault("debug", false); this.configuration.addDefault("debug", false);
// Do we need to create the file? // Do we need to create the file?
if (this.configuration.get("guid", null) == null) { if (this.configuration.get("guid", null) == null) {
this.configuration.options().header("http://mcstats.org") this.configuration.options().header("http://mcstats.org").copyDefaults(true);
.copyDefaults(true);
this.configuration.save(this.configurationFile); this.configuration.save(this.configurationFile);
} }
// Load the guid then // Load the guid then
@ -185,52 +183,50 @@ public class Metrics {
return true; return true;
} }
// Begin hitting the server with glorious data // Begin hitting the server with glorious data
this.task = this.plugin.getServer().getScheduler() this.task = this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, new Runnable() {
.runTaskTimerAsynchronously(this.plugin, new Runnable() { private boolean firstPost = true;
private boolean firstPost = true;
@Override @Override
public void run() { public void run() {
try { try {
// This has to be synchronized or it can collide // This has to be synchronized or it can collide
// with // with
// the disable method. // the disable method.
synchronized (Metrics.this.optOutLock) { synchronized (Metrics.this.optOutLock) {
// Disable Task, if it is running and the // Disable Task, if it is running and the
// server // server
// owner decided to opt-out // owner decided to opt-out
if (isOptOut() if (isOptOut() && (Metrics.this.task != null)) {
&& (Metrics.this.task != null)) { Metrics.this.task.cancel();
Metrics.this.task.cancel(); Metrics.this.task = null;
Metrics.this.task = null; // Tell all plotters to stop gathering
// Tell all plotters to stop gathering // information.
// information. for (Graph graph : Metrics.this.graphs) {
for (Graph graph : Metrics.this.graphs) { graph.onOptOut();
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());
} }
} }
} }
}, 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; return true;
} }
} }
@ -245,16 +241,16 @@ public class Metrics {
try { try {
// Reload the metrics file // Reload the metrics file
this.configuration.load(getConfigFile()); this.configuration.load(getConfigFile());
} catch (IOException ex) { }
catch (IOException ex) {
if (this.debug) { if (this.debug) {
Bukkit.getLogger().log(Level.INFO, Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
"[Metrics] " + ex.getMessage());
} }
return true; return true;
} catch (InvalidConfigurationException ex) { }
catch (InvalidConfigurationException ex) {
if (this.debug) { if (this.debug) {
Bukkit.getLogger().log(Level.INFO, Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
"[Metrics] " + ex.getMessage());
} }
return true; return true;
} }
@ -335,10 +331,10 @@ public class Metrics {
PluginDescriptionFile description = this.plugin.getDescription(); PluginDescriptionFile description = this.plugin.getDescription();
String pluginName = description.getName(); String pluginName = description.getName();
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if
// online // online
// mode // mode
// is // is
// enabled // enabled
String pluginVersion = description.getVersion(); String pluginVersion = description.getVersion();
String serverVersion = Bukkit.getVersion(); String serverVersion = Bukkit.getVersion();
int playersOnline = Bukkit.getServer().getOnlinePlayers().length; int playersOnline = Bukkit.getServer().getOnlinePlayers().length;
@ -388,8 +384,7 @@ public class Metrics {
StringBuilder graphJson = new StringBuilder(); StringBuilder graphJson = new StringBuilder();
graphJson.append('{'); graphJson.append('{');
for (Plotter plotter : graph.getPlotters()) { for (Plotter plotter : graph.getPlotters()) {
appendJSONPair(graphJson, plotter.getColumnName(), appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue()));
Integer.toString(plotter.getValue()));
} }
graphJson.append('}'); graphJson.append('}');
if (!firstGraph) { if (!firstGraph) {
@ -406,15 +401,15 @@ public class Metrics {
// close json // close json
json.append('}'); json.append('}');
// Create the url // Create the url
URL url = new URL(BASE_URL URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName)));
+ String.format(REPORT_URL, urlEncode(pluginName)));
// Connect to the website // Connect to the website
URLConnection connection; URLConnection connection;
// Mineshafter creates a socks proxy, so we can safely bypass it // Mineshafter creates a socks proxy, so we can safely bypass it
// It does not reroute POST requests so we need to go around it // It does not reroute POST requests so we need to go around it
if (isMineshafterPresent()) { if (isMineshafterPresent()) {
connection = url.openConnection(Proxy.NO_PROXY); connection = url.openConnection(Proxy.NO_PROXY);
} else { }
else {
connection = url.openConnection(); connection = url.openConnection();
} }
byte[] uncompressed = json.toString().getBytes(); byte[] uncompressed = json.toString().getBytes();
@ -423,40 +418,37 @@ public class Metrics {
connection.addRequestProperty("User-Agent", "MCStats/" + REVISION); connection.addRequestProperty("User-Agent", "MCStats/" + REVISION);
connection.addRequestProperty("Content-Type", "application/json"); connection.addRequestProperty("Content-Type", "application/json");
connection.addRequestProperty("Content-Encoding", "gzip"); connection.addRequestProperty("Content-Encoding", "gzip");
connection.addRequestProperty("Content-Length", connection.addRequestProperty("Content-Length", Integer.toString(compressed.length));
Integer.toString(compressed.length));
connection.addRequestProperty("Accept", "application/json"); connection.addRequestProperty("Accept", "application/json");
connection.addRequestProperty("Connection", "close"); connection.addRequestProperty("Connection", "close");
connection.setDoOutput(true); connection.setDoOutput(true);
if (this.debug) { if (this.debug) {
System.out.println("[Metrics] Prepared request for " + pluginName System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length
+ " uncompressed=" + uncompressed.length + " compressed=" + " compressed=" + compressed.length);
+ compressed.length);
} }
// Write the data // Write the data
OutputStream os = connection.getOutputStream(); OutputStream os = connection.getOutputStream();
os.write(compressed); os.write(compressed);
os.flush(); os.flush();
// Now read the response // Now read the response
final BufferedReader reader = new BufferedReader(new InputStreamReader( final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
connection.getInputStream()));
String response = reader.readLine(); String response = reader.readLine();
// close resources // close resources
os.close(); os.close();
reader.close(); reader.close();
if ((response == null) || response.startsWith("ERR") if ((response == null) || response.startsWith("ERR") || response.startsWith("7")) {
|| response.startsWith("7")) {
if (response == null) { if (response == null) {
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); throw new IOException(response);
} else { }
else {
// Is this the first update this hour? // Is this the first update this hour?
if (response.equals("1") if (response.equals("1") || response.contains("This is your first update this hour")) {
|| response.contains("This is your first update this hour")) {
synchronized (this.graphs) { synchronized (this.graphs) {
final Iterator<Graph> iter = this.graphs.iterator(); final Iterator<Graph> iter = this.graphs.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
@ -482,13 +474,16 @@ public class Metrics {
try { try {
gzos = new GZIPOutputStream(baos); gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8")); gzos.write(input.getBytes("UTF-8"));
} catch (IOException e) { }
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally { }
finally {
if (gzos != null) { if (gzos != null) {
try { try {
gzos.close(); gzos.close();
} catch (IOException ignore) { }
catch (IOException ignore) {
} }
} }
} }
@ -505,7 +500,8 @@ public class Metrics {
try { try {
Class.forName("mineshafter.MineServer"); Class.forName("mineshafter.MineServer");
return true; return true;
} catch (Exception e) { }
catch (Exception e) {
return false; return false;
} }
} }
@ -518,15 +514,15 @@ public class Metrics {
* @param value * @param value
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
*/ */
private static void appendJSONPair(StringBuilder json, String key, private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false; boolean isValueNumeric = false;
try { try {
if (value.equals("0") || !value.endsWith("0")) { if (value.equals("0") || !value.endsWith("0")) {
Double.parseDouble(value); Double.parseDouble(value);
isValueNumeric = true; isValueNumeric = true;
} }
} catch (NumberFormatException e) { }
catch (NumberFormatException e) {
isValueNumeric = false; isValueNumeric = false;
} }
if (json.charAt(json.length() - 1) != '{') { if (json.charAt(json.length() - 1) != '{') {
@ -536,7 +532,8 @@ public class Metrics {
json.append(':'); json.append(':');
if (isValueNumeric) { if (isValueNumeric) {
json.append(value); json.append(value);
} else { }
else {
json.append(escapeJSON(value)); json.append(escapeJSON(value));
} }
} }
@ -574,7 +571,8 @@ public class Metrics {
if (chr < ' ') { if (chr < ' ') {
String t = "000" + Integer.toHexString(chr); String t = "000" + Integer.toHexString(chr);
builder.append("\\u" + t.substring(t.length() - 4)); builder.append("\\u" + t.substring(t.length() - 4));
} else { }
else {
builder.append(chr); builder.append(chr);
} }
break; break;
@ -591,8 +589,7 @@ public class Metrics {
* the text to encode * the text to encode
* @return the encoded text, as UTF-8 * @return the encoded text, as UTF-8
*/ */
private static String urlEncode(final String text) private static String urlEncode(final String text) throws UnsupportedEncodingException {
throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8"); return URLEncoder.encode(text, "UTF-8");
} }
@ -738,8 +735,7 @@ public class Metrics {
return false; return false;
} }
final Plotter plotter = (Plotter) object; final Plotter plotter = (Plotter) object;
return plotter.name.equals(this.name) return plotter.name.equals(this.name) && (plotter.getValue() == getValue());
&& (plotter.getValue() == getValue());
} }
} }
} }

View File

@ -13,9 +13,7 @@ import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
/** /**
*
* @author Citymonstret * @author Citymonstret
*
*/ */
public class PWE { public class PWE {
@ -24,7 +22,8 @@ public class PWE {
LocalSession s; LocalSession s;
if (PlotMain.worldEdit == null) { if (PlotMain.worldEdit == null) {
s = WorldEdit.getInstance().getSession(p.getName()); s = WorldEdit.getInstance().getSession(p.getName());
} else { }
else {
s = PlotMain.worldEdit.getSession(p); s = PlotMain.worldEdit.getSession(p);
} }
@ -33,33 +32,29 @@ public class PWE {
Plot plot = PlotMain.getPlots(l.getWorld()).get(id); Plot plot = PlotMain.getPlots(l.getWorld()).get(id);
if (plot != null) { if (plot != null) {
boolean r; boolean r;
r = (plot.getOwner() != null) r =
&& plot.getOwner().equals(p.getUniqueId()) (plot.getOwner() != null) && plot.getOwner().equals(p.getUniqueId())
|| plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId());
|| plot.helpers.contains(p.getUniqueId());
if (!r) { if (!r) {
if (p.hasPermission("plots.worldedit.bypass")) { if (p.hasPermission("plots.worldedit.bypass")) {
removeMask(p, s); removeMask(p, s);
return; return;
} }
} else { }
else {
World w = p.getWorld(); World w = p.getWorld();
Location bloc = PlotHelper.getPlotBottomLoc(w, plot.id); Location bloc = PlotHelper.getPlotBottomLoc(w, plot.id);
Location tloc = PlotHelper.getPlotTopLoc(w, plot.id); Location tloc = PlotHelper.getPlotTopLoc(w, plot.id);
Vector bvec = new Vector(bloc.getBlockX() + 1, Vector bvec = new Vector(bloc.getBlockX() + 1, bloc.getBlockY() + 1, bloc.getBlockZ() + 1);
bloc.getBlockY() + 1, bloc.getBlockZ() + 1); Vector tvec = new Vector(tloc.getBlockX(), tloc.getBlockY(), tloc.getBlockZ());
Vector tvec = new Vector(tloc.getBlockX(),
tloc.getBlockY(), tloc.getBlockZ());
LocalWorld lw = PlotMain.worldEdit.wrapPlayer(p) LocalWorld lw = PlotMain.worldEdit.wrapPlayer(p).getWorld();
.getWorld();
CuboidRegion region = new CuboidRegion(lw, bvec, tvec); CuboidRegion region = new CuboidRegion(lw, bvec, tvec);
com.sk89q.worldedit.masks.RegionMask mask = new com.sk89q.worldedit.masks.RegionMask( com.sk89q.worldedit.masks.RegionMask mask = new com.sk89q.worldedit.masks.RegionMask(region);
region);
s.setMask(mask); s.setMask(mask);
return; return;
@ -70,10 +65,10 @@ public class PWE {
BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p); BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p);
Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69); Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69);
s.setMask(new com.sk89q.worldedit.masks.RegionMask( s.setMask(new com.sk89q.worldedit.masks.RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
new CuboidRegion(plr.getWorld(), p1, p2)));
} }
} catch (Exception e) { }
catch (Exception e) {
// throw new // throw new
// PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, // PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY,
// "WorldEdit == Null?"); // "WorldEdit == Null?");
@ -84,7 +79,8 @@ public class PWE {
try { try {
com.sk89q.worldedit.masks.Mask mask = s.getMask(); com.sk89q.worldedit.masks.Mask mask = s.getMask();
return mask == null; return mask == null;
} catch (Throwable e) { }
catch (Throwable e) {
return true; return true;
} }
} }
@ -92,7 +88,8 @@ public class PWE {
public static void removeMask(Player p, LocalSession s) { public static void removeMask(Player p, LocalSession s) {
try { try {
s.setMask(null); s.setMask(null);
} catch (Throwable e) { }
catch (Throwable e) {
com.sk89q.worldedit.masks.Mask mask = null; com.sk89q.worldedit.masks.Mask mask = null;
s.setMask(mask); s.setMask(mask);
} }
@ -103,11 +100,13 @@ public class PWE {
LocalSession s; LocalSession s;
if (PlotMain.worldEdit == null) { if (PlotMain.worldEdit == null) {
s = WorldEdit.getInstance().getSession(p.getName()); s = WorldEdit.getInstance().getSession(p.getName());
} else { }
else {
s = PlotMain.worldEdit.getSession(p); s = PlotMain.worldEdit.getSession(p);
} }
removeMask(p, s); removeMask(p, s);
} catch (Exception e) { }
catch (Exception e) {
// throw new // throw new
// PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, // PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY,
// "WorldEdit == Null?"); // "WorldEdit == Null?");

View File

@ -1,10 +1,10 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlayerFunctions.java * >> File = PlayerFunctions.java >> Generated by: Citymonstret at 2014-08-09
* >> Generated by: Citymonstret at 2014-08-09 01:43 * 01:43
*/ */
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
@ -28,13 +28,11 @@ import org.bukkit.entity.Player;
* Functions involving players, plots and locations. * Functions involving players, plots and locations.
* *
* @author Citymonstret * @author Citymonstret
*
*/ */
@SuppressWarnings("javadoc") @SuppressWarnings("javadoc")
public class PlayerFunctions { public class PlayerFunctions {
/** /**
*
* @param player * @param player
* player * player
* @return * @return
@ -44,7 +42,6 @@ public class PlayerFunctions {
} }
/** /**
*
* @param plot * @param plot
* plot * plot
* @return * @return
@ -56,8 +53,7 @@ public class PlayerFunctions {
return (lp - cu) > 30l; return (lp - cu) > 30l;
} }
public static ArrayList<PlotId> getPlotSelectionIds(World world, public static ArrayList<PlotId> getPlotSelectionIds(World world, PlotId pos1, PlotId pos2) {
PlotId pos1, PlotId pos2) {
ArrayList<PlotId> myplots = new ArrayList<PlotId>(); ArrayList<PlotId> myplots = new ArrayList<PlotId>();
for (int x = pos1.x; x <= pos2.x; x++) { for (int x = pos1.x; x <= pos2.x; x++) {
for (int y = pos1.y; y <= pos2.y; y++) { for (int y = pos1.y; y <= pos2.y; y++) {
@ -70,38 +66,25 @@ public class PlayerFunctions {
public static Plot getBottomPlot(World world, Plot plot) { public static Plot getBottomPlot(World world, Plot plot) {
if (plot.settings.getMerged(0)) { if (plot.settings.getMerged(0)) {
return getBottomPlot( return getBottomPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y - 1)));
world,
PlotMain.getPlots(world).get(
new PlotId(plot.id.x, plot.id.y - 1)));
} }
if (plot.settings.getMerged(3)) { if (plot.settings.getMerged(3)) {
return getBottomPlot( return getBottomPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x - 1, plot.id.y)));
world,
PlotMain.getPlots(world).get(
new PlotId(plot.id.x - 1, plot.id.y)));
} }
return plot; return plot;
} }
public static Plot getTopPlot(World world, Plot plot) { public static Plot getTopPlot(World world, Plot plot) {
if (plot.settings.getMerged(2)) { if (plot.settings.getMerged(2)) {
return getTopPlot( return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1)));
world,
PlotMain.getPlots(world).get(
new PlotId(plot.id.x, plot.id.y + 1)));
} }
if (plot.settings.getMerged(1)) { if (plot.settings.getMerged(1)) {
return getTopPlot( return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x + 1, plot.id.y)));
world,
PlotMain.getPlots(world).get(
new PlotId(plot.id.x + 1, plot.id.y)));
} }
return plot; return plot;
} }
/** /**
*
* @param loc * @param loc
* @return * @return
*/ */
@ -126,17 +109,14 @@ public class PlayerFunctions {
} }
/** /**
*
* @param player * @param player
* @param plot * @param plot
*/ */
public static void togglePlotWeather(Player player, Plot plot) { public static void togglePlotWeather(Player player, Plot plot) {
player.setPlayerWeather(plot.settings.getRain() ? WeatherType.DOWNFALL player.setPlayerWeather(plot.settings.getRain() ? WeatherType.DOWNFALL : WeatherType.CLEAR);
: WeatherType.CLEAR);
} }
/** /**
*
* @param player * @param player
* @param plot * @param plot
*/ */
@ -145,7 +125,6 @@ public class PlayerFunctions {
} }
/** /**
*
* @param player * @param player
* @return * @return
*/ */
@ -164,8 +143,7 @@ public class PlayerFunctions {
return plots.get(id); return plots.get(id);
} }
} }
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), world.getName());
new ArrayList<UUID>(), world.getName());
} }
@ -180,7 +158,6 @@ public class PlayerFunctions {
} }
/** /**
*
* @param plr * @param plr
* @return * @return
*/ */
@ -197,7 +174,6 @@ public class PlayerFunctions {
} }
/** /**
*
* @param plr * @param plr
* @return * @return
*/ */
@ -210,7 +186,6 @@ public class PlayerFunctions {
} }
/** /**
*
* @param p * @param p
* @return * @return
*/ */
@ -220,7 +195,6 @@ public class PlayerFunctions {
} }
/** /**
*
* @return PlotMain.getPlots(); * @return PlotMain.getPlots();
* @deprecated * @deprecated
*/ */
@ -252,8 +226,7 @@ public class PlayerFunctions {
if ((msg.length() == 0) || msg.equalsIgnoreCase("")) { if ((msg.length() == 0) || msg.equalsIgnoreCase("")) {
return; return;
} }
sendMessageWrapped(plr, sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg));
ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg));
} }
/** /**

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Plot.java * >> File = Plot.java >> Generated by: Citymonstret at 2014-08-09 01:43
* >> Generated by: Citymonstret at 2014-08-09 01:43
*/ */
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
@ -23,7 +22,6 @@ import com.intellectualcrafters.plot.database.DBFunc;
* The plot class * The plot class
* *
* @author Citymonstret * @author Citymonstret
*
*/ */
@SuppressWarnings("javadoc") @SuppressWarnings("javadoc")
public class Plot implements Cloneable { public class Plot implements Cloneable {
@ -78,8 +76,7 @@ public class Plot implements Cloneable {
* @param helpers * @param helpers
* @param denied * @param denied
*/ */
public Plot(PlotId id, UUID owner, Biome plotBiome, public Plot(PlotId id, UUID owner, Biome plotBiome, ArrayList<UUID> helpers, ArrayList<UUID> denied, String world) {
ArrayList<UUID> helpers, ArrayList<UUID> denied, String world) {
this.id = id; this.id = id;
this.settings = new PlotSettings(this); this.settings = new PlotSettings(this);
this.settings.setBiome(plotBiome); this.settings.setBiome(plotBiome);
@ -110,11 +107,9 @@ public class Plot implements Cloneable {
* @param time * @param time
* @param merged * @param merged
*/ */
public Plot(PlotId id, UUID owner, Biome plotBiome, public Plot(PlotId id, UUID owner, Biome plotBiome, ArrayList<UUID> helpers, ArrayList<UUID> trusted,
ArrayList<UUID> helpers, ArrayList<UUID> trusted, ArrayList<UUID> denied, boolean changeTime, long time, boolean rain, String alias,
ArrayList<UUID> denied, boolean changeTime, long time, PlotHomePosition position, Flag[] flags, String world, boolean[] merged) {
boolean rain, String alias, PlotHomePosition position,
Flag[] flags, String world, boolean[] merged) {
this.id = id; this.id = id;
this.settings = new PlotSettings(this); this.settings = new PlotSettings(this);
this.settings.setBiome(plotBiome); this.settings.setBiome(plotBiome);
@ -132,7 +127,8 @@ public class Plot implements Cloneable {
this.delete = false; this.delete = false;
if (flags != null) { if (flags != null) {
this.settings.setFlags(flags); this.settings.setFlags(flags);
} else { }
else {
this.settings.setFlags(new Flag[0]); this.settings.setFlags(new Flag[0]);
} }
this.world = world; this.world = world;
@ -164,16 +160,10 @@ public class Plot implements Cloneable {
*/ */
public boolean hasRights(Player player) { public boolean hasRights(Player player) {
return player.hasPermission("plots.admin") return player.hasPermission("plots.admin")
|| ((this.helpers != null) && this.helpers || ((this.helpers != null) && this.helpers.contains(DBFunc.everyone))
.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(player.getUniqueId()))
|| ((this.helpers != null) && this.helpers.contains(player || ((this.owner != null) && this.owner.equals(player.getUniqueId()))
.getUniqueId())) || ((this.owner != null) && (this.trusted != null) && (Bukkit.getPlayer(this.owner) != null) && (this.trusted.contains(player.getUniqueId()) || this.trusted.contains(DBFunc.everyone)));
|| ((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) { public boolean deny_entry(Player player) {
return (this.denied != null) return (this.denied != null)
&& ((this.denied.contains(DBFunc.everyone) && !this && ((this.denied.contains(DBFunc.everyone) && !this.hasRights(player)) || (!this.hasRights(player) && this.denied.contains(player.getUniqueId())));
.hasRights(player)) || (!this.hasRights(player) && this.denied
.contains(player.getUniqueId())));
} }
/** /**
* Get the UUID of the owner * Get the UUID of the owner
*
*/ */
public UUID getOwner() { public UUID getOwner() {
return this.owner; return this.owner;
@ -199,7 +186,6 @@ public class Plot implements Cloneable {
/** /**
* Get the plot ID * Get the plot ID
*
*/ */
public PlotId getId() { public PlotId getId() {
return this.id; return this.id;
@ -207,7 +193,6 @@ public class Plot implements Cloneable {
/** /**
* Get the plot World * Get the plot World
*
*/ */
public World getWorld() { public World getWorld() {
return Bukkit.getWorld(this.world); return Bukkit.getWorld(this.world);
@ -222,7 +207,8 @@ public class Plot implements Cloneable {
public Object clone() throws CloneNotSupportedException { public Object clone() throws CloneNotSupportedException {
try { try {
return super.clone(); return super.clone();
} catch (CloneNotSupportedException e) { }
catch (CloneNotSupportedException e) {
return null; return null;
} }
} }

View File

@ -3,10 +3,10 @@ package com.intellectualcrafters.plot;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
public abstract class PlotGenerator extends ChunkGenerator { public abstract class PlotGenerator extends ChunkGenerator {
public PlotGenerator(String world) { public PlotGenerator(String world) {
PlotMain.loadWorld(world, this); PlotMain.loadWorld(world, this);
} }
public abstract PlotWorld getNewPlotWorld(String world); public abstract PlotWorld getNewPlotWorld(String world);

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlotHelper.java * >> File = PlotHelper.java >> Generated by: Citymonstret at 2014-08-09 01:43
* >> Generated by: Citymonstret at 2014-08-09 01:43
*/ */
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
@ -35,7 +34,6 @@ import com.intellectualcrafters.plot.database.DBFunc;
* plot functions * plot functions
* *
* @author Citymonstret * @author Citymonstret
*
*/ */
public class PlotHelper { public class PlotHelper {
public static boolean canSetFast = false; public static boolean canSetFast = false;
@ -62,16 +60,14 @@ public class PlotHelper {
return id; return id;
} }
public static boolean mergePlots(Player plr, World world, public static boolean mergePlots(Player plr, World world, ArrayList<PlotId> plotIds) {
ArrayList<PlotId> plotIds) {
PlotWorld plotworld = PlotMain.getWorldSettings(world); PlotWorld plotworld = PlotMain.getWorldSettings(world);
if (PlotMain.useEconomy && plotworld.USE_ECONOMY) { if (PlotMain.useEconomy && plotworld.USE_ECONOMY) {
double cost = plotIds.size() * plotworld.MERGE_PRICE; double cost = plotIds.size() * plotworld.MERGE_PRICE;
if (cost > 0d) { if (cost > 0d) {
Economy economy = PlotMain.economy; Economy economy = PlotMain.economy;
if (economy.getBalance(plr) < cost) { if (economy.getBalance(plr) < cost) {
PlayerFunctions.sendMessage(plr, C.CANNOT_AFFORD_MERGE, "" PlayerFunctions.sendMessage(plr, C.CANNOT_AFFORD_MERGE, "" + cost);
+ cost);
return false; return false;
} }
economy.withdrawPlayer(plr, cost); economy.withdrawPlayer(plr, cost);
@ -116,14 +112,12 @@ public class PlotHelper {
if (lx) { if (lx) {
if (ly) { if (ly) {
if (!plot.settings.getMerged(1) if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) {
|| !plot.settings.getMerged(2)) {
manager.removeRoadSouthEast(plotworld, plot); manager.removeRoadSouthEast(plotworld, plot);
} }
} }
if (!plot.settings.getMerged(1)) { if (!plot.settings.getMerged(1)) {
Plot plot2 = PlotMain.getPlots(world).get( Plot plot2 = PlotMain.getPlots(world).get(new PlotId(x + 1, y));
new PlotId(x + 1, y));
mergePlot(world, plot, plot2); mergePlot(world, plot, plot2);
plot.settings.setMerged(1, true); plot.settings.setMerged(1, true);
plot2.settings.setMerged(3, true); plot2.settings.setMerged(3, true);
@ -131,8 +125,7 @@ public class PlotHelper {
} }
if (ly) { if (ly) {
if (!plot.settings.getMerged(2)) { if (!plot.settings.getMerged(2)) {
Plot plot2 = PlotMain.getPlots(world).get( Plot plot2 = PlotMain.getPlots(world).get(new PlotId(x, y + 1));
new PlotId(x, y + 1));
mergePlot(world, plot, plot2); mergePlot(world, plot, plot2);
plot.settings.setMerged(2, true); plot.settings.setMerged(2, true);
plot2.settings.setMerged(0, true); plot2.settings.setMerged(0, true);
@ -167,7 +160,8 @@ public class PlotHelper {
greaterPlot.settings.setMerged(0, true); greaterPlot.settings.setMerged(0, true);
manager.removeRoadSouth(plotworld, lesserPlot); manager.removeRoadSouth(plotworld, lesserPlot);
} }
} else { }
else {
if (!lesserPlot.settings.getMerged(1)) { if (!lesserPlot.settings.getMerged(1)) {
lesserPlot.settings.setMerged(1, true); lesserPlot.settings.setMerged(1, true);
greaterPlot.settings.setMerged(3, true); greaterPlot.settings.setMerged(3, true);
@ -217,12 +211,9 @@ public class PlotHelper {
String id = p.id.y + ";" + p.id.x; String id = p.id.y + ";" + p.id.x;
Sign sign = (Sign) bs.getState(); Sign sign = (Sign) bs.getState();
sign.setLine(0, C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id)); sign.setLine(0, C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id));
sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id) sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName()));
.replaceAll("%plr%", plr.getName())); sign.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName()));
sign.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id) sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName()));
.replaceAll("%plr%", plr.getName()));
sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id)
.replaceAll("%plr%", plr.getName()));
sign.update(true); sign.update(true);
} }
@ -247,14 +238,12 @@ public class PlotHelper {
public static void setBlock(Block block, PlotBlock plotblock) { public static void setBlock(Block block, PlotBlock plotblock) {
if (canSetFast) { if (canSetFast) {
if (block.getTypeId() != plotblock.id if (block.getTypeId() != plotblock.id && plotblock.data != block.getData()) {
&& plotblock.data != block.getData()) {
try { try {
SetBlockFast.set(block.getWorld(), block.getX(), SetBlockFast.set(block.getWorld(), block.getX(), block.getY(), block.getZ(), plotblock.id, plotblock.data);
block.getY(), block.getZ(), plotblock.id,
plotblock.data);
return; return;
} catch (NoSuchMethodException e) { }
catch (NoSuchMethodException e) {
canSetFast = false; canSetFast = false;
} }
} }
@ -263,10 +252,12 @@ public class PlotHelper {
if (block.getTypeId() != plotblock.id) { if (block.getTypeId() != plotblock.id) {
block.setTypeId(plotblock.id); block.setTypeId(plotblock.id);
} }
} else { }
else {
if (block.getTypeId() == plotblock.id) { if (block.getTypeId() == plotblock.id) {
block.setData(plotblock.data); block.setData(plotblock.data);
} else { }
else {
block.setTypeIdAndData(plotblock.id, plotblock.data, false); block.setTypeIdAndData(plotblock.id, plotblock.data, false);
} }
} }
@ -297,29 +288,25 @@ public class PlotHelper {
PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id; PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id;
PlotId top = PlayerFunctions.getTopPlot(world, plot).id; PlotId top = PlayerFunctions.getTopPlot(world, plot).id;
merge = false; merge = false;
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId( plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
bot.x, bot.y - 1), new PlotId(top.x, top.y));
if (ownsPlots(world, plots, player, 0)) { if (ownsPlots(world, plots, player, 0)) {
merge = true; merge = true;
mergePlots(world, plots); mergePlots(world, plots);
continue; continue;
} }
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId( plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
bot.x, bot.y), new PlotId(top.x + 1, top.y));
if (ownsPlots(world, plots, player, 1)) { if (ownsPlots(world, plots, player, 1)) {
merge = true; merge = true;
mergePlots(world, plots); mergePlots(world, plots);
continue; continue;
} }
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId( plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
bot.x, bot.y), new PlotId(top.x, top.y + 1));
if (ownsPlots(world, plots, player, 2)) { if (ownsPlots(world, plots, player, 2)) {
merge = true; merge = true;
mergePlots(world, plots); mergePlots(world, plots);
continue; continue;
} }
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId( plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
bot.x - 1, bot.y), new PlotId(top.x, top.y));
if (ownsPlots(world, plots, player, 3)) { if (ownsPlots(world, plots, player, 3)) {
merge = true; merge = true;
mergePlots(world, plots); mergePlots(world, plots);
@ -331,24 +318,20 @@ public class PlotHelper {
} }
} }
private static boolean ownsPlots(World world, ArrayList<PlotId> plots, private static boolean ownsPlots(World world, ArrayList<PlotId> plots, Player player, int dir) {
Player player, int dir) {
PlotId id_min = plots.get(0); PlotId id_min = plots.get(0);
PlotId id_max = plots.get(plots.size() - 1); PlotId id_max = plots.get(plots.size() - 1);
for (PlotId myid : plots) { for (PlotId myid : plots) {
Plot myplot = PlotMain.getPlots(world).get(myid); Plot myplot = PlotMain.getPlots(world).get(myid);
if ((myplot == null) || !myplot.hasOwner() if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(player.getUniqueId()))) {
|| !(myplot.getOwner().equals(player.getUniqueId()))) {
return false; return false;
} }
PlotId top = PlayerFunctions.getTopPlot(world, myplot).id; PlotId top = PlayerFunctions.getTopPlot(world, myplot).id;
if (((top.x > id_max.x) && (dir != 1)) if (((top.x > id_max.x) && (dir != 1)) || ((top.y > id_max.y) && (dir != 2))) {
|| ((top.y > id_max.y) && (dir != 2))) {
return false; return false;
} }
PlotId bot = PlayerFunctions.getBottomPlot(world, myplot).id; PlotId bot = PlayerFunctions.getBottomPlot(world, myplot).id;
if (((bot.x < id_min.x) && (dir != 3)) if (((bot.x < id_min.x) && (dir != 3)) || ((bot.y < id_min.y) && (dir != 0))) {
|| ((bot.y < id_min.y) && (dir != 0))) {
return false; return false;
} }
} }
@ -357,9 +340,8 @@ public class PlotHelper {
public static boolean createPlot(Player player, Plot plot) { public static boolean createPlot(Player player, Plot plot) {
World w = plot.getWorld(); World w = plot.getWorld();
Plot p = new Plot(plot.id, player.getUniqueId(), Plot p =
plot.settings.getBiome(), new ArrayList<UUID>(), new Plot(plot.id, player.getUniqueId(), plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
new ArrayList<UUID>(), w.getName());
PlotMain.updatePlot(p); PlotMain.updatePlot(p);
DBFunc.createPlot(p); DBFunc.createPlot(p);
DBFunc.createPlotSettings(DBFunc.getId(w.getName(), p.id), p); DBFunc.createPlotSettings(DBFunc.getId(w.getName(), p.id), p);
@ -558,8 +540,7 @@ public class PlotHelper {
public static ArrayList<String> runners_p = new ArrayList<String>(); public static ArrayList<String> runners_p = new ArrayList<String>();
public static HashMap<Plot, Integer> runners = new HashMap<Plot, Integer>(); public static HashMap<Plot, Integer> runners = new HashMap<Plot, Integer>();
public static void adjustWallFilling(final Player requester, public static void adjustWallFilling(final Player requester, final Plot plot, PlotBlock block) {
final Plot plot, PlotBlock block) {
if (runners.containsKey(plot)) { if (runners.containsKey(plot)) {
PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER); PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER);
return; return;
@ -573,8 +554,7 @@ public class PlotHelper {
PlayerFunctions.sendMessage(requester, C.SET_BLOCK_ACTION_FINISHED); PlayerFunctions.sendMessage(requester, C.SET_BLOCK_ACTION_FINISHED);
} }
public static void setFloor(final Player requester, final Plot plot, public static void setFloor(final Player requester, final Plot plot, PlotBlock[] blocks) {
PlotBlock[] blocks) {
if (runners.containsKey(plot)) { if (runners.containsKey(plot)) {
PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER); PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER);
return; return;
@ -595,8 +575,7 @@ public class PlotHelper {
public static short[] getBlock(String block) { public static short[] getBlock(String block) {
if (block.contains(":")) { if (block.contains(":")) {
String[] split = block.split(":"); String[] split = block.split(":");
return new short[] { Short.parseShort(split[0]), return new short[] { Short.parseShort(split[0]), Short.parseShort(split[1]) };
Short.parseShort(split[1]) };
} }
return new short[] { Short.parseShort(block), 0 }; 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 pos1 = getPlotBottomLoc(world, plot.id).add(1, 0, 1);
final Location pos2 = getPlotTopLoc(world, plot.id); final Location pos2 = getPlotTopLoc(world, plot.id);
for (int i = (pos1.getBlockX() / 16) * 16; i < (16 + ((pos2.getBlockX() / 16) * 16)); i += 16) { 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 for (int j = (pos1.getBlockZ() / 16) * 16; j < (16 + ((pos2.getBlockZ() / 16) * 16)); j += 16) {
.getBlockZ() / 16) * 16)); j += 16) {
Chunk chunk = world.getChunkAt(i, j); Chunk chunk = world.getChunkAt(i, j);
for (Entity entity : chunk.getEntities()) { for (Entity entity : chunk.getEntities()) {
PlotId id = PlayerFunctions.getPlot(entity.getLocation()); PlotId id = PlayerFunctions.getPlot(entity.getLocation());
if ((id != null) && id.equals(plot.id)) { if ((id != null) && id.equals(plot.id)) {
if (entity instanceof Player) { if (entity instanceof Player) {
PlotMain.teleportPlayer((Player) entity, PlotMain.teleportPlayer((Player) entity, entity.getLocation(), plot);
entity.getLocation(), plot); }
} else { else {
entity.remove(); entity.remove();
} }
} }
@ -650,8 +628,7 @@ public class PlotHelper {
clearAllEntities(world, plot, false); clearAllEntities(world, plot, false);
PlotManager manager = PlotMain.getPlotManager(world); PlotManager manager = PlotMain.getPlotManager(world);
Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id) Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
.add(1, 0, 1);
final int prime = 31; final int prime = 31;
int h = 1; int h = 1;
@ -667,10 +644,8 @@ public class PlotHelper {
removeSign(requester, plot); removeSign(requester, plot);
setSign(requester, plot); setSign(requester, plot);
PlayerFunctions.sendMessage( PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", ""
requester, + ((System.nanoTime() - start) / 1000000.0)));
C.CLEARING_DONE.s().replaceAll("%time%",
"" + ((System.nanoTime() - start) / 1000000.0)));
if (canSetFast) { if (canSetFast) {
refreshPlotChunks(world, plot); refreshPlotChunks(world, plot);
// SetBlockFast.update(requester); // SetBlockFast.update(requester);
@ -678,8 +653,7 @@ public class PlotHelper {
return; return;
} }
public static void setCuboid(World world, Location pos1, Location pos2, public static void setCuboid(World world, Location pos1, Location pos2, PlotBlock[] blocks) {
PlotBlock[] blocks) {
if (!canSetFast) { if (!canSetFast) {
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
@ -687,15 +661,14 @@ public class PlotHelper {
int i = random(blocks.length); int i = random(blocks.length);
PlotBlock newblock = blocks[i]; PlotBlock newblock = blocks[i];
Block block = world.getBlockAt(x, y, z); Block block = world.getBlockAt(x, y, z);
if (!((block.getTypeId() == newblock.id) && (block if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
.getData() == newblock.data))) { block.setTypeIdAndData(newblock.id, newblock.data, false);
block.setTypeIdAndData(newblock.id, newblock.data,
false);
} }
} }
} }
} }
} else { }
else {
try { try {
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
@ -703,21 +676,19 @@ public class PlotHelper {
int i = random(blocks.length); int i = random(blocks.length);
PlotBlock newblock = blocks[i]; PlotBlock newblock = blocks[i];
Block block = world.getBlockAt(x, y, z); Block block = world.getBlockAt(x, y, z);
if (!((block.getTypeId() == newblock.id) && (block if (!((block.getTypeId() == newblock.id) && (block.getData() == newblock.data))) {
.getData() == newblock.data))) { SetBlockFast.set(world, x, y, z, newblock.id, 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, public static void setSimpleCuboid(World world, Location pos1, Location pos2, PlotBlock newblock) {
Location pos2, PlotBlock newblock) {
if (!canSetFast) { if (!canSetFast) {
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
@ -729,20 +700,21 @@ public class PlotHelper {
} }
} }
} }
} else { }
else {
try { try {
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) { for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) { for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) { for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) {
Block block = world.getBlockAt(x, y, z); Block block = world.getBlockAt(x, y, z);
if (!((block.getTypeId() == newblock.id))) { if (!((block.getTypeId() == newblock.id))) {
SetBlockFast.set(world, x, y, z, newblock.id, SetBlockFast.set(world, x, y, z, newblock.id, (byte) 0);
(byte) 0);
} }
} }
} }
} }
} catch (Exception e) { }
catch (Exception e) {
} }
} }
@ -768,13 +740,14 @@ public class PlotHelper {
public static Location getPlotHome(World w, PlotId plotid) { public static Location getPlotHome(World w, PlotId plotid) {
PlotMain.getWorldSettings(w); PlotMain.getWorldSettings(w);
if (getPlot(w, plotid).settings.getPosition() == PlotHomePosition.DEFAULT) { if (getPlot(w, plotid).settings.getPosition() == PlotHomePosition.DEFAULT) {
int x = getPlotBottomLoc(w, plotid).getBlockX() int x =
+ (getPlotTopLoc(w, plotid).getBlockX() - getPlotBottomLoc( getPlotBottomLoc(w, plotid).getBlockX()
w, plotid).getBlockX()); + (getPlotTopLoc(w, plotid).getBlockX() - getPlotBottomLoc(w, plotid).getBlockX());
int z = getPlotBottomLoc(w, plotid).getBlockZ() - 2; int z = getPlotBottomLoc(w, plotid).getBlockZ() - 2;
int y = w.getHighestBlockYAt(x, z); int y = w.getHighestBlockYAt(x, z);
return new Location(w, x, y + 2, z); return new Location(w, x, y + 2, z);
} else { }
else {
World world = w; World world = w;
Location bot, top; Location bot, top;
@ -823,8 +796,7 @@ public class PlotHelper {
} }
public static int getPlotWidth(World world, PlotId id) { public static int getPlotWidth(World world, PlotId id) {
return getPlotTopLoc(world, id).getBlockX() return getPlotTopLoc(world, id).getBlockX() - getPlotBottomLoc(world, id).getBlockX();
- getPlotBottomLoc(world, id).getBlockX();
} }
public static Location getPlotTopLoc(World world, PlotId id) { public static Location getPlotTopLoc(World world, PlotId id) {
@ -854,8 +826,7 @@ public class PlotHelper {
if (PlotMain.getPlots(world).containsKey(id)) { if (PlotMain.getPlots(world).containsKey(id)) {
return PlotMain.getPlots(world).get(id); return PlotMain.getPlots(world).get(id);
} }
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), world.getName());
new ArrayList<UUID>(), world.getName());
} }
public static Plot getCurrentPlot(Location loc) { public static Plot getCurrentPlot(Location loc) {
@ -866,7 +837,6 @@ public class PlotHelper {
if (PlotMain.getPlots(loc.getWorld()).containsKey(id)) { if (PlotMain.getPlots(loc.getWorld()).containsKey(id)) {
return PlotMain.getPlots(loc.getWorld()).get(id); return PlotMain.getPlots(loc.getWorld()).get(id);
} }
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), loc.getWorld().getName());
new ArrayList<UUID>(), loc.getWorld().getName());
} }
} }

View File

@ -1,10 +1,10 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlotHomePosition.java * >> File = PlotHomePosition.java >> Generated by: Citymonstret at 2014-08-09
* >> Generated by: Citymonstret at 2014-08-09 01:44 * 01:44
*/ */
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
@ -13,7 +13,8 @@ package com.intellectualcrafters.plot;
* Created by Citymonstret on 2014-08-05. * Created by Citymonstret on 2014-08-05.
*/ */
public enum PlotHomePosition { public enum PlotHomePosition {
CENTER("Center", 'c'), DEFAULT("Default", 'd'); CENTER("Center", 'c'),
DEFAULT("Default", 'd');
private String string; private String string;
private char ch; private char ch;

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Main.java * >> File = Main.java >> Generated by: Citymonstret at 2014-08-09 01:43
* >> Generated by: Citymonstret at 2014-08-09 01:43
*/ */
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
@ -125,13 +124,12 @@ public class PlotMain extends JavaPlugin {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void checkForExpiredPlots() { public static void checkForExpiredPlots() {
final JavaPlugin plugin = PlotMain.getMain(); final JavaPlugin plugin = PlotMain.getMain();
Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin, Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
new Runnable() { @Override
@Override public void run() {
public void run() { checkExpired(plugin, true);
checkExpired(plugin, true); }
} }, 0l, 12 * 60 * 60 * 20l);
}, 0l, 12 * 60 * 60 * 20l);
} }
/** /**
@ -175,7 +173,8 @@ public class PlotMain extends JavaPlugin {
boolean hasperm = false; boolean hasperm = false;
if (player.hasPermission(perm)) { if (player.hasPermission(perm)) {
hasperm = true; hasperm = true;
} else { }
else {
String[] nodes = perm.split("\\."); String[] nodes = perm.split("\\.");
StringBuilder n = new StringBuilder(); StringBuilder n = new StringBuilder();
for (int i = 0; i < (nodes.length - 1); i++) { for (int i = 0; i < (nodes.length - 1); i++) {
@ -246,7 +245,6 @@ public class PlotMain extends JavaPlugin {
} }
/** /**
*
* @param player * @param player
* @return * @return
*/ */
@ -266,7 +264,6 @@ public class PlotMain extends JavaPlugin {
} }
/** /**
*
* @param world * @param world
* @param player * @param player
* @return * @return
@ -285,7 +282,6 @@ public class PlotMain extends JavaPlugin {
} }
/** /**
*
* @param world * @param world
* @return * @return
*/ */
@ -304,7 +300,6 @@ public class PlotMain extends JavaPlugin {
} }
/** /**
*
* @return * @return
*/ */
public static String[] getPlotWorldsString() { public static String[] getPlotWorldsString() {
@ -312,7 +307,6 @@ public class PlotMain extends JavaPlugin {
} }
/** /**
*
* @param world * @param world
* @return * @return
*/ */
@ -321,7 +315,6 @@ public class PlotMain extends JavaPlugin {
} }
/** /**
*
* @param world * @param world
* @return * @return
*/ */
@ -333,7 +326,6 @@ public class PlotMain extends JavaPlugin {
} }
/** /**
*
* @param world * @param world
* @return * @return
*/ */
@ -345,7 +337,6 @@ public class PlotMain extends JavaPlugin {
} }
/** /**
*
* @param world * @param world
* @return * @return
*/ */
@ -357,7 +348,6 @@ public class PlotMain extends JavaPlugin {
} }
/** /**
*
* @param world * @param world
* @return * @return
*/ */
@ -369,7 +359,6 @@ public class PlotMain extends JavaPlugin {
} }
/** /**
*
* @param world * @param world
* @return set containing the plots for a 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 * TODO: <b>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 * recycle old plots</b> <br>
* to hide the fact that the are owned. Reduce amount of expired plots: - On * So why not just allow users to claim old plots, and try to hide the fact
* /plot auto - allow claiming of old plot, clear it so the user doesn't * that the are owned. <br>
* know - On /plot info, - show that the plot is expired and allowed to be * <br>
* claimed * Reduce amount of expired plots: <br>
* * - On /plot <br>
* Have the task run less often: - Run the task when there are very little, * auto<br>
* or no players online (great for small servers) - Run the task at startup * - allow claiming of old plot, clear it so the user doesn't know<br>
* (also only useful for small servers) * - On /plot info,<br>
* * - show that the plot is expired and allowed to be claimed Have the task
* Also, in terms of faster code: - Have an array of plots, sorted by expiry * run less often:<br>
* time. - Add new plots to the end. - The task then only needs to go * - Run the task when there are very little, or no players online (great
* through the first few plots * for small servers)<br>
* - Run the task at startup (also only useful for small servers)<br>
* Also, in terms of faster code:<br>
* - Have an array of plots, sorted by expiry time.<br>
* - Add new plots to the end.<br>
* - The task then only needs to go through the first few plots
* *
* @param plugin * @param plugin
* Plugin * Plugin
@ -443,13 +437,12 @@ public class PlotMain extends JavaPlugin {
} }
int days = (int) (lastPlayed / (1000 * 60 * 60 * 24)); int days = (int) (lastPlayed / (1000 * 60 * 60 * 24));
if (days >= Settings.AUTO_CLEAR_DAYS) { if (days >= Settings.AUTO_CLEAR_DAYS) {
PlotDeleteEvent event = new PlotDeleteEvent( PlotDeleteEvent event = new PlotDeleteEvent(world, plot.id);
world, plot.id); Bukkit.getServer().getPluginManager().callEvent(event);
Bukkit.getServer().getPluginManager()
.callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
event.setCancelled(true); event.setCancelled(true);
} else { }
else {
DBFunc.delete(world, plot); DBFunc.delete(world, plot);
} }
} }
@ -458,18 +451,18 @@ public class PlotMain extends JavaPlugin {
} }
} }
}); });
} else { }
else {
for (String world : getPlotWorldsString()) { for (String world : getPlotWorldsString()) {
if (PlotMain.plots.containsKey(world)) { if (PlotMain.plots.containsKey(world)) {
for (Plot plot : PlotMain.plots.get(world).values()) { for (Plot plot : PlotMain.plots.get(world).values()) {
if (PlayerFunctions.hasExpired(plot)) { if (PlayerFunctions.hasExpired(plot)) {
PlotDeleteEvent event = new PlotDeleteEvent(world, PlotDeleteEvent event = new PlotDeleteEvent(world, plot.id);
plot.id); Bukkit.getServer().getPluginManager().callEvent(event);
Bukkit.getServer().getPluginManager()
.callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
event.setCancelled(true); event.setCancelled(true);
} else { }
else {
DBFunc.delete(world, plot); DBFunc.delete(world, plot);
} }
} }
@ -480,22 +473,19 @@ public class PlotMain extends JavaPlugin {
} }
private void setupLogger() { private void setupLogger() {
File log = new File(getMain().getDataFolder() + File.separator + "logs" File log = new File(getMain().getDataFolder() + File.separator + "logs" + File.separator + "plots.log");
+ File.separator + "plots.log");
if (!log.exists()) { if (!log.exists()) {
try { try {
if (!new File(getMain().getDataFolder() + File.separator if (!new File(getMain().getDataFolder() + File.separator + "logs").mkdirs()) {
+ "logs").mkdirs()) { sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to create logs folder. Do it manually.");
sendConsoleSenderMessage(C.PREFIX.s()
+ "&cFailed to create logs folder. Do it manually.");
} }
if (log.createNewFile()) { if (log.createNewFile()) {
FileWriter writer = new FileWriter(log); FileWriter writer = new FileWriter(log);
writer.write("Created at: " + new Date().toString() writer.write("Created at: " + new Date().toString() + "\n\n\n");
+ "\n\n\n");
writer.close(); writer.close();
} }
} catch (IOException e) { }
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -505,8 +495,7 @@ public class PlotMain extends JavaPlugin {
} }
private static double getJavaVersion() { private static double getJavaVersion() {
return Double.parseDouble(System return Double.parseDouble(System.getProperty("java.specification.version"));
.getProperty("java.specification.version"));
} }
/** /**
@ -519,10 +508,8 @@ public class PlotMain extends JavaPlugin {
// Check for outdated java version. // Check for outdated java version.
if (getJavaVersion() < 1.7) { if (getJavaVersion() < 1.7) {
sendConsoleSenderMessage(C.PREFIX.s() sendConsoleSenderMessage(C.PREFIX.s() + "&cYour java version is outdated. Please update to at least 1.7.");
+ "&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()
+ "&cURL: &6https://java.com/en/download/index.jsp");
Bukkit.getPluginManager().disablePlugin(this); Bukkit.getPluginManager().disablePlugin(this);
return; return;
} }
@ -534,9 +521,9 @@ public class PlotMain extends JavaPlugin {
Metrics metrics = new Metrics(this); Metrics metrics = new Metrics(this);
metrics.start(); metrics.start();
sendConsoleSenderMessage(C.PREFIX.s() + "&6Metrics enabled."); sendConsoleSenderMessage(C.PREFIX.s() + "&6Metrics enabled.");
} catch (Exception e) { }
sendConsoleSenderMessage(C.PREFIX.s() catch (Exception e) {
+ "&cFailed to load up metrics."); sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to load up metrics.");
} }
} }
@ -549,85 +536,90 @@ public class PlotMain extends JavaPlugin {
} }
if (Settings.DB.USE_MYSQL) { if (Settings.DB.USE_MYSQL) {
try { try {
mySQL = new MySQL(this, Settings.DB.HOST_NAME, mySQL =
Settings.DB.PORT, Settings.DB.DATABASE, new MySQL(this, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD);
Settings.DB.USER, Settings.DB.PASSWORD);
connection = mySQL.openConnection(); connection = mySQL.openConnection();
{ {
DatabaseMetaData meta = connection.getMetaData(); DatabaseMetaData meta = connection.getMetaData();
ResultSet res = meta.getTables(null, null, "plot", null); ResultSet res = meta.getTables(null, null, "plot", null);
if (!res.next()) { if (!res.next()) {
DBFunc.createTables("mysql", true); DBFunc.createTables("mysql", true);
} else { }
else {
res = meta.getTables(null, null, "plot_trusted", null); res = meta.getTables(null, null, "plot_trusted", null);
if (!res.next()) { if (!res.next()) {
DBFunc.createTables("mysql", false); DBFunc.createTables("mysql", false);
} else { }
res = meta.getTables(null, null, "plot_ratings", else {
null); res = meta.getTables(null, null, "plot_ratings", null);
if (!res.next()) { if (!res.next()) {
DBFunc.createTables("mysql", false); DBFunc.createTables("mysql", false);
} }
} }
} }
} }
} catch (ClassNotFoundException | SQLException e) { }
catch (ClassNotFoundException | SQLException e) {
Logger.add(LogLevel.DANGER, "MySQL connection failed."); Logger.add(LogLevel.DANGER, "MySQL connection failed.");
System.out System.out.print("\u001B[31m[Plots] MySQL is not setup correctly. The plugin will disable itself.\u001B[0m");
.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[36m==== Here is an ugly stacktrace if you are interested in those things ====\u001B[0m");
e.printStackTrace(); e.printStackTrace();
Bukkit.getPluginManager().disablePlugin(this); Bukkit.getPluginManager().disablePlugin(this);
return; return;
} }
plots = DBFunc.getPlots(); plots = DBFunc.getPlots();
} else if (Settings.DB.USE_MONGO) { }
sendConsoleSenderMessage(C.PREFIX.s() else
+ "MongoDB is not yet implemented"); if (Settings.DB.USE_MONGO) {
} else if (Settings.DB.USE_SQLITE) { sendConsoleSenderMessage(C.PREFIX.s() + "MongoDB is not yet implemented");
try { }
connection = new SQLite(this, Settings.DB.SQLITE_DB + ".db") else
.openConnection(); if (Settings.DB.USE_SQLITE) {
{ try {
DatabaseMetaData meta = connection.getMetaData(); connection = new SQLite(this, Settings.DB.SQLITE_DB + ".db").openConnection();
ResultSet res = meta.getTables(null, null, "plot", null); {
if (!res.next()) { DatabaseMetaData meta = connection.getMetaData();
DBFunc.createTables("sqlite", true); ResultSet res = meta.getTables(null, null, "plot", null);
} 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()) { 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) { if (getServer().getPluginManager().getPlugin("PlotMe") != null) {
try { try {
new PlotMeConverter(this).runAsync(); new PlotMeConverter(this).runAsync();
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -650,22 +642,17 @@ public class PlotMain extends JavaPlugin {
getServer().getPluginManager().registerEvents(camera, this); getServer().getPluginManager().registerEvents(camera, this);
} }
if (getServer().getPluginManager().getPlugin("BarAPI") != null) { if (getServer().getPluginManager().getPlugin("BarAPI") != null) {
barAPI = (BarAPI) getServer().getPluginManager() barAPI = (BarAPI) getServer().getPluginManager().getPlugin("BarAPI");
.getPlugin("BarAPI");
} }
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) { if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
worldEdit = (WorldEditPlugin) getServer().getPluginManager() worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
.getPlugin("WorldEdit"); getServer().getPluginManager().registerEvents(new WorldEditListener(), this);
getServer().getPluginManager().registerEvents(
new WorldEditListener(), this);
} }
if (Settings.WORLDGUARD) { if (Settings.WORLDGUARD) {
if (getServer().getPluginManager().getPlugin("WorldGuard") != null) { if (getServer().getPluginManager().getPlugin("WorldGuard") != null) {
worldGuard = (WorldGuardPlugin) getServer().getPluginManager() worldGuard = (WorldGuardPlugin) getServer().getPluginManager().getPlugin("WorldGuard");
.getPlugin("WorldGuard");
worldGuardListener = new WorldGuardListener(this); worldGuardListener = new WorldGuardListener(this);
getServer().getPluginManager().registerEvents( getServer().getPluginManager().registerEvents(worldGuardListener, this);
worldGuardListener, this);
} }
} }
if (Settings.AUTO_CLEAR) { if (Settings.AUTO_CLEAR) {
@ -673,26 +660,24 @@ public class PlotMain extends JavaPlugin {
checkForExpiredPlots(); checkForExpiredPlots();
} }
if (getServer().getPluginManager().getPlugin("Vault") != null) { if (getServer().getPluginManager().getPlugin("Vault") != null) {
RegisteredServiceProvider<Economy> economyProvider = getServer() RegisteredServiceProvider<Economy> economyProvider =
.getServicesManager().getRegistration( getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) { if (economyProvider != null) {
economy = economyProvider.getProvider(); economy = economyProvider.getProvider();
} }
useEconomy = (economy != null); useEconomy = (economy != null);
} }
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Lag(), getServer().getScheduler().scheduleSyncRepeatingTask(this, new Lag(), 100L, 1L);
100L, 1L);
if (Web.ENABLED) { if (Web.ENABLED) {
sendConsoleSenderMessage(C.PREFIX.s() sendConsoleSenderMessage(C.PREFIX.s() + "Web Is not implemented yet. Please bear with us.");
+ "Web Is not implemented yet. Please bear with us.");
} }
try { try {
new SetBlockFast(); new SetBlockFast();
PlotHelper.canSetFast = true; PlotHelper.canSetFast = true;
} catch (Exception e) { }
catch (Exception e) {
PlotHelper.canSetFast = false; PlotHelper.canSetFast = false;
} }
@ -738,28 +723,20 @@ public class PlotMain extends JavaPlugin {
*/ */
public static void sendConsoleSenderMessage(String string) { public static void sendConsoleSenderMessage(String string) {
if (getMain().getServer().getConsoleSender() == null) { if (getMain().getServer().getConsoleSender() == null) {
System.out.println(ChatColor.stripColor(ConsoleColors System.out.println(ChatColor.stripColor(ConsoleColors.fromString(string)));
.fromString(string))); }
} else { else {
getMain() getMain().getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', string));
.getServer()
.getConsoleSender()
.sendMessage(
ChatColor.translateAlternateColorCodes('&', string));
} }
} }
public static boolean teleportPlayer(Player player, Location from, Plot plot) { public static boolean teleportPlayer(Player player, Location from, Plot plot) {
PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, plot);
from, plot);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
Location location = PlotHelper.getPlotHome( Location location = PlotHelper.getPlotHome(Bukkit.getWorld(plot.world), plot);
Bukkit.getWorld(plot.world), plot); if ((location.getBlockX() >= 29999999) || (location.getBlockX() <= -29999999)
if ((location.getBlockX() >= 29999999) || (location.getBlockZ() >= 299999999) || (location.getBlockZ() <= -29999999)) {
|| (location.getBlockX() <= -29999999)
|| (location.getBlockZ() >= 299999999)
|| (location.getBlockZ() <= -29999999)) {
event.setCancelled(true); event.setCancelled(true);
return false; return false;
} }
@ -787,8 +764,7 @@ public class PlotMain extends JavaPlugin {
* message * message
*/ */
public static void Broadcast(C c) { public static void Broadcast(C c) {
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + c.s()));
C.PREFIX.s() + c.s()));
} }
/** /**
@ -812,8 +788,7 @@ public class PlotMain extends JavaPlugin {
PlayerFunctions.sendMessage(player, c); PlayerFunctions.sendMessage(player, c);
} }
} }
System.out.println(ChatColor.stripColor(ChatColor System.out.println(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + c.s())));
.translateAlternateColorCodes('&', C.PREFIX.s() + c.s())));
} }
public static void reloadTranslations() throws IOException { public static void reloadTranslations() throws IOException {
@ -825,8 +800,7 @@ public class PlotMain extends JavaPlugin {
return 0; return 0;
} }
OfflinePlayer player; OfflinePlayer player;
if (((player = Bukkit.getOfflinePlayer(uuid)) == null) if (((player = Bukkit.getOfflinePlayer(uuid)) == null) || !player.hasPlayedBefore()) {
|| !player.hasPlayedBefore()) {
return 0; return 0;
} }
return player.getLastPlayed(); return player.getLastPlayed();
@ -837,47 +811,48 @@ public class PlotMain extends JavaPlugin {
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void configs() { public static void configs() {
File folder = new File(getMain().getDataFolder() + File.separator File folder = new File(getMain().getDataFolder() + File.separator + "config");
+ "config");
if (!folder.exists() && !folder.mkdirs()) { if (!folder.exists() && !folder.mkdirs()) {
sendConsoleSenderMessage(C.PREFIX.s() sendConsoleSenderMessage(C.PREFIX.s()
+ "&cFailed to create the /plugins/config folder. Please create it manually."); + "&cFailed to create the /plugins/config folder. Please create it manually.");
} }
try { try {
configFile = new File(getMain().getDataFolder() + File.separator configFile =
+ "config" + File.separator + "settings.yml"); new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "settings.yml");
if (!configFile.exists()) { if (!configFile.exists()) {
configFile.createNewFile(); configFile.createNewFile();
} }
config = YamlConfiguration.loadConfiguration(configFile); config = YamlConfiguration.loadConfiguration(configFile);
setupConfig(); setupConfig();
} catch (Exception err_trans) { }
catch (Exception err_trans) {
Logger.add(LogLevel.DANGER, "Failed to save settings.yml"); Logger.add(LogLevel.DANGER, "Failed to save settings.yml");
System.out.println("Failed to save settings.yml"); System.out.println("Failed to save settings.yml");
} }
try { try {
storageFile = new File(getMain().getDataFolder() + File.separator storageFile =
+ "config" + File.separator + "storage.yml"); new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "storage.yml");
if (!storageFile.exists()) { if (!storageFile.exists()) {
storageFile.createNewFile(); storageFile.createNewFile();
} }
storage = YamlConfiguration.loadConfiguration(storageFile); storage = YamlConfiguration.loadConfiguration(storageFile);
setupStorage(); setupStorage();
} catch (Exception err_trans) { }
catch (Exception err_trans) {
Logger.add(LogLevel.DANGER, "Failed to save storage.yml"); Logger.add(LogLevel.DANGER, "Failed to save storage.yml");
System.out.println("Failed to save storage.yml"); System.out.println("Failed to save storage.yml");
} }
try { try {
translationsFile = new File(getMain().getDataFolder() translationsFile =
+ File.separator + "config" + File.separator new File(getMain().getDataFolder() + File.separator + "config" + File.separator
+ "translations.yml"); + "translations.yml");
if (!translationsFile.exists()) { if (!translationsFile.exists()) {
translationsFile.createNewFile(); translationsFile.createNewFile();
} }
translations = YamlConfiguration translations = YamlConfiguration.loadConfiguration(translationsFile);
.loadConfiguration(translationsFile);
setupTranslations(); setupTranslations();
} catch (Exception err_trans) { }
catch (Exception err_trans) {
Logger.add(LogLevel.DANGER, "Failed to save translations.yml"); Logger.add(LogLevel.DANGER, "Failed to save translations.yml");
System.out.println("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); config.save(configFile);
storage.save(storageFile); storage.save(storageFile);
translations.save(translationsFile); translations.save(translationsFile);
} catch (IOException e) { }
catch (IOException e) {
Logger.add(LogLevel.DANGER, "Configuration file saving failed"); Logger.add(LogLevel.DANGER, "Configuration file saving failed");
e.printStackTrace(); e.printStackTrace();
} }
@ -922,8 +898,7 @@ public class PlotMain extends JavaPlugin {
settings.put("Auto Clear Days", "" + Settings.AUTO_CLEAR_DAYS); settings.put("Auto Clear Days", "" + Settings.AUTO_CLEAR_DAYS);
for (Entry<String, String> setting : settings.entrySet()) { for (Entry<String, String> setting : settings.entrySet()) {
sendConsoleSenderMessage(C.PREFIX.s() sendConsoleSenderMessage(C.PREFIX.s()
+ String.format("&cKey: &6%s&c, Value: &6%s", + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
setting.getKey(), setting.getValue()));
} }
} }
} }
@ -933,145 +908,108 @@ public class PlotMain extends JavaPlugin {
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void killAllEntities() { public static void killAllEntities() {
Bukkit.getScheduler().scheduleAsyncRepeatingTask(getMain(), Bukkit.getScheduler().scheduleAsyncRepeatingTask(getMain(), new Runnable() {
new Runnable() { Location location;
Location location; long ticked = 0l;
long ticked = 0l; long error = 0l;
long error = 0l; {
{ sendConsoleSenderMessage(C.PREFIX.s() + "KillAllEntities started.");
sendConsoleSenderMessage(C.PREFIX.s() }
+ "KillAllEntities started.");
}
@Override @Override
public void run() { public void run() {
if (this.ticked > 36000l) { if (this.ticked > 36000l) {
this.ticked = 0l; this.ticked = 0l;
sendConsoleSenderMessage(C.PREFIX.s() sendConsoleSenderMessage(C.PREFIX.s() + "KillAllEntities has been running for 60 minutes. Errors: "
+ "KillAllEntities has been running for 60 minutes. Errors: " + this.error);
+ this.error); this.error = 0l;
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()) { for (Chunk chunk : world.getLoadedChunks()) {
getWorldSettings(w); Entity[] entities = chunk.getEntities();
World world = Bukkit.getServer().getWorld(w); for (int i = entities.length - 1; i >= 0; i--) {
try { Entity entity = entities[i];
if (world.getLoadedChunks().length < 1) {
if ((entity instanceof Player) || PlayerEvents.isInPlot(entity.getLocation())) {
continue; 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;
} boolean tamed = false;
if (PlayerEvents if (Settings.MOB_PATHFINDING) {
.isInPlot(pos)) { if (entity instanceof Tameable) {
entity.teleport(pos Tameable tameable = (Tameable) entity;
.add(0.5, if (tameable.isTamed()) {
0, tamed = true;
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();
}
}
} }
} }
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"); Settings.DEBUG = config.getBoolean("debug");
if (Settings.DEBUG) { if (Settings.DEBUG) {
sendConsoleSenderMessage(C.PREFIX.s() sendConsoleSenderMessage(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
+ "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
} }
Web.ENABLED = config.getBoolean("web.enabled"); Web.ENABLED = config.getBoolean("web.enabled");
Web.PORT = config.getInt("web.port"); Web.PORT = config.getInt("web.port");
@ -1129,68 +1066,70 @@ public class PlotMain extends JavaPlugin {
try { try {
config.save(PlotMain.configFile); 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"); 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) { public static void loadWorld(String world, ChunkGenerator generator) {
if (getWorldSettings(world)!=null) { if (getWorldSettings(world) != null) {
return; return;
} }
Set<String> worlds; Set<String> worlds;
if (config.contains("worlds")) { if (config.contains("worlds")) {
worlds = config.getConfigurationSection("worlds").getKeys(false); worlds = config.getConfigurationSection("worlds").getKeys(false);
} else { }
worlds = new HashSet<String>(); else {
} worlds = new HashSet<String>();
if (generator!=null && generator instanceof PlotGenerator) { }
sendConsoleSenderMessage(C.PREFIX.s() if (generator != null && generator instanceof PlotGenerator) {
+ "&aDetected world load for '" + world + "'."); sendConsoleSenderMessage(C.PREFIX.s() + "&aDetected world load for '" + world + "'.");
PlotGenerator plotgen = (PlotGenerator) generator; PlotGenerator plotgen = (PlotGenerator) generator;
PlotWorld plotworld = plotgen.getNewPlotWorld(world); PlotWorld plotworld = plotgen.getNewPlotWorld(world);
PlotManager manager = plotgen.getPlotManager(); PlotManager manager = plotgen.getPlotManager();
if (!config.contains("worlds." + world)) { if (!config.contains("worlds." + world)) {
config.createSection("worlds." + world); config.createSection("worlds." + world);
} }
plotworld.saveConfiguration(config.getConfigurationSection("worlds." + world)); plotworld.saveConfiguration(config.getConfigurationSection("worlds." + world));
plotworld.loadDefaultConfiguration(config.getConfigurationSection("worlds." + world)); plotworld.loadDefaultConfiguration(config.getConfigurationSection("worlds." + world));
try {
config.save(configFile);
} catch (IOException e) {
e.printStackTrace();
}
addPlotWorld(world, plotworld, manager); try {
config.save(configFile);
}
catch (IOException e) {
e.printStackTrace();
}
} else { addPlotWorld(world, plotworld, manager);
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));
plotworld.loadConfiguration(config.getConfigurationSection("worlds." + world)); }
else {
try { if (worlds.contains(world)) {
config.save(configFile); sendConsoleSenderMessage("&cWorld '" + world + "' in settings.yml is not using PlotSquared generator!");
} catch (IOException e) {
e.printStackTrace();
}
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"); Logger.add(LogLevel.GENERAL, "Logger disabled");
try { try {
Logger.write(); Logger.write();
} catch (IOException e1) { }
catch (IOException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
try { try {
connection.close(); connection.close();
mySQL.closeConnection(); mySQL.closeConnection();
} catch (NullPointerException | SQLException e) { }
catch (NullPointerException | SQLException e) {
if (connection != null) { if (connection != null) {
Logger.add(LogLevel.DANGER, "Could not close mysql connection"); 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, public static void addPlotWorld(String world, PlotWorld plotworld, PlotManager manager) {
PlotManager manager) {
worlds.put(world, plotworld); worlds.put(world, plotworld);
managers.put(world, manager); managers.put(world, manager);
if (!plots.containsKey(world)) { if (!plots.containsKey(world)) {

View File

@ -18,12 +18,10 @@ public abstract class PlotManager {
public abstract PlotId getPlotId(PlotWorld plotworld, Location loc); public abstract PlotId getPlotId(PlotWorld plotworld, Location loc);
public abstract boolean isInPlotAbs(PlotWorld plotworld, Location loc, public abstract boolean isInPlotAbs(PlotWorld plotworld, Location loc, PlotId plotid);
PlotId plotid);
// If you have a circular plot, just return the corner if it were a square // If you have a circular plot, just return the corner if it were a square
public abstract Location getPlotBottomLocAbs(PlotWorld plotworld, public abstract Location getPlotBottomLocAbs(PlotWorld plotworld, PlotId plotid);
PlotId plotid);
// the same applies here // the same applies here
public abstract Location getPlotTopLocAbs(PlotWorld plotworld, PlotId plotid); 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 boolean clearPlot(Player player, Plot plot);
public abstract Location getSignLoc(Player player, PlotWorld plotworld, public abstract Location getSignLoc(Player player, PlotWorld plotworld, Plot plot);
Plot plot);
/* /*
* Plot set functions (return false if you do not support the specific set * Plot set functions (return false if you do not support the specific set
* method) * method)
*/ */
public abstract boolean setWall(Player player, PlotWorld plotworld, public abstract boolean setWall(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock block);
PlotId plotid, PlotBlock block);
public abstract boolean setFloor(Player player, PlotWorld plotworld, public abstract boolean setFloor(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock[] block);
PlotId plotid, PlotBlock[] block);
public abstract boolean setBiome(Player player, Plot plot, Biome biome); 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 removeRoadSouthEast(PlotWorld plotworld, Plot plot);
public abstract boolean finishPlotMerge(World world, PlotWorld plotworld, public abstract boolean finishPlotMerge(World world, PlotWorld plotworld, ArrayList<PlotId> plotIds);
ArrayList<PlotId> plotIds);
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlotSettings.java * >> File = PlotSettings.java >> Generated by: Citymonstret at 2014-08-09 01:44
* >> Generated by: Citymonstret at 2014-08-09 01:44
*/ */
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
@ -19,7 +18,6 @@ import org.bukkit.block.Biome;
* plot settings * plot settings
* *
* @author Citymonstret * @author Citymonstret
*
*/ */
public class PlotSettings { public class PlotSettings {
/** /**
@ -92,7 +90,6 @@ public class PlotSettings {
} }
/** /**
*
* @param b * @param b
*/ */
public void setBiome(Biome b) { public void setBiome(Biome b) {
@ -100,7 +97,6 @@ public class PlotSettings {
} }
/** /**
*
* @param b * @param b
*/ */
public void setTimeChange(boolean b) { public void setTimeChange(boolean b) {
@ -108,7 +104,6 @@ public class PlotSettings {
} }
/** /**
*
* @param l * @param l
*/ */
public void setTime(long l) { public void setTime(long l) {
@ -116,7 +111,6 @@ public class PlotSettings {
} }
/** /**
*
* @return * @return
* @deprecated * @deprecated
*/ */
@ -126,7 +120,6 @@ public class PlotSettings {
} }
/** /**
*
* @return * @return
*/ */
public boolean getRain() { public boolean getRain() {
@ -138,7 +131,6 @@ public class PlotSettings {
} }
/** /**
*
* @return * @return
*/ */
public long getTime() { public long getTime() {
@ -146,7 +138,6 @@ public class PlotSettings {
} }
/** /**
*
* @return * @return
*/ */
public boolean getChangeTime() { public boolean getChangeTime() {
@ -154,7 +145,6 @@ public class PlotSettings {
} }
/** /**
*
* @param alias * @param alias
*/ */
public void setAlias(String alias) { public void setAlias(String alias) {
@ -162,7 +152,6 @@ public class PlotSettings {
} }
/** /**
*
* @param flag * @param flag
*/ */
public void addFlag(Flag flag) { public void addFlag(Flag flag) {
@ -174,7 +163,6 @@ public class PlotSettings {
} }
/** /**
*
* @param flags * @param flags
*/ */
public void setFlags(Flag[] flags) { public void setFlags(Flag[] flags) {
@ -182,7 +170,6 @@ public class PlotSettings {
} }
/** /**
*
* @return * @return
*/ */
public Set<Flag> getFlags() { public Set<Flag> getFlags() {
@ -190,7 +177,6 @@ public class PlotSettings {
} }
/** /**
*
* @param flag * @param flag
* @return * @return
*/ */

View File

@ -7,8 +7,7 @@ public class PlotSquaredException extends RuntimeException {
public PlotSquaredException(PlotError error, String details) { public PlotSquaredException(PlotError error, String details) {
super("PlotError >> " + error.getHeader() + ": " + details); super("PlotError >> " + error.getHeader() + ": " + details);
PlotMain.sendConsoleSenderMessage("&cPlotError &6>> &c" PlotMain.sendConsoleSenderMessage("&cPlotError &6>> &c" + error.getHeader() + ": &6" + details);
+ error.getHeader() + ": &6" + details);
} }
public static enum PlotError { public static enum PlotError {

View File

@ -97,28 +97,18 @@ public abstract class PlotWorld {
// TODO make this configurable // TODO make this configurable
// make non static and static_default_valu + add config option // make non static and static_default_valu + add config option
public static ArrayList<Material> BLOCKS = new ArrayList<Material>( public static ArrayList<Material> BLOCKS = new ArrayList<Material>(Arrays.asList(new Material[] { ACACIA_STAIRS,
Arrays.asList(new Material[] { ACACIA_STAIRS, BEACON, BEDROCK, BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE,
BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, CAKE_BLOCK, CAULDRON, CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, COBBLESTONE, COBBLESTONE_STAIRS,
BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON, COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER,
CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, EMERALD_BLOCK, EMERALD_ORE, ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, FURNACE, GLOWSTONE,
COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, HUGE_MUSHROOM_2,
DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE, LEAVES,
DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER, MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK,
ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE, NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN, PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE,
FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL, QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND, SANDSTONE_STAIRS, SMOOTH_BRICK, SMOOTH_STAIRS, SNOW_BLOCK,
GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1, SOUL_SAND, SPONGE, SPRUCE_WOOD_STAIRS, STONE, WOOD, WOOD_STAIRS, WORKBENCH, WOOL, getMaterial(44),
HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN, getMaterial(126) }));
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 boolean AUTO_MERGE;
public static boolean AUTO_MERGE_DEFAULT = false; public static boolean AUTO_MERGE_DEFAULT = false;
@ -172,12 +162,10 @@ public abstract class PlotWorld {
public void loadDefaultConfiguration(ConfigurationSection config) { public void loadDefaultConfiguration(ConfigurationSection config) {
this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning"); this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning");
this.AUTO_MERGE = config.getBoolean("plot.auto_merge"); this.AUTO_MERGE = config.getBoolean("plot.auto_merge");
this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config.getString("plot.biome"));
.getString("plot.biome"));
this.SCHEMATIC_ON_CLAIM = config.getBoolean("schematic.on_claim"); this.SCHEMATIC_ON_CLAIM = config.getBoolean("schematic.on_claim");
this.SCHEMATIC_FILE = config.getString("schematic.file"); this.SCHEMATIC_FILE = config.getString("schematic.file");
this.SCHEMATIC_CLAIM_SPECIFY = config this.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("schematic.specify_on_claim");
.getBoolean("schematic.specify_on_claim");
this.SCHEMATICS = config.getStringList("schematic.schematics"); this.SCHEMATICS = config.getStringList("schematic.schematics");
this.USE_ECONOMY = config.getBoolean("economy.use"); this.USE_ECONOMY = config.getBoolean("economy.use");
this.PLOT_PRICE = config.getDouble("economy.prices.claim"); this.PLOT_PRICE = config.getDouble("economy.prices.claim");
@ -187,7 +175,7 @@ public abstract class PlotWorld {
this.DEFAULT_FLAGS = config.getStringList("flags.default"); this.DEFAULT_FLAGS = config.getStringList("flags.default");
loadConfiguration(config); loadConfiguration(config);
} }
public abstract void loadConfiguration(ConfigurationSection config); public abstract void loadConfiguration(ConfigurationSection config);
public void saveConfiguration(ConfigurationSection config) { public void saveConfiguration(ConfigurationSection config) {
@ -195,22 +183,22 @@ public abstract class PlotWorld {
/* /*
* Saving core plotworld settings * Saving core plotworld settings
*/ */
HashMap<String, Object> options = new HashMap<String, Object>(); HashMap<String, Object> options = new HashMap<String, Object>();
options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT); options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT);
options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT); options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT);
options.put("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT.toString()); options.put("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT.toString());
options.put("schematic.on_claim", PlotWorld.SCHEMATIC_ON_CLAIM_DEFAULT); options.put("schematic.on_claim", PlotWorld.SCHEMATIC_ON_CLAIM_DEFAULT);
options.put("schematic.file", PlotWorld.SCHEMATIC_FILE_DEFAULT); options.put("schematic.file", PlotWorld.SCHEMATIC_FILE_DEFAULT);
options.put("schematic.specify_on_claim", PlotWorld.SCHEMATIC_CLAIM_SPECIFY_DEFAULT); options.put("schematic.specify_on_claim", PlotWorld.SCHEMATIC_CLAIM_SPECIFY_DEFAULT);
options.put("schematic.schematics", PlotWorld.SCHEMATICS_DEFAULT); options.put("schematic.schematics", PlotWorld.SCHEMATICS_DEFAULT);
options.put("economy.use", PlotWorld.USE_ECONOMY_DEFAULT); options.put("economy.use", PlotWorld.USE_ECONOMY_DEFAULT);
options.put("economy.prices.claim", PlotWorld.PLOT_PRICE_DEFAULT); options.put("economy.prices.claim", PlotWorld.PLOT_PRICE_DEFAULT);
options.put("economy.prices.merge", PlotWorld.MERGE_PRICE_DEFAULT); options.put("economy.prices.merge", PlotWorld.MERGE_PRICE_DEFAULT);
options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT); options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT);
options.put("chat.enabled", PlotWorld.PLOT_CHAT_DEFAULT); options.put("chat.enabled", PlotWorld.PLOT_CHAT_DEFAULT);
options.put("flags.default", PlotWorld.DEFAULT_FLAGS_DEFAULT); options.put("flags.default", PlotWorld.DEFAULT_FLAGS_DEFAULT);
ConfigurationNode[] settings = getSettingNodes(); ConfigurationNode[] settings = getSettingNodes();
@ -220,11 +208,11 @@ public abstract class PlotWorld {
for (ConfigurationNode setting : settings) { for (ConfigurationNode setting : settings) {
options.put(setting.getConstant(), setting.getType().parseObject(setting.getValue())); options.put(setting.getConstant(), setting.getType().parseObject(setting.getValue()));
} }
for (String option:options.keySet()) { for (String option : options.keySet()) {
if (!config.contains(option)) { if (!config.contains(option)) {
config.set(option, options.get(option)); config.set(option, options.get(option));
} }
} }
} }
@ -237,4 +225,4 @@ public abstract class PlotWorld {
* @return ConfigurationNode[] * @return ConfigurationNode[]
*/ */
public abstract ConfigurationNode[] getSettingNodes(); public abstract ConfigurationNode[] getSettingNodes();
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = RUtils.java * >> File = RUtils.java >> Generated by: Citymonstret at 2014-08-09 01:44
* >> Generated by: Citymonstret at 2014-08-09 01:44
*/ */
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
@ -16,7 +15,6 @@ import org.bukkit.entity.Player;
* Random utilities * Random utilities
* *
* @author Citymonstret * @author Citymonstret
*
*/ */
public class RUtils { public class RUtils {
@ -43,12 +41,14 @@ public class RUtils {
String s_h = (int) h + " " + ((int) h != 1 ? "hours" : "hour"); String s_h = (int) h + " " + ((int) h != 1 ? "hours" : "hour");
String s_m = (int) m + " " + ((int) m != 1 ? "minutes" : "minute"); String s_m = (int) m + " " + ((int) m != 1 ? "minutes" : "minute");
String s_s = (int) s + " " + ((int) s != 1 ? "seconds" : "second"); String s_s = (int) s + " " + ((int) s != 1 ? "seconds" : "second");
return string.replaceAll("%sec%", s_s).replaceAll("%min%", s_m) return string.replaceAll("%sec%", s_s).replaceAll("%min%", s_m).replaceAll("%hours%", s_h);
.replaceAll("%hours%", s_h);
} }
enum Direction { enum Direction {
SOUTH(0), EAST(1), NORTH(2), WEST(3); SOUTH(0),
EAST(1),
NORTH(2),
WEST(3);
private int i; private int i;
Direction(int i) { Direction(int i) {

View File

@ -27,8 +27,7 @@ public class ReflectionUtils {
/** check server version and class names */ /** check server version and class names */
static { static {
if (Bukkit.getServer() != null) { if (Bukkit.getServer() != null) {
if (Bukkit.getVersion().contains("MCPC") if (Bukkit.getVersion().contains("MCPC") || Bukkit.getVersion().contains("Forge")) {
|| Bukkit.getVersion().contains("Forge")) {
forge = true; forge = true;
} }
Server server = Bukkit.getServer(); Server server = Bukkit.getServer();
@ -39,8 +38,7 @@ public class ReflectionUtils {
preClassB += "." + verB; preClassB += "." + verB;
} }
try { try {
Method getHandle = bukkitServerClass Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle");
.getDeclaredMethod("getHandle");
Object handle = getHandle.invoke(server); Object handle = getHandle.invoke(server);
Class handleServerClass = handle.getClass(); Class handleServerClass = handle.getClass();
pas = handleServerClass.getName().split("\\."); pas = handleServerClass.getName().split("\\.");
@ -48,7 +46,8 @@ public class ReflectionUtils {
String verM = pas[3]; String verM = pas[3];
preClassM += "." + verM; preClassM += "." + verM;
} }
} catch (Exception ignored) { }
catch (Exception ignored) {
} }
} }
} }
@ -73,11 +72,11 @@ public class ReflectionUtils {
public static RefClass getRefClass(String... classes) { public static RefClass getRefClass(String... classes) {
for (String className : classes) { for (String className : classes) {
try { try {
className = className.replace("{cb}", preClassB) className =
.replace("{nms}", preClassM) className.replace("{cb}", preClassB).replace("{nms}", preClassM).replace("{nm}", "net.minecraft");
.replace("{nm}", "net.minecraft");
return getRefClass(Class.forName(className)); return getRefClass(Class.forName(className));
} catch (ClassNotFoundException ignored) { }
catch (ClassNotFoundException ignored) {
} }
} }
throw new RuntimeException("no class found"); throw new RuntimeException("no class found");
@ -135,27 +134,30 @@ public class ReflectionUtils {
* @throws RuntimeException * @throws RuntimeException
* if method not found * if method not found
*/ */
public RefMethod getMethod(String name, Object... types) public RefMethod getMethod(String name, Object... types) throws NoSuchMethodException {
throws NoSuchMethodException {
try { try {
Class[] classes = new Class[types.length]; Class[] classes = new Class[types.length];
int i = 0; int i = 0;
for (Object e : types) { for (Object e : types) {
if (e instanceof Class) { if (e instanceof Class) {
classes[i++] = (Class) e; 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 { try {
return new RefMethod(this.clazz.getMethod(name, classes)); 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); throw new RuntimeException(e);
} }
} }
@ -176,20 +178,23 @@ public class ReflectionUtils {
for (Object e : types) { for (Object e : types) {
if (e instanceof Class) { if (e instanceof Class) {
classes[i++] = (Class) e; 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 { try {
return new RefConstructor( return new RefConstructor(this.clazz.getConstructor(classes));
this.clazz.getConstructor(classes));
} catch (NoSuchMethodException ignored) {
return new RefConstructor(
this.clazz.getDeclaredConstructor(classes));
} }
} catch (Exception e) { catch (NoSuchMethodException ignored) {
return new RefConstructor(this.clazz.getDeclaredConstructor(classes));
}
}
catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
@ -209,16 +214,20 @@ public class ReflectionUtils {
for (Object e : types) { for (Object e : types) {
if (e instanceof Class) { if (e instanceof Class) {
classes[t++] = (Class) e; 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<Method> methods = new ArrayList<>(); List<Method> methods = new ArrayList<>();
Collections.addAll(methods, this.clazz.getMethods()); Collections.addAll(methods, this.clazz.getMethods());
Collections.addAll(methods, this.clazz.getDeclaredMethods()); Collections.addAll(methods, this.clazz.getDeclaredMethods());
findMethod: for (Method m : methods) { findMethod:
for (Method m : methods) {
Class<?>[] methodTypes = m.getParameterTypes(); Class<?>[] methodTypes = m.getParameterTypes();
if (methodTypes.length != classes.length) { if (methodTypes.length != classes.length) {
continue; continue;
@ -305,8 +314,7 @@ public class ReflectionUtils {
public RefConstructor findConstructor(int number) { public RefConstructor findConstructor(int number) {
List<Constructor> constructors = new ArrayList<>(); List<Constructor> constructors = new ArrayList<>();
Collections.addAll(constructors, this.clazz.getConstructors()); Collections.addAll(constructors, this.clazz.getConstructors());
Collections.addAll(constructors, Collections.addAll(constructors, this.clazz.getDeclaredConstructors());
this.clazz.getDeclaredConstructors());
for (Constructor m : constructors) { for (Constructor m : constructors) {
if (m.getParameterTypes().length == number) { if (m.getParameterTypes().length == number) {
return new RefConstructor(m); return new RefConstructor(m);
@ -328,10 +336,12 @@ public class ReflectionUtils {
try { try {
try { try {
return new RefField(this.clazz.getField(name)); return new RefField(this.clazz.getField(name));
} catch (NoSuchFieldException ignored) { }
catch (NoSuchFieldException ignored) {
return new RefField(this.clazz.getDeclaredField(name)); return new RefField(this.clazz.getDeclaredField(name));
} }
} catch (Exception e) { }
catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
@ -427,7 +437,8 @@ public class ReflectionUtils {
public Object call(Object... params) { public Object call(Object... params) {
try { try {
return this.method.invoke(null, params); return this.method.invoke(null, params);
} catch (Exception e) { }
catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
@ -451,7 +462,8 @@ public class ReflectionUtils {
public Object call(Object... params) { public Object call(Object... params) {
try { try {
return RefMethod.this.method.invoke(this.e, params); return RefMethod.this.method.invoke(this.e, params);
} catch (Exception e) { }
catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
@ -495,7 +507,8 @@ public class ReflectionUtils {
public Object create(Object... params) { public Object create(Object... params) {
try { try {
return this.constructor.newInstance(params); return this.constructor.newInstance(params);
} catch (Exception e) { }
catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
@ -557,7 +570,8 @@ public class ReflectionUtils {
public void set(Object param) { public void set(Object param) {
try { try {
RefField.this.field.set(this.e, param); RefField.this.field.set(this.e, param);
} catch (Exception e) { }
catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
@ -570,7 +584,8 @@ public class ReflectionUtils {
public Object get() { public Object get() {
try { try {
return RefField.this.field.get(this.e); return RefField.this.field.get(this.e);
} catch (Exception e) { }
catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }

View File

@ -31,19 +31,17 @@ public class SchematicHandler {
return false; return false;
} }
try { try {
EditSession session = new EditSession(new BukkitWorld( EditSession session = new EditSession(new BukkitWorld(location.getWorld()), 999999999);
location.getWorld()), 999999999); CuboidClipboard clipboard = CuboidClipboard.loadSchematic(schematic.getFile());
CuboidClipboard clipboard = CuboidClipboard.loadSchematic(schematic Location l1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId());
.getFile());
Location l1 = PlotHelper.getPlotBottomLoc(plot.getWorld(),
plot.getId());
PlotHelper.getPlotTopLoc(plot.getWorld(), plot.getId()); PlotHelper.getPlotTopLoc(plot.getWorld(), plot.getId());
int x = l1.getBlockX() + 1; int x = l1.getBlockX() + 1;
int z = l1.getBlockZ() + 1; int z = l1.getBlockZ() + 1;
int y = location.getWorld().getHighestBlockYAt(x, z); int y = location.getWorld().getHighestBlockYAt(x, z);
Vector v1 = new Vector(x, y + 1, z); Vector v1 = new Vector(x, y + 1, z);
clipboard.paste(session, v1, true); clipboard.paste(session, v1, true);
} catch (Exception e) { }
catch (Exception e) {
return false; return false;
} }
return true; return true;
@ -51,35 +49,30 @@ public class SchematicHandler {
public Schematic getSchematic(String name) { public Schematic getSchematic(String name) {
{ {
File parent = new File(JavaPlugin.getPlugin(PlotMain.class) File parent =
.getDataFolder() + File.separator + "schematics"); new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics");
if (!parent.exists()) { if (!parent.exists()) {
parent.mkdir(); parent.mkdir();
} }
} }
File file = new File(JavaPlugin.getPlugin(PlotMain.class) File file =
.getDataFolder() new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics"
+ File.separator + File.separator + name + ".schematic");
+ "schematics"
+ File.separator + name + ".schematic");
if (!file.exists()) { if (!file.exists()) {
PlotMain.sendConsoleSenderMessage(file.toString() PlotMain.sendConsoleSenderMessage(file.toString() + " doesn't exist");
+ " doesn't exist");
return null; return null;
} }
Schematic schematic = null; Schematic schematic = null;
try { try {
InputStream iStream = new FileInputStream(file); InputStream iStream = new FileInputStream(file);
NBTInputStream stream = new NBTInputStream(new GZIPInputStream( NBTInputStream stream = new NBTInputStream(new GZIPInputStream(iStream));
iStream));
CompoundTag tag = (CompoundTag) stream.readTag(); CompoundTag tag = (CompoundTag) stream.readTag();
Map<String, Tag> tagMap = tag.getValue(); Map<String, Tag> tagMap = tag.getValue();
byte[] addId = new byte[0]; byte[] addId = new byte[0];
if (tagMap.containsKey("AddBlocks")) { if (tagMap.containsKey("AddBlocks")) {
addId = ByteArrayTag.class.cast(tagMap.get("AddBlocks")) addId = ByteArrayTag.class.cast(tagMap.get("AddBlocks")).getValue();
.getValue();
} }
short width = ShortTag.class.cast(tagMap.get("Width")).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++) { for (int index = 0; index < b.length; index++) {
if ((index >> 1) >= addId.length) { // No corresponding if ((index >> 1) >= addId.length) { // No corresponding
// AddBlocks index // AddBlocks index
blocks[index] = (short) (b[index] & 0xFF); blocks[index] = (short) (b[index] & 0xFF);
} else { }
else {
if ((index & 1) == 0) { if ((index & 1) == 0) {
blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (b[index] & 0xFF)); blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (b[index] & 0xFF));
} else { }
else {
blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (b[index] & 0xFF)); blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (b[index] & 0xFF));
} }
} }
@ -112,10 +107,12 @@ public class SchematicHandler {
} }
schematic = new Schematic(collection, dimension, file); schematic = new Schematic(collection, dimension, file);
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} finally { }
finally {
return schematic; return schematic;
} }
} }
@ -125,8 +122,7 @@ public class SchematicHandler {
private Dimension schematicDimension; private Dimension schematicDimension;
private File file; private File file;
public Schematic(DataCollection[] blockCollection, public Schematic(DataCollection[] blockCollection, Dimension schematicDimension, File file) {
Dimension schematicDimension, File file) {
this.blockCollection = blockCollection; this.blockCollection = blockCollection;
this.schematicDimension = schematicDimension; this.schematicDimension = schematicDimension;
this.file = file; this.file = file;

View File

@ -8,10 +8,8 @@ import com.intellectualcrafters.plot.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.ReflectionUtils.RefMethod; import com.intellectualcrafters.plot.ReflectionUtils.RefMethod;
/** /**
*
* SetBlockFast class<br> * SetBlockFast class<br>
* Used to do fast world editing * Used to do fast world editing
*
*/ */
public class SetBlockFast { public class SetBlockFast {
@ -27,15 +25,12 @@ public class SetBlockFast {
public SetBlockFast() throws NoSuchMethodException { public SetBlockFast() throws NoSuchMethodException {
methodGetHandle = classCraftWorld.getMethod("getHandle"); methodGetHandle = classCraftWorld.getMethod("getHandle");
methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class, int.class);
int.class); methodA = classChunk.getMethod("a", int.class, int.class, int.class, classBlock, int.class);
methodA = classChunk.getMethod("a", int.class, int.class, int.class,
classBlock, int.class);
methodGetById = classBlock.getMethod("getById", int.class); methodGetById = classBlock.getMethod("getById", int.class);
} }
public static boolean set(org.bukkit.World world, int x, int y, int z, public static boolean set(org.bukkit.World world, int x, int y, int z, int blockId, byte data) throws NoSuchMethodException {
int blockId, byte data) throws NoSuchMethodException {
Object w = methodGetHandle.of(world).call(); Object w = methodGetHandle.of(world).call();
Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4); Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4);
@ -48,9 +43,8 @@ public class SetBlockFast {
int distance = Bukkit.getViewDistance() + 1; int distance = Bukkit.getViewDistance() + 1;
for (int cx = -distance; cx < distance; cx++) { for (int cx = -distance; cx < distance; cx++) {
for (int cz = -distance; cz < distance; cz++) { for (int cz = -distance; cz < distance; cz++) {
player.getWorld().refreshChunk( player.getWorld().refreshChunk(player.getLocation().getChunk().getX() + cx, player.getLocation().getChunk().getZ()
player.getLocation().getChunk().getX() + cx, + cz);
player.getLocation().getChunk().getZ() + cz);
} }
} }
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Settings.java * >> File = Settings.java >> Generated by: Citymonstret at 2014-08-09 01:44
* >> Generated by: Citymonstret at 2014-08-09 01:44
*/ */
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
@ -13,7 +12,6 @@ package com.intellectualcrafters.plot;
* Updater and DB settings * Updater and DB settings
* *
* @author Citymonstret * @author Citymonstret
*
* @author Empire92 * @author Empire92
*/ */
public class Settings { public class Settings {
@ -50,7 +48,6 @@ public class Settings {
* Update settings * Update settings
* *
* @author Citymonstret * @author Citymonstret
*
*/ */
public static String URL = "http://dev.bukkit.org/bukkit-plugins/plotsquared/"; public static String URL = "http://dev.bukkit.org/bukkit-plugins/plotsquared/";
@ -78,7 +75,6 @@ public class Settings {
* Database settings * Database settings
* *
* @author Citymonstret * @author Citymonstret
*
*/ */
public static class DB { public static class DB {
public static boolean USE_MONGO = false; /* public static boolean USE_MONGO = false; /*

View File

@ -80,8 +80,7 @@ public class Title {
* @param fadeOutTime * @param fadeOutTime
* Fade out time * Fade out time
*/ */
public Title(String title, String subtitle, int fadeInTime, int stayTime, public Title(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
int fadeOutTime) {
this.title = title; this.title = title;
this.subtitle = subtitle; this.subtitle = subtitle;
this.fadeInTime = fadeInTime; this.fadeInTime = fadeInTime;
@ -170,59 +169,44 @@ public class Title {
* Player * Player
*/ */
public void send(Player player) { public void send(Player player) {
if ((getProtocolVersion(player) >= 47) && isSpigot() if ((getProtocolVersion(player) >= 47) && isSpigot() && (this.packetTitle != null)) {
&& (this.packetTitle != null)) {
// First reset previous settings // First reset previous settings
resetTitle(player); resetTitle(player);
try { try {
// Send timings first // Send timings first
Object handle = getHandle(player); Object handle = getHandle(player);
Object connection = getField(handle.getClass(), Object connection = getField(handle.getClass(), "playerConnection").get(handle);
"playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants(); Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), Method sendPacket = getMethod(connection.getClass(), "sendPacket");
"sendPacket"); Object packet =
Object packet = this.packetTitle.getConstructor( this.packetTitle.getConstructor(this.packetActions, Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(actions[2], this.fadeInTime
this.packetActions, Integer.TYPE, Integer.TYPE, * (this.ticks ? 1 : 20), this.stayTime * (this.ticks ? 1 : 20), this.fadeOutTime
Integer.TYPE).newInstance(actions[2], * (this.ticks ? 1 : 20));
this.fadeInTime * (this.ticks ? 1 : 20),
this.stayTime * (this.ticks ? 1 : 20),
this.fadeOutTime * (this.ticks ? 1 : 20));
// Send if set // Send if set
if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) {
&& (this.stayTime != -1)) {
sendPacket.invoke(connection, packet); sendPacket.invoke(connection, packet);
} }
// Send title // Send title
Object serialized = getMethod(this.nmsChatSerializer, "a", Object serialized =
String.class).invoke( getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, "{text:\""
null, + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:"
"{text:\""
+ ChatColor.translateAlternateColorCodes('&',
this.title) + "\",color:"
+ this.titleColor.name().toLowerCase() + "}"); + this.titleColor.name().toLowerCase() + "}");
packet = this.packetTitle.getConstructor(this.packetActions, packet =
getNMSClass("IChatBaseComponent")).newInstance( this.packetTitle.getConstructor(this.packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[0], serialized);
actions[0], serialized);
sendPacket.invoke(connection, packet); sendPacket.invoke(connection, packet);
if (!this.subtitle.equals("")) { if (!this.subtitle.equals("")) {
// Send subtitle if present // Send subtitle if present
serialized = getMethod(this.nmsChatSerializer, "a", serialized =
String.class).invoke( getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, "{text:\""
null, + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:"
"{text:\"" + this.subtitleColor.name().toLowerCase() + "}");
+ ChatColor.translateAlternateColorCodes( packet =
'&', this.subtitle) + "\",color:" this.packetTitle.getConstructor(this.packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[1], serialized);
+ this.subtitleColor.name().toLowerCase()
+ "}");
packet = this.packetTitle.getConstructor(
this.packetActions,
getNMSClass("IChatBaseComponent")).newInstance(
actions[1], serialized);
sendPacket.invoke(connection, packet); sendPacket.invoke(connection, packet);
} }
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -248,15 +232,13 @@ public class Title {
try { try {
// Send timings first // Send timings first
Object handle = getHandle(player); Object handle = getHandle(player);
Object connection = getField(handle.getClass(), Object connection = getField(handle.getClass(), "playerConnection").get(handle);
"playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants(); Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), Method sendPacket = getMethod(connection.getClass(), "sendPacket");
"sendPacket"); Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[3]);
Object packet = this.packetTitle.getConstructor(
this.packetActions).newInstance(actions[3]);
sendPacket.invoke(connection, packet); sendPacket.invoke(connection, packet);
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -273,15 +255,13 @@ public class Title {
try { try {
// Send timings first // Send timings first
Object handle = getHandle(player); Object handle = getHandle(player);
Object connection = getField(handle.getClass(), Object connection = getField(handle.getClass(), "playerConnection").get(handle);
"playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants(); Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), Method sendPacket = getMethod(connection.getClass(), "sendPacket");
"sendPacket"); Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[4]);
Object packet = this.packetTitle.getConstructor(
this.packetActions).newInstance(actions[4]);
sendPacket.invoke(connection, packet); sendPacket.invoke(connection, packet);
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -298,14 +278,13 @@ public class Title {
int version = 0; int version = 0;
try { try {
Object handle = getHandle(player); Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection") Object connection = getField(handle.getClass(), "playerConnection").get(handle);
.get(handle);
Object networkManager = getValue("networkManager", connection); Object networkManager = getValue("networkManager", connection);
version = (Integer) getMethod("getVersion", version = (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager);
networkManager.getClass()).invoke(networkManager);
return version; return version;
} catch (Exception ex) { }
catch (Exception ex) {
// ex.printStackTrace(); <-- spammy console // ex.printStackTrace(); <-- spammy console
} }
return version; return version;
@ -330,7 +309,8 @@ public class Title {
private Class<?> getClass(String namespace) { private Class<?> getClass(String namespace) {
try { try {
return Class.forName(namespace); return Class.forName(namespace);
} catch (Exception e) { }
catch (Exception e) {
return null; return null;
} }
} }
@ -346,8 +326,7 @@ public class Title {
} }
private Class<?> getPrimitiveType(Class<?> clazz) { private Class<?> getPrimitiveType(Class<?> clazz) {
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz;
.get(clazz) : clazz;
} }
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) { private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
@ -374,14 +353,14 @@ public class Title {
private Object getHandle(Object obj) { private Object getHandle(Object obj) {
try { try {
return getMethod("getHandle", obj.getClass()).invoke(obj); return getMethod("getHandle", obj.getClass()).invoke(obj);
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
} }
private Method getMethod(String name, Class<?> clazz, private Method getMethod(String name, Class<?> clazz, Class<?>... paramTypes) {
Class<?>... paramTypes) {
Class<?>[] t = toPrimitiveTypeArray(paramTypes); Class<?>[] t = toPrimitiveTypeArray(paramTypes);
for (Method m : clazz.getMethods()) { for (Method m : clazz.getMethods()) {
Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes()); Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes());
@ -402,7 +381,8 @@ public class Title {
Class<?> clazz = null; Class<?> clazz = null;
try { try {
clazz = Class.forName(fullName); clazz = Class.forName(fullName);
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return clazz; return clazz;
@ -413,7 +393,8 @@ public class Title {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field; return field;
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
@ -421,9 +402,7 @@ public class Title {
private Method getMethod(Class<?> clazz, String name, Class<?>... args) { private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
for (Method m : clazz.getMethods()) { for (Method m : clazz.getMethods()) {
if (m.getName().equals(name) if (m.getName().equals(name) && ((args.length == 0) || ClassListEqual(args, m.getParameterTypes()))) {
&& ((args.length == 0) || ClassListEqual(args,
m.getParameterTypes()))) {
m.setAccessible(true); m.setAccessible(true);
return m; return m;
} }

View File

@ -18,8 +18,8 @@ import com.intellectualcrafters.plot.uuid.UUIDFetcher;
public class UUIDHandler { public class UUIDHandler {
private static boolean online = Bukkit.getServer().getOnlineMode(); private static boolean online = Bukkit.getServer().getOnlineMode();
private static BiMap<String, UUID> uuidMap = HashBiMap.create(); private static BiMap<String, UUID> uuidMap = HashBiMap.create();
public static boolean uuidExists(UUID uuid) { public static boolean uuidExists(UUID uuid) {
@ -35,43 +35,35 @@ public class UUIDHandler {
} }
/** /**
*
* @param plugin * @param plugin
*/ */
public static void startFetch(JavaPlugin plugin) { public static void startFetch(JavaPlugin plugin) {
plugin.getServer().getScheduler() plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
.runTaskAsynchronously(plugin, new Runnable() { @Override
@Override public void run() {
public void run() { OfflinePlayer[] offlinePlayers = Bukkit.getOfflinePlayers();
OfflinePlayer[] offlinePlayers = Bukkit int length = offlinePlayers.length;
.getOfflinePlayers(); long start = System.currentTimeMillis();
int length = offlinePlayers.length;
long start = System.currentTimeMillis();
String name; String name;
UUID uuid; UUID uuid;
for (OfflinePlayer player : offlinePlayers) { for (OfflinePlayer player : offlinePlayers) {
uuid = player.getUniqueId(); uuid = player.getUniqueId();
if (!uuidExists(uuid)) { if (!uuidExists(uuid)) {
name = player.getName(); name = player.getName();
add(name, uuid); 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.");
} }
}); }
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 * @param name
* @return * @return
*/ */
@ -91,33 +83,33 @@ public class UUIDHandler {
UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name)); UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name));
uuid = fetcher.call().get(name); uuid = fetcher.call().get(name);
add(name, uuid); add(name, uuid);
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} else { }
else {
return getUuidOfflineMode(name); return getUuidOfflineMode(name);
} }
return null; return null;
} }
/** /**
*
* @param uuid * @param uuid
* @return * @return
*/ */
private static String loopSearch(UUID uuid) { private static String loopSearch(UUID uuid) {
return uuidMap.inverse().get(uuid); return uuidMap.inverse().get(uuid);
} }
/** /**
*
* @param uuid * @param uuid
* @return * @return
*/ */
public static String getName(UUID uuid) { public static String getName(UUID uuid) {
if (uuidExists(uuid)) { if (uuidExists(uuid)) {
return loopSearch(uuid); return loopSearch(uuid);
} }
String name; String name;
if ((name = getNameOnlinePlayer(uuid)) != null) { if ((name = getNameOnlinePlayer(uuid)) != null) {
return name; return name;
@ -131,29 +123,28 @@ public class UUIDHandler {
name = fetcher.call().get(uuid); name = fetcher.call().get(uuid);
add(name, uuid); add(name, uuid);
return name; return name;
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} else { }
else {
return "unknown"; return "unknown";
} }
return ""; return "";
} }
/** /**
*
* @param name * @param name
* @return * @return
*/ */
private static UUID getUuidOfflineMode(String name) { private static UUID getUuidOfflineMode(String name) {
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name) UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
.getBytes(Charsets.UTF_8));
add(name, uuid); add(name, uuid);
return uuid; return uuid;
} }
/** /**
*
* @param uuid * @param uuid
* @return * @return
*/ */
@ -168,7 +159,6 @@ public class UUIDHandler {
} }
/** /**
*
* @param uuid * @param uuid
* @return * @return
*/ */
@ -183,7 +173,6 @@ public class UUIDHandler {
} }
/** /**
*
* @param name * @param name
* @return * @return
*/ */
@ -198,12 +187,11 @@ public class UUIDHandler {
} }
/** /**
*
* @param name * @param name
* @return * @return
*/ */
private static UUID getUuidOfflinePlayer(String name) { 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); add(name, uuid);
return uuid; return uuid;
} }

View File

@ -1,15 +1,13 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlotAPI.java * >> File = PlotAPI.java >> Generated by: Citymonstret at 2014-08-09 01:44
* >> Generated by: Citymonstret at 2014-08-09 01:44
*/ */
package com.intellectualcrafters.plot.api; package com.intellectualcrafters.plot.api;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Set; import java.util.Set;
@ -40,35 +38,35 @@ import com.intellectualcrafters.plot.commands.SubCommand;
*/ */
@SuppressWarnings({ "unused", "javadoc" }) @SuppressWarnings({ "unused", "javadoc" })
public class PlotAPI { public class PlotAPI {
private static PlotHelper plotHelper; private static PlotHelper plotHelper;
private static PlayerFunctions playerFunctions; private static PlayerFunctions playerFunctions;
private static FlagManager flagManager; private static FlagManager flagManager;
private static SchematicHandler schematicHandler; private static SchematicHandler schematicHandler;
private static C c; private static C c;
// Methods/fields in PlotMain class // Methods/fields in PlotMain class
// PlotMain.config; // PlotMain.config;
// PlotMain.storage // PlotMain.storage
// PlotMain.translations // PlotMain.translations
// PlotMain.addPlotWorld(world, plotworld, manager); // PlotMain.addPlotWorld(world, plotworld, manager);
// //
// PlotMain.checkForExpiredPlots(); // PlotMain.checkForExpiredPlots();
// PlotMain.killAllEntities(); // PlotMain.killAllEntities();
// //
// PlotMain.createConfiguration(plotworld); // PlotMain.createConfiguration(plotworld);
// PlotMain.getPlots() // PlotMain.getPlots()
// PlotMain.getPlots(player) // PlotMain.getPlots(player)
// PlotMain.getPlots(world) // PlotMain.getPlots(world)
// PlotMain.getPlots(world, player) // PlotMain.getPlots(world, player)
// PlotMain.getWorldPlots(world) // PlotMain.getWorldPlots(world)
// PlotMain.getPlotWorlds() // PlotMain.getPlotWorlds()
// PlotMain.isPlotWorld(world) // PlotMain.isPlotWorld(world)
// PlotMain.removePlot(world, id, callEvent) // PlotMain.removePlot(world, id, callEvent)
// PlotMain.teleportPlayer(player, from, plot) // PlotMain.teleportPlayer(player, from, plot)
// PlotMain.updatePlot(plot); // PlotMain.updatePlot(plot);
// To access plotMain stuff. // To access plotMain stuff.
private PlotMain plotMain; private PlotMain plotMain;
// Reference // Reference
@ -82,18 +80,17 @@ public class PlotAPI {
public PlotAPI(JavaPlugin plugin) { public PlotAPI(JavaPlugin plugin) {
this.plotMain = JavaPlugin.getPlugin(PlotMain.class); this.plotMain = JavaPlugin.getPlugin(PlotMain.class);
} }
/** /**
* Get the main class for this plugin <br> * Get the main class for this plugin <br>
* - Contains a lot of fields and methods * - Contains a lot of fields and methods - not very well organized
* - not very well organized
* *
* @return * @return
*/ */
public PlotMain getMain() { public PlotMain getMain() {
return plotMain; return plotMain;
} }
/** /**
* PlotHelper class contains useful methods relating to plots. * PlotHelper class contains useful methods relating to plots.
* *
@ -102,26 +99,26 @@ public class PlotAPI {
public PlotHelper getPlotHelper() { public PlotHelper getPlotHelper() {
return plotHelper; return plotHelper;
} }
/** /**
* PlayerFunctions class contains useful methods relating to players * PlayerFunctions class contains useful methods relating to players - Some
* - Some player/plot methods are here as well * player/plot methods are here as well
* *
* @return * @return
*/ */
public PlayerFunctions getPlayerFunctions() { public PlayerFunctions getPlayerFunctions() {
return playerFunctions; return playerFunctions;
} }
/** /**
* FlagManager class contains methods relating to plot flags * FlagManager class contains methods relating to plot flags
* *
* @return * @return
*/ */
public FlagManager getFlagManager() { public FlagManager getFlagManager() {
return flagManager; return flagManager;
} }
/** /**
* SchematicHandler class contains methods related to pasting schematics * SchematicHandler class contains methods related to pasting schematics
* *
@ -130,7 +127,7 @@ public class PlotAPI {
public SchematicHandler getSchematicHandler() { public SchematicHandler getSchematicHandler() {
return schematicHandler; return schematicHandler;
} }
/** /**
* C class contains all the captions from the translations.yml file. * C class contains all the captions from the translations.yml file.
* *
@ -139,10 +136,10 @@ public class PlotAPI {
public C getCaptions() { public C getCaptions() {
return c; return c;
} }
/** /**
* Get the plot manager for a world. * Get the plot manager for a world. - Most of these methods can be accessed
* - Most of these methods can be accessed through the PlotHelper * through the PlotHelper
* *
* @param world * @param world
* @return * @return
@ -150,44 +147,44 @@ public class PlotAPI {
public PlotManager getPlotManager(World world) { public PlotManager getPlotManager(World world) {
return PlotMain.getPlotManager(world); return PlotMain.getPlotManager(world);
} }
/** /**
* Get the plot manager for a world. * Get the plot manager for a world. - Contains useful low level methods for
* - Contains useful low level methods for plot merging, clearing, and tessellation * plot merging, clearing, and tessellation
* *
* @param world * @param world
* @return * @return
*/ */
public PlotManager getPlotManager(String world) { public PlotManager getPlotManager(String world) {
return PlotMain.getPlotManager(world); return PlotMain.getPlotManager(world);
} }
/** /**
* Get the settings for a world (settings bundled in PlotWorld class) * Get the settings for a world (settings bundled in PlotWorld class) - You
* - You will need to downcast for the specific settings a Generator has. * will need to downcast for the specific settings a Generator has. e.g.
* e.g. DefaultPlotWorld class implements PlotWorld * DefaultPlotWorld class implements PlotWorld
* *
* @param world * @param world
* (to get settings of) * (to get settings of)
* @return PlotWorld class for that world ! will return null if not a plot world * @return PlotWorld class for that world ! will return null if not a plot
* world * world world
*/ */
public PlotWorld getWorldSettings(World world) { public PlotWorld getWorldSettings(World world) {
return PlotMain.getWorldSettings(world); return PlotMain.getWorldSettings(world);
} }
/** /**
* Get the settings for a world (settings bundled in PlotWorld class) * Get the settings for a world (settings bundled in PlotWorld class)
* *
* @param world * @param world
* (to get settings of) * (to get settings of)
* @return PlotWorld class for that world ! will return null if not a plot world * @return PlotWorld class for that world ! will return null if not a plot
* world * world world
*/ */
public PlotWorld getWorldSettings(String world) { public PlotWorld getWorldSettings(String world) {
return PlotMain.getWorldSettings(world); return PlotMain.getWorldSettings(world);
} }
/** /**
* Send a message to a player. * Send a message to a player.
* *
@ -200,8 +197,7 @@ public class PlotAPI {
} }
/** /**
* Send a message to a player. * Send a message to a player. - Supports color codes
* - Supports color codes
* *
* @param player * @param player
* @param string * @param string
@ -211,8 +207,7 @@ public class PlotAPI {
} }
/** /**
* Send a message to the console. * Send a message to the console. - Supports color codes
* - Supports color codes
* *
* @param msg * @param msg
*/ */
@ -287,8 +282,7 @@ public class PlotAPI {
* @return true if player has a plot, false if not. * @return true if player has a plot, false if not.
*/ */
public boolean hasPlot(World world, Player player) { public boolean hasPlot(World world, Player player) {
return (getPlots(world, player, true) != null) return (getPlots(world, player, true) != null) && (getPlots(world, player, true).length > 0);
&& (getPlots(world, player, true).length > 0);
} }
/** /**
@ -306,7 +300,8 @@ public class PlotAPI {
if ((plot.owner != null) && (plot.owner == plr.getUniqueId())) { if ((plot.owner != null) && (plot.owner == plr.getUniqueId())) {
pPlots.add(plot); pPlots.add(plot);
} }
} else { }
else {
if (plot.hasRights(plr)) { if (plot.hasRights(plr)) {
pPlots.add(plot); pPlots.add(plot);
} }
@ -354,8 +349,7 @@ public class PlotAPI {
*/ */
public Location[] getLocations(Plot p) { public Location[] getLocations(Plot p) {
World world = Bukkit.getWorld(p.world); World world = Bukkit.getWorld(p.world);
return new Location[] { PlotHelper.getPlotBottomLoc(world, p.id), return new Location[] { PlotHelper.getPlotBottomLoc(world, p.id), PlotHelper.getPlotTopLoc(world, p.id),
PlotHelper.getPlotTopLoc(world, p.id),
PlotHelper.getPlotHome(world, p.id) }; PlotHelper.getPlotHome(world, p.id) };
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Auto.java * >> File = Auto.java >> Generated by: Citymonstret at 2014-08-09 01:40
* >> Generated by: Citymonstret at 2014-08-09 01:40
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -25,8 +24,7 @@ import com.intellectualcrafters.plot.PlotWorld;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class Auto extends SubCommand { public class Auto extends SubCommand {
public Auto() { public Auto() {
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING);
CommandCategory.CLAIMING);
} }
// TODO auto claim a mega plot!!!!!!!!!!!! // TODO auto claim a mega plot!!!!!!!!!!!!
@ -38,10 +36,12 @@ public class Auto extends SubCommand {
String schematic = ""; String schematic = "";
if (PlotMain.getPlotWorlds().length == 1) { if (PlotMain.getPlotWorlds().length == 1) {
world = Bukkit.getWorld(PlotMain.getPlotWorlds()[0]); world = Bukkit.getWorld(PlotMain.getPlotWorlds()[0]);
} else { }
else {
if (PlotMain.isPlotWorld(plr.getWorld())) { if (PlotMain.isPlotWorld(plr.getWorld())) {
world = plr.getWorld(); world = plr.getWorld();
} else { }
else {
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
return false; return false;
} }
@ -61,20 +61,21 @@ public class Auto extends SubCommand {
if (args.length > 1) { if (args.length > 1) {
schematic = args[1]; schematic = args[1];
} }
} catch (Exception e) { }
catch (Exception e) {
schematic = args[0]; schematic = args[0];
// PlayerFunctions.sendMessage(plr, // PlayerFunctions.sendMessage(plr,
// "&cError: Invalid size (X,Y)"); // "&cError: Invalid size (X,Y)");
// return false; // return false;
} }
} else { }
else {
schematic = args[0]; schematic = args[0];
// PlayerFunctions.sendMessage(plr, C.NO_PERMISSION); // PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
// return false; // return false;
} }
} }
if (PlayerFunctions.getPlayerPlotCount(world, plr) >= PlayerFunctions if (PlayerFunctions.getPlayerPlotCount(world, plr) >= PlayerFunctions.getAllowedPlots(plr)) {
.getAllowedPlots(plr)) {
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
return false; return false;
} }
@ -95,14 +96,11 @@ public class Auto extends SubCommand {
if (!schematic.equals("")) { if (!schematic.equals("")) {
if (pWorld.SCHEMATIC_CLAIM_SPECIFY) { if (pWorld.SCHEMATIC_CLAIM_SPECIFY) {
if (pWorld.SCHEMATICS.contains(schematic.toLowerCase())) { if (pWorld.SCHEMATICS.contains(schematic.toLowerCase())) {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
+ schematic);
return true; return true;
} }
if (!plr.hasPermission("plots.claim." + schematic) if (!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) {
&& !plr.hasPermission("plots.admin")) { PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION,
schematic);
return true; return true;
} }
} }
@ -120,44 +118,49 @@ public class Auto extends SubCommand {
} }
if ((z < q) && ((z - x) < q)) { if ((z < q) && ((z - x) < q)) {
z++; 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) { while (!br) {
PlotId start = new PlotId(x, z); PlotId start = new PlotId(x, z);
PlotId end = new PlotId((x + size_x) - 1, (z + size_z) - 1); PlotId end = new PlotId((x + size_x) - 1, (z + size_z) - 1);
if (isUnowned(world, start, end)) { if (isUnowned(world, start, end)) {
for (int i = start.x; i <= end.x; i++) { for (int i = start.x; i <= end.x; i++) {
for (int j = start.y; j <= end.y; j++) { for (int j = start.y; j <= end.y; j++) {
Plot plot = PlotHelper.getPlot(world, new PlotId(i, Plot plot = PlotHelper.getPlot(world, new PlotId(i, j));
j));
boolean teleport = ((i == end.x) && (j == end.y)); boolean teleport = ((i == end.x) && (j == end.y));
Claim.claimPlot(plr, plot, teleport); Claim.claimPlot(plr, plot, teleport);
} }
} }
if (!PlotHelper.mergePlots(plr, world, PlayerFunctions if (!PlotHelper.mergePlots(plr, world, PlayerFunctions.getPlotSelectionIds(world, start, end))) {
.getPlotSelectionIds(world, start, end))) {
return false; return false;
} }
br = true; br = true;
} }
if ((z < q) && ((z - x) < q)) { if ((z < q) && ((z - x) < q)) {
z += size_z; 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; return true;

View File

@ -26,8 +26,7 @@ public class Camera extends SubCommand implements Listener {
private CameraAPI api; private CameraAPI api;
public Camera() { public Camera() {
super("camera", "plots.camera", "Go into camera mode", "camera", "c", super("camera", "plots.camera", "Go into camera mode", "camera", "c", CommandCategory.TELEPORT);
CommandCategory.TELEPORT);
this.api = CameraAPI.getInstance(); this.api = CameraAPI.getInstance();
this.travelers = new ArrayList<String>(); this.travelers = new ArrayList<String>();
} }
@ -48,8 +47,7 @@ public class Camera extends SubCommand implements Listener {
return true; return true;
} }
this.api.travel(getController(player, plot)); this.api.travel(getController(player, plot));
PlayerFunctions.sendMessage(player, C.CAMERA_STARTED, plot.getId().x PlayerFunctions.sendMessage(player, C.CAMERA_STARTED, plot.getId().x + ";" + plot.getId().y);
+ ";" + plot.getId().y);
this.travelers.add(player.getName()); this.travelers.add(player.getName());
return true; return true;
} }
@ -87,8 +85,7 @@ public class Camera extends SubCommand implements Listener {
loc4.setYaw(((2 / 4.0F) * 360.0F) - 0.5F); loc4.setYaw(((2 / 4.0F) * 360.0F) - 0.5F);
loc2.setYaw(((0 / 4.0F) * 360.0F) - 0.5F); loc2.setYaw(((0 / 4.0F) * 360.0F) - 0.5F);
loc5 = loc1.clone(); loc5 = loc1.clone();
CameraController controller = this.api.createController(player, CameraController controller = this.api.createController(player, seconds, loc1, loc2, loc3, loc4, loc5);
seconds, loc1, loc2, loc3, loc4, loc5);
return controller; return controller;
} }
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Claim.java * >> File = Claim.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -25,15 +24,12 @@ import com.intellectualcrafters.plot.SchematicHandler;
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent; import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
/** /**
*
* @author Citymonstret * @author Citymonstret
*
*/ */
public class Claim extends SubCommand { public class Claim extends SubCommand {
public Claim() { public Claim() {
super(Command.CLAIM, "Claim the current plot you're standing on.", super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING);
"claim", CommandCategory.CLAIMING);
} }
@Override @Override
@ -46,8 +42,7 @@ public class Claim extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT); PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
return true; return true;
} }
if (PlayerFunctions.getPlayerPlotCount(plr.getWorld(), plr) >= PlayerFunctions if (PlayerFunctions.getPlayerPlotCount(plr.getWorld(), plr) >= PlayerFunctions.getAllowedPlots(plr)) {
.getAllowedPlots(plr)) {
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS); PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
return true; return true;
} }
@ -72,14 +67,11 @@ public class Claim extends SubCommand {
if (!schematic.equals("")) { if (!schematic.equals("")) {
if (world.SCHEMATIC_CLAIM_SPECIFY) { if (world.SCHEMATIC_CLAIM_SPECIFY) {
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) { if (!world.SCHEMATICS.contains(schematic.toLowerCase())) {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
+ schematic);
return true; return true;
} }
if (!plr.hasPermission("plots.claim." + schematic) if (!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) {
&& !plr.hasPermission("plots.admin")) { PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION,
schematic);
return true; return true;
} }
} }
@ -97,8 +89,7 @@ public class Claim extends SubCommand {
return claimPlot(player, plot, teleport, ""); return claimPlot(player, plot, teleport, "");
} }
public static boolean claimPlot(Player player, Plot plot, boolean teleport, public static boolean claimPlot(Player player, Plot plot, boolean teleport, String schematic) {
String schematic) {
PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot); PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
@ -114,7 +105,8 @@ public class Claim extends SubCommand {
SchematicHandler.Schematic sch; SchematicHandler.Schematic sch;
if (schematic.equals("")) { if (schematic.equals("")) {
sch = handler.getSchematic(world.SCHEMATIC_FILE); sch = handler.getSchematic(world.SCHEMATIC_FILE);
} else { }
else {
sch = handler.getSchematic(schematic); sch = handler.getSchematic(schematic);
if (sch == null) { if (sch == null) {
sch = handler.getSchematic(world.SCHEMATIC_FILE); sch = handler.getSchematic(world.SCHEMATIC_FILE);
@ -122,8 +114,7 @@ public class Claim extends SubCommand {
} }
handler.paste(player.getLocation(), sch, plot); handler.paste(player.getLocation(), sch, plot);
} }
plot.settings.setFlags(FlagManager.parseFlags(PlotMain plot.settings.setFlags(FlagManager.parseFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS));
.getWorldSettings(player.getWorld()).DEFAULT_FLAGS));
} }
return event.isCancelled(); return event.isCancelled();
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Clear.java * >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -31,8 +30,7 @@ public class Clear extends SubCommand {
return false; return false;
} }
Plot plot = PlayerFunctions.getCurrentPlot(plr); Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals( if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))
plr.getUniqueId()))
&& !plr.hasPermission("plots.admin")) { && !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Command.java * >> File = Command.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -108,7 +107,6 @@ public enum Command {
private CommandPermission permission; private CommandPermission permission;
/** /**
*
* @param command * @param command
*/ */
Command(String command) { Command(String command) {
@ -118,7 +116,6 @@ public enum Command {
} }
/** /**
*
* @param command * @param command
* @param permission * @param permission
*/ */
@ -129,7 +126,6 @@ public enum Command {
} }
/** /**
*
* @param command * @param command
* @param alias * @param alias
*/ */
@ -140,7 +136,6 @@ public enum Command {
} }
/** /**
*
* @param Command * @param Command
* @param alias * @param alias
* @param permission * @param permission
@ -152,7 +147,6 @@ public enum Command {
} }
/** /**
*
* @return * @return
*/ */
public String getCommand() { public String getCommand() {
@ -160,7 +154,6 @@ public enum Command {
} }
/** /**
*
* @return * @return
*/ */
public String getAlias() { public String getAlias() {
@ -168,7 +161,6 @@ public enum Command {
} }
/** /**
*
* @return * @return
*/ */
public CommandPermission getPermission() { public CommandPermission getPermission() {

View File

@ -1,10 +1,10 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = CommandPermission.java * >> File = CommandPermission.java >> Generated by: Citymonstret at 2014-08-09
* >> Generated by: Citymonstret at 2014-08-09 01:41 * 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -31,12 +31,10 @@ public class CommandPermission {
} }
/** /**
*
* @param player * @param player
* @return * @return
*/ */
public boolean hasPermission(Player player) { public boolean hasPermission(Player player) {
return player.hasPermission(this.permission) return player.hasPermission(this.permission) || player.hasPermission("plots.admin");
|| player.hasPermission("plots.admin");
} }
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Clear.java * >> File = Clear.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -31,8 +30,7 @@ public class Copy extends SubCommand {
return false; return false;
} }
Plot plot = PlayerFunctions.getCurrentPlot(plr); Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals( if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))
plr.getUniqueId()))
&& !plr.hasPermission("plots.admin")) { && !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Debug.java * >> File = Debug.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -34,8 +33,7 @@ public class Debug extends SubCommand {
// private extends SubCommand^Implements {Command, Information} from // private extends SubCommand^Implements {Command, Information} from
// >>\\S.txt6\\ // >>\\S.txt6\\
public Debug() { public Debug() {
super(Command.DEBUG, "Show debug information", "debug [msg]", super(Command.DEBUG, "Show debug information", "debug [msg]", CommandCategory.INFO);
CommandCategory.INFO);
{ {
/** /**
* This. * This.
@ -82,36 +80,25 @@ public class Debug extends SubCommand {
information.append(header); information.append(header);
information.append(getSection(section, "Lag / TPS")); information.append(getSection(section, "Lag / TPS"));
information.append(getLine(line, "Ticks Per Second", Lag.getTPS())); information.append(getLine(line, "Ticks Per Second", Lag.getTPS()));
information.append(getLine(line, "Lag Percentage", information.append(getLine(line, "Lag Percentage", (int) Lag.getPercentage() + "%"));
(int) Lag.getPercentage() + "%")); information.append(getLine(line, "TPS Percentage", (int) Lag.getFullPercentage() + "%"));
information.append(getLine(line, "TPS Percentage",
(int) Lag.getFullPercentage() + "%"));
information.append(getSection(section, "PlotWorld")); information.append(getSection(section, "PlotWorld"));
information.append(getLine(line, "Plot Worlds", worlds)); information.append(getLine(line, "Plot Worlds", worlds));
information.append(getLine(line, "Owned Plots", PlotMain.getPlots() information.append(getLine(line, "Owned Plots", PlotMain.getPlots().size()));
.size()));
// information.append(getLine(line, "PlotWorld Size", // information.append(getLine(line, "PlotWorld Size",
// PlotHelper.getWorldFolderSize() + "MB")); // PlotHelper.getWorldFolderSize() + "MB"));
for (String world : PlotMain.getPlotWorlds()) { for (String world : PlotMain.getPlotWorlds()) {
information.append(getLine(line, "World: " + world + " size", information.append(getLine(line, "World: " + world + " size", PlotHelper.getWorldFolderSize(Bukkit.getWorld(world))));
PlotHelper.getWorldFolderSize(Bukkit.getWorld(world))));
} }
information.append(getLine(line, "Entities", information.append(getLine(line, "Entities", PlotHelper.getEntities(plr.getWorld())));
PlotHelper.getEntities(plr.getWorld()))); information.append(getLine(line, "Loaded Tile Entities", PlotHelper.getTileEntities(plr.getWorld())));
information.append(getLine(line, "Loaded Tile Entities", information.append(getLine(line, "Loaded Chunks", PlotHelper.getLoadedChunks(plr.getWorld())));
PlotHelper.getTileEntities(plr.getWorld())));
information.append(getLine(line, "Loaded Chunks",
PlotHelper.getLoadedChunks(plr.getWorld())));
information.append(getSection(section, "RAM")); information.append(getSection(section, "RAM"));
information.append(getLine(line, "Free Ram", RUtils.getFreeRam() information.append(getLine(line, "Free Ram", RUtils.getFreeRam() + "MB"));
+ "MB")); information.append(getLine(line, "Total Ram", RUtils.getTotalRam() + "MB"));
information.append(getLine(line, "Total Ram", RUtils.getTotalRam()
+ "MB"));
information.append(getSection(section, "Messages")); information.append(getSection(section, "Messages"));
information.append(getLine(line, "Total Messages", information.append(getLine(line, "Total Messages", C.values().length));
C.values().length)); information.append(getLine(line, "View all captions", "/plot debug msg"));
information.append(getLine(line, "View all captions",
"/plot debug msg"));
} }
/** /**
* {function:: SEND_MESSAGE |local player -> plr|local string -> * {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) { private String getLine(String line, String var, Object val) {
return line.replaceAll("%var%", var).replaceAll("%val%", "" + val) return line.replaceAll("%var%", var).replaceAll("%val%", "" + val) + "\n";
+ "\n";
} }
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Delete.java * >> File = Delete.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -27,8 +26,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
public class Delete extends SubCommand { public class Delete extends SubCommand {
public Delete() { public Delete() {
super(Command.DELETE, "Delete a plot", "delete", super(Command.DELETE, "Delete a plot", "delete", CommandCategory.ACTIONS);
CommandCategory.ACTIONS);
} }
@Override @Override
@ -38,13 +36,11 @@ public class Delete extends SubCommand {
return false; return false;
} }
Plot plot = PlayerFunctions.getCurrentPlot(plr); Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals( if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED); PlayerFunctions.sendMessage(plr, C.UNLINK_REQUIRED);
return false; return false;
} }
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals( if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())))
plr.getUniqueId())))
&& !plr.hasPermission("plots.admin")) { && !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;
@ -58,13 +54,13 @@ public class Delete extends SubCommand {
sendMessage(plr, C.ADDED_BALANCE, c + ""); sendMessage(plr, C.ADDED_BALANCE, c + "");
} }
} }
boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id, true);
true);
if (result) { if (result) {
PlotHelper.removeSign(plr, plot); PlotHelper.removeSign(plr, plot);
plot.clear(plr); plot.clear(plr);
DBFunc.delete(plr.getWorld().getName(), plot); DBFunc.delete(plr.getWorld().getName(), plot);
} else { }
else {
PlayerFunctions.sendMessage(plr, "Plot clearing has been denied."); PlayerFunctions.sendMessage(plr, "Plot clearing has been denied.");
} }
return true; return true;

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Denied.java * >> File = Denied.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -28,8 +27,7 @@ import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent;
public class Denied extends SubCommand { public class Denied extends SubCommand {
public Denied() { public Denied() {
super(Command.DENIED, "Manage plot helpers", super(Command.DENIED, "Manage plot helpers", "denied {add|remove} {player}", CommandCategory.ACTIONS);
"denied {add|remove} {player}", CommandCategory.ACTIONS);
} }
@Override @Override
@ -51,8 +49,7 @@ public class Denied extends SubCommand {
if (args[1].equalsIgnoreCase("*")) { if (args[1].equalsIgnoreCase("*")) {
UUID uuid = DBFunc.everyone; UUID uuid = DBFunc.everyone;
plot.addDenied(uuid); plot.addDenied(uuid);
DBFunc.setDenied(plr.getWorld().getName(), plot, DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
Bukkit.getOfflinePlayer(args[1]));
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED); PlayerFunctions.sendMessage(plr, C.DENIED_ADDED);
return true; return true;
} }
@ -67,60 +64,54 @@ public class Denied extends SubCommand {
*/ */
UUID uuid = UUIDHandler.getUUID(args[1]); UUID uuid = UUIDHandler.getUUID(args[1]);
plot.addDenied(uuid); plot.addDenied(uuid);
DBFunc.setDenied(plr.getWorld().getName(), plot, DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
Bukkit.getOfflinePlayer(args[1])); PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true);
PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot,
uuid, true);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED); PlayerFunctions.sendMessage(plr, C.DENIED_ADDED);
if ((Bukkit.getPlayer(uuid) != null) if ((Bukkit.getPlayer(uuid) != null) && Bukkit.getPlayer(uuid).isOnline()) {
&& Bukkit.getPlayer(uuid).isOnline()) { Plot pl = PlayerFunctions.getCurrentPlot(Bukkit.getPlayer((uuid)));
Plot pl = PlayerFunctions.getCurrentPlot(Bukkit
.getPlayer((uuid)));
if (pl.id == plot.id) { if (pl.id == plot.id) {
PlayerFunctions.sendMessage(Bukkit.getPlayer(uuid), PlayerFunctions.sendMessage(Bukkit.getPlayer(uuid), C.YOU_BE_DENIED);
C.YOU_BE_DENIED); Bukkit.getPlayer(uuid).teleport(Bukkit.getPlayer(uuid).getWorld().getSpawnLocation());
Bukkit.getPlayer(uuid).teleport(
Bukkit.getPlayer(uuid).getWorld()
.getSpawnLocation());
} }
} }
} else if (args[0].equalsIgnoreCase("remove")) { }
if (args[1].equalsIgnoreCase("*")) { else
UUID uuid = DBFunc.everyone; if (args[0].equalsIgnoreCase("remove")) {
if (!plot.denied.contains(uuid)) { if (args[1].equalsIgnoreCase("*")) {
PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); 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; 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); plot.removeDenied(uuid);
DBFunc.removeDenied(plr.getWorld().getName(), plot, DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
Bukkit.getOfflinePlayer(args[1])); PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, false);
Bukkit.getPluginManager().callEvent(event);
PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED); PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED);
}
else {
PlayerFunctions.sendMessage(plr, C.DENIED_NEED_ARGUMENT);
return true; 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; return true;
} }
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Help.java * >> File = Help.java >> Generated by: Citymonstret at 2014-08-11 17:32
* >> Generated by: Citymonstret at 2014-08-11 17:32
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -16,8 +15,7 @@ import org.bukkit.entity.Player;
*/ */
public class Help extends SubCommand { public class Help extends SubCommand {
public Help() { public Help() {
super("help", "", "Get this help menu", "help", "he", super("help", "", "Get this help menu", "help", "he", SubCommand.CommandCategory.INFO);
SubCommand.CommandCategory.INFO);
} }
@Override @Override

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Helpers.java * >> File = Helpers.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -25,8 +24,7 @@ import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent;
public class Helpers extends SubCommand { public class Helpers extends SubCommand {
public Helpers() { public Helpers() {
super(Command.HELPERS, "Manage plot helpers", super(Command.HELPERS, "Manage plot helpers", "helpers {add|remove} {player}", CommandCategory.ACTIONS);
"helpers {add|remove} {player}", CommandCategory.ACTIONS);
} }
@Override @Override
@ -48,8 +46,7 @@ public class Helpers extends SubCommand {
if (args[1].equalsIgnoreCase("*")) { if (args[1].equalsIgnoreCase("*")) {
UUID uuid = DBFunc.everyone; UUID uuid = DBFunc.everyone;
plot.addHelper(uuid); plot.addHelper(uuid);
DBFunc.setHelper(plr.getWorld().getName(), plot, DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
Bukkit.getOfflinePlayer(args[1]));
PlayerFunctions.sendMessage(plr, C.HELPER_ADDED); PlayerFunctions.sendMessage(plr, C.HELPER_ADDED);
return true; return true;
} }
@ -64,48 +61,48 @@ public class Helpers extends SubCommand {
*/ */
UUID uuid = UUIDHandler.getUUID(args[1]); UUID uuid = UUIDHandler.getUUID(args[1]);
plot.addHelper(uuid); plot.addHelper(uuid);
DBFunc.setHelper(plr.getWorld().getName(), plot, DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
Bukkit.getOfflinePlayer(args[1])); PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true);
PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot,
uuid, true);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
PlayerFunctions.sendMessage(plr, C.HELPER_ADDED); PlayerFunctions.sendMessage(plr, C.HELPER_ADDED);
} else if (args[0].equalsIgnoreCase("remove")) { }
if (args[1].equalsIgnoreCase("*")) { else
UUID uuid = DBFunc.everyone; if (args[0].equalsIgnoreCase("remove")) {
if (!plot.helpers.contains(uuid)) { if (args[1].equalsIgnoreCase("*")) {
PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED); 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; 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); plot.removeHelper(uuid);
DBFunc.removeHelper(plr.getWorld().getName(), plot, DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
Bukkit.getOfflinePlayer(args[1])); PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, false);
Bukkit.getPluginManager().callEvent(event);
PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED); PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED);
}
else {
PlayerFunctions.sendMessage(plr, C.HELPER_NEED_ARGUMENT);
return true; 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; return true;
} }
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Home.java * >> File = Home.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -17,21 +16,17 @@ import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
/** /**
*
* @author Citymonstret * @author Citymonstret
*
*/ */
public class Home extends SubCommand { public class Home extends SubCommand {
public Home() { public Home() {
super(Command.HOME, "Go to your plot", "home {id|alias}", super(Command.HOME, "Go to your plot", "home {id|alias}", CommandCategory.TELEPORT);
CommandCategory.TELEPORT);
} }
private Plot isAlias(String a) { private Plot isAlias(String a) {
for (Plot p : PlotMain.getPlots()) { for (Plot p : PlotMain.getPlots()) {
if ((p.settings.getAlias().length() > 0) if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) {
&& p.settings.getAlias().equalsIgnoreCase(a)) {
return p; return p;
} }
} }
@ -44,38 +39,41 @@ public class Home extends SubCommand {
if (plots.length == 1) { if (plots.length == 1) {
PlotMain.teleportPlayer(plr, plr.getLocation(), plots[0]); PlotMain.teleportPlayer(plr, plr.getLocation(), plots[0]);
return true; return true;
} else if (plots.length > 1) { }
if (args.length < 1) { else
args = new String[] { "1" }; if (plots.length > 1) {
} if (args.length < 1) {
int id = 0; args = new String[] { "1" };
try { }
id = Integer.parseInt(args[0]); int id = 0;
} catch (Exception e) { try {
Plot temp; id = Integer.parseInt(args[0]);
if ((temp = isAlias(args[0])) != null) { }
if (temp.hasOwner()) { catch (Exception e) {
if (temp.getOwner().equals(plr.getUniqueId())) { Plot temp;
PlotMain.teleportPlayer(plr, plr.getLocation(), if ((temp = isAlias(args[0])) != null) {
temp); if (temp.hasOwner()) {
return true; 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; return false;
} }
PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); PlotMain.teleportPlayer(plr, plr.getLocation(), plots[id - 1]);
return true; return true;
} }
if ((id > (plots.length)) || (id < 1)) { else {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); PlayerFunctions.sendMessage(plr, C.NO_PLOTS);
return false; return true;
} }
PlotMain.teleportPlayer(plr, plr.getLocation(), plots[id - 1]);
return true;
} else {
PlayerFunctions.sendMessage(plr, C.NO_PLOTS);
return true;
}
} }
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Info.java * >> File = Info.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -27,9 +26,7 @@ import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
/** /**
*
* @author Citymonstret * @author Citymonstret
*
*/ */
public class Info extends SubCommand { public class Info extends SubCommand {
@ -55,20 +52,21 @@ public class Info extends SubCommand {
{ {
if (plot.helpers == null) { if (plot.helpers == null) {
containsEveryone = false; containsEveryone = false;
} else { }
else {
containsEveryone = plot.helpers.contains(DBFunc.everyone); containsEveryone = plot.helpers.contains(DBFunc.everyone);
} }
if (plot.trusted == null) { if (plot.trusted == null) {
trustedEveryone = false; trustedEveryone = false;
} else { }
else {
trustedEveryone = plot.trusted.contains(DBFunc.everyone); trustedEveryone = plot.trusted.contains(DBFunc.everyone);
} }
} }
// Unclaimed? // Unclaimed?
if (!hasOwner && !containsEveryone && !trustedEveryone) { if (!hasOwner && !containsEveryone && !trustedEveryone) {
PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, plot.id.x + ";" + plot.id.y);
plot.id.x + ";" + plot.id.y);
return true; return true;
} }
@ -83,27 +81,19 @@ public class Info extends SubCommand {
} }
String info = C.PLOT_INFO.s(); String info = C.PLOT_INFO.s();
info = info.replaceAll( info = info.replaceAll("%alias%", plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none");
"%alias%",
plot.settings.getAlias().length() > 0 ? plot.settings
.getAlias() : "none");
info = info.replaceAll("%id%", plot.id.toString()); info = info.replaceAll("%id%", plot.id.toString());
info = info.replaceAll("%biome%", getBiomeAt(plot).toString()); info = info.replaceAll("%biome%", getBiomeAt(plot).toString());
info = info.replaceAll("%owner%", owner); info = info.replaceAll("%owner%", owner);
info = info.replaceAll("%time%", info = info.replaceAll("%time%", plot.settings.getChangeTime() ? plot.settings.getTime() + "" : "default");
plot.settings.getChangeTime() ? plot.settings.getTime() + "" info = info.replaceAll("%weather%", plot.settings.getRain() ? "rain" : "default");
: "default");
info = info.replaceAll("%weather%", plot.settings.getRain() ? "rain"
: "default");
info = info.replaceAll("%helpers%", getPlayerList(plot.helpers)); info = info.replaceAll("%helpers%", getPlayerList(plot.helpers));
info = info.replaceAll("%trusted%", getPlayerList(plot.trusted)); info = info.replaceAll("%trusted%", getPlayerList(plot.trusted));
info = info.replaceAll("%denied%", getPlayerList(plot.denied)); info = info.replaceAll("%denied%", getPlayerList(plot.denied));
info = info.replaceAll("%rating%", "" + DBFunc.getRatings(plot)); info = info.replaceAll("%rating%", "" + DBFunc.getRatings(plot));
info = info info =
.replaceAll( info.replaceAll("%flags%", StringUtils.join(plot.settings.getFlags(), "").length() > 0
"%flags%", ? StringUtils.join(plot.settings.getFlags(), ",") : "none");
StringUtils.join(plot.settings.getFlags(), "").length() > 0 ? StringUtils
.join(plot.settings.getFlags(), ",") : "none");
// PlayerFunctions.sendMessage(player, // PlayerFunctions.sendMessage(player,
// PlayerFunctions.getTopPlot(player.getWorld(), plot).id.toString()); // PlayerFunctions.getTopPlot(player.getWorld(), plot).id.toString());
// PlayerFunctions.sendMessage(player, // PlayerFunctions.sendMessage(player,
@ -121,9 +111,9 @@ public class Info extends SubCommand {
StringBuilder list = new StringBuilder(); StringBuilder list = new StringBuilder();
for (int x = 0; x < l.size(); x++) { for (int x = 0; x < l.size(); x++) {
if ((x + 1) == l.size()) { if ((x + 1) == l.size()) {
list.append(c.replace("%user%", getPlayerName(l.get(x))) list.append(c.replace("%user%", getPlayerName(l.get(x))).replace(",", ""));
.replace(",", "")); }
} else { else {
list.append(c.replace("%user%", getPlayerName(l.get(x)))); list.append(c.replace("%user%", getPlayerName(l.get(x))));
} }
} }
@ -134,8 +124,7 @@ public class Info extends SubCommand {
if (uuid == null) { if (uuid == null) {
return "unknown"; return "unknown";
} }
if (uuid.equals(DBFunc.everyone) if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) {
|| uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) {
return "everyone"; return "everyone";
} }
/* /*

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Inventory.java * >> File = Inventory.java >> Generated by: Citymonstret at 2014-08-10 13:57
* >> Generated by: Citymonstret at 2014-08-10 13:57
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -21,8 +20,7 @@ import org.bukkit.inventory.meta.ItemMeta;
public class Inventory extends SubCommand { public class Inventory extends SubCommand {
public Inventory() { public Inventory() {
super("inventory", "plots.inventory", "Open a command inventory", super("inventory", "plots.inventory", "Open a command inventory", "inventory", "inv", CommandCategory.INFO);
"inventory", "inv", CommandCategory.INFO);
} }
@Override @Override
@ -34,8 +32,7 @@ public class Inventory extends SubCommand {
} }
} }
int size = 9 * (int) Math.ceil(cmds.size() / 9.0); int size = 9 * (int) Math.ceil(cmds.size() / 9.0);
org.bukkit.inventory.Inventory inventory = Bukkit.createInventory(null, org.bukkit.inventory.Inventory inventory = Bukkit.createInventory(null, size, "PlotSquared Commands");
size, "PlotSquared Commands");
for (SubCommand cmd : cmds) { for (SubCommand cmd : cmds) {
inventory.addItem(getItem(cmd)); inventory.addItem(getItem(cmd));
} }
@ -47,17 +44,13 @@ public class Inventory extends SubCommand {
ItemStack stack = new ItemStack(Material.COMMAND); ItemStack stack = new ItemStack(Material.COMMAND);
ItemMeta meta = stack.getItemMeta(); ItemMeta meta = stack.getItemMeta();
{ {
meta.setDisplayName(ChatColor.GREEN + cmd.cmd + ChatColor.DARK_GRAY meta.setDisplayName(ChatColor.GREEN + cmd.cmd + ChatColor.DARK_GRAY + " [" + ChatColor.GREEN + cmd.alias
+ " [" + ChatColor.GREEN + cmd.alias + ChatColor.DARK_GRAY + ChatColor.DARK_GRAY + "]");
+ "]");
meta.setLore(new ArrayList<String>() { meta.setLore(new ArrayList<String>() {
{ {
add(ChatColor.RED + "Category: " + ChatColor.GOLD add(ChatColor.RED + "Category: " + ChatColor.GOLD + cmd.category.toString());
+ cmd.category.toString()); add(ChatColor.RED + "Description: " + ChatColor.GOLD + cmd.description);
add(ChatColor.RED + "Description: " + ChatColor.GOLD add(ChatColor.RED + "Usage: " + ChatColor.GOLD + "/plot " + cmd.usage);
+ cmd.description);
add(ChatColor.RED + "Usage: " + ChatColor.GOLD + "/plot "
+ cmd.usage);
} }
}); });
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Kick.java * >> File = Kick.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -22,8 +21,7 @@ import com.intellectualcrafters.plot.Plot;
public class Kick extends SubCommand { public class Kick extends SubCommand {
public Kick() { public Kick() {
super(Command.KICK, "Kick a player from your plot", "kick", super(Command.KICK, "Kick a player from your plot", "kick", CommandCategory.ACTIONS);
CommandCategory.ACTIONS);
} }
@Override @Override
@ -33,8 +31,7 @@ public class Kick extends SubCommand {
return false; return false;
} }
Plot plot = PlayerFunctions.getCurrentPlot(plr); Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals( if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))
plr.getUniqueId()))
&& !plr.hasPermission("plots.admin")) { && !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;
@ -44,17 +41,14 @@ public class Kick extends SubCommand {
return false; return false;
} }
if (Bukkit.getPlayer(args[0]) != null) { if (Bukkit.getPlayer(args[0]) != null) {
PlayerFunctions.sendMessage(plr, PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
return false; return false;
} }
Player player = Bukkit.getPlayer(args[0]); Player player = Bukkit.getPlayer(args[0]);
if (!player.getWorld().equals(plr.getWorld()) if (!player.getWorld().equals(plr.getWorld()) || !PlayerFunctions.isInPlot(player)
|| !PlayerFunctions.isInPlot(player)
|| (PlayerFunctions.getCurrentPlot(player) == null) || (PlayerFunctions.getCurrentPlot(player) == null)
|| !PlayerFunctions.getCurrentPlot(player).equals(plot)) { || !PlayerFunctions.getCurrentPlot(player).equals(plot)) {
PlayerFunctions.sendMessage(plr, PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
return false; return false;
} }
player.teleport(player.getWorld().getSpawnLocation()); player.teleport(player.getWorld().getSpawnLocation());

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = MainCommand.java * >> File = MainCommand.java >> Generated by: Citymonstret at 2014-08-09 01:42
* >> Generated by: Citymonstret at 2014-08-09 01:42
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -26,15 +25,12 @@ import com.intellectualcrafters.plot.PlotMain;
* PlotMain command class * PlotMain command class
* *
* @author Citymonstret * @author Citymonstret
*
*/ */
public class MainCommand implements CommandExecutor { public class MainCommand implements CommandExecutor {
private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Auto(), new Home(), new Visit(),
new Auto(), new Home(), new Visit(), new TP(), new Set(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(),
new Clear(), new Delete(), new SetOwner(), new Denied(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(),
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() }; new Reload(), new Merge(), new Unlink(), new Kick(), new Setup() };
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() { public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
@ -49,16 +45,15 @@ public class MainCommand implements CommandExecutor {
} }
@Override @Override
public boolean onCommand(CommandSender sender, Command cmd, public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
String commandLabel, String[] args) {
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
if (args.length > 0) { if (args.length > 0) {
if (args[0].equalsIgnoreCase("reload")) { if (args[0].equalsIgnoreCase("reload")) {
new Reload().executeConsole(args); new Reload().executeConsole(args);
} }
} else { }
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() else {
+ C.HELP_HEADER.s()); PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + C.HELP_HEADER.s());
PlotMain.sendConsoleSenderMessage("&6/plots reload &c-&6 reloads the plugin"); PlotMain.sendConsoleSenderMessage("&6/plots reload &c-&6 reloads the plugin");
} }
return false; return false;
@ -68,28 +63,20 @@ public class MainCommand implements CommandExecutor {
return no_permission(player); return no_permission(player);
} }
if ((args.length < 1) if ((args.length < 1)
|| ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0] || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) {
.equalsIgnoreCase("he")))) {
if (args.length < 2) { if (args.length < 2) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(C.HELP_INFO.s()); builder.append(C.HELP_INFO.s());
for (SubCommand.CommandCategory category : SubCommand.CommandCategory for (SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) {
.values()) {
builder.append("\n" builder.append("\n"
+ C.HELP_INFO_ITEM + C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
.s()
.replaceAll("%category%",
category.toString().toLowerCase())
.replaceAll("%category_desc%",
category.toString()));
} }
PlayerFunctions.sendMessage(player, builder.toString()); PlayerFunctions.sendMessage(player, builder.toString());
return true; return true;
} }
String cat = args[1]; String cat = args[1];
SubCommand.CommandCategory cato = null; SubCommand.CommandCategory cato = null;
for (SubCommand.CommandCategory category : SubCommand.CommandCategory for (SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) {
.values()) {
if (cat.equalsIgnoreCase(category.toString())) { if (cat.equalsIgnoreCase(category.toString())) {
cato = category; cato = category;
break; break;
@ -98,15 +85,9 @@ public class MainCommand implements CommandExecutor {
if (cato == null) { if (cato == null) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(C.HELP_INFO.s()); builder.append(C.HELP_INFO.s());
for (SubCommand.CommandCategory category : SubCommand.CommandCategory for (SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) {
.values()) {
builder.append("\n" builder.append("\n"
+ C.HELP_INFO_ITEM + C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
.s()
.replaceAll("%category%",
category.toString().toLowerCase())
.replaceAll("%category_desc%",
category.toString()));
} }
PlayerFunctions.sendMessage(player, builder.toString()); PlayerFunctions.sendMessage(player, builder.toString());
return true; return true;
@ -117,17 +98,18 @@ public class MainCommand implements CommandExecutor {
} }
PlayerFunctions.sendMessage(player, help.toString()); PlayerFunctions.sendMessage(player, help.toString());
return true; return true;
} else { }
else {
for (SubCommand command : subCommands) { for (SubCommand command : subCommands) {
if (command.cmd.equalsIgnoreCase(args[0]) if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.equalsIgnoreCase(args[0])) {
|| command.alias.equalsIgnoreCase(args[0])) {
String[] arguments = new String[args.length - 1]; String[] arguments = new String[args.length - 1];
for (int x = 1; x < args.length; x++) { for (int x = 1; x < args.length; x++) {
arguments[x - 1] = args[x]; arguments[x - 1] = args[x];
} }
if (command.permission.hasPermission(player)) { if (command.permission.hasPermission(player)) {
return command.execute(player, arguments); return command.execute(player, arguments);
} else { }
else {
return no_permission(player); return no_permission(player);
} }
} }
@ -137,23 +119,18 @@ public class MainCommand implements CommandExecutor {
return false; return false;
} }
public static ArrayList<String> helpMenu(Player player, public static ArrayList<String> helpMenu(Player player, final SubCommand.CommandCategory category) {
final SubCommand.CommandCategory category) {
ArrayList<String> help = new ArrayList<String>() { ArrayList<String> help = new ArrayList<String>() {
{ {
add(t(C.HELP_HEADER.s())); add(t(C.HELP_HEADER.s()));
add(t(C.HELP_CATEGORY.s().replaceAll("%category%", add(t(C.HELP_CATEGORY.s().replaceAll("%category%", category.toString())));
category.toString())));
} }
}; };
for (SubCommand cmd : subCommands) { for (SubCommand cmd : subCommands) {
if (cmd.permission.hasPermission(player) if (cmd.permission.hasPermission(player) && (cmd.category == category)) {
&& (cmd.category == category)) {
String s = t(C.HELP_PAGE.s()); String s = t(C.HELP_PAGE.s());
s = s.replaceAll("%alias%", cmd.alias); s = s.replaceAll("%alias%", cmd.alias);
s = s.replaceAll("%usage%", s = s.replaceAll("%usage%", cmd.usage.contains("plot") ? cmd.usage : "/plot " + cmd.usage);
cmd.usage.contains("plot") ? cmd.usage : "/plot "
+ cmd.usage);
s = s.replaceAll("%cmd%", cmd.cmd); s = s.replaceAll("%cmd%", cmd.cmd);
s = s.replaceAll("%desc%", cmd.description); s = s.replaceAll("%desc%", cmd.description);
help.add(s); help.add(s);

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Merge.java * >> File = Merge.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -29,20 +28,15 @@ import com.intellectualcrafters.plot.SetBlockFast;
import com.intellectualcrafters.plot.events.PlotMergeEvent; import com.intellectualcrafters.plot.events.PlotMergeEvent;
/** /**
*
* @author Citymonstret * @author Citymonstret
*
*/ */
public class Merge extends SubCommand { public class Merge extends SubCommand {
public static String[] values = new String[] { "north", "east", "south", public static String[] values = new String[] { "north", "east", "south", "west" };
"west" };
public static String[] aliases = new String[] { "n", "e", "s", "w" }; public static String[] aliases = new String[] { "n", "e", "s", "w" };
public Merge() { public Merge() {
super(Command.MERGE, super(Command.MERGE, "Merge the plot you are standing on with another plot.", "merge", CommandCategory.ACTIONS);
"Merge the plot you are standing on with another plot.",
"merge", CommandCategory.ACTIONS);
} }
public static String direction(float yaw) { public static String direction(float yaw) {
@ -83,35 +77,22 @@ public class Merge extends SubCommand {
return false; return false;
} }
if (args.length < 1) { if (args.length < 1) {
PlayerFunctions.sendMessage( PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s()
plr, + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s()));
C.SUBCOMMAND_SET_OPTIONS_HEADER.s() PlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw())));
+ StringUtils.join(values,
C.BLOCK_LIST_SEPARATER.s()));
PlayerFunctions.sendMessage(
plr,
C.DIRECTION.s().replaceAll("%dir%",
direction(plr.getLocation().getYaw())));
return false; return false;
} }
int direction = -1; int direction = -1;
for (int i = 0; i < values.length; i++) { for (int i = 0; i < values.length; i++) {
if (args[0].equalsIgnoreCase(values[i]) if (args[0].equalsIgnoreCase(values[i]) || args[0].equalsIgnoreCase(aliases[i])) {
|| args[0].equalsIgnoreCase(aliases[i])) {
direction = i; direction = i;
break; break;
} }
} }
if (direction == -1) { if (direction == -1) {
PlayerFunctions.sendMessage( PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s()
plr, + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s()));
C.SUBCOMMAND_SET_OPTIONS_HEADER.s() PlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw())));
+ StringUtils.join(values,
C.BLOCK_LIST_SEPARATER.s()));
PlayerFunctions.sendMessage(
plr,
C.DIRECTION.s().replaceAll("%dir%",
direction(plr.getLocation().getYaw())));
return false; return false;
} }
World world = plr.getWorld(); World world = plr.getWorld();
@ -120,30 +101,28 @@ public class Merge extends SubCommand {
ArrayList<PlotId> plots; ArrayList<PlotId> plots;
switch (direction) { switch (direction) {
case 0: // north = -y case 0: // north = -y
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), plots =
new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y)); PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
break; break;
case 1: // east = +x case 1: // east = +x
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), plots =
new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y)); PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
break; break;
case 2: // south = +y case 2: // south = +y
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), plots =
new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1)); PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
break; break;
case 3: // west = -x case 3: // west = -x
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), plots =
new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y)); PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
break; break;
default: default:
return false; return false;
} }
for (PlotId myid : plots) { for (PlotId myid : plots) {
Plot myplot = PlotMain.getPlots(world).get(myid); Plot myplot = PlotMain.getPlots(world).get(myid);
if ((myplot == null) || !myplot.hasOwner() if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(plr.getUniqueId()))) {
|| !(myplot.getOwner().equals(plr.getUniqueId()))) { PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s()
.replaceAll("%plot%", myid.toString()));
return false; return false;
} }
} }

View File

@ -17,8 +17,7 @@ public class Rate extends SubCommand {
*/ */
public Rate() { public Rate() {
super("rate", "plots.rate", "Rate the plot", "rate {0-10}", "rt", super("rate", "plots.rate", "Rate the plot", "rate {0-10}", "rt", CommandCategory.ACTIONS);
CommandCategory.ACTIONS);
} }
@Override @Override
@ -65,7 +64,8 @@ public class Rate extends SubCommand {
boolean success = false; boolean success = false;
if (success) { if (success) {
sendMessage(plr, C.RATING_APPLIED, plot.getId().toString()); sendMessage(plr, C.RATING_APPLIED, plot.getId().toString());
} else { }
else {
sendMessage(plr, C.COMMAND_WENT_WRONG); sendMessage(plr, C.COMMAND_WENT_WRONG);
} }
return true; return true;

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Reload.java * >> File = Reload.java >> Generated by: Citymonstret at 2014-08-09 01:42
* >> Generated by: Citymonstret at 2014-08-09 01:42
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -21,8 +20,7 @@ import com.intellectualcrafters.plot.PlotMain;
public class Reload extends SubCommand { public class Reload extends SubCommand {
public Reload() { public Reload() {
super("reload", "plots.admin", "Reload configurations", "", "reload", super("reload", "plots.admin", "Reload configurations", "", "reload", CommandCategory.INFO);
CommandCategory.INFO);
} }
@Override @Override
@ -30,10 +28,12 @@ public class Reload extends SubCommand {
try { try {
PlotMain.reloadTranslations(); PlotMain.reloadTranslations();
PlotMain.BroadcastWithPerms(C.RELOADED_CONFIGS); PlotMain.BroadcastWithPerms(C.RELOADED_CONFIGS);
} catch (Exception e) { }
catch (Exception e) {
if (plr != null) { if (plr != null) {
PlayerFunctions.sendMessage(plr, C.RELOAD_FAILED); PlayerFunctions.sendMessage(plr, C.RELOAD_FAILED);
} else { }
else {
PlotMain.sendConsoleSenderMessage(C.RELOAD_FAILED); PlotMain.sendConsoleSenderMessage(C.RELOAD_FAILED);
} }
} }

View File

@ -11,8 +11,7 @@ import com.intellectualcrafters.plot.SchematicHandler;
public class Schematic extends SubCommand { public class Schematic extends SubCommand {
public Schematic() { public Schematic() {
super("schematic", "plots.admin", "Schematic Command", super("schematic", "plots.admin", "Schematic Command", "schematic {arg}", "sch", CommandCategory.ACTIONS);
"schematic {arg}", "sch", CommandCategory.ACTIONS);
} }
@Override @Override
@ -36,11 +35,11 @@ public class Schematic extends SubCommand {
} }
file = args[1]; file = args[1];
schematic = new SchematicHandler().getSchematic(file); schematic = new SchematicHandler().getSchematic(file);
boolean s = new SchematicHandler().paste(plr.getLocation(), boolean s = new SchematicHandler().paste(plr.getLocation(), schematic, PlayerFunctions.getCurrentPlot(plr));
schematic, PlayerFunctions.getCurrentPlot(plr));
if (s) { if (s) {
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS); sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
} else { }
else {
sendMessage(plr, C.SCHEMATIC_PASTE_FAILED); sendMessage(plr, C.SCHEMATIC_PASTE_FAILED);
} }
break; break;
@ -66,8 +65,7 @@ public class Schematic extends SubCommand {
int length = PlotHelper.getPlotWidth(plr.getWorld(), plot.id); int length = PlotHelper.getPlotWidth(plr.getWorld(), plot.id);
if ((l1 != length) || (l2 != length)) { if ((l1 != length) || (l2 != length)) {
sendMessage(plr, C.SCHEMATIC_INVALID, String.format( sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
"Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
break; break;
} }
sendMessage(plr, C.SCHEMATIC_VALID); sendMessage(plr, C.SCHEMATIC_VALID);

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Set.java * >> File = Set.java >> Generated by: Citymonstret at 2014-08-09 01:42
* >> Generated by: Citymonstret at 2014-08-09 01:42
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -36,21 +35,17 @@ import com.intellectualcrafters.plot.events.PlotFlagAddEvent;
import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent; import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
/** /**
*
* @author Citymonstret * @author Citymonstret
*
*/ */
public class Set extends SubCommand { public class Set extends SubCommand {
public Set() { public Set() {
super(Command.SET, "Set a plot value", "set {arg} {value...}", super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS);
CommandCategory.ACTIONS);
} }
public static String[] values = new String[] { "biome", "wall", public static String[] values = new String[] { "biome", "wall", "wall_filling", "floor", "alias", "home", "rain",
"wall_filling", "floor", "alias", "home", "rain", "flag" }; "flag" };
public static String[] aliases = new String[] { "b", "w", "wf", "f", "a", public static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "r", "fl" };
"h", "r", "fl" };
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
@ -89,28 +84,20 @@ public class Set extends SubCommand {
if (args[0].equalsIgnoreCase("flag")) { if (args[0].equalsIgnoreCase("flag")) {
if (args.length < 2) { if (args.length < 2) {
String message = StringUtils.join(FlagManager.getFlags(), String message = StringUtils.join(FlagManager.getFlags(), "&c, &6");
"&c, &6");
if (PlotMain.worldGuardListener != null) { if (PlotMain.worldGuardListener != null) {
if (message.equals("")) { if (message.equals("")) {
message = StringUtils message = StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6");
.join(PlotMain.worldGuardListener.str_flags, }
"&c, &6"); else {
} else { message += "," + StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6");
message += ","
+ StringUtils.join(
PlotMain.worldGuardListener.str_flags,
"&c, &6");
} }
} }
PlayerFunctions.sendMessage(plr, PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message));
C.NEED_KEY.s().replaceAll("%values%", message));
return false; return false;
} }
if (!FlagManager.getFlags().contains(args[1].toLowerCase()) if (!FlagManager.getFlags().contains(args[1].toLowerCase()) && (PlotMain.worldGuardListener != null)
&& (PlotMain.worldGuardListener != null) && !PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) {
&& !PlotMain.worldGuardListener.str_flags.contains(args[1]
.toLowerCase())) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG); PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
return false; return false;
} }
@ -121,10 +108,8 @@ public class Set extends SubCommand {
if (args.length == 2) { if (args.length == 2) {
if (plot.settings.getFlag(args[1].toLowerCase()) == null) { if (plot.settings.getFlag(args[1].toLowerCase()) == null) {
if (PlotMain.worldGuardListener != null) { if (PlotMain.worldGuardListener != null) {
if (PlotMain.worldGuardListener.str_flags if (PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) {
.contains(args[1].toLowerCase())) { PlotMain.worldGuardListener.removeFlag(plr, plr.getWorld(), plot, args[1]);
PlotMain.worldGuardListener.removeFlag(plr,
plr.getWorld(), plot, args[1]);
return false; return false;
} }
} }
@ -145,22 +130,17 @@ public class Set extends SubCommand {
newflags.remove(oldFlag); newflags.remove(oldFlag);
} }
plot.settings.setFlags(newflags.toArray(new Flag[0])); plot.settings.setFlags(newflags.toArray(new Flag[0]));
DBFunc.setFlags(plr.getWorld().getName(), plot, DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0]));
newflags.toArray(new Flag[0]));
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED); PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
return true; return true;
} }
try { try {
String value = StringUtils.join( String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
Arrays.copyOfRange(args, 2, args.length), " "); if ((FlagManager.getFlag(args[1].toLowerCase()) == null) && (PlotMain.worldGuardListener != null)) {
if ((FlagManager.getFlag(args[1].toLowerCase()) == null) PlotMain.worldGuardListener.addFlag(plr, plr.getWorld(), plot, args[1], value);
&& (PlotMain.worldGuardListener != null)) {
PlotMain.worldGuardListener.addFlag(plr, plr.getWorld(),
plot, args[1], value);
return false; return false;
} }
Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), value);
true), value);
PlotFlagAddEvent event = new PlotFlagAddEvent(flag, plot); PlotFlagAddEvent event = new PlotFlagAddEvent(flag, plot);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
@ -169,11 +149,11 @@ public class Set extends SubCommand {
return false; return false;
} }
plot.settings.addFlag(flag); plot.settings.addFlag(flag);
DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags().toArray(new Flag[0]));
.getFlags().toArray(new Flag[0]));
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED); PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
return true; return true;
} catch (Exception e) { }
catch (Exception e) {
PlayerFunctions.sendMessage(plr, "&c" + e.getMessage()); PlayerFunctions.sendMessage(plr, "&c" + e.getMessage());
return false; return false;
} }
@ -195,7 +175,8 @@ public class Set extends SubCommand {
if (PlayerFunctions.getCurrentPlot(plr).id == plot.id) { if (PlayerFunctions.getCurrentPlot(plr).id == plot.id) {
if (b) { if (b) {
p.setPlayerWeather(WeatherType.DOWNFALL); p.setPlayerWeather(WeatherType.DOWNFALL);
} else { }
else {
p.resetPlayerWeather(); p.resetPlayerWeather();
} }
} }
@ -218,8 +199,7 @@ public class Set extends SubCommand {
PlayerFunctions.sendMessage(plr, C.INVALID_POSITION); PlayerFunctions.sendMessage(plr, C.INVALID_POSITION);
return false; return false;
} }
DBFunc.setPosition(plr.getWorld().getName(), plot, DBFunc.setPosition(plr.getWorld().getName(), plot, position.toString());
position.toString());
PlayerFunctions.sendMessage(plr, C.POSITION_SET); PlayerFunctions.sendMessage(plr, C.POSITION_SET);
return true; return true;
} }
@ -241,8 +221,7 @@ public class Set extends SubCommand {
} }
} }
DBFunc.setAlias(plr.getWorld().getName(), plot, alias); DBFunc.setAlias(plr.getWorld().getName(), plot, alias);
PlayerFunctions.sendMessage(plr, PlayerFunctions.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias));
C.ALIAS_SET_TO.s().replaceAll("%alias%", alias));
return true; return true;
} }
if (args[0].equalsIgnoreCase("biome")) { if (args[0].equalsIgnoreCase("biome")) {
@ -258,13 +237,11 @@ public class Set extends SubCommand {
} }
} }
if (biome == null) { if (biome == null) {
PlayerFunctions.sendMessage(plr, PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values())));
getBiomeList(Arrays.asList(Biome.values())));
return true; return true;
} }
PlotHelper.setBiome(plr.getWorld(), plot, biome); PlotHelper.setBiome(plr.getWorld(), plot, biome);
PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase());
+ biome.toString().toLowerCase());
return true; return true;
} }
if (args[0].equalsIgnoreCase("wall")) { if (args[0].equalsIgnoreCase("wall")) {
@ -285,8 +262,7 @@ public class Set extends SubCommand {
} }
} }
if (material == null) { if (material == null) {
PlayerFunctions PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
return true; return true;
} }
byte data = 0; byte data = 0;
@ -294,14 +270,14 @@ public class Set extends SubCommand {
if (args.length > 2) { if (args.length > 2) {
try { try {
data = (byte) Integer.parseInt(args[2]); data = (byte) Integer.parseInt(args[2]);
} catch (Exception e) { }
catch (Exception e) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA); PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
return true; return true;
} }
} }
PlayerFunctions.sendMessage(plr, C.GENERATING_WALL); PlayerFunctions.sendMessage(plr, C.GENERATING_WALL);
PlotHelper.adjustWall(plr, plot, PlotHelper.adjustWall(plr, plot, new PlotBlock((short) material.getId(), data));
new PlotBlock((short) material.getId(), data));
return true; return true;
} }
if (args[0].equalsIgnoreCase("floor")) { if (args[0].equalsIgnoreCase("floor")) {
@ -316,8 +292,7 @@ public class Set extends SubCommand {
} }
// //
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ArrayList<Material> materials = (ArrayList<Material>) PlotWorld.BLOCKS ArrayList<Material> materials = (ArrayList<Material>) PlotWorld.BLOCKS.clone();
.clone();
materials.add(Material.AIR); materials.add(Material.AIR);
// //
String[] strings = args[1].split(","); String[] strings = args[1].split(",");
@ -345,10 +320,12 @@ public class Set extends SubCommand {
if (ss.length == 1) { if (ss.length == 1) {
blocks[index] = new PlotBlock((short) m.getId(), (byte) 0); blocks[index] = new PlotBlock((short) m.getId(), (byte) 0);
} else { }
else {
try { try {
b = (byte) Integer.parseInt(ss[1]); b = (byte) Integer.parseInt(ss[1]);
} catch (Exception e) { }
catch (Exception e) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA); PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
return true; return true;
} }
@ -377,8 +354,7 @@ public class Set extends SubCommand {
} }
} }
if (material == null) { if (material == null) {
PlayerFunctions PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
return true; return true;
} }
byte data = 0; byte data = 0;
@ -386,13 +362,13 @@ public class Set extends SubCommand {
if (args.length > 2) { if (args.length > 2) {
try { try {
data = (byte) Integer.parseInt(args[2]); data = (byte) Integer.parseInt(args[2]);
} catch (Exception e) { }
catch (Exception e) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA); PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
return true; return true;
} }
} }
PlotHelper.adjustWallFilling(plr, plot, new PlotBlock( PlotHelper.adjustWallFilling(plr, plot, new PlotBlock((short) material.getId(), data));
(short) material.getId(), data));
return true; return true;
} }
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -403,18 +379,15 @@ public class Set extends SubCommand {
} }
private String getMaterial(Material m) { private String getMaterial(Material m) {
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", m.toString().toLowerCase()));
.s().replaceAll("%mat%", m.toString().toLowerCase()));
} }
private String getBiome(Biome b) { private String getBiome(Biome b) {
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", b.toString().toLowerCase()));
.s().replaceAll("%mat%", b.toString().toLowerCase()));
} }
private String getString(String s) { private String getString(String s) {
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s));
.s().replaceAll("%mat%", s));
} }
private String getArgumentList(String[] strings) { private String getArgumentList(String[] strings) {
@ -427,8 +400,7 @@ public class Set extends SubCommand {
private String getBiomeList(List<Biome> biomes) { private String getBiomeList(List<Biome> biomes) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(ChatColor.translateAlternateColorCodes('&', builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
C.NOT_VALID_BLOCK_LIST_HEADER.s()));
for (Biome b : biomes) { for (Biome b : biomes) {
builder.append(getBiome(b)); builder.append(getBiome(b));
} }
@ -437,8 +409,7 @@ public class Set extends SubCommand {
private String getBlockList(List<Material> blocks) { private String getBlockList(List<Material> blocks) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(ChatColor.translateAlternateColorCodes('&', builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
C.NOT_VALID_BLOCK_LIST_HEADER.s()));
for (Material b : blocks) { for (Material b : blocks) {
builder.append(getMaterial(b)); builder.append(getMaterial(b));
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = SetOwner.java * >> File = SetOwner.java >> Generated by: Citymonstret at 2014-08-09 01:42
* >> Generated by: Citymonstret at 2014-08-09 01:42
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -24,8 +23,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
public class SetOwner extends SubCommand { public class SetOwner extends SubCommand {
public SetOwner() { public SetOwner() {
super("setowner", "plots.admin", "Set the plot owner", super("setowner", "plots.admin", "Set the plot owner", "setowner {player}", "so", CommandCategory.ACTIONS);
"setowner {player}", "so", CommandCategory.ACTIONS);
} }
/* /*

View File

@ -39,7 +39,7 @@ public class Setup extends SubCommand implements Listener {
this.step = plotworld.getSettingNodes(); this.step = plotworld.getSettingNodes();
this.plugin = plugin; this.plugin = plugin;
} }
public String getPlugin() { public String getPlugin() {
return this.plugin; return this.plugin;
} }
@ -54,8 +54,7 @@ public class Setup extends SubCommand implements Listener {
} }
public Setup() { public Setup() {
super("setup", "plots.admin", "Setup a PlotWorld", "setup {world}", super("setup", "plots.admin", "Setup a PlotWorld", "setup {world}", "setup", CommandCategory.ACTIONS);
"setup", CommandCategory.ACTIONS);
} }
@Override @Override
@ -68,23 +67,25 @@ public class Setup extends SubCommand implements Listener {
ConfigurationNode[] steps = object.step; ConfigurationNode[] steps = object.step;
String world = object.world; String world = object.world;
for (ConfigurationNode step : steps) { for (ConfigurationNode step : steps) {
PlotMain.config.set( PlotMain.config.set("worlds." + world + "." + step.getConstant(), step.getValue());
"worlds." + world + "." + step.getConstant(),
step.getValue());
} }
try { try {
PlotMain.config.save(PlotMain.configFile); PlotMain.config.save(PlotMain.configFile);
} catch (IOException e) { }
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
// Creating the worlds // Creating the worlds
if (object.getPlugin().equals("Multiverse-Core")) { if (object.getPlugin().equals("Multiverse-Core")) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create "+world+" normal -g "+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);
} }
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); sendMessage(plr, C.SETUP_FINISHED, object.world);
setupMap.remove(plr.getName()); setupMap.remove(plr.getName());
@ -93,11 +94,11 @@ public class Setup extends SubCommand implements Listener {
} }
ConfigurationNode step = object.step[object.current]; ConfigurationNode step = object.step[object.current];
if (args.length < 1) { if (args.length < 1) {
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue()
step.getDescription(), step.getType().getType(), + "");
step.getDefaultValue() + "");
return true; return true;
} else { }
else {
if (args[0].equalsIgnoreCase("cancel")) { if (args[0].equalsIgnoreCase("cancel")) {
setupMap.remove(plr.getName()); setupMap.remove(plr.getName());
PlayerFunctions.sendMessage(plr, "&cCancelled setup."); PlayerFunctions.sendMessage(plr, "&cCancelled setup.");
@ -107,21 +108,19 @@ public class Setup extends SubCommand implements Listener {
if (object.current > 0) { if (object.current > 0) {
object.current--; object.current--;
step = object.step[object.current]; step = object.step[object.current];
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue()
step.getDescription(), step.getType().getType(), + "");
step.getDefaultValue() + "");
return true; return true;
} else { }
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", else {
step.getDescription(), step.getType().getType(), sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue()
step.getDefaultValue() + ""); + "");
return true; return true;
} }
} }
boolean valid = step.isValid(args[0]); boolean valid = step.isValid(args[0]);
if (valid) { if (valid) {
sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(), sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(), args[0]);
args[0]);
step.setValue(args[0]); step.setValue(args[0]);
object.current++; object.current++;
if (object.getCurrent() == object.getMax()) { if (object.getCurrent() == object.getMax()) {
@ -129,20 +128,19 @@ public class Setup extends SubCommand implements Listener {
return true; return true;
} }
step = object.step[object.current]; step = object.step[object.current];
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue()
step.getDescription(), step.getType().getType(), + "");
step.getDefaultValue() + "");
return true; return true;
} else { }
sendMessage(plr, C.SETUP_INVALID_ARG, args[0], else {
step.getConstant()); sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant());
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue()
step.getDescription(), step.getType().getType(), + "");
step.getDefaultValue() + "");
return true; return true;
} }
} }
} else { }
else {
if (args.length < 1) { if (args.length < 1) {
sendMessage(plr, C.SETUP_MISSING_WORLD); sendMessage(plr, C.SETUP_MISSING_WORLD);
return true; return true;
@ -156,32 +154,31 @@ public class Setup extends SubCommand implements Listener {
sendMessage(plr, C.SETUP_WORLD_TAKEN, world); sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
return true; return true;
} }
if (PlotMain.getWorldSettings(world) != null) { if (PlotMain.getWorldSettings(world) != null) {
sendMessage(plr, C.SETUP_WORLD_TAKEN, world); sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
return true; return true;
} }
ArrayList<String> generators = new ArrayList<String>(); ArrayList<String> generators = new ArrayList<String>();
ChunkGenerator generator = null; ChunkGenerator generator = null;
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
if (plugin.isEnabled()) { if (plugin.isEnabled()) {
ChunkGenerator currentGen = plugin.getDefaultWorldGenerator("world", ""); if (plugin.getDefaultWorldGenerator("world", "") != null) {
if (currentGen != null) {
String name = plugin.getDescription().getName(); String name = plugin.getDescription().getName();
generators.add(name); generators.add(name);
if (args[1].equals(name)) { if (args[1].equals(name)) {
generator = currentGen; generator = plugin.getDefaultWorldGenerator(world, "");
break; break;
} }
} }
} }
} }
if (generator == null) { 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; return true;
} }
PlotWorld plotworld; PlotWorld plotworld;
@ -196,9 +193,8 @@ public class Setup extends SubCommand implements Listener {
sendMessage(plr, C.SETUP_INIT); sendMessage(plr, C.SETUP_INIT);
SetupObject object = setupMap.get(plr.getName()); SetupObject object = setupMap.get(plr.getName());
ConfigurationNode step = object.step[object.current]; ConfigurationNode step = object.step[object.current];
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue()
step.getDescription(), step.getType().getType(), + "");
step.getDefaultValue() + "");
return true; return true;
} }
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = SubCommand.java * >> File = SubCommand.java >> Generated by: Citymonstret at 2014-08-09 01:42
* >> Generated by: Citymonstret at 2014-08-09 01:42
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -18,7 +17,6 @@ import com.intellectualcrafters.plot.PlayerFunctions;
* SubCommand class * SubCommand class
* *
* @author Citymonstret * @author Citymonstret
*
*/ */
public abstract class SubCommand { public abstract class SubCommand {
@ -47,7 +45,6 @@ public abstract class SubCommand {
public CommandCategory category; public CommandCategory category;
/** /**
*
* @param cmd * @param cmd
* Command /plot {cmd} <-- That! * Command /plot {cmd} <-- That!
* @param permission * @param permission
@ -61,8 +58,8 @@ public abstract class SubCommand {
* @param category * @param category
* CommandCategory. Pick whichever closests to what you want. * CommandCategory. Pick whichever closests to what you want.
*/ */
public SubCommand(String cmd, String permission, String description, public SubCommand(String cmd, String permission, String description, String usage, String alias,
String usage, String alias, CommandCategory category) { CommandCategory category) {
this.cmd = cmd; this.cmd = cmd;
this.permission = new CommandPermission(permission); this.permission = new CommandPermission(permission);
this.description = description; this.description = description;
@ -72,7 +69,6 @@ public abstract class SubCommand {
} }
/** /**
*
* @param command * @param command
* Command /plot {cmd} <-- That! * Command /plot {cmd} <-- That!
* @param description * @param description
@ -82,8 +78,7 @@ public abstract class SubCommand {
* @param category * @param category
* CommandCategory. Pick whichever closests to what you want. * CommandCategory. Pick whichever closests to what you want.
*/ */
public SubCommand(Command command, String description, String usage, public SubCommand(Command command, String description, String usage, CommandCategory category) {
CommandCategory category) {
this.cmd = command.getCommand(); this.cmd = command.getCommand();
this.permission = command.getPermission(); this.permission = command.getPermission();
this.alias = command.getAlias(); this.alias = command.getAlias();
@ -119,8 +114,10 @@ public abstract class SubCommand {
} }
public enum CommandCategory { public enum CommandCategory {
CLAIMING("Claiming"), TELEPORT("Teleportation"), ACTIONS("Actions"), INFO( CLAIMING("Claiming"),
"Information"); TELEPORT("Teleportation"),
ACTIONS("Actions"),
INFO("Information");
private String name; private String name;
CommandCategory(String name) { CommandCategory(String name) {

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = TP.java * >> File = TP.java >> Generated by: Citymonstret at 2014-08-09 01:42
* >> Generated by: Citymonstret at 2014-08-09 01:42
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -22,15 +21,12 @@ import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
/** /**
*
* @author Citymonstret * @author Citymonstret
*
*/ */
public class TP extends SubCommand { public class TP extends SubCommand {
public TP() { public TP() {
super(Command.TP, "Teleport to a plot", "tp {alias|id}", super(Command.TP, "Teleport to a plot", "tp {alias|id}", CommandCategory.TELEPORT);
CommandCategory.TELEPORT);
} }
@Override @Override
@ -57,12 +53,11 @@ public class TP extends SubCommand {
return true; return true;
} }
try { try {
plotid = new PlotId(Integer.parseInt(id.split(";")[0]), plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
Integer.parseInt(id.split(";")[1])); PlotMain.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid));
PlotMain.teleportPlayer(plr, plr.getLocation(),
PlotHelper.getPlot(world, plotid));
return true; return true;
} catch (Exception e) { }
catch (Exception e) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
} }
return false; return false;
@ -79,16 +74,14 @@ public class TP extends SubCommand {
} }
Player player = Bukkit.getPlayer(a); Player player = Bukkit.getPlayer(a);
if (player != null) { if (player != null) {
Plot[] plots = PlotMain.getPlots(world, player) Plot[] plots = PlotMain.getPlots(world, player).toArray(new Plot[0]);
.toArray(new Plot[0]);
if (plots.length > index) { if (plots.length > index) {
return plots[index]; return plots[index];
} }
return null; return null;
} }
for (Plot p : PlotMain.getPlots(world).values()) { for (Plot p : PlotMain.getPlots(world).values()) {
if ((p.settings.getAlias().length() > 0) if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) {
&& p.settings.getAlias().equalsIgnoreCase(a)) {
return p; return p;
} }
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Trusted.java * >> File = Trusted.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -25,8 +24,7 @@ import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent;
public class Trusted extends SubCommand { public class Trusted extends SubCommand {
public Trusted() { public Trusted() {
super(Command.TRUSTED, "Manage trusted users for a plot", super(Command.TRUSTED, "Manage trusted users for a plot", "trusted {add|remove} {player}", CommandCategory.ACTIONS);
"trusted {add|remove} {player}", CommandCategory.ACTIONS);
} }
@Override @Override
@ -48,8 +46,7 @@ public class Trusted extends SubCommand {
if (args[1].equalsIgnoreCase("*")) { if (args[1].equalsIgnoreCase("*")) {
UUID uuid = DBFunc.everyone; UUID uuid = DBFunc.everyone;
plot.addTrusted(uuid); plot.addTrusted(uuid);
DBFunc.setTrusted(plr.getWorld().getName(), plot, DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
Bukkit.getOfflinePlayer(args[1]));
PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED); PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED);
return true; return true;
} }
@ -64,48 +61,48 @@ public class Trusted extends SubCommand {
*/ */
UUID uuid = UUIDHandler.getUUID(args[1]); UUID uuid = UUIDHandler.getUUID(args[1]);
plot.addTrusted(uuid); plot.addTrusted(uuid);
DBFunc.setTrusted(plr.getWorld().getName(), plot, DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
Bukkit.getOfflinePlayer(args[1])); PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true);
PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr,
plot, uuid, true);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED); PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED);
} else if (args[0].equalsIgnoreCase("remove")) { }
if (args[1].equalsIgnoreCase("*")) { else
UUID uuid = DBFunc.everyone; if (args[0].equalsIgnoreCase("remove")) {
if (!plot.trusted.contains(uuid)) { if (args[1].equalsIgnoreCase("*")) {
PlayerFunctions.sendMessage(plr, C.T_WAS_NOT_ADDED); 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; 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); plot.removeTrusted(uuid);
DBFunc.removeTrusted(plr.getWorld().getName(), plot, DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
Bukkit.getOfflinePlayer(args[1])); PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, false);
Bukkit.getPluginManager().callEvent(event);
PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED); PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED);
}
else {
PlayerFunctions.sendMessage(plr, C.TRUSTED_NEED_ARGUMENT);
return true; 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; return true;
} }
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Unlink.java * >> File = Unlink.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -32,8 +31,7 @@ import com.intellectualcrafters.plot.events.PlotUnlinkEvent;
public class Unlink extends SubCommand { public class Unlink extends SubCommand {
public Unlink() { public Unlink() {
super(Command.UNLINK, "Unlink a mega-plot", "unlink", super(Command.UNLINK, "Unlink a mega-plot", "unlink", CommandCategory.ACTIONS);
CommandCategory.ACTIONS);
} }
@Override @Override
@ -43,22 +41,19 @@ public class Unlink extends SubCommand {
return true; return true;
} }
Plot plot = PlayerFunctions.getCurrentPlot(plr); Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals( if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId()))
plr.getUniqueId()))
&& !plr.hasPermission("plots.admin")) { && !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return true; return true;
} }
if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals( if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
PlayerFunctions.sendMessage(plr, C.UNLINK_IMPOSSIBLE); PlayerFunctions.sendMessage(plr, C.UNLINK_IMPOSSIBLE);
return true; return true;
} }
World world = plr.getWorld(); World world = plr.getWorld();
PlotId pos1 = PlayerFunctions.getBottomPlot(world, plot).id; PlotId pos1 = PlayerFunctions.getBottomPlot(world, plot).id;
PlotId pos2 = PlayerFunctions.getTopPlot(world, plot).id; PlotId pos2 = PlayerFunctions.getTopPlot(world, plot).id;
ArrayList<PlotId> ids = PlayerFunctions.getPlotSelectionIds(world, ArrayList<PlotId> ids = PlayerFunctions.getPlotSelectionIds(world, pos1, pos2);
pos1, pos2);
PlotUnlinkEvent event = new PlotUnlinkEvent(world, ids); PlotUnlinkEvent event = new PlotUnlinkEvent(world, ids);
@ -79,10 +74,8 @@ public class Unlink extends SubCommand {
myplot.denied = plot.denied; myplot.denied = plot.denied;
} }
myplot.deny_entry = plot.deny_entry; myplot.deny_entry = plot.deny_entry;
myplot.settings.setMerged(new boolean[] { false, false, false, myplot.settings.setMerged(new boolean[] { false, false, false, false });
false }); DBFunc.setMerged(world.getName(), myplot, myplot.settings.getMerged());
DBFunc.setMerged(world.getName(), myplot,
myplot.settings.getMerged());
} }
PlotManager manager = PlotMain.getPlotManager(world); PlotManager manager = PlotMain.getPlotManager(world);
PlotWorld plotworld = PlotMain.getWorldSettings(world); PlotWorld plotworld = PlotMain.getWorldSettings(world);
@ -111,7 +104,8 @@ public class Unlink extends SubCommand {
try { try {
SetBlockFast.update(plr); SetBlockFast.update(plr);
} catch (Exception e) { }
catch (Exception e) {
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = Visit.java * >> File = Visit.java >> Generated by: Citymonstret at 2014-08-09 01:42
* >> Generated by: Citymonstret at 2014-08-09 01:42
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -23,8 +22,7 @@ import com.intellectualcrafters.plot.PlotMain;
public class Visit extends SubCommand { public class Visit extends SubCommand {
public Visit() { public Visit() {
super("visit", "plots.visit", "Visit someones plot", super("visit", "plots.visit", "Visit someones plot", "visit {player} [#]", "v", CommandCategory.TELEPORT);
"visit {player} [#]", "v", CommandCategory.TELEPORT);
} }
public List<Plot> getPlots(UUID uuid) { public List<Plot> getPlots(UUID uuid) {
@ -45,8 +43,7 @@ public class Visit extends SubCommand {
return true; return true;
} }
String username = args[0]; String username = args[0];
List<Plot> plots = getPlots(Bukkit.getOfflinePlayer(username) List<Plot> plots = getPlots(Bukkit.getOfflinePlayer(username).getUniqueId());
.getUniqueId());
if (plots.isEmpty()) { if (plots.isEmpty()) {
PlayerFunctions.sendMessage(plr, C.FOUND_NO_PLOTS); PlayerFunctions.sendMessage(plr, C.FOUND_NO_PLOTS);
return true; return true;
@ -59,7 +56,8 @@ public class Visit extends SubCommand {
int i; int i;
try { try {
i = Integer.parseInt(args[1]); i = Integer.parseInt(args[1]);
} catch (Exception e) { }
catch (Exception e) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER);
return true; return true;
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = list.java * >> File = list.java >> Generated by: Citymonstret at 2014-08-09 01:41
* >> Generated by: Citymonstret at 2014-08-09 01:41
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -23,15 +22,12 @@ import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.UUIDHandler; import com.intellectualcrafters.plot.UUIDHandler;
/** /**
*
* @author Citymonstret * @author Citymonstret
*
*/ */
public class list extends SubCommand { public class list extends SubCommand {
public list() { public list() {
super(Command.LIST, "List all plots", "list {mine|all|world}", super(Command.LIST, "List all plots", "list {mine|all|world}", CommandCategory.INFO);
CommandCategory.INFO);
} }
@Override @Override
@ -39,22 +35,16 @@ public class list extends SubCommand {
if (args.length < 1) { if (args.length < 1) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s()); builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
builder.append(getArgumentList(new String[] { "mine", "shared", builder.append(getArgumentList(new String[] { "mine", "shared", "world", "all" }));
"world", "all" }));
PlayerFunctions.sendMessage(plr, builder.toString()); PlayerFunctions.sendMessage(plr, builder.toString());
return true; return true;
} }
if (args[0].equalsIgnoreCase("mine")) { if (args[0].equalsIgnoreCase("mine")) {
StringBuilder string = new StringBuilder(); StringBuilder string = new StringBuilder();
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "your") string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "your") + "\n");
+ "\n");
int idx = 0; int idx = 0;
for (Plot p : PlotMain.getPlots(plr)) { for (Plot p : PlotMain.getPlots(plr)) {
string.append(C.PLOT_LIST_ITEM string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id%", p.id.x + ";" + p.id.y + ";" + p.world).replaceAll("%owner%", getName(p.owner))
.s()
.replaceAll("%id%",
p.id.x + ";" + p.id.y + ";" + p.world)
.replaceAll("%owner%", getName(p.owner))
+ "\n"); + "\n");
idx++; idx++;
} }
@ -62,79 +52,57 @@ public class list extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NO_PLOTS); PlayerFunctions.sendMessage(plr, C.NO_PLOTS);
return true; return true;
} }
string.append(C.PLOT_LIST_FOOTER.s() string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "You have").replaceAll("%num%", idx + "").replaceAll("%plot%", idx == 1
.replaceAll("%word%", "You have") ? "plot" : "plots"));
.replaceAll("%num%", idx + "")
.replaceAll("%plot%", idx == 1 ? "plot" : "plots"));
PlayerFunctions.sendMessage(plr, string.toString()); PlayerFunctions.sendMessage(plr, string.toString());
return true; 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<PlotId, Plot> 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<PlotId, Plot> 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) { private static String getName(UUID id) {
@ -157,8 +125,7 @@ public class list extends SubCommand {
} }
private String getString(String s) { private String getString(String s) {
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s));
.s().replaceAll("%mat%", s));
} }
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = plugin.java * >> File = plugin.java >> Generated by: Citymonstret at 2014-08-09 01:42
* >> Generated by: Citymonstret at 2014-08-09 01:42
*/ */
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
@ -25,45 +24,35 @@ import com.intellectualcrafters.plot.PlotMain;
public class plugin extends SubCommand { public class plugin extends SubCommand {
public plugin() { public plugin() {
super("plugin", "plots.use", "Show plugin information", "plugin", "pl", super("plugin", "plots.use", "Show plugin information", "plugin", "pl", CommandCategory.INFO);
CommandCategory.INFO);
} }
@Override @Override
public boolean execute(final Player plr, String... args) { public boolean execute(final Player plr, String... args) {
Bukkit.getScheduler().runTaskAsynchronously( Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() {
JavaPlugin.getPlugin(PlotMain.class), new Runnable() { @Override
@Override public void run() {
public void run() { ArrayList<String> strings = new ArrayList<String>() {
ArrayList<String> strings = new ArrayList<String>() { {
{ String downloads =
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"); getInfo("https://intellectualsites.com/spigot_api.php?method=downloads&url=http://www.spigotmc.org/resources/plotsquared.1177/"), version =
add(String.format( getInfo("https://intellectualsites.com/spigot_api.php?method=version&resource=1177");
"&c>> &6PlotSquared (Version: %s)", add(String.format("&c>> &6PlotSquared (Version: %s)", PlotMain.getMain().getDescription().getVersion()));
PlotMain.getMain().getDescription() add(String.format("&c>> &6Made by Citymonstret and Empire92"));
.getVersion())); add(String.format("&c>> &6Download at &lhttp://i-s.link/ps"));
add(String add(String.format("&c>> &cNewest Version (Spigot): %s", version));
.format("&c>> &6Made by Citymonstret and Empire92")); add(String.format("&c>> &cTotal Downloads (Spigot): %s", downloads));
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);
}
} }
}); };
for (String s : strings) {
PlayerFunctions.sendMessage(plr, s);
}
}
});
return true; return true;
} }
/** /**
*
* @param link * @param link
* @return * @return
*/ */
@ -71,15 +60,15 @@ public class plugin extends SubCommand {
try { try {
URLConnection connection = new URL(link).openConnection(); URLConnection connection = new URL(link).openConnection();
connection.addRequestProperty("User-Agent", "Mozilla/4.0"); connection.addRequestProperty("User-Agent", "Mozilla/4.0");
BufferedReader reader = new BufferedReader(new InputStreamReader( BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
connection.getInputStream()));
String document = "", line; String document = "", line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
document += (line + "\n"); document += (line + "\n");
} }
reader.close(); reader.close();
return document; return document;
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return ""; return "";
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = DBFunc.java * >> File = DBFunc.java >> Generated by: Citymonstret at 2014-08-09 01:43
* >> Generated by: Citymonstret at 2014-08-09 01:43
*/ */
package com.intellectualcrafters.plot.database; package com.intellectualcrafters.plot.database;
@ -53,17 +52,17 @@ public class DBFunc {
@Override @Override
public void run() { public void run() {
try { try {
PreparedStatement statement = connection PreparedStatement statement =
.prepareStatement("UPDATE `plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ? "); connection.prepareStatement("UPDATE `plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ? ");
statement.setString(1, uuid.toString()); statement.setString(1, uuid.toString());
statement.setInt(2, plot.id.x); statement.setInt(2, plot.id.x);
statement.setInt(3, plot.id.y); statement.setInt(3, plot.id.y);
statement.executeUpdate(); statement.executeUpdate();
statement.close(); statement.close();
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
Logger.add(LogLevel.DANGER, "Could not set owner for plot " Logger.add(LogLevel.DANGER, "Could not set owner for plot " + plot.id);
+ plot.id);
} }
} }
}); });
@ -73,8 +72,8 @@ public class DBFunc {
HashMap<String, HashMap<PlotId, Integer>> stored = new HashMap<String, HashMap<PlotId, Integer>>(); HashMap<String, HashMap<PlotId, Integer>> stored = new HashMap<String, HashMap<PlotId, Integer>>();
HashMap<Integer, ArrayList<UUID>> helpers = new HashMap<Integer, ArrayList<UUID>>(); HashMap<Integer, ArrayList<UUID>> helpers = new HashMap<Integer, ArrayList<UUID>>();
try { try {
PreparedStatement stmt = connection PreparedStatement stmt =
.prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z`, `world` FROM `plot`"); connection.prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z`, `world` FROM `plot`");
ResultSet result = stmt.executeQuery(); ResultSet result = stmt.executeQuery();
while (result.next()) { while (result.next()) {
int id = result.getInt("id"); int id = result.getInt("id");
@ -87,7 +86,8 @@ public class DBFunc {
} }
stored.get(world).put(new PlotId(idx, idz), id); stored.get(world).put(new PlotId(idx, idz), id);
} }
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -107,8 +107,7 @@ public class DBFunc {
// add plot settings // add plot settings
Integer[] ids = helpers.keySet().toArray(new Integer[0]); Integer[] ids = helpers.keySet().toArray(new Integer[0]);
StringBuilder statement = new StringBuilder( StringBuilder statement = new StringBuilder("INSERT INTO `plot_settings` (`plot_plot_id`) values ");
"INSERT INTO `plot_settings` (`plot_plot_id`) values ");
for (int i = 0; i < (ids.length - 1); i++) { for (int i = 0; i < (ids.length - 1); i++) {
statement.append("(?),"); statement.append("(?),");
} }
@ -121,14 +120,14 @@ public class DBFunc {
} }
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
// add plot helpers // add plot helpers
String prefix = ""; String prefix = "";
statement = new StringBuilder( statement = new StringBuilder("INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) values ");
"INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) values ");
for (Integer id : helpers.keySet()) { for (Integer id : helpers.keySet()) {
for (UUID helper : helpers.get(id)) { for (UUID helper : helpers.get(id)) {
statement.append(prefix + "(?, ?)"); statement.append(prefix + "(?, ?)");
@ -151,7 +150,8 @@ public class DBFunc {
} }
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
} catch (SQLException e) { }
catch (SQLException e) {
Logger.add(LogLevel.WARNING, "Failed to set helper for plots"); Logger.add(LogLevel.WARNING, "Failed to set helper for plots");
e.printStackTrace(); e.printStackTrace();
} }
@ -166,8 +166,8 @@ public class DBFunc {
if (plots.size() == 0) { if (plots.size() == 0) {
return; return;
} }
StringBuilder statement = new StringBuilder( StringBuilder statement =
"INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) values "); new StringBuilder("INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) values ");
for (int i = 0; i < (plots.size() - 1); i++) { for (int i = 0; i < (plots.size() - 1); i++) {
statement.append("(?, ?, ?, ?),"); statement.append("(?, ?, ?, ?),");
@ -186,7 +186,8 @@ public class DBFunc {
} }
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
Logger.add(LogLevel.DANGER, "Failed to save plots!"); Logger.add(LogLevel.DANGER, "Failed to save plots!");
} }
@ -200,15 +201,16 @@ public class DBFunc {
public static void createPlot(Plot plot) { public static void createPlot(Plot plot) {
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
stmt = connection stmt =
.prepareStatement("INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) VALUES(?, ?, ?, ?)"); connection.prepareStatement("INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) VALUES(?, ?, ?, ?)");
stmt.setInt(1, plot.id.x); stmt.setInt(1, plot.id.x);
stmt.setInt(2, plot.id.y); stmt.setInt(2, plot.id.y);
stmt.setString(3, plot.owner.toString()); stmt.setString(3, plot.owner.toString());
stmt.setString(4, plot.world); stmt.setString(4, plot.world);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
Logger.add(LogLevel.DANGER, "Failed to save plot " + plot.id); Logger.add(LogLevel.DANGER, "Failed to save plot " + plot.id);
} }
@ -219,81 +221,52 @@ public class DBFunc {
* *
* @throws SQLException * @throws SQLException
*/ */
public static void createTables(String database, boolean add_constraint) public static void createTables(String database, boolean add_constraint) throws SQLException {
throws SQLException {
boolean mysql = database.equals("mysql"); boolean mysql = database.equals("mysql");
Statement stmt = connection.createStatement(); Statement stmt = connection.createStatement();
if (mysql) { if (mysql) {
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot` (" stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT,"
+ "`id` INT(11) NOT NULL AUTO_INCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL,"
+ "`plot_id_x` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL,"
+ "`plot_id_z` INT(11) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)"
+ "`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"); + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_denied` (" stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL,"
+ "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
+ "`user_uuid` VARCHAR(40) NOT NULL" stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL,"
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` (" stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL,"
+ "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
+ "`user_uuid` VARCHAR(40) NOT NULL" stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL,"
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0,"
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` (" + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000',"
+ "`plot_plot_id` INT(11) NOT NULL," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL,"
+ "`user_uuid` VARCHAR(40) NOT NULL" + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL,"
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8"); + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`),"
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" + " UNIQUE KEY `unique_alias` (`alias`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
+ " `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"); 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) { 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"); 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` (" else {
+ "`id` INTEGER(11) PRIMARY KEY," stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot` (" + "`id` INTEGER(11) PRIMARY KEY,"
+ "`plot_id_x` INT(11) NOT NULL," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL,"
+ "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL,"
+ "`owner` VARCHAR(45) NOT NULL,"
+ "`world` VARCHAR(45) NOT NULL,"
+ "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)"); + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_denied` (" stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL,"
+ "`plot_plot_id` INT(11) NOT NULL,"
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")"); + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` (" stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL,"
+ "`plot_plot_id` INT(11) NOT NULL,"
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")"); + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` (" stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL,"
+ "`plot_plot_id` INT(11) NOT NULL,"
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")"); + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL,"
+ " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0,"
+ " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000',"
+ " `rain` INT(1) DEFAULT 0," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL,"
+ " `custom_time` TINYINT(1) DEFAULT '0'," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL,"
+ " `time` INT(11) DEFAULT '8000'," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")");
+ " `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.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(); stmt.executeBatch();
@ -314,30 +287,26 @@ public class DBFunc {
PreparedStatement stmt = null; PreparedStatement stmt = null;
int id = getId(world, plot.id); int id = getId(world, plot.id);
try { try {
stmt = connection stmt = connection.prepareStatement("DELETE FROM `plot_settings` WHERE `plot_plot_id` = ?");
.prepareStatement("DELETE FROM `plot_settings` WHERE `plot_plot_id` = ?");
stmt.setInt(1, id); stmt.setInt(1, id);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
stmt = connection stmt = connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ?");
.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ?");
stmt.setInt(1, id); stmt.setInt(1, id);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
stmt = connection stmt = connection.prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = ?");
.prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = ?");
stmt.setInt(1, id); stmt.setInt(1, id);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
stmt = connection stmt = connection.prepareStatement("DELETE FROM `plot` WHERE `id` = ?");
.prepareStatement("DELETE FROM `plot` WHERE `id` = ?");
stmt.setInt(1, id); stmt.setInt(1, id);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
Logger.add(LogLevel.DANGER, "Failed to delete plot " Logger.add(LogLevel.DANGER, "Failed to delete plot " + plot.id);
+ plot.id);
} }
} }
}); });
@ -355,13 +324,12 @@ public class DBFunc {
public void run() { public void run() {
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
stmt = connection stmt = connection.prepareStatement("INSERT INTO `plot_settings`(`plot_plot_id`) VALUES(" + "?)");
.prepareStatement("INSERT INTO `plot_settings`(`plot_plot_id`) VALUES("
+ "?)");
stmt.setInt(1, id); stmt.setInt(1, id);
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -372,8 +340,8 @@ public class DBFunc {
public static int getId(String world, PlotId id2) { public static int getId(String world, PlotId id2) {
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
stmt = connection stmt =
.prepareStatement("SELECT `id` FROM `plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC"); 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(1, id2.x);
stmt.setInt(2, id2.y); stmt.setInt(2, id2.y);
stmt.setString(3, world); stmt.setString(3, world);
@ -384,7 +352,8 @@ public class DBFunc {
} }
stmt.close(); stmt.close();
return id; return id;
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
@ -417,36 +386,27 @@ public class DBFunc {
boolean execute = rs.next(); boolean execute = rs.next();
if (execute) { if (execute) {
Statement statement = connection.createStatement(); Statement statement = connection.createStatement();
statement statement.addBatch("ALTER IGNORE TABLE `plot` ADD `plot_id_x` int(11) DEFAULT 0");
.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 statement.addBatch("UPDATE `plot` SET\n" + " `plot_id_x` = IF("
.addBatch("ALTER IGNORE TABLE `plot` ADD `plot_id_z` int(11) DEFAULT 0"); + " LOCATE(';', `plot_id`) > 0,"
statement + " SUBSTRING(`plot_id`, 1, LOCATE(';', `plot_id`) - 1)," + " `plot_id`"
.addBatch("UPDATE `plot` SET\n" + " )," + " `plot_id_z` = IF(" + " LOCATE(';', `plot_id`) > 0,"
+ " `plot_id_x` = IF(" + " SUBSTRING(`plot_id`, LOCATE(';', `plot_id`) + 1)," + " NULL" + " )");
+ " 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 TABLE `plot` DROP `plot_id`");
statement statement.addBatch("ALTER IGNORE TABLE `plot_settings` ADD `flags` VARCHAR(512) DEFAULT NULL");
.addBatch("ALTER IGNORE TABLE `plot_settings` ADD `flags` VARCHAR(512) DEFAULT NULL");
statement.executeBatch(); statement.executeBatch();
statement.close(); statement.close();
} }
rs = data.getColumns(null, null, "plot_settings", "merged"); rs = data.getColumns(null, null, "plot_settings", "merged");
if (!rs.next()) { if (!rs.next()) {
Statement statement = connection.createStatement(); Statement statement = connection.createStatement();
statement statement.addBatch("ALTER TABLE `plot_settings` ADD `merged` int(11) DEFAULT NULL");
.addBatch("ALTER TABLE `plot_settings` ADD `merged` int(11) DEFAULT NULL");
statement.executeBatch(); statement.executeBatch();
statement.close(); statement.close();
} }
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<String, HashMap<PlotId, Plot>>(); HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<String, HashMap<PlotId, Plot>>();
@ -455,19 +415,16 @@ public class DBFunc {
Set<String> worlds = new HashSet<String>(); Set<String> worlds = new HashSet<String>();
if (PlotMain.config.contains("worlds")) { if (PlotMain.config.contains("worlds")) {
worlds = PlotMain.config.getConfigurationSection("worlds") worlds = PlotMain.config.getConfigurationSection("worlds").getKeys(false);
.getKeys(false);
} }
stmt = connection.createStatement(); stmt = connection.createStatement();
ResultSet r = stmt ResultSet r = stmt.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world` FROM `plot`");
.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world` FROM `plot`");
PlotId plot_id; PlotId plot_id;
int id; int id;
Plot p; Plot p;
while (r.next()) { while (r.next()) {
plot_id = new PlotId(r.getInt("plot_id_x"), plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
r.getInt("plot_id_z"));
id = r.getInt("id"); id = r.getInt("id");
String worldname = r.getString("world"); String worldname = r.getString("world");
HashMap<String, Object> settings = getSettings(id); HashMap<String, Object> settings = getSettings(id);
@ -476,18 +433,18 @@ public class DBFunc {
String[] flags_string; String[] flags_string;
if (settings.get("flags") == null) { if (settings.get("flags") == null) {
flags_string = new String[] {}; flags_string = new String[] {};
} else { }
else {
flags_string = ((String) settings.get("flags")).split(","); flags_string = ((String) settings.get("flags")).split(",");
} }
Flag[] flags = new Flag[flags_string.length]; Flag[] flags = new Flag[flags_string.length];
for (int i = 0; i < flags.length; i++) { for (int i = 0; i < flags.length; i++) {
if (flags_string[i].contains(":")) { if (flags_string[i].contains(":")) {
String[] split = flags_string[i].split(":"); String[] split = flags_string[i].split(":");
flags[i] = new Flag( flags[i] = new Flag(FlagManager.getFlag(split[0], true), split[1]);
FlagManager.getFlag(split[0], true), split[1]); }
} else { else {
flags[i] = new Flag(FlagManager.getFlag( flags[i] = new Flag(FlagManager.getFlag(flags_string[i], true), "");
flags_string[i], true), "");
} }
} }
ArrayList<UUID> helpers = plotHelpers(id); ArrayList<UUID> helpers = plotHelpers(id);
@ -505,7 +462,8 @@ public class DBFunc {
boolean rain; boolean rain;
try { try {
rain = (int) settings.get("rain") == 1 ? true : false; rain = (int) settings.get("rain") == 1 ? true : false;
} catch (Exception e) { }
catch (Exception e) {
rain = false; rain = false;
} }
String alias = (String) settings.get("alias"); String alias = (String) settings.get("alias");
@ -513,48 +471,44 @@ public class DBFunc {
alias = ""; alias = "";
} }
PlotHomePosition position = null; PlotHomePosition position = null;
for (PlotHomePosition plotHomePosition : PlotHomePosition for (PlotHomePosition plotHomePosition : PlotHomePosition.values()) {
.values()) {
if (settings.get("position") == null) { if (settings.get("position") == null) {
position = PlotHomePosition.DEFAULT; position = PlotHomePosition.DEFAULT;
break; break;
} }
if (plotHomePosition.isMatching((String) settings if (plotHomePosition.isMatching((String) settings.get("position"))) {
.get("position"))) {
position = plotHomePosition; position = plotHomePosition;
} }
} }
if (position == null) { if (position == null) {
position = PlotHomePosition.DEFAULT; position = PlotHomePosition.DEFAULT;
} }
int merged_int = settings.get("merged") == null ? 0 int merged_int = settings.get("merged") == null ? 0 : (int) settings.get("merged");
: (int) settings.get("merged");
boolean[] merged = new boolean[4]; boolean[] merged = new boolean[4];
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
merged[3 - i] = (merged_int & (1 << i)) != 0; merged[3 - i] = (merged_int & (1 << i)) != 0;
} }
p = new Plot(plot_id, owner, plotBiome, helpers, trusted, p =
denied, /* changeTime */false, time, rain, alias, new Plot(plot_id, owner, plotBiome, helpers, trusted, denied, /* changeTime */false, time, rain, alias, position, flags, worldname, merged);
position, flags, worldname, merged);
if (plots.containsKey(worldname)) { if (plots.containsKey(worldname)) {
plots.get(worldname).put((plot_id), p); plots.get(worldname).put((plot_id), p);
} else { }
else {
if (worlds.contains(p.world)) { if (worlds.contains(p.world)) {
HashMap<PlotId, Plot> map = new HashMap<PlotId, Plot>(); HashMap<PlotId, Plot> map = new HashMap<PlotId, Plot>();
map.put((plot_id), p); map.put((plot_id), p);
plots.put(worldname, map); plots.put(worldname, map);
} else { }
PlotMain.sendConsoleSenderMessage("&cPlot '" else {
+ p.id PlotMain.sendConsoleSenderMessage("&cPlot '" + p.id + "' in DB for world '" + p.world
+ "' in DB for world '"
+ p.world
+ "' does not exist! Please create this world, or remove the plots from the DB!"); + "' does not exist! Please create this world, or remove the plots from the DB!");
} }
} }
} }
stmt.close(); stmt.close();
} catch (SQLException e) { }
catch (SQLException e) {
Logger.add(LogLevel.WARNING, "Failed to load plots."); Logger.add(LogLevel.WARNING, "Failed to load plots.");
e.printStackTrace(); e.printStackTrace();
} }
@ -565,31 +519,29 @@ public class DBFunc {
* @param plot * @param plot
* @param rain * @param rain
*/ */
public static void setWeather(final String world, final Plot plot, public static void setWeather(final String world, final Plot plot, final boolean rain) {
final boolean rain) {
plot.settings.setRain(rain); plot.settings.setRain(rain);
runTask(new Runnable() { runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
int weather = rain ? 1 : 0; int weather = rain ? 1 : 0;
PreparedStatement stmt = connection PreparedStatement stmt =
.prepareStatement("UPDATE `plot_settings` SET `rain` = ? WHERE `plot_plot_id` = ?"); connection.prepareStatement("UPDATE `plot_settings` SET `rain` = ? WHERE `plot_plot_id` = ?");
stmt.setInt(1, weather); stmt.setInt(1, weather);
stmt.setInt(2, getId(world, plot.id)); stmt.setInt(2, getId(world, plot.id));
stmt.execute(); stmt.execute();
stmt.close(); stmt.close();
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
Logger.add(LogLevel.WARNING, Logger.add(LogLevel.WARNING, "Could not set weather for plot " + plot.id);
"Could not set weather for plot " + plot.id);
} }
} }
}); });
} }
public static void setMerged(final String world, final Plot plot, public static void setMerged(final String world, final Plot plot, final boolean[] merged) {
final boolean[] merged) {
plot.settings.setMerged(merged); plot.settings.setMerged(merged);
runTask(new Runnable() { runTask(new Runnable() {
@Override @Override
@ -599,23 +551,22 @@ public class DBFunc {
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
n = (n << 1) + (merged[i] ? 1 : 0); n = (n << 1) + (merged[i] ? 1 : 0);
} }
PreparedStatement stmt = connection PreparedStatement stmt =
.prepareStatement("UPDATE `plot_settings` SET `merged` = ? WHERE `plot_plot_id` = ?"); connection.prepareStatement("UPDATE `plot_settings` SET `merged` = ? WHERE `plot_plot_id` = ?");
stmt.setInt(1, n); stmt.setInt(1, n);
stmt.setInt(2, getId(world, plot.id)); stmt.setInt(2, getId(world, plot.id));
stmt.execute(); stmt.execute();
stmt.close(); stmt.close();
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
Logger.add(LogLevel.WARNING, Logger.add(LogLevel.WARNING, "Could not set merged for plot " + plot.id);
"Could not set merged for plot " + plot.id);
} }
} }
}); });
} }
public static void setFlags(final String world, final Plot plot, public static void setFlags(final String world, final Plot plot, final Flag[] flags) {
final Flag[] flags) {
plot.settings.setFlags(flags); plot.settings.setFlags(flags);
final StringBuilder flag_string = new StringBuilder(); final StringBuilder flag_string = new StringBuilder();
int i = 0; int i = 0;
@ -630,16 +581,16 @@ public class DBFunc {
@Override @Override
public void run() { public void run() {
try { try {
PreparedStatement stmt = connection PreparedStatement stmt =
.prepareStatement("UPDATE `plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?"); connection.prepareStatement("UPDATE `plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?");
stmt.setString(1, flag_string.toString()); stmt.setString(1, flag_string.toString());
stmt.setInt(2, getId(world, plot.id)); stmt.setInt(2, getId(world, plot.id));
stmt.execute(); stmt.execute();
stmt.close(); stmt.close();
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
Logger.add(LogLevel.WARNING, "Could not set flag for plot " Logger.add(LogLevel.WARNING, "Could not set flag for plot " + plot.id);
+ plot.id);
} }
} }
}); });
@ -649,23 +600,22 @@ public class DBFunc {
* @param plot * @param plot
* @param alias * @param alias
*/ */
public static void setAlias(final String world, final Plot plot, public static void setAlias(final String world, final Plot plot, final String alias) {
final String alias) {
plot.settings.setAlias(alias); plot.settings.setAlias(alias);
runTask(new Runnable() { runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
stmt = connection stmt =
.prepareStatement("UPDATE `plot_settings` SET `alias` = ? WHERE `plot_plot_id` = ?"); connection.prepareStatement("UPDATE `plot_settings` SET `alias` = ? WHERE `plot_plot_id` = ?");
stmt.setString(1, alias); stmt.setString(1, alias);
stmt.setInt(2, getId(world, plot.id)); stmt.setInt(2, getId(world, plot.id));
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
} catch (SQLException e) { }
Logger.add(LogLevel.WARNING, catch (SQLException e) {
"Failed to set alias for plot " + plot.id); Logger.add(LogLevel.WARNING, "Failed to set alias for plot " + plot.id);
e.printStackTrace(); e.printStackTrace();
} }
@ -677,31 +627,29 @@ public class DBFunc {
* @param r * @param r
*/ */
private static void runTask(Runnable r) { private static void runTask(Runnable r) {
PlotMain.getMain().getServer().getScheduler() PlotMain.getMain().getServer().getScheduler().runTaskAsynchronously(PlotMain.getMain(), r);
.runTaskAsynchronously(PlotMain.getMain(), r);
} }
/** /**
* @param plot * @param plot
* @param position * @param position
*/ */
public static void setPosition(final String world, final Plot plot, public static void setPosition(final String world, final Plot plot, final String position) {
final String position) {
plot.settings.setPosition(PlotHomePosition.valueOf(position)); plot.settings.setPosition(PlotHomePosition.valueOf(position));
runTask(new Runnable() { runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
stmt = connection stmt =
.prepareStatement("UPDATE `plot_settings` SET `position` = ? WHERE `plot_plot_id` = ?"); connection.prepareStatement("UPDATE `plot_settings` SET `position` = ? WHERE `plot_plot_id` = ?");
stmt.setString(1, position); stmt.setString(1, position);
stmt.setInt(2, getId(world, plot.id)); stmt.setInt(2, getId(world, plot.id));
stmt.executeUpdate(); stmt.executeUpdate();
stmt.close(); stmt.close();
} catch (SQLException e) { }
Logger.add(LogLevel.WARNING, catch (SQLException e) {
"Failed to set position for plot " + plot.id); Logger.add(LogLevel.WARNING, "Failed to set position for plot " + plot.id);
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -716,8 +664,7 @@ public class DBFunc {
HashMap<String, Object> h = new HashMap<String, Object>(); HashMap<String, Object> h = new HashMap<String, Object>();
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
stmt = connection stmt = connection.prepareStatement("SELECT * FROM `plot_settings` WHERE `plot_plot_id` = ?");
.prepareStatement("SELECT * FROM `plot_settings` WHERE `plot_plot_id` = ?");
stmt.setInt(1, id); stmt.setInt(1, id);
ResultSet r = stmt.executeQuery(); ResultSet r = stmt.executeQuery();
String var; String var;
@ -753,9 +700,9 @@ public class DBFunc {
} }
stmt.close(); stmt.close();
; ;
} catch (SQLException e) { }
Logger.add(LogLevel.WARNING, "Failed to load settings for plot: " catch (SQLException e) {
+ id); Logger.add(LogLevel.WARNING, "Failed to load settings for plot: " + id);
e.printStackTrace(); e.printStackTrace();
} }
return h; return h;
@ -774,8 +721,7 @@ public class DBFunc {
ArrayList<UUID> l = new ArrayList<UUID>(); ArrayList<UUID> l = new ArrayList<UUID>();
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
stmt = connection stmt = connection.prepareStatement("SELECT `user_uuid` FROM `plot_denied` WHERE `plot_plot_id` = ?");
.prepareStatement("SELECT `user_uuid` FROM `plot_denied` WHERE `plot_plot_id` = ?");
stmt.setInt(1, id); stmt.setInt(1, id);
ResultSet r = stmt.executeQuery(); ResultSet r = stmt.executeQuery();
UUID u; UUID u;
@ -784,7 +730,8 @@ public class DBFunc {
l.add(u); l.add(u);
} }
stmt.close(); stmt.close();
} catch (Exception e) { }
catch (Exception e) {
Logger.add(LogLevel.DANGER, "Failed to load denied for plot: " + id); Logger.add(LogLevel.DANGER, "Failed to load denied for plot: " + id);
e.printStackTrace(); e.printStackTrace();
} }
@ -800,18 +747,16 @@ public class DBFunc {
Statement stmt = null; Statement stmt = null;
try { try {
stmt = connection.createStatement(); stmt = connection.createStatement();
ResultSet r = stmt ResultSet r = stmt.executeQuery("SELECT `user_uuid` FROM `plot_helpers` WHERE `plot_plot_id` = " + id);
.executeQuery("SELECT `user_uuid` FROM `plot_helpers` WHERE `plot_plot_id` = "
+ id);
UUID u; UUID u;
while (r.next()) { while (r.next()) {
u = UUID.fromString(r.getString("user_uuid")); u = UUID.fromString(r.getString("user_uuid"));
l.add(u); l.add(u);
} }
stmt.close(); stmt.close();
} catch (SQLException e) { }
Logger.add(LogLevel.WARNING, "Failed to load helpers for plot: " catch (SQLException e) {
+ id); Logger.add(LogLevel.WARNING, "Failed to load helpers for plot: " + id);
e.printStackTrace(); e.printStackTrace();
} }
return l; return l;
@ -826,18 +771,16 @@ public class DBFunc {
Statement stmt = null; Statement stmt = null;
try { try {
stmt = connection.createStatement(); stmt = connection.createStatement();
ResultSet r = stmt ResultSet r = stmt.executeQuery("SELECT `user_uuid` FROM `plot_trusted` WHERE `plot_plot_id` = " + id);
.executeQuery("SELECT `user_uuid` FROM `plot_trusted` WHERE `plot_plot_id` = "
+ id);
UUID u; UUID u;
while (r.next()) { while (r.next()) {
u = UUID.fromString(r.getString("user_uuid")); u = UUID.fromString(r.getString("user_uuid"));
l.add(u); l.add(u);
} }
stmt.close(); stmt.close();
} catch (SQLException e) { }
Logger.add(LogLevel.WARNING, catch (SQLException e) {
"Failed to load trusted users for plot: " + id); Logger.add(LogLevel.WARNING, "Failed to load trusted users for plot: " + id);
e.printStackTrace(); e.printStackTrace();
} }
return l; return l;
@ -847,22 +790,21 @@ public class DBFunc {
* @param plot * @param plot
* @param player * @param player
*/ */
public static void removeHelper(final String world, final Plot plot, public static void removeHelper(final String world, final Plot plot, final OfflinePlayer player) {
final OfflinePlayer player) {
runTask(new Runnable() { runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
PreparedStatement statement = connection PreparedStatement statement =
.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?"); connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
statement.setInt(1, getId(world, plot.id)); statement.setInt(1, getId(world, plot.id));
statement.setString(2, player.getUniqueId().toString()); statement.setString(2, player.getUniqueId().toString());
statement.executeUpdate(); statement.executeUpdate();
statement.close(); statement.close();
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
Logger.add(LogLevel.WARNING, Logger.add(LogLevel.WARNING, "Failed to remove helper for plot " + plot.id);
"Failed to remove helper for plot " + plot.id);
} }
} }
}); });
@ -872,22 +814,21 @@ public class DBFunc {
* @param plot * @param plot
* @param player * @param player
*/ */
public static void removeTrusted(final String world, final Plot plot, public static void removeTrusted(final String world, final Plot plot, final OfflinePlayer player) {
final OfflinePlayer player) {
runTask(new Runnable() { runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
PreparedStatement statement = connection PreparedStatement statement =
.prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = ? AND `user_uuid` = ?"); connection.prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
statement.setInt(1, getId(world, plot.id)); statement.setInt(1, getId(world, plot.id));
statement.setString(2, player.getUniqueId().toString()); statement.setString(2, player.getUniqueId().toString());
statement.executeUpdate(); statement.executeUpdate();
statement.close(); statement.close();
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
Logger.add(LogLevel.WARNING, Logger.add(LogLevel.WARNING, "Failed to remove trusted user for plot " + plot.id);
"Failed to remove trusted user for plot " + plot.id);
} }
} }
}); });
@ -897,21 +838,20 @@ public class DBFunc {
* @param plot * @param plot
* @param player * @param player
*/ */
public static void setHelper(final String world, final Plot plot, public static void setHelper(final String world, final Plot plot, final OfflinePlayer player) {
final OfflinePlayer player) {
runTask(new Runnable() { runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
PreparedStatement statement = connection PreparedStatement statement =
.prepareStatement("INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)"); connection.prepareStatement("INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
statement.setInt(1, getId(world, plot.id)); statement.setInt(1, getId(world, plot.id));
statement.setString(2, player.getUniqueId().toString()); statement.setString(2, player.getUniqueId().toString());
statement.executeUpdate(); statement.executeUpdate();
statement.close(); statement.close();
} catch (SQLException e) { }
Logger.add(LogLevel.WARNING, catch (SQLException e) {
"Failed to set helper for plot " + plot.id); Logger.add(LogLevel.WARNING, "Failed to set helper for plot " + plot.id);
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -922,21 +862,20 @@ public class DBFunc {
* @param plot * @param plot
* @param player * @param player
*/ */
public static void setTrusted(final String world, final Plot plot, public static void setTrusted(final String world, final Plot plot, final OfflinePlayer player) {
final OfflinePlayer player) {
runTask(new Runnable() { runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
PreparedStatement statement = connection PreparedStatement statement =
.prepareStatement("INSERT INTO `plot_trusted` (`plot_plot_id`, `user_uuid`) VALUES(?,?)"); connection.prepareStatement("INSERT INTO `plot_trusted` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
statement.setInt(1, getId(world, plot.id)); statement.setInt(1, getId(world, plot.id));
statement.setString(2, player.getUniqueId().toString()); statement.setString(2, player.getUniqueId().toString());
statement.executeUpdate(); statement.executeUpdate();
statement.close(); statement.close();
} catch (SQLException e) { }
Logger.add(LogLevel.WARNING, catch (SQLException e) {
"Failed to set plot trusted for plot " + plot.id); Logger.add(LogLevel.WARNING, "Failed to set plot trusted for plot " + plot.id);
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -947,22 +886,21 @@ public class DBFunc {
* @param plot * @param plot
* @param player * @param player
*/ */
public static void removeDenied(final String world, final Plot plot, public static void removeDenied(final String world, final Plot plot, final OfflinePlayer player) {
final OfflinePlayer player) {
runTask(new Runnable() { runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
PreparedStatement statement = connection PreparedStatement statement =
.prepareStatement("DELETE FROM `plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?"); connection.prepareStatement("DELETE FROM `plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
statement.setInt(1, getId(world, plot.id)); statement.setInt(1, getId(world, plot.id));
statement.setString(2, player.getUniqueId().toString()); statement.setString(2, player.getUniqueId().toString());
statement.executeUpdate(); statement.executeUpdate();
statement.close(); statement.close();
} catch (SQLException e) { }
catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
Logger.add(LogLevel.WARNING, Logger.add(LogLevel.WARNING, "Failed to remove denied for plot " + plot.id);
"Failed to remove denied for plot " + plot.id);
} }
} }
}); });
@ -972,21 +910,20 @@ public class DBFunc {
* @param plot * @param plot
* @param player * @param player
*/ */
public static void setDenied(final String world, final Plot plot, public static void setDenied(final String world, final Plot plot, final OfflinePlayer player) {
final OfflinePlayer player) {
runTask(new Runnable() { runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
PreparedStatement statement = connection PreparedStatement statement =
.prepareStatement("INSERT INTO `plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)"); connection.prepareStatement("INSERT INTO `plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
statement.setInt(1, getId(world, plot.id)); statement.setInt(1, getId(world, plot.id));
statement.setString(2, player.getUniqueId().toString()); statement.setString(2, player.getUniqueId().toString());
statement.executeUpdate(); statement.executeUpdate();
statement.close(); statement.close();
} catch (SQLException e) { }
Logger.add(LogLevel.WARNING, catch (SQLException e) {
"Failed to set denied for plot " + plot.id); Logger.add(LogLevel.WARNING, "Failed to set denied for plot " + plot.id);
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -995,8 +932,8 @@ public class DBFunc {
public static double getRatings(final Plot plot) { public static double getRatings(final Plot plot) {
try { try {
PreparedStatement statement = connection PreparedStatement statement =
.prepareStatement("SELECT AVG(`rating`) AS `rating` FROM `plot_ratings` WHERE `plot_plot_id` = ? "); connection.prepareStatement("SELECT AVG(`rating`) AS `rating` FROM `plot_ratings` WHERE `plot_plot_id` = ? ");
statement.setInt(1, getId(plot.getWorld().getName(), plot.id)); statement.setInt(1, getId(plot.getWorld().getName(), plot.id));
ResultSet set = statement.executeQuery(); ResultSet set = statement.executeQuery();
double rating = 0; double rating = 0;
@ -1005,9 +942,9 @@ public class DBFunc {
} }
statement.close(); statement.close();
return rating; return rating;
} catch (SQLException e) { }
Logger.add(LogLevel.WARNING, "Failed to fetch rating for plot " catch (SQLException e) {
+ plot.getId().toString()); Logger.add(LogLevel.WARNING, "Failed to fetch rating for plot " + plot.getId().toString());
e.printStackTrace(); e.printStackTrace();
} }
return 0.0d; return 0.0d;

View File

@ -39,8 +39,7 @@ public abstract class Database {
* @throws ClassNotFoundException * @throws ClassNotFoundException
* if the driver cannot be found * if the driver cannot be found
*/ */
public abstract Connection openConnection() throws SQLException, public abstract Connection openConnection() throws SQLException, ClassNotFoundException;
ClassNotFoundException;
/** /**
* Checks if a connection is open with the database * Checks if a connection is open with the database
@ -69,7 +68,6 @@ public abstract class Database {
/** /**
* Executes a SQL Query<br> * Executes a SQL Query<br>
*
* If the connection is closed, it will be opened * If the connection is closed, it will be opened
* *
* @param query * @param query
@ -80,8 +78,7 @@ public abstract class Database {
* @throws ClassNotFoundException * @throws ClassNotFoundException
* If the driver cannot be found; see {@link #openConnection()} * If the driver cannot be found; see {@link #openConnection()}
*/ */
public abstract ResultSet querySQL(String query) throws SQLException, public abstract ResultSet querySQL(String query) throws SQLException, ClassNotFoundException;
ClassNotFoundException;
/** /**
* Executes an Update SQL Query<br> * Executes an Update SQL Query<br>
@ -96,6 +93,5 @@ public abstract class Database {
* @throws ClassNotFoundException * @throws ClassNotFoundException
* If the driver cannot be found; see {@link #openConnection()} * If the driver cannot be found; see {@link #openConnection()}
*/ */
public abstract int updateSQL(String query) throws SQLException, public abstract int updateSQL(String query) throws SQLException, ClassNotFoundException;
ClassNotFoundException;
} }

View File

@ -39,8 +39,7 @@ public class MySQL extends Database {
* @param password * @param password
* Password * Password
*/ */
public MySQL(Plugin plugin, String hostname, String port, String database, public MySQL(Plugin plugin, String hostname, String port, String database, String username, String password) {
String username, String password) {
super(plugin); super(plugin);
this.hostname = hostname; this.hostname = hostname;
this.port = port; this.port = port;
@ -51,15 +50,13 @@ public class MySQL extends Database {
} }
@Override @Override
public Connection openConnection() throws SQLException, public Connection openConnection() throws SQLException, ClassNotFoundException {
ClassNotFoundException {
if (checkConnection()) { if (checkConnection()) {
return this.connection; return this.connection;
} }
Class.forName("com.mysql.jdbc.Driver"); Class.forName("com.mysql.jdbc.Driver");
this.connection = DriverManager.getConnection("jdbc:mysql://" this.connection =
+ this.hostname + ":" + this.port + "/" + this.database, DriverManager.getConnection("jdbc:mysql://" + this.hostname + ":" + this.port + "/" + this.database, this.user, this.password);
this.user, this.password);
return this.connection; return this.connection;
} }
@ -83,8 +80,7 @@ public class MySQL extends Database {
} }
@Override @Override
public ResultSet querySQL(String query) throws SQLException, public ResultSet querySQL(String query) throws SQLException, ClassNotFoundException {
ClassNotFoundException {
if (checkConnection()) { if (checkConnection()) {
openConnection(); openConnection();
} }
@ -97,8 +93,7 @@ public class MySQL extends Database {
} }
@Override @Override
public int updateSQL(String query) throws SQLException, public int updateSQL(String query) throws SQLException, ClassNotFoundException {
ClassNotFoundException {
if (checkConnection()) { if (checkConnection()) {
openConnection(); openConnection();
} }

View File

@ -33,180 +33,143 @@ public class PlotMeConverter {
final PrintStream stream = new PrintStream("converter_log.txt"); final PrintStream stream = new PrintStream("converter_log.txt");
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, Bukkit.getScheduler().runTaskAsynchronously(this.plugin, new Runnable() {
new Runnable() { @Override
@Override public void run() {
public void run() { PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has started");
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has started"); PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Caching playerdata...");
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Caching playerdata..."); ArrayList<com.intellectualcrafters.plot.Plot> createdPlots =
ArrayList<com.intellectualcrafters.plot.Plot> createdPlots = new ArrayList<com.intellectualcrafters.plot.Plot>(); new ArrayList<com.intellectualcrafters.plot.Plot>();
boolean online = Bukkit.getServer().getOnlineMode(); boolean online = Bukkit.getServer().getOnlineMode();
for (World world : Bukkit.getWorlds()) { for (World world : Bukkit.getWorlds()) {
HashMap<String, Plot> plots = PlotManager HashMap<String, Plot> plots = PlotManager.getPlots(world);
.getPlots(world); if (plots != null) {
if (plots != null) { PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '" + plots.size()
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '" + "' plots for world '" + world.getName() + "'");
+ 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<UUID> psAdded = new ArrayList<>();
ArrayList<UUID> psTrusted = new ArrayList<>();
ArrayList<UUID> 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<String, UUID> 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<String, UUID> 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) {
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting " + plots.size()
+ " plots for '" + world.toString() + "'...");
for (Plot plot : plots.values()) {
ArrayList<UUID> psAdded = new ArrayList<>();
ArrayList<UUID> psTrusted = new ArrayList<>();
ArrayList<UUID> 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<String, UUID> 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) { if (set.getValue() != null) {
e.printStackTrace(); psAdded.add(set.getValue());
eR3040bl230 = 232000499888388747l; }
} finally {
eR3040bl230 = 232999304998392004l;
} }
stream.println(eR3040bl230); for (Map.Entry<String, UUID> set : denied.getAllPlayers().entrySet()) {
PlotId id = new PlotId( if ((set.getValue() != null) || set.getKey().equals("*")) {
Integer.parseInt(plot.id.split(";")[0]), if (set.getKey().equals("*") || set.getValue().toString().equals("*")) {
Integer.parseInt(plot.id.split(";")[1])); psDenied.add(DBFunc.everyone);
com.intellectualcrafters.plot.Plot pl = null; continue;
if (online) { }
pl = new com.intellectualcrafters.plot.Plot( }
id, plot.getOwnerId(), plot if (set.getValue() != null) {
.getBiome(), psAdded, psDenied.add(set.getValue());
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 });
} }
}
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);
} }
} }
} }
} catch (Throwable e) {
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating plot DB"); e.printStackTrace();
DBFunc.createPlots(createdPlots); eR3040bl230 = 232000499888388747l;
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating settings/helpers DB"); }
DBFunc.createAllSettingsAndHelpers(createdPlots); finally {
stream.close(); eR3040bl230 = 232999304998392004l;
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has finished"); }
// TODO disable PlotMe -> Unload all plot worlds, change stream.println(eR3040bl230);
// the PlotId id =
// generator, restart the server automatically new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1]));
// Possibly use multiverse / multiworld if it's to com.intellectualcrafters.plot.Plot pl = null;
// difficult if (online) {
// modifying a world's generator while the server is pl =
// running new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] {
// Should really do that? Would seem pretty bad from our false, false, false, false });
// side + }
// bukkit wouldn't approve 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( // TODO createPlot doesn't add helpers /
PlotMeConverter.this.plugin); // 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);
}
});
} }
} }

View File

@ -36,8 +36,7 @@ public class SQLite extends Database {
} }
@Override @Override
public Connection openConnection() throws SQLException, public Connection openConnection() throws SQLException, ClassNotFoundException {
ClassNotFoundException {
if (checkConnection()) { if (checkConnection()) {
return this.connection; return this.connection;
} }
@ -48,15 +47,15 @@ public class SQLite extends Database {
if (!(file.exists())) { if (!(file.exists())) {
try { try {
file.createNewFile(); file.createNewFile();
} catch (IOException e) { }
this.plugin.getLogger().log(Level.SEVERE, catch (IOException e) {
"Unable to create database!"); this.plugin.getLogger().log(Level.SEVERE, "Unable to create database!");
} }
} }
Class.forName("org.sqlite.JDBC"); Class.forName("org.sqlite.JDBC");
this.connection = DriverManager.getConnection("jdbc:sqlite:" this.connection =
+ this.plugin.getDataFolder().toPath().toString() + "/" DriverManager.getConnection("jdbc:sqlite:" + this.plugin.getDataFolder().toPath().toString() + "/"
+ this.dbLocation); + this.dbLocation);
return this.connection; return this.connection;
} }
@ -80,8 +79,7 @@ public class SQLite extends Database {
} }
@Override @Override
public ResultSet querySQL(String query) throws SQLException, public ResultSet querySQL(String query) throws SQLException, ClassNotFoundException {
ClassNotFoundException {
if (checkConnection()) { if (checkConnection()) {
openConnection(); openConnection();
} }
@ -94,8 +92,7 @@ public class SQLite extends Database {
} }
@Override @Override
public int updateSQL(String query) throws SQLException, public int updateSQL(String query) throws SQLException, ClassNotFoundException {
ClassNotFoundException {
if (checkConnection()) { if (checkConnection()) {
openConnection(); openConnection();
} }

View File

@ -1,10 +1,10 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlayerClaimPlotEvent.java * >> File = PlayerClaimPlotEvent.java >> Generated by: Citymonstret at
* >> Generated by: Citymonstret at 2014-08-09 15:21 * 2014-08-09 15:21
*/ */
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;

View File

@ -28,8 +28,7 @@ public class PlayerPlotDeniedEvent extends Event {
* @param player * @param player
* @param added * @param added
*/ */
public PlayerPlotDeniedEvent(Player initiator, Plot plot, UUID player, public PlayerPlotDeniedEvent(Player initiator, Plot plot, UUID player, boolean added) {
boolean added) {
this.initiator = initiator; this.initiator = initiator;
this.plot = plot; this.plot = plot;
this.added = added; this.added = added;

View File

@ -27,8 +27,7 @@ public class PlayerPlotHelperEvent extends Event {
* @param player * @param player
* @param added * @param added
*/ */
public PlayerPlotHelperEvent(Player initiator, Plot plot, UUID player, public PlayerPlotHelperEvent(Player initiator, Plot plot, UUID player, boolean added) {
boolean added) {
this.initiator = initiator; this.initiator = initiator;
this.plot = plot; this.plot = plot;
this.added = added; this.added = added;

View File

@ -27,8 +27,7 @@ public class PlayerPlotTrustedEvent extends Event {
* @param player * @param player
* @param added * @param added
*/ */
public PlayerPlotTrustedEvent(Player initiator, Plot plot, UUID player, public PlayerPlotTrustedEvent(Player initiator, Plot plot, UUID player, boolean added) {
boolean added) {
this.initiator = initiator; this.initiator = initiator;
this.plot = plot; this.plot = plot;
this.added = added; this.added = added;

View File

@ -1,10 +1,10 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlayerTeleportToPlotEvent.java * >> File = PlayerTeleportToPlotEvent.java >> Generated by: Citymonstret at
* >> Generated by: Citymonstret at 2014-08-09 14:57 * 2014-08-09 14:57
*/ */
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;
@ -20,8 +20,7 @@ import com.intellectualcrafters.plot.Plot;
/** /**
* Called when a player teleports to a plot * Called when a player teleports to a plot
*/ */
public class PlayerTeleportToPlotEvent extends PlayerEvent implements public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable {
Cancellable {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private Location from; private Location from;

View File

@ -1,10 +1,10 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlotClearEvent.java * >> File = PlotClearEvent.java >> Generated by: Citymonstret at 2014-08-09
* >> Generated by: Citymonstret at 2014-08-09 15:21 * 15:21
*/ */
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;

View File

@ -1,10 +1,10 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlotDeleteEvent.java * >> File = PlotDeleteEvent.java >> Generated by: Citymonstret at 2014-08-09
* >> Generated by: Citymonstret at 2014-08-09 15:21 * 15:21
*/ */
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;

View File

@ -1,10 +1,10 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlayerClaimPlotEvent.java * >> File = PlayerClaimPlotEvent.java >> Generated by: Citymonstret at
* >> Generated by: Citymonstret at 2014-08-09 15:21 * 2014-08-09 15:21
*/ */
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;

View File

@ -1,10 +1,10 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlayerClaimPlotEvent.java * >> File = PlayerClaimPlotEvent.java >> Generated by: Citymonstret at
* >> Generated by: Citymonstret at 2014-08-09 15:21 * 2014-08-09 15:21
*/ */
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;

View File

@ -1,10 +1,10 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlayerClaimPlotEvent.java * >> File = PlayerClaimPlotEvent.java >> Generated by: Citymonstret at
* >> Generated by: Citymonstret at 2014-08-09 15:21 * 2014-08-09 15:21
*/ */
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;

View File

@ -1,10 +1,10 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlayerClaimPlotEvent.java * >> File = PlayerClaimPlotEvent.java >> Generated by: Citymonstret at
* >> Generated by: Citymonstret at 2014-08-09 15:21 * 2014-08-09 15:21
*/ */
package com.intellectualcrafters.plot.events; package com.intellectualcrafters.plot.events;

View File

@ -21,17 +21,14 @@ import com.intellectualcrafters.plot.PlotWorld;
public class DefaultPlotManager extends PlotManager { public class DefaultPlotManager extends PlotManager {
/** /**
* Default implementation of getting a plot at a given location * Default implementation of getting a plot at a given location For a
* * simplified explanation of the math involved: - Get the current coords -
* For a simplified explanation of the math involved: - Get the current * shift these numbers down to something relatable for a single plot
* coords - shift these numbers down to something relatable for a single * (similar to reducing trigonometric functions down to the first quadrant)
* plot (similar to reducing trigonometric functions down to the first * - e.g. If the plot size is 20 blocks, and we are at x=25, it's equivalent
* quadrant) - e.g. If the plot size is 20 blocks, and we are at x=25, it's * to x=5 for that specific plot From this, and knowing how thick the road
* equivalent to x=5 for that specific plot * 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
* 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 @Override
public PlotId getPlotIdAbs(PlotWorld plotworld, Location loc) { public PlotId getPlotIdAbs(PlotWorld plotworld, Location loc) {
@ -49,7 +46,8 @@ public class DefaultPlotManager extends PlotManager {
int pathWidthLower; int pathWidthLower;
if ((dpw.ROAD_WIDTH % 2) == 0) { if ((dpw.ROAD_WIDTH % 2) == 0) {
pathWidthLower = (int) (Math.floor(dpw.ROAD_WIDTH / 2) - 1); pathWidthLower = (int) (Math.floor(dpw.ROAD_WIDTH / 2) - 1);
} else { }
else {
pathWidthLower = (int) Math.floor(dpw.ROAD_WIDTH / 2); pathWidthLower = (int) Math.floor(dpw.ROAD_WIDTH / 2);
} }
@ -98,7 +96,8 @@ public class DefaultPlotManager extends PlotManager {
int pathWidthLower; int pathWidthLower;
if ((dpw.ROAD_WIDTH % 2) == 0) { if ((dpw.ROAD_WIDTH % 2) == 0) {
pathWidthLower = (int) (Math.floor(dpw.ROAD_WIDTH / 2) - 1); pathWidthLower = (int) (Math.floor(dpw.ROAD_WIDTH / 2) - 1);
} else { }
else {
pathWidthLower = (int) Math.floor(dpw.ROAD_WIDTH / 2); pathWidthLower = (int) Math.floor(dpw.ROAD_WIDTH / 2);
} }
@ -123,8 +122,7 @@ public class DefaultPlotManager extends PlotManager {
boolean eastWest = (rx <= pathWidthLower) || (rx > end); boolean eastWest = (rx <= pathWidthLower) || (rx > end);
if (northSouth && eastWest) { if (northSouth && eastWest) {
// This means you are in the intersection // This means you are in the intersection
PlotId id = PlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, PlotId id = PlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, dpw.ROAD_WIDTH));
dpw.ROAD_WIDTH));
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id); Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
if (plot == null) { if (plot == null) {
return null; return null;
@ -137,8 +135,7 @@ public class DefaultPlotManager extends PlotManager {
if (northSouth) { if (northSouth) {
// You are on a road running West to East (yeah, I named the var // You are on a road running West to East (yeah, I named the var
// poorly) // poorly)
PlotId id = PlayerFunctions.getPlotAbs(loc PlotId id = PlayerFunctions.getPlotAbs(loc.add(0, 0, dpw.ROAD_WIDTH));
.add(0, 0, dpw.ROAD_WIDTH));
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id); Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
if (plot == null) { if (plot == null) {
return null; return null;
@ -150,8 +147,7 @@ public class DefaultPlotManager extends PlotManager {
} }
if (eastWest) { if (eastWest) {
// This is the road separating an Eastern and Western plot // This is the road separating an Eastern and Western plot
PlotId id = PlayerFunctions.getPlotAbs(loc PlotId id = PlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 0, 0));
.add(dpw.ROAD_WIDTH, 0, 0));
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id); Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
if (plot == null) { if (plot == null) {
return null; return null;
@ -193,10 +189,8 @@ public class DefaultPlotManager extends PlotManager {
int px = plotid.x; int px = plotid.x;
int pz = plotid.y; int pz = plotid.y;
int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
- ((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 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); return new Location(Bukkit.getWorld(plotworld.worldname), x, 1, z);
} }
@ -211,10 +205,8 @@ public class DefaultPlotManager extends PlotManager {
int px = plotid.x; int px = plotid.x;
int pz = plotid.y; int pz = plotid.y;
int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
- ((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 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); 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 * Clearing the plot needs to only consider removing the blocks - This
* implementation has used the SetCuboid function, as it is fast, and uses * 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 * NMS code - It also makes use of the fact that deleting chunks is a lot
* faster than block updates * 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
* This code is very messy, but you don't need to do something quite as * plots
* complex unless you happen to have 512x512 sized plots
*/ */
@Override @Override
public boolean clearPlot(Player player, Plot plot) { public boolean clearPlot(Player player, Plot plot) {
World world = player.getWorld(); World world = player.getWorld();
DefaultPlotWorld dpw = ((DefaultPlotWorld) PlotMain DefaultPlotWorld dpw = ((DefaultPlotWorld) PlotMain.getWorldSettings(world));
.getWorldSettings(world));
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add( final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
1, 0, 1);
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id); final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
PlotBlock[] plotfloor = dpw.TOP_BLOCK; PlotBlock[] plotfloor = dpw.TOP_BLOCK;
PlotBlock[] filling = dpw.TOP_BLOCK; PlotBlock[] filling = dpw.TOP_BLOCK;
if ((pos2.getBlockX() - pos1.getBlockX()) < 16) { if ((pos2.getBlockX() - pos1.getBlockX()) < 16) {
PlotHelper.setSimpleCuboid( 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));
world, 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));
new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling);
new Location(world, pos2.getBlockX() + 1, 1, pos2 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);
.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; return true;
} }
int startX = (pos1.getBlockX() / 16) * 16; int startX = (pos1.getBlockX() / 16) * 16;
@ -279,73 +251,45 @@ public class DefaultPlotManager extends PlotManager {
Location max = null; Location max = null;
for (int i = startX; i < chunkX; i += 16) { for (int i = startX; i < chunkX; i += 16) {
for (int j = startZ; j < chunkZ; j += 16) { for (int j = startZ; j < chunkZ; j += 16) {
Plot plot1 = PlotHelper.getCurrentPlot(new Location(world, i, Plot plot1 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j));
0, j)); if ((plot1 != null) && (plot1.getId() != plot.getId()) && plot1.hasOwner()) {
if ((plot1 != null) && (plot1.getId() != plot.getId())
&& plot1.hasOwner()) {
break; break;
} }
Plot plot2 = PlotHelper.getCurrentPlot(new Location(world, Plot plot2 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j));
i + 15, 0, j)); if ((plot2 != null) && (plot2.getId() != plot.getId()) && plot2.hasOwner()) {
if ((plot2 != null) && (plot2.getId() != plot.getId())
&& plot2.hasOwner()) {
break; break;
} }
Plot plot3 = PlotHelper.getCurrentPlot(new Location(world, Plot plot3 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
i + 15, 0, j + 15)); if ((plot3 != null) && (plot3.getId() != plot.getId()) && plot3.hasOwner()) {
if ((plot3 != null) && (plot3.getId() != plot.getId())
&& plot3.hasOwner()) {
break; break;
} }
Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i, Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j + 15));
0, j + 15)); if ((plot4 != null) && (plot4.getId() != plot.getId()) && plot4.hasOwner()) {
if ((plot4 != null) && (plot4.getId() != plot.getId())
&& plot4.hasOwner()) {
break; break;
} }
Plot plot5 = PlotHelper.getCurrentPlot(new Location(world, Plot plot5 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
i + 15, 0, j + 15)); if ((plot5 != null) && (plot5.getId() != plot.getId()) && plot5.hasOwner()) {
if ((plot5 != null) && (plot5.getId() != plot.getId())
&& plot5.hasOwner()) {
break; break;
} }
if (min == null) { if (min == null) {
min = new Location(world, Math.max(i - 1, plotMinX), 0, min = new Location(world, Math.max(i - 1, plotMinX), 0, Math.max(j - 1, plotMinZ));
Math.max(j - 1, plotMinZ)); max = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
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));
} }
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); world.regenerateChunk(i / 16, j / 16);
} }
} }
if (min == null) { if (min == null) {
PlotHelper.setSimpleCuboid( 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));
world, 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));
new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(), 1, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT, pos2.getBlockZ() + 1), filling);
new Location(world, pos2.getBlockX() + 1, 1, pos2 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);
.getBlockZ() + 1), new PlotBlock((short) 7, }
(byte) 0)); else {
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) { if (min.getBlockX() < plotMinX) {
min.setX(plotMinX); min.setX(plotMinX);
@ -360,161 +304,45 @@ public class DefaultPlotManager extends PlotManager {
max.setZ(plotMaxZ); max.setZ(plotMaxZ);
} }
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, 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));
plotMinZ), 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));
new Location(world, min.getBlockX() + 1, 1, PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), filling);
min.getBlockZ() + 1), new PlotBlock((short) 7, 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);
(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, 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));
new Location(world, min.getBlockX(), 0, plotMinZ), 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));
new Location(world, max.getBlockX() + 1, 1, PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling);
min.getBlockZ() + 1), new PlotBlock((short) 7, 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);
(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, 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));
new Location(world, max.getBlockX(), 0, plotMinZ), 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));
new Location(world, plotMaxX + 1, 1, min.getBlockZ() + 1), PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling);
new PlotBlock((short) 7, (byte) 0)); 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(), 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 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));
.setSimpleCuboid( 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));
world, PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling);
new Location(world, plotMinX, 0, min.getBlockZ()), 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);
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, 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));
max.getBlockZ()), new Location(world, min.getBlockX() + 1, 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));
1, plotMaxZ + 1), new PlotBlock((short) 7, (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.setSimpleCuboid( 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);
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, 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));
new Location(world, min.getBlockX(), 0, max.getBlockZ()), 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));
new Location(world, max.getBlockX() + 1, 1, plotMaxZ + 1), PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
new PlotBlock((short) 7, (byte) 0)); 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(), 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, 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));
new Location(world, max.getBlockX(), 0, min.getBlockZ()), 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));
new Location(world, plotMaxX + 1, 1, max.getBlockZ() + 1), PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling);
new PlotBlock((short) 7, (byte) 0)); 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(), 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, 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));
new Location(world, max.getBlockX(), 0, max.getBlockZ()), 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));
new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
new PlotBlock((short) 7, (byte) 0)); 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(), 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; return true;
} }
@ -526,25 +354,20 @@ public class DefaultPlotManager extends PlotManager {
public Location getSignLoc(Player player, PlotWorld plotworld, Plot plot) { public Location getSignLoc(Player player, PlotWorld plotworld, Plot plot) {
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld; DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
World world = player.getWorld(); World world = player.getWorld();
return new Location(world, PlotHelper.getPlotBottomLoc(world, plot.id) return new Location(world, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockX(), dpw.ROAD_HEIGHT + 1, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1);
.getBlockX(), dpw.ROAD_HEIGHT + 1, PlotHelper.getPlotBottomLoc(
world, plot.id).getBlockZ() - 1);
} }
@Override @Override
public boolean setFloor(Player player, PlotWorld plotworld, PlotId plotid, public boolean setFloor(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock[] blocks) {
PlotBlock[] blocks) {
World world = player.getWorld(); World world = player.getWorld();
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plotid).add(1, final Location pos1 = PlotHelper.getPlotBottomLoc(world, plotid).add(1, 0, 1);
0, 1);
final Location pos2 = PlotHelper.getPlotTopLoc(world, plotid); final Location pos2 = PlotHelper.getPlotTopLoc(world, plotid);
PlotHelper.setCuboid(world, pos1, pos2, blocks); PlotHelper.setCuboid(world, pos1, pos2, blocks);
return true; return true;
} }
@Override @Override
public boolean setWall(Player player, PlotWorld plotworld, PlotId plotid, public boolean setWall(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock plotblock) {
PlotBlock plotblock) {
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld; DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
World w = player.getWorld(); World w = player.getWorld();
@ -629,30 +452,15 @@ public class DefaultPlotManager extends PlotManager {
int sz = pos1.getBlockZ() - 1; int sz = pos1.getBlockZ() - 1;
int ez = pos2.getBlockZ() + 2; int ez = pos2.getBlockZ() + 2;
PlotHelper 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));
.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), PlotHelper.setSimpleCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), 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);
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), PlotHelper.setSimpleCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), 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);
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), PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
return true; return true;
} }
@ -670,30 +478,15 @@ public class DefaultPlotManager extends PlotManager {
int sx = pos1.getBlockX() - 1; int sx = pos1.getBlockX() - 1;
int ex = pos2.getBlockX() + 2; int ex = pos2.getBlockX() + 2;
PlotHelper 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));
.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), PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING);
new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), 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);
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), PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING);
new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), 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);
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), PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
return true; return true;
} }
@ -710,11 +503,8 @@ public class DefaultPlotManager extends PlotManager {
int sz = pos2.getBlockZ() + 1; int sz = pos2.getBlockZ() + 1;
int ez = (sz + dpw.ROAD_WIDTH) - 1; int ez = (sz + dpw.ROAD_WIDTH) - 1;
PlotHelper.setSimpleCuboid(w, new Location(w, sx, dpw.ROAD_HEIGHT + 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));
sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock( PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
(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; return true;
} }
@ -732,16 +522,9 @@ public class DefaultPlotManager extends PlotManager {
int sz = pos1.getBlockZ(); int sz = pos1.getBlockZ();
int ez = pos2.getBlockZ() + 1; int ez = pos2.getBlockZ() + 1;
PlotHelper.setSimpleCuboid(w, 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));
new Location(w, sx, PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), 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);
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; return true;
} }
@ -759,16 +542,9 @@ public class DefaultPlotManager extends PlotManager {
int sx = pos1.getBlockX(); int sx = pos1.getBlockX();
int ex = pos2.getBlockX() + 1; int ex = pos2.getBlockX() + 1;
PlotHelper.setSimpleCuboid(w, 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));
new Location(w, sx, PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), 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);
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; return true;
} }
@ -785,15 +561,10 @@ public class DefaultPlotManager extends PlotManager {
int sz = loc.getBlockZ() + 1; int sz = loc.getBlockZ() + 1;
int ez = (sz + dpw.ROAD_WIDTH) - 1; int ez = (sz + dpw.ROAD_WIDTH) - 1;
PlotHelper.setSimpleCuboid(world, new Location(world, sx, 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));
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), PlotHelper.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK);
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,
dpw.ROAD_HEIGHT, sz + 1), new Location(world, ex,
dpw.ROAD_HEIGHT + 1, ez), dpw.TOP_BLOCK);
return true; return true;
} }
@ -802,8 +573,7 @@ public class DefaultPlotManager extends PlotManager {
* (OPTIONAL)(UNFINISHED) * (OPTIONAL)(UNFINISHED)
*/ */
@Override @Override
public boolean finishPlotMerge(World world, PlotWorld plotworld, public boolean finishPlotMerge(World world, PlotWorld plotworld, ArrayList<PlotId> plotIds) {
ArrayList<PlotId> plotIds) {
// TODO set plot wall // TODO set plot wall
@ -815,16 +585,12 @@ public class DefaultPlotManager extends PlotManager {
PlotBlock block = dpw.WALL_BLOCK; PlotBlock block = dpw.WALL_BLOCK;
Location megaPlotBot = PlotHelper.getPlotBottomLoc(world, pos1); Location megaPlotBot = PlotHelper.getPlotBottomLoc(world, pos1);
Location megaPlotTop = PlotHelper.getPlotTopLoc(world, pos2).add(1, 0, Location megaPlotTop = PlotHelper.getPlotTopLoc(world, pos2).add(1, 0, 1);
1);
for (int x = megaPlotBot.getBlockX(); x <= megaPlotTop.getBlockX(); x++) { for (int x = megaPlotBot.getBlockX(); x <= megaPlotTop.getBlockX(); x++) {
for (int z = megaPlotBot.getBlockZ(); z <= megaPlotTop.getBlockZ(); z++) { for (int z = megaPlotBot.getBlockZ(); z <= megaPlotTop.getBlockZ(); z++) {
if ((z == megaPlotBot.getBlockZ()) if ((z == megaPlotBot.getBlockZ()) || (z == megaPlotTop.getBlockZ()) || (x == megaPlotBot.getBlockX())
|| (z == megaPlotTop.getBlockZ())
|| (x == megaPlotBot.getBlockX())
|| (x == megaPlotTop.getBlockX())) { || (x == megaPlotTop.getBlockX())) {
world.getBlockAt(x, dpw.WALL_HEIGHT + 1, z) world.getBlockAt(x, dpw.WALL_HEIGHT + 1, z).setTypeIdAndData(block.id, block.data, false);
.setTypeIdAndData(block.id, block.data, false);
} }
} }
} }

View File

@ -68,8 +68,7 @@ public class DefaultPlotWorld extends PlotWorld {
/** /**
* Default main block: 1 * Default main block: 1
*/ */
public static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock( public static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 1, (byte) 0) };
(short) 1, (byte) 0) };
/** /**
* Top blocks * Top blocks
*/ */
@ -77,8 +76,7 @@ public class DefaultPlotWorld extends PlotWorld {
/** /**
* Default top blocks: {"2"} * Default top blocks: {"2"}
*/ */
public static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock( public static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 2, (byte) 0) };
(short) 2, (byte) 0) };
/** /**
* Wall block * Wall block
@ -96,8 +94,7 @@ public class DefaultPlotWorld extends PlotWorld {
/** /**
* Default wall filling: 1 * Default wall filling: 1
*/ */
public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0);
(byte) 0);
/** /**
* Road stripes * Road stripes
@ -106,8 +103,7 @@ public class DefaultPlotWorld extends PlotWorld {
/** /**
* Default road stripes: 35 * Default road stripes: 35
*/ */
public static PlotBlock ROAD_STRIPES_DEFAULT = new PlotBlock((short) 98, public static PlotBlock ROAD_STRIPES_DEFAULT = new PlotBlock((short) 98, (byte) 0);
(byte) 0);
/** /**
* enable road stripes * enable road stripes
*/ */
@ -120,8 +116,7 @@ public class DefaultPlotWorld extends PlotWorld {
/** /**
* Default road block: 155 * Default road block: 155
*/ */
public static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155, public static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155, (byte) 0);
(byte) 0);
/* /*
* Here we are just calling the super method, nothing special * Here we are just calling the super method, nothing special
@ -142,32 +137,19 @@ public class DefaultPlotWorld extends PlotWorld {
@Override @Override
public ConfigurationNode[] getSettingNodes() { public ConfigurationNode[] getSettingNodes() {
// TODO return a set of configuration nodes (used for setup command) // TODO return a set of configuration nodes (used for setup command)
return new ConfigurationNode[] { return new ConfigurationNode[] {
new ConfigurationNode("plot.height", DefaultPlotWorld.PLOT_HEIGHT_DEFAULT, new ConfigurationNode("plot.height", DefaultPlotWorld.PLOT_HEIGHT_DEFAULT, "Plot height", Configuration.INTEGER, true),
"Plot height", Configuration.INTEGER, true), new ConfigurationNode("plot.width", DefaultPlotWorld.PLOT_WIDTH_DEFAULT, "Plot width", Configuration.INTEGER, true),
new ConfigurationNode("plot.width", DefaultPlotWorld.PLOT_WIDTH_DEFAULT, new ConfigurationNode("plot.filling", DefaultPlotWorld.MAIN_BLOCK_DEFAULT, "Plot block", Configuration.BLOCKLIST, true),
"Plot width", Configuration.INTEGER, true), new ConfigurationNode("plot.floor", DefaultPlotWorld.TOP_BLOCK_DEFAULT, "Plot floor block", Configuration.BLOCKLIST, true),
new ConfigurationNode("plot.filling", DefaultPlotWorld.MAIN_BLOCK_DEFAULT, new ConfigurationNode("wall.block", DefaultPlotWorld.WALL_BLOCK_DEFAULT, "Top wall block", Configuration.BLOCK, true),
"Plot block", Configuration.BLOCKLIST, true), new ConfigurationNode("road.width", DefaultPlotWorld.ROAD_WIDTH_DEFAULT, "Road width", Configuration.INTEGER, true),
new ConfigurationNode("plot.floor", DefaultPlotWorld.TOP_BLOCK_DEFAULT, new ConfigurationNode("road.height", DefaultPlotWorld.ROAD_HEIGHT_DEFAULT, "Road height", Configuration.INTEGER, true),
"Plot floor block", Configuration.BLOCKLIST, true), new ConfigurationNode("road.enable_stripes", DefaultPlotWorld.ROAD_STRIPES_ENABLED_DEFAULT, "Enable road stripes", Configuration.BOOLEAN, true),
new ConfigurationNode("wall.block", DefaultPlotWorld.WALL_BLOCK_DEFAULT, new ConfigurationNode("road.block", DefaultPlotWorld.ROAD_BLOCK_DEFAULT, "Road block", Configuration.BLOCK, true),
"Top wall block", Configuration.BLOCK, true), new ConfigurationNode("road.stripes", DefaultPlotWorld.ROAD_STRIPES_DEFAULT, "Road stripe block", Configuration.BLOCK, true),
new ConfigurationNode("road.width", DefaultPlotWorld.ROAD_WIDTH_DEFAULT, new ConfigurationNode("wall.filling", DefaultPlotWorld.WALL_FILLING_DEFAULT, "Wall filling block", Configuration.BLOCK, true),
"Road width", Configuration.INTEGER, true), new ConfigurationNode("wall.height", DefaultPlotWorld.WALL_HEIGHT_DEFAULT, "Wall height", 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) { public void loadConfiguration(ConfigurationSection config) {
this.PLOT_HEIGHT = config.getInt("plot.height"); this.PLOT_HEIGHT = config.getInt("plot.height");
this.PLOT_WIDTH = config.getInt("plot.width"); this.PLOT_WIDTH = config.getInt("plot.width");
this.MAIN_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST this.MAIN_BLOCK =
.parseString(StringUtils.join( (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.filling"), ','));
config.getStringList("plot.filling"), ',')); this.TOP_BLOCK =
this.TOP_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST (PlotBlock[]) Configuration.BLOCKLIST.parseString(StringUtils.join(config.getStringList("plot.floor"), ','));
.parseString(StringUtils.join( this.WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.block"));
config.getStringList("plot.floor"), ','));
this.WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config
.getString("wall.block"));
this.ROAD_WIDTH = config.getInt("road.width"); this.ROAD_WIDTH = config.getInt("road.width");
this.ROAD_HEIGHT = config.getInt("road.height"); this.ROAD_HEIGHT = config.getInt("road.height");
this.ROAD_STRIPES_ENABLED = config.getBoolean("road.enable_stripes"); this.ROAD_STRIPES_ENABLED = config.getBoolean("road.enable_stripes");
this.ROAD_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config this.ROAD_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.block"));
.getString("road.block")); this.ROAD_STRIPES = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.stripes"));
this.ROAD_STRIPES = (PlotBlock) Configuration.BLOCK.parseString(config this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.filling"));
.getString("road.stripes"));
this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config
.getString("wall.filling"));
this.WALL_HEIGHT = config.getInt("wall.height"); this.WALL_HEIGHT = config.getInt("wall.height");
} }

View File

@ -15,16 +15,12 @@ import com.intellectualcrafters.plot.PlotManager;
import com.intellectualcrafters.plot.PlotWorld; import com.intellectualcrafters.plot.PlotWorld;
/** /**
*
* @auther Empire92 * @auther Empire92
* @author Citymonstret * @author Citymonstret The default generator is very messy, as we have decided
* * to try externalize all calculations from within the loop. - You will
* The default generator is very messy, as we have decided to try * see a lot of slower implementations have a single for loop. - This is
* 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 * perfectly fine to do, it will just mean world generation may take
* somewhat longer * somewhat longer
*
*/ */
public class WorldGenerator extends PlotGenerator { public class WorldGenerator extends PlotGenerator {
/** /**
@ -59,8 +55,9 @@ public class WorldGenerator extends PlotGenerator {
final PlotBlock[] filling; final PlotBlock[] filling;
/** /**
* Return the plot manager for this type of generator, or create one * Return the plot manager for this type of generator, or create one For
* For square plots you may as well use the default plot manager which comes with PlotSquared * square plots you may as well use the default plot manager which comes
* with PlotSquared
*/ */
@Override @Override
public PlotManager getPlotManager() { public PlotManager getPlotManager() {
@ -71,14 +68,13 @@ public class WorldGenerator extends PlotGenerator {
} }
/** /**
* Get a new plotworld class * Get a new plotworld class For square plots you can use the
* For square plots you can use the DefaultPlotWorld class which comes with PlotSquared * DefaultPlotWorld class which comes with PlotSquared
*
*/ */
@Override @Override
public PlotWorld getNewPlotWorld(String world) { public PlotWorld getNewPlotWorld(String world) {
this.plotworld = new DefaultPlotWorld(world); this.plotworld = new DefaultPlotWorld(world);
return this.plotworld; 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) { private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks) {
if (blocks.length == 1) { if (blocks.length == 1) {
setCuboidRegion(x1, x2, y1, y2, z1, z2, blocks[0]); setCuboidRegion(x1, x2, y1, y2, z1, z2, blocks[0]);
} else { }
else {
for (int x = x1; x < x2; x++) { for (int x = x1; x < x2; x++) {
for (int z = z1; z < z2; z++) { for (int z = z1; z < z2; z++) {
for (int y = y1; y < y2; y++) { 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 * Initialize variables, and create plotworld object used in calculations
*/ */
public WorldGenerator(String world) { public WorldGenerator(String world) {
super(world); super(world);
this.plotsize = this.plotworld.PLOT_WIDTH; this.plotsize = this.plotworld.PLOT_WIDTH;
this.pathsize = this.plotworld.ROAD_WIDTH; this.pathsize = this.plotworld.ROAD_WIDTH;
this.floor1 = this.plotworld.ROAD_BLOCK; this.floor1 = this.plotworld.ROAD_BLOCK;
@ -201,20 +198,21 @@ public class WorldGenerator extends PlotGenerator {
*/ */
@Override @Override
public short[][] generateExtBlockSections(World world, Random random, int cx, int cz, BiomeGrid biomes) { public short[][] generateExtBlockSections(World world, Random random, int cx, int cz, BiomeGrid biomes) {
int maxY = world.getMaxHeight(); int maxY = world.getMaxHeight();
this.result = new short[maxY / 16][]; this.result = new short[maxY / 16][];
final int prime = 31; final int prime = 31;
int h = 1; int h = 1;
h = (prime * h) + cx; h = (prime * h) + cx;
h = (prime * h) + cz; h = (prime * h) + cz;
this.state = h; this.state = h;
double pathWidthLower; double pathWidthLower;
if ((this.pathsize % 2) == 0) { if ((this.pathsize % 2) == 0) {
pathWidthLower = Math.floor(this.pathsize / 2) - 1; pathWidthLower = Math.floor(this.pathsize / 2) - 1;
} else { }
else {
pathWidthLower = Math.floor(this.pathsize / 2); pathWidthLower = Math.floor(this.pathsize / 2);
} }
cx = (cx % this.size) + (8 * this.size); cx = (cx % this.size) + (8 * this.size);
@ -231,7 +229,7 @@ public class WorldGenerator extends PlotGenerator {
if (roadStartZ >= this.size) { if (roadStartZ >= this.size) {
roadStartZ -= this.size; roadStartZ -= this.size;
} }
// BOTTOM (1/1 cuboids) // BOTTOM (1/1 cuboids)
for (int x = 0; x < 16; x++) { for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) { 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 // ROAD (0/24) The following is an inefficient placeholder as it is too
// much work to finish it // much work to finish it
if ((this.pathsize > 16) if ((this.pathsize > 16) && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ))
&& ((plotMinX > roadStartX) || (plotMinZ > roadStartZ))
&& !((roadStartX < 16) && (roadStartZ < 16)) && !((roadStartX < 16) && (roadStartZ < 16))
&& (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) { && (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) {
setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1); setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1);
return this.result; return this.result;
} }
if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) { if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) {
int start = Math.max((16 - plotMinZ - this.pathsize) + 1, int start = Math.max((16 - plotMinZ - this.pathsize) + 1, (16 - roadStartZ) + 1);
(16 - roadStartZ) + 1); int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) + this.pathsize);
int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ)
+ this.pathsize);
if ((start >= 0) && (start <= 16) && (end < 0)) { if ((start >= 0) && (start <= 16) && (end < 0)) {
end = 16; end = 16;
} }
setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0), setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0), Math.min(16, end), this.floor1);
Math.min(16, end), this.floor1);
} }
if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) { if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) {
int start = Math.max((16 - plotMinX - this.pathsize) + 1, int start = Math.max((16 - plotMinX - this.pathsize) + 1, (16 - roadStartX) + 1);
(16 - roadStartX) + 1); int end = Math.min(16 - plotMinX - 1, (16 - roadStartX) + this.pathsize);
int end = Math.min(16 - plotMinX - 1, (16 - roadStartX)
+ this.pathsize);
if ((start >= 0) && (start <= 16) && (end < 0)) { if ((start >= 0) && (start <= 16) && (end < 0)) {
end = 16; end = 16;
} }
setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1, setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1, this.roadheight + 1, 0, 16, this.floor1);
this.roadheight + 1, 0, 16, this.floor1);
} }
// ROAD STRIPES // ROAD STRIPES
@ -278,88 +269,84 @@ public class WorldGenerator extends PlotGenerator {
int start, end; int start, end;
if ((plotMinX + 2) <= 16) { if ((plotMinX + 2) <= 16) {
start = 16 - plotMinX - 1; start = 16 - plotMinX - 1;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartX - 1) <= 16) { if ((roadStartX - 1) <= 16) {
end = (16 - roadStartX) + 1; end = (16 - roadStartX) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, 16 - value, (16 - value) + 1, this.floor2); //
16 - value, (16 - value) + 1, this.floor2); // setCuboidRegion(start, 16, 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) { if ((plotMinX + 2) <= 16) {
int value = (plotMinX + 2); int value = (plotMinX + 2);
int start, end; int start, end;
if ((plotMinZ + 2) <= 16) { if ((plotMinZ + 2) <= 16) {
start = 16 - plotMinZ - 1; start = 16 - plotMinZ - 1;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartZ - 1) <= 16) { if ((roadStartZ - 1) <= 16) {
end = (16 - roadStartZ) + 1; end = (16 - roadStartZ) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight, setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight, this.wallheight + 1, 0, end, this.floor2); //
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, start, 16, this.floor2); //
} }
if ((roadStartZ <= 16) && (roadStartZ > 1)) { if ((roadStartZ <= 16) && (roadStartZ > 1)) {
int val = roadStartZ; int val = roadStartZ;
int start, end; int start, end;
if ((plotMinX + 2) <= 16) { if ((plotMinX + 2) <= 16) {
start = 16 - plotMinX - 1; start = 16 - plotMinX - 1;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartX - 1) <= 16) { if ((roadStartX - 1) <= 16) {
end = (16 - roadStartX) + 1; end = (16 - roadStartX) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, setCuboidRegion(0, end, this.wallheight, this.wallheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2);
(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(start, 16, this.wallheight,
this.wallheight + 1, (16 - val) + 1, (16 - val) + 2,
this.floor2);
} }
if ((roadStartX <= 16) && (roadStartX > 1)) { if ((roadStartX <= 16) && (roadStartX > 1)) {
int val = roadStartX; int val = roadStartX;
int start, end; int start, end;
if ((plotMinZ + 2) <= 16) { if ((plotMinZ + 2) <= 16) {
start = 16 - plotMinZ - 1; start = 16 - plotMinZ - 1;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartZ - 1) <= 16) { if ((roadStartZ - 1) <= 16) {
end = (16 - roadStartZ) + 1; end = (16 - roadStartZ) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion((16 - val) + 1, (16 - val) + 2, setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.wallheight, this.wallheight + 1, 0, end, this.floor2); //
this.wallheight, this.wallheight + 1, 0, end, setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.wallheight, this.wallheight + 1, start, 16, this.floor2); //
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 (this.plotsize > 16) {
if (roadStartX <= 16) { if (roadStartX <= 16) {
if (roadStartZ <= 16) { if (roadStartZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
16 - roadStartZ, this.filling); setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
setCuboidRegion(0, 16 - roadStartX, this.plotheight,
this.plotheight + 1, 0, 16 - roadStartZ,
this.plotfloors);
} }
if (plotMinZ <= 16) { if (plotMinZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
16 - plotMinZ, 16, this.filling); setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
setCuboidRegion(0, 16 - roadStartX, this.plotheight,
this.plotheight + 1, 16 - plotMinZ, 16,
this.plotfloors);
} }
} else { }
else {
if (roadStartZ <= 16) { if (roadStartZ <= 16) {
if (plotMinX > 16) { if (plotMinX > 16) {
setCuboidRegion(0, 16, 1, this.plotheight, 0, setCuboidRegion(0, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
16 - roadStartZ, this.filling); setCuboidRegion(0, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
setCuboidRegion(0, 16, this.plotheight,
this.plotheight + 1, 0, 16 - roadStartZ,
this.plotfloors);
} }
} }
} }
if (plotMinX <= 16) { if (plotMinX <= 16) {
if (plotMinZ <= 16) { if (plotMinZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
16 - plotMinZ, 16, this.filling); setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
setCuboidRegion(16 - plotMinX, 16, this.plotheight, }
this.plotheight + 1, 16 - plotMinZ, 16, else {
this.plotfloors);
} else {
int z = 16 - roadStartZ; int z = 16 - roadStartZ;
if (z < 0) { if (z < 0) {
z = 16; z = 16;
} }
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, z, this.filling);
z, this.filling); setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors);
setCuboidRegion(16 - plotMinX, 16, this.plotheight,
this.plotheight + 1, 0, z, this.plotfloors);
} }
if (roadStartZ <= 16) { if (roadStartZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
16 - roadStartZ, this.filling); setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
setCuboidRegion(16 - plotMinX, 16, this.plotheight, }
this.plotheight + 1, 0, 16 - roadStartZ, else {
this.plotfloors);
} else {
if (roadStartX <= 16) { if (roadStartX <= 16) {
if (plotMinZ > 16) { if (plotMinZ > 16) {
int x = 16 - roadStartX; int x = 16 - roadStartX;
if (x < 0) { if (x < 0) {
x = 16; x = 16;
} }
setCuboidRegion(0, x, 1, this.plotheight, 0, 16, setCuboidRegion(0, x, 1, this.plotheight, 0, 16, this.filling);
this.filling); setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, 16, this.plotfloors);
setCuboidRegion(0, x, this.plotheight,
this.plotheight + 1, 0, 16, this.plotfloors);
} }
} }
} }
} else { }
else {
if (plotMinZ <= 16) { if (plotMinZ <= 16) {
if (roadStartX > 16) { if (roadStartX > 16) {
int x = 16 - roadStartX; int x = 16 - roadStartX;
if (x < 0) { if (x < 0) {
x = 16; x = 16;
} }
setCuboidRegion(0, x, 1, this.plotheight, setCuboidRegion(0, x, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
16 - plotMinZ, 16, this.filling); setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
setCuboidRegion(0, x, this.plotheight,
this.plotheight + 1, 16 - plotMinZ, 16,
this.plotfloors);
} }
} else { }
else {
if (roadStartZ > 16) { if (roadStartZ > 16) {
int x = 16 - roadStartX; int x = 16 - roadStartX;
if (x < 0) { if (x < 0) {
@ -452,50 +422,36 @@ public class WorldGenerator extends PlotGenerator {
z = 16; z = 16;
} }
if (roadStartX > 16) { if (roadStartX > 16) {
setCuboidRegion(0, x, 1, this.plotheight, 0, z, setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling);
this.filling); setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors);
setCuboidRegion(0, x, this.plotheight, }
this.plotheight + 1, 0, z, this.plotfloors); else {
} else { setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling);
setCuboidRegion(0, x, 1, this.plotheight, 0, z, setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors);
this.filling);
setCuboidRegion(0, x, this.plotheight,
this.plotheight + 1, 0, z, this.plotfloors);
} }
} }
} }
} }
} else { }
else {
if (roadStartX <= 16) { if (roadStartX <= 16) {
if (roadStartZ <= 16) { if (roadStartZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
16 - roadStartZ, this.filling); setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
setCuboidRegion(0, 16 - roadStartX, this.plotheight,
this.plotheight + 1, 0, 16 - roadStartZ,
this.plotfloors);
} }
if (plotMinZ <= 16) { if (plotMinZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
16 - plotMinZ, 16, this.filling); setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
setCuboidRegion(0, 16 - roadStartX, this.plotheight,
this.plotheight + 1, 16 - plotMinZ, 16,
this.plotfloors);
} }
} }
if (plotMinX <= 16) { if (plotMinX <= 16) {
if (plotMinZ <= 16) { if (plotMinZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
16 - plotMinZ, 16, this.filling); setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
setCuboidRegion(16 - plotMinX, 16, this.plotheight,
this.plotheight + 1, 16 - plotMinZ, 16,
this.plotfloors);
} }
if (roadStartZ <= 16) { if (roadStartZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
16 - roadStartZ, this.filling); setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
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; int start, end;
if ((plotMinX + 2) <= 16) { if ((plotMinX + 2) <= 16) {
start = 16 - plotMinX - 1; start = 16 - plotMinX - 1;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartX - 1) <= 16) { if ((roadStartX - 1) <= 16) {
end = (16 - roadStartX) + 1; end = (16 - roadStartX) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(0, end, 1, this.wallheight + 1, setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling);
16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling); setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall);
setCuboidRegion(0, end, this.wallheight + 1, setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling);
this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall);
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) { if ((plotMinX + 1) <= 16) {
int start, end; int start, end;
if ((plotMinZ + 2) <= 16) { if ((plotMinZ + 2) <= 16) {
start = 16 - plotMinZ - 1; start = 16 - plotMinZ - 1;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartZ - 1) <= 16) { if ((roadStartZ - 1) <= 16) {
end = (16 - roadStartZ) + 1; end = (16 - roadStartZ) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, 0, end, this.wallfilling);
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, setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, start, 16, this.wallfilling);
this.wallheight + 1, this.wallheight + 2, 0, end, setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall);
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)) { if ((roadStartZ <= 16) && (roadStartZ > 0)) {
int start, end; int start, end;
if ((plotMinX + 1) <= 16) { if ((plotMinX + 1) <= 16) {
start = 16 - plotMinX; start = 16 - plotMinX;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartX + 1) <= 16) { if ((roadStartX + 1) <= 16) {
end = (16 - roadStartX) + 1; end = (16 - roadStartX) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) { if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(0, end, 1, this.wallheight + 1, setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling);
16 - roadStartZ, (16 - roadStartZ) + 1, setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall);
this.wallfilling); setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling);
setCuboidRegion(0, end, this.wallheight + 1, setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall);
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)) { if ((roadStartX <= 16) && (roadStartX > 0)) {
int start, end; int start, end;
if ((plotMinZ + 1) <= 16) { if ((plotMinZ + 1) <= 16) {
start = 16 - plotMinZ; start = 16 - plotMinZ;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartZ + 1) <= 16) { if ((roadStartZ + 1) <= 16) {
end = (16 - roadStartZ) + 1; end = (16 - roadStartZ) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinZ + 1) <= 16) || ((roadStartZ + 1) <= 16))) { if (!(((plotMinZ + 1) <= 16) || ((roadStartZ + 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, 0, end, this.wallfilling);
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, setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, start, 16, this.wallfilling);
this.wallheight + 1, this.roadheight + 2, 0, end, setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall);
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 // Return the chunk

View File

@ -11,9 +11,7 @@ import com.intellectualcrafters.plot.PlotBlock;
import com.intellectualcrafters.plot.PlotWorld; import com.intellectualcrafters.plot.PlotWorld;
/** /**
*
* @author Citymonstret * @author Citymonstret
*
*/ */
public class XPopulator extends BlockPopulator { public class XPopulator extends BlockPopulator {
@ -46,8 +44,7 @@ public class XPopulator extends BlockPopulator {
return (int) result; return (int) result;
} }
public void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, public void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock block, World w) {
PlotBlock block, World w) {
if (block.data == 0) { if (block.data == 0) {
return; return;
} }
@ -60,11 +57,11 @@ public class XPopulator extends BlockPopulator {
} }
} }
private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks, World w) {
int z2, PlotBlock[] blocks, World w) {
if (blocks.length == 1) { if (blocks.length == 1) {
setCuboidRegion(x1, x2, y1, y2, z1, z2, blocks[0], w); setCuboidRegion(x1, x2, y1, y2, z1, z2, blocks[0], w);
} else { }
else {
for (int x = x1; x < x2; x++) { for (int x = x1; x < x2; x++) {
for (int z = z1; z < z2; z++) { for (int z = z1; z < z2; z++) {
for (int y = y1; y < y2; y++) { for (int y = y1; y < y2; y++) {
@ -82,8 +79,7 @@ public class XPopulator extends BlockPopulator {
public short[] getBlock(String block) { public short[] getBlock(String block) {
if (block.contains(":")) { if (block.contains(":")) {
String[] split = block.split(":"); String[] split = block.split(":");
return new short[] { Short.parseShort(split[0]), return new short[] { Short.parseShort(split[0]), Short.parseShort(split[1]) };
Short.parseShort(split[1]) };
} }
return new short[] { Short.parseShort(block), 0 }; return new short[] { Short.parseShort(block), 0 };
} }
@ -129,7 +125,8 @@ public class XPopulator extends BlockPopulator {
if ((this.pathsize % 2) == 0) { if ((this.pathsize % 2) == 0) {
this.pathWidthLower = Math.floor(this.pathsize / 2) - 1; this.pathWidthLower = Math.floor(this.pathsize / 2) - 1;
} else { }
else {
this.pathWidthLower = Math.floor(this.pathsize / 2); this.pathWidthLower = Math.floor(this.pathsize / 2);
} }
} }
@ -148,8 +145,8 @@ public class XPopulator extends BlockPopulator {
this.Z = cz << 4; this.Z = cz << 4;
cx = (cx % this.size) + (8 * this.size); cx = (cx % this.size) + (8 * this.size);
cz = (cz % 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) double absX = ((((cx * 16) + 16) - this.pathWidthLower - 1) + (8 * this.size)), absZ =
- this.pathWidthLower - 1) + (8 * this.size)); ((((cz * 16) + 16) - this.pathWidthLower - 1) + (8 * this.size));
int plotMinX = (int) (((absX) % this.size)); int plotMinX = (int) (((absX) % this.size));
int plotMinZ = (int) (((absZ) % this.size)); int plotMinZ = (int) (((absZ) % this.size));
int roadStartX = (plotMinX + this.pathsize); int roadStartX = (plotMinX + this.pathsize);
@ -163,36 +160,28 @@ public class XPopulator extends BlockPopulator {
// ROADS // ROADS
if ((this.pathsize > 16) if ((this.pathsize > 16) && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ))
&& ((plotMinX > roadStartX) || (plotMinZ > roadStartZ))
&& !((roadStartX < 16) && (roadStartZ < 16)) && !((roadStartX < 16) && (roadStartZ < 16))
&& (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) { && (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) {
setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1, setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1, w);
w);
return; return;
} }
if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) { if (((plotMinZ + 1) <= 16) || ((roadStartZ <= 16) && (roadStartZ > 0))) {
int start = Math.max((16 - plotMinZ - this.pathsize) + 1, int start = Math.max((16 - plotMinZ - this.pathsize) + 1, (16 - roadStartZ) + 1);
(16 - roadStartZ) + 1); int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) + this.pathsize);
int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ)
+ this.pathsize);
if ((start >= 0) && (start <= 16) && (end < 0)) { if ((start >= 0) && (start <= 16) && (end < 0)) {
end = 16; end = 16;
} }
setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0), setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0), Math.min(16, end), this.floor1, w);
Math.min(16, end), this.floor1, w);
} }
if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) { if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) {
int start = Math.max((16 - plotMinX - this.pathsize) + 1, int start = Math.max((16 - plotMinX - this.pathsize) + 1, (16 - roadStartX) + 1);
(16 - roadStartX) + 1); int end = Math.min(16 - plotMinX - 1, (16 - roadStartX) + this.pathsize);
int end = Math.min(16 - plotMinX - 1, (16 - roadStartX)
+ this.pathsize);
if ((start >= 0) && (start <= 16) && (end < 0)) { if ((start >= 0) && (start <= 16) && (end < 0)) {
end = 16; end = 16;
} }
setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1, setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1, this.roadheight + 1, 0, 16, this.floor1, w);
this.roadheight + 1, 0, 16, this.floor1, w);
} }
// STRIPES // STRIPES
@ -202,88 +191,84 @@ public class XPopulator extends BlockPopulator {
int start, end; int start, end;
if ((plotMinX + 2) <= 16) { if ((plotMinX + 2) <= 16) {
start = 16 - plotMinX - 1; start = 16 - plotMinX - 1;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartX - 1) <= 16) { if ((roadStartX - 1) <= 16) {
end = (16 - roadStartX) + 1; end = (16 - roadStartX) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, 16 - value, (16 - value) + 1, this.floor2, w); //
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(start, 16, this.roadheight,
this.roadheight + 1, 16 - value, (16 - value) + 1,
this.floor2, w); //
} }
if ((plotMinX + 2) <= 16) { if ((plotMinX + 2) <= 16) {
int value = (plotMinX + 2); int value = (plotMinX + 2);
int start, end; int start, end;
if ((plotMinZ + 2) <= 16) { if ((plotMinZ + 2) <= 16) {
start = 16 - plotMinZ - 1; start = 16 - plotMinZ - 1;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartZ - 1) <= 16) { if ((roadStartZ - 1) <= 16) {
end = (16 - roadStartZ) + 1; end = (16 - roadStartZ) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight, setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight, this.roadheight + 1, 0, end, this.floor2, w); //
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, start, 16, this.floor2, w); //
} }
if ((roadStartZ <= 16) && (roadStartZ > 1)) { if ((roadStartZ <= 16) && (roadStartZ > 1)) {
int val = roadStartZ; int val = roadStartZ;
int start, end; int start, end;
if ((plotMinX + 2) <= 16) { if ((plotMinX + 2) <= 16) {
start = 16 - plotMinX - 1; start = 16 - plotMinX - 1;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartX - 1) <= 16) { if ((roadStartX - 1) <= 16) {
end = (16 - roadStartX) + 1; end = (16 - roadStartX) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, setCuboidRegion(0, end, this.roadheight, this.roadheight + 1, (16 - val) + 1, (16 - val) + 2, this.floor2, w);
(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(start, 16, this.roadheight,
this.roadheight + 1, (16 - val) + 1, (16 - val) + 2,
this.floor2, w);
} }
if ((roadStartX <= 16) && (roadStartX > 1)) { if ((roadStartX <= 16) && (roadStartX > 1)) {
int val = roadStartX; int val = roadStartX;
int start, end; int start, end;
if ((plotMinZ + 2) <= 16) { if ((plotMinZ + 2) <= 16) {
start = 16 - plotMinZ - 1; start = 16 - plotMinZ - 1;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartZ - 1) <= 16) { if ((roadStartZ - 1) <= 16) {
end = (16 - roadStartZ) + 1; end = (16 - roadStartZ) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion((16 - val) + 1, (16 - val) + 2, setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.roadheight, this.roadheight + 1, 0, end, this.floor2, w); //
this.roadheight, this.roadheight + 1, 0, end, setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.roadheight, this.roadheight + 1, start, 16, this.floor2, w); //
this.floor2, w); //
setCuboidRegion((16 - val) + 1, (16 - val) + 2,
this.roadheight, this.roadheight + 1, start, 16,
this.floor2, w); //
} }
} }
// WALLS // WALLS
@ -292,107 +277,89 @@ public class XPopulator extends BlockPopulator {
int start, end; int start, end;
if ((plotMinX + 2) <= 16) { if ((plotMinX + 2) <= 16) {
start = 16 - plotMinX - 1; start = 16 - plotMinX - 1;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartX - 1) <= 16) { if ((roadStartX - 1) <= 16) {
end = (16 - roadStartX) + 1; end = (16 - roadStartX) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) { if (!(((plotMinX + 2) <= 16) || ((roadStartX - 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(0, end, 1, this.wallheight + 1, setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling, w);
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(0, end, this.wallheight + 1, setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling, w);
this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall, w);
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) { if ((plotMinX + 1) <= 16) {
int start, end; int start, end;
if ((plotMinZ + 2) <= 16) { if ((plotMinZ + 2) <= 16) {
start = 16 - plotMinZ - 1; start = 16 - plotMinZ - 1;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartZ - 1) <= 16) { if ((roadStartZ - 1) <= 16) {
end = (16 - roadStartZ) + 1; end = (16 - roadStartZ) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) { if (!(((plotMinZ + 2) <= 16) || ((roadStartZ - 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, 0, end, this.wallfilling, w);
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, setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, start, 16, this.wallfilling, w);
this.wallheight + 1, this.wallheight + 2, 0, end, setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall, w);
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)) { if ((roadStartZ <= 16) && (roadStartZ > 0)) {
int start, end; int start, end;
if ((plotMinX + 1) <= 16) { if ((plotMinX + 1) <= 16) {
start = 16 - plotMinX; start = 16 - plotMinX;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartX + 1) <= 16) { if ((roadStartX + 1) <= 16) {
end = (16 - roadStartX) + 1; end = (16 - roadStartX) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) { if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(0, end, 1, this.wallheight + 1, setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling, w);
16 - roadStartZ, (16 - roadStartZ) + 1, setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall, w);
this.wallfilling, w); setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling, w);
setCuboidRegion(0, end, this.wallheight + 1, setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall, w);
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)) { if ((roadStartX <= 16) && (roadStartX > 0)) {
int start, end; int start, end;
if ((plotMinZ + 1) <= 16) { if ((plotMinZ + 1) <= 16) {
start = 16 - plotMinZ; start = 16 - plotMinZ;
} else { }
else {
start = 16; start = 16;
} }
if ((roadStartZ + 1) <= 16) { if ((roadStartZ + 1) <= 16) {
end = (16 - roadStartZ) + 1; end = (16 - roadStartZ) + 1;
} else { }
else {
end = 0; end = 0;
} }
if (!(((plotMinZ + 1) <= 16) || ((roadStartZ + 1) <= 16))) { if (!(((plotMinZ + 1) <= 16) || ((roadStartZ + 1) <= 16))) {
start = 0; start = 0;
} }
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, 0, end, this.wallfilling, w);
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, setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, start, 16, this.wallfilling, w);
this.wallheight + 1, this.roadheight + 2, 0, end, setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall, w);
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 (this.plotsize > 16) {
if (roadStartX <= 16) { if (roadStartX <= 16) {
if (roadStartZ <= 16) { if (roadStartZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w);
16 - roadStartZ, this.filling, w); setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
setCuboidRegion(0, 16 - roadStartX, this.plotheight,
this.plotheight + 1, 0, 16 - roadStartZ,
this.plotfloors, w);
} }
if (plotMinZ <= 16) { if (plotMinZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w);
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, this.plotheight,
this.plotheight + 1, 16 - plotMinZ, 16,
this.plotfloors, w);
} }
} else { }
else {
if (roadStartZ <= 16) { if (roadStartZ <= 16) {
if (plotMinX > 16) { if (plotMinX > 16) {
setCuboidRegion(0, 16, 1, this.plotheight, 0, setCuboidRegion(0, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w);
16 - roadStartZ, this.filling, w); setCuboidRegion(0, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
setCuboidRegion(0, 16, this.plotheight,
this.plotheight + 1, 0, 16 - roadStartZ,
this.plotfloors, w);
} }
} }
} }
if (plotMinX <= 16) { if (plotMinX <= 16) {
if (plotMinZ <= 16) { if (plotMinZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w);
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, this.plotheight, }
this.plotheight + 1, 16 - plotMinZ, 16, else {
this.plotfloors, w);
} else {
int z = 16 - roadStartZ; int z = 16 - roadStartZ;
if (z < 0) { if (z < 0) {
z = 16; z = 16;
} }
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, z, this.filling, w);
z, this.filling, w); setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors, w);
setCuboidRegion(16 - plotMinX, 16, this.plotheight,
this.plotheight + 1, 0, z, this.plotfloors, w);
} }
if (roadStartZ <= 16) { if (roadStartZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w);
16 - roadStartZ, this.filling, w); setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
setCuboidRegion(16 - plotMinX, 16, this.plotheight, }
this.plotheight + 1, 0, 16 - roadStartZ, else {
this.plotfloors, w);
} else {
if (roadStartX <= 16) { if (roadStartX <= 16) {
if (plotMinZ > 16) { if (plotMinZ > 16) {
int x = 16 - roadStartX; int x = 16 - roadStartX;
if (x < 0) { if (x < 0) {
x = 16; x = 16;
} }
setCuboidRegion(0, x, 1, this.plotheight, 0, 16, setCuboidRegion(0, x, 1, this.plotheight, 0, 16, this.filling, w);
this.filling, w); setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, 16, this.plotfloors, w);
setCuboidRegion(0, x, this.plotheight,
this.plotheight + 1, 0, 16,
this.plotfloors, w);
} }
} }
} }
} else { }
else {
if (plotMinZ <= 16) { if (plotMinZ <= 16) {
if (roadStartX > 16) { if (roadStartX > 16) {
int x = 16 - roadStartX; int x = 16 - roadStartX;
if (x < 0) { if (x < 0) {
x = 16; x = 16;
} }
setCuboidRegion(0, x, 1, this.plotheight, setCuboidRegion(0, x, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w);
16 - plotMinZ, 16, this.filling, w); setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w);
setCuboidRegion(0, x, this.plotheight,
this.plotheight + 1, 16 - plotMinZ, 16,
this.plotfloors, w);
} }
} else { }
else {
if (roadStartZ > 16) { if (roadStartZ > 16) {
int x = 16 - roadStartX; int x = 16 - roadStartX;
if (x < 0) { if (x < 0) {
@ -487,52 +436,36 @@ public class XPopulator extends BlockPopulator {
z = 16; z = 16;
} }
if (roadStartX > 16) { if (roadStartX > 16) {
setCuboidRegion(0, x, 1, this.plotheight, 0, z, setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling, w);
this.filling, w); setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors, w);
setCuboidRegion(0, x, this.plotheight, }
this.plotheight + 1, 0, z, this.plotfloors, else {
w); setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling, w);
} else { 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 { }
else {
if (roadStartX <= 16) { if (roadStartX <= 16) {
if (roadStartZ <= 16) { if (roadStartZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w);
16 - roadStartZ, this.filling, w); setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
setCuboidRegion(0, 16 - roadStartX, this.plotheight,
this.plotheight + 1, 0, 16 - roadStartZ,
this.plotfloors, w);
} }
if (plotMinZ <= 16) { if (plotMinZ <= 16) {
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w);
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, this.plotheight,
this.plotheight + 1, 16 - plotMinZ, 16,
this.plotfloors, w);
} }
} }
if (plotMinX <= 16) { if (plotMinX <= 16) {
if (plotMinZ <= 16) { if (plotMinZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w);
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, this.plotheight,
this.plotheight + 1, 16 - plotMinZ, 16,
this.plotfloors, w);
} }
if (roadStartZ <= 16) { if (roadStartZ <= 16) {
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w);
16 - roadStartZ, this.filling, w); setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
setCuboidRegion(16 - plotMinX, 16, this.plotheight,
this.plotheight + 1, 0, 16 - roadStartZ,
this.plotfloors, w);
} }
} }
} }

View File

@ -1,10 +1,9 @@
/* /*
* Copyright (c) IntellectualCrafters - 2014. * Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
* You are not allowed to distribute and/or monetize any of our intellectual property. * and/or monetize any of our intellectual property. IntellectualCrafters is not
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB. * affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
* *
* >> File = PlayerEvents.java * >> File = PlayerEvents.java >> Generated by: Citymonstret at 2014-08-09 01:43
* >> Generated by: Citymonstret at 2014-08-09 01:43
*/ */
package com.intellectualcrafters.plot.listeners; package com.intellectualcrafters.plot.listeners;
@ -90,10 +89,8 @@ public class PlayerEvents implements Listener {
} }
public boolean enteredPlot(Location l1, Location l2) { public boolean enteredPlot(Location l1, Location l2) {
PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1 PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 64, l1.getBlockZ()));
.getBlockX(), 64, l1.getBlockZ())); PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 64, l2.getBlockZ()));
PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2
.getBlockX(), 64, l2.getBlockZ()));
if (p2 == null) { if (p2 == null) {
return false; return false;
} }
@ -107,10 +104,8 @@ public class PlayerEvents implements Listener {
} }
public boolean leftPlot(Location l1, Location l2) { public boolean leftPlot(Location l1, Location l2) {
PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1 PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 64, l1.getBlockZ()));
.getBlockX(), 64, l1.getBlockZ())); PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 64, l2.getBlockZ()));
PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2
.getBlockX(), 64, l2.getBlockZ()));
if (p1 == null) { if (p1 == null) {
return false; return false;
} }
@ -144,8 +139,7 @@ public class PlayerEvents implements Listener {
if (PlotMain.getPlots(world).containsKey(id)) { if (PlotMain.getPlots(world).containsKey(id)) {
return PlotMain.getPlots(world).get(id); return PlotMain.getPlots(world).get(id);
} }
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), loc.getWorld().getName());
new ArrayList<UUID>(), loc.getWorld().getName());
} }
@EventHandler @EventHandler
@ -162,18 +156,17 @@ public class PlayerEvents implements Listener {
} }
private void textures(Player p) { private void textures(Player p) {
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld())) {
&& isPlotWorld(p.getWorld())) {
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK); p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
} }
} }
@EventHandler @EventHandler
public void onChangeWorld(PlayerChangedWorldEvent event) { public void onChangeWorld(PlayerChangedWorldEvent event) {
if (isPlotWorld(event.getFrom()) if (isPlotWorld(event.getFrom()) && (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) {
&& (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) {
event.getPlayer().setResourcePack(""); event.getPlayer().setResourcePack("");
} else { }
else {
textures(event.getPlayer()); textures(event.getPlayer());
} }
} }
@ -181,14 +174,10 @@ public class PlayerEvents implements Listener {
public void plotEntry(Player player, Plot plot) { public void plotEntry(Player player, Plot plot) {
if (plot.hasOwner()) { if (plot.hasOwner()) {
if (C.TITLE_ENTERED_PLOT.s().length() > 2) { if (C.TITLE_ENTERED_PLOT.s().length() > 2) {
String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", plot.getDisplayName());
plot.getDisplayName()); String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner));
String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst( ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s());
"%s", getName(plot.owner)); ChatColor sTitleSubColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s());
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 title = new Title(sTitleMain, sTitleSub, 10, 20, 10);
title.setTitleColor(sTitleMainColor); title.setTitleColor(sTitleMainColor);
title.setSubtitleColor(sTitleSubColor); title.setSubtitleColor(sTitleSubColor);
@ -196,8 +185,7 @@ public class PlayerEvents implements Listener {
title.send(player); title.send(player);
} }
{ {
PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent( PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot);
player, plot);
Bukkit.getPluginManager().callEvent(callEvent); Bukkit.getPluginManager().callEvent(callEvent);
} }
PlayerFunctions.sendMessage(player, plot.settings.getJoinMessage()); PlayerFunctions.sendMessage(player, plot.settings.getJoinMessage());
@ -212,8 +200,7 @@ public class PlayerEvents implements Listener {
public void plotExit(Player player, Plot plot) { public void plotExit(Player player, Plot plot) {
{ {
PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
plot);
Bukkit.getPluginManager().callEvent(callEvent); Bukkit.getPluginManager().callEvent(callEvent);
} }
player.resetPlayerTime(); player.resetPlayerTime();
@ -221,14 +208,14 @@ public class PlayerEvents implements Listener {
PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage()); PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage());
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(
priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void PlayerMove(PlayerMoveEvent event) { public void PlayerMove(PlayerMoveEvent event) {
try { try {
Player player = event.getPlayer(); Player player = event.getPlayer();
Location from = event.getFrom(); Location from = event.getFrom();
Location to = event.getTo(); Location to = event.getTo();
if ((from.getBlockX() != to.getBlockX()) if ((from.getBlockX() != to.getBlockX()) || (from.getBlockZ() != to.getBlockZ())) {
|| (from.getBlockZ() != to.getBlockZ())) {
if (!isPlotWorld(player.getWorld())) { if (!isPlotWorld(player.getWorld())) {
return; return;
} }
@ -240,17 +227,21 @@ public class PlayerEvents implements Listener {
return; return;
} }
plotEntry(player, plot); 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. // Gotta catch 'em all.
} }
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(
priority = EventPriority.HIGHEST)
public void onChat(AsyncPlayerChatEvent event) { public void onChat(AsyncPlayerChatEvent event) {
World world = event.getPlayer().getWorld(); World world = event.getPlayer().getWorld();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
@ -275,13 +266,14 @@ public class PlayerEvents implements Listener {
recipients.add(p); recipients.add(p);
} }
} }
format = format.replaceAll("%plot_id%", id.x + ";" + id.y) format =
.replaceAll("%sender%", sender).replaceAll("%msg%", message); format.replaceAll("%plot_id%", id.x + ";" + id.y).replaceAll("%sender%", sender).replaceAll("%msg%", message);
format = ChatColor.translateAlternateColorCodes('&', format); format = ChatColor.translateAlternateColorCodes('&', format);
event.setFormat(format); event.setFormat(format);
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(
priority = EventPriority.HIGH)
public void BlockDestroy(BlockBreakEvent event) { public void BlockDestroy(BlockBreakEvent event) {
World world = event.getPlayer().getWorld(); World world = event.getPlayer().getWorld();
if (!isPlotWorld(world)) { 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) { public void BlockCreate(BlockPlaceEvent event) {
World world = event.getPlayer().getWorld(); World world = event.getPlayer().getWorld();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
@ -330,9 +323,10 @@ public class PlayerEvents implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPeskyMobsChangeTheWorldLikeWTFEvent( // LOL! public void onPeskyMobsChangeTheWorldLikeWTFEvent( // LOL!
EntityChangeBlockEvent event) { EntityChangeBlockEvent event) {
World world = event.getBlock().getWorld(); World world = event.getBlock().getWorld();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
return; return;
@ -342,29 +336,34 @@ public class PlayerEvents implements Listener {
if (!(e instanceof org.bukkit.entity.FallingBlock)) { if (!(e instanceof org.bukkit.entity.FallingBlock)) {
event.setCancelled(true); event.setCancelled(true);
} }
} else { }
else {
Block b = event.getBlock(); Block b = event.getBlock();
Player p = (Player) e; Player p = (Player) e;
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
event.setCancelled(true); event.setCancelled(true);
} }
} else { }
else {
Plot plot = getCurrentPlot(b.getLocation()); Plot plot = getCurrentPlot(b.getLocation());
if (plot == null) { if (plot == null) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
event.setCancelled(true); 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) { public void onEntityBlockForm(final EntityBlockFormEvent event) {
World world = event.getBlock().getWorld(); World world = event.getBlock().getWorld();
if (!isPlotWorld(world)) { 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) { public void onBS(final BlockSpreadEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
if (isPlotWorld(b.getLocation())) { 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) { public void onBF(final BlockFormEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
if (isPlotWorld(b.getLocation())) { 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) { public void onBD(final BlockDamageEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
if (isPlotWorld(b.getLocation())) { 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) { public void onFade(final BlockFadeEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
if (isPlotWorld(b.getLocation())) { 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) { public void onChange(final BlockFromToEvent e) {
Block b = e.getToBlock(); Block b = e.getToBlock();
if (isPlotWorld(b.getLocation())) { 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) { public void onGrow(final BlockGrowEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
if (isPlotWorld(b.getLocation())) { 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) { public void onBlockPistonExtend(final BlockPistonExtendEvent e) {
if (isInPlot(e.getBlock().getLocation())) { if (isInPlot(e.getBlock().getLocation())) {
@ -445,13 +451,19 @@ public class PlayerEvents implements Listener {
{ {
if (e.getDirection() == BlockFace.EAST) { if (e.getDirection() == BlockFace.EAST) {
l = e.getBlock().getLocation().subtract(modifier, 0, 0); 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)) { if (!isInPlot(l)) {
e.setCancelled(true); e.setCancelled(true);
@ -467,36 +479,43 @@ public class PlayerEvents implements Listener {
if (!isInPlot(b.getLocation().subtract(1, 0, 0))) { if (!isInPlot(b.getLocation().subtract(1, 0, 0))) {
e.setCancelled(true); 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) { public void onBlockPistonRetract(final BlockPistonRetractEvent e) {
Block b = e.getRetractLocation().getBlock(); Block b = e.getRetractLocation().getBlock();
if (isPlotWorld(b.getLocation()) if (isPlotWorld(b.getLocation()) && (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) {
&& (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) {
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
e.setCancelled(true); e.setCancelled(true);
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true)
public void onStructureGrow(final StructureGrowEvent e) { public void onStructureGrow(final StructureGrowEvent e) {
List<BlockState> blocks = e.getBlocks(); List<BlockState> blocks = e.getBlocks();
boolean remove = false; boolean remove = false;
@ -524,19 +543,19 @@ public class PlayerEvents implements Listener {
} }
if (isInPlot(event.getClickedBlock().getLocation())) { if (isInPlot(event.getClickedBlock().getLocation())) {
Plot plot = getCurrentPlot(event.getClickedBlock().getLocation()); Plot plot = getCurrentPlot(event.getClickedBlock().getLocation());
// They shouldn't be allowed to access other people's chests // They shouldn't be allowed to access other people's chests
// if (new ArrayList<>(Arrays.asList(new Material[] { // if (new ArrayList<>(Arrays.asList(new Material[] {
// Material.STONE_BUTTON, Material.WOOD_BUTTON, // Material.STONE_BUTTON, Material.WOOD_BUTTON,
// Material.LEVER, Material.STONE_PLATE, Material.WOOD_PLATE, // Material.LEVER, Material.STONE_PLATE, Material.WOOD_PLATE,
// Material.CHEST, Material.TRAPPED_CHEST, Material.TRAP_DOOR, // Material.CHEST, Material.TRAPPED_CHEST, Material.TRAP_DOOR,
// Material.WOOD_DOOR, Material.WOODEN_DOOR, // Material.WOOD_DOOR, Material.WOODEN_DOOR,
// Material.DISPENSER, Material.DROPPER // Material.DISPENSER, Material.DROPPER
// //
// })).contains(event.getClickedBlock().getType())) { // })).contains(event.getClickedBlock().getType())) {
// return; // return;
// } // }
if (!plot.hasRights(event.getPlayer())) { if (!plot.hasRights(event.getPlayer())) {
event.setCancelled(true); 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) { public void onBlockIgnite(final BlockIgniteEvent e) {
if (e.getCause() == BlockIgniteEvent.IgniteCause.LIGHTNING) { if (e.getCause() == BlockIgniteEvent.IgniteCause.LIGHTNING) {
e.setCancelled(true); e.setCancelled(true);
@ -574,25 +594,30 @@ public class PlayerEvents implements Listener {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
e.setCancelled(true); e.setCancelled(true);
} }
} else { }
else {
Plot plot = getCurrentPlot(b.getLocation()); Plot plot = getCurrentPlot(b.getLocation());
if (plot == null) { if (plot == null) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
e.setCancelled(true); 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); e.setCancelled(true);
} }
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(
priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent event) { public void onTeleport(PlayerTeleportEvent event) {
Location f = event.getFrom(); Location f = event.getFrom();
@ -602,64 +627,65 @@ public class PlayerEvents implements Listener {
if (isInPlot(event.getTo())) { if (isInPlot(event.getTo())) {
Plot plot = getCurrentPlot(event.getTo()); Plot plot = getCurrentPlot(event.getTo());
if (plot.deny_entry(event.getPlayer())) { if (plot.deny_entry(event.getPlayer())) {
PlayerFunctions.sendMessage(event.getPlayer(), PlayerFunctions.sendMessage(event.getPlayer(), C.YOU_BE_DENIED);
C.YOU_BE_DENIED);
event.setCancelled(true); event.setCancelled(true);
} else { }
else {
if (enteredPlot(f, t)) { if (enteredPlot(f, t)) {
plotEntry(event.getPlayer(), plot); plotEntry(event.getPlayer(), plot);
} }
} }
} else { }
else {
if (leftPlot(f, t)) { if (leftPlot(f, t)) {
Plot plot = getCurrentPlot(event.getTo()); Plot plot = getCurrentPlot(event.getTo());
plotExit(event.getPlayer(), plot); plotExit(event.getPlayer(), plot);
} }
} }
if ((event.getTo().getBlockX() >= 29999999) if ((event.getTo().getBlockX() >= 29999999) || (event.getTo().getBlockX() <= -29999999)
|| (event.getTo().getBlockX() <= -29999999) || (event.getTo().getBlockZ() >= 29999999) || (event.getTo().getBlockZ() <= -29999999)) {
|| (event.getTo().getBlockZ() >= 29999999)
|| (event.getTo().getBlockZ() <= -29999999)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBucketEmpty(PlayerBucketEmptyEvent e) { public void onBucketEmpty(PlayerBucketEmptyEvent e) {
if (!e.getPlayer().hasPermission("plots.admin")) { if (!e.getPlayer().hasPermission("plots.admin")) {
BlockFace bf = e.getBlockFace(); BlockFace bf = e.getBlockFace();
Block b = e.getBlockClicked().getLocation() Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock();
.add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock();
if (isPlotWorld(b.getLocation())) { if (isPlotWorld(b.getLocation())) {
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
e.setCancelled(true); e.setCancelled(true);
} else { }
else {
Plot plot = getCurrentPlot(b.getLocation()); Plot plot = getCurrentPlot(b.getLocation());
if (plot == null) { if (plot == null) {
PlayerFunctions.sendMessage(e.getPlayer(), PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
C.NO_PERMISSION);
e.setCancelled(true);
} else if (!plot.hasRights(e.getPlayer())) {
PlayerFunctions.sendMessage(e.getPlayer(),
C.NO_PERMISSION);
e.setCancelled(true); 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) { public void onInventoryClick(InventoryClickEvent event) {
if (event.getInventory().getName() if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) {
.equalsIgnoreCase("PlotSquared Commands")) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBucketFill(PlayerBucketFillEvent e) { public void onBucketFill(PlayerBucketFillEvent e) {
if (!e.getPlayer().hasPermission("plots.admin")) { if (!e.getPlayer().hasPermission("plots.admin")) {
Block b = e.getBlockClicked(); Block b = e.getBlockClicked();
@ -667,23 +693,25 @@ public class PlayerEvents implements Listener {
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
e.setCancelled(true); e.setCancelled(true);
} else { }
else {
Plot plot = getCurrentPlot(b.getLocation()); Plot plot = getCurrentPlot(b.getLocation());
if (plot == null) { if (plot == null) {
PlayerFunctions.sendMessage(e.getPlayer(), PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
C.NO_PERMISSION);
e.setCancelled(true);
} else if (!plot.hasRights(e.getPlayer())) {
PlayerFunctions.sendMessage(e.getPlayer(),
C.NO_PERMISSION);
e.setCancelled(true); 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) { public void onHangingPlace(final HangingPlaceEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
if (isPlotWorld(b.getLocation())) { if (isPlotWorld(b.getLocation())) {
@ -693,24 +721,28 @@ public class PlayerEvents implements Listener {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
e.setCancelled(true); e.setCancelled(true);
} }
} else { }
else {
Plot plot = getCurrentPlot(b.getLocation()); Plot plot = getCurrentPlot(b.getLocation());
if (plot == null) { if (plot == null) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
e.setCancelled(true); 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) { public void onHangingBreakByEntity(final HangingBreakByEntityEvent e) {
Entity r = e.getRemover(); Entity r = e.getRemover();
if (r instanceof Player) { if (r instanceof Player) {
@ -722,25 +754,29 @@ public class PlayerEvents implements Listener {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
e.setCancelled(true); e.setCancelled(true);
} }
} else { }
else {
Plot plot = getCurrentPlot(l); Plot plot = getCurrentPlot(l);
if (plot == null) { if (plot == null) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
e.setCancelled(true); 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) { public void onPlayerInteractEntity(final PlayerInteractEntityEvent e) {
Location l = e.getRightClicked().getLocation(); Location l = e.getRightClicked().getLocation();
if (isPlotWorld(l)) { if (isPlotWorld(l)) {
@ -750,24 +786,28 @@ public class PlayerEvents implements Listener {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
e.setCancelled(true); e.setCancelled(true);
} }
} else { }
else {
Plot plot = getCurrentPlot(l); Plot plot = getCurrentPlot(l);
if (plot == null) { if (plot == null) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
e.setCancelled(true); 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) { public void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) {
Location l = e.getEntity().getLocation(); Location l = e.getEntity().getLocation();
Entity d = e.getDamager(); Entity d = e.getDamager();
@ -779,25 +819,29 @@ public class PlayerEvents implements Listener {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
e.setCancelled(true); e.setCancelled(true);
} }
} else { }
else {
Plot plot = getCurrentPlot(l); Plot plot = getCurrentPlot(l);
if (plot == null) { if (plot == null) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
e.setCancelled(true); 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) { public void onPlayerEggThrow(final PlayerEggThrowEvent e) {
Location l = e.getEgg().getLocation(); Location l = e.getEgg().getLocation();
if (isPlotWorld(l)) { if (isPlotWorld(l)) {
@ -807,19 +851,22 @@ public class PlayerEvents implements Listener {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
e.setHatching(false); e.setHatching(false);
} }
} else { }
else {
Plot plot = getCurrentPlot(l); Plot plot = getCurrentPlot(l);
if (plot == null) { if (plot == null) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
e.setHatching(false); 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);
}
}
} }
} }
} }

View File

@ -27,22 +27,19 @@ import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
/** /**
*
* @author Citymonstret * @author Citymonstret
*
*/ */
public class WorldEditListener implements Listener { public class WorldEditListener implements Listener {
public final Set<String> blockedcmds = new HashSet<String>(Arrays.asList( public final Set<String> blockedcmds = new HashSet<String>(Arrays.asList("/gmask", "//gmask", "/worldedit:gmask"));
"/gmask", "//gmask", "/worldedit:gmask")); public final Set<String> restrictedcmds = new HashSet<String>(Arrays.asList("/up", "//up", "/worldedit:up"));
public final Set<String> restrictedcmds = new HashSet<String>(
Arrays.asList("/up", "//up", "/worldedit:up"));
private boolean isPlotWorld(Location l) { private boolean isPlotWorld(Location l) {
return (PlotMain.isPlotWorld(l.getWorld())); return (PlotMain.isPlotWorld(l.getWorld()));
} }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(
priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onInteract(PlayerInteractEvent e) { public void onInteract(PlayerInteractEvent e) {
Block b = e.getClickedBlock(); Block b = e.getClickedBlock();
if (b == null) { if (b == null) {
@ -54,27 +51,23 @@ public class WorldEditListener implements Listener {
return; return;
} }
p.getItemInHand(); p.getItemInHand();
if ((p.getItemInHand() == null) if ((p.getItemInHand() == null) || (p.getItemInHand().getType() == Material.AIR)) {
|| (p.getItemInHand().getType() == Material.AIR)) {
return; return;
} }
Plot plot = PlotHelper.getCurrentPlot(b.getLocation()); Plot plot = PlotHelper.getCurrentPlot(b.getLocation());
if (plot != null) { if (plot != null) {
if ((plot != null) if ((plot != null) && plot.hasOwner() && (plot.helpers != null)
&& plot.hasOwner() && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
&& (plot.helpers != null)
&& (plot.helpers.contains(DBFunc.everyone) || plot.helpers
.contains(p.getUniqueId()))) {
PWE.setMask(p, l); PWE.setMask(p, l);
} }
} }
} }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(
priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerCommand(PlayerCommandPreprocessEvent e) { public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
if (PlotMain.hasPermission(p, "plots.worldedit.bypass") if (PlotMain.hasPermission(p, "plots.worldedit.bypass") || !PlotMain.isPlotWorld(p.getWorld())) {
|| !PlotMain.isPlotWorld(p.getWorld())) {
return; return;
} }
String cmd = e.getMessage().toLowerCase(); String cmd = e.getMessage().toLowerCase();
@ -84,17 +77,18 @@ public class WorldEditListener implements Listener {
} }
if (this.restrictedcmds.contains(cmd)) { if (this.restrictedcmds.contains(cmd)) {
Plot plot = PlayerFunctions.getCurrentPlot(p); Plot plot = PlayerFunctions.getCurrentPlot(p);
if ((plot == null) if ((plot == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
|| !(plot.helpers.contains(DBFunc.everyone) || plot.helpers
.contains(p.getUniqueId()))) {
e.setCancelled(true); 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) { public void onPlayerJoin(final PlayerJoinEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
if (PlotMain.hasPermission(p, "plots.worldedit.bypass")) { if (PlotMain.hasPermission(p, "plots.worldedit.bypass")) {
@ -103,12 +97,14 @@ public class WorldEditListener implements Listener {
Location l = p.getLocation(); Location l = p.getLocation();
if (isPlotWorld(l)) { if (isPlotWorld(l)) {
PWE.setMask(p, l); PWE.setMask(p, l);
} else { }
else {
PWE.removeMask(p); PWE.removeMask(p);
} }
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(
priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent e) { public void onPlayerMove(final PlayerMoveEvent e) {
Location t = e.getTo(); Location t = e.getTo();
if (!isPlotWorld(t)) { if (!isPlotWorld(t)) {
@ -117,8 +113,7 @@ public class WorldEditListener implements Listener {
Location f = e.getFrom(); Location f = e.getFrom();
Player p = e.getPlayer(); Player p = e.getPlayer();
if ((f.getBlockX() != t.getBlockX()) if ((f.getBlockX() != t.getBlockX()) || (f.getBlockZ() != t.getBlockZ())) {
|| (f.getBlockZ() != t.getBlockZ())) {
PlotId idF = PlayerFunctions.getPlot(f); PlotId idF = PlayerFunctions.getPlot(f);
PlotId idT = PlayerFunctions.getPlot(t); PlotId idT = PlayerFunctions.getPlot(t);
if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { 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) { public void onPortal(PlayerPortalEvent e) {
if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) {
return; 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) { public void onTeleport(final PlayerTeleportEvent e) {
if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) { if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) {
return; return;
@ -163,7 +160,8 @@ public class WorldEditListener implements Listener {
if (!isPlotWorld(t)) { if (!isPlotWorld(t)) {
if (isPlotWorld(f)) { if (isPlotWorld(f)) {
PWE.removeMask(p); PWE.removeMask(p);
} else { }
else {
return; return;
} }
} }

View File

@ -50,19 +50,19 @@ public class WorldGuardListener implements Listener {
manager.getRegion(plot.id.x + "-" + plot.id.y); manager.getRegion(plot.id.x + "-" + plot.id.y);
for (Flag flag : this.flags) { for (Flag flag : this.flags) {
if (flag.getName().equalsIgnoreCase(key)) { if (flag.getName().equalsIgnoreCase(key)) {
requester.performCommand("region flag " requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key);
+ (plot.id.x + "-" + plot.id.y) + " " + key);
} }
} }
} catch (Exception e) { }
catch (Exception e) {
requester.setOp(op); requester.setOp(op);
} finally { }
finally {
requester.setOp(op); requester.setOp(op);
} }
} }
public void addFlag(Player requester, World world, Plot plot, String key, public void addFlag(Player requester, World world, Plot plot, String key, String value) {
String value) {
boolean op = requester.isOp(); boolean op = requester.isOp();
requester.setOp(true); requester.setOp(true);
try { try {
@ -70,19 +70,20 @@ public class WorldGuardListener implements Listener {
manager.getRegion(plot.id.x + "-" + plot.id.y); manager.getRegion(plot.id.x + "-" + plot.id.y);
for (Flag flag : this.flags) { for (Flag flag : this.flags) {
if (flag.getName().equalsIgnoreCase(key)) { if (flag.getName().equalsIgnoreCase(key)) {
requester.performCommand("region flag " requester.performCommand("region flag " + (plot.id.x + "-" + plot.id.y) + " " + key + " " + value);
+ (plot.id.x + "-" + plot.id.y) + " " + key + " "
+ value);
} }
} }
} catch (Exception e) { }
catch (Exception e) {
requester.setOp(op); requester.setOp(op);
} finally { }
finally {
requester.setOp(op); requester.setOp(op);
} }
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(
priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMerge(PlotMergeEvent event) { public void onMerge(PlotMergeEvent event) {
Plot main = event.getPlot(); Plot main = event.getPlot();
ArrayList<PlotId> plots = event.getPlots(); ArrayList<PlotId> plots = event.getPlots();
@ -99,17 +100,12 @@ public class WorldGuardListener implements Listener {
DefaultDomain members = region.getMembers(); DefaultDomain members = region.getMembers();
manager.removeRegion(main.id.x + "-" + main.id.y); manager.removeRegion(main.id.x + "-" + main.id.y);
Location location1 = PlotHelper Location location1 = PlotHelper.getPlotBottomLocAbs(world, plots.get(0));
.getPlotBottomLocAbs(world, plots.get(0)); Location location2 = PlotHelper.getPlotTopLocAbs(world, plots.get(plots.size() - 1));
Location location2 = PlotHelper.getPlotTopLocAbs(world,
plots.get(plots.size() - 1));
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
location1.getBlockZ()); BlockVector vector2 = new BlockVector(location2.getBlockX(), world.getMaxHeight(), location2.getBlockZ());
BlockVector vector2 = new BlockVector(location2.getBlockX(), ProtectedRegion rg = new ProtectedCuboidRegion(main.id.x + "-" + main.id.y, vector1, vector2);
world.getMaxHeight(), location2.getBlockZ());
ProtectedRegion rg = new ProtectedCuboidRegion(main.id.x + "-"
+ main.id.y, vector1, vector2);
rg.setFlags(flags); rg.setFlags(flags);
@ -120,7 +116,8 @@ public class WorldGuardListener implements Listener {
manager.addRegion(rg); manager.addRegion(rg);
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(
priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onUnlink(PlotUnlinkEvent event) { public void onUnlink(PlotUnlinkEvent event) {
World w = event.getWorld(); World w = event.getWorld();
ArrayList<PlotId> plots = event.getPlots(); ArrayList<PlotId> plots = event.getPlots();
@ -139,12 +136,9 @@ public class WorldGuardListener implements Listener {
Location location1 = PlotHelper.getPlotBottomLocAbs(w, id); Location location1 = PlotHelper.getPlotBottomLocAbs(w, id);
Location location2 = PlotHelper.getPlotTopLocAbs(w, id); Location location2 = PlotHelper.getPlotTopLocAbs(w, id);
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
location1.getBlockZ()); BlockVector vector2 = new BlockVector(location2.getBlockX(), w.getMaxHeight(), location2.getBlockZ());
BlockVector vector2 = new BlockVector(location2.getBlockX(), ProtectedRegion rg = new ProtectedCuboidRegion(id.x + "-" + id.y, vector1, vector2);
w.getMaxHeight(), location2.getBlockZ());
ProtectedRegion rg = new ProtectedCuboidRegion(id.x + "-" + id.y,
vector1, vector2);
rg.setFlags(flags); rg.setFlags(flags);
@ -160,21 +154,16 @@ public class WorldGuardListener implements Listener {
public void onPlotClaim(PlayerClaimPlotEvent event) { public void onPlotClaim(PlayerClaimPlotEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
Plot plot = event.getPlot(); Plot plot = event.getPlot();
RegionManager manager = PlotMain.worldGuard.getRegionManager(plot RegionManager manager = PlotMain.worldGuard.getRegionManager(plot.getWorld());
.getWorld());
Location location1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), Location location1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId());
plot.getId()); Location location2 = PlotHelper.getPlotTopLoc(plot.getWorld(), plot.getId());
Location location2 = PlotHelper.getPlotTopLoc(plot.getWorld(),
plot.getId());
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
location1.getBlockZ()); BlockVector vector2 =
BlockVector vector2 = new BlockVector(location2.getBlockX(), plot new BlockVector(location2.getBlockX(), plot.getWorld().getMaxHeight(), location2.getBlockZ());
.getWorld().getMaxHeight(), location2.getBlockZ());
ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2);
+ plot.getId().y, vector1, vector2);
DefaultDomain owner = new DefaultDomain(); DefaultDomain owner = new DefaultDomain();
owner.addPlayer(PlotMain.worldGuard.wrapPlayer(player)); owner.addPlayer(PlotMain.worldGuard.wrapPlayer(player));

View File

@ -15,9 +15,7 @@ import org.json.simple.parser.JSONParser;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
/** /**
*
* @author * @author
*
*/ */
public class NameFetcher implements Callable<Map<UUID, String>> { public class NameFetcher implements Callable<Map<UUID, String>> {
private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/"; private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/";
@ -35,11 +33,10 @@ public class NameFetcher implements Callable<Map<UUID, String>> {
if (uuidStringMap.containsKey(uuid)) { if (uuidStringMap.containsKey(uuid)) {
continue; continue;
} }
HttpURLConnection connection = (HttpURLConnection) new URL( HttpURLConnection connection =
PROFILE_URL + uuid.toString().replace("-", "")) (HttpURLConnection) new URL(PROFILE_URL + uuid.toString().replace("-", "")).openConnection();
.openConnection(); JSONObject response =
JSONObject response = (JSONObject) this.jsonParser (JSONObject) this.jsonParser.parse(new InputStreamReader(connection.getInputStream()));
.parse(new InputStreamReader(connection.getInputStream()));
String name = (String) response.get("name"); String name = (String) response.get("name");
if (name == null) { if (name == null) {
continue; continue;

View File

@ -40,15 +40,13 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
@Override @Override
public Map<String, UUID> call() throws Exception { public Map<String, UUID> call() throws Exception {
Map<String, UUID> uuidMap = new HashMap<String, UUID>(); Map<String, UUID> uuidMap = new HashMap<String, UUID>();
int requests = (int) Math int requests = (int) Math.ceil(this.names.size() / PROFILES_PER_REQUEST);
.ceil(this.names.size() / PROFILES_PER_REQUEST);
for (int i = 0; i < requests; i++) { for (int i = 0; i < requests; i++) {
HttpURLConnection connection = createConnection(); HttpURLConnection connection = createConnection();
String body = JSONArray.toJSONString(this.names.subList(i * 100, String body =
Math.min((i + 1) * 100, this.names.size()))); JSONArray.toJSONString(this.names.subList(i * 100, Math.min((i + 1) * 100, this.names.size())));
writeBody(connection, body); writeBody(connection, body);
JSONArray array = (JSONArray) this.jsonParser JSONArray array = (JSONArray) this.jsonParser.parse(new InputStreamReader(connection.getInputStream()));
.parse(new InputStreamReader(connection.getInputStream()));
for (Object profile : array) { for (Object profile : array) {
JSONObject jsonProfile = (JSONObject) profile; JSONObject jsonProfile = (JSONObject) profile;
String id = (String) jsonProfile.get("id"); String id = (String) jsonProfile.get("id");
@ -63,8 +61,7 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
return uuidMap; return uuidMap;
} }
private static void writeBody(HttpURLConnection connection, String body) private static void writeBody(HttpURLConnection connection, String body) throws Exception {
throws Exception {
OutputStream stream = connection.getOutputStream(); OutputStream stream = connection.getOutputStream();
stream.write(body.getBytes()); stream.write(body.getBytes());
stream.flush(); stream.flush();
@ -83,9 +80,8 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
} }
public static UUID getUUID(String id) { public static UUID getUUID(String id) {
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-"
+ "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32));
+ id.substring(20, 32));
} }
public static byte[] toBytes(UUID uuid) { public static byte[] toBytes(UUID uuid) {
@ -97,8 +93,7 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
public static UUID fromBytes(byte[] array) { public static UUID fromBytes(byte[] array) {
if (array.length != 16) { if (array.length != 16) {
throw new IllegalArgumentException("Illegal byte array length: " throw new IllegalArgumentException("Illegal byte array length: " + array.length);
+ array.length);
} }
ByteBuffer byteBuffer = ByteBuffer.wrap(array); ByteBuffer byteBuffer = ByteBuffer.wrap(array);
long mostSignificant = byteBuffer.getLong(); long mostSignificant = byteBuffer.getLong();

View File

@ -37,15 +37,13 @@ public class IndexHandler implements Container {
if ((request.getInteger("page")) < 0) { if ((request.getInteger("page")) < 0) {
} }
if (((coverage = request.getTarget()) == null) if (((coverage = request.getTarget()) == null) || coverage.equals("/")) {
|| coverage.equals("/")) {
coverage = "index"; coverage = "index";
} }
coverage = coverage.toLowerCase(); coverage = coverage.toLowerCase();
List<String> list = new ArrayList<>(Arrays.asList(new String[] { List<String> list = new ArrayList<>(Arrays.asList(new String[] { "install", "index", "stylesheet" }));
"install", "index", "stylesheet" }));
if (!list.contains(coverage)) { if (!list.contains(coverage)) {
coverage = "index"; coverage = "index";
@ -57,33 +55,29 @@ public class IndexHandler implements Container {
response.setDate("Date", time); response.setDate("Date", time);
response.setDate("Last-Modified", time); response.setDate("Last-Modified", time);
ResourceHandler stylesheet = new ResourceHandler("stylesheet", ResourceHandler stylesheet =
ResourceHandler.FileType.CSS, new ResourceHandler("stylesheet", ResourceHandler.FileType.CSS, this.plugin.getDataFolder());
this.plugin.getDataFolder());
String stylesheetHTML = stylesheet.getHTML(); String stylesheetHTML = stylesheet.getHTML();
stylesheet.done(); stylesheet.done();
body.print(stylesheetHTML); body.print(stylesheetHTML);
} else { }
else {
response.setValue("Content-Type", "html"); response.setValue("Content-Type", "html");
response.setValue("Server", "PlotWeb/1.0 (Simple 5.0)"); response.setValue("Server", "PlotWeb/1.0 (Simple 5.0)");
response.setDate("Date", time); response.setDate("Date", time);
response.setDate("Last-Modified", time); response.setDate("Last-Modified", time);
ResourceHandler header = new ResourceHandler("header", ResourceHandler header =
ResourceHandler.FileType.HTML, new ResourceHandler("header", ResourceHandler.FileType.HTML, this.plugin.getDataFolder());
this.plugin.getDataFolder()); ResourceHandler footer =
ResourceHandler footer = new ResourceHandler("footer", new ResourceHandler("footer", ResourceHandler.FileType.HTML, this.plugin.getDataFolder());
ResourceHandler.FileType.HTML, ResourceHandler cPage =
this.plugin.getDataFolder()); new ResourceHandler(coverage, ResourceHandler.FileType.HTML, this.plugin.getDataFolder());
ResourceHandler cPage = new ResourceHandler(coverage,
ResourceHandler.FileType.HTML,
this.plugin.getDataFolder());
String headerHTML = header.getHTML().replace("@title", String headerHTML = header.getHTML().replace("@title", this.title);
this.title);
String footerHTML = footer.getHTML(); String footerHTML = footer.getHTML();
String cPageHTML = cPage.getHTML(); String cPageHTML = cPage.getHTML();
@ -96,7 +90,8 @@ public class IndexHandler implements Container {
body.print(footerHTML); body.print(footerHTML);
} }
body.close(); body.close();
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -34,8 +34,7 @@ public class PlotWeb {
} }
public void start() throws Exception { public void start() throws Exception {
this.container = new IndexHandler(JavaPlugin.getPlugin(PlotMain.class), this.container = new IndexHandler(JavaPlugin.getPlugin(PlotMain.class), this.title);
this.title);
this.server = new ContainerServer(this.container); this.server = new ContainerServer(this.container);
this.connection = new SocketConnection(this.server); this.connection = new SocketConnection(this.server);
this.address = new InetSocketAddress(this.port); this.address = new InetSocketAddress(this.port);

View File

@ -13,23 +13,22 @@ public class ResourceHandler {
private File file; private File file;
private BufferedReader reader; private BufferedReader reader;
public ResourceHandler(String filePath, FileType fileType, File folder) public ResourceHandler(String filePath, FileType fileType, File folder) throws Exception {
throws Exception {
if (fileType == FileType.CSS) { if (fileType == FileType.CSS) {
this.file = new File(folder.toPath().toString() + File.separator this.file =
+ "web" + File.separator + "css" + File.separator new File(folder.toPath().toString() + File.separator + "web" + File.separator + "css"
+ filePath + "." + fileType.toString()); + File.separator + filePath + "." + fileType.toString());
} else { }
this.file = new File(folder.toPath().toString() + File.separator else {
+ "web" + File.separator + filePath + "." this.file =
+ fileType.toString()); new File(folder.toPath().toString() + File.separator + "web" + File.separator + filePath + "."
+ fileType.toString());
} }
} }
public String getHTML() throws Exception { public String getHTML() throws Exception {
StringBuilder html = new StringBuilder(); StringBuilder html = new StringBuilder();
this.reader = new BufferedReader(new InputStreamReader( this.reader = new BufferedReader(new InputStreamReader(new FileInputStream(this.file)));
new FileInputStream(this.file)));
String line = ""; String line = "";
while ((line = this.reader.readLine()) != null) { while ((line = this.reader.readLine()) != null) {
html.append(line); html.append(line);
@ -42,7 +41,9 @@ public class ResourceHandler {
} }
public static enum FileType { public static enum FileType {
CSS("css"), HTML("html"), JS("js"); CSS("css"),
HTML("html"),
JS("js");
private String ext; private String ext;

View File

@ -8,7 +8,8 @@ public class Test {
public static void main(String[] args) { public static void main(String[] args) {
try { try {
new PlotWeb("Test", 9000).start(); new PlotWeb("Test", 9000).start();
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }