mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
No red files anymore. Some stuff still unfinished.
+ weekly code cleanup
This commit is contained in:
parent
2f5f3ac8e2
commit
a6375796c0
@ -18,7 +18,8 @@ public class AbstractFlag {
|
|||||||
*/
|
*/
|
||||||
public AbstractFlag(String key) {
|
public AbstractFlag(String key) {
|
||||||
if (!StringUtils.isAlpha(key)) {
|
if (!StringUtils.isAlpha(key)) {
|
||||||
throw new IllegalArgumentException("Flag must be alphabetic characters");
|
throw new IllegalArgumentException(
|
||||||
|
"Flag must be alphabetic characters");
|
||||||
}
|
}
|
||||||
if (key.length() > 16) {
|
if (key.length() > 16) {
|
||||||
throw new IllegalArgumentException("Key must be <= 16 characters");
|
throw new IllegalArgumentException("Key must be <= 16 characters");
|
||||||
|
@ -21,31 +21,54 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Ratings
|
* Ratings
|
||||||
*/
|
*/
|
||||||
RATING_NOT_VALID("&cYou need to specify a number between 1 and 10"), RATING_ALREADY_EXISTS("&cYou have already rated plot &c%s"), RATING_APPLIED("&cYou successfully rated plot &6%s"), RATING_NOT_YOUR_OWN("&cYou cannot rate your own plot"), RATING_NOT_OWNED("&cYou cannot rate a plot that is not claimed by anyone"),
|
RATING_NOT_VALID("&cYou need to specify a number between 1 and 10"), RATING_ALREADY_EXISTS(
|
||||||
|
"&cYou have already rated plot &c%s"), RATING_APPLIED(
|
||||||
|
"&cYou successfully rated plot &6%s"), RATING_NOT_YOUR_OWN(
|
||||||
|
"&cYou cannot rate your own plot"), RATING_NOT_OWNED(
|
||||||
|
"&cYou cannot rate a plot that is not claimed by anyone"),
|
||||||
/*
|
/*
|
||||||
* Economy Stuff
|
* Economy Stuff
|
||||||
*/
|
*/
|
||||||
CANNOT_AFFORD_PLOT("&cYou cannot afford to buy this plot. It costs &6%s"), CANNOT_AFFORD_MERGE("&cYou cannot afford to merge the plots. It costs &6%s"), ADDED_BALANCE("&6%s &chas been added to your balance"), REMOVED_BALANCE("&6%s &chas been taken from your balance"),
|
CANNOT_AFFORD_PLOT("&cYou cannot afford to buy this plot. It costs &6%s"), CANNOT_AFFORD_MERGE(
|
||||||
|
"&cYou cannot afford to merge the plots. It costs &6%s"), ADDED_BALANCE(
|
||||||
|
"&6%s &chas been added to your balance"), REMOVED_BALANCE(
|
||||||
|
"&6%s &chas been taken from your balance"),
|
||||||
/*
|
/*
|
||||||
* Setup Stuff
|
* Setup Stuff
|
||||||
*/
|
*/
|
||||||
SETUP_INIT("&6PlotSquared Setup -> Setup a new plotworld"), SETUP_STEP("&cStep &6%s&c: %s &c<Expecting: &6%s&c, Default: &6%s&c>"), SETUP_INVALID_ARG("&c%s is not a valid argument for step %s. To cancel setup use: /plot setup cancel"), SETUP_VALID_ARG("&cValue &6%s &cset for step %s"), SETUP_FINISHED("&cFinished setup for world &c%s.\n&4If you are using MULTIVERSE or MULTIWORLD you will need to import this world. Otherwise you will need to add this world to the 'bukkit.yml' file (See installation tutorial for more info)"), SETUP_WORLD_TAKEN("&c%s is already a registered plotworld"), SETUP_MISSING_WORLD("&cYou need to specify a world name (&6/p setup {world}&c)\n&6Additional commands:\n&c - &6/p setup <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"),
|
SETUP_INIT("&6PlotSquared Setup -> Setup a new plotworld"), SETUP_STEP(
|
||||||
|
"&cStep &6%s&c: %s &c<Expecting: &6%s&c, Default: &6%s&c>"), SETUP_INVALID_ARG(
|
||||||
|
"&c%s is not a valid argument for step %s. To cancel setup use: /plot setup cancel"), SETUP_VALID_ARG(
|
||||||
|
"&cValue &6%s &cset for step %s"), SETUP_FINISHED(
|
||||||
|
"&cFinished setup for world &c%s.\n&4If you are using MULTIVERSE or MULTIWORLD you will need to import this world. Otherwise you will need to add this world to the 'bukkit.yml' file (See installation tutorial for more info)"), SETUP_WORLD_TAKEN(
|
||||||
|
"&c%s is already a registered plotworld"), SETUP_MISSING_WORLD(
|
||||||
|
"&cYou need to specify a world name (&6/p setup {world}&c)\n&6Additional commands:\n&c - &6/p setup <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"),
|
||||||
/*
|
/*
|
||||||
* Schematic Stuff
|
* Schematic Stuff
|
||||||
*/
|
*/
|
||||||
SCHEMATIC_MISSING_ARG("&cYou need to specify an argument. Possible values: &6test {name}"), SCHEMATIC_INVALID("&cThat is not a valid schematic. Reason: &c%s"), SCHEMATIC_VALID("&cThat's a valid schematic"), SCHEMATIC_PASTE_FAILED("&cFailed to paste schematic"), SCHEMATIC_PASTE_SUCCESS("&cSchematic pasted successfully"),
|
SCHEMATIC_MISSING_ARG(
|
||||||
|
"&cYou need to specify an argument. Possible values: &6test {name}"), SCHEMATIC_INVALID(
|
||||||
|
"&cThat is not a valid schematic. Reason: &c%s"), SCHEMATIC_VALID(
|
||||||
|
"&cThat's a valid schematic"), SCHEMATIC_PASTE_FAILED(
|
||||||
|
"&cFailed to paste schematic"), SCHEMATIC_PASTE_SUCCESS(
|
||||||
|
"&cSchematic pasted successfully"),
|
||||||
/*
|
/*
|
||||||
* Title Stuff
|
* Title Stuff
|
||||||
*/
|
*/
|
||||||
TITLE_ENTERED_PLOT("You entered plot %s"), TITLE_ENTERED_PLOT_COLOR("GOLD"), TITLE_ENTERED_PLOT_SUB("Owned by %s"), TITLE_ENTERED_PLOT_SUB_COLOR("RED"), TITLE_LEFT_PLOT("You entered plot %s"), TITLE_LEFT_PLOT_COLOR("GOLD"), TITLE_LEFT_PLOT_SUB("Owned by %s"), TITLE_LEFT_PLOT_SUB_COLOR("RED"),
|
TITLE_ENTERED_PLOT("You entered plot %s"), TITLE_ENTERED_PLOT_COLOR("GOLD"), TITLE_ENTERED_PLOT_SUB(
|
||||||
|
"Owned by %s"), TITLE_ENTERED_PLOT_SUB_COLOR("RED"), TITLE_LEFT_PLOT(
|
||||||
|
"You entered plot %s"), TITLE_LEFT_PLOT_COLOR("GOLD"), TITLE_LEFT_PLOT_SUB(
|
||||||
|
"Owned by %s"), TITLE_LEFT_PLOT_SUB_COLOR("RED"),
|
||||||
/*
|
/*
|
||||||
* Core Stuff
|
* Core Stuff
|
||||||
*/
|
*/
|
||||||
PREFIX("&c[&6&lPlot&c] "), ENABLED("&6Plots are now enabled"), EXAMPLE_MESSAGE("&cThis is an example message &k!!!"),
|
PREFIX("&c[&6&lPlot&c] "), ENABLED("&6Plots are now enabled"), EXAMPLE_MESSAGE(
|
||||||
|
"&cThis is an example message &k!!!"),
|
||||||
/*
|
/*
|
||||||
* Reload
|
* Reload
|
||||||
*/
|
*/
|
||||||
RELOADED_CONFIGS("&6The translation files has been reloaded"), RELOAD_FAILED("&cFailed to reload the translations file"),
|
RELOADED_CONFIGS("&6The translation files has been reloaded"), RELOAD_FAILED(
|
||||||
|
"&cFailed to reload the translations file"),
|
||||||
/*
|
/*
|
||||||
* BarAPI
|
* BarAPI
|
||||||
*/
|
*/
|
||||||
@ -53,11 +76,16 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Alias
|
* Alias
|
||||||
*/
|
*/
|
||||||
ALIAS_SET_TO("&cPlot alias set to &6%alias%"), MISSING_ALIAS("&cYou need to specify the alias"), ALIAS_IS_TAKEN("&cThat alias is already taken"),
|
ALIAS_SET_TO("&cPlot alias set to &6%alias%"), MISSING_ALIAS(
|
||||||
|
"&cYou need to specify the alias"), ALIAS_IS_TAKEN(
|
||||||
|
"&cThat alias is already taken"),
|
||||||
/*
|
/*
|
||||||
* Position
|
* Position
|
||||||
*/
|
*/
|
||||||
MISSING_POSITION("&cYou need to specify a position. Possible values: &6default&c, &6center"), POSITION_SET("&cPlot home position set"), INVALID_POSITION("&cThat is not a valid position value"),
|
MISSING_POSITION(
|
||||||
|
"&cYou need to specify a position. Possible values: &6default&c, &6center"), POSITION_SET(
|
||||||
|
"&cPlot home position set"), INVALID_POSITION(
|
||||||
|
"&cThat is not a valid position value"),
|
||||||
/*
|
/*
|
||||||
* Time
|
* Time
|
||||||
*/
|
*/
|
||||||
@ -65,13 +93,23 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Permission
|
* Permission
|
||||||
*/
|
*/
|
||||||
NO_SCHEMATIC_PERMISSION("&cYou don't have the permission required to use schematic &6%s"), NO_PERMISSION("&cYou don't have the permissions required to use this command."), NO_PLOT_PERMS("&cYou don't have the permissions to do that in this plot"), CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."), YOU_BE_DENIED("&cYou are not allowed to enter this plot"),
|
NO_SCHEMATIC_PERMISSION(
|
||||||
|
"&cYou don't have the permission required to use schematic &6%s"), NO_PERMISSION(
|
||||||
|
"&cYou don't have the permissions required to use this command."), NO_PLOT_PERMS(
|
||||||
|
"&cYou don't have the permissions to do that in this plot"), CANT_CLAIM_MORE_PLOTS(
|
||||||
|
"&cYou can't claim more plots."), YOU_BE_DENIED(
|
||||||
|
"&cYou are not allowed to enter this plot"),
|
||||||
|
|
||||||
NO_PERM_MERGE("&cYou are not the owner of the plot: &6%plot%"), UNLINK_REQUIRED("&cAn unlink is required to do this."), UNLINK_IMPOSSIBLE("&cYou can only unlink a mega-plot"), NO_MERGE_TO_MEGA("&cMega plots cannot be merged into. Please merge from the desired mega plot."),
|
NO_PERM_MERGE("&cYou are not the owner of the plot: &6%plot%"), UNLINK_REQUIRED(
|
||||||
|
"&cAn unlink is required to do this."), UNLINK_IMPOSSIBLE(
|
||||||
|
"&cYou can only unlink a mega-plot"), NO_MERGE_TO_MEGA(
|
||||||
|
"&cMega plots cannot be merged into. Please merge from the desired mega plot."),
|
||||||
/*
|
/*
|
||||||
* Commands
|
* Commands
|
||||||
*/
|
*/
|
||||||
NOT_VALID_SUBCOMMAND("&cThat is not a valid subcommand."), NO_COMMANDS("&cI'm sorry, but you're not permitted to use any subcommands."), SUBCOMMAND_SET_OPTIONS_HEADER("&cPossible Values: "),
|
NOT_VALID_SUBCOMMAND("&cThat is not a valid subcommand."), NO_COMMANDS(
|
||||||
|
"&cI'm sorry, but you're not permitted to use any subcommands."), SUBCOMMAND_SET_OPTIONS_HEADER(
|
||||||
|
"&cPossible Values: "),
|
||||||
/*
|
/*
|
||||||
* Player not found
|
* Player not found
|
||||||
*/
|
*/
|
||||||
@ -83,15 +121,22 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* No {plot}
|
* No {plot}
|
||||||
*/
|
*/
|
||||||
NOT_IN_PLOT("&cYou're not in a plot"), NOT_IN_PLOT_WORLD("&cYou're not in a plot world"), NOT_VALID_WORLD("&cThat is not a valid world (case sensitive)"), NOT_VALID_PLOT_WORLD("&cThat is not a valid plot world (case sensitive)"), NO_PLOTS("&cYou don't have any plots"),
|
NOT_IN_PLOT("&cYou're not in a plot"), NOT_IN_PLOT_WORLD(
|
||||||
|
"&cYou're not in a plot world"), NOT_VALID_WORLD(
|
||||||
|
"&cThat is not a valid world (case sensitive)"), NOT_VALID_PLOT_WORLD(
|
||||||
|
"&cThat is not a valid plot world (case sensitive)"), NO_PLOTS(
|
||||||
|
"&cYou don't have any plots"),
|
||||||
/*
|
/*
|
||||||
* Block List
|
* Block List
|
||||||
*/
|
*/
|
||||||
NOT_VALID_BLOCK_LIST_HEADER("&cThat's not a valid block. Valid blocks are:\\n"), BLOCK_LIST_ITEM(" &6%mat%&c,"), BLOCK_LIST_SEPARATER("&6,&c "),
|
NOT_VALID_BLOCK_LIST_HEADER(
|
||||||
|
"&cThat's not a valid block. Valid blocks are:\\n"), BLOCK_LIST_ITEM(
|
||||||
|
" &6%mat%&c,"), BLOCK_LIST_SEPARATER("&6,&c "),
|
||||||
/*
|
/*
|
||||||
* Biome
|
* Biome
|
||||||
*/
|
*/
|
||||||
NEED_BIOME("&cYou've got to specify a biome"), BIOME_SET_TO("&cPlot biome set to &c"),
|
NEED_BIOME("&cYou've got to specify a biome"), BIOME_SET_TO(
|
||||||
|
"&cPlot biome set to &c"),
|
||||||
/*
|
/*
|
||||||
* Teleport / Entry
|
* Teleport / Entry
|
||||||
*/
|
*/
|
||||||
@ -103,39 +148,61 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Debug
|
* Debug
|
||||||
*/
|
*/
|
||||||
DEUBG_HEADER("&6Debug Information\\n"), DEBUG_SECTION("&c>> &6&l%val%"), DEBUG_LINE("&c>> &6%var%&c:&6 %val%\\n"),
|
DEUBG_HEADER("&6Debug Information\\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("&cThat's not a valid number"), NOT_VALID_PLOT_ID("&cThat's not a valid plot id."), NOT_YOUR_PLOT("&cThat is not your plot."), NO_SUCH_PLOT("&cThere is no such plot"), PLAYER_HAS_NOT_BEEN_ON("&cThat player hasn't been in the plotworld"), FOUND_NO_PLOTS("&cFound no plots with your search query"),
|
NOT_VALID_DATA("&cThat's not a valid data id."), NOT_VALID_BLOCK(
|
||||||
|
"&cThat's not a valid block."), NOT_VALID_NUMBER(
|
||||||
|
"&cThat's not a valid number"), NOT_VALID_PLOT_ID(
|
||||||
|
"&cThat's not a valid plot id."), NOT_YOUR_PLOT(
|
||||||
|
"&cThat is not your plot."), NO_SUCH_PLOT("&cThere is no such plot"), PLAYER_HAS_NOT_BEEN_ON(
|
||||||
|
"&cThat player hasn't been in the plotworld"), FOUND_NO_PLOTS(
|
||||||
|
"&cFound no plots with your search query"),
|
||||||
/*
|
/*
|
||||||
* Camera
|
* Camera
|
||||||
*/
|
*/
|
||||||
CAMERA_STARTED("&cYou have entered camera mode for plot &6%s"), CAMERA_STOPPED("&cYou are no longer in camera mode"),
|
CAMERA_STARTED("&cYou have entered camera mode for plot &6%s"), CAMERA_STOPPED(
|
||||||
|
"&cYou are no longer in camera mode"),
|
||||||
/*
|
/*
|
||||||
* Need
|
* Need
|
||||||
*/
|
*/
|
||||||
NEED_PLOT_NUMBER("&cYou've got to specify a plot number or alias"), NEED_BLOCK("&cYou've got to specify a block"), NEED_PLOT_ID("&cYou've got to specify a plot id."), NEED_USER("&cYou need to specify a username"),
|
NEED_PLOT_NUMBER("&cYou've got to specify a plot number or alias"), NEED_BLOCK(
|
||||||
|
"&cYou've got to specify a block"), NEED_PLOT_ID(
|
||||||
|
"&cYou've got to specify a plot id."), NEED_USER(
|
||||||
|
"&cYou need to specify a username"),
|
||||||
/*
|
/*
|
||||||
* Info
|
* Info
|
||||||
*/
|
*/
|
||||||
PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"), PLOT_INFO("plot ID: &6%id%&c, plot Alias: &6%alias%&c, plot Owner: &6%owner%&c, plot Biome: &6%biome%&c, plot Time: &6%time%&c, plot Weather: &6%weather%&c, plot Helpers:&6%helpers%&c, plot Trusted:&6%trusted%&c, plot Denied:&6%denied%&c, plot Rating: &6%rating%, &cplot flags: &6%flags%"), PLOT_USER_LIST(" &6%user%&c,"),
|
PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"), PLOT_INFO(
|
||||||
|
"plot ID: &6%id%&c, plot Alias: &6%alias%&c, plot Owner: &6%owner%&c, plot Biome: &6%biome%&c, plot Time: &6%time%&c, plot Weather: &6%weather%&c, plot Helpers:&6%helpers%&c, plot Trusted:&6%trusted%&c, plot Denied:&6%denied%&c, plot Rating: &6%rating%, &cplot flags: &6%flags%"), PLOT_USER_LIST(
|
||||||
|
" &6%user%&c,"),
|
||||||
/*
|
/*
|
||||||
* Generating
|
* Generating
|
||||||
*/
|
*/
|
||||||
GENERATING_FLOOR("&6Started generating floor from your settings. It will take %time%"), GENERATING_WALL("&6Started generating wall from your settings"), GENERATING_WALL_FILLING("&cStarted generating wall filling from your settings."),
|
GENERATING_FLOOR(
|
||||||
|
"&6Started generating floor from your settings. It will take %time%"), GENERATING_WALL(
|
||||||
|
"&6Started generating wall from your settings"), GENERATING_WALL_FILLING(
|
||||||
|
"&cStarted generating wall filling from your settings."),
|
||||||
/*
|
/*
|
||||||
* Clearing
|
* Clearing
|
||||||
*/
|
*/
|
||||||
CLEARING_PLOT("&cClearing plot."), CLEARING_DONE("&6Done, took &a%time%&6 ms!"), CLEARING_DONE_PACKETS("&6(&a%time% &6ms for packets)"),
|
CLEARING_PLOT("&cClearing plot."), 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("&6You successfully claimed the plot"),
|
PLOT_NOT_CLAIMED("&cCannot claim 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("&c>> &6%word% a total of &c%num% &6claimed %plot%."),
|
PLOT_LIST_HEADER("&6List of %word% plots"), PLOT_LIST_ITEM(
|
||||||
|
"&c>> &6%id% &c- &6%owner%"), PLOT_LIST_FOOTER(
|
||||||
|
"&c>> &6%word% a total of &c%num% &6claimed %plot%."),
|
||||||
/*
|
/*
|
||||||
* Left
|
* Left
|
||||||
*/
|
*/
|
||||||
@ -143,7 +210,8 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* 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
|
||||||
*/
|
*/
|
||||||
@ -151,23 +219,40 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Denied
|
* Denied
|
||||||
*/
|
*/
|
||||||
DENIED_REMOVED("&cYou successfully undenied the player from this plot"), DENIED_ADDED("&cYou successfully denied the player from this plot"), DENIED_NEED_ARGUMENT("&cArguments are missing. &6/plot denied add {name} &cor &6/plot helpers remove {name}"), WAS_NOT_DENIED("&cThat player was not denied on this plot"),
|
DENIED_REMOVED("&cYou successfully undenied the player from this plot"), DENIED_ADDED(
|
||||||
|
"&cYou successfully denied the player from this plot"), DENIED_NEED_ARGUMENT(
|
||||||
|
"&cArguments are missing. &6/plot denied add {name} &cor &6/plot helpers remove {name}"), WAS_NOT_DENIED(
|
||||||
|
"&cThat player was not denied on this plot"),
|
||||||
/*
|
/*
|
||||||
* Rain
|
* Rain
|
||||||
*/
|
*/
|
||||||
NEED_ON_OFF("&cYou need to specify a value. Possible values: &6on&c, &6off"), SETTING_UPDATED("&cYou successfully updated the setting"),
|
NEED_ON_OFF("&cYou need to specify a value. Possible values: &6on&c, &6off"), SETTING_UPDATED(
|
||||||
|
"&cYou successfully updated the setting"),
|
||||||
/*
|
/*
|
||||||
* Flag
|
* Flag
|
||||||
*/
|
*/
|
||||||
NEED_KEY("&cPossible values: &6%values%"), NOT_VALID_FLAG("&cThat is not a valid flag"), NOT_VALID_VALUE("&cFlag values must be alphanumerical"), FLAG_NOT_IN_PLOT("&cThe plot does not have that flag"), FLAG_NOT_REMOVED("&cThe flag could not be removed"), FLAG_NOT_ADDED("&cThe flag could not be added"), FLAG_REMOVED("&6Successfully removed flag"), FLAG_ADDED("&6Successfully added flag"),
|
NEED_KEY("&cPossible values: &6%values%"), NOT_VALID_FLAG(
|
||||||
|
"&cThat is not a valid flag"), NOT_VALID_VALUE(
|
||||||
|
"&cFlag values must be alphanumerical"), FLAG_NOT_IN_PLOT(
|
||||||
|
"&cThe plot does not have that flag"), FLAG_NOT_REMOVED(
|
||||||
|
"&cThe flag could not be removed"), FLAG_NOT_ADDED(
|
||||||
|
"&cThe flag could not be added"), FLAG_REMOVED(
|
||||||
|
"&6Successfully removed flag"), FLAG_ADDED(
|
||||||
|
"&6Successfully added flag"),
|
||||||
/*
|
/*
|
||||||
* Helper
|
* Helper
|
||||||
*/
|
*/
|
||||||
HELPER_ADDED("&6You successfully added a helper to the plot"), HELPER_REMOVED("&6You successfully removed a helper from the plot"), HELPER_NEED_ARGUMENT("&cArguments are missing. &6/plot helpers add {name} &cor &6/plot helpers remove {name}"), WAS_NOT_ADDED("&cThat player was not added as a helper on this plot"),
|
HELPER_ADDED("&6You successfully added a helper to the plot"), HELPER_REMOVED(
|
||||||
|
"&6You successfully removed a helper from the plot"), HELPER_NEED_ARGUMENT(
|
||||||
|
"&cArguments are missing. &6/plot helpers add {name} &cor &6/plot helpers remove {name}"), WAS_NOT_ADDED(
|
||||||
|
"&cThat player was not added as a helper on this plot"),
|
||||||
/*
|
/*
|
||||||
* Trusted
|
* Trusted
|
||||||
*/
|
*/
|
||||||
TRUSTED_ADDED("&6You successfully added a trusted user to the plot"), TRUSTED_REMOVED("&6You successfully removed a trusted user from the plot"), TRUSTED_NEED_ARGUMENT("&cArguments are missing. &6/plot trusted add {name} &cor &6/plot trusted remove {name}"), T_WAS_NOT_ADDED("&cThat player was not added as a trusted user on this plot"),
|
TRUSTED_ADDED("&6You successfully added a trusted user to the plot"), TRUSTED_REMOVED(
|
||||||
|
"&6You successfully removed a trusted user from the plot"), TRUSTED_NEED_ARGUMENT(
|
||||||
|
"&cArguments are missing. &6/plot trusted add {name} &cor &6/plot trusted remove {name}"), T_WAS_NOT_ADDED(
|
||||||
|
"&cThat player was not added as a trusted user on this plot"),
|
||||||
/*
|
/*
|
||||||
* Set Owner
|
* Set Owner
|
||||||
*/
|
*/
|
||||||
@ -175,11 +260,16 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Signs
|
* Signs
|
||||||
*/
|
*/
|
||||||
OWNER_SIGN_LINE_1("&cID: &6%id%"), OWNER_SIGN_LINE_2("&cOwner:"), OWNER_SIGN_LINE_3("&6%plr%"), OWNER_SIGN_LINE_4("&2Claimed"),
|
OWNER_SIGN_LINE_1("&cID: &6%id%"), OWNER_SIGN_LINE_2("&cOwner:"), OWNER_SIGN_LINE_3(
|
||||||
|
"&6%plr%"), OWNER_SIGN_LINE_4("&2Claimed"),
|
||||||
/*
|
/*
|
||||||
* Help
|
* Help
|
||||||
*/
|
*/
|
||||||
HELP_CATEGORY("&6Current Category&c: &l%category%"), HELP_INFO("&6You need to specify a help category"), HELP_INFO_ITEM("&6/plots help %category% &c- &6%category_desc%"), HELP_PAGE("&c>> &6%usage% &c[&6%alias%&c] &c- &6%desc%"), HELP_HEADER("&6Help for Plots"),
|
HELP_CATEGORY("&6Current Category&c: &l%category%"), HELP_INFO(
|
||||||
|
"&6You need to specify a help category"), HELP_INFO_ITEM(
|
||||||
|
"&6/plots help %category% &c- &6%category_desc%"), HELP_PAGE(
|
||||||
|
"&c>> &6%usage% &c[&6%alias%&c] &c- &6%desc%"), HELP_HEADER(
|
||||||
|
"&6Help for Plots"),
|
||||||
/*
|
/*
|
||||||
* Direction
|
* Direction
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
|
|
||||||
public class Configuration {
|
public class Configuration {
|
||||||
public static final SettingValue STRING = new SettingValue("STRING") {
|
public static final SettingValue STRING = new SettingValue("STRING") {
|
||||||
@Override
|
@Override
|
||||||
@ -125,7 +124,8 @@ 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]), Byte.parseByte(split[1]));
|
return new PlotBlock(Short.parseShort(split[0]),
|
||||||
|
Byte.parseByte(split[1]));
|
||||||
} else {
|
} else {
|
||||||
return new PlotBlock(Short.parseShort(string), (byte) 0);
|
return new PlotBlock(Short.parseShort(string), (byte) 0);
|
||||||
}
|
}
|
||||||
@ -163,13 +163,16 @@ public class Configuration {
|
|||||||
for (int i = 0; i < blocks.length; i++) {
|
for (int i = 0; i < blocks.length; i++) {
|
||||||
if (string.contains(":")) {
|
if (string.contains(":")) {
|
||||||
String[] split = string.split(":");
|
String[] split = string.split(":");
|
||||||
values[i] = new PlotBlock(Short.parseShort(split[0]), Byte.parseByte(split[1]));
|
values[i] = new PlotBlock(Short.parseShort(split[0]),
|
||||||
|
Byte.parseByte(split[1]));
|
||||||
} else {
|
} else {
|
||||||
values[i] = new PlotBlock(Short.parseShort(string), (byte) 0);
|
values[i] = new PlotBlock(Short.parseShort(string),
|
||||||
|
(byte) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object parseObject(Object object) {
|
public Object parseObject(Object object) {
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
@ -182,7 +185,8 @@ public class Configuration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Create your own SettingValue object to make the management of plotworld configuration easier
|
* Create your own SettingValue object to make the management of plotworld
|
||||||
|
* configuration easier
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static abstract class SettingValue {
|
public static abstract class SettingValue {
|
||||||
|
@ -13,7 +13,8 @@ public class ConfigurationNode {
|
|||||||
private Object value = 0;
|
private Object value = 0;
|
||||||
private SettingValue type;
|
private SettingValue type;
|
||||||
|
|
||||||
public ConfigurationNode(String constant, Object default_value, String description, SettingValue type, boolean required) {
|
public ConfigurationNode(String constant, Object default_value,
|
||||||
|
String description, SettingValue type, boolean required) {
|
||||||
this.constant = constant;
|
this.constant = constant;
|
||||||
this.default_value = default_value;
|
this.default_value = default_value;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
@ -25,6 +26,18 @@ public class ConfigurationNode {
|
|||||||
return this.type.getType();
|
return this.type.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isValid(String string) {
|
||||||
|
try {
|
||||||
|
Object result = this.type.parseString(string);
|
||||||
|
if (result == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean setValue(String string) {
|
public boolean setValue(String string) {
|
||||||
if (!this.type.validateValue(string)) {
|
if (!this.type.validateValue(string)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -8,52 +8,64 @@ import org.bukkit.ChatColor;
|
|||||||
public class ConsoleColors {
|
public class ConsoleColors {
|
||||||
|
|
||||||
static enum ConsoleColor {
|
static enum ConsoleColor {
|
||||||
RESET ("\u001B[0m"),
|
RESET("\u001B[0m"), BLACK("\u001B[30m"), RED("\u001B[31m"), GREEN(
|
||||||
BLACK ("\u001B[30m"),
|
"\u001B[32m"), YELLOW("\u001B[33m"), BLUE("\u001B[34m"), PURPLE(
|
||||||
RED ("\u001B[31m"),
|
"\u001B[35m"), CYAN("\u001B[36m"), WHITE("\u001B[37m"), BOLD(
|
||||||
GREEN ("\u001B[32m"),
|
"\033[1m"), UNDERLINE("\033[0m"), ITALIC("\033[3m");
|
||||||
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;
|
||||||
|
|
||||||
ConsoleColor(String lin) {
|
ConsoleColor(String lin) {
|
||||||
this.lin = lin;
|
this.lin = lin;
|
||||||
this.win = win;
|
this.win = this.win;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWin() {
|
public String getWin() {
|
||||||
return win;
|
return this.win;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLin() {
|
public String getLin() {
|
||||||
return lin;
|
return this.lin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public static final String ANSI_RESET = "\u001B[0m";
|
/*
|
||||||
public static final String ANSI_BLACK = "\u001B[30m";
|
* public static final String ANSI_RESET = "\u001B[0m"; public static final
|
||||||
public static final String ANSI_RED = "\u001B[31m";
|
* String ANSI_BLACK = "\u001B[30m"; public static final String ANSI_RED =
|
||||||
public static final String ANSI_GREEN = "\u001B[32m";
|
* "\u001B[31m"; public static final String ANSI_GREEN = "\u001B[32m";
|
||||||
public static final String ANSI_YELLOW = "\u001B[33m";
|
* public static final String ANSI_YELLOW = "\u001B[33m"; public static
|
||||||
public static final String ANSI_BLUE = "\u001B[34m";
|
* final String ANSI_BLUE = "\u001B[34m"; public static final String
|
||||||
public static final String ANSI_PURPLE = "\u001B[35m";
|
* ANSI_PURPLE = "\u001B[35m"; public static final String ANSI_CYAN =
|
||||||
public static final String ANSI_CYAN = "\u001B[36m";
|
* "\u001B[36m"; public static final String ANSI_WHITE = "\u001B[37m";
|
||||||
public static final String ANSI_WHITE = "\u001B[37m";
|
* public static final String ANSI_BOLD = "\033[1m"; public static final
|
||||||
public static final String ANSI_BOLD = "\033[1m";
|
* String ANSI_UNDERLINE = "\033[0m"; public static final String ANSI_ITALIC
|
||||||
public static final String ANSI_UNDERLINE = "\033[0m";
|
* = "\033[3m]";
|
||||||
public static final String ANSI_ITALIC = "\033[3m]";*/
|
*/
|
||||||
|
|
||||||
public static String fromString(String input) {
|
public static String fromString(String input) {
|
||||||
input = input.replaceAll("&0", fromChatColor(ChatColor.BLACK)).replaceAll("&1", fromChatColor(ChatColor.DARK_BLUE)).replaceAll("&2", fromChatColor(ChatColor.DARK_GREEN)).replaceAll("&3", fromChatColor(ChatColor.DARK_AQUA)).replaceAll("&4", fromChatColor(ChatColor.DARK_RED)).replaceAll("&5", fromChatColor(ChatColor.DARK_PURPLE)).replaceAll("&6", fromChatColor(ChatColor.GOLD)).replaceAll("&7", fromChatColor(ChatColor.GRAY)).replaceAll("&8", fromChatColor(ChatColor.DARK_GRAY)).replaceAll("&9", fromChatColor(ChatColor.BLUE)).replaceAll("&a", fromChatColor(ChatColor.GREEN)).replaceAll("&b", fromChatColor(ChatColor.AQUA)).replaceAll("&c", fromChatColor(ChatColor.RED)).replaceAll("&d", fromChatColor(ChatColor.LIGHT_PURPLE)).replaceAll("&e", fromChatColor(ChatColor.YELLOW)).replaceAll("&f", fromChatColor(ChatColor.WHITE)).replaceAll("&k", fromChatColor(ChatColor.MAGIC)).replaceAll("&l", fromChatColor(ChatColor.BOLD)).replaceAll("&m", fromChatColor(ChatColor.STRIKETHROUGH))
|
input = input.replaceAll("&0", fromChatColor(ChatColor.BLACK))
|
||||||
.replaceAll("&n", fromChatColor(ChatColor.UNDERLINE)).replaceAll("&o", fromChatColor(ChatColor.ITALIC)).replaceAll("&r", fromChatColor(ChatColor.RESET));
|
.replaceAll("&1", fromChatColor(ChatColor.DARK_BLUE))
|
||||||
|
.replaceAll("&2", fromChatColor(ChatColor.DARK_GREEN))
|
||||||
|
.replaceAll("&3", fromChatColor(ChatColor.DARK_AQUA))
|
||||||
|
.replaceAll("&4", fromChatColor(ChatColor.DARK_RED))
|
||||||
|
.replaceAll("&5", fromChatColor(ChatColor.DARK_PURPLE))
|
||||||
|
.replaceAll("&6", fromChatColor(ChatColor.GOLD))
|
||||||
|
.replaceAll("&7", fromChatColor(ChatColor.GRAY))
|
||||||
|
.replaceAll("&8", fromChatColor(ChatColor.DARK_GRAY))
|
||||||
|
.replaceAll("&9", fromChatColor(ChatColor.BLUE))
|
||||||
|
.replaceAll("&a", fromChatColor(ChatColor.GREEN))
|
||||||
|
.replaceAll("&b", fromChatColor(ChatColor.AQUA))
|
||||||
|
.replaceAll("&c", fromChatColor(ChatColor.RED))
|
||||||
|
.replaceAll("&d", fromChatColor(ChatColor.LIGHT_PURPLE))
|
||||||
|
.replaceAll("&e", fromChatColor(ChatColor.YELLOW))
|
||||||
|
.replaceAll("&f", fromChatColor(ChatColor.WHITE))
|
||||||
|
.replaceAll("&k", fromChatColor(ChatColor.MAGIC))
|
||||||
|
.replaceAll("&l", fromChatColor(ChatColor.BOLD))
|
||||||
|
.replaceAll("&m", fromChatColor(ChatColor.STRIKETHROUGH))
|
||||||
|
.replaceAll("&n", fromChatColor(ChatColor.UNDERLINE))
|
||||||
|
.replaceAll("&o", fromChatColor(ChatColor.ITALIC))
|
||||||
|
.replaceAll("&r", fromChatColor(ChatColor.RESET));
|
||||||
return input + ConsoleColor.RESET.toString();
|
return input + ConsoleColor.RESET.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,8 @@ 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.equals(other.value));
|
return (this.key.getKey().equals(other.key.getKey()) && this.value
|
||||||
|
.equals(other.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -79,6 +79,19 @@ public class FlagManager {
|
|||||||
return flags.remove(flag);
|
return flags.remove(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Flag[] parseFlags(List<String> flagstrings) {
|
||||||
|
Flag[] flags = new Flag[flagstrings.size()];
|
||||||
|
for (int i = 0; i < flagstrings.size(); i++) {
|
||||||
|
String[] split = flagstrings.get(i).split(";");
|
||||||
|
if (split.length == 1) {
|
||||||
|
flags[i] = new Flag(getFlag(split[0], true), "");
|
||||||
|
} else {
|
||||||
|
flags[i] = new Flag(getFlag(split[0], true), split[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the flags for a plot
|
* Get the flags for a plot
|
||||||
*
|
*
|
||||||
|
@ -111,7 +111,9 @@ public class LSetCube {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return ((this.current.getBlockX() + 1) <= this.max.getBlockX()) && ((this.current.getBlockY() + 1) <= this.max.getBlockY()) && ((this.current.getBlockZ() + 1) <= this.max.getBlockZ());
|
return ((this.current.getBlockX() + 1) <= this.max.getBlockX())
|
||||||
|
&& ((this.current.getBlockY() + 1) <= this.max.getBlockY())
|
||||||
|
&& ((this.current.getBlockZ() + 1) <= this.max.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,8 @@ 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.round(getTPS(100));
|
return Math.round(getTPS(100)) > 20.0D ? 20.0D : Math
|
||||||
|
.round(getTPS(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,8 @@ public class Logger {
|
|||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "File setup error Logger#setup");
|
PlotMain.sendConsoleSenderMessage(C.PREFIX.s()
|
||||||
|
+ "File setup error Logger#setup");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,8 @@ 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.synchronizedSet(new HashSet<Graph>());
|
private final Set<Graph> graphs = Collections
|
||||||
|
.synchronizedSet(new HashSet<Graph>());
|
||||||
/**
|
/**
|
||||||
* The plugin configuration file
|
* The plugin configuration file
|
||||||
*/
|
*/
|
||||||
@ -112,14 +113,16 @@ public class Metrics {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
// load the config
|
// load the config
|
||||||
this.configurationFile = getConfigFile();
|
this.configurationFile = getConfigFile();
|
||||||
this.configuration = YamlConfiguration.loadConfiguration(this.configurationFile);
|
this.configuration = YamlConfiguration
|
||||||
|
.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").copyDefaults(true);
|
this.configuration.options().header("http://mcstats.org")
|
||||||
|
.copyDefaults(true);
|
||||||
this.configuration.save(this.configurationFile);
|
this.configuration.save(this.configurationFile);
|
||||||
}
|
}
|
||||||
// Load the guid then
|
// Load the guid then
|
||||||
@ -182,18 +185,22 @@ 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().runTaskTimerAsynchronously(this.plugin, new Runnable() {
|
this.task = this.plugin.getServer().getScheduler()
|
||||||
|
.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 with
|
// This has to be synchronized or it can collide
|
||||||
|
// with
|
||||||
// the disable method.
|
// the disable method.
|
||||||
synchronized (Metrics.this.optOutLock) {
|
synchronized (Metrics.this.optOutLock) {
|
||||||
// Disable Task, if it is running and the server
|
// Disable Task, if it is running and the
|
||||||
|
// server
|
||||||
// owner decided to opt-out
|
// owner decided to opt-out
|
||||||
if (isOptOut() && (Metrics.this.task != null)) {
|
if (isOptOut()
|
||||||
|
&& (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
|
||||||
@ -203,18 +210,23 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We use the inverse of firstPost because if it is the
|
// We use the inverse of firstPost because if it
|
||||||
|
// is the
|
||||||
// first time we are posting,
|
// first time we are posting,
|
||||||
// it is not a interval ping, so it evaluates to FALSE
|
// it is not a interval ping, so it evaluates to
|
||||||
// Each time thereafter it will evaluate to TRUE, i.e
|
// FALSE
|
||||||
|
// Each time thereafter it will evaluate to
|
||||||
|
// TRUE, i.e
|
||||||
// PING!
|
// PING!
|
||||||
postPlugin(!this.firstPost);
|
postPlugin(!this.firstPost);
|
||||||
// After the first post we set firstPost to false
|
// After the first post we set firstPost to
|
||||||
|
// false
|
||||||
// Each post thereafter will be a ping
|
// Each post thereafter will be a ping
|
||||||
this.firstPost = false;
|
this.firstPost = false;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (Metrics.this.debug) {
|
if (Metrics.this.debug) {
|
||||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
|
Bukkit.getLogger().log(Level.INFO,
|
||||||
|
"[Metrics] " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -235,12 +247,14 @@ public class Metrics {
|
|||||||
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, "[Metrics] " + ex.getMessage());
|
Bukkit.getLogger().log(Level.INFO,
|
||||||
|
"[Metrics] " + ex.getMessage());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (InvalidConfigurationException ex) {
|
} catch (InvalidConfigurationException ex) {
|
||||||
if (this.debug) {
|
if (this.debug) {
|
||||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
Bukkit.getLogger().log(Level.INFO,
|
||||||
|
"[Metrics] " + ex.getMessage());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -321,8 +335,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 mode
|
// online
|
||||||
// is enabled
|
// mode
|
||||||
|
// is
|
||||||
|
// 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;
|
||||||
@ -372,7 +388,8 @@ 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(), Integer.toString(plotter.getValue()));
|
appendJSONPair(graphJson, plotter.getColumnName(),
|
||||||
|
Integer.toString(plotter.getValue()));
|
||||||
}
|
}
|
||||||
graphJson.append('}');
|
graphJson.append('}');
|
||||||
if (!firstGraph) {
|
if (!firstGraph) {
|
||||||
@ -389,7 +406,8 @@ public class Metrics {
|
|||||||
// close json
|
// close json
|
||||||
json.append('}');
|
json.append('}');
|
||||||
// Create the url
|
// Create the url
|
||||||
URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName)));
|
URL url = new URL(BASE_URL
|
||||||
|
+ String.format(REPORT_URL, urlEncode(pluginName)));
|
||||||
// Connect to the website
|
// 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
|
||||||
@ -405,33 +423,40 @@ 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", Integer.toString(compressed.length));
|
connection.addRequestProperty("Content-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 + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
|
System.out.println("[Metrics] Prepared request for " + pluginName
|
||||||
|
+ " uncompressed=" + uncompressed.length + " compressed="
|
||||||
|
+ 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(connection.getInputStream()));
|
final BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||||
|
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") || response.startsWith("7")) {
|
if ((response == null) || response.startsWith("ERR")
|
||||||
|
|| response.startsWith("7")) {
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
response = "null";
|
response = "null";
|
||||||
} else if (response.startsWith("7")) {
|
} else if (response.startsWith("7")) {
|
||||||
response = response.substring(response.startsWith("7,") ? 2 : 1);
|
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") || response.contains("This is your first update this hour")) {
|
if (response.equals("1")
|
||||||
|
|| response.contains("This is your first update this hour")) {
|
||||||
synchronized (this.graphs) {
|
synchronized (this.graphs) {
|
||||||
final Iterator<Graph> iter = this.graphs.iterator();
|
final Iterator<Graph> iter = this.graphs.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
@ -493,7 +518,8 @@ public class Metrics {
|
|||||||
* @param value
|
* @param value
|
||||||
* @throws UnsupportedEncodingException
|
* @throws UnsupportedEncodingException
|
||||||
*/
|
*/
|
||||||
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
|
private static void appendJSONPair(StringBuilder json, String key,
|
||||||
|
String value) throws UnsupportedEncodingException {
|
||||||
boolean isValueNumeric = false;
|
boolean isValueNumeric = false;
|
||||||
try {
|
try {
|
||||||
if (value.equals("0") || !value.endsWith("0")) {
|
if (value.equals("0") || !value.endsWith("0")) {
|
||||||
@ -565,7 +591,8 @@ 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) throws UnsupportedEncodingException {
|
private static String urlEncode(final String text)
|
||||||
|
throws UnsupportedEncodingException {
|
||||||
return URLEncoder.encode(text, "UTF-8");
|
return URLEncoder.encode(text, "UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -711,7 +738,8 @@ public class Metrics {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Plotter plotter = (Plotter) object;
|
final Plotter plotter = (Plotter) object;
|
||||||
return plotter.name.equals(this.name) && (plotter.getValue() == getValue());
|
return plotter.name.equals(this.name)
|
||||||
|
&& (plotter.getValue() == getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,10 @@ 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) && plot.getOwner().equals(p.getUniqueId()) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId());
|
r = (plot.getOwner() != null)
|
||||||
|
&& plot.getOwner().equals(p.getUniqueId())
|
||||||
|
|| plot.helpers.contains(DBFunc.everyone)
|
||||||
|
|| plot.helpers.contains(p.getUniqueId());
|
||||||
if (!r) {
|
if (!r) {
|
||||||
if (p.hasPermission("plots.worldedit.bypass")) {
|
if (p.hasPermission("plots.worldedit.bypass")) {
|
||||||
removeMask(p, s);
|
removeMask(p, s);
|
||||||
@ -46,13 +49,17 @@ public class PWE {
|
|||||||
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, bloc.getBlockY() + 1, bloc.getBlockZ() + 1);
|
Vector bvec = new Vector(bloc.getBlockX() + 1,
|
||||||
Vector tvec = new Vector(tloc.getBlockX(), tloc.getBlockY(), tloc.getBlockZ());
|
bloc.getBlockY() + 1, bloc.getBlockZ() + 1);
|
||||||
|
Vector tvec = new Vector(tloc.getBlockX(),
|
||||||
|
tloc.getBlockY(), tloc.getBlockZ());
|
||||||
|
|
||||||
LocalWorld lw = PlotMain.worldEdit.wrapPlayer(p).getWorld();
|
LocalWorld lw = PlotMain.worldEdit.wrapPlayer(p)
|
||||||
|
.getWorld();
|
||||||
|
|
||||||
CuboidRegion region = new CuboidRegion(lw, bvec, tvec);
|
CuboidRegion region = new CuboidRegion(lw, bvec, tvec);
|
||||||
com.sk89q.worldedit.masks.RegionMask mask = new com.sk89q.worldedit.masks.RegionMask(region);
|
com.sk89q.worldedit.masks.RegionMask mask = new com.sk89q.worldedit.masks.RegionMask(
|
||||||
|
region);
|
||||||
|
|
||||||
s.setMask(mask);
|
s.setMask(mask);
|
||||||
return;
|
return;
|
||||||
@ -63,10 +70,13 @@ 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(new CuboidRegion(plr.getWorld(), p1, p2)));
|
s.setMask(new com.sk89q.worldedit.masks.RegionMask(
|
||||||
|
new CuboidRegion(plr.getWorld(), p1, p2)));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
|
// throw new
|
||||||
|
// PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY,
|
||||||
|
// "WorldEdit == Null?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +108,9 @@ public class PWE {
|
|||||||
}
|
}
|
||||||
removeMask(p, s);
|
removeMask(p, s);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
|
// throw new
|
||||||
|
// PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY,
|
||||||
|
// "WorldEdit == Null?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,8 @@ public class PlayerFunctions {
|
|||||||
return (lp - cu) > 30l;
|
return (lp - cu) > 30l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<PlotId> getPlotSelectionIds(World world, PlotId pos1, PlotId pos2) {
|
public static ArrayList<PlotId> getPlotSelectionIds(World world,
|
||||||
|
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++) {
|
||||||
@ -69,20 +70,32 @@ 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(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y - 1)));
|
return getBottomPlot(
|
||||||
|
world,
|
||||||
|
PlotMain.getPlots(world).get(
|
||||||
|
new PlotId(plot.id.x, plot.id.y - 1)));
|
||||||
}
|
}
|
||||||
if (plot.settings.getMerged(3)) {
|
if (plot.settings.getMerged(3)) {
|
||||||
return getBottomPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x - 1, plot.id.y)));
|
return getBottomPlot(
|
||||||
|
world,
|
||||||
|
PlotMain.getPlots(world).get(
|
||||||
|
new PlotId(plot.id.x - 1, plot.id.y)));
|
||||||
}
|
}
|
||||||
return plot;
|
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(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x, plot.id.y + 1)));
|
return getTopPlot(
|
||||||
|
world,
|
||||||
|
PlotMain.getPlots(world).get(
|
||||||
|
new PlotId(plot.id.x, plot.id.y + 1)));
|
||||||
}
|
}
|
||||||
if (plot.settings.getMerged(1)) {
|
if (plot.settings.getMerged(1)) {
|
||||||
return getTopPlot(world, PlotMain.getPlots(world).get(new PlotId(plot.id.x + 1, plot.id.y)));
|
return getTopPlot(
|
||||||
|
world,
|
||||||
|
PlotMain.getPlots(world).get(
|
||||||
|
new PlotId(plot.id.x + 1, plot.id.y)));
|
||||||
}
|
}
|
||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
@ -118,7 +131,8 @@ public class PlayerFunctions {
|
|||||||
* @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 : WeatherType.CLEAR);
|
player.setPlayerWeather(plot.settings.getRain() ? WeatherType.DOWNFALL
|
||||||
|
: WeatherType.CLEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,7 +164,8 @@ public class PlayerFunctions {
|
|||||||
return plots.get(id);
|
return plots.get(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), world.getName());
|
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(),
|
||||||
|
new ArrayList<UUID>(), world.getName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +252,8 @@ public class PlayerFunctions {
|
|||||||
if ((msg.length() == 0) || msg.equalsIgnoreCase("")) {
|
if ((msg.length() == 0) || msg.equalsIgnoreCase("")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg));
|
sendMessageWrapped(plr,
|
||||||
|
ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +78,8 @@ public class Plot implements Cloneable {
|
|||||||
* @param helpers
|
* @param helpers
|
||||||
* @param denied
|
* @param denied
|
||||||
*/
|
*/
|
||||||
public Plot(PlotId id, UUID owner, Biome plotBiome, ArrayList<UUID> helpers, ArrayList<UUID> denied, String world) {
|
public Plot(PlotId id, UUID owner, Biome plotBiome,
|
||||||
|
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);
|
||||||
@ -109,7 +110,11 @@ public class Plot implements Cloneable {
|
|||||||
* @param time
|
* @param time
|
||||||
* @param merged
|
* @param merged
|
||||||
*/
|
*/
|
||||||
public Plot(PlotId id, UUID owner, Biome plotBiome, ArrayList<UUID> helpers, ArrayList<UUID> trusted, ArrayList<UUID> denied, boolean changeTime, long time, boolean rain, String alias, PlotHomePosition position, Flag[] flags, String world, boolean[] merged) {
|
public Plot(PlotId id, UUID owner, Biome plotBiome,
|
||||||
|
ArrayList<UUID> helpers, ArrayList<UUID> trusted,
|
||||||
|
ArrayList<UUID> denied, boolean changeTime, long time,
|
||||||
|
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);
|
||||||
@ -158,7 +163,17 @@ public class Plot implements Cloneable {
|
|||||||
* @return true if the player is added as a helper or is the owner
|
* @return true if the player is added as a helper or is the owner
|
||||||
*/
|
*/
|
||||||
public boolean hasRights(Player player) {
|
public boolean hasRights(Player player) {
|
||||||
return player.hasPermission("plots.admin") || ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(player.getUniqueId())) || ((this.owner != null) && this.owner.equals(player.getUniqueId())) || ((this.owner != null) && (this.trusted != null) && (Bukkit.getPlayer(this.owner) != null) && (this.trusted.contains(player.getUniqueId()) || this.trusted.contains(DBFunc.everyone)));
|
return player.hasPermission("plots.admin")
|
||||||
|
|| ((this.helpers != null) && this.helpers
|
||||||
|
.contains(DBFunc.everyone))
|
||||||
|
|| ((this.helpers != null) && this.helpers.contains(player
|
||||||
|
.getUniqueId()))
|
||||||
|
|| ((this.owner != null) && this.owner.equals(player
|
||||||
|
.getUniqueId()))
|
||||||
|
|| ((this.owner != null) && (this.trusted != null)
|
||||||
|
&& (Bukkit.getPlayer(this.owner) != null) && (this.trusted
|
||||||
|
.contains(player.getUniqueId()) || this.trusted
|
||||||
|
.contains(DBFunc.everyone)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,7 +183,10 @@ public class Plot implements Cloneable {
|
|||||||
* @return false if the player is allowed to enter
|
* @return false if the player is allowed to enter
|
||||||
*/
|
*/
|
||||||
public boolean deny_entry(Player player) {
|
public boolean deny_entry(Player player) {
|
||||||
return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.hasRights(player)) || (!this.hasRights(player) && this.denied.contains(player.getUniqueId())));
|
return (this.denied != null)
|
||||||
|
&& ((this.denied.contains(DBFunc.everyone) && !this
|
||||||
|
.hasRights(player)) || (!this.hasRights(player) && this.denied
|
||||||
|
.contains(player.getUniqueId())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot;
|
|||||||
public class PlotBlock {
|
public class PlotBlock {
|
||||||
public short id;
|
public short id;
|
||||||
public byte data;
|
public byte data;
|
||||||
|
|
||||||
public PlotBlock(short id, byte data) {
|
public PlotBlock(short id, byte data) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.data = data;
|
this.data = data;
|
||||||
|
@ -9,11 +9,19 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
@ -21,8 +29,7 @@ import org.bukkit.block.Sign;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plot functions
|
* plot functions
|
||||||
@ -34,10 +41,6 @@ public class PlotHelper {
|
|||||||
public static boolean canSetFast = false;
|
public static boolean canSetFast = false;
|
||||||
static long state = 1;
|
static long state = 1;
|
||||||
|
|
||||||
private static double calculateNeededTime(double blocks, double blocks_per_second) {
|
|
||||||
return (blocks / blocks_per_second);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* direction 0 = north, 1 = south, etc:
|
* direction 0 = north, 1 = south, etc:
|
||||||
*
|
*
|
||||||
@ -59,14 +62,16 @@ public class PlotHelper {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean mergePlots(Player plr, World world, ArrayList<PlotId> plotIds) {
|
public static boolean mergePlots(Player plr, World world,
|
||||||
|
ArrayList<PlotId> plotIds) {
|
||||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
if (PlotMain.useEconomy && plotworld.USE_ECONOMY) {
|
if (PlotMain.useEconomy && plotworld.USE_ECONOMY) {
|
||||||
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, "" + cost);
|
PlayerFunctions.sendMessage(plr, C.CANNOT_AFFORD_MERGE, ""
|
||||||
|
+ cost);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
economy.withdrawPlayer(plr, cost);
|
economy.withdrawPlayer(plr, cost);
|
||||||
@ -111,12 +116,14 @@ public class PlotHelper {
|
|||||||
|
|
||||||
if (lx) {
|
if (lx) {
|
||||||
if (ly) {
|
if (ly) {
|
||||||
if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) {
|
if (!plot.settings.getMerged(1)
|
||||||
|
|| !plot.settings.getMerged(2)) {
|
||||||
manager.createRoadSouthEast(plotworld, plot);
|
manager.createRoadSouthEast(plotworld, plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.settings.getMerged(1)) {
|
if (!plot.settings.getMerged(1)) {
|
||||||
Plot plot2 = PlotMain.getPlots(world).get(new PlotId(x + 1, y));
|
Plot plot2 = PlotMain.getPlots(world).get(
|
||||||
|
new PlotId(x + 1, y));
|
||||||
mergePlot(world, plot, plot2);
|
mergePlot(world, plot, plot2);
|
||||||
plot.settings.setMerged(1, true);
|
plot.settings.setMerged(1, true);
|
||||||
plot2.settings.setMerged(3, true);
|
plot2.settings.setMerged(3, true);
|
||||||
@ -124,7 +131,8 @@ public class PlotHelper {
|
|||||||
}
|
}
|
||||||
if (ly) {
|
if (ly) {
|
||||||
if (!plot.settings.getMerged(2)) {
|
if (!plot.settings.getMerged(2)) {
|
||||||
Plot plot2 = PlotMain.getPlots(world).get(new PlotId(x, y + 1));
|
Plot plot2 = PlotMain.getPlots(world).get(
|
||||||
|
new PlotId(x, y + 1));
|
||||||
mergePlot(world, plot, plot2);
|
mergePlot(world, plot, plot2);
|
||||||
plot.settings.setMerged(2, true);
|
plot.settings.setMerged(2, true);
|
||||||
plot2.settings.setMerged(0, true);
|
plot2.settings.setMerged(0, true);
|
||||||
@ -209,9 +217,12 @@ 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).replaceAll("%plr%", plr.getName()));
|
sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id)
|
||||||
sign.setLine(2, C.OWNER_SIGN_LINE_3.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.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id)
|
||||||
|
.replaceAll("%plr%", plr.getName()));
|
||||||
|
sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id)
|
||||||
|
.replaceAll("%plr%", plr.getName()));
|
||||||
sign.update(true);
|
sign.update(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,9 +247,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 && plotblock.data != block.getData()) {
|
if (block.getTypeId() != plotblock.id
|
||||||
|
&& plotblock.data != block.getData()) {
|
||||||
try {
|
try {
|
||||||
SetBlockFast.set(block.getWorld(), block.getX(), block.getY(), block.getZ(), plotblock.id, plotblock.data);
|
SetBlockFast.set(block.getWorld(), block.getX(),
|
||||||
|
block.getY(), block.getZ(), plotblock.id,
|
||||||
|
plotblock.data);
|
||||||
return;
|
return;
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
canSetFast = false;
|
canSetFast = false;
|
||||||
@ -249,23 +263,21 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void adjustWall(Player player, World w, Plot plot, short id, byte data) {
|
public static void adjustWall(Player player, Plot plot, PlotBlock block) {
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
PlotManager manager = PlotMain.getPlotManager(world);
|
PlotManager manager = PlotMain.getPlotManager(world);
|
||||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
|
|
||||||
manager.setWall(player, plotworld, plot.id, new PlotBlock(id,data));
|
manager.setWall(player, plotworld, plot.id, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void autoMerge(World world, Plot plot, Player player) {
|
public static void autoMerge(World world, Plot plot, Player player) {
|
||||||
@ -285,25 +297,29 @@ 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(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(
|
||||||
|
bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
||||||
if (ownsPlots(world, plots, player, 0)) {
|
if (ownsPlots(world, plots, player, 0)) {
|
||||||
merge = true;
|
merge = true;
|
||||||
mergePlots(world, plots);
|
mergePlots(world, plots);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(
|
||||||
|
bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
||||||
if (ownsPlots(world, plots, player, 1)) {
|
if (ownsPlots(world, plots, player, 1)) {
|
||||||
merge = true;
|
merge = true;
|
||||||
mergePlots(world, plots);
|
mergePlots(world, plots);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(
|
||||||
|
bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
||||||
if (ownsPlots(world, plots, player, 2)) {
|
if (ownsPlots(world, plots, player, 2)) {
|
||||||
merge = true;
|
merge = true;
|
||||||
mergePlots(world, plots);
|
mergePlots(world, plots);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
plots = PlayerFunctions.getPlotSelectionIds(world, new PlotId(
|
||||||
|
bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
||||||
if (ownsPlots(world, plots, player, 3)) {
|
if (ownsPlots(world, plots, player, 3)) {
|
||||||
merge = true;
|
merge = true;
|
||||||
mergePlots(world, plots);
|
mergePlots(world, plots);
|
||||||
@ -315,20 +331,24 @@ public class PlotHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean ownsPlots(World world, ArrayList<PlotId> plots, Player player, int dir) {
|
private static boolean ownsPlots(World world, ArrayList<PlotId> plots,
|
||||||
|
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() || !(myplot.getOwner().equals(player.getUniqueId()))) {
|
if ((myplot == null) || !myplot.hasOwner()
|
||||||
|
|| !(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)) || ((top.y > id_max.y) && (dir != 2))) {
|
if (((top.x > id_max.x) && (dir != 1))
|
||||||
|
|| ((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)) || ((bot.y < id_min.y) && (dir != 0))) {
|
if (((bot.x < id_min.x) && (dir != 3))
|
||||||
|
|| ((bot.y < id_min.y) && (dir != 0))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,7 +357,9 @@ 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.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
|
Plot p = new Plot(plot.id, player.getUniqueId(),
|
||||||
|
plot.settings.getBiome(), new ArrayList<UUID>(),
|
||||||
|
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);
|
||||||
@ -536,7 +558,8 @@ 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, final World w, final Plot plot, PlotBlock block) {
|
public static void adjustWallFilling(final Player requester,
|
||||||
|
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;
|
||||||
@ -550,7 +573,8 @@ 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, PlotBlock[] blocks) {
|
public static void setFloor(final Player requester, final Plot plot,
|
||||||
|
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;
|
||||||
@ -571,7 +595,8 @@ 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]), Short.parseShort(split[1]) };
|
return new short[] { Short.parseShort(split[0]),
|
||||||
|
Short.parseShort(split[1]) };
|
||||||
}
|
}
|
||||||
return new short[] { Short.parseShort(block), 0 };
|
return new short[] { Short.parseShort(block), 0 };
|
||||||
}
|
}
|
||||||
@ -580,13 +605,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.getBlockZ() / 16) * 16)); j += 16) {
|
for (int j = (pos1.getBlockZ() / 16) * 16; j < (16 + ((pos2
|
||||||
|
.getBlockZ() / 16) * 16)); j += 16) {
|
||||||
Chunk chunk = world.getChunkAt(i, j);
|
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, entity.getLocation(), plot);
|
PlotMain.teleportPlayer((Player) entity,
|
||||||
|
entity.getLocation(), plot);
|
||||||
} else {
|
} else {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
@ -623,7 +650,8 @@ 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).add(1, 0, 1);
|
Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id)
|
||||||
|
.add(1, 0, 1);
|
||||||
|
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int h = 1;
|
int h = 1;
|
||||||
@ -639,7 +667,10 @@ public class PlotHelper {
|
|||||||
removeSign(requester, plot);
|
removeSign(requester, plot);
|
||||||
setSign(requester, plot);
|
setSign(requester, plot);
|
||||||
|
|
||||||
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.nanoTime() - start) / 1000000.0)));
|
PlayerFunctions.sendMessage(
|
||||||
|
requester,
|
||||||
|
C.CLEARING_DONE.s().replaceAll("%time%",
|
||||||
|
"" + ((System.nanoTime() - start) / 1000000.0)));
|
||||||
if (canSetFast) {
|
if (canSetFast) {
|
||||||
refreshPlotChunks(world, plot);
|
refreshPlotChunks(world, plot);
|
||||||
// SetBlockFast.update(requester);
|
// SetBlockFast.update(requester);
|
||||||
@ -647,7 +678,8 @@ public class PlotHelper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setCuboid(World world, Location pos1, Location pos2, PlotBlock[] blocks) {
|
public static void setCuboid(World world, Location pos1, Location pos2,
|
||||||
|
PlotBlock[] blocks) {
|
||||||
if (!canSetFast) {
|
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++) {
|
||||||
@ -655,8 +687,10 @@ 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.getData() == newblock.data))) {
|
if (!((block.getTypeId() == newblock.id) && (block
|
||||||
block.setTypeIdAndData(newblock.id, newblock.data, false);
|
.getData() == newblock.data))) {
|
||||||
|
block.setTypeIdAndData(newblock.id, newblock.data,
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -669,8 +703,10 @@ 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.getData() == newblock.data))) {
|
if (!((block.getTypeId() == newblock.id) && (block
|
||||||
SetBlockFast.set(world, x, y, z, newblock.id, newblock.data);
|
.getData() == newblock.data))) {
|
||||||
|
SetBlockFast.set(world, x, y, z, newblock.id,
|
||||||
|
newblock.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -680,7 +716,8 @@ public class PlotHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSimpleCuboid(World world, Location pos1, Location pos2, PlotBlock newblock) {
|
public static void setSimpleCuboid(World world, Location pos1,
|
||||||
|
Location pos2, PlotBlock newblock) {
|
||||||
if (!canSetFast) {
|
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++) {
|
||||||
@ -699,7 +736,8 @@ public class PlotHelper {
|
|||||||
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, (byte) 0);
|
SetBlockFast.set(world, x, y, z, newblock.id,
|
||||||
|
(byte) 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -730,7 +768,9 @@ 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() + (getPlotTopLoc(w, plotid).getBlockX() - getPlotBottomLoc(w, plotid).getBlockX());
|
int x = getPlotBottomLoc(w, plotid).getBlockX()
|
||||||
|
+ (getPlotTopLoc(w, plotid).getBlockX() - getPlotBottomLoc(
|
||||||
|
w, plotid).getBlockX());
|
||||||
int z = getPlotBottomLoc(w, plotid).getBlockZ() - 2;
|
int 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);
|
||||||
@ -782,6 +822,11 @@ public class PlotHelper {
|
|||||||
return manager.getPlotBottomLocAbs(plotworld, id);
|
return manager.getPlotBottomLocAbs(plotworld, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getPlotWidth(World world, PlotId id) {
|
||||||
|
return getPlotTopLoc(world, id).getBlockX()
|
||||||
|
- getPlotBottomLoc(world, id).getBlockX();
|
||||||
|
}
|
||||||
|
|
||||||
public static Location getPlotTopLoc(World world, PlotId id) {
|
public static Location getPlotTopLoc(World world, PlotId id) {
|
||||||
Plot plot = PlotMain.getPlots(world).get(id);
|
Plot plot = PlotMain.getPlots(world).get(id);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
@ -809,7 +854,8 @@ 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>(), new ArrayList<UUID>(), world.getName());
|
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(),
|
||||||
|
new ArrayList<UUID>(), world.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Plot getCurrentPlot(Location loc) {
|
public static Plot getCurrentPlot(Location loc) {
|
||||||
@ -820,6 +866,7 @@ 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>(), new ArrayList<UUID>(), loc.getWorld().getName());
|
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(),
|
||||||
|
new ArrayList<UUID>(), loc.getWorld().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,8 @@ 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, new Runnable() {
|
Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin,
|
||||||
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
checkExpired(plugin, true);
|
checkExpired(plugin, true);
|
||||||
@ -269,7 +270,6 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Set<Plot> getPlots(World world, Player player) {
|
public static Set<Plot> getPlots(World world, Player player) {
|
||||||
int i = 0;
|
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
ArrayList<Plot> myplots = new ArrayList<Plot>();
|
ArrayList<Plot> myplots = new ArrayList<Plot>();
|
||||||
for (Plot plot : getPlots(world).values()) {
|
for (Plot plot : getPlots(world).values()) {
|
||||||
@ -404,8 +404,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Implement better system
|
* TODO: Implement better system The whole point of this system is to
|
||||||
* 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 So why not just allow users to claim old plots, and try
|
||||||
* to hide the fact that the are owned. Reduce amount of expired plots: - On
|
* to hide the fact that the are owned. Reduce amount of expired plots: - On
|
||||||
* /plot auto - allow claiming of old plot, clear it so the user doesn't
|
* /plot auto - allow claiming of old plot, clear it so the user doesn't
|
||||||
* know - On /plot info, - show that the plot is expired and allowed to be
|
* know - On /plot info, - show that the plot is expired and allowed to be
|
||||||
@ -441,8 +441,10 @@ 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(world, plot.id);
|
PlotDeleteEvent event = new PlotDeleteEvent(
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
world, plot.id);
|
||||||
|
Bukkit.getServer().getPluginManager()
|
||||||
|
.callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else {
|
} else {
|
||||||
@ -459,8 +461,10 @@ public class PlotMain extends JavaPlugin {
|
|||||||
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, plot.id);
|
PlotDeleteEvent event = new PlotDeleteEvent(world,
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
plot.id);
|
||||||
|
Bukkit.getServer().getPluginManager()
|
||||||
|
.callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else {
|
} else {
|
||||||
@ -474,15 +478,19 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupLogger() {
|
private void setupLogger() {
|
||||||
File log = new File(getMain().getDataFolder() + File.separator + "logs" + File.separator + "plots.log");
|
File log = new File(getMain().getDataFolder() + File.separator + "logs"
|
||||||
|
+ File.separator + "plots.log");
|
||||||
if (!log.exists()) {
|
if (!log.exists()) {
|
||||||
try {
|
try {
|
||||||
if (!new File(getMain().getDataFolder() + File.separator + "logs").mkdirs()) {
|
if (!new File(getMain().getDataFolder() + File.separator
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to create logs folder. Do it manually.");
|
+ "logs").mkdirs()) {
|
||||||
|
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() + "\n\n\n");
|
writer.write("Created at: " + new Date().toString()
|
||||||
|
+ "\n\n\n");
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -495,7 +503,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static double getJavaVersion() {
|
private static double getJavaVersion() {
|
||||||
return Double.parseDouble(System.getProperty("java.specification.version"));
|
return Double.parseDouble(System
|
||||||
|
.getProperty("java.specification.version"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -508,8 +517,10 @@ 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() + "&cYour java version is outdated. Please update to at least 1.7.");
|
sendConsoleSenderMessage(C.PREFIX.s()
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "&cURL: &6https://java.com/en/download/index.jsp");
|
+ "&cYour java version is outdated. Please update to at least 1.7.");
|
||||||
|
sendConsoleSenderMessage(C.PREFIX.s()
|
||||||
|
+ "&cURL: &6https://java.com/en/download/index.jsp");
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -522,7 +533,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
metrics.start();
|
metrics.start();
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "&6Metrics enabled.");
|
sendConsoleSenderMessage(C.PREFIX.s() + "&6Metrics enabled.");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to load up metrics.");
|
sendConsoleSenderMessage(C.PREFIX.s()
|
||||||
|
+ "&cFailed to load up metrics.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,7 +547,9 @@ 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, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD);
|
mySQL = new MySQL(this, Settings.DB.HOST_NAME,
|
||||||
|
Settings.DB.PORT, Settings.DB.DATABASE,
|
||||||
|
Settings.DB.USER, Settings.DB.PASSWORD);
|
||||||
connection = mySQL.openConnection();
|
connection = mySQL.openConnection();
|
||||||
{
|
{
|
||||||
DatabaseMetaData meta = connection.getMetaData();
|
DatabaseMetaData meta = connection.getMetaData();
|
||||||
@ -546,9 +560,9 @@ public class PlotMain extends JavaPlugin {
|
|||||||
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 {
|
||||||
else {
|
res = meta.getTables(null, null, "plot_ratings",
|
||||||
res = meta.getTables(null, null, "plot_ratings", null);
|
null);
|
||||||
if (!res.next()) {
|
if (!res.next()) {
|
||||||
DBFunc.createTables("mysql", false);
|
DBFunc.createTables("mysql", false);
|
||||||
}
|
}
|
||||||
@ -557,8 +571,10 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
} catch (ClassNotFoundException | SQLException e) {
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
Logger.add(LogLevel.DANGER, "MySQL connection failed.");
|
Logger.add(LogLevel.DANGER, "MySQL connection failed.");
|
||||||
System.out.print("\u001B[31m[Plots] MySQL is not setup correctly. The plugin will disable itself.\u001B[0m");
|
System.out
|
||||||
System.out.print("\u001B[36m==== Here is an ugly stacktrace if you are interested in those things ====\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");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
@ -566,10 +582,12 @@ public class PlotMain extends JavaPlugin {
|
|||||||
plots = DBFunc.getPlots();
|
plots = DBFunc.getPlots();
|
||||||
|
|
||||||
} else if (Settings.DB.USE_MONGO) {
|
} else if (Settings.DB.USE_MONGO) {
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "MongoDB is not yet implemented");
|
sendConsoleSenderMessage(C.PREFIX.s()
|
||||||
|
+ "MongoDB is not yet implemented");
|
||||||
} else if (Settings.DB.USE_SQLITE) {
|
} else if (Settings.DB.USE_SQLITE) {
|
||||||
try {
|
try {
|
||||||
connection = new SQLite(this, Settings.DB.SQLITE_DB + ".db").openConnection();
|
connection = new SQLite(this, Settings.DB.SQLITE_DB + ".db")
|
||||||
|
.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);
|
||||||
@ -579,9 +597,9 @@ public class PlotMain extends JavaPlugin {
|
|||||||
res = meta.getTables(null, null, "plot_trusted", null);
|
res = meta.getTables(null, null, "plot_trusted", null);
|
||||||
if (!res.next()) {
|
if (!res.next()) {
|
||||||
DBFunc.createTables("sqlite", false);
|
DBFunc.createTables("sqlite", false);
|
||||||
}
|
} else {
|
||||||
else {
|
res = meta.getTables(null, null, "plot_ratings",
|
||||||
res = meta.getTables(null, null, "plot_ratings", null);
|
null);
|
||||||
if (!res.next()) {
|
if (!res.next()) {
|
||||||
DBFunc.createTables("sqlite", false);
|
DBFunc.createTables("sqlite", false);
|
||||||
}
|
}
|
||||||
@ -590,7 +608,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
} catch (ClassNotFoundException | SQLException e) {
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
Logger.add(LogLevel.DANGER, "SQLite connection failed");
|
Logger.add(LogLevel.DANGER, "SQLite connection failed");
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to open SQLite connection. The plugin will disable itself.");
|
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 ===");
|
sendConsoleSenderMessage("&9==== Here is an ugly stacktrace, if you are interested in those things ===");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
@ -629,17 +648,22 @@ 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().getPlugin("BarAPI");
|
barAPI = (BarAPI) getServer().getPluginManager()
|
||||||
|
.getPlugin("BarAPI");
|
||||||
}
|
}
|
||||||
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
||||||
worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
worldEdit = (WorldEditPlugin) getServer().getPluginManager()
|
||||||
getServer().getPluginManager().registerEvents(new WorldEditListener(), this);
|
.getPlugin("WorldEdit");
|
||||||
|
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().getPlugin("WorldGuard");
|
worldGuard = (WorldGuardPlugin) getServer().getPluginManager()
|
||||||
|
.getPlugin("WorldGuard");
|
||||||
worldGuardListener = new WorldGuardListener(this);
|
worldGuardListener = new WorldGuardListener(this);
|
||||||
getServer().getPluginManager().registerEvents(worldGuardListener, this);
|
getServer().getPluginManager().registerEvents(
|
||||||
|
worldGuardListener, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Settings.AUTO_CLEAR) {
|
if (Settings.AUTO_CLEAR) {
|
||||||
@ -647,16 +671,20 @@ public class PlotMain extends JavaPlugin {
|
|||||||
checkForExpiredPlots();
|
checkForExpiredPlots();
|
||||||
}
|
}
|
||||||
if (getServer().getPluginManager().getPlugin("Vault") != null) {
|
if (getServer().getPluginManager().getPlugin("Vault") != null) {
|
||||||
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
RegisteredServiceProvider<Economy> economyProvider = getServer()
|
||||||
|
.getServicesManager().getRegistration(
|
||||||
|
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(), 100L, 1L);
|
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Lag(),
|
||||||
|
100L, 1L);
|
||||||
|
|
||||||
if (Web.ENABLED) {
|
if (Web.ENABLED) {
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "Web Is not implemented yet. Please bear with us.");
|
sendConsoleSenderMessage(C.PREFIX.s()
|
||||||
|
+ "Web Is not implemented yet. Please bear with us.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -708,18 +736,28 @@ 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.fromString(string)));
|
System.out.println(ChatColor.stripColor(ConsoleColors
|
||||||
|
.fromString(string)));
|
||||||
} else {
|
} else {
|
||||||
getMain().getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', string));
|
getMain()
|
||||||
|
.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, from, plot);
|
PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player,
|
||||||
|
from, plot);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
Location location = PlotHelper.getPlotHome(Bukkit.getWorld(plot.world), plot);
|
Location location = PlotHelper.getPlotHome(
|
||||||
if ((location.getBlockX() >= 29999999) || (location.getBlockX() <= -29999999) || (location.getBlockZ() >= 299999999) || (location.getBlockZ() <= -29999999)) {
|
Bukkit.getWorld(plot.world), plot);
|
||||||
|
if ((location.getBlockX() >= 29999999)
|
||||||
|
|| (location.getBlockX() <= -29999999)
|
||||||
|
|| (location.getBlockZ() >= 299999999)
|
||||||
|
|| (location.getBlockZ() <= -29999999)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -747,7 +785,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* message
|
* message
|
||||||
*/
|
*/
|
||||||
public static void Broadcast(C c) {
|
public static void Broadcast(C c) {
|
||||||
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + c.s()));
|
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&',
|
||||||
|
C.PREFIX.s() + c.s()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -771,7 +810,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
PlayerFunctions.sendMessage(player, c);
|
PlayerFunctions.sendMessage(player, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + c.s())));
|
System.out.println(ChatColor.stripColor(ChatColor
|
||||||
|
.translateAlternateColorCodes('&', C.PREFIX.s() + c.s())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reloadTranslations() throws IOException {
|
public static void reloadTranslations() throws IOException {
|
||||||
@ -783,7 +823,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
OfflinePlayer player;
|
OfflinePlayer player;
|
||||||
if (((player = Bukkit.getOfflinePlayer(uuid)) == null) || !player.hasPlayedBefore()) {
|
if (((player = Bukkit.getOfflinePlayer(uuid)) == null)
|
||||||
|
|| !player.hasPlayedBefore()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return player.getLastPlayed();
|
return player.getLastPlayed();
|
||||||
@ -794,12 +835,15 @@ 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 + "config");
|
File folder = new File(getMain().getDataFolder() + File.separator
|
||||||
|
+ "config");
|
||||||
if (!folder.exists() && !folder.mkdirs()) {
|
if (!folder.exists() && !folder.mkdirs()) {
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to create the /plugins/config folder. Please create it manually.");
|
sendConsoleSenderMessage(C.PREFIX.s()
|
||||||
|
+ "&cFailed to create the /plugins/config folder. Please create it manually.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
configFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "settings.yml");
|
configFile = new File(getMain().getDataFolder() + File.separator
|
||||||
|
+ "config" + File.separator + "settings.yml");
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
configFile.createNewFile();
|
configFile.createNewFile();
|
||||||
}
|
}
|
||||||
@ -810,7 +854,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
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 + "config" + File.separator + "storage.yml");
|
storageFile = new File(getMain().getDataFolder() + File.separator
|
||||||
|
+ "config" + File.separator + "storage.yml");
|
||||||
if (!storageFile.exists()) {
|
if (!storageFile.exists()) {
|
||||||
storageFile.createNewFile();
|
storageFile.createNewFile();
|
||||||
}
|
}
|
||||||
@ -821,11 +866,14 @@ public class PlotMain extends JavaPlugin {
|
|||||||
System.out.println("Failed to save storage.yml");
|
System.out.println("Failed to save storage.yml");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
translationsFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "translations.yml");
|
translationsFile = new File(getMain().getDataFolder()
|
||||||
|
+ File.separator + "config" + File.separator
|
||||||
|
+ "translations.yml");
|
||||||
if (!translationsFile.exists()) {
|
if (!translationsFile.exists()) {
|
||||||
translationsFile.createNewFile();
|
translationsFile.createNewFile();
|
||||||
}
|
}
|
||||||
translations = YamlConfiguration.loadConfiguration(translationsFile);
|
translations = YamlConfiguration
|
||||||
|
.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");
|
||||||
@ -871,7 +919,9 @@ public class PlotMain extends JavaPlugin {
|
|||||||
settings.put("Auto Clear Enabled", "" + Settings.AUTO_CLEAR);
|
settings.put("Auto Clear Enabled", "" + Settings.AUTO_CLEAR);
|
||||||
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() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
|
sendConsoleSenderMessage(C.PREFIX.s()
|
||||||
|
+ String.format("&cKey: &6%s&c, Value: &6%s",
|
||||||
|
setting.getKey(), setting.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -881,23 +931,27 @@ public class PlotMain extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static void killAllEntities() {
|
public static void killAllEntities() {
|
||||||
Bukkit.getScheduler().scheduleAsyncRepeatingTask(getMain(), new Runnable() {
|
Bukkit.getScheduler().scheduleAsyncRepeatingTask(getMain(),
|
||||||
|
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() + "KillAllEntities has been running for 60 minutes. Errors: " + this.error);
|
sendConsoleSenderMessage(C.PREFIX.s()
|
||||||
|
+ "KillAllEntities has been running for 60 minutes. Errors: "
|
||||||
|
+ this.error);
|
||||||
this.error = 0l;
|
this.error = 0l;
|
||||||
}
|
}
|
||||||
for (String w : getPlotWorlds()) {
|
for (String w : getPlotWorlds()) {
|
||||||
PlotWorld plotworld = getWorldSettings(w);
|
getWorldSettings(w);
|
||||||
World world = Bukkit.getServer().getWorld(w);
|
World world = Bukkit.getServer().getWorld(w);
|
||||||
try {
|
try {
|
||||||
if (world.getLoadedChunks().length < 1) {
|
if (world.getLoadedChunks().length < 1) {
|
||||||
@ -908,8 +962,10 @@ public class PlotMain extends JavaPlugin {
|
|||||||
for (int i = entities.length - 1; i >= 0; i--) {
|
for (int i = entities.length - 1; i >= 0; i--) {
|
||||||
Entity entity = entities[i];
|
Entity entity = entities[i];
|
||||||
if (!(entity instanceof Player)) {
|
if (!(entity instanceof Player)) {
|
||||||
this.location = entity.getLocation();
|
this.location = entity
|
||||||
if (!PlayerEvents.isInPlot(this.location)) {
|
.getLocation();
|
||||||
|
if (!PlayerEvents
|
||||||
|
.isInPlot(this.location)) {
|
||||||
boolean tamed = false;
|
boolean tamed = false;
|
||||||
if (Settings.MOB_PATHFINDING) {
|
if (Settings.MOB_PATHFINDING) {
|
||||||
if (entity instanceof Tameable) {
|
if (entity instanceof Tameable) {
|
||||||
@ -919,7 +975,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
} else if (entity instanceof LivingEntity) {
|
} else if (entity instanceof LivingEntity) {
|
||||||
LivingEntity livingEntity = ((LivingEntity) entity);
|
LivingEntity livingEntity = ((LivingEntity) entity);
|
||||||
if (livingEntity.getCustomName() != null) {
|
if (livingEntity
|
||||||
|
.getCustomName() != null) {
|
||||||
tamed = true;
|
tamed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -927,26 +984,48 @@ public class PlotMain extends JavaPlugin {
|
|||||||
boolean found = false;
|
boolean found = false;
|
||||||
int radius = 1;
|
int radius = 1;
|
||||||
int dir = 0;
|
int dir = 0;
|
||||||
int x = this.location.getBlockX();
|
int x = this.location
|
||||||
int y = this.location.getBlockY();
|
.getBlockX();
|
||||||
int z = this.location.getBlockZ();
|
int y = this.location
|
||||||
while (!found && (radius < 4)) {
|
.getBlockY();
|
||||||
|
int z = this.location
|
||||||
|
.getBlockZ();
|
||||||
|
while (!found
|
||||||
|
&& (radius < 4)) {
|
||||||
Location pos;
|
Location pos;
|
||||||
switch (dir) {
|
switch (dir) {
|
||||||
case 0:
|
case 0:
|
||||||
pos = new Location(world, x + radius, y, z);
|
pos = new Location(
|
||||||
|
world,
|
||||||
|
x
|
||||||
|
+ radius,
|
||||||
|
y, z);
|
||||||
dir++;
|
dir++;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
pos = new Location(world, x, y, z + radius);
|
pos = new Location(
|
||||||
|
world,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
z
|
||||||
|
+ radius);
|
||||||
dir++;
|
dir++;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
pos = new Location(world, x - radius, y, z);
|
pos = new Location(
|
||||||
|
world,
|
||||||
|
x
|
||||||
|
- radius,
|
||||||
|
y, z);
|
||||||
dir++;
|
dir++;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
pos = new Location(world, x, y, z - radius);
|
pos = new Location(
|
||||||
|
world,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
z
|
||||||
|
- radius);
|
||||||
dir = 0;
|
dir = 0;
|
||||||
radius++;
|
radius++;
|
||||||
break;
|
break;
|
||||||
@ -955,15 +1034,25 @@ public class PlotMain extends JavaPlugin {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (PlayerEvents.isInPlot(pos)) {
|
if (PlayerEvents
|
||||||
entity.teleport(pos.add(0.5, 0, 0.5));
|
.isInPlot(pos)) {
|
||||||
|
entity.teleport(pos
|
||||||
|
.add(0.5,
|
||||||
|
0,
|
||||||
|
0.5));
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Welp! how did this entity get
|
// Welp! how did this
|
||||||
|
// entity get
|
||||||
// here?
|
// here?
|
||||||
entity.teleport(this.location.subtract(this.location.getDirection().normalize().multiply(2)));
|
entity.teleport(this.location
|
||||||
|
.subtract(this.location
|
||||||
|
.getDirection()
|
||||||
|
.normalize()
|
||||||
|
.multiply(
|
||||||
|
2)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!tamed) {
|
if (!tamed) {
|
||||||
@ -1008,7 +1097,8 @@ 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() + "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
|
sendConsoleSenderMessage(C.PREFIX.s()
|
||||||
|
+ "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
|
||||||
}
|
}
|
||||||
Web.ENABLED = config.getBoolean("web.enabled");
|
Web.ENABLED = config.getBoolean("web.enabled");
|
||||||
Web.PORT = config.getInt("web.port");
|
Web.PORT = config.getInt("web.port");
|
||||||
@ -1022,7 +1112,6 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void createConfiguration(PlotWorld plotworld) {
|
public static void createConfiguration(PlotWorld plotworld) {
|
||||||
String w = plotworld.worldname;
|
|
||||||
Map<String, Object> options = new HashMap<String, Object>();
|
Map<String, Object> options = new HashMap<String, Object>();
|
||||||
|
|
||||||
for (ConfigurationNode setting : plotworld.getSettingNodes()) {
|
for (ConfigurationNode setting : plotworld.getSettingNodes()) {
|
||||||
@ -1044,9 +1133,10 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an external world as a recognized PlotSquared world
|
* Adds an external world as a recognized PlotSquared world - The PlotWorld
|
||||||
* - The PlotWorld class created is based off the configuration in the settings.yml
|
* class created is based off the configuration in the settings.yml - Do not
|
||||||
* - Do not use this method unless the required world is preconfigured in the settings.yml
|
* use this method unless the required world is preconfigured in the
|
||||||
|
* settings.yml
|
||||||
*
|
*
|
||||||
* @param world
|
* @param world
|
||||||
*/
|
*/
|
||||||
@ -1057,13 +1147,13 @@ public class PlotMain extends JavaPlugin {
|
|||||||
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 {
|
||||||
else {
|
|
||||||
worlds = new HashSet<String>();
|
worlds = new HashSet<String>();
|
||||||
}
|
}
|
||||||
ChunkGenerator generator = world.getGenerator();
|
ChunkGenerator generator = world.getGenerator();
|
||||||
if (generator instanceof PlotGenerator) {
|
if (generator instanceof PlotGenerator) {
|
||||||
sendConsoleSenderMessage(C.PREFIX.s()+"&aDetected world load for '"+world.getName()+"'.");
|
sendConsoleSenderMessage(C.PREFIX.s()
|
||||||
|
+ "&aDetected world load for '" + world.getName() + "'.");
|
||||||
PlotGenerator plotgen = (PlotGenerator) generator;
|
PlotGenerator plotgen = (PlotGenerator) generator;
|
||||||
|
|
||||||
PlotWorld plotworld = plotgen.getPlotWorld();
|
PlotWorld plotworld = plotgen.getPlotWorld();
|
||||||
@ -1072,17 +1162,19 @@ public class PlotMain extends JavaPlugin {
|
|||||||
|
|
||||||
config.createSection("worlds." + world.getName());
|
config.createSection("worlds." + world.getName());
|
||||||
|
|
||||||
plotworld.saveConfiguration(config.getConfigurationSection("worlds."+world.getName()));
|
plotworld.saveConfiguration(config
|
||||||
|
.getConfigurationSection("worlds." + world.getName()));
|
||||||
|
|
||||||
plotworld.loadConfiguration(config.getConfigurationSection("worlds."+world.getName()));
|
plotworld.loadConfiguration(config
|
||||||
|
.getConfigurationSection("worlds." + world.getName()));
|
||||||
|
|
||||||
addPlotWorld(world.getName(), plotworld, manager);
|
addPlotWorld(world.getName(), plotworld, manager);
|
||||||
|
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (worlds.contains(world.getName())) {
|
if (worlds.contains(world.getName())) {
|
||||||
sendConsoleSenderMessage("&cWorld '" + world.getName() + "' in settings.yml is not using PlotSquared generator!");
|
sendConsoleSenderMessage("&cWorld '"
|
||||||
|
+ world.getName()
|
||||||
|
+ "' in settings.yml is not using PlotSquared generator!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1146,7 +1238,8 @@ public class PlotMain extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addPlotWorld(String world, PlotWorld plotworld, PlotManager manager) {
|
public static void addPlotWorld(String world, PlotWorld plotworld,
|
||||||
|
PlotManager manager) {
|
||||||
worlds.put(world, plotworld);
|
worlds.put(world, plotworld);
|
||||||
managers.put(world, manager);
|
managers.put(world, manager);
|
||||||
if (!plots.containsKey(world)) {
|
if (!plots.containsKey(world)) {
|
||||||
|
@ -5,7 +5,6 @@ import java.util.ArrayList;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public abstract class PlotManager {
|
public abstract class PlotManager {
|
||||||
@ -19,30 +18,35 @@ 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, PlotId plotid);
|
public abstract boolean isInPlotAbs(PlotWorld plotworld, Location loc,
|
||||||
|
PlotId plotid);
|
||||||
|
|
||||||
// If you have a circular plot, just return the corner if it were a square
|
// If you have a circular plot, just return the corner if it were a square
|
||||||
public abstract Location getPlotBottomLocAbs(PlotWorld plotworld, PlotId plotid);
|
public abstract Location getPlotBottomLocAbs(PlotWorld plotworld,
|
||||||
|
PlotId plotid);
|
||||||
|
|
||||||
// the same applies here
|
// the same applies here
|
||||||
public abstract Location getPlotTopLocAbs(PlotWorld plotworld, PlotId plotid);
|
public abstract Location getPlotTopLocAbs(PlotWorld plotworld, PlotId plotid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Plot clearing (return false if you do not support some method)
|
* Plot clearing (return false if you do not support some method)
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract boolean clearPlot(Player player, Plot plot);
|
public abstract boolean clearPlot(Player player, Plot plot);
|
||||||
|
|
||||||
public abstract Location getSignLoc(Player player, PlotWorld plotworld, Plot plot);
|
public abstract Location getSignLoc(Player player, PlotWorld plotworld,
|
||||||
|
Plot plot);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Plot set functions (return false if you do not support the specific set
|
* Plot set functions (return false if you do not support the specific set
|
||||||
* method)
|
* method)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract boolean setWall(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock block);
|
public abstract boolean setWall(Player player, PlotWorld plotworld,
|
||||||
|
PlotId plotid, PlotBlock block);
|
||||||
|
|
||||||
public abstract boolean setFloor(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock[] block);
|
public abstract boolean setFloor(Player player, PlotWorld plotworld,
|
||||||
|
PlotId plotid, PlotBlock[] block);
|
||||||
|
|
||||||
public abstract boolean setBiome(Player player, Plot plot, Biome biome);
|
public abstract boolean setBiome(Player player, Plot plot, Biome biome);
|
||||||
|
|
||||||
@ -62,6 +66,7 @@ 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, ArrayList<PlotId> plotIds);
|
public abstract boolean finishPlotMerge(World world, PlotWorld plotworld,
|
||||||
|
ArrayList<PlotId> plotIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@ 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" + error.getHeader() + ": &6" + details);
|
PlotMain.sendConsoleSenderMessage("&cPlotError &6>> &c"
|
||||||
|
+ error.getHeader() + ": &6" + details);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum PlotError {
|
public static enum PlotError {
|
||||||
|
@ -1,12 +1,124 @@
|
|||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
|
import static org.bukkit.Material.ACACIA_STAIRS;
|
||||||
|
import static org.bukkit.Material.BEACON;
|
||||||
|
import static org.bukkit.Material.BEDROCK;
|
||||||
|
import static org.bukkit.Material.BIRCH_WOOD_STAIRS;
|
||||||
|
import static org.bukkit.Material.BOOKSHELF;
|
||||||
|
import static org.bukkit.Material.BREWING_STAND;
|
||||||
|
import static org.bukkit.Material.BRICK;
|
||||||
|
import static org.bukkit.Material.BRICK_STAIRS;
|
||||||
|
import static org.bukkit.Material.BURNING_FURNACE;
|
||||||
|
import static org.bukkit.Material.CAKE_BLOCK;
|
||||||
|
import static org.bukkit.Material.CAULDRON;
|
||||||
|
import static org.bukkit.Material.CLAY;
|
||||||
|
import static org.bukkit.Material.CLAY_BRICK;
|
||||||
|
import static org.bukkit.Material.COAL_BLOCK;
|
||||||
|
import static org.bukkit.Material.COAL_ORE;
|
||||||
|
import static org.bukkit.Material.COBBLESTONE;
|
||||||
|
import static org.bukkit.Material.COBBLESTONE_STAIRS;
|
||||||
|
import static org.bukkit.Material.COBBLE_WALL;
|
||||||
|
import static org.bukkit.Material.COMMAND;
|
||||||
|
import static org.bukkit.Material.DARK_OAK_STAIRS;
|
||||||
|
import static org.bukkit.Material.DAYLIGHT_DETECTOR;
|
||||||
|
import static org.bukkit.Material.DIAMOND_BLOCK;
|
||||||
|
import static org.bukkit.Material.DIAMOND_ORE;
|
||||||
|
import static org.bukkit.Material.DIRT;
|
||||||
|
import static org.bukkit.Material.DISPENSER;
|
||||||
|
import static org.bukkit.Material.DROPPER;
|
||||||
|
import static org.bukkit.Material.EMERALD_BLOCK;
|
||||||
|
import static org.bukkit.Material.EMERALD_ORE;
|
||||||
|
import static org.bukkit.Material.ENCHANTMENT_TABLE;
|
||||||
|
import static org.bukkit.Material.ENDER_PORTAL_FRAME;
|
||||||
|
import static org.bukkit.Material.ENDER_STONE;
|
||||||
|
import static org.bukkit.Material.FURNACE;
|
||||||
|
import static org.bukkit.Material.GLASS;
|
||||||
|
import static org.bukkit.Material.GLOWSTONE;
|
||||||
|
import static org.bukkit.Material.GOLD_BLOCK;
|
||||||
|
import static org.bukkit.Material.GOLD_ORE;
|
||||||
|
import static org.bukkit.Material.GRASS;
|
||||||
|
import static org.bukkit.Material.GRAVEL;
|
||||||
|
import static org.bukkit.Material.HARD_CLAY;
|
||||||
|
import static org.bukkit.Material.HAY_BLOCK;
|
||||||
|
import static org.bukkit.Material.HUGE_MUSHROOM_1;
|
||||||
|
import static org.bukkit.Material.HUGE_MUSHROOM_2;
|
||||||
|
import static org.bukkit.Material.IRON_BLOCK;
|
||||||
|
import static org.bukkit.Material.IRON_ORE;
|
||||||
|
import static org.bukkit.Material.JACK_O_LANTERN;
|
||||||
|
import static org.bukkit.Material.JUKEBOX;
|
||||||
|
import static org.bukkit.Material.JUNGLE_WOOD_STAIRS;
|
||||||
|
import static org.bukkit.Material.LAPIS_BLOCK;
|
||||||
|
import static org.bukkit.Material.LAPIS_ORE;
|
||||||
|
import static org.bukkit.Material.LEAVES;
|
||||||
|
import static org.bukkit.Material.LEAVES_2;
|
||||||
|
import static org.bukkit.Material.LOG;
|
||||||
|
import static org.bukkit.Material.LOG_2;
|
||||||
|
import static org.bukkit.Material.MELON_BLOCK;
|
||||||
|
import static org.bukkit.Material.MOB_SPAWNER;
|
||||||
|
import static org.bukkit.Material.MOSSY_COBBLESTONE;
|
||||||
|
import static org.bukkit.Material.MYCEL;
|
||||||
|
import static org.bukkit.Material.NETHERRACK;
|
||||||
|
import static org.bukkit.Material.NETHER_BRICK;
|
||||||
|
import static org.bukkit.Material.NETHER_BRICK_STAIRS;
|
||||||
|
import static org.bukkit.Material.NOTE_BLOCK;
|
||||||
|
import static org.bukkit.Material.OBSIDIAN;
|
||||||
|
import static org.bukkit.Material.PACKED_ICE;
|
||||||
|
import static org.bukkit.Material.PUMPKIN;
|
||||||
|
import static org.bukkit.Material.QUARTZ_BLOCK;
|
||||||
|
import static org.bukkit.Material.QUARTZ_ORE;
|
||||||
|
import static org.bukkit.Material.QUARTZ_STAIRS;
|
||||||
|
import static org.bukkit.Material.REDSTONE_BLOCK;
|
||||||
|
import static org.bukkit.Material.SAND;
|
||||||
|
import static org.bukkit.Material.SANDSTONE;
|
||||||
|
import static org.bukkit.Material.SANDSTONE_STAIRS;
|
||||||
|
import static org.bukkit.Material.SMOOTH_BRICK;
|
||||||
|
import static org.bukkit.Material.SMOOTH_STAIRS;
|
||||||
|
import static org.bukkit.Material.SNOW_BLOCK;
|
||||||
|
import static org.bukkit.Material.SOUL_SAND;
|
||||||
|
import static org.bukkit.Material.SPONGE;
|
||||||
|
import static org.bukkit.Material.SPRUCE_WOOD_STAIRS;
|
||||||
|
import static org.bukkit.Material.STONE;
|
||||||
|
import static org.bukkit.Material.WOOD;
|
||||||
|
import static org.bukkit.Material.WOOD_STAIRS;
|
||||||
|
import static org.bukkit.Material.WOOL;
|
||||||
|
import static org.bukkit.Material.WORKBENCH;
|
||||||
|
import static org.bukkit.Material.getMaterial;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
public abstract class PlotWorld {
|
public abstract class PlotWorld {
|
||||||
|
|
||||||
|
// TODO make this configurable
|
||||||
|
// make non static and static_default_valu + add config option
|
||||||
|
public static ArrayList<Material> BLOCKS = new ArrayList<Material>(
|
||||||
|
Arrays.asList(new Material[] { ACACIA_STAIRS, BEACON, BEDROCK,
|
||||||
|
BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK,
|
||||||
|
BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON,
|
||||||
|
CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL,
|
||||||
|
COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS,
|
||||||
|
DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT,
|
||||||
|
DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE,
|
||||||
|
ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE,
|
||||||
|
FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL,
|
||||||
|
GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1,
|
||||||
|
HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN,
|
||||||
|
JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE,
|
||||||
|
LEAVES, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER,
|
||||||
|
MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK,
|
||||||
|
NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN,
|
||||||
|
PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE,
|
||||||
|
QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND,
|
||||||
|
SANDSTONE_STAIRS, SMOOTH_BRICK, SMOOTH_STAIRS, SNOW_BLOCK,
|
||||||
|
SOUL_SAND, SPONGE, SPRUCE_WOOD_STAIRS, STONE, WOOD,
|
||||||
|
WOOD_STAIRS, WORKBENCH, WOOL, getMaterial(44),
|
||||||
|
getMaterial(126) }));
|
||||||
|
|
||||||
public boolean AUTO_MERGE;
|
public boolean AUTO_MERGE;
|
||||||
public static boolean AUTO_MERGE_DEFAULT = false;
|
public static boolean AUTO_MERGE_DEFAULT = false;
|
||||||
|
|
||||||
@ -43,13 +155,17 @@ public abstract class PlotWorld {
|
|||||||
public double MERGE_PRICE;
|
public double MERGE_PRICE;
|
||||||
public static double MERGE_PRICE_DEFAULT = 100;
|
public static double MERGE_PRICE_DEFAULT = 100;
|
||||||
|
|
||||||
|
public double SELL_PRICE;
|
||||||
|
public static double SELL_PRICE_DEFAULT = 75;
|
||||||
|
|
||||||
public PlotWorld(String worldname) {
|
public PlotWorld(String worldname) {
|
||||||
this.worldname = worldname;
|
this.worldname = worldname;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a world is created, the following method will be called for each node set in the configuration
|
* When a world is created, the following method will be called for each
|
||||||
* - You may ignore this if you generator does not support configuration, or if you want to implement your own methods
|
* node set in the configuration - You may ignore this if you generator does
|
||||||
|
* not support configuration, or if you want to implement your own methods
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
@ -57,14 +173,17 @@ public abstract class PlotWorld {
|
|||||||
public void loadConfiguration(ConfigurationSection config) {
|
public void loadConfiguration(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.getString("plot.biome"));
|
this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config
|
||||||
|
.getString("plot.biome"));
|
||||||
this.SCHEMATIC_ON_CLAIM = config.getBoolean("schematic.on_claim");
|
this.SCHEMATIC_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.getBoolean("schematic.specify_on_claim");
|
this.SCHEMATIC_CLAIM_SPECIFY = config
|
||||||
|
.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");
|
||||||
this.MERGE_PRICE = config.getDouble("economy.prices.merge");
|
this.MERGE_PRICE = config.getDouble("economy.prices.merge");
|
||||||
|
this.SELL_PRICE = config.getDouble("economy.prices.sell");
|
||||||
this.PLOT_CHAT = config.getBoolean("chat.enabled");
|
this.PLOT_CHAT = config.getBoolean("chat.enabled");
|
||||||
this.DEFAULT_FLAGS = config.getStringList("flags.default");
|
this.DEFAULT_FLAGS = config.getStringList("flags.default");
|
||||||
}
|
}
|
||||||
@ -84,6 +203,7 @@ public abstract class PlotWorld {
|
|||||||
config.set("economy.use", this.USE_ECONOMY);
|
config.set("economy.use", this.USE_ECONOMY);
|
||||||
config.set("economy.prices.claim", this.PLOT_PRICE);
|
config.set("economy.prices.claim", this.PLOT_PRICE);
|
||||||
config.set("economy.prices.merge", this.MERGE_PRICE);
|
config.set("economy.prices.merge", this.MERGE_PRICE);
|
||||||
|
config.set("economy.prices.sell", this.SELL_PRICE);
|
||||||
config.set("chat.enabled", this.PLOT_CHAT);
|
config.set("chat.enabled", this.PLOT_CHAT);
|
||||||
config.set("flags.default", this.DEFAULT_FLAGS);
|
config.set("flags.default", this.DEFAULT_FLAGS);
|
||||||
|
|
||||||
@ -100,8 +220,8 @@ public abstract class PlotWorld {
|
|||||||
public String worldname;
|
public String worldname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for the <b>/plot setup</b> command
|
* Used for the <b>/plot setup</b> command Return null if you do not want to
|
||||||
* Return null if you do not want to support this feature
|
* support this feature
|
||||||
*
|
*
|
||||||
* @return ConfigurationNode[]
|
* @return ConfigurationNode[]
|
||||||
*/
|
*/
|
||||||
|
@ -43,7 +43,8 @@ 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).replaceAll("%hours%", s_h);
|
return string.replaceAll("%sec%", s_s).replaceAll("%min%", s_m)
|
||||||
|
.replaceAll("%hours%", s_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Direction {
|
enum Direction {
|
||||||
|
@ -27,7 +27,8 @@ 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") || Bukkit.getVersion().contains("Forge")) {
|
if (Bukkit.getVersion().contains("MCPC")
|
||||||
|
|| Bukkit.getVersion().contains("Forge")) {
|
||||||
forge = true;
|
forge = true;
|
||||||
}
|
}
|
||||||
Server server = Bukkit.getServer();
|
Server server = Bukkit.getServer();
|
||||||
@ -38,7 +39,8 @@ public class ReflectionUtils {
|
|||||||
preClassB += "." + verB;
|
preClassB += "." + verB;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle");
|
Method getHandle = bukkitServerClass
|
||||||
|
.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("\\.");
|
||||||
@ -71,7 +73,9 @@ 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).replace("{nms}", preClassM).replace("{nm}", "net.minecraft");
|
className = className.replace("{cb}", preClassB)
|
||||||
|
.replace("{nms}", preClassM)
|
||||||
|
.replace("{nm}", "net.minecraft");
|
||||||
return getRefClass(Class.forName(className));
|
return getRefClass(Class.forName(className));
|
||||||
} catch (ClassNotFoundException ignored) {
|
} catch (ClassNotFoundException ignored) {
|
||||||
}
|
}
|
||||||
@ -131,7 +135,8 @@ public class ReflectionUtils {
|
|||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
* if method not found
|
* if method not found
|
||||||
*/
|
*/
|
||||||
public RefMethod getMethod(String name, Object... types) throws NoSuchMethodException {
|
public RefMethod getMethod(String name, Object... types)
|
||||||
|
throws NoSuchMethodException {
|
||||||
try {
|
try {
|
||||||
Class[] classes = new Class[types.length];
|
Class[] classes = new Class[types.length];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -147,7 +152,8 @@ public class ReflectionUtils {
|
|||||||
try {
|
try {
|
||||||
return new RefMethod(this.clazz.getMethod(name, classes));
|
return new RefMethod(this.clazz.getMethod(name, classes));
|
||||||
} catch (NoSuchMethodException ignored) {
|
} catch (NoSuchMethodException ignored) {
|
||||||
return new RefMethod(this.clazz.getDeclaredMethod(name, classes));
|
return new RefMethod(this.clazz.getDeclaredMethod(name,
|
||||||
|
classes));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -177,9 +183,11 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return new RefConstructor(this.clazz.getConstructor(classes));
|
return new RefConstructor(
|
||||||
|
this.clazz.getConstructor(classes));
|
||||||
} catch (NoSuchMethodException ignored) {
|
} catch (NoSuchMethodException ignored) {
|
||||||
return new RefConstructor(this.clazz.getDeclaredConstructor(classes));
|
return new RefConstructor(
|
||||||
|
this.clazz.getDeclaredConstructor(classes));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -297,7 +305,8 @@ 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, this.clazz.getDeclaredConstructors());
|
Collections.addAll(constructors,
|
||||||
|
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);
|
||||||
|
@ -31,9 +31,12 @@ public class SchematicHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
EditSession session = new EditSession(new BukkitWorld(location.getWorld()), 999999999);
|
EditSession session = new EditSession(new BukkitWorld(
|
||||||
CuboidClipboard clipboard = CuboidClipboard.loadSchematic(schematic.getFile());
|
location.getWorld()), 999999999);
|
||||||
Location l1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId());
|
CuboidClipboard clipboard = CuboidClipboard.loadSchematic(schematic
|
||||||
|
.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;
|
||||||
@ -48,27 +51,35 @@ public class SchematicHandler {
|
|||||||
|
|
||||||
public Schematic getSchematic(String name) {
|
public Schematic getSchematic(String name) {
|
||||||
{
|
{
|
||||||
File parent = new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics");
|
File parent = new File(JavaPlugin.getPlugin(PlotMain.class)
|
||||||
|
.getDataFolder() + File.separator + "schematics");
|
||||||
if (!parent.exists()) {
|
if (!parent.exists()) {
|
||||||
parent.mkdir();
|
parent.mkdir();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File file = new File(JavaPlugin.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics" + File.separator + name + ".schematic");
|
File file = new File(JavaPlugin.getPlugin(PlotMain.class)
|
||||||
|
.getDataFolder()
|
||||||
|
+ File.separator
|
||||||
|
+ "schematics"
|
||||||
|
+ File.separator + name + ".schematic");
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
PlotMain.sendConsoleSenderMessage(file.toString() + " doesn't exist");
|
PlotMain.sendConsoleSenderMessage(file.toString()
|
||||||
|
+ " 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(iStream));
|
NBTInputStream stream = new NBTInputStream(new GZIPInputStream(
|
||||||
|
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")).getValue();
|
addId = ByteArrayTag.class.cast(tagMap.get("AddBlocks"))
|
||||||
|
.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
short width = ShortTag.class.cast(tagMap.get("Width")).getValue();
|
short width = ShortTag.class.cast(tagMap.get("Width")).getValue();
|
||||||
@ -114,7 +125,8 @@ public class SchematicHandler {
|
|||||||
private Dimension schematicDimension;
|
private Dimension schematicDimension;
|
||||||
private File file;
|
private File file;
|
||||||
|
|
||||||
public Schematic(DataCollection[] blockCollection, Dimension schematicDimension, File file) {
|
public Schematic(DataCollection[] blockCollection,
|
||||||
|
Dimension schematicDimension, File file) {
|
||||||
this.blockCollection = blockCollection;
|
this.blockCollection = blockCollection;
|
||||||
this.schematicDimension = schematicDimension;
|
this.schematicDimension = schematicDimension;
|
||||||
this.file = file;
|
this.file = file;
|
||||||
|
@ -27,12 +27,15 @@ 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, int.class);
|
methodGetChunkAt = classWorld.getMethod("getChunkAt", int.class,
|
||||||
methodA = classChunk.getMethod("a", int.class, int.class, int.class, classBlock, int.class);
|
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, int blockId, byte data) throws NoSuchMethodException {
|
public static boolean set(org.bukkit.World world, int x, int y, int z,
|
||||||
|
int blockId, byte data) throws NoSuchMethodException {
|
||||||
|
|
||||||
Object w = methodGetHandle.of(world).call();
|
Object 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);
|
||||||
@ -45,7 +48,9 @@ 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.getLocation().getChunk().getX() + cx, player.getLocation().getChunk().getZ() + cz);
|
player.getWorld().refreshChunk(
|
||||||
|
player.getLocation().getChunk().getX() + cx,
|
||||||
|
player.getLocation().getChunk().getZ() + cz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,7 @@ public class Settings {
|
|||||||
public static class DB {
|
public static class DB {
|
||||||
public static boolean USE_MONGO = false; /*
|
public static boolean USE_MONGO = false; /*
|
||||||
* TODO: Implement Mongo
|
* TODO: Implement Mongo
|
||||||
|
*
|
||||||
* @Brandon
|
* @Brandon
|
||||||
*/;
|
*/;
|
||||||
public static boolean USE_SQLITE = false;
|
public static boolean USE_SQLITE = false;
|
||||||
|
@ -80,7 +80,8 @@ public class Title {
|
|||||||
* @param fadeOutTime
|
* @param fadeOutTime
|
||||||
* Fade out time
|
* Fade out time
|
||||||
*/
|
*/
|
||||||
public Title(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
public Title(String title, String subtitle, int fadeInTime, int stayTime,
|
||||||
|
int fadeOutTime) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
this.fadeInTime = fadeInTime;
|
this.fadeInTime = fadeInTime;
|
||||||
@ -169,29 +170,56 @@ public class Title {
|
|||||||
* Player
|
* Player
|
||||||
*/
|
*/
|
||||||
public void send(Player player) {
|
public void send(Player player) {
|
||||||
if ((getProtocolVersion(player) >= 47) && isSpigot() && (this.packetTitle != null)) {
|
if ((getProtocolVersion(player) >= 47) && isSpigot()
|
||||||
|
&& (this.packetTitle != null)) {
|
||||||
// First reset previous settings
|
// 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(), "playerConnection").get(handle);
|
Object connection = getField(handle.getClass(),
|
||||||
|
"playerConnection").get(handle);
|
||||||
Object[] actions = this.packetActions.getEnumConstants();
|
Object[] actions = this.packetActions.getEnumConstants();
|
||||||
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
Method sendPacket = getMethod(connection.getClass(),
|
||||||
Object packet = this.packetTitle.getConstructor(this.packetActions, Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(actions[2], this.fadeInTime * (this.ticks ? 1 : 20), this.stayTime * (this.ticks ? 1 : 20), this.fadeOutTime * (this.ticks ? 1 : 20));
|
"sendPacket");
|
||||||
|
Object packet = this.packetTitle.getConstructor(
|
||||||
|
this.packetActions, Integer.TYPE, Integer.TYPE,
|
||||||
|
Integer.TYPE).newInstance(actions[2],
|
||||||
|
this.fadeInTime * (this.ticks ? 1 : 20),
|
||||||
|
this.stayTime * (this.ticks ? 1 : 20),
|
||||||
|
this.fadeOutTime * (this.ticks ? 1 : 20));
|
||||||
// Send if set
|
// Send if set
|
||||||
if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) {
|
if ((this.fadeInTime != -1) && (this.fadeOutTime != -1)
|
||||||
|
&& (this.stayTime != -1)) {
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send title
|
// Send title
|
||||||
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}");
|
Object serialized = getMethod(this.nmsChatSerializer, "a",
|
||||||
packet = this.packetTitle.getConstructor(this.packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[0], serialized);
|
String.class).invoke(
|
||||||
|
null,
|
||||||
|
"{text:\""
|
||||||
|
+ ChatColor.translateAlternateColorCodes('&',
|
||||||
|
this.title) + "\",color:"
|
||||||
|
+ this.titleColor.name().toLowerCase() + "}");
|
||||||
|
packet = this.packetTitle.getConstructor(this.packetActions,
|
||||||
|
getNMSClass("IChatBaseComponent")).newInstance(
|
||||||
|
actions[0], serialized);
|
||||||
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", String.class).invoke(null, "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name().toLowerCase() + "}");
|
serialized = getMethod(this.nmsChatSerializer, "a",
|
||||||
packet = this.packetTitle.getConstructor(this.packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[1], serialized);
|
String.class).invoke(
|
||||||
|
null,
|
||||||
|
"{text:\""
|
||||||
|
+ ChatColor.translateAlternateColorCodes(
|
||||||
|
'&', this.subtitle) + "\",color:"
|
||||||
|
+ this.subtitleColor.name().toLowerCase()
|
||||||
|
+ "}");
|
||||||
|
packet = this.packetTitle.getConstructor(
|
||||||
|
this.packetActions,
|
||||||
|
getNMSClass("IChatBaseComponent")).newInstance(
|
||||||
|
actions[1], serialized);
|
||||||
sendPacket.invoke(connection, packet);
|
sendPacket.invoke(connection, packet);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -220,10 +248,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(), "playerConnection").get(handle);
|
Object connection = getField(handle.getClass(),
|
||||||
|
"playerConnection").get(handle);
|
||||||
Object[] actions = this.packetActions.getEnumConstants();
|
Object[] actions = this.packetActions.getEnumConstants();
|
||||||
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
Method sendPacket = getMethod(connection.getClass(),
|
||||||
Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[3]);
|
"sendPacket");
|
||||||
|
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();
|
||||||
@ -242,10 +273,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(), "playerConnection").get(handle);
|
Object connection = getField(handle.getClass(),
|
||||||
|
"playerConnection").get(handle);
|
||||||
Object[] actions = this.packetActions.getEnumConstants();
|
Object[] actions = this.packetActions.getEnumConstants();
|
||||||
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
|
Method sendPacket = getMethod(connection.getClass(),
|
||||||
Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[4]);
|
"sendPacket");
|
||||||
|
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();
|
||||||
@ -264,9 +298,11 @@ 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").get(handle);
|
Object connection = getField(handle.getClass(), "playerConnection")
|
||||||
|
.get(handle);
|
||||||
Object networkManager = getValue("networkManager", connection);
|
Object networkManager = getValue("networkManager", connection);
|
||||||
version = (Integer) getMethod("getVersion", networkManager.getClass()).invoke(networkManager);
|
version = (Integer) getMethod("getVersion",
|
||||||
|
networkManager.getClass()).invoke(networkManager);
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -310,7 +346,8 @@ public class Title {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Class<?> getPrimitiveType(Class<?> clazz) {
|
private Class<?> getPrimitiveType(Class<?> clazz) {
|
||||||
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz;
|
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES
|
||||||
|
.get(clazz) : clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
||||||
@ -343,7 +380,8 @@ public class Title {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Method getMethod(String name, Class<?> clazz, Class<?>... paramTypes) {
|
private Method getMethod(String name, Class<?> clazz,
|
||||||
|
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());
|
||||||
@ -383,7 +421,9 @@ 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) && ((args.length == 0) || ClassListEqual(args, m.getParameterTypes()))) {
|
if (m.getName().equals(name)
|
||||||
|
&& ((args.length == 0) || ClassListEqual(args,
|
||||||
|
m.getParameterTypes()))) {
|
||||||
m.setAccessible(true);
|
m.setAccessible(true);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
import com.intellectualcrafters.plot.uuid.NameFetcher;
|
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDFetcher;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
|
import com.intellectualcrafters.plot.uuid.NameFetcher;
|
||||||
|
import com.intellectualcrafters.plot.uuid.UUIDFetcher;
|
||||||
|
|
||||||
public class UUIDHandler {
|
public class UUIDHandler {
|
||||||
|
|
||||||
private static ConcurrentHashMap<String, UUID> uuidMap = new ConcurrentHashMap<>();
|
private static ConcurrentHashMap<String, UUID> uuidMap = new ConcurrentHashMap<>();
|
||||||
@ -34,10 +35,12 @@ public class UUIDHandler {
|
|||||||
* @param plugin
|
* @param plugin
|
||||||
*/
|
*/
|
||||||
public static void startFetch(JavaPlugin plugin) {
|
public static void startFetch(JavaPlugin plugin) {
|
||||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
plugin.getServer().getScheduler()
|
||||||
|
.runTaskAsynchronously(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
OfflinePlayer[] offlinePlayers = Bukkit.getOfflinePlayers();
|
OfflinePlayer[] offlinePlayers = Bukkit
|
||||||
|
.getOfflinePlayers();
|
||||||
int lenght = offlinePlayers.length;
|
int lenght = offlinePlayers.length;
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
@ -46,13 +49,19 @@ public class UUIDHandler {
|
|||||||
for (OfflinePlayer player : offlinePlayers) {
|
for (OfflinePlayer player : offlinePlayers) {
|
||||||
name = player.getName();
|
name = player.getName();
|
||||||
uuid = player.getUniqueId();
|
uuid = player.getUniqueId();
|
||||||
if(!uuidExists(uuid))
|
if (!uuidExists(uuid)) {
|
||||||
add(name, uuid);
|
add(name, uuid);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
long time = System.currentTimeMillis() - start;
|
long time = System.currentTimeMillis() - start;
|
||||||
PlotMain.sendConsoleSenderMessage("&cFinished caching of offlineplayers! Took &6" + time + "&cms, &6" + lenght + " &cUUID's were cached" +
|
PlotMain.sendConsoleSenderMessage("&cFinished caching of offlineplayers! Took &6"
|
||||||
" and there is now a grand total of &6" + uuidMap.size() + " &ccached.");
|
+ time
|
||||||
|
+ "&cms, &6"
|
||||||
|
+ lenght
|
||||||
|
+ " &cUUID's were cached"
|
||||||
|
+ " and there is now a grand total of &6"
|
||||||
|
+ uuidMap.size() + " &ccached.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -138,7 +147,8 @@ public class UUIDHandler {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static UUID getUuidOfflineMode(String name) {
|
private static UUID getUuidOfflineMode(String name) {
|
||||||
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
|
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name)
|
||||||
|
.getBytes(Charsets.UTF_8));
|
||||||
add(name, uuid);
|
add(name, uuid);
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,8 @@ 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) && (getPlots(world, player, true).length > 0);
|
return (getPlots(world, player, true) != null)
|
||||||
|
&& (getPlots(world, player, true).length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -227,7 +228,9 @@ 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), PlotHelper.getPlotTopLoc(world, p.id), PlotHelper.getPlotHome(world, p.id) };
|
return new Location[] { PlotHelper.getPlotBottomLoc(world, p.id),
|
||||||
|
PlotHelper.getPlotTopLoc(world, p.id),
|
||||||
|
PlotHelper.getPlotHome(world, p.id) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,16 +8,25 @@
|
|||||||
*/
|
*/
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.*;
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.C;
|
||||||
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
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", CommandCategory.CLAIMING);
|
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a",
|
||||||
|
CommandCategory.CLAIMING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO auto claim a mega plot!!!!!!!!!!!!
|
// TODO auto claim a mega plot!!!!!!!!!!!!
|
||||||
@ -54,7 +63,8 @@ public class Auto extends SubCommand {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
schematic = args[0];
|
schematic = args[0];
|
||||||
//PlayerFunctions.sendMessage(plr, "&cError: Invalid size (X,Y)");
|
// PlayerFunctions.sendMessage(plr,
|
||||||
|
// "&cError: Invalid size (X,Y)");
|
||||||
// return false;
|
// return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -63,7 +73,8 @@ public class Auto extends SubCommand {
|
|||||||
// return false;
|
// return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PlayerFunctions.getPlayerPlotCount(world, plr) >= PlayerFunctions.getAllowedPlots(plr)) {
|
if (PlayerFunctions.getPlayerPlotCount(world, plr) >= PlayerFunctions
|
||||||
|
.getAllowedPlots(plr)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -84,11 +95,14 @@ 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: " + schematic);
|
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: "
|
||||||
|
+ schematic);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) {
|
if (!plr.hasPermission("plots.claim." + schematic)
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
|
&& !plr.hasPermission("plots.admin")) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION,
|
||||||
|
schematic);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,12 +136,14 @@ public class Auto extends SubCommand {
|
|||||||
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, j));
|
Plot plot = PlotHelper.getPlot(world, new PlotId(i,
|
||||||
|
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.getPlotSelectionIds(world, start, end))) {
|
if (!PlotHelper.mergePlots(plr, world, PlayerFunctions
|
||||||
|
.getPlotSelectionIds(world, start, end))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
br = true;
|
br = true;
|
||||||
|
@ -17,8 +17,6 @@ import com.intellectualcrafters.plot.C;
|
|||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
import com.intellectualcrafters.plot.PlotHelper;
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
|
||||||
import com.intellectualcrafters.plot.PlotWorld;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Citymonstret on 2014-08-15.
|
* Created by Citymonstret on 2014-08-15.
|
||||||
@ -28,7 +26,8 @@ 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", CommandCategory.TELEPORT);
|
super("camera", "plots.camera", "Go into camera mode", "camera", "c",
|
||||||
|
CommandCategory.TELEPORT);
|
||||||
this.api = CameraAPI.getInstance();
|
this.api = CameraAPI.getInstance();
|
||||||
this.travelers = new ArrayList<String>();
|
this.travelers = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
@ -49,7 +48,8 @@ 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 + ";" + plot.getId().y);
|
PlayerFunctions.sendMessage(player, C.CAMERA_STARTED, plot.getId().x
|
||||||
|
+ ";" + plot.getId().y);
|
||||||
this.travelers.add(player.getName());
|
this.travelers.add(player.getName());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -68,8 +68,7 @@ public class Camera extends SubCommand implements Listener {
|
|||||||
|
|
||||||
public CameraController getController(Player player, Plot plot) {
|
public CameraController getController(Player player, Plot plot) {
|
||||||
World w = Bukkit.getWorld(plot.world);
|
World w = Bukkit.getWorld(plot.world);
|
||||||
PlotWorld plotworld = PlotMain.getWorldSettings(w);
|
int seconds = PlotHelper.getPlotWidth(w, plot.id) * 5;
|
||||||
int seconds = plotworld.PLOT_WIDTH * 5;
|
|
||||||
Location loc1, loc2, loc3, loc4, loc5;
|
Location loc1, loc2, loc3, loc4, loc5;
|
||||||
double y = player.getLocation().getY();
|
double y = player.getLocation().getY();
|
||||||
Location bottomLoc = PlotHelper.getPlotBottomLoc(w, plot.id);
|
Location bottomLoc = PlotHelper.getPlotBottomLoc(w, plot.id);
|
||||||
@ -88,7 +87,8 @@ 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, seconds, loc1, loc2, loc3, loc4, loc5);
|
CameraController controller = this.api.createController(player,
|
||||||
|
seconds, loc1, loc2, loc3, loc4, loc5);
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
|
import com.intellectualcrafters.plot.FlagManager;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
import com.intellectualcrafters.plot.PlotHelper;
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
@ -31,7 +32,8 @@ import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
|||||||
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.", "claim", CommandCategory.CLAIMING);
|
super(Command.CLAIM, "Claim the current plot you're standing on.",
|
||||||
|
"claim", CommandCategory.CLAIMING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,7 +46,8 @@ 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.getAllowedPlots(plr)) {
|
if (PlayerFunctions.getPlayerPlotCount(plr.getWorld(), plr) >= PlayerFunctions
|
||||||
|
.getAllowedPlots(plr)) {
|
||||||
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -69,11 +72,14 @@ 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: " + schematic);
|
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: "
|
||||||
|
+ schematic);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) {
|
if (!plr.hasPermission("plots.claim." + schematic)
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
|
&& !plr.hasPermission("plots.admin")) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION,
|
||||||
|
schematic);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +97,8 @@ 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, String schematic) {
|
public static boolean claimPlot(Player player, Plot plot, boolean teleport,
|
||||||
|
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()) {
|
||||||
@ -115,7 +122,8 @@ public class Claim extends SubCommand {
|
|||||||
}
|
}
|
||||||
handler.paste(player.getLocation(), sch, plot);
|
handler.paste(player.getLocation(), sch, plot);
|
||||||
}
|
}
|
||||||
plot.settings.setFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS);
|
plot.settings.setFlags(FlagManager.parseFlags(PlotMain
|
||||||
|
.getWorldSettings(player.getWorld()).DEFAULT_FLAGS));
|
||||||
}
|
}
|
||||||
return event.isCancelled();
|
return event.isCancelled();
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,9 @@ 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(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(
|
||||||
|
plr.getUniqueId()))
|
||||||
|
&& !plr.hasPermission("plots.admin")) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ public class CommandPermission {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean hasPermission(Player player) {
|
public boolean hasPermission(Player player) {
|
||||||
return player.hasPermission(this.permission) || player.hasPermission("plots.admin");
|
return player.hasPermission(this.permission)
|
||||||
|
|| player.hasPermission("plots.admin");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,9 @@ 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(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(
|
||||||
|
plr.getUniqueId()))
|
||||||
|
&& !plr.hasPermission("plots.admin")) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,8 @@ 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]", CommandCategory.INFO);
|
super(Command.DEBUG, "Show debug information", "debug [msg]",
|
||||||
|
CommandCategory.INFO);
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* This.
|
* This.
|
||||||
@ -81,25 +82,36 @@ 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", (int) Lag.getPercentage() + "%"));
|
information.append(getLine(line, "Lag Percentage",
|
||||||
information.append(getLine(line, "TPS Percentage", (int) Lag.getFullPercentage() + "%"));
|
(int) Lag.getPercentage() + "%"));
|
||||||
|
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().size()));
|
information.append(getLine(line, "Owned Plots", PlotMain.getPlots()
|
||||||
|
.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", PlotHelper.getWorldFolderSize(Bukkit.getWorld(world))));
|
information.append(getLine(line, "World: " + world + " size",
|
||||||
|
PlotHelper.getWorldFolderSize(Bukkit.getWorld(world))));
|
||||||
}
|
}
|
||||||
information.append(getLine(line, "Entities", PlotHelper.getEntities(plr.getWorld())));
|
information.append(getLine(line, "Entities",
|
||||||
information.append(getLine(line, "Loaded Tile Entities", PlotHelper.getTileEntities(plr.getWorld())));
|
PlotHelper.getEntities(plr.getWorld())));
|
||||||
information.append(getLine(line, "Loaded Chunks", PlotHelper.getLoadedChunks(plr.getWorld())));
|
information.append(getLine(line, "Loaded Tile Entities",
|
||||||
|
PlotHelper.getTileEntities(plr.getWorld())));
|
||||||
|
information.append(getLine(line, "Loaded Chunks",
|
||||||
|
PlotHelper.getLoadedChunks(plr.getWorld())));
|
||||||
information.append(getSection(section, "RAM"));
|
information.append(getSection(section, "RAM"));
|
||||||
information.append(getLine(line, "Free Ram", RUtils.getFreeRam() + "MB"));
|
information.append(getLine(line, "Free Ram", RUtils.getFreeRam()
|
||||||
information.append(getLine(line, "Total Ram", RUtils.getTotalRam() + "MB"));
|
+ "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", C.values().length));
|
information.append(getLine(line, "Total Messages",
|
||||||
information.append(getLine(line, "View all captions", "/plot debug msg"));
|
C.values().length));
|
||||||
|
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 ->
|
||||||
@ -116,7 +128,8 @@ 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) + "\n";
|
return line.replaceAll("%var%", var).replaceAll("%val%", "" + val)
|
||||||
|
+ "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,18 +9,26 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.*;
|
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.C;
|
||||||
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Citymonstret on 2014-08-01.
|
* Created by Citymonstret on 2014-08-01.
|
||||||
*/
|
*/
|
||||||
public class Delete extends SubCommand {
|
public class Delete extends SubCommand {
|
||||||
|
|
||||||
public Delete() {
|
public Delete() {
|
||||||
super(Command.DELETE, "Delete a plot", "delete", CommandCategory.ACTIONS);
|
super(Command.DELETE, "Delete a plot", "delete",
|
||||||
|
CommandCategory.ACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -30,11 +38,14 @@ 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(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
if (!PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(
|
||||||
|
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(plr.getUniqueId()))) && !plr.hasPermission("plots.admin")) {
|
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(
|
||||||
|
plr.getUniqueId())))
|
||||||
|
&& !plr.hasPermission("plots.admin")) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -47,7 +58,8 @@ 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, true);
|
boolean result = PlotMain.removePlot(plr.getWorld().getName(), plot.id,
|
||||||
|
true);
|
||||||
if (result) {
|
if (result) {
|
||||||
PlotHelper.removeSign(plr, plot);
|
PlotHelper.removeSign(plr, plot);
|
||||||
plot.clear(plr);
|
plot.clear(plr);
|
||||||
|
@ -9,17 +9,17 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
import com.intellectualcrafters.plot.UUIDHandler;
|
import com.intellectualcrafters.plot.UUIDHandler;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent;
|
import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Citymonstret on 2014-08-03.
|
* Created by Citymonstret on 2014-08-03.
|
||||||
@ -28,25 +28,8 @@ import java.util.UUID;
|
|||||||
public class Denied extends SubCommand {
|
public class Denied extends SubCommand {
|
||||||
|
|
||||||
public Denied() {
|
public Denied() {
|
||||||
super(Command.DENIED, "Manage plot helpers", "denied {add|remove} {player}", CommandCategory.ACTIONS);
|
super(Command.DENIED, "Manage plot helpers",
|
||||||
}
|
"denied {add|remove} {player}", CommandCategory.ACTIONS);
|
||||||
|
|
||||||
private boolean hasBeenOnServer(String name) {
|
|
||||||
Player plr = Bukkit.getPlayer(name);
|
|
||||||
if (plr == null) {
|
|
||||||
OfflinePlayer oplr = Bukkit.getPlayer(name);
|
|
||||||
if (oplr == null) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return oplr.hasPlayedBefore();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (plr.isOnline()) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return plr.hasPlayedBefore();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -68,35 +51,38 @@ 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, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.setDenied(plr.getWorld().getName(), plot,
|
||||||
|
Bukkit.getOfflinePlayer(args[1]));
|
||||||
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED);
|
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*if (!hasBeenOnServer(args[1])) {
|
/*
|
||||||
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
* if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr,
|
||||||
return true;
|
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if
|
||||||
}
|
* ((Bukkit.getPlayer(args[1]) != null)) { uuid =
|
||||||
UUID uuid = null;
|
* Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid =
|
||||||
if ((Bukkit.getPlayer(args[1]) != null)) {
|
* Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid ==
|
||||||
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
|
* null) { PlayerFunctions.sendMessage(plr,
|
||||||
} else {
|
* C.PLAYER_HAS_NOT_BEEN_ON); return true; }
|
||||||
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
|
*/
|
||||||
}
|
|
||||||
if (uuid == null) {
|
|
||||||
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
UUID uuid = UUIDHandler.getUUID(args[1]);
|
UUID uuid = UUIDHandler.getUUID(args[1]);
|
||||||
plot.addDenied(uuid);
|
plot.addDenied(uuid);
|
||||||
DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.setDenied(plr.getWorld().getName(), plot,
|
||||||
PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true);
|
Bukkit.getOfflinePlayer(args[1]));
|
||||||
|
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) && Bukkit.getPlayer(uuid).isOnline()) {
|
if ((Bukkit.getPlayer(uuid) != null)
|
||||||
Plot pl = PlayerFunctions.getCurrentPlot(Bukkit.getPlayer((uuid)));
|
&& Bukkit.getPlayer(uuid).isOnline()) {
|
||||||
|
Plot pl = PlayerFunctions.getCurrentPlot(Bukkit
|
||||||
|
.getPlayer((uuid)));
|
||||||
if (pl.id == plot.id) {
|
if (pl.id == plot.id) {
|
||||||
PlayerFunctions.sendMessage(Bukkit.getPlayer(uuid), C.YOU_BE_DENIED);
|
PlayerFunctions.sendMessage(Bukkit.getPlayer(uuid),
|
||||||
Bukkit.getPlayer(uuid).teleport(Bukkit.getPlayer(uuid).getWorld().getSpawnLocation());
|
C.YOU_BE_DENIED);
|
||||||
|
Bukkit.getPlayer(uuid).teleport(
|
||||||
|
Bukkit.getPlayer(uuid).getWorld()
|
||||||
|
.getSpawnLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (args[0].equalsIgnoreCase("remove")) {
|
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||||
@ -107,32 +93,28 @@ public class Denied extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
plot.removeDenied(uuid);
|
plot.removeDenied(uuid);
|
||||||
DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.removeDenied(plr.getWorld().getName(), plot,
|
||||||
|
Bukkit.getOfflinePlayer(args[1]));
|
||||||
PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED);
|
PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*if (!hasBeenOnServer(args[1])) {
|
/*
|
||||||
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
* if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr,
|
||||||
return true;
|
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if
|
||||||
}
|
* (Bukkit.getPlayer(args[1])!=null) { uuid =
|
||||||
UUID uuid = null;
|
* Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid =
|
||||||
if (Bukkit.getPlayer(args[1])!=null) {
|
* Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if
|
||||||
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
|
* (!plot.denied.contains(uuid)) { PlayerFunctions.sendMessage(plr,
|
||||||
} else {
|
* C.WAS_NOT_ADDED); return true; } if (uuid == null) {
|
||||||
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
|
* PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
||||||
}
|
* return true; }
|
||||||
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]);
|
UUID uuid = UUIDHandler.getUUID(args[1]);
|
||||||
plot.removeDenied(uuid);
|
plot.removeDenied(uuid);
|
||||||
DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.removeDenied(plr.getWorld().getName(), plot,
|
||||||
PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, false);
|
Bukkit.getOfflinePlayer(args[1]));
|
||||||
|
PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot,
|
||||||
|
uuid, false);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED);
|
PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED);
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,7 +16,8 @@ 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", SubCommand.CommandCategory.INFO);
|
super("help", "", "Get this help menu", "help", "he",
|
||||||
|
SubCommand.CommandCategory.INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -9,41 +9,24 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
import com.intellectualcrafters.plot.UUIDHandler;
|
import com.intellectualcrafters.plot.UUIDHandler;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent;
|
import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class Helpers extends SubCommand {
|
public class Helpers extends SubCommand {
|
||||||
|
|
||||||
public Helpers() {
|
public Helpers() {
|
||||||
super(Command.HELPERS, "Manage plot helpers", "helpers {add|remove} {player}", CommandCategory.ACTIONS);
|
super(Command.HELPERS, "Manage plot helpers",
|
||||||
}
|
"helpers {add|remove} {player}", CommandCategory.ACTIONS);
|
||||||
|
|
||||||
private boolean hasBeenOnServer(String name) {
|
|
||||||
Player plr = Bukkit.getPlayer(name);
|
|
||||||
if (plr == null) {
|
|
||||||
OfflinePlayer oplr = Bukkit.getOfflinePlayer(name);
|
|
||||||
if (oplr == null) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return oplr.hasPlayedBefore();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (plr.isOnline()) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return plr.hasPlayedBefore();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -65,28 +48,26 @@ 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, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.setHelper(plr.getWorld().getName(), plot,
|
||||||
|
Bukkit.getOfflinePlayer(args[1]));
|
||||||
PlayerFunctions.sendMessage(plr, C.HELPER_ADDED);
|
PlayerFunctions.sendMessage(plr, C.HELPER_ADDED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*if (!hasBeenOnServer(args[1])) {
|
/*
|
||||||
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
* if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr,
|
||||||
return true;
|
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if
|
||||||
}
|
* ((Bukkit.getPlayer(args[1]) != null)) { uuid =
|
||||||
UUID uuid = null;
|
* Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid =
|
||||||
if ((Bukkit.getPlayer(args[1]) != null)) {
|
* Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid ==
|
||||||
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
|
* null) { PlayerFunctions.sendMessage(plr,
|
||||||
} else {
|
* C.PLAYER_HAS_NOT_BEEN_ON); return true; }
|
||||||
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
|
*/
|
||||||
}
|
|
||||||
if (uuid == null) {
|
|
||||||
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
UUID uuid = UUIDHandler.getUUID(args[1]);
|
UUID uuid = UUIDHandler.getUUID(args[1]);
|
||||||
plot.addHelper(uuid);
|
plot.addHelper(uuid);
|
||||||
DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.setHelper(plr.getWorld().getName(), plot,
|
||||||
PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true);
|
Bukkit.getOfflinePlayer(args[1]));
|
||||||
|
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")) {
|
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||||
@ -97,32 +78,28 @@ public class Helpers extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
plot.removeHelper(uuid);
|
plot.removeHelper(uuid);
|
||||||
DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.removeHelper(plr.getWorld().getName(), plot,
|
||||||
|
Bukkit.getOfflinePlayer(args[1]));
|
||||||
PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED);
|
PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*if (!hasBeenOnServer(args[1])) {
|
/*
|
||||||
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
* if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr,
|
||||||
return true;
|
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if
|
||||||
}
|
* (Bukkit.getPlayer(args[1]) != null) { uuid =
|
||||||
UUID uuid = null;
|
* Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid =
|
||||||
if (Bukkit.getPlayer(args[1]) != null) {
|
* Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid ==
|
||||||
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
|
* null) { PlayerFunctions.sendMessage(plr,
|
||||||
} else {
|
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } if
|
||||||
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
|
* (!plot.helpers.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;
|
|
||||||
}
|
|
||||||
if (!plot.helpers.contains(uuid)) {
|
|
||||||
PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED);
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
UUID uuid = UUIDHandler.getUUID(args[1]);
|
UUID uuid = UUIDHandler.getUUID(args[1]);
|
||||||
plot.removeHelper(uuid);
|
plot.removeHelper(uuid);
|
||||||
DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.removeHelper(plr.getWorld().getName(), plot,
|
||||||
PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, false);
|
Bukkit.getOfflinePlayer(args[1]));
|
||||||
|
PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot,
|
||||||
|
uuid, false);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED);
|
PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED);
|
||||||
} else {
|
} else {
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
@ -26,12 +24,14 @@ import com.intellectualcrafters.plot.PlotMain;
|
|||||||
public class Home extends SubCommand {
|
public class Home extends SubCommand {
|
||||||
|
|
||||||
public Home() {
|
public Home() {
|
||||||
super(Command.HOME, "Go to your plot", "home {id|alias}", CommandCategory.TELEPORT);
|
super(Command.HOME, "Go to your plot", "home {id|alias}",
|
||||||
|
CommandCategory.TELEPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Plot isAlias(String a) {
|
private Plot isAlias(String a) {
|
||||||
for (Plot p : PlotMain.getPlots()) {
|
for (Plot p : PlotMain.getPlots()) {
|
||||||
if ((p.settings.getAlias().length() > 0) && p.settings.getAlias().equalsIgnoreCase(a)) {
|
if ((p.settings.getAlias().length() > 0)
|
||||||
|
&& p.settings.getAlias().equalsIgnoreCase(a)) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,7 +56,8 @@ public class Home extends SubCommand {
|
|||||||
if ((temp = isAlias(args[0])) != null) {
|
if ((temp = isAlias(args[0])) != null) {
|
||||||
if (temp.hasOwner()) {
|
if (temp.hasOwner()) {
|
||||||
if (temp.getOwner().equals(plr.getUniqueId())) {
|
if (temp.getOwner().equals(plr.getUniqueId())) {
|
||||||
PlotMain.teleportPlayer(plr, plr.getLocation(), temp);
|
PlotMain.teleportPlayer(plr, plr.getLocation(),
|
||||||
|
temp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,9 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.*;
|
import java.util.ArrayList;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -18,8 +19,12 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.intellectualcrafters.plot.C;
|
||||||
import java.util.UUID;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
|
import com.intellectualcrafters.plot.UUIDHandler;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -62,7 +67,8 @@ public class Info extends SubCommand {
|
|||||||
|
|
||||||
// Unclaimed?
|
// Unclaimed?
|
||||||
if (!hasOwner && !containsEveryone && !trustedEveryone) {
|
if (!hasOwner && !containsEveryone && !trustedEveryone) {
|
||||||
PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, plot.id.x + ";" + plot.id.y);
|
PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED,
|
||||||
|
plot.id.x + ";" + plot.id.y);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,17 +83,27 @@ public class Info extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String info = C.PLOT_INFO.s();
|
String info = C.PLOT_INFO.s();
|
||||||
info = info.replaceAll("%alias%", plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none");
|
info = info.replaceAll(
|
||||||
|
"%alias%",
|
||||||
|
plot.settings.getAlias().length() > 0 ? plot.settings
|
||||||
|
.getAlias() : "none");
|
||||||
info = info.replaceAll("%id%", plot.id.toString());
|
info = info.replaceAll("%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%", plot.settings.getChangeTime() ? plot.settings.getTime() + "" : "default");
|
info = info.replaceAll("%time%",
|
||||||
info = info.replaceAll("%weather%", plot.settings.getRain() ? "rain" : "default");
|
plot.settings.getChangeTime() ? plot.settings.getTime() + ""
|
||||||
|
: "default");
|
||||||
|
info = info.replaceAll("%weather%", plot.settings.getRain() ? "rain"
|
||||||
|
: "default");
|
||||||
info = info.replaceAll("%helpers%", getPlayerList(plot.helpers));
|
info = info.replaceAll("%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.replaceAll("%flags%", StringUtils.join(plot.settings.getFlags(), "").length() > 0 ? StringUtils.join(plot.settings.getFlags(), ",") : "none");
|
info = info
|
||||||
|
.replaceAll(
|
||||||
|
"%flags%",
|
||||||
|
StringUtils.join(plot.settings.getFlags(), "").length() > 0 ? StringUtils
|
||||||
|
.join(plot.settings.getFlags(), ",") : "none");
|
||||||
// PlayerFunctions.sendMessage(player,
|
// PlayerFunctions.sendMessage(player,
|
||||||
// PlayerFunctions.getTopPlot(player.getWorld(), plot).id.toString());
|
// PlayerFunctions.getTopPlot(player.getWorld(), plot).id.toString());
|
||||||
// PlayerFunctions.sendMessage(player,
|
// PlayerFunctions.sendMessage(player,
|
||||||
@ -105,7 +121,8 @@ 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))).replace(",", ""));
|
list.append(c.replace("%user%", getPlayerName(l.get(x)))
|
||||||
|
.replace(",", ""));
|
||||||
} else {
|
} else {
|
||||||
list.append(c.replace("%user%", getPlayerName(l.get(x))));
|
list.append(c.replace("%user%", getPlayerName(l.get(x))));
|
||||||
}
|
}
|
||||||
@ -117,15 +134,14 @@ public class Info extends SubCommand {
|
|||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) {
|
if (uuid.equals(DBFunc.everyone)
|
||||||
|
|| uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) {
|
||||||
return "everyone";
|
return "everyone";
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
OfflinePlayer plr = Bukkit.getOfflinePlayer(uuid);
|
* OfflinePlayer plr = Bukkit.getOfflinePlayer(uuid); if (plr.getName()
|
||||||
if (plr.getName() == null) {
|
* == null) { return "unknown"; } return plr.getName();
|
||||||
return "unknown";
|
*/
|
||||||
}
|
|
||||||
return plr.getName();*/
|
|
||||||
return UUIDHandler.getName(uuid);
|
return UUIDHandler.getName(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@ 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", "inventory", "inv", CommandCategory.INFO);
|
super("inventory", "plots.inventory", "Open a command inventory",
|
||||||
|
"inventory", "inv", CommandCategory.INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -33,7 +34,8 @@ 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, size, "PlotSquared Commands");
|
org.bukkit.inventory.Inventory inventory = Bukkit.createInventory(null,
|
||||||
|
size, "PlotSquared Commands");
|
||||||
for (SubCommand cmd : cmds) {
|
for (SubCommand cmd : cmds) {
|
||||||
inventory.addItem(getItem(cmd));
|
inventory.addItem(getItem(cmd));
|
||||||
}
|
}
|
||||||
@ -45,12 +47,17 @@ 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 + " [" + ChatColor.GREEN + cmd.alias + ChatColor.DARK_GRAY + "]");
|
meta.setDisplayName(ChatColor.GREEN + cmd.cmd + ChatColor.DARK_GRAY
|
||||||
|
+ " [" + ChatColor.GREEN + cmd.alias + ChatColor.DARK_GRAY
|
||||||
|
+ "]");
|
||||||
meta.setLore(new ArrayList<String>() {
|
meta.setLore(new ArrayList<String>() {
|
||||||
{
|
{
|
||||||
add(ChatColor.RED + "Category: " + ChatColor.GOLD + cmd.category.toString());
|
add(ChatColor.RED + "Category: " + ChatColor.GOLD
|
||||||
add(ChatColor.RED + "Description: " + ChatColor.GOLD + cmd.description);
|
+ cmd.category.toString());
|
||||||
add(ChatColor.RED + "Usage: " + ChatColor.GOLD + "/plot " + cmd.usage);
|
add(ChatColor.RED + "Description: " + ChatColor.GOLD
|
||||||
|
+ cmd.description);
|
||||||
|
add(ChatColor.RED + "Usage: " + ChatColor.GOLD + "/plot "
|
||||||
|
+ cmd.usage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,8 @@ 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", CommandCategory.ACTIONS);
|
super(Command.KICK, "Kick a player from your plot", "kick",
|
||||||
|
CommandCategory.ACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -32,7 +33,9 @@ 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(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(
|
||||||
|
plr.getUniqueId()))
|
||||||
|
&& !plr.hasPermission("plots.admin")) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -41,12 +44,17 @@ public class Kick extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Bukkit.getPlayer(args[0]) != null) {
|
if (Bukkit.getPlayer(args[0]) != null) {
|
||||||
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
|
PlayerFunctions.sendMessage(plr,
|
||||||
|
C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Player player = Bukkit.getPlayer(args[0]);
|
Player player = Bukkit.getPlayer(args[0]);
|
||||||
if (!player.getWorld().equals(plr.getWorld()) || !PlayerFunctions.isInPlot(player) || (PlayerFunctions.getCurrentPlot(player) == null) || !PlayerFunctions.getCurrentPlot(player).equals(plot)) {
|
if (!player.getWorld().equals(plr.getWorld())
|
||||||
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
|
|| !PlayerFunctions.isInPlot(player)
|
||||||
|
|| (PlayerFunctions.getCurrentPlot(player) == null)
|
||||||
|
|| !PlayerFunctions.getCurrentPlot(player).equals(plot)) {
|
||||||
|
PlayerFunctions.sendMessage(plr,
|
||||||
|
C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
player.teleport(player.getWorld().getSpawnLocation());
|
player.teleport(player.getWorld().getSpawnLocation());
|
||||||
|
@ -9,17 +9,18 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import java.util.ArrayList;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import java.util.Arrays;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.intellectualcrafters.plot.C;
|
||||||
import java.util.Arrays;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlotMain command class
|
* PlotMain command class
|
||||||
@ -29,7 +30,12 @@ import java.util.Arrays;
|
|||||||
*/
|
*/
|
||||||
public class MainCommand implements CommandExecutor {
|
public class MainCommand implements CommandExecutor {
|
||||||
|
|
||||||
private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup() };
|
private static SubCommand[] _subCommands = new SubCommand[] { new Claim(),
|
||||||
|
new Auto(), new Home(), new Visit(), new TP(), new Set(),
|
||||||
|
new Clear(), new Delete(), new SetOwner(), new Denied(),
|
||||||
|
new Helpers(), new Trusted(), new Info(), new list(), new Help(),
|
||||||
|
new Debug(), new Schematic(), new plugin(), new Inventory(),
|
||||||
|
new Reload(), new Merge(), new Unlink(), new Kick(), new Setup() };
|
||||||
|
|
||||||
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
||||||
{
|
{
|
||||||
@ -43,14 +49,16 @@ public class MainCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd,
|
||||||
|
String commandLabel, String[] args) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(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 {
|
} else {
|
||||||
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + 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;
|
||||||
@ -59,19 +67,29 @@ public class MainCommand implements CommandExecutor {
|
|||||||
if (!player.hasPermission("plots.use")) {
|
if (!player.hasPermission("plots.use")) {
|
||||||
return no_permission(player);
|
return no_permission(player);
|
||||||
}
|
}
|
||||||
if ((args.length < 1) || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) {
|
if ((args.length < 1)
|
||||||
|
|| ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0]
|
||||||
|
.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.values()) {
|
for (SubCommand.CommandCategory category : SubCommand.CommandCategory
|
||||||
builder.append("\n" + C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
|
.values()) {
|
||||||
|
builder.append("\n"
|
||||||
|
+ C.HELP_INFO_ITEM
|
||||||
|
.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.values()) {
|
for (SubCommand.CommandCategory category : SubCommand.CommandCategory
|
||||||
|
.values()) {
|
||||||
if (cat.equalsIgnoreCase(category.toString())) {
|
if (cat.equalsIgnoreCase(category.toString())) {
|
||||||
cato = category;
|
cato = category;
|
||||||
break;
|
break;
|
||||||
@ -80,8 +98,15 @@ 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.values()) {
|
for (SubCommand.CommandCategory category : SubCommand.CommandCategory
|
||||||
builder.append("\n" + C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
|
.values()) {
|
||||||
|
builder.append("\n"
|
||||||
|
+ C.HELP_INFO_ITEM
|
||||||
|
.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;
|
||||||
@ -94,7 +119,8 @@ public class MainCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
for (SubCommand command : subCommands) {
|
for (SubCommand command : subCommands) {
|
||||||
if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.equalsIgnoreCase(args[0])) {
|
if (command.cmd.equalsIgnoreCase(args[0])
|
||||||
|
|| command.alias.equalsIgnoreCase(args[0])) {
|
||||||
String[] arguments = new String[args.length - 1];
|
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];
|
||||||
@ -111,18 +137,23 @@ public class MainCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<String> helpMenu(Player player, final SubCommand.CommandCategory category) {
|
public static ArrayList<String> helpMenu(Player player,
|
||||||
|
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%", category.toString())));
|
add(t(C.HELP_CATEGORY.s().replaceAll("%category%",
|
||||||
|
category.toString())));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
for (SubCommand cmd : subCommands) {
|
for (SubCommand cmd : subCommands) {
|
||||||
if (cmd.permission.hasPermission(player) && (cmd.category == category)) {
|
if (cmd.permission.hasPermission(player)
|
||||||
|
&& (cmd.category == category)) {
|
||||||
String s = t(C.HELP_PAGE.s());
|
String s = t(C.HELP_PAGE.s());
|
||||||
s = s.replaceAll("%alias%", cmd.alias);
|
s = s.replaceAll("%alias%", cmd.alias);
|
||||||
s = s.replaceAll("%usage%", cmd.usage.contains("plot") ? cmd.usage : "/plot " + cmd.usage);
|
s = s.replaceAll("%usage%",
|
||||||
|
cmd.usage.contains("plot") ? cmd.usage : "/plot "
|
||||||
|
+ cmd.usage);
|
||||||
s = s.replaceAll("%cmd%", cmd.cmd);
|
s = s.replaceAll("%cmd%", cmd.cmd);
|
||||||
s = s.replaceAll("%desc%", cmd.description);
|
s = s.replaceAll("%desc%", cmd.description);
|
||||||
help.add(s);
|
help.add(s);
|
||||||
|
@ -9,15 +9,24 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.*;
|
import java.util.ArrayList;
|
||||||
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.intellectualcrafters.plot.C;
|
||||||
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.SetBlockFast;
|
||||||
|
import com.intellectualcrafters.plot.events.PlotMergeEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -26,11 +35,14 @@ import java.util.ArrayList;
|
|||||||
*/
|
*/
|
||||||
public class Merge extends SubCommand {
|
public class Merge extends SubCommand {
|
||||||
|
|
||||||
public static String[] values = new String[] { "north", "east", "south", "west" };
|
public static String[] values = new String[] { "north", "east", "south",
|
||||||
|
"west" };
|
||||||
public static String[] aliases = new String[] { "n", "e", "s", "w" };
|
public static String[] aliases = new String[] { "n", "e", "s", "w" };
|
||||||
|
|
||||||
public Merge() {
|
public Merge() {
|
||||||
super(Command.MERGE, "Merge the plot you are standing on with another plot.", "merge", CommandCategory.ACTIONS);
|
super(Command.MERGE,
|
||||||
|
"Merge the plot you are standing on with another plot.",
|
||||||
|
"merge", CommandCategory.ACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String direction(float yaw) {
|
public static String direction(float yaw) {
|
||||||
@ -71,20 +83,35 @@ public class Merge extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s()));
|
PlayerFunctions.sendMessage(
|
||||||
PlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw())));
|
plr,
|
||||||
|
C.SUBCOMMAND_SET_OPTIONS_HEADER.s()
|
||||||
|
+ StringUtils.join(values,
|
||||||
|
C.BLOCK_LIST_SEPARATER.s()));
|
||||||
|
PlayerFunctions.sendMessage(
|
||||||
|
plr,
|
||||||
|
C.DIRECTION.s().replaceAll("%dir%",
|
||||||
|
direction(plr.getLocation().getYaw())));
|
||||||
return false;
|
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]) || args[0].equalsIgnoreCase(aliases[i])) {
|
if (args[0].equalsIgnoreCase(values[i])
|
||||||
|
|| args[0].equalsIgnoreCase(aliases[i])) {
|
||||||
direction = i;
|
direction = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (direction == -1) {
|
if (direction == -1) {
|
||||||
PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringUtils.join(values, C.BLOCK_LIST_SEPARATER.s()));
|
PlayerFunctions.sendMessage(
|
||||||
PlayerFunctions.sendMessage(plr, C.DIRECTION.s().replaceAll("%dir%", direction(plr.getLocation().getYaw())));
|
plr,
|
||||||
|
C.SUBCOMMAND_SET_OPTIONS_HEADER.s()
|
||||||
|
+ StringUtils.join(values,
|
||||||
|
C.BLOCK_LIST_SEPARATER.s()));
|
||||||
|
PlayerFunctions.sendMessage(
|
||||||
|
plr,
|
||||||
|
C.DIRECTION.s().replaceAll("%dir%",
|
||||||
|
direction(plr.getLocation().getYaw())));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
World world = plr.getWorld();
|
World world = plr.getWorld();
|
||||||
@ -93,24 +120,30 @@ 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(), new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(),
|
||||||
|
new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
||||||
break;
|
break;
|
||||||
case 1: // east = +x
|
case 1: // east = +x
|
||||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(),
|
||||||
|
new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
||||||
break;
|
break;
|
||||||
case 2: // south = +y
|
case 2: // south = +y
|
||||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(),
|
||||||
|
new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
||||||
break;
|
break;
|
||||||
case 3: // west = -x
|
case 3: // west = -x
|
||||||
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(), new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
plots = PlayerFunctions.getPlotSelectionIds(plr.getWorld(),
|
||||||
|
new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
||||||
break;
|
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() || !(myplot.getOwner().equals(plr.getUniqueId()))) {
|
if ((myplot == null) || !myplot.hasOwner()
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
|
|| !(myplot.getOwner().equals(plr.getUniqueId()))) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s()
|
||||||
|
.replaceAll("%plot%", myid.toString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@ public class Rate extends SubCommand {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public Rate() {
|
public Rate() {
|
||||||
super("rate", "plots.rate", "Rate the plot", "rate {0-10}", "rt", CommandCategory.ACTIONS);
|
super("rate", "plots.rate", "Rate the plot", "rate {0-10}", "rt",
|
||||||
|
CommandCategory.ACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,8 @@ 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", CommandCategory.INFO);
|
super("reload", "plots.admin", "Reload configurations", "", "reload",
|
||||||
|
CommandCategory.INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,13 +4,15 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
import com.intellectualcrafters.plot.SchematicHandler;
|
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", "schematic {arg}", "sch", CommandCategory.ACTIONS);
|
super("schematic", "plots.admin", "Schematic Command",
|
||||||
|
"schematic {arg}", "sch", CommandCategory.ACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,7 +36,8 @@ 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(), schematic, PlayerFunctions.getCurrentPlot(plr));
|
boolean s = new SchematicHandler().paste(plr.getLocation(),
|
||||||
|
schematic, PlayerFunctions.getCurrentPlot(plr));
|
||||||
if (s) {
|
if (s) {
|
||||||
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
|
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
@ -52,11 +55,19 @@ public class Schematic extends SubCommand {
|
|||||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!PlayerFunctions.isInPlot(plr)) {
|
||||||
|
sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
int l1 = schematic.getSchematicDimension().getX();
|
int l1 = schematic.getSchematicDimension().getX();
|
||||||
int l2 = schematic.getSchematicDimension().getZ();
|
int l2 = schematic.getSchematicDimension().getZ();
|
||||||
int length = PlotMain.getWorldSettings(plr.getWorld()).PLOT_WIDTH;
|
|
||||||
|
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||||
|
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("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
|
sendMessage(plr, C.SCHEMATIC_INVALID, String.format(
|
||||||
|
"Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sendMessage(plr, C.SCHEMATIC_VALID);
|
sendMessage(plr, C.SCHEMATIC_VALID);
|
||||||
|
@ -26,6 +26,7 @@ import com.intellectualcrafters.plot.Flag;
|
|||||||
import com.intellectualcrafters.plot.FlagManager;
|
import com.intellectualcrafters.plot.FlagManager;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.PlotHelper;
|
import com.intellectualcrafters.plot.PlotHelper;
|
||||||
import com.intellectualcrafters.plot.PlotHomePosition;
|
import com.intellectualcrafters.plot.PlotHomePosition;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
@ -42,11 +43,14 @@ import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
|
|||||||
public class Set extends SubCommand {
|
public class Set extends SubCommand {
|
||||||
|
|
||||||
public Set() {
|
public Set() {
|
||||||
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS);
|
super(Command.SET, "Set a plot value", "set {arg} {value...}",
|
||||||
|
CommandCategory.ACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] values = new String[] { "biome", "wall", "wall_filling", "floor", "alias", "home", "rain", "flag" };
|
public static String[] values = new String[] { "biome", "wall",
|
||||||
public static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "r", "fl" };
|
"wall_filling", "floor", "alias", "home", "rain", "flag" };
|
||||||
|
public static String[] aliases = new String[] { "b", "w", "wf", "f", "a",
|
||||||
|
"h", "r", "fl" };
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
@ -85,18 +89,28 @@ 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(), "&c, &6");
|
String message = StringUtils.join(FlagManager.getFlags(),
|
||||||
|
"&c, &6");
|
||||||
if (PlotMain.worldGuardListener != null) {
|
if (PlotMain.worldGuardListener != null) {
|
||||||
if (message.equals("")) {
|
if (message.equals("")) {
|
||||||
message = StringUtils.join(PlotMain.worldGuardListener.str_flags, "&c, &6");
|
message = StringUtils
|
||||||
|
.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, C.NEED_KEY.s().replaceAll("%values%", message));
|
PlayerFunctions.sendMessage(plr,
|
||||||
|
C.NEED_KEY.s().replaceAll("%values%", message));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!FlagManager.getFlags().contains(args[1].toLowerCase()) && (PlotMain.worldGuardListener != null) && !PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) {
|
if (!FlagManager.getFlags().contains(args[1].toLowerCase())
|
||||||
|
&& (PlotMain.worldGuardListener != null)
|
||||||
|
&& !PlotMain.worldGuardListener.str_flags.contains(args[1]
|
||||||
|
.toLowerCase())) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -107,8 +121,10 @@ 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.contains(args[1].toLowerCase())) {
|
if (PlotMain.worldGuardListener.str_flags
|
||||||
PlotMain.worldGuardListener.removeFlag(plr, plr.getWorld(), plot, args[1]);
|
.contains(args[1].toLowerCase())) {
|
||||||
|
PlotMain.worldGuardListener.removeFlag(plr,
|
||||||
|
plr.getWorld(), plot, args[1]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,17 +145,22 @@ 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, newflags.toArray(new Flag[0]));
|
DBFunc.setFlags(plr.getWorld().getName(), plot,
|
||||||
|
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(Arrays.copyOfRange(args, 2, args.length), " ");
|
String value = StringUtils.join(
|
||||||
if ((FlagManager.getFlag(args[1].toLowerCase()) == null) && (PlotMain.worldGuardListener != null)) {
|
Arrays.copyOfRange(args, 2, args.length), " ");
|
||||||
PlotMain.worldGuardListener.addFlag(plr, plr.getWorld(), plot, args[1], value);
|
if ((FlagManager.getFlag(args[1].toLowerCase()) == null)
|
||||||
|
&& (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(), true), value);
|
Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(),
|
||||||
|
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()) {
|
||||||
@ -148,7 +169,8 @@ 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.getFlags().toArray(new Flag[0]));
|
DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings
|
||||||
|
.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) {
|
||||||
@ -196,7 +218,8 @@ 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, position.toString());
|
DBFunc.setPosition(plr.getWorld().getName(), plot,
|
||||||
|
position.toString());
|
||||||
PlayerFunctions.sendMessage(plr, C.POSITION_SET);
|
PlayerFunctions.sendMessage(plr, C.POSITION_SET);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -218,7 +241,8 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
DBFunc.setAlias(plr.getWorld().getName(), plot, alias);
|
DBFunc.setAlias(plr.getWorld().getName(), plot, alias);
|
||||||
PlayerFunctions.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias));
|
PlayerFunctions.sendMessage(plr,
|
||||||
|
C.ALIAS_SET_TO.s().replaceAll("%alias%", alias));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("biome")) {
|
if (args[0].equalsIgnoreCase("biome")) {
|
||||||
@ -234,11 +258,13 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (biome == null) {
|
if (biome == null) {
|
||||||
PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values())));
|
PlayerFunctions.sendMessage(plr,
|
||||||
|
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() + biome.toString().toLowerCase());
|
PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s()
|
||||||
|
+ biome.toString().toLowerCase());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("wall")) {
|
if (args[0].equalsIgnoreCase("wall")) {
|
||||||
@ -259,7 +285,8 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
|
PlayerFunctions
|
||||||
|
.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
byte data = 0;
|
byte data = 0;
|
||||||
@ -273,7 +300,8 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(plr, C.GENERATING_WALL);
|
PlayerFunctions.sendMessage(plr, C.GENERATING_WALL);
|
||||||
PlotHelper.adjustWall(plr.getWorld(), plot, (short) material.getId(), data);
|
PlotHelper.adjustWall(plr, plot,
|
||||||
|
new PlotBlock((short) material.getId(), data));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("floor")) {
|
if (args[0].equalsIgnoreCase("floor")) {
|
||||||
@ -288,19 +316,19 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
//
|
//
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
ArrayList<Material> materials = (ArrayList<Material>) PlotWorld.BLOCKS.clone();
|
ArrayList<Material> materials = (ArrayList<Material>) PlotWorld.BLOCKS
|
||||||
|
.clone();
|
||||||
materials.add(Material.AIR);
|
materials.add(Material.AIR);
|
||||||
//
|
//
|
||||||
String[] strings = args[1].split(",");
|
String[] strings = args[1].split(",");
|
||||||
//
|
//
|
||||||
Material[] material = new Material[strings.length];
|
|
||||||
byte[] data = new byte[strings.length];
|
|
||||||
//
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
//
|
//
|
||||||
byte b = (byte) 0;
|
byte b = (byte) 0;
|
||||||
Material m = null;
|
Material m = null;
|
||||||
//
|
//
|
||||||
|
PlotBlock[] blocks = new PlotBlock[strings.length];
|
||||||
|
|
||||||
for (String s : strings) {
|
for (String s : strings) {
|
||||||
s = s.replaceAll(",", "");
|
s = s.replaceAll(",", "");
|
||||||
String[] ss = s.split(";");
|
String[] ss = s.split(";");
|
||||||
@ -315,8 +343,8 @@ public class Set extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ss.length == 1) {
|
if (ss.length == 1) {
|
||||||
data[index] = (byte) 0;
|
|
||||||
material[index] = m;
|
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]);
|
||||||
@ -324,12 +352,11 @@ public class Set extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
data[index] = b;
|
blocks[index] = new PlotBlock((short) m.getId(), b);
|
||||||
material[index] = m;
|
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
PlotHelper.setFloor(plr, plot, material, data);
|
PlotHelper.setFloor(plr, plot, blocks);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("wall_filling")) {
|
if (args[0].equalsIgnoreCase("wall_filling")) {
|
||||||
@ -350,7 +377,8 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (material == null) {
|
if (material == null) {
|
||||||
PlayerFunctions.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
|
PlayerFunctions
|
||||||
|
.sendMessage(plr, getBlockList(PlotWorld.BLOCKS));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
byte data = 0;
|
byte data = 0;
|
||||||
@ -363,7 +391,8 @@ public class Set extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlotHelper.adjustWallFilling(plr, plr.getWorld(), plot, (short) material.getId(), data);
|
PlotHelper.adjustWallFilling(plr, plot, new PlotBlock(
|
||||||
|
(short) material.getId(), data));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
@ -374,15 +403,18 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getMaterial(Material m) {
|
private String getMaterial(Material m) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", m.toString().toLowerCase()));
|
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM
|
||||||
|
.s().replaceAll("%mat%", m.toString().toLowerCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getBiome(Biome b) {
|
private String getBiome(Biome b) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", b.toString().toLowerCase()));
|
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM
|
||||||
|
.s().replaceAll("%mat%", b.toString().toLowerCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getString(String s) {
|
private String getString(String s) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s));
|
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM
|
||||||
|
.s().replaceAll("%mat%", s));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getArgumentList(String[] strings) {
|
private String getArgumentList(String[] strings) {
|
||||||
@ -395,7 +427,8 @@ 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('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
builder.append(ChatColor.translateAlternateColorCodes('&',
|
||||||
|
C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
||||||
for (Biome b : biomes) {
|
for (Biome b : biomes) {
|
||||||
builder.append(getBiome(b));
|
builder.append(getBiome(b));
|
||||||
}
|
}
|
||||||
@ -404,7 +437,8 @@ 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('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
builder.append(ChatColor.translateAlternateColorCodes('&',
|
||||||
|
C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
||||||
for (Material b : blocks) {
|
for (Material b : blocks) {
|
||||||
builder.append(getMaterial(b));
|
builder.append(getMaterial(b));
|
||||||
}
|
}
|
||||||
|
@ -9,24 +9,30 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.*;
|
import java.util.UUID;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.UUID;
|
import com.intellectualcrafters.plot.C;
|
||||||
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.UUIDHandler;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class SetOwner extends SubCommand {
|
public class SetOwner extends SubCommand {
|
||||||
|
|
||||||
public SetOwner() {
|
public SetOwner() {
|
||||||
super("setowner", "plots.admin", "Set the plot owner", "setowner {player}", "so", CommandCategory.ACTIONS);
|
super("setowner", "plots.admin", "Set the plot owner",
|
||||||
|
"setowner {player}", "so", CommandCategory.ACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
private UUID getUUID(String string) {
|
* private UUID getUUID(String string) { OfflinePlayer player =
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(string);
|
* Bukkit.getOfflinePlayer(string); return ((player != null) &&
|
||||||
return ((player != null) && player.hasPlayedBefore()) ? player.getUniqueId() : null;
|
* player.hasPlayedBefore()) ? player.getUniqueId() : null; }
|
||||||
}*/
|
*/
|
||||||
|
|
||||||
private UUID getUUID(String string) {
|
private UUID getUUID(String string) {
|
||||||
return UUIDHandler.getUUID(string);
|
return UUIDHandler.getUUID(string);
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
|
import com.intellectualcrafters.plot.ConfigurationNode;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
import com.intellectualcrafters.plot.PlotWorld;
|
import com.intellectualcrafters.plot.PlotWorld;
|
||||||
@ -22,141 +21,15 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
|
|
||||||
public static Map<String, SetupObject> setupMap = new HashMap<>();
|
public static Map<String, SetupObject> setupMap = new HashMap<>();
|
||||||
|
|
||||||
private static class SetupStep {
|
|
||||||
private String constant;
|
|
||||||
private Object default_value;
|
|
||||||
private String description;
|
|
||||||
private Object value = 0;
|
|
||||||
private String type;
|
|
||||||
|
|
||||||
public SetupStep(String constant, Object default_value, String description, String type, boolean require_previous) {
|
|
||||||
this.constant = constant;
|
|
||||||
this.default_value = default_value;
|
|
||||||
this.description = description;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return this.type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setValue(String string) {
|
|
||||||
if (!validValue(string)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
switch (this.type) {
|
|
||||||
case "integer":
|
|
||||||
this.value = Integer.parseInt(string);
|
|
||||||
break;
|
|
||||||
case "boolean":
|
|
||||||
this.value = Boolean.parseBoolean(string);
|
|
||||||
break;
|
|
||||||
case "double":
|
|
||||||
this.value = Double.parseDouble(string);
|
|
||||||
break;
|
|
||||||
case "float":
|
|
||||||
this.value = Float.parseFloat(string);
|
|
||||||
break;
|
|
||||||
case "biome":
|
|
||||||
this.value = (string.toUpperCase());
|
|
||||||
break;
|
|
||||||
case "block":
|
|
||||||
this.value = string;
|
|
||||||
break;
|
|
||||||
case "blocklist":
|
|
||||||
this.value = string.split(",");
|
|
||||||
break;
|
|
||||||
case "string":
|
|
||||||
this.value = string;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean validValue(String string) {
|
|
||||||
try {
|
|
||||||
if (this.type.equals("integer")) {
|
|
||||||
Integer.parseInt(string);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (this.type.equals("boolean")) {
|
|
||||||
Boolean.parseBoolean(string);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (this.type.equals("double")) {
|
|
||||||
Double.parseDouble(string);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (this.type.equals("float")) {
|
|
||||||
Float.parseFloat(string);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (this.type.equals("biome")) {
|
|
||||||
Biome.valueOf(string.toUpperCase());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (this.type.equals("block")) {
|
|
||||||
if (string.contains(":")) {
|
|
||||||
String[] split = string.split(":");
|
|
||||||
Short.parseShort(split[0]);
|
|
||||||
Short.parseShort(split[1]);
|
|
||||||
} else {
|
|
||||||
Short.parseShort(string);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (this.type.equals("blocklist")) {
|
|
||||||
for (String block : string.split(",")) {
|
|
||||||
if (block.contains(":")) {
|
|
||||||
String[] split = block.split(":");
|
|
||||||
Short.parseShort(split[0]);
|
|
||||||
Short.parseShort(split[1]);
|
|
||||||
} else {
|
|
||||||
Short.parseShort(block);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (this.type.equals("string")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getValue() {
|
|
||||||
if (this.value instanceof String[]) {
|
|
||||||
return Arrays.asList((String[]) this.value);
|
|
||||||
}
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getConstant() {
|
|
||||||
return this.constant;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getDefaultValue() {
|
|
||||||
if (this.default_value instanceof String[]) {
|
|
||||||
return StringUtils.join((String[]) this.default_value, ",");
|
|
||||||
}
|
|
||||||
return this.default_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return this.description;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SetupObject {
|
private class SetupObject {
|
||||||
String world;
|
String world;
|
||||||
int current = 0;
|
int current = 0;
|
||||||
|
|
||||||
SetupStep[] step = new SetupStep[] { new SetupStep("road.height", PlotWorld.ROAD_HEIGHT_DEFAULT, "Height of road", "integer", false), new SetupStep("plot.height", PlotWorld.PLOT_HEIGHT_DEFAULT, "Height of plot", "integer", false), new SetupStep("wall.height", PlotWorld.WALL_HEIGHT_DEFAULT, "Height of wall", "integer", false), new SetupStep("plot.size", PlotWorld.PLOT_WIDTH_DEFAULT, "Size of plot", "integer", false), new SetupStep("road.width", PlotWorld.ROAD_WIDTH_DEFAULT, "Width of road", "integer", false), new SetupStep("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT, "Plot biome", "biome", false), new SetupStep("plot.filling", PlotWorld.MAIN_BLOCK_DEFAULT, "Plot filling", "blocklist", false), new SetupStep("plot.floor", PlotWorld.TOP_BLOCK_DEFAULT, "Plot floor", "blocklist", false), new SetupStep("wall.block", PlotWorld.WALL_BLOCK_DEFAULT, "Wall block", "block", false), new SetupStep("wall.filling", PlotWorld.WALL_FILLING_DEFAULT, "Wall filling", "block", false),
|
ConfigurationNode[] step;
|
||||||
new SetupStep("road.enable_stripes", PlotWorld.ROAD_STRIPES_ENABLED_DEFAULT, "Enable road stripes", "boolean", false), new SetupStep("road.stripes", PlotWorld.ROAD_STRIPES_DEFAULT, "Road stripes block", "block", true), new SetupStep("road.block", PlotWorld.ROAD_BLOCK_DEFAULT, "Road block", "block", false), };
|
|
||||||
|
|
||||||
public SetupObject(String world) {
|
public SetupObject(String world, PlotWorld plotworld) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
this.step = plotworld.getSettingNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrent() {
|
public int getCurrent() {
|
||||||
@ -169,20 +42,33 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Setup() {
|
public Setup() {
|
||||||
super("setup", "plots.admin", "Setup a PlotWorld", "setup {world}", "setup", CommandCategory.ACTIONS);
|
super("setup", "plots.admin", "Setup a PlotWorld", "setup {world}",
|
||||||
|
"setup", CommandCategory.ACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(Player plr, String... args) {
|
public boolean execute(Player plr, String... args) {
|
||||||
|
boolean finished = false;
|
||||||
|
|
||||||
|
if (!finished) {
|
||||||
|
// TODO recode this to work with the multiple generators
|
||||||
|
PlayerFunctions
|
||||||
|
.sendMessage(plr, "&4CURRENTLY NOT IMPLEMENTED YET!");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (setupMap.containsKey(plr.getName())) {
|
if (setupMap.containsKey(plr.getName())) {
|
||||||
SetupObject object = setupMap.get(plr.getName());
|
SetupObject object = setupMap.get(plr.getName());
|
||||||
if (object.getCurrent() == object.getMax()) {
|
if (object.getCurrent() == object.getMax()) {
|
||||||
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
||||||
|
|
||||||
SetupStep[] steps = object.step;
|
ConfigurationNode[] steps = object.step;
|
||||||
String world = object.world;
|
String world = object.world;
|
||||||
for (SetupStep step : steps) {
|
for (ConfigurationNode step : steps) {
|
||||||
PlotMain.config.set("worlds." + world + "." + step.constant, step.getValue());
|
PlotMain.config.set(
|
||||||
|
"worlds." + world + "." + step.getConstant(),
|
||||||
|
step.getValue());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
PlotMain.config.save(PlotMain.configFile);
|
PlotMain.config.save(PlotMain.configFile);
|
||||||
@ -198,9 +84,11 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SetupStep 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 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
|
||||||
|
step.getDescription(), step.getType(),
|
||||||
|
step.getDefaultValue() + "");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (args[0].equalsIgnoreCase("cancel")) {
|
if (args[0].equalsIgnoreCase("cancel")) {
|
||||||
@ -212,16 +100,21 @@ 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 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
|
||||||
|
step.getDescription(), step.getType(),
|
||||||
|
step.getDefaultValue() + "");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
|
||||||
|
step.getDescription(), step.getType(),
|
||||||
|
step.getDefaultValue() + "");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean valid = step.validValue(args[0]);
|
boolean valid = step.isValid(args[0]);
|
||||||
if (valid) {
|
if (valid) {
|
||||||
sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(), args[0]);
|
sendMessage(plr, C.SETUP_VALID_ARG, step.getConstant(),
|
||||||
|
args[0]);
|
||||||
step.setValue(args[0]);
|
step.setValue(args[0]);
|
||||||
object.current++;
|
object.current++;
|
||||||
if (object.getCurrent() == object.getMax()) {
|
if (object.getCurrent() == object.getMax()) {
|
||||||
@ -229,11 +122,16 @@ 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 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
|
||||||
|
step.getDescription(), step.getType(),
|
||||||
|
step.getDefaultValue() + "");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant());
|
sendMessage(plr, C.SETUP_INVALID_ARG, args[0],
|
||||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
step.getConstant());
|
||||||
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
|
||||||
|
step.getDescription(), step.getType(),
|
||||||
|
step.getDefaultValue() + "");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,11 +149,16 @@ 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;
|
||||||
}
|
}
|
||||||
setupMap.put(plr.getName(), new SetupObject(world));
|
|
||||||
|
PlotWorld plotworld = PlotMain.getWorldSettings("//TODO"); // TODO
|
||||||
|
|
||||||
|
setupMap.put(plr.getName(), new SetupObject(world, plotworld));
|
||||||
sendMessage(plr, C.SETUP_INIT);
|
sendMessage(plr, C.SETUP_INIT);
|
||||||
SetupObject object = setupMap.get(plr.getName());
|
SetupObject object = setupMap.get(plr.getName());
|
||||||
SetupStep step = object.step[object.current];
|
ConfigurationNode step = object.step[object.current];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
|
||||||
|
step.getDescription(), step.getType(),
|
||||||
|
step.getDefaultValue() + "");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,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, String usage, String alias, CommandCategory category) {
|
public SubCommand(String cmd, String permission, String description,
|
||||||
|
String usage, String alias, CommandCategory category) {
|
||||||
this.cmd = cmd;
|
this.cmd = cmd;
|
||||||
this.permission = new CommandPermission(permission);
|
this.permission = new CommandPermission(permission);
|
||||||
this.description = description;
|
this.description = description;
|
||||||
@ -81,7 +82,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(Command command, String description, String usage, CommandCategory category) {
|
public SubCommand(Command command, String description, String usage,
|
||||||
|
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();
|
||||||
@ -117,7 +119,8 @@ public abstract class SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum CommandCategory {
|
public enum CommandCategory {
|
||||||
CLAIMING("Claiming"), TELEPORT("Teleportation"), ACTIONS("Actions"), INFO("Information");
|
CLAIMING("Claiming"), TELEPORT("Teleportation"), ACTIONS("Actions"), INFO(
|
||||||
|
"Information");
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
CommandCategory(String name) {
|
CommandCategory(String name) {
|
||||||
|
@ -29,7 +29,8 @@ import com.intellectualcrafters.plot.PlotMain;
|
|||||||
public class TP extends SubCommand {
|
public class TP extends SubCommand {
|
||||||
|
|
||||||
public TP() {
|
public TP() {
|
||||||
super(Command.TP, "Teleport to a plot", "tp {alias|id}", CommandCategory.TELEPORT);
|
super(Command.TP, "Teleport to a plot", "tp {alias|id}",
|
||||||
|
CommandCategory.TELEPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,8 +57,10 @@ public class TP extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
|
plotid = new PlotId(Integer.parseInt(id.split(";")[0]),
|
||||||
PlotMain.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid));
|
Integer.parseInt(id.split(";")[1]));
|
||||||
|
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);
|
||||||
@ -76,14 +79,16 @@ 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).toArray(new Plot[0]);
|
Plot[] plots = PlotMain.getPlots(world, player)
|
||||||
|
.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) && p.settings.getAlias().equalsIgnoreCase(a)) {
|
if ((p.settings.getAlias().length() > 0)
|
||||||
|
&& p.settings.getAlias().equalsIgnoreCase(a)) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,41 +9,24 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
import com.intellectualcrafters.plot.UUIDHandler;
|
import com.intellectualcrafters.plot.UUIDHandler;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent;
|
import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class Trusted extends SubCommand {
|
public class Trusted extends SubCommand {
|
||||||
|
|
||||||
public Trusted() {
|
public Trusted() {
|
||||||
super(Command.TRUSTED, "Manage trusted users for a plot", "trusted {add|remove} {player}", CommandCategory.ACTIONS);
|
super(Command.TRUSTED, "Manage trusted users for a plot",
|
||||||
}
|
"trusted {add|remove} {player}", CommandCategory.ACTIONS);
|
||||||
|
|
||||||
private boolean hasBeenOnServer(String name) {
|
|
||||||
Player plr = Bukkit.getPlayer(name);
|
|
||||||
if (plr == null) {
|
|
||||||
OfflinePlayer oplr = Bukkit.getOfflinePlayer(name);
|
|
||||||
if (oplr == null) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return oplr.hasPlayedBefore();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (plr.isOnline()) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return plr.hasPlayedBefore();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -65,28 +48,26 @@ 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, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.setTrusted(plr.getWorld().getName(), plot,
|
||||||
|
Bukkit.getOfflinePlayer(args[1]));
|
||||||
PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED);
|
PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*if (!hasBeenOnServer(args[1])) {
|
/*
|
||||||
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
* if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr,
|
||||||
return true;
|
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if
|
||||||
}
|
* ((Bukkit.getPlayer(args[1]) != null)) { uuid =
|
||||||
UUID uuid = null;
|
* Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid =
|
||||||
if ((Bukkit.getPlayer(args[1]) != null)) {
|
* Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid ==
|
||||||
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
|
* null) { PlayerFunctions.sendMessage(plr,
|
||||||
} else {
|
* C.PLAYER_HAS_NOT_BEEN_ON); return true; }
|
||||||
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
|
*/
|
||||||
}
|
|
||||||
if (uuid == null) {
|
|
||||||
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
UUID uuid = UUIDHandler.getUUID(args[1]);
|
UUID uuid = UUIDHandler.getUUID(args[1]);
|
||||||
plot.addTrusted(uuid);
|
plot.addTrusted(uuid);
|
||||||
DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.setTrusted(plr.getWorld().getName(), plot,
|
||||||
PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true);
|
Bukkit.getOfflinePlayer(args[1]));
|
||||||
|
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")) {
|
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||||
@ -97,33 +78,28 @@ public class Trusted extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
plot.removeTrusted(uuid);
|
plot.removeTrusted(uuid);
|
||||||
DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.removeTrusted(plr.getWorld().getName(), plot,
|
||||||
|
Bukkit.getOfflinePlayer(args[1]));
|
||||||
PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED);
|
PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
if (!hasBeenOnServer(args[1])) {
|
* if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr,
|
||||||
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if
|
||||||
return true;
|
* (Bukkit.getPlayer(args[1]) != null) { uuid =
|
||||||
}
|
* Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid =
|
||||||
UUID uuid = null;
|
* Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid ==
|
||||||
if (Bukkit.getPlayer(args[1]) != null) {
|
* null) { PlayerFunctions.sendMessage(plr,
|
||||||
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
|
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } if
|
||||||
} else {
|
* (!plot.trusted.contains(uuid)) { PlayerFunctions.sendMessage(plr,
|
||||||
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
|
* C.T_WAS_NOT_ADDED); return true; }
|
||||||
}
|
*/
|
||||||
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]);
|
UUID uuid = UUIDHandler.getUUID(args[1]);
|
||||||
plot.removeTrusted(uuid);
|
plot.removeTrusted(uuid);
|
||||||
DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
DBFunc.removeTrusted(plr.getWorld().getName(), plot,
|
||||||
PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, false);
|
Bukkit.getOfflinePlayer(args[1]));
|
||||||
|
PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr,
|
||||||
|
plot, uuid, false);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED);
|
PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED);
|
||||||
} else {
|
} else {
|
||||||
|
@ -12,16 +12,15 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
import com.intellectualcrafters.plot.PlotHelper;
|
|
||||||
import com.intellectualcrafters.plot.PlotId;
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.PlotManager;
|
||||||
import com.intellectualcrafters.plot.PlotWorld;
|
import com.intellectualcrafters.plot.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.SetBlockFast;
|
import com.intellectualcrafters.plot.SetBlockFast;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
@ -32,18 +31,9 @@ import com.intellectualcrafters.plot.events.PlotUnlinkEvent;
|
|||||||
*/
|
*/
|
||||||
public class Unlink extends SubCommand {
|
public class Unlink extends SubCommand {
|
||||||
|
|
||||||
private short w_id;
|
|
||||||
private byte w_v;
|
|
||||||
private short wf_id;
|
|
||||||
private byte wf_v;
|
|
||||||
private short f1_id;
|
|
||||||
private byte f1_v;
|
|
||||||
private int pathsize;
|
|
||||||
private int wallheight;
|
|
||||||
private int roadheight;
|
|
||||||
|
|
||||||
public Unlink() {
|
public Unlink() {
|
||||||
super(Command.UNLINK, "Unlink a mega-plot", "unlink", CommandCategory.ACTIONS);
|
super(Command.UNLINK, "Unlink a mega-plot", "unlink",
|
||||||
|
CommandCategory.ACTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -53,18 +43,22 @@ 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(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
|
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(
|
||||||
|
plr.getUniqueId()))
|
||||||
|
&& !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(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(
|
||||||
|
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, pos1, pos2);
|
ArrayList<PlotId> ids = PlayerFunctions.getPlotSelectionIds(world,
|
||||||
|
pos1, pos2);
|
||||||
|
|
||||||
PlotUnlinkEvent event = new PlotUnlinkEvent(world, ids);
|
PlotUnlinkEvent event = new PlotUnlinkEvent(world, ids);
|
||||||
|
|
||||||
@ -85,49 +79,31 @@ 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, false });
|
myplot.settings.setMerged(new boolean[] { false, false, false,
|
||||||
DBFunc.setMerged(world.getName(), myplot, myplot.settings.getMerged());
|
false });
|
||||||
|
DBFunc.setMerged(world.getName(), myplot,
|
||||||
|
myplot.settings.getMerged());
|
||||||
}
|
}
|
||||||
|
PlotManager manager = PlotMain.getPlotManager(world);
|
||||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
this.pathsize = plotworld.ROAD_WIDTH;
|
|
||||||
this.roadheight = plotworld.ROAD_HEIGHT;
|
|
||||||
this.wallheight = plotworld.WALL_HEIGHT;
|
|
||||||
// WALL
|
|
||||||
short[] result_w = PlotHelper.getBlock(plotworld.WALL_BLOCK);
|
|
||||||
this.w_id = result_w[0];
|
|
||||||
this.w_v = (byte) result_w[1];
|
|
||||||
|
|
||||||
// WALL FILLING
|
|
||||||
short[] result_wf = PlotHelper.getBlock(plotworld.WALL_FILLING);
|
|
||||||
this.wf_id = result_wf[0];
|
|
||||||
this.wf_v = (byte) result_wf[1];
|
|
||||||
|
|
||||||
// ROAD
|
|
||||||
short[] result_f1 = PlotHelper.getBlock(plotworld.ROAD_BLOCK);
|
|
||||||
this.f1_id = result_f1[0];
|
|
||||||
this.f1_v = (byte) result_f1[1];
|
|
||||||
//
|
|
||||||
|
|
||||||
PlotHelper.getBlock(plotworld.ROAD_STRIPES);
|
|
||||||
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++) {
|
||||||
boolean lx = x < pos2.x;
|
boolean lx = x < pos2.x;
|
||||||
boolean ly = y < pos2.y;
|
boolean ly = y < pos2.y;
|
||||||
|
|
||||||
PlotId id = new PlotId(x, y);
|
new PlotId(x, y);
|
||||||
|
|
||||||
if (lx) {
|
if (lx) {
|
||||||
setRoadX(world, id);
|
manager.removeRoadEast(plotworld, plot);
|
||||||
|
|
||||||
if (ly) {
|
if (ly) {
|
||||||
setRoadXY(world, id);
|
manager.removeRoadSouthEast(plotworld, plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ly) {
|
if (ly) {
|
||||||
setRoadY(world, id);
|
manager.removeRoadSouth(plotworld, plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -142,76 +118,4 @@ public class Unlink extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, "&6Plots unlinked successfully!");
|
PlayerFunctions.sendMessage(plr, "&6Plots unlinked successfully!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Setting the road with the greatest X value
|
|
||||||
*
|
|
||||||
* @param world
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
public void setRoadX(World w, PlotId id) {
|
|
||||||
Location pos1 = PlotHelper.getPlotBottomLocAbs(w, id);
|
|
||||||
Location pos2 = PlotHelper.getPlotTopLocAbs(w, id);
|
|
||||||
|
|
||||||
int sx = pos2.getBlockX();
|
|
||||||
int ex = (sx + this.pathsize);
|
|
||||||
int sz = pos1.getBlockZ() - 1;
|
|
||||||
int ez = pos2.getBlockZ() + 2;
|
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(this.wallheight, this.roadheight) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), (short) 0);
|
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, this.wallheight + 1, ez), new short[] { this.wf_id }, new short[] { this.wf_v });
|
|
||||||
PlotHelper.setCuboid(w, new Location(w, sx, this.wallheight + 1, sz + 1), new Location(w, sx + 1, this.wallheight + 2, ez), new short[] { this.w_id }, new short[] { this.w_v });
|
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, this.wallheight + 1, ez), new short[] { this.wf_id }, new short[] { this.wf_v });
|
|
||||||
PlotHelper.setCuboid(w, new Location(w, ex, this.wallheight + 1, sz + 1), new Location(w, ex + 1, this.wallheight + 2, ez), new short[] { this.w_id }, new short[] { this.w_v });
|
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, this.roadheight + 1, ez), new short[] { this.f1_id }, new short[] { this.f1_v });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setting the road with the greatest Y value
|
|
||||||
*
|
|
||||||
* @param world
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void setRoadY(World w, PlotId id) {
|
|
||||||
Location pos1 = PlotHelper.getPlotBottomLocAbs(w, id);
|
|
||||||
Location pos2 = PlotHelper.getPlotTopLocAbs(w, id);
|
|
||||||
|
|
||||||
int sz = pos2.getBlockZ();
|
|
||||||
int ez = (sz + this.pathsize);
|
|
||||||
int sx = pos1.getBlockX() - 1;
|
|
||||||
int ex = pos2.getBlockX() + 2;
|
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(this.wallheight, this.roadheight) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), (short) 0);
|
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, this.wallheight + 1, sz + 1), new short[] { this.wf_id }, new short[] { this.wf_v });
|
|
||||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, this.wallheight + 1, sz), new Location(w, ex, this.wallheight + 2, sz + 1), new short[] { this.w_id }, new short[] { this.w_v });
|
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, this.wallheight + 1, ez + 1), new short[] { this.wf_id }, new short[] { this.wf_v });
|
|
||||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, this.wallheight + 1, ez), new Location(w, ex, this.wallheight + 2, ez + 1), new short[] { this.w_id }, new short[] { this.w_v });
|
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, this.roadheight + 1, ez), new short[] { this.f1_id }, new short[] { this.f1_v });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setting the intersection with the greatest X and Y value
|
|
||||||
*
|
|
||||||
* @param world
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
public void setRoadXY(World w, PlotId id) {
|
|
||||||
Location pos2 = PlotHelper.getPlotTopLocAbs(w, id);
|
|
||||||
|
|
||||||
int sx = pos2.getBlockX() + 1;
|
|
||||||
int ex = (sx + this.pathsize) - 1;
|
|
||||||
int sz = pos2.getBlockZ() + 1;
|
|
||||||
int ez = (sz + this.pathsize) - 1;
|
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx, this.roadheight + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), (short) 0);
|
|
||||||
|
|
||||||
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, this.roadheight + 1, ez), new short[] { this.f1_id }, new short[] { this.f1_v });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,8 @@ 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", "visit {player} [#]", "v", CommandCategory.TELEPORT);
|
super("visit", "plots.visit", "Visit someones plot",
|
||||||
|
"visit {player} [#]", "v", CommandCategory.TELEPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Plot> getPlots(UUID uuid) {
|
public List<Plot> getPlots(UUID uuid) {
|
||||||
@ -44,7 +45,8 @@ public class Visit extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String username = args[0];
|
String username = args[0];
|
||||||
List<Plot> plots = getPlots(Bukkit.getOfflinePlayer(username).getUniqueId());
|
List<Plot> plots = getPlots(Bukkit.getOfflinePlayer(username)
|
||||||
|
.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;
|
||||||
|
@ -9,12 +9,18 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import com.intellectualcrafters.plot.C;
|
||||||
import java.util.UUID;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.UUIDHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -24,7 +30,8 @@ import java.util.UUID;
|
|||||||
public class list extends SubCommand {
|
public class list extends SubCommand {
|
||||||
|
|
||||||
public list() {
|
public list() {
|
||||||
super(Command.LIST, "List all plots", "list {mine|all|world}", CommandCategory.INFO);
|
super(Command.LIST, "List all plots", "list {mine|all|world}",
|
||||||
|
CommandCategory.INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -32,53 +39,96 @@ 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", "world", "all" }));
|
builder.append(getArgumentList(new String[] { "mine", "shared",
|
||||||
|
"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") + "\n");
|
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "your")
|
||||||
|
+ "\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.s().replaceAll("%id%", p.id.x + ";" + p.id.y + ";" + p.world).replaceAll("%owner%", getName(p.owner)) + "\n");
|
string.append(C.PLOT_LIST_ITEM
|
||||||
|
.s()
|
||||||
|
.replaceAll("%id%",
|
||||||
|
p.id.x + ";" + p.id.y + ";" + p.world)
|
||||||
|
.replaceAll("%owner%", getName(p.owner))
|
||||||
|
+ "\n");
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
if (idx == 0) {
|
if (idx == 0) {
|
||||||
PlayerFunctions.sendMessage(plr, C.NO_PLOTS);
|
PlayerFunctions.sendMessage(plr, C.NO_PLOTS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "You have").replaceAll("%num%", idx + "").replaceAll("%plot%", idx == 1 ? "plot" : "plots"));
|
string.append(C.PLOT_LIST_FOOTER.s()
|
||||||
|
.replaceAll("%word%", "You have")
|
||||||
|
.replaceAll("%num%", idx + "")
|
||||||
|
.replaceAll("%plot%", idx == 1 ? "plot" : "plots"));
|
||||||
PlayerFunctions.sendMessage(plr, string.toString());
|
PlayerFunctions.sendMessage(plr, string.toString());
|
||||||
return true;
|
return true;
|
||||||
} else if (args[0].equalsIgnoreCase("shared")) {
|
} else if (args[0].equalsIgnoreCase("shared")) {
|
||||||
StringBuilder string = new StringBuilder();
|
StringBuilder string = new StringBuilder();
|
||||||
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") + "\n");
|
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all")
|
||||||
|
+ "\n");
|
||||||
for (Plot p : PlotMain.getPlots()) {
|
for (Plot p : PlotMain.getPlots()) {
|
||||||
if (p.helpers.contains(plr.getUniqueId())) {
|
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_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"));
|
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());
|
PlayerFunctions.sendMessage(plr, string.toString());
|
||||||
return true;
|
return true;
|
||||||
} else if (args[0].equalsIgnoreCase("all")) {
|
} else if (args[0].equalsIgnoreCase("all")) {
|
||||||
StringBuilder string = new StringBuilder();
|
StringBuilder string = new StringBuilder();
|
||||||
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") + "\n");
|
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all")
|
||||||
|
+ "\n");
|
||||||
for (Plot p : PlotMain.getPlots()) {
|
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_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"));
|
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());
|
PlayerFunctions.sendMessage(plr, string.toString());
|
||||||
return true;
|
return true;
|
||||||
} else if (args[0].equalsIgnoreCase("world")) {
|
} else if (args[0].equalsIgnoreCase("world")) {
|
||||||
StringBuilder string = new StringBuilder();
|
StringBuilder string = new StringBuilder();
|
||||||
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") + "\n");
|
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all")
|
||||||
|
+ "\n");
|
||||||
HashMap<PlotId, Plot> plots = PlotMain.getPlots(plr.getWorld());
|
HashMap<PlotId, Plot> plots = PlotMain.getPlots(plr.getWorld());
|
||||||
for (Plot p : plots.values()) {
|
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_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"));
|
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());
|
PlayerFunctions.sendMessage(plr, string.toString());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -91,11 +141,10 @@ public class list extends SubCommand {
|
|||||||
if (id == null) {
|
if (id == null) {
|
||||||
return "none";
|
return "none";
|
||||||
}
|
}
|
||||||
/*String name = Bukkit.getOfflinePlayer(id).getName();
|
/*
|
||||||
if (name == null) {
|
* String name = Bukkit.getOfflinePlayer(id).getName(); if (name ==
|
||||||
return "none";
|
* null) { return "none"; } return name;
|
||||||
}
|
*/
|
||||||
return name;*/
|
|
||||||
return UUIDHandler.getName(id);
|
return UUIDHandler.getName(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +157,8 @@ public class list extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getString(String s) {
|
private String getString(String s) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s));
|
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM
|
||||||
|
.s().replaceAll("%mat%", s));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,39 +9,49 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
|
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", CommandCategory.INFO);
|
super("plugin", "plots.use", "Show plugin information", "plugin", "pl",
|
||||||
|
CommandCategory.INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final Player plr, String... args) {
|
public boolean execute(final Player plr, String... args) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(
|
||||||
|
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
|
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");
|
||||||
downloads = getInfo("https://intellectualsites.com/spigot_api.php?method=downloads&url=http://www.spigotmc.org/resources/plotsquared.1177/"),
|
add(String.format(
|
||||||
version = 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) {
|
for (String s : strings) {
|
||||||
@ -61,7 +71,8 @@ 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(connection.getInputStream()));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||||
|
connection.getInputStream()));
|
||||||
String document = "", line;
|
String document = "", line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
document += (line + "\n");
|
document += (line + "\n");
|
||||||
|
@ -24,7 +24,6 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.Flag;
|
import com.intellectualcrafters.plot.Flag;
|
||||||
@ -54,7 +53,8 @@ public class DBFunc {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = connection.prepareStatement("UPDATE `plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ? ");
|
PreparedStatement statement = connection
|
||||||
|
.prepareStatement("UPDATE `plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ? ");
|
||||||
statement.setString(1, uuid.toString());
|
statement.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);
|
||||||
@ -62,7 +62,8 @@ public class DBFunc {
|
|||||||
statement.close();
|
statement.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Logger.add(LogLevel.DANGER, "Could not set owner for plot " + plot.id);
|
Logger.add(LogLevel.DANGER, "Could not set owner for plot "
|
||||||
|
+ plot.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -72,7 +73,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.prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z`, `world` FROM `plot`");
|
PreparedStatement stmt = connection
|
||||||
|
.prepareStatement("SELECT `id`, `plot_id_x`, `plot_id_z`, `world` FROM `plot`");
|
||||||
ResultSet result = stmt.executeQuery();
|
ResultSet result = stmt.executeQuery();
|
||||||
while (result.next()) {
|
while (result.next()) {
|
||||||
int id = result.getInt("id");
|
int id = result.getInt("id");
|
||||||
@ -105,7 +107,8 @@ 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("INSERT INTO `plot_settings` (`plot_plot_id`) values ");
|
StringBuilder statement = new StringBuilder(
|
||||||
|
"INSERT INTO `plot_settings` (`plot_plot_id`) values ");
|
||||||
for (int i = 0; i < (ids.length - 1); i++) {
|
for (int i = 0; i < (ids.length - 1); i++) {
|
||||||
statement.append("(?),");
|
statement.append("(?),");
|
||||||
}
|
}
|
||||||
@ -124,7 +127,8 @@ public class DBFunc {
|
|||||||
|
|
||||||
// add plot helpers
|
// add plot helpers
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
statement = new StringBuilder("INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) values ");
|
statement = new StringBuilder(
|
||||||
|
"INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) values ");
|
||||||
for (Integer id : helpers.keySet()) {
|
for (Integer id : helpers.keySet()) {
|
||||||
for (UUID helper : helpers.get(id)) {
|
for (UUID helper : helpers.get(id)) {
|
||||||
statement.append(prefix + "(?, ?)");
|
statement.append(prefix + "(?, ?)");
|
||||||
@ -162,7 +166,8 @@ public class DBFunc {
|
|||||||
if (plots.size() == 0) {
|
if (plots.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StringBuilder statement = new StringBuilder("INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) values ");
|
StringBuilder statement = new StringBuilder(
|
||||||
|
"INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) values ");
|
||||||
|
|
||||||
for (int i = 0; i < (plots.size() - 1); i++) {
|
for (int i = 0; i < (plots.size() - 1); i++) {
|
||||||
statement.append("(?, ?, ?, ?),");
|
statement.append("(?, ?, ?, ?),");
|
||||||
@ -195,7 +200,8 @@ 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.prepareStatement("INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) VALUES(?, ?, ?, ?)");
|
stmt = connection
|
||||||
|
.prepareStatement("INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) VALUES(?, ?, ?, ?)");
|
||||||
stmt.setInt(1, plot.id.x);
|
stmt.setInt(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());
|
||||||
@ -213,27 +219,81 @@ public class DBFunc {
|
|||||||
*
|
*
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public static void createTables(String database, boolean add_constraint) throws SQLException {
|
public static void createTables(String database, boolean add_constraint)
|
||||||
|
throws SQLException {
|
||||||
boolean mysql = database.equals("mysql");
|
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` (" + "`id` INT(11) NOT NULL AUTO_INCREMENT," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," + "PRIMARY KEY (`id`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot` ("
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
+ "`id` INT(11) NOT NULL AUTO_INCREMENT,"
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
+ "`plot_id_x` INT(11) NOT NULL,"
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
+ "`plot_id_z` INT(11) NOT NULL,"
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)," + " UNIQUE KEY `unique_alias` (`alias`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
+ "`owner` VARCHAR(45) NOT NULL,"
|
||||||
|
+ "`world` VARCHAR(45) NOT NULL,"
|
||||||
|
+ "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,"
|
||||||
|
+ "PRIMARY KEY (`id`)"
|
||||||
|
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
|
||||||
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_denied` ("
|
||||||
|
+ "`plot_plot_id` INT(11) NOT NULL,"
|
||||||
|
+ "`user_uuid` VARCHAR(40) NOT NULL"
|
||||||
|
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` ("
|
||||||
|
+ "`plot_plot_id` INT(11) NOT NULL,"
|
||||||
|
+ "`user_uuid` VARCHAR(40) NOT NULL"
|
||||||
|
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` ("
|
||||||
|
+ "`plot_plot_id` INT(11) NOT NULL,"
|
||||||
|
+ "`user_uuid` VARCHAR(40) NOT NULL"
|
||||||
|
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` ("
|
||||||
|
+ " `plot_plot_id` INT(11) NOT NULL,"
|
||||||
|
+ " `biome` VARCHAR(45) DEFAULT 'FOREST',"
|
||||||
|
+ " `rain` INT(1) DEFAULT 0,"
|
||||||
|
+ " `custom_time` TINYINT(1) DEFAULT '0',"
|
||||||
|
+ " `time` INT(11) DEFAULT '8000',"
|
||||||
|
+ " `deny_entry` TINYINT(1) DEFAULT '0',"
|
||||||
|
+ " `alias` VARCHAR(50) DEFAULT NULL,"
|
||||||
|
+ " `flags` VARCHAR(512) DEFAULT NULL,"
|
||||||
|
+ " `merged` INT(11) DEFAULT NULL,"
|
||||||
|
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
||||||
|
+ " PRIMARY KEY (`plot_plot_id`),"
|
||||||
|
+ " UNIQUE KEY `unique_alias` (`alias`)"
|
||||||
|
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_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 {
|
} else {
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot` (" + "`id` INTEGER(11) PRIMARY KEY," + "`plot_id_x` INT(11) NOT NULL," + "`plot_id_z` INT(11) NOT NULL," + "`owner` VARCHAR(45) NOT NULL," + "`world` VARCHAR(45) NOT NULL," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)");
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot` ("
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
+ "`id` INTEGER(11) PRIMARY KEY,"
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
+ "`plot_id_x` INT(11) NOT NULL,"
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
+ "`plot_id_z` INT(11) NOT NULL,"
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")");
|
+ "`owner` VARCHAR(45) NOT NULL,"
|
||||||
|
+ "`world` VARCHAR(45) NOT NULL,"
|
||||||
|
+ "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)");
|
||||||
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_denied` ("
|
||||||
|
+ "`plot_plot_id` INT(11) NOT NULL,"
|
||||||
|
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
||||||
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` ("
|
||||||
|
+ "`plot_plot_id` INT(11) NOT NULL,"
|
||||||
|
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
||||||
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` ("
|
||||||
|
+ "`plot_plot_id` INT(11) NOT NULL,"
|
||||||
|
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
|
||||||
|
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` ("
|
||||||
|
+ " `plot_plot_id` INT(11) NOT NULL,"
|
||||||
|
+ " `biome` VARCHAR(45) DEFAULT 'FOREST',"
|
||||||
|
+ " `rain` INT(1) DEFAULT 0,"
|
||||||
|
+ " `custom_time` TINYINT(1) DEFAULT '0',"
|
||||||
|
+ " `time` INT(11) DEFAULT '8000',"
|
||||||
|
+ " `deny_entry` TINYINT(1) DEFAULT '0',"
|
||||||
|
+ " `alias` VARCHAR(50) DEFAULT NULL,"
|
||||||
|
+ " `flags` VARCHAR(512) DEFAULT NULL,"
|
||||||
|
+ " `merged` INT(11) DEFAULT NULL,"
|
||||||
|
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
|
||||||
|
+ " PRIMARY KEY (`plot_plot_id`)" + ")");
|
||||||
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_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();
|
||||||
@ -254,25 +314,30 @@ 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.prepareStatement("DELETE FROM `plot_settings` WHERE `plot_plot_id` = ?");
|
stmt = connection
|
||||||
|
.prepareStatement("DELETE FROM `plot_settings` WHERE `plot_plot_id` = ?");
|
||||||
stmt.setInt(1, id);
|
stmt.setInt(1, id);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
stmt = connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ?");
|
stmt = connection
|
||||||
|
.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ?");
|
||||||
stmt.setInt(1, id);
|
stmt.setInt(1, id);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
stmt = connection.prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = ?");
|
stmt = connection
|
||||||
|
.prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = ?");
|
||||||
stmt.setInt(1, id);
|
stmt.setInt(1, id);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
stmt = connection.prepareStatement("DELETE FROM `plot` WHERE `id` = ?");
|
stmt = connection
|
||||||
|
.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 " + plot.id);
|
Logger.add(LogLevel.DANGER, "Failed to delete plot "
|
||||||
|
+ plot.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -290,7 +355,9 @@ public class DBFunc {
|
|||||||
public void run() {
|
public void run() {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
stmt = connection.prepareStatement("INSERT INTO `plot_settings`(`plot_plot_id`) VALUES(" + "?)");
|
stmt = connection
|
||||||
|
.prepareStatement("INSERT INTO `plot_settings`(`plot_plot_id`) VALUES("
|
||||||
|
+ "?)");
|
||||||
stmt.setInt(1, id);
|
stmt.setInt(1, id);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
@ -305,7 +372,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.prepareStatement("SELECT `id` FROM `plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC");
|
stmt = connection
|
||||||
|
.prepareStatement("SELECT `id` FROM `plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC");
|
||||||
stmt.setInt(1, id2.x);
|
stmt.setInt(1, id2.x);
|
||||||
stmt.setInt(2, id2.y);
|
stmt.setInt(2, id2.y);
|
||||||
stmt.setString(3, world);
|
stmt.setString(3, world);
|
||||||
@ -349,18 +417,32 @@ public class DBFunc {
|
|||||||
boolean execute = rs.next();
|
boolean execute = rs.next();
|
||||||
if (execute) {
|
if (execute) {
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
statement.addBatch("ALTER IGNORE TABLE `plot` ADD `plot_id_x` int(11) DEFAULT 0");
|
statement
|
||||||
statement.addBatch("ALTER IGNORE TABLE `plot` ADD `plot_id_z` int(11) DEFAULT 0");
|
.addBatch("ALTER IGNORE TABLE `plot` ADD `plot_id_x` int(11) DEFAULT 0");
|
||||||
statement.addBatch("UPDATE `plot` SET\n" + " `plot_id_x` = IF(" + " LOCATE(';', `plot_id`) > 0," + " SUBSTRING(`plot_id`, 1, LOCATE(';', `plot_id`) - 1)," + " `plot_id`" + " )," + " `plot_id_z` = IF(" + " LOCATE(';', `plot_id`) > 0," + " SUBSTRING(`plot_id`, LOCATE(';', `plot_id`) + 1)," + " NULL" + " )");
|
statement
|
||||||
|
.addBatch("ALTER IGNORE TABLE `plot` ADD `plot_id_z` int(11) DEFAULT 0");
|
||||||
|
statement
|
||||||
|
.addBatch("UPDATE `plot` SET\n"
|
||||||
|
+ " `plot_id_x` = IF("
|
||||||
|
+ " LOCATE(';', `plot_id`) > 0,"
|
||||||
|
+ " SUBSTRING(`plot_id`, 1, LOCATE(';', `plot_id`) - 1),"
|
||||||
|
+ " `plot_id`"
|
||||||
|
+ " ),"
|
||||||
|
+ " `plot_id_z` = IF("
|
||||||
|
+ " LOCATE(';', `plot_id`) > 0,"
|
||||||
|
+ " SUBSTRING(`plot_id`, LOCATE(';', `plot_id`) + 1),"
|
||||||
|
+ " NULL" + " )");
|
||||||
statement.addBatch("ALTER TABLE `plot` DROP `plot_id`");
|
statement.addBatch("ALTER TABLE `plot` DROP `plot_id`");
|
||||||
statement.addBatch("ALTER IGNORE TABLE `plot_settings` ADD `flags` VARCHAR(512) DEFAULT NULL");
|
statement
|
||||||
|
.addBatch("ALTER IGNORE TABLE `plot_settings` ADD `flags` VARCHAR(512) DEFAULT NULL");
|
||||||
statement.executeBatch();
|
statement.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.addBatch("ALTER TABLE `plot_settings` ADD `merged` int(11) DEFAULT NULL");
|
statement
|
||||||
|
.addBatch("ALTER TABLE `plot_settings` ADD `merged` int(11) DEFAULT NULL");
|
||||||
statement.executeBatch();
|
statement.executeBatch();
|
||||||
statement.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
@ -373,16 +455,19 @@ 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").getKeys(false);
|
worlds = PlotMain.config.getConfigurationSection("worlds")
|
||||||
|
.getKeys(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt = connection.createStatement();
|
stmt = connection.createStatement();
|
||||||
ResultSet r = stmt.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world` FROM `plot`");
|
ResultSet r = stmt
|
||||||
|
.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world` FROM `plot`");
|
||||||
PlotId plot_id;
|
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"), r.getInt("plot_id_z"));
|
plot_id = new PlotId(r.getInt("plot_id_x"),
|
||||||
|
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);
|
||||||
@ -398,9 +483,11 @@ public class DBFunc {
|
|||||||
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(FlagManager.getFlag(split[0], true), split[1]);
|
flags[i] = new Flag(
|
||||||
|
FlagManager.getFlag(split[0], true), split[1]);
|
||||||
} else {
|
} else {
|
||||||
flags[i] = new Flag(FlagManager.getFlag(flags_string[i], true), "");
|
flags[i] = new Flag(FlagManager.getFlag(
|
||||||
|
flags_string[i], true), "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArrayList<UUID> helpers = plotHelpers(id);
|
ArrayList<UUID> helpers = plotHelpers(id);
|
||||||
@ -426,25 +513,30 @@ public class DBFunc {
|
|||||||
alias = "";
|
alias = "";
|
||||||
}
|
}
|
||||||
PlotHomePosition position = null;
|
PlotHomePosition position = null;
|
||||||
for (PlotHomePosition plotHomePosition : PlotHomePosition.values()) {
|
for (PlotHomePosition plotHomePosition : PlotHomePosition
|
||||||
|
.values()) {
|
||||||
if (settings.get("position") == null) {
|
if (settings.get("position") == null) {
|
||||||
position = PlotHomePosition.DEFAULT;
|
position = PlotHomePosition.DEFAULT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (plotHomePosition.isMatching((String) settings.get("position"))) {
|
if (plotHomePosition.isMatching((String) settings
|
||||||
|
.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) settings.get("merged");
|
int merged_int = settings.get("merged") == null ? 0
|
||||||
|
: (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, denied, /* changeTime */false, time, rain, alias, position, flags, worldname, merged);
|
p = new Plot(plot_id, owner, plotBiome, helpers, trusted,
|
||||||
|
denied, /* changeTime */false, time, rain, alias,
|
||||||
|
position, flags, worldname, merged);
|
||||||
if (plots.containsKey(worldname)) {
|
if (plots.containsKey(worldname)) {
|
||||||
plots.get(worldname).put((plot_id), p);
|
plots.get(worldname).put((plot_id), p);
|
||||||
} else {
|
} else {
|
||||||
@ -452,9 +544,12 @@ public class DBFunc {
|
|||||||
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 {
|
||||||
else {
|
PlotMain.sendConsoleSenderMessage("&cPlot '"
|
||||||
PlotMain.sendConsoleSenderMessage("&cPlot '"+p.id+"' in DB for world '"+p.world+"' does not exist! Please create this world, or remove the plots from the DB!");
|
+ p.id
|
||||||
|
+ "' in DB for world '"
|
||||||
|
+ p.world
|
||||||
|
+ "' does not exist! Please create this world, or remove the plots from the DB!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -470,27 +565,31 @@ public class DBFunc {
|
|||||||
* @param plot
|
* @param plot
|
||||||
* @param rain
|
* @param rain
|
||||||
*/
|
*/
|
||||||
public static void setWeather(final String world, final Plot plot, final boolean rain) {
|
public static void setWeather(final String world, final Plot plot,
|
||||||
|
final boolean rain) {
|
||||||
plot.settings.setRain(rain);
|
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.prepareStatement("UPDATE `plot_settings` SET `rain` = ? WHERE `plot_plot_id` = ?");
|
PreparedStatement stmt = connection
|
||||||
|
.prepareStatement("UPDATE `plot_settings` SET `rain` = ? WHERE `plot_plot_id` = ?");
|
||||||
stmt.setInt(1, weather);
|
stmt.setInt(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, "Could not set weather for plot " + plot.id);
|
Logger.add(LogLevel.WARNING,
|
||||||
|
"Could not set weather for plot " + plot.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setMerged(final String world, final Plot plot, final boolean[] merged) {
|
public static void setMerged(final String world, final Plot plot,
|
||||||
|
final boolean[] merged) {
|
||||||
plot.settings.setMerged(merged);
|
plot.settings.setMerged(merged);
|
||||||
runTask(new Runnable() {
|
runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -500,20 +599,23 @@ 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.prepareStatement("UPDATE `plot_settings` SET `merged` = ? WHERE `plot_plot_id` = ?");
|
PreparedStatement stmt = connection
|
||||||
|
.prepareStatement("UPDATE `plot_settings` SET `merged` = ? WHERE `plot_plot_id` = ?");
|
||||||
stmt.setInt(1, n);
|
stmt.setInt(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, "Could not set merged for plot " + plot.id);
|
Logger.add(LogLevel.WARNING,
|
||||||
|
"Could not set merged for plot " + plot.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setFlags(final String world, final Plot plot, final Flag[] flags) {
|
public static void setFlags(final String world, final Plot plot,
|
||||||
|
final Flag[] flags) {
|
||||||
plot.settings.setFlags(flags);
|
plot.settings.setFlags(flags);
|
||||||
final StringBuilder flag_string = new StringBuilder();
|
final StringBuilder flag_string = new StringBuilder();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -528,14 +630,16 @@ public class DBFunc {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
PreparedStatement stmt = connection.prepareStatement("UPDATE `plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?");
|
PreparedStatement stmt = connection
|
||||||
|
.prepareStatement("UPDATE `plot_settings` SET `flags` = ? WHERE `plot_plot_id` = ?");
|
||||||
stmt.setString(1, flag_string.toString());
|
stmt.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 " + plot.id);
|
Logger.add(LogLevel.WARNING, "Could not set flag for plot "
|
||||||
|
+ plot.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -545,20 +649,23 @@ public class DBFunc {
|
|||||||
* @param plot
|
* @param plot
|
||||||
* @param alias
|
* @param alias
|
||||||
*/
|
*/
|
||||||
public static void setAlias(final String world, final Plot plot, final String alias) {
|
public static void setAlias(final String world, final Plot plot,
|
||||||
|
final String alias) {
|
||||||
plot.settings.setAlias(alias);
|
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.prepareStatement("UPDATE `plot_settings` SET `alias` = ? WHERE `plot_plot_id` = ?");
|
stmt = connection
|
||||||
|
.prepareStatement("UPDATE `plot_settings` SET `alias` = ? WHERE `plot_plot_id` = ?");
|
||||||
stmt.setString(1, alias);
|
stmt.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) {
|
} catch (SQLException e) {
|
||||||
Logger.add(LogLevel.WARNING, "Failed to set alias for plot " + plot.id);
|
Logger.add(LogLevel.WARNING,
|
||||||
|
"Failed to set alias for plot " + plot.id);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,27 +677,31 @@ public class DBFunc {
|
|||||||
* @param r
|
* @param r
|
||||||
*/
|
*/
|
||||||
private static void runTask(Runnable r) {
|
private static void runTask(Runnable r) {
|
||||||
PlotMain.getMain().getServer().getScheduler().runTaskAsynchronously(PlotMain.getMain(), r);
|
PlotMain.getMain().getServer().getScheduler()
|
||||||
|
.runTaskAsynchronously(PlotMain.getMain(), r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* @param plot
|
||||||
* @param position
|
* @param position
|
||||||
*/
|
*/
|
||||||
public static void setPosition(final String world, final Plot plot, final String position) {
|
public static void setPosition(final String world, final Plot plot,
|
||||||
|
final String position) {
|
||||||
plot.settings.setPosition(PlotHomePosition.valueOf(position));
|
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.prepareStatement("UPDATE `plot_settings` SET `position` = ? WHERE `plot_plot_id` = ?");
|
stmt = connection
|
||||||
|
.prepareStatement("UPDATE `plot_settings` SET `position` = ? WHERE `plot_plot_id` = ?");
|
||||||
stmt.setString(1, position);
|
stmt.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) {
|
} catch (SQLException e) {
|
||||||
Logger.add(LogLevel.WARNING, "Failed to set position for plot " + plot.id);
|
Logger.add(LogLevel.WARNING,
|
||||||
|
"Failed to set position for plot " + plot.id);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -605,7 +716,8 @@ 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.prepareStatement("SELECT * FROM `plot_settings` WHERE `plot_plot_id` = ?");
|
stmt = connection
|
||||||
|
.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;
|
||||||
@ -642,7 +754,8 @@ public class DBFunc {
|
|||||||
stmt.close();
|
stmt.close();
|
||||||
;
|
;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.add(LogLevel.WARNING, "Failed to load settings for plot: " + id);
|
Logger.add(LogLevel.WARNING, "Failed to load settings for plot: "
|
||||||
|
+ id);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return h;
|
return h;
|
||||||
@ -661,7 +774,8 @@ 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.prepareStatement("SELECT `user_uuid` FROM `plot_denied` WHERE `plot_plot_id` = ?");
|
stmt = connection
|
||||||
|
.prepareStatement("SELECT `user_uuid` FROM `plot_denied` WHERE `plot_plot_id` = ?");
|
||||||
stmt.setInt(1, id);
|
stmt.setInt(1, id);
|
||||||
ResultSet r = stmt.executeQuery();
|
ResultSet r = stmt.executeQuery();
|
||||||
UUID u;
|
UUID u;
|
||||||
@ -686,7 +800,9 @@ public class DBFunc {
|
|||||||
Statement stmt = null;
|
Statement stmt = null;
|
||||||
try {
|
try {
|
||||||
stmt = connection.createStatement();
|
stmt = connection.createStatement();
|
||||||
ResultSet r = stmt.executeQuery("SELECT `user_uuid` FROM `plot_helpers` WHERE `plot_plot_id` = " + id);
|
ResultSet r = stmt
|
||||||
|
.executeQuery("SELECT `user_uuid` FROM `plot_helpers` WHERE `plot_plot_id` = "
|
||||||
|
+ id);
|
||||||
UUID u;
|
UUID u;
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
u = UUID.fromString(r.getString("user_uuid"));
|
u = UUID.fromString(r.getString("user_uuid"));
|
||||||
@ -694,7 +810,8 @@ public class DBFunc {
|
|||||||
}
|
}
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.add(LogLevel.WARNING, "Failed to load helpers for plot: " + id);
|
Logger.add(LogLevel.WARNING, "Failed to load helpers for plot: "
|
||||||
|
+ id);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
@ -709,7 +826,9 @@ public class DBFunc {
|
|||||||
Statement stmt = null;
|
Statement stmt = null;
|
||||||
try {
|
try {
|
||||||
stmt = connection.createStatement();
|
stmt = connection.createStatement();
|
||||||
ResultSet r = stmt.executeQuery("SELECT `user_uuid` FROM `plot_trusted` WHERE `plot_plot_id` = " + id);
|
ResultSet r = stmt
|
||||||
|
.executeQuery("SELECT `user_uuid` FROM `plot_trusted` WHERE `plot_plot_id` = "
|
||||||
|
+ id);
|
||||||
UUID u;
|
UUID u;
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
u = UUID.fromString(r.getString("user_uuid"));
|
u = UUID.fromString(r.getString("user_uuid"));
|
||||||
@ -717,7 +836,8 @@ public class DBFunc {
|
|||||||
}
|
}
|
||||||
stmt.close();
|
stmt.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.add(LogLevel.WARNING, "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;
|
||||||
@ -727,19 +847,22 @@ public class DBFunc {
|
|||||||
* @param plot
|
* @param plot
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public static void removeHelper(final String world, final Plot plot, final OfflinePlayer player) {
|
public static void removeHelper(final String world, final Plot plot,
|
||||||
|
final OfflinePlayer player) {
|
||||||
runTask(new Runnable() {
|
runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
PreparedStatement statement = connection
|
||||||
|
.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
||||||
statement.setInt(1, getId(world, plot.id));
|
statement.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, "Failed to remove helper for plot " + plot.id);
|
Logger.add(LogLevel.WARNING,
|
||||||
|
"Failed to remove helper for plot " + plot.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -749,19 +872,22 @@ public class DBFunc {
|
|||||||
* @param plot
|
* @param plot
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public static void removeTrusted(final String world, final Plot plot, final OfflinePlayer player) {
|
public static void removeTrusted(final String world, final Plot plot,
|
||||||
|
final OfflinePlayer player) {
|
||||||
runTask(new Runnable() {
|
runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = connection.prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
PreparedStatement statement = connection
|
||||||
|
.prepareStatement("DELETE FROM `plot_trusted` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
||||||
statement.setInt(1, getId(world, plot.id));
|
statement.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, "Failed to remove trusted user for plot " + plot.id);
|
Logger.add(LogLevel.WARNING,
|
||||||
|
"Failed to remove trusted user for plot " + plot.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -771,18 +897,21 @@ public class DBFunc {
|
|||||||
* @param plot
|
* @param plot
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public static void setHelper(final String world, final Plot plot, final OfflinePlayer player) {
|
public static void setHelper(final String world, final Plot plot,
|
||||||
|
final OfflinePlayer player) {
|
||||||
runTask(new Runnable() {
|
runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
PreparedStatement statement = connection
|
||||||
|
.prepareStatement("INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
||||||
statement.setInt(1, getId(world, plot.id));
|
statement.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) {
|
||||||
Logger.add(LogLevel.WARNING, "Failed to set helper for plot " + plot.id);
|
Logger.add(LogLevel.WARNING,
|
||||||
|
"Failed to set helper for plot " + plot.id);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -793,18 +922,21 @@ public class DBFunc {
|
|||||||
* @param plot
|
* @param plot
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public static void setTrusted(final String world, final Plot plot, final OfflinePlayer player) {
|
public static void setTrusted(final String world, final Plot plot,
|
||||||
|
final OfflinePlayer player) {
|
||||||
runTask(new Runnable() {
|
runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO `plot_trusted` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
PreparedStatement statement = connection
|
||||||
|
.prepareStatement("INSERT INTO `plot_trusted` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
||||||
statement.setInt(1, getId(world, plot.id));
|
statement.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) {
|
||||||
Logger.add(LogLevel.WARNING, "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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -815,19 +947,22 @@ public class DBFunc {
|
|||||||
* @param plot
|
* @param plot
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public static void removeDenied(final String world, final Plot plot, final OfflinePlayer player) {
|
public static void removeDenied(final String world, final Plot plot,
|
||||||
|
final OfflinePlayer player) {
|
||||||
runTask(new Runnable() {
|
runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = connection.prepareStatement("DELETE FROM `plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
PreparedStatement statement = connection
|
||||||
|
.prepareStatement("DELETE FROM `plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
||||||
statement.setInt(1, getId(world, plot.id));
|
statement.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, "Failed to remove denied for plot " + plot.id);
|
Logger.add(LogLevel.WARNING,
|
||||||
|
"Failed to remove denied for plot " + plot.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -837,18 +972,21 @@ public class DBFunc {
|
|||||||
* @param plot
|
* @param plot
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public static void setDenied(final String world, final Plot plot, final OfflinePlayer player) {
|
public static void setDenied(final String world, final Plot plot,
|
||||||
|
final OfflinePlayer player) {
|
||||||
runTask(new Runnable() {
|
runTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO `plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
PreparedStatement statement = connection
|
||||||
|
.prepareStatement("INSERT INTO `plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
||||||
statement.setInt(1, getId(world, plot.id));
|
statement.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) {
|
||||||
Logger.add(LogLevel.WARNING, "Failed to set denied for plot " + plot.id);
|
Logger.add(LogLevel.WARNING,
|
||||||
|
"Failed to set denied for plot " + plot.id);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -857,7 +995,8 @@ public class DBFunc {
|
|||||||
|
|
||||||
public static double getRatings(final Plot plot) {
|
public static double getRatings(final Plot plot) {
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = connection.prepareStatement("SELECT AVG(`rating`) AS `rating` FROM `plot_ratings` WHERE `plot_plot_id` = ? ");
|
PreparedStatement statement = connection
|
||||||
|
.prepareStatement("SELECT AVG(`rating`) AS `rating` FROM `plot_ratings` WHERE `plot_plot_id` = ? ");
|
||||||
statement.setInt(1, getId(plot.getWorld().getName(), plot.id));
|
statement.setInt(1, getId(plot.getWorld().getName(), plot.id));
|
||||||
ResultSet set = statement.executeQuery();
|
ResultSet set = statement.executeQuery();
|
||||||
double rating = 0;
|
double rating = 0;
|
||||||
@ -867,7 +1006,8 @@ public class DBFunc {
|
|||||||
statement.close();
|
statement.close();
|
||||||
return rating;
|
return rating;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.add(LogLevel.WARNING, "Failed to fetch rating for plot " + 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;
|
||||||
|
@ -39,7 +39,8 @@ 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, ClassNotFoundException;
|
public abstract Connection openConnection() throws SQLException,
|
||||||
|
ClassNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a connection is open with the database
|
* Checks if a connection is open with the database
|
||||||
@ -79,7 +80,8 @@ 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, ClassNotFoundException;
|
public abstract ResultSet querySQL(String query) throws SQLException,
|
||||||
|
ClassNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes an Update SQL Query<br>
|
* Executes an Update SQL Query<br>
|
||||||
@ -94,5 +96,6 @@ 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, ClassNotFoundException;
|
public abstract int updateSQL(String query) throws SQLException,
|
||||||
|
ClassNotFoundException;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,8 @@ public class MySQL extends Database {
|
|||||||
* @param password
|
* @param password
|
||||||
* Password
|
* Password
|
||||||
*/
|
*/
|
||||||
public MySQL(Plugin plugin, String hostname, String port, String database, String username, String password) {
|
public MySQL(Plugin plugin, String hostname, String port, String database,
|
||||||
|
String username, String password) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.hostname = hostname;
|
this.hostname = hostname;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
@ -50,12 +51,15 @@ public class MySQL extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection openConnection() throws SQLException, ClassNotFoundException {
|
public Connection openConnection() throws SQLException,
|
||||||
|
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.hostname + ":" + this.port + "/" + this.database, this.user, this.password);
|
this.connection = DriverManager.getConnection("jdbc:mysql://"
|
||||||
|
+ this.hostname + ":" + this.port + "/" + this.database,
|
||||||
|
this.user, this.password);
|
||||||
return this.connection;
|
return this.connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +83,8 @@ public class MySQL extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet querySQL(String query) throws SQLException, ClassNotFoundException {
|
public ResultSet querySQL(String query) throws SQLException,
|
||||||
|
ClassNotFoundException {
|
||||||
if (checkConnection()) {
|
if (checkConnection()) {
|
||||||
openConnection();
|
openConnection();
|
||||||
}
|
}
|
||||||
@ -92,7 +97,8 @@ public class MySQL extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateSQL(String query) throws SQLException, ClassNotFoundException {
|
public int updateSQL(String query) throws SQLException,
|
||||||
|
ClassNotFoundException {
|
||||||
if (checkConnection()) {
|
if (checkConnection()) {
|
||||||
openConnection();
|
openConnection();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.intellectualcrafters.plot.database;
|
package com.intellectualcrafters.plot.database;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FilenameFilter;
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -35,7 +33,8 @@ public class PlotMeConverter {
|
|||||||
|
|
||||||
final PrintStream stream = new PrintStream("converter_log.txt");
|
final PrintStream stream = new PrintStream("converter_log.txt");
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(this.plugin,
|
||||||
|
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");
|
||||||
@ -43,11 +42,18 @@ public class PlotMeConverter {
|
|||||||
ArrayList<com.intellectualcrafters.plot.Plot> createdPlots = new ArrayList<com.intellectualcrafters.plot.Plot>();
|
ArrayList<com.intellectualcrafters.plot.Plot> createdPlots = 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.getPlots(world);
|
HashMap<String, Plot> plots = PlotManager
|
||||||
|
.getPlots(world);
|
||||||
if (plots != null) {
|
if (plots != null) {
|
||||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '" + plots.size() + "' plots for world '" + world.getName() + "'");
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '"
|
||||||
|
+ plots.size()
|
||||||
|
+ "' plots for world '"
|
||||||
|
+ world.getName() + "'");
|
||||||
|
|
||||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting " + plots.size() + " plots for '" + world.toString() + "'...");
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting "
|
||||||
|
+ plots.size()
|
||||||
|
+ " plots for '"
|
||||||
|
+ world.toString() + "'...");
|
||||||
for (Plot plot : plots.values()) {
|
for (Plot plot : plots.values()) {
|
||||||
ArrayList<UUID> psAdded = new ArrayList<>();
|
ArrayList<UUID> psAdded = new ArrayList<>();
|
||||||
ArrayList<UUID> psTrusted = new ArrayList<>();
|
ArrayList<UUID> psTrusted = new ArrayList<>();
|
||||||
@ -60,15 +66,28 @@ public class PlotMeConverter {
|
|||||||
if (online) {
|
if (online) {
|
||||||
PlayerList denied = null;
|
PlayerList denied = null;
|
||||||
PlayerList added = null;
|
PlayerList added = null;
|
||||||
Field fAdded = plot.getClass().getDeclaredField("allowed");
|
Field fAdded = plot
|
||||||
Field fDenied = plot.getClass().getDeclaredField("denied");
|
.getClass()
|
||||||
|
.getDeclaredField("allowed");
|
||||||
|
Field fDenied = plot.getClass()
|
||||||
|
.getDeclaredField("denied");
|
||||||
fAdded.setAccessible(true);
|
fAdded.setAccessible(true);
|
||||||
fDenied.setAccessible(true);
|
fDenied.setAccessible(true);
|
||||||
added = (PlayerList) fAdded.get(plot);
|
added = (PlayerList) fAdded
|
||||||
denied = (PlayerList) fDenied.get(plot);
|
.get(plot);
|
||||||
for (Map.Entry<String, UUID> set : added.getAllPlayers().entrySet()) {
|
denied = (PlayerList) fDenied
|
||||||
if ((set.getValue() != null) || set.getKey().equals("*")) {
|
.get(plot);
|
||||||
if (set.getKey().equalsIgnoreCase("*") || set.getValue().toString().equals("*")) {
|
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);
|
psAdded.add(DBFunc.everyone);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -77,9 +96,16 @@ public class PlotMeConverter {
|
|||||||
psAdded.add(set.getValue());
|
psAdded.add(set.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, UUID> set : denied.getAllPlayers().entrySet()) {
|
for (Map.Entry<String, UUID> set : denied
|
||||||
if ((set.getValue() != null) || set.getKey().equals("*")) {
|
.getAllPlayers().entrySet()) {
|
||||||
if (set.getKey().equals("*") || set.getValue().toString().equals("*")) {
|
if ((set.getValue() != null)
|
||||||
|
|| set.getKey().equals(
|
||||||
|
"*")) {
|
||||||
|
if (set.getKey()
|
||||||
|
.equals("*")
|
||||||
|
|| set.getValue()
|
||||||
|
.toString()
|
||||||
|
.equals("*")) {
|
||||||
psDenied.add(DBFunc.everyone);
|
psDenied.add(DBFunc.everyone);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -89,20 +115,26 @@ public class PlotMeConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (String user : plot.getAllowed().split(",")) {
|
for (String user : plot
|
||||||
|
.getAllowed().split(",")) {
|
||||||
if (user.equals("*")) {
|
if (user.equals("*")) {
|
||||||
psAdded.add(DBFunc.everyone);
|
psAdded.add(DBFunc.everyone);
|
||||||
} else {
|
} else {
|
||||||
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8));
|
UUID uuid = UUID
|
||||||
|
.nameUUIDFromBytes(("OfflinePlayer:" + user)
|
||||||
|
.getBytes(Charsets.UTF_8));
|
||||||
psAdded.add(uuid);
|
psAdded.add(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
for (String user : plot.getDenied().split(",")) {
|
for (String user : plot
|
||||||
|
.getDenied().split(",")) {
|
||||||
if (user.equals("*")) {
|
if (user.equals("*")) {
|
||||||
psDenied.add(DBFunc.everyone);
|
psDenied.add(DBFunc.everyone);
|
||||||
} else {
|
} else {
|
||||||
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8));
|
UUID uuid = UUID
|
||||||
|
.nameUUIDFromBytes(("OfflinePlayer:" + user)
|
||||||
|
.getBytes(Charsets.UTF_8));
|
||||||
psDenied.add(uuid);
|
psDenied.add(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,16 +149,37 @@ public class PlotMeConverter {
|
|||||||
eR3040bl230 = 232999304998392004l;
|
eR3040bl230 = 232999304998392004l;
|
||||||
}
|
}
|
||||||
stream.println(eR3040bl230);
|
stream.println(eR3040bl230);
|
||||||
PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1]));
|
PlotId id = new PlotId(
|
||||||
|
Integer.parseInt(plot.id.split(";")[0]),
|
||||||
|
Integer.parseInt(plot.id.split(";")[1]));
|
||||||
com.intellectualcrafters.plot.Plot pl = null;
|
com.intellectualcrafters.plot.Plot pl = null;
|
||||||
if (online) {
|
if (online) {
|
||||||
pl = new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false });
|
pl = new com.intellectualcrafters.plot.Plot(
|
||||||
|
id, plot.getOwnerId(), plot
|
||||||
|
.getBiome(), psAdded,
|
||||||
|
psTrusted, psDenied, false,
|
||||||
|
8000l, false, "",
|
||||||
|
PlotHomePosition.DEFAULT, null,
|
||||||
|
world.getName(), new boolean[] {
|
||||||
|
false, false, false,
|
||||||
|
false });
|
||||||
} else {
|
} else {
|
||||||
String owner = plot.getOwner();
|
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 });
|
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 });
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO createPlot doesn't add helpers / denied
|
// TODO createPlot doesn't add helpers /
|
||||||
|
// denied
|
||||||
// users
|
// users
|
||||||
if (pl != null) {
|
if (pl != null) {
|
||||||
createdPlots.add(pl);
|
createdPlots.add(pl);
|
||||||
@ -140,14 +193,19 @@ public class PlotMeConverter {
|
|||||||
DBFunc.createAllSettingsAndHelpers(createdPlots);
|
DBFunc.createAllSettingsAndHelpers(createdPlots);
|
||||||
stream.close();
|
stream.close();
|
||||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has finished");
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has finished");
|
||||||
// TODO disable PlotMe -> Unload all plot worlds, change the
|
// TODO disable PlotMe -> Unload all plot worlds, change
|
||||||
|
// the
|
||||||
// generator, restart the server automatically
|
// generator, restart the server automatically
|
||||||
// Possibly use multiverse / multiworld if it's to difficult
|
// Possibly use multiverse / multiworld if it's to
|
||||||
// modifying a world's generator while the server is running
|
// difficult
|
||||||
// Should really do that? Would seem pretty bad from our side +
|
// 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 wouldn't approve
|
||||||
|
|
||||||
Bukkit.getPluginManager().disablePlugin(PlotMeConverter.this.plugin);
|
Bukkit.getPluginManager().disablePlugin(
|
||||||
|
PlotMeConverter.this.plugin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,8 @@ public class SQLite extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection openConnection() throws SQLException, ClassNotFoundException {
|
public Connection openConnection() throws SQLException,
|
||||||
|
ClassNotFoundException {
|
||||||
if (checkConnection()) {
|
if (checkConnection()) {
|
||||||
return this.connection;
|
return this.connection;
|
||||||
}
|
}
|
||||||
@ -48,11 +49,14 @@ public class SQLite extends Database {
|
|||||||
try {
|
try {
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
this.plugin.getLogger().log(Level.SEVERE, "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.plugin.getDataFolder().toPath().toString() + "/" + this.dbLocation);
|
this.connection = DriverManager.getConnection("jdbc:sqlite:"
|
||||||
|
+ this.plugin.getDataFolder().toPath().toString() + "/"
|
||||||
|
+ this.dbLocation);
|
||||||
return this.connection;
|
return this.connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +80,8 @@ public class SQLite extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultSet querySQL(String query) throws SQLException, ClassNotFoundException {
|
public ResultSet querySQL(String query) throws SQLException,
|
||||||
|
ClassNotFoundException {
|
||||||
if (checkConnection()) {
|
if (checkConnection()) {
|
||||||
openConnection();
|
openConnection();
|
||||||
}
|
}
|
||||||
@ -89,7 +94,8 @@ public class SQLite extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateSQL(String query) throws SQLException, ClassNotFoundException {
|
public int updateSQL(String query) throws SQLException,
|
||||||
|
ClassNotFoundException {
|
||||||
if (checkConnection()) {
|
if (checkConnection()) {
|
||||||
openConnection();
|
openConnection();
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,8 @@ public class PlayerPlotDeniedEvent extends Event {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param added
|
* @param added
|
||||||
*/
|
*/
|
||||||
public PlayerPlotDeniedEvent(Player initiator, Plot plot, UUID player, boolean added) {
|
public PlayerPlotDeniedEvent(Player initiator, Plot plot, UUID player,
|
||||||
|
boolean added) {
|
||||||
this.initiator = initiator;
|
this.initiator = initiator;
|
||||||
this.plot = plot;
|
this.plot = plot;
|
||||||
this.added = added;
|
this.added = added;
|
||||||
|
@ -27,7 +27,8 @@ public class PlayerPlotHelperEvent extends Event {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param added
|
* @param added
|
||||||
*/
|
*/
|
||||||
public PlayerPlotHelperEvent(Player initiator, Plot plot, UUID player, boolean added) {
|
public PlayerPlotHelperEvent(Player initiator, Plot plot, UUID player,
|
||||||
|
boolean added) {
|
||||||
this.initiator = initiator;
|
this.initiator = initiator;
|
||||||
this.plot = plot;
|
this.plot = plot;
|
||||||
this.added = added;
|
this.added = added;
|
||||||
|
@ -27,7 +27,8 @@ public class PlayerPlotTrustedEvent extends Event {
|
|||||||
* @param player
|
* @param player
|
||||||
* @param added
|
* @param added
|
||||||
*/
|
*/
|
||||||
public PlayerPlotTrustedEvent(Player initiator, Plot plot, UUID player, boolean added) {
|
public PlayerPlotTrustedEvent(Player initiator, Plot plot, UUID player,
|
||||||
|
boolean added) {
|
||||||
this.initiator = initiator;
|
this.initiator = initiator;
|
||||||
this.plot = plot;
|
this.plot = plot;
|
||||||
this.added = added;
|
this.added = added;
|
||||||
|
@ -20,7 +20,8 @@ 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 Cancellable {
|
public class PlayerTeleportToPlotEvent extends PlayerEvent implements
|
||||||
|
Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Location from;
|
private Location from;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.intellectualcrafters.plot.generator;
|
package com.intellectualcrafters.plot.generator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -22,16 +23,15 @@ 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:
|
* For a simplified explanation of the math involved: - Get the current
|
||||||
* - Get the current coords
|
* coords - shift these numbers down to something relatable for a single
|
||||||
* - shift these numbers down to something relatable for a single plot
|
* plot (similar to reducing trigonometric functions down to the first
|
||||||
* (similar to reducing trigonometric functions down to the first quadrant)
|
* quadrant) - e.g. If the plot size is 20 blocks, and we are at x=25, it's
|
||||||
* - e.g. If the plot size is 20 blocks, and we are at x=25, it's equivalent to x=5 for that specific plot
|
* equivalent to x=5 for that specific plot
|
||||||
*
|
|
||||||
* From this, and knowing how thick the road is, we can say whether x=5 is road, or plot.
|
|
||||||
* The number of shifts done, is also counted, and this number gives us the PlotId
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
|
* 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) {
|
||||||
@ -81,7 +81,8 @@ public class DefaultPlotManager extends PlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some complex stuff for traversing mega plots (return getPlotIdAbs if you do not support mega plots)
|
* Some complex stuff for traversing mega plots (return getPlotIdAbs if you
|
||||||
|
* do not support mega plots)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PlotId getPlotId(PlotWorld plotworld, Location loc) {
|
public PlotId getPlotId(PlotWorld plotworld, Location loc) {
|
||||||
@ -122,7 +123,8 @@ 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, dpw.ROAD_WIDTH));
|
PlotId id = PlayerFunctions.getPlotAbs(loc.add(dpw.ROAD_WIDTH, 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;
|
||||||
@ -135,7 +137,8 @@ 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.add(0, 0, dpw.ROAD_WIDTH));
|
PlotId id = PlayerFunctions.getPlotAbs(loc
|
||||||
|
.add(0, 0, dpw.ROAD_WIDTH));
|
||||||
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -147,7 +150,8 @@ 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.add(dpw.ROAD_WIDTH, 0, 0));
|
PlotId id = PlayerFunctions.getPlotAbs(loc
|
||||||
|
.add(dpw.ROAD_WIDTH, 0, 0));
|
||||||
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
Plot plot = PlotMain.getPlots(loc.getWorld()).get(id);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -166,8 +170,9 @@ public class DefaultPlotManager extends PlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if a location is inside a specific plot(non-Javadoc)
|
* Check if a location is inside a specific plot(non-Javadoc) - For this
|
||||||
* - For this implementation, we don't need to do anything fancier than referring to getPlotIdAbs(...)
|
* implementation, we don't need to do anything fancier than referring to
|
||||||
|
* getPlotIdAbs(...)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isInPlotAbs(PlotWorld plotworld, Location loc, PlotId plotid) {
|
public boolean isInPlotAbs(PlotWorld plotworld, Location loc, PlotId plotid) {
|
||||||
@ -179,8 +184,7 @@ public class DefaultPlotManager extends PlotManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the bottom plot loc
|
* Get the bottom plot loc (some basic math)
|
||||||
* (some basic math)
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Location getPlotBottomLocAbs(PlotWorld plotworld, PlotId plotid) {
|
public Location getPlotBottomLocAbs(PlotWorld plotworld, PlotId plotid) {
|
||||||
@ -189,15 +193,16 @@ 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) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH)) - dpw.PLOT_WIDTH
|
||||||
int z = (pz * (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;
|
||||||
|
|
||||||
return new Location(Bukkit.getWorld(plotworld.worldname), x, 1, z);
|
return new Location(Bukkit.getWorld(plotworld.worldname), x, 1, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the top plot loc
|
* Get the top plot loc (some basic math)
|
||||||
* (some basic math)
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Location getPlotTopLocAbs(PlotWorld plotworld, PlotId plotid) {
|
public Location getPlotTopLocAbs(PlotWorld plotworld, PlotId plotid) {
|
||||||
@ -206,36 +211,58 @@ 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) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
int x = (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))
|
||||||
int z = (pz * (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;
|
||||||
|
|
||||||
return new Location(Bukkit.getWorld(plotworld.worldname), x, 256, z);
|
return new Location(Bukkit.getWorld(plotworld.worldname), x, 256, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Clearing the plot needs to only consider removing the blocks
|
* Clearing the plot needs to only consider removing the blocks - This
|
||||||
* - This implementation has used the SetCuboid function, as it is fast, and uses NMS code
|
* implementation has used the SetCuboid function, as it is fast, and uses
|
||||||
* - It also makes use of the fact that deleting chunks is a lot faster than block updates
|
* NMS code - It also makes use of the fact that deleting chunks is a lot
|
||||||
*
|
* faster than block updates
|
||||||
* This code is very messy, but you don't need to do something quite as complex unless you happen to have 512x512 sized plots
|
|
||||||
*
|
*
|
||||||
|
* This code is very messy, but you don't need to do something quite as
|
||||||
|
* complex unless you happen to have 512x512 sized plots
|
||||||
*/
|
*/
|
||||||
@Override
|
@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.getWorldSettings(world));
|
DefaultPlotWorld dpw = ((DefaultPlotWorld) PlotMain
|
||||||
|
.getWorldSettings(world));
|
||||||
|
|
||||||
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(
|
||||||
|
1, 0, 1);
|
||||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
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(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
PlotHelper.setSimpleCuboid(
|
||||||
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));
|
world,
|
||||||
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, pos1.getBlockX(), 0, pos1.getBlockZ()),
|
||||||
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);
|
new Location(world, pos2.getBlockX() + 1, 1, pos2
|
||||||
|
.getBlockZ() + 1), new PlotBlock((short) 7,
|
||||||
|
(byte) 0));
|
||||||
|
PlotHelper.setSimpleCuboid(
|
||||||
|
world,
|
||||||
|
new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1,
|
||||||
|
pos1.getBlockZ()),
|
||||||
|
new Location(world, pos2.getBlockX() + 1, world
|
||||||
|
.getMaxHeight() + 1, pos2.getBlockZ() + 1),
|
||||||
|
new PlotBlock((short) 0, (byte) 0));
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(),
|
||||||
|
1, pos1.getBlockZ()),
|
||||||
|
new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT,
|
||||||
|
pos2.getBlockZ() + 1), filling);
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(),
|
||||||
|
dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world,
|
||||||
|
pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1,
|
||||||
|
pos2.getBlockZ() + 1), plotfloor);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int startX = (pos1.getBlockX() / 16) * 16;
|
int startX = (pos1.getBlockX() / 16) * 16;
|
||||||
@ -252,41 +279,72 @@ 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, 0, j));
|
Plot plot1 = PlotHelper.getCurrentPlot(new Location(world, i,
|
||||||
if ((plot1 != null) && (plot1.getId() != plot.getId()) && plot1.hasOwner()) {
|
0, j));
|
||||||
|
if ((plot1 != null) && (plot1.getId() != plot.getId())
|
||||||
|
&& plot1.hasOwner()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Plot plot2 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j));
|
Plot plot2 = PlotHelper.getCurrentPlot(new Location(world,
|
||||||
if ((plot2 != null) && (plot2.getId() != plot.getId()) && plot2.hasOwner()) {
|
i + 15, 0, j));
|
||||||
|
if ((plot2 != null) && (plot2.getId() != plot.getId())
|
||||||
|
&& plot2.hasOwner()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Plot plot3 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
|
Plot plot3 = PlotHelper.getCurrentPlot(new Location(world,
|
||||||
if ((plot3 != null) && (plot3.getId() != plot.getId()) && plot3.hasOwner()) {
|
i + 15, 0, j + 15));
|
||||||
|
if ((plot3 != null) && (plot3.getId() != plot.getId())
|
||||||
|
&& plot3.hasOwner()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i, 0, j + 15));
|
Plot plot4 = PlotHelper.getCurrentPlot(new Location(world, i,
|
||||||
if ((plot4 != null) && (plot4.getId() != plot.getId()) && plot4.hasOwner()) {
|
0, j + 15));
|
||||||
|
if ((plot4 != null) && (plot4.getId() != plot.getId())
|
||||||
|
&& plot4.hasOwner()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Plot plot5 = PlotHelper.getCurrentPlot(new Location(world, i + 15, 0, j + 15));
|
Plot plot5 = PlotHelper.getCurrentPlot(new Location(world,
|
||||||
if ((plot5 != null) && (plot5.getId() != plot.getId()) && plot5.hasOwner()) {
|
i + 15, 0, j + 15));
|
||||||
|
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, Math.max(j - 1, plotMinZ));
|
min = new Location(world, Math.max(i - 1, plotMinX), 0,
|
||||||
max = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
|
Math.max(j - 1, plotMinZ));
|
||||||
} else if ((max.getBlockZ() < (j + 15)) || (max.getBlockX() < (i + 15))) {
|
max = new Location(world, Math.min(i + 16, plotMaxX), 0,
|
||||||
max = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
|
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(world, new Location(world, pos1.getBlockX(), 0, pos1.getBlockZ()), new Location(world, pos2.getBlockX() + 1, 1, pos2.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
PlotHelper.setSimpleCuboid(
|
||||||
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));
|
world,
|
||||||
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, pos1.getBlockX(), 0, pos1.getBlockZ()),
|
||||||
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);
|
new Location(world, pos2.getBlockX() + 1, 1, pos2
|
||||||
|
.getBlockZ() + 1), new PlotBlock((short) 7,
|
||||||
|
(byte) 0));
|
||||||
|
PlotHelper.setSimpleCuboid(
|
||||||
|
world,
|
||||||
|
new Location(world, pos1.getBlockX(), dpw.PLOT_HEIGHT + 1,
|
||||||
|
pos1.getBlockZ()),
|
||||||
|
new Location(world, pos2.getBlockX() + 1, world
|
||||||
|
.getMaxHeight() + 1, pos2.getBlockZ() + 1),
|
||||||
|
new PlotBlock((short) 0, (byte) 0));
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(),
|
||||||
|
1, pos1.getBlockZ()),
|
||||||
|
new Location(world, pos2.getBlockX() + 1, dpw.PLOT_HEIGHT,
|
||||||
|
pos2.getBlockZ() + 1), filling);
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, pos1.getBlockX(),
|
||||||
|
dpw.PLOT_HEIGHT, pos1.getBlockZ()), new Location(world,
|
||||||
|
pos2.getBlockX() + 1, dpw.PLOT_HEIGHT + 1,
|
||||||
|
pos2.getBlockZ() + 1), plotfloor);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (min.getBlockX() < plotMinX) {
|
if (min.getBlockX() < plotMinX) {
|
||||||
@ -302,45 +360,161 @@ public class DefaultPlotManager extends PlotManager {
|
|||||||
max.setZ(plotMaxZ);
|
max.setZ(plotMaxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 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));
|
plotMinZ),
|
||||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), filling);
|
new Location(world, min.getBlockX() + 1, 1,
|
||||||
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);
|
min.getBlockZ() + 1), new PlotBlock((short) 7,
|
||||||
|
(byte) 0));
|
||||||
|
PlotHelper
|
||||||
|
.setSimpleCuboid(
|
||||||
|
world,
|
||||||
|
new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1,
|
||||||
|
plotMinZ),
|
||||||
|
new Location(world, min.getBlockX() + 1, world
|
||||||
|
.getMaxHeight() + 1, min.getBlockZ() + 1),
|
||||||
|
new PlotBlock((short) 0, (byte) 0));
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, plotMinX, 1,
|
||||||
|
plotMinZ), new Location(world, min.getBlockX() + 1,
|
||||||
|
dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1), filling);
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, plotMinX,
|
||||||
|
dpw.PLOT_HEIGHT, plotMinZ),
|
||||||
|
new Location(world, min.getBlockX() + 1,
|
||||||
|
dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1),
|
||||||
|
plotfloor);
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, plotMinZ), new Location(world, max.getBlockX() + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
PlotHelper.setSimpleCuboid(world,
|
||||||
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, min.getBlockX(), 0, plotMinZ),
|
||||||
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, plotMinZ), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling);
|
new Location(world, max.getBlockX() + 1, 1,
|
||||||
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);
|
min.getBlockZ() + 1), new PlotBlock((short) 7,
|
||||||
|
(byte) 0));
|
||||||
|
PlotHelper.setSimpleCuboid(world,
|
||||||
|
new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1,
|
||||||
|
plotMinZ), new Location(world, max.getBlockX() + 1,
|
||||||
|
world.getMaxHeight() + 1, min.getBlockZ() + 1),
|
||||||
|
new PlotBlock((short) 0, (byte) 0));
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1,
|
||||||
|
plotMinZ), new Location(world, max.getBlockX() + 1,
|
||||||
|
dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling);
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(),
|
||||||
|
dpw.PLOT_HEIGHT, plotMinZ),
|
||||||
|
new Location(world, max.getBlockX() + 1,
|
||||||
|
dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1),
|
||||||
|
plotfloor);
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
PlotHelper.setSimpleCuboid(world,
|
||||||
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, max.getBlockX(), 0, plotMinZ),
|
||||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling);
|
new Location(world, plotMaxX + 1, 1, min.getBlockZ() + 1),
|
||||||
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);
|
new PlotBlock((short) 7, (byte) 0));
|
||||||
|
PlotHelper.setSimpleCuboid(world,
|
||||||
|
new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1,
|
||||||
|
plotMinZ),
|
||||||
|
new Location(world, plotMaxX + 1, world.getMaxHeight() + 1,
|
||||||
|
min.getBlockZ() + 1), new PlotBlock((short) 0,
|
||||||
|
(byte) 0));
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1,
|
||||||
|
plotMinZ), new Location(world, plotMaxX + 1,
|
||||||
|
dpw.PLOT_HEIGHT, min.getBlockZ() + 1), filling);
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(),
|
||||||
|
dpw.PLOT_HEIGHT, plotMinZ), new Location(world,
|
||||||
|
plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getBlockZ() + 1),
|
||||||
|
plotfloor);
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
PlotHelper
|
||||||
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));
|
.setSimpleCuboid(
|
||||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, min.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling);
|
world,
|
||||||
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, plotMinX, 0, min.getBlockZ()),
|
||||||
|
new Location(world, min.getBlockX() + 1, 1, max
|
||||||
|
.getBlockZ() + 1), new PlotBlock((short) 7,
|
||||||
|
(byte) 0));
|
||||||
|
PlotHelper.setSimpleCuboid(
|
||||||
|
world,
|
||||||
|
new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min
|
||||||
|
.getBlockZ()),
|
||||||
|
new Location(world, min.getBlockX() + 1, world
|
||||||
|
.getMaxHeight() + 1, max.getBlockZ() + 1),
|
||||||
|
new PlotBlock((short) 0, (byte) 0));
|
||||||
|
PlotHelper.setCuboid(world,
|
||||||
|
new Location(world, plotMinX, 1, min.getBlockZ()),
|
||||||
|
new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT,
|
||||||
|
max.getBlockZ() + 1), filling);
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, plotMinX,
|
||||||
|
dpw.PLOT_HEIGHT, min.getBlockZ()),
|
||||||
|
new Location(world, min.getBlockX() + 1,
|
||||||
|
dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1),
|
||||||
|
plotfloor);
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getBlockZ()), new Location(world, min.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0));
|
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, 0,
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, world.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
max.getBlockZ()), new Location(world, min.getBlockX() + 1,
|
||||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, 1, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0));
|
||||||
PlotHelper.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
PlotHelper.setSimpleCuboid(
|
||||||
|
world,
|
||||||
|
new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max
|
||||||
|
.getBlockZ()),
|
||||||
|
new Location(world, min.getBlockX() + 1, world
|
||||||
|
.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock(
|
||||||
|
(short) 0, (byte) 0));
|
||||||
|
PlotHelper.setCuboid(world,
|
||||||
|
new Location(world, plotMinX, 1, max.getBlockZ()),
|
||||||
|
new Location(world, min.getBlockX() + 1, dpw.PLOT_HEIGHT,
|
||||||
|
plotMaxZ + 1), filling);
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, plotMinX,
|
||||||
|
dpw.PLOT_HEIGHT, max.getBlockZ()),
|
||||||
|
new Location(world, min.getBlockX() + 1,
|
||||||
|
dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, min.getBlockX(), 0, max.getBlockZ()), new Location(world, max.getBlockX() + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0));
|
PlotHelper.setSimpleCuboid(world,
|
||||||
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, min.getBlockX(), 0, max.getBlockZ()),
|
||||||
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1, max.getBlockZ()), new Location(world, max.getBlockX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
new Location(world, max.getBlockX() + 1, 1, plotMaxZ + 1),
|
||||||
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);
|
new PlotBlock((short) 7, (byte) 0));
|
||||||
|
PlotHelper.setSimpleCuboid(
|
||||||
|
world,
|
||||||
|
new Location(world, min.getBlockX(), dpw.PLOT_HEIGHT + 1,
|
||||||
|
max.getBlockZ()),
|
||||||
|
new Location(world, max.getBlockX() + 1, world
|
||||||
|
.getMaxHeight() + 1, plotMaxZ + 1), new PlotBlock(
|
||||||
|
(short) 0, (byte) 0));
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(), 1,
|
||||||
|
max.getBlockZ()), new Location(world, max.getBlockX() + 1,
|
||||||
|
dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, min.getBlockX(),
|
||||||
|
dpw.PLOT_HEIGHT, max.getBlockZ()),
|
||||||
|
new Location(world, max.getBlockX() + 1,
|
||||||
|
dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, min.getBlockZ()), new Location(world, plotMaxX + 1, 1, max.getBlockZ() + 1), new PlotBlock((short) 7, (byte) 0));
|
PlotHelper.setSimpleCuboid(world,
|
||||||
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, max.getBlockX(), 0, min.getBlockZ()),
|
||||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, min.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling);
|
new Location(world, plotMaxX + 1, 1, max.getBlockZ() + 1),
|
||||||
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);
|
new PlotBlock((short) 7, (byte) 0));
|
||||||
|
PlotHelper.setSimpleCuboid(world,
|
||||||
|
new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1,
|
||||||
|
max.getBlockZ()), new Location(world, plotMaxX + 1,
|
||||||
|
world.getMaxHeight() + 1, plotMaxZ + 1),
|
||||||
|
new PlotBlock((short) 0, (byte) 0));
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1,
|
||||||
|
min.getBlockZ()), new Location(world, plotMaxX + 1,
|
||||||
|
dpw.PLOT_HEIGHT, max.getBlockZ() + 1), filling);
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(),
|
||||||
|
dpw.PLOT_HEIGHT, min.getBlockZ()), new Location(world,
|
||||||
|
plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getBlockZ() + 1),
|
||||||
|
plotfloor);
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(world, new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock((short) 7, (byte) 0));
|
PlotHelper.setSimpleCuboid(world,
|
||||||
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, max.getBlockX(), 0, max.getBlockZ()),
|
||||||
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1, max.getBlockZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
new Location(world, plotMaxX + 1, 1, plotMaxZ + 1),
|
||||||
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);
|
new PlotBlock((short) 7, (byte) 0));
|
||||||
|
PlotHelper.setSimpleCuboid(world,
|
||||||
|
new Location(world, max.getBlockX(), dpw.PLOT_HEIGHT + 1,
|
||||||
|
max.getBlockZ()), new Location(world, plotMaxX + 1,
|
||||||
|
world.getMaxHeight() + 1, plotMaxZ + 1),
|
||||||
|
new PlotBlock((short) 0, (byte) 0));
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, max.getBlockX(), 1,
|
||||||
|
max.getBlockZ()), new Location(world, plotMaxX + 1,
|
||||||
|
dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
||||||
|
PlotHelper
|
||||||
|
.setCuboid(world, new Location(world, max.getBlockX(),
|
||||||
|
dpw.PLOT_HEIGHT, max.getBlockZ()), new Location(
|
||||||
|
world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1,
|
||||||
|
plotMaxZ + 1), plotfloor);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -352,21 +526,25 @@ 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).getBlockX(), dpw.ROAD_HEIGHT + 1, PlotHelper.getPlotBottomLoc(world, plot.id).getBlockZ() - 1);
|
return new Location(world, PlotHelper.getPlotBottomLoc(world, plot.id)
|
||||||
|
.getBlockX(), dpw.ROAD_HEIGHT + 1, PlotHelper.getPlotBottomLoc(
|
||||||
|
world, plot.id).getBlockZ() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setFloor(Player player, PlotWorld plotworld, PlotId plotid, PlotBlock[] blocks) {
|
public boolean setFloor(Player player, PlotWorld plotworld, PlotId plotid,
|
||||||
|
PlotBlock[] blocks) {
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plotid).add(1, 0, 1);
|
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plotid).add(1,
|
||||||
|
0, 1);
|
||||||
final Location pos2 = PlotHelper.getPlotTopLoc(world, plotid);
|
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, PlotBlock plotblock) {
|
public boolean setWall(Player player, PlotWorld plotworld, PlotId plotid,
|
||||||
|
PlotBlock plotblock) {
|
||||||
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
|
DefaultPlotWorld dpw = (DefaultPlotWorld) plotworld;
|
||||||
World w = player.getWorld();
|
World w = player.getWorld();
|
||||||
|
|
||||||
@ -451,15 +629,30 @@ 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.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), new PlotBlock((short) 0, (byte) 0));
|
PlotHelper
|
||||||
|
.setSimpleCuboid(
|
||||||
|
w,
|
||||||
|
new Location(w, sx, Math.min(dpw.WALL_HEIGHT,
|
||||||
|
dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w,
|
||||||
|
ex + 1, 257 + 1, ez), new PlotBlock((short) 0,
|
||||||
|
(byte) 0));
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
|
PlotHelper.setSimpleCuboid(w, new Location(w, sx, 1, sz + 1),
|
||||||
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);
|
new Location(w, sx + 1, dpw.WALL_HEIGHT + 1, ez),
|
||||||
|
dpw.WALL_FILLING);
|
||||||
|
PlotHelper.setSimpleCuboid(w, new Location(w, sx, dpw.WALL_HEIGHT + 1,
|
||||||
|
sz + 1), new Location(w, sx + 1, dpw.WALL_HEIGHT + 2, ez),
|
||||||
|
dpw.WALL_BLOCK);
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_FILLING);
|
PlotHelper.setSimpleCuboid(w, new Location(w, ex, 1, sz + 1),
|
||||||
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);
|
new Location(w, ex + 1, dpw.WALL_HEIGHT + 1, ez),
|
||||||
|
dpw.WALL_FILLING);
|
||||||
|
PlotHelper.setSimpleCuboid(w, new Location(w, ex, dpw.WALL_HEIGHT + 1,
|
||||||
|
sz + 1), new Location(w, ex + 1, dpw.WALL_HEIGHT + 2, ez),
|
||||||
|
dpw.WALL_BLOCK);
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
|
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1),
|
||||||
|
new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -477,15 +670,30 @@ 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.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0));
|
PlotHelper
|
||||||
|
.setSimpleCuboid(
|
||||||
|
w,
|
||||||
|
new Location(w, sx, Math.min(dpw.WALL_HEIGHT,
|
||||||
|
dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(w,
|
||||||
|
ex + 1, 257, ez), new PlotBlock((short) 0,
|
||||||
|
(byte) 0));
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING);
|
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz),
|
||||||
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);
|
new Location(w, ex, dpw.WALL_HEIGHT + 1, sz + 1),
|
||||||
|
dpw.WALL_FILLING);
|
||||||
|
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1,
|
||||||
|
dpw.WALL_HEIGHT + 1, sz), new Location(w, ex,
|
||||||
|
dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK);
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1), dpw.WALL_FILLING);
|
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, ez),
|
||||||
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);
|
new Location(w, ex, dpw.WALL_HEIGHT + 1, ez + 1),
|
||||||
|
dpw.WALL_FILLING);
|
||||||
|
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1,
|
||||||
|
dpw.WALL_HEIGHT + 1, ez), new Location(w, ex,
|
||||||
|
dpw.WALL_HEIGHT + 2, ez + 1), dpw.WALL_BLOCK);
|
||||||
|
|
||||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
|
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1),
|
||||||
|
new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -502,8 +710,11 @@ 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, sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0));
|
PlotHelper.setSimpleCuboid(w, new Location(w, sx, dpw.ROAD_HEIGHT + 1,
|
||||||
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
|
sz + 1), new Location(w, ex + 1, 257, ez), new PlotBlock(
|
||||||
|
(short) 0, (byte) 0));
|
||||||
|
PlotHelper.setSimpleCuboid(w, new Location(w, sx + 1, 1, sz + 1),
|
||||||
|
new Location(w, ex, dpw.ROAD_HEIGHT + 1, ez), dpw.ROAD_BLOCK);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -521,9 +732,16 @@ 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.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0));
|
PlotHelper.setSimpleCuboid(w,
|
||||||
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
|
new Location(w, sx,
|
||||||
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);
|
Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
|
||||||
|
new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0,
|
||||||
|
(byte) 0));
|
||||||
|
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w,
|
||||||
|
ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
|
||||||
|
PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz),
|
||||||
|
new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1),
|
||||||
|
dpw.TOP_BLOCK);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -541,9 +759,16 @@ 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.setSimpleCuboid(w, new Location(w, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0));
|
PlotHelper.setSimpleCuboid(w,
|
||||||
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w, ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
|
new Location(w, sx,
|
||||||
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);
|
Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
|
||||||
|
new Location(w, ex + 1, 257, ez + 1), new PlotBlock((short) 0,
|
||||||
|
(byte) 0));
|
||||||
|
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz), new Location(w,
|
||||||
|
ex + 1, dpw.PLOT_HEIGHT, ez + 1), dpw.MAIN_BLOCK);
|
||||||
|
PlotHelper.setCuboid(w, new Location(w, sx, dpw.PLOT_HEIGHT, sz),
|
||||||
|
new Location(w, ex + 1, dpw.PLOT_HEIGHT + 1, ez + 1),
|
||||||
|
dpw.TOP_BLOCK);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -560,10 +785,15 @@ 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, dpw.ROAD_HEIGHT + 1, sz), new Location(world, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0));
|
PlotHelper.setSimpleCuboid(world, new Location(world, sx,
|
||||||
|
dpw.ROAD_HEIGHT + 1, sz), new Location(world, ex + 1, 257,
|
||||||
|
ez + 1), new PlotBlock((short) 0, (byte) 0));
|
||||||
|
|
||||||
PlotHelper.setCuboid(world, new Location(world, sx + 1, 1, sz + 1), new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK);
|
PlotHelper.setCuboid(world, new Location(world, sx + 1, 1, sz + 1),
|
||||||
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);
|
new Location(world, ex, dpw.ROAD_HEIGHT, ez), dpw.MAIN_BLOCK);
|
||||||
|
PlotHelper.setCuboid(world, new Location(world, sx + 1,
|
||||||
|
dpw.ROAD_HEIGHT, sz + 1), new Location(world, ex,
|
||||||
|
dpw.ROAD_HEIGHT + 1, ez), dpw.TOP_BLOCK);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,7 +802,8 @@ public class DefaultPlotManager extends PlotManager {
|
|||||||
* (OPTIONAL)(UNFINISHED)
|
* (OPTIONAL)(UNFINISHED)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean finishPlotMerge(World world, PlotWorld plotworld, ArrayList<PlotId> plotIds) {
|
public boolean finishPlotMerge(World world, PlotWorld plotworld,
|
||||||
|
ArrayList<PlotId> plotIds) {
|
||||||
|
|
||||||
// TODO set plot wall
|
// TODO set plot wall
|
||||||
|
|
||||||
@ -584,11 +815,16 @@ 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, 1);
|
Location megaPlotTop = PlotHelper.getPlotTopLoc(world, pos2).add(1, 0,
|
||||||
|
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()) || (z == megaPlotTop.getBlockZ()) || (x == megaPlotBot.getBlockX()) || (x == megaPlotTop.getBlockX())) {
|
if ((z == megaPlotBot.getBlockZ())
|
||||||
world.getBlockAt(x, dpw.WALL_HEIGHT + 1, z).setTypeIdAndData(block.id, block.data, false);
|
|| (z == megaPlotTop.getBlockZ())
|
||||||
|
|| (x == megaPlotBot.getBlockX())
|
||||||
|
|| (x == megaPlotTop.getBlockX())) {
|
||||||
|
world.getBlockAt(x, dpw.WALL_HEIGHT + 1, z)
|
||||||
|
.setTypeIdAndData(block.id, block.data, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,11 @@ import com.intellectualcrafters.plot.PlotWorld;
|
|||||||
public class DefaultPlotWorld extends PlotWorld {
|
public class DefaultPlotWorld extends PlotWorld {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These variables are set to ensure fast access to config settings
|
* These variables are set to ensure fast access to config settings Strings
|
||||||
* Strings are used as little as possible to optimize math performance in many of the functions/algorithms
|
* are used as little as possible to optimize math performance in many of
|
||||||
*
|
* the functions/algorithms
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Road Height
|
* Road Height
|
||||||
*/
|
*/
|
||||||
@ -69,7 +68,8 @@ public class DefaultPlotWorld extends PlotWorld {
|
|||||||
/**
|
/**
|
||||||
* Default main block: 1
|
* Default main block: 1
|
||||||
*/
|
*/
|
||||||
public static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 1, (byte) 0) };
|
public static PlotBlock[] MAIN_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock(
|
||||||
|
(short) 1, (byte) 0) };
|
||||||
/**
|
/**
|
||||||
* Top blocks
|
* Top blocks
|
||||||
*/
|
*/
|
||||||
@ -77,7 +77,8 @@ public class DefaultPlotWorld extends PlotWorld {
|
|||||||
/**
|
/**
|
||||||
* Default top blocks: {"2"}
|
* Default top blocks: {"2"}
|
||||||
*/
|
*/
|
||||||
public static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock((short) 2, (byte) 0) };
|
public static PlotBlock[] TOP_BLOCK_DEFAULT = new PlotBlock[] { new PlotBlock(
|
||||||
|
(short) 2, (byte) 0) };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wall block
|
* Wall block
|
||||||
@ -95,7 +96,8 @@ public class DefaultPlotWorld extends PlotWorld {
|
|||||||
/**
|
/**
|
||||||
* Default wall filling: 1
|
* Default wall filling: 1
|
||||||
*/
|
*/
|
||||||
public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1, (byte) 0);
|
public static PlotBlock WALL_FILLING_DEFAULT = new PlotBlock((short) 1,
|
||||||
|
(byte) 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Road stripes
|
* Road stripes
|
||||||
@ -104,7 +106,8 @@ public class DefaultPlotWorld extends PlotWorld {
|
|||||||
/**
|
/**
|
||||||
* Default road stripes: 35
|
* Default road stripes: 35
|
||||||
*/
|
*/
|
||||||
public static PlotBlock ROAD_STRIPES_DEFAULT = new PlotBlock((short) 98, (byte) 0);
|
public static PlotBlock ROAD_STRIPES_DEFAULT = new PlotBlock((short) 98,
|
||||||
|
(byte) 0);
|
||||||
/**
|
/**
|
||||||
* enable road stripes
|
* enable road stripes
|
||||||
*/
|
*/
|
||||||
@ -117,8 +120,8 @@ public class DefaultPlotWorld extends PlotWorld {
|
|||||||
/**
|
/**
|
||||||
* Default road block: 155
|
* Default road block: 155
|
||||||
*/
|
*/
|
||||||
public static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155, (byte) 0);
|
public static PlotBlock ROAD_BLOCK_DEFAULT = new PlotBlock((short) 155,
|
||||||
|
(byte) 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here we are just calling the super method, nothing special
|
* Here we are just calling the super method, nothing special
|
||||||
@ -128,52 +131,73 @@ public class DefaultPlotWorld extends PlotWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED FOR INITIAL SETUP
|
* CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED
|
||||||
*
|
* FOR INITIAL SETUP
|
||||||
* Set the last boolean to false if you do not require a specific config node to be set while using the setup command
|
|
||||||
* - this may be useful if a config value can be changed at a later date, and has no impact on the actual world generation
|
|
||||||
*
|
*
|
||||||
|
* Set the last boolean to false if you do not require a specific config
|
||||||
|
* node to be set while using the setup command - this may be useful if a
|
||||||
|
* config value can be changed at a later date, and has no impact on the
|
||||||
|
* actual world generation
|
||||||
*/
|
*/
|
||||||
@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
|
return new ConfigurationNode[] {
|
||||||
new ConfigurationNode[] {
|
new ConfigurationNode("plot.height", this.PLOT_HEIGHT,
|
||||||
new ConfigurationNode("plot.height", PLOT_HEIGHT, "Plot height", Configuration.INTEGER, true),
|
"Plot height", Configuration.INTEGER, true),
|
||||||
new ConfigurationNode("plot.width", PLOT_WIDTH, "Plot width", Configuration.INTEGER, true),
|
new ConfigurationNode("plot.width", this.PLOT_WIDTH,
|
||||||
new ConfigurationNode("plot.filling", MAIN_BLOCK, "Plot block", Configuration.BLOCKLIST, true),
|
"Plot width", Configuration.INTEGER, true),
|
||||||
new ConfigurationNode("plot.floor", TOP_BLOCK, "Plot floor block", Configuration.BLOCKLIST, true),
|
new ConfigurationNode("plot.filling", this.MAIN_BLOCK,
|
||||||
new ConfigurationNode("wall.block", WALL_BLOCK, "Top wall block", Configuration.BLOCK, true),
|
"Plot block", Configuration.BLOCKLIST, true),
|
||||||
new ConfigurationNode("road.width", ROAD_WIDTH, "Road width", Configuration.INTEGER, true),
|
new ConfigurationNode("plot.floor", this.TOP_BLOCK,
|
||||||
new ConfigurationNode("road.height", ROAD_HEIGHT, "Road height", Configuration.INTEGER, true),
|
"Plot floor block", Configuration.BLOCKLIST, true),
|
||||||
new ConfigurationNode("road.enable_stripes", ROAD_STRIPES_ENABLED, "Enable road stripes", Configuration.BOOLEAN, true),
|
new ConfigurationNode("wall.block", this.WALL_BLOCK,
|
||||||
new ConfigurationNode("road.block", ROAD_BLOCK, "Road block", Configuration.BLOCK, true),
|
"Top wall block", Configuration.BLOCK, true),
|
||||||
new ConfigurationNode("road.stripes", ROAD_STRIPES, "Road stripe block", Configuration.BLOCK, true),
|
new ConfigurationNode("road.width", this.ROAD_WIDTH,
|
||||||
new ConfigurationNode("wall.filling", WALL_FILLING, "Wall filling block", Configuration.BLOCK, true),
|
"Road width", Configuration.INTEGER, true),
|
||||||
new ConfigurationNode("wall.height", WALL_HEIGHT, "Wall height", Configuration.INTEGER, true),
|
new ConfigurationNode("road.height", this.ROAD_HEIGHT,
|
||||||
};
|
"Road height", Configuration.INTEGER, true),
|
||||||
|
new ConfigurationNode("road.enable_stripes",
|
||||||
|
this.ROAD_STRIPES_ENABLED, "Enable road stripes",
|
||||||
|
Configuration.BOOLEAN, true),
|
||||||
|
new ConfigurationNode("road.block", this.ROAD_BLOCK,
|
||||||
|
"Road block", Configuration.BLOCK, true),
|
||||||
|
new ConfigurationNode("road.stripes", this.ROAD_STRIPES,
|
||||||
|
"Road stripe block", Configuration.BLOCK, true),
|
||||||
|
new ConfigurationNode("wall.filling", this.WALL_FILLING,
|
||||||
|
"Wall filling block", Configuration.BLOCK, true),
|
||||||
|
new ConfigurationNode("wall.height", this.WALL_HEIGHT,
|
||||||
|
"Wall height", Configuration.INTEGER, true), };
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This method is called when a world loads. Make sure you set all your constants here.
|
* This method is called when a world loads. Make sure you set all your
|
||||||
* You are provided with the configuration section for that specific world.
|
* constants here. You are provided with the configuration section for that
|
||||||
|
* specific world.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
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.parseString(StringUtils.join(config.getStringList("plot.filling"),','));
|
this.MAIN_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST
|
||||||
this.TOP_BLOCK = (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.filling"), ','));
|
||||||
|
this.TOP_BLOCK = (PlotBlock[]) Configuration.BLOCKLIST
|
||||||
|
.parseString(StringUtils.join(
|
||||||
|
config.getStringList("plot.floor"), ','));
|
||||||
|
this.WALL_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config
|
||||||
|
.getString("wall.block"));
|
||||||
this.ROAD_WIDTH = config.getInt("road.width");
|
this.ROAD_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.getString("road.block"));
|
this.ROAD_BLOCK = (PlotBlock) Configuration.BLOCK.parseString(config
|
||||||
this.ROAD_STRIPES = (PlotBlock) Configuration.BLOCK.parseString(config.getString("road.stripes"));
|
.getString("road.block"));
|
||||||
this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config.getString("wall.filling"));
|
this.ROAD_STRIPES = (PlotBlock) Configuration.BLOCK.parseString(config
|
||||||
|
.getString("road.stripes"));
|
||||||
|
this.WALL_FILLING = (PlotBlock) Configuration.BLOCK.parseString(config
|
||||||
|
.getString("wall.filling"));
|
||||||
this.WALL_HEIGHT = config.getInt("wall.height");
|
this.WALL_HEIGHT = config.getInt("wall.height");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -8,7 +8,6 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotBlock;
|
import com.intellectualcrafters.plot.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.PlotGenerator;
|
import com.intellectualcrafters.plot.PlotGenerator;
|
||||||
@ -20,9 +19,11 @@ 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.
|
* The default generator is very messy, as we have decided to try
|
||||||
* - You will see a lot of slower implementations have a single for loop.
|
* externalize all calculations from within the loop. - You will see a
|
||||||
* - This is perfectly fine to do, it will just mean world generation may take somewhat longer
|
* lot of slower implementations have a single for loop. - This is
|
||||||
|
* perfectly fine to do, it will just mean world generation may take
|
||||||
|
* somewhat longer
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class WorldGenerator extends PlotGenerator {
|
public class WorldGenerator extends PlotGenerator {
|
||||||
@ -59,7 +60,6 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the plot manager for this type of generator, or create one
|
* Return the plot manager for this type of generator, or create one
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PlotManager getPlotManager() {
|
public PlotManager getPlotManager() {
|
||||||
@ -80,6 +80,7 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
* Faster sudo-random number generator than java.util.random
|
* Faster sudo-random number generator than java.util.random
|
||||||
*/
|
*/
|
||||||
private long state;
|
private long state;
|
||||||
|
|
||||||
public final long nextLong() {
|
public final long nextLong() {
|
||||||
long a = this.state;
|
long a = this.state;
|
||||||
this.state = xorShift64(a);
|
this.state = xorShift64(a);
|
||||||
@ -99,10 +100,12 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cuboid based plot generation is quick, as it requires no calculations inside the loop
|
* Cuboid based plot generation is quick, as it requires no calculations
|
||||||
* - You don't have to use this this method, but you may find it useful.
|
* inside the loop - You don't have to use this this method, but you may
|
||||||
|
* find it useful.
|
||||||
*/
|
*/
|
||||||
public void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock block) {
|
public void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2,
|
||||||
|
PlotBlock block) {
|
||||||
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++) {
|
||||||
@ -112,7 +115,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 {
|
||||||
@ -143,23 +147,23 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
public WorldGenerator(String world) {
|
public WorldGenerator(String world) {
|
||||||
this.plotworld = new DefaultPlotWorld(world);
|
this.plotworld = new DefaultPlotWorld(world);
|
||||||
|
|
||||||
plotsize = plotworld.PLOT_WIDTH;
|
this.plotsize = this.plotworld.PLOT_WIDTH;
|
||||||
pathsize = plotworld.ROAD_WIDTH;
|
this.pathsize = this.plotworld.ROAD_WIDTH;
|
||||||
|
|
||||||
floor1 = plotworld.ROAD_BLOCK;
|
this.floor1 = this.plotworld.ROAD_BLOCK;
|
||||||
floor2 = plotworld.ROAD_STRIPES;
|
this.floor2 = this.plotworld.ROAD_STRIPES;
|
||||||
|
|
||||||
wallfilling = plotworld.WALL_FILLING;
|
this.wallfilling = this.plotworld.WALL_FILLING;
|
||||||
size = pathsize + plotsize;
|
this.size = this.pathsize + this.plotsize;
|
||||||
wall = plotworld.WALL_BLOCK;
|
this.wall = this.plotworld.WALL_BLOCK;
|
||||||
|
|
||||||
plotfloors = plotworld.TOP_BLOCK;
|
this.plotfloors = this.plotworld.TOP_BLOCK;
|
||||||
filling = plotworld.MAIN_BLOCK;
|
this.filling = this.plotworld.MAIN_BLOCK;
|
||||||
wallheight = plotworld.WALL_HEIGHT;
|
this.wallheight = this.plotworld.WALL_HEIGHT;
|
||||||
roadheight = plotworld.ROAD_HEIGHT;
|
this.roadheight = this.plotworld.ROAD_HEIGHT;
|
||||||
plotheight = plotworld.PLOT_HEIGHT;
|
this.plotheight = this.plotworld.PLOT_HEIGHT;
|
||||||
|
|
||||||
biome = plotworld.PLOT_BIOME;
|
this.biome = this.plotworld.PLOT_BIOME;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -175,8 +179,9 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
world.setMonsterSpawnLimit(0);
|
world.setMonsterSpawnLimit(0);
|
||||||
world.setWaterAnimalSpawnLimit(0);
|
world.setWaterAnimalSpawnLimit(0);
|
||||||
}
|
}
|
||||||
// You can have as many populators as you would like, e.g. tree populator, ore populator
|
// You can have as many populators as you would like, e.g. tree
|
||||||
return Arrays.asList((BlockPopulator) new XPopulator(plotworld));
|
// populator, ore populator
|
||||||
|
return Arrays.asList((BlockPopulator) new XPopulator(this.plotworld));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -184,15 +189,16 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Location getFixedSpawnLocation(World world, Random random) {
|
public Location getFixedSpawnLocation(World world, Random random) {
|
||||||
return new Location(world, 0, plotworld.ROAD_HEIGHT + 2, 0);
|
return new Location(world, 0, this.plotworld.ROAD_HEIGHT + 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This part is a fucking mess.
|
* This part is a fucking mess. - Refer to a proper tutorial if you would
|
||||||
* - Refer to a proper tutorial if you would like to learn how to make a world generator
|
* like to learn how to make a world generator
|
||||||
*/
|
*/
|
||||||
@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) {
|
||||||
|
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int h = 1;
|
int h = 1;
|
||||||
@ -235,26 +241,35 @@ 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) && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) && !((roadStartX < 16) && (roadStartZ < 16)) && (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) {
|
if ((this.pathsize > 16)
|
||||||
|
&& ((plotMinX > roadStartX) || (plotMinZ > roadStartZ))
|
||||||
|
&& !((roadStartX < 16) && (roadStartZ < 16))
|
||||||
|
&& (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) {
|
||||||
setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1);
|
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, (16 - roadStartZ) + 1);
|
int start = Math.max((16 - plotMinZ - this.pathsize) + 1,
|
||||||
int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) + this.pathsize);
|
(16 - roadStartZ) + 1);
|
||||||
|
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), Math.min(16, end), this.floor1);
|
setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0),
|
||||||
|
Math.min(16, end), this.floor1);
|
||||||
}
|
}
|
||||||
if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) {
|
if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) {
|
||||||
int start = Math.max((16 - plotMinX - this.pathsize) + 1, (16 - roadStartX) + 1);
|
int start = Math.max((16 - plotMinX - this.pathsize) + 1,
|
||||||
int end = Math.min(16 - plotMinX - 1, (16 - roadStartX) + this.pathsize);
|
(16 - roadStartX) + 1);
|
||||||
|
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, this.roadheight + 1, 0, 16, this.floor1);
|
setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1,
|
||||||
|
this.roadheight + 1, 0, 16, this.floor1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ROAD STRIPES
|
// ROAD STRIPES
|
||||||
@ -275,8 +290,11 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
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, 16 - value, (16 - value) + 1, this.floor2); //
|
setCuboidRegion(0, end, this.wallheight, this.wallheight + 1,
|
||||||
setCuboidRegion(start, 16, 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); //
|
||||||
}
|
}
|
||||||
if ((plotMinX + 2) <= 16) {
|
if ((plotMinX + 2) <= 16) {
|
||||||
int value = (plotMinX + 2);
|
int value = (plotMinX + 2);
|
||||||
@ -294,8 +312,10 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
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, this.wallheight + 1, 0, end, this.floor2); //
|
setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight,
|
||||||
setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight, this.wallheight + 1, start, 16, this.floor2); //
|
this.wallheight + 1, 0, end, this.floor2); //
|
||||||
|
setCuboidRegion(16 - value, (16 - value) + 1, this.wallheight,
|
||||||
|
this.wallheight + 1, start, 16, this.floor2); //
|
||||||
}
|
}
|
||||||
if ((roadStartZ <= 16) && (roadStartZ > 1)) {
|
if ((roadStartZ <= 16) && (roadStartZ > 1)) {
|
||||||
int val = roadStartZ;
|
int val = roadStartZ;
|
||||||
@ -313,8 +333,11 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
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, (16 - val) + 1, (16 - val) + 2, this.floor2);
|
setCuboidRegion(0, end, this.wallheight, this.wallheight + 1,
|
||||||
setCuboidRegion(start, 16, 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);
|
||||||
}
|
}
|
||||||
if ((roadStartX <= 16) && (roadStartX > 1)) {
|
if ((roadStartX <= 16) && (roadStartX > 1)) {
|
||||||
int val = roadStartX;
|
int val = roadStartX;
|
||||||
@ -332,8 +355,12 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
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, this.wallheight, this.wallheight + 1, 0, end, this.floor2); //
|
setCuboidRegion((16 - val) + 1, (16 - val) + 2,
|
||||||
setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.wallheight, this.wallheight + 1, start, 16, this.floor2); //
|
this.wallheight, this.wallheight + 1, 0, end,
|
||||||
|
this.floor2); //
|
||||||
|
setCuboidRegion((16 - val) + 1, (16 - val) + 2,
|
||||||
|
this.wallheight, this.wallheight + 1, start, 16,
|
||||||
|
this.floor2); //
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,36 +368,53 @@ 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, 16 - roadStartZ, this.filling);
|
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0,
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
|
16 - roadStartZ, this.filling);
|
||||||
|
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, 16 - plotMinZ, 16, this.filling);
|
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight,
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
|
16 - plotMinZ, 16, this.filling);
|
||||||
|
setCuboidRegion(0, 16 - roadStartX, this.plotheight,
|
||||||
|
this.plotheight + 1, 16 - plotMinZ, 16,
|
||||||
|
this.plotfloors);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (roadStartZ <= 16) {
|
if (roadStartZ <= 16) {
|
||||||
if (plotMinX > 16) {
|
if (plotMinX > 16) {
|
||||||
setCuboidRegion(0, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
|
setCuboidRegion(0, 16, 1, this.plotheight, 0,
|
||||||
setCuboidRegion(0, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
|
16 - roadStartZ, this.filling);
|
||||||
|
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, 16 - plotMinZ, 16, this.filling);
|
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight,
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
|
16 - plotMinZ, 16, this.filling);
|
||||||
|
setCuboidRegion(16 - plotMinX, 16, this.plotheight,
|
||||||
|
this.plotheight + 1, 16 - plotMinZ, 16,
|
||||||
|
this.plotfloors);
|
||||||
} else {
|
} 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, z, this.filling);
|
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0,
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors);
|
z, this.filling);
|
||||||
|
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, 16 - roadStartZ, this.filling);
|
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0,
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
|
16 - roadStartZ, this.filling);
|
||||||
|
setCuboidRegion(16 - plotMinX, 16, this.plotheight,
|
||||||
|
this.plotheight + 1, 0, 16 - roadStartZ,
|
||||||
|
this.plotfloors);
|
||||||
} else {
|
} else {
|
||||||
if (roadStartX <= 16) {
|
if (roadStartX <= 16) {
|
||||||
if (plotMinZ > 16) {
|
if (plotMinZ > 16) {
|
||||||
@ -378,8 +422,10 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
x = 16;
|
x = 16;
|
||||||
}
|
}
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 0, 16, this.filling);
|
setCuboidRegion(0, x, 1, this.plotheight, 0, 16,
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, 16, this.plotfloors);
|
this.filling);
|
||||||
|
setCuboidRegion(0, x, this.plotheight,
|
||||||
|
this.plotheight + 1, 0, 16, this.plotfloors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,8 +436,11 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
x = 16;
|
x = 16;
|
||||||
}
|
}
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 16 - plotMinZ, 16, this.filling);
|
setCuboidRegion(0, x, 1, this.plotheight,
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
|
16 - plotMinZ, 16, this.filling);
|
||||||
|
setCuboidRegion(0, x, this.plotheight,
|
||||||
|
this.plotheight + 1, 16 - plotMinZ, 16,
|
||||||
|
this.plotfloors);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (roadStartZ > 16) {
|
if (roadStartZ > 16) {
|
||||||
@ -404,11 +453,15 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
z = 16;
|
z = 16;
|
||||||
}
|
}
|
||||||
if (roadStartX > 16) {
|
if (roadStartX > 16) {
|
||||||
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 {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -416,22 +469,34 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
} else {
|
} else {
|
||||||
if (roadStartX <= 16) {
|
if (roadStartX <= 16) {
|
||||||
if (roadStartZ <= 16) {
|
if (roadStartZ <= 16) {
|
||||||
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling);
|
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0,
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
|
16 - roadStartZ, this.filling);
|
||||||
|
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, 16 - plotMinZ, 16, this.filling);
|
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight,
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
|
16 - plotMinZ, 16, this.filling);
|
||||||
|
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, 16 - plotMinZ, 16, this.filling);
|
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight,
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors);
|
16 - plotMinZ, 16, this.filling);
|
||||||
|
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, 16 - roadStartZ, this.filling);
|
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0,
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors);
|
16 - roadStartZ, this.filling);
|
||||||
|
setCuboidRegion(16 - plotMinX, 16, this.plotheight,
|
||||||
|
this.plotheight + 1, 0, 16 - roadStartZ,
|
||||||
|
this.plotfloors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -453,10 +518,16 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
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, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling);
|
setCuboidRegion(0, end, 1, this.wallheight + 1,
|
||||||
setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall);
|
16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling);
|
||||||
setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling);
|
setCuboidRegion(0, end, this.wallheight + 1,
|
||||||
setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall);
|
this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ,
|
||||||
|
this.wall);
|
||||||
|
setCuboidRegion(start, 16, 1, this.wallheight + 1,
|
||||||
|
16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling);
|
||||||
|
setCuboidRegion(start, 16, this.wallheight + 1,
|
||||||
|
this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ,
|
||||||
|
this.wall);
|
||||||
}
|
}
|
||||||
if ((plotMinX + 1) <= 16) {
|
if ((plotMinX + 1) <= 16) {
|
||||||
int start, end;
|
int start, end;
|
||||||
@ -473,10 +544,16 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
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, this.wallheight + 1, 0, end, this.wallfilling);
|
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1,
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, 0, end, this.wall);
|
this.wallheight + 1, 0, end, this.wallfilling);
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, start, 16, this.wallfilling);
|
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX,
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall);
|
this.wallheight + 1, this.wallheight + 2, 0, end,
|
||||||
|
this.wall);
|
||||||
|
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1,
|
||||||
|
this.wallheight + 1, start, 16, this.wallfilling);
|
||||||
|
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX,
|
||||||
|
this.wallheight + 1, this.wallheight + 2, start, 16,
|
||||||
|
this.wall);
|
||||||
}
|
}
|
||||||
if ((roadStartZ <= 16) && (roadStartZ > 0)) {
|
if ((roadStartZ <= 16) && (roadStartZ > 0)) {
|
||||||
int start, end;
|
int start, end;
|
||||||
@ -493,10 +570,18 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) {
|
if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) {
|
||||||
start = 0;
|
start = 0;
|
||||||
}
|
}
|
||||||
setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling);
|
setCuboidRegion(0, end, 1, this.wallheight + 1,
|
||||||
setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall);
|
16 - roadStartZ, (16 - roadStartZ) + 1,
|
||||||
setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling);
|
this.wallfilling);
|
||||||
setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall);
|
setCuboidRegion(0, end, this.wallheight + 1,
|
||||||
|
this.wallheight + 2, 16 - roadStartZ,
|
||||||
|
(16 - roadStartZ) + 1, this.wall);
|
||||||
|
setCuboidRegion(start, 16, 1, this.wallheight + 1,
|
||||||
|
16 - roadStartZ, (16 - roadStartZ) + 1,
|
||||||
|
this.wallfilling);
|
||||||
|
setCuboidRegion(start, 16, this.wallheight + 1,
|
||||||
|
this.wallheight + 2, 16 - roadStartZ,
|
||||||
|
(16 - roadStartZ) + 1, this.wall);
|
||||||
}
|
}
|
||||||
if ((roadStartX <= 16) && (roadStartX > 0)) {
|
if ((roadStartX <= 16) && (roadStartX > 0)) {
|
||||||
int start, end;
|
int start, end;
|
||||||
@ -513,10 +598,16 @@ public class WorldGenerator extends PlotGenerator {
|
|||||||
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, this.wallheight + 1, 0, end, this.wallfilling);
|
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1,
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.roadheight + 2, 0, end, this.wall);
|
this.wallheight + 1, 0, end, this.wallfilling);
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, start, 16, this.wallfilling);
|
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1,
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall);
|
this.wallheight + 1, this.roadheight + 2, 0, end,
|
||||||
|
this.wall);
|
||||||
|
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1,
|
||||||
|
this.wallheight + 1, start, 16, this.wallfilling);
|
||||||
|
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1,
|
||||||
|
this.wallheight + 1, this.wallheight + 2, start, 16,
|
||||||
|
this.wall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Return the chunk
|
// Return the chunk
|
||||||
|
@ -20,8 +20,8 @@ public class XPopulator extends BlockPopulator {
|
|||||||
/*
|
/*
|
||||||
* Sorry, this isn't well documented at the moment.
|
* Sorry, this isn't well documented at the moment.
|
||||||
*
|
*
|
||||||
* We advise you to take a look at a world generation tutorial for information about how a BlockPopulator works.
|
* We advise you to take a look at a world generation tutorial for
|
||||||
*
|
* information about how a BlockPopulator works.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private int X;
|
private int X;
|
||||||
@ -46,7 +46,8 @@ 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, PlotBlock block, World w) {
|
public void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2,
|
||||||
|
PlotBlock block, World w) {
|
||||||
if (block.data == 0) {
|
if (block.data == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -59,7 +60,8 @@ public class XPopulator extends BlockPopulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks, World w) {
|
private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1,
|
||||||
|
int z2, PlotBlock[] blocks, World w) {
|
||||||
if (blocks.length == 1) {
|
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 {
|
||||||
@ -80,7 +82,8 @@ 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]), Short.parseShort(split[1]) };
|
return new short[] { Short.parseShort(split[0]),
|
||||||
|
Short.parseShort(split[1]) };
|
||||||
}
|
}
|
||||||
return new short[] { Short.parseShort(block), 0 };
|
return new short[] { Short.parseShort(block), 0 };
|
||||||
}
|
}
|
||||||
@ -107,22 +110,22 @@ public class XPopulator extends BlockPopulator {
|
|||||||
|
|
||||||
// save configuration
|
// save configuration
|
||||||
|
|
||||||
plotsize = plotworld.PLOT_WIDTH;
|
this.plotsize = this.plotworld.PLOT_WIDTH;
|
||||||
pathsize = plotworld.ROAD_WIDTH;
|
this.pathsize = this.plotworld.ROAD_WIDTH;
|
||||||
|
|
||||||
floor1 = plotworld.ROAD_BLOCK;
|
this.floor1 = this.plotworld.ROAD_BLOCK;
|
||||||
floor2 = plotworld.ROAD_STRIPES;
|
this.floor2 = this.plotworld.ROAD_STRIPES;
|
||||||
|
|
||||||
wallfilling = plotworld.WALL_FILLING;
|
this.wallfilling = this.plotworld.WALL_FILLING;
|
||||||
size = pathsize + plotsize;
|
this.size = this.pathsize + this.plotsize;
|
||||||
wall = plotworld.WALL_BLOCK;
|
this.wall = this.plotworld.WALL_BLOCK;
|
||||||
|
|
||||||
plotfloors = plotworld.TOP_BLOCK;
|
this.plotfloors = this.plotworld.TOP_BLOCK;
|
||||||
filling = plotworld.MAIN_BLOCK;
|
this.filling = this.plotworld.MAIN_BLOCK;
|
||||||
|
|
||||||
wallheight = plotworld.WALL_HEIGHT;
|
this.wallheight = this.plotworld.WALL_HEIGHT;
|
||||||
roadheight = plotworld.ROAD_HEIGHT;
|
this.roadheight = this.plotworld.ROAD_HEIGHT;
|
||||||
plotheight = plotworld.PLOT_HEIGHT;
|
this.plotheight = this.plotworld.PLOT_HEIGHT;
|
||||||
|
|
||||||
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;
|
||||||
@ -145,7 +148,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) - this.pathWidthLower - 1) + (8 * this.size));
|
double absX = ((((cx * 16) + 16) - this.pathWidthLower - 1) + (8 * this.size)), absZ = ((((cz * 16) + 16)
|
||||||
|
- this.pathWidthLower - 1) + (8 * this.size));
|
||||||
int plotMinX = (int) (((absX) % this.size));
|
int 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);
|
||||||
@ -159,26 +163,36 @@ public class XPopulator extends BlockPopulator {
|
|||||||
|
|
||||||
// ROADS
|
// ROADS
|
||||||
|
|
||||||
if ((this.pathsize > 16) && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) && !((roadStartX < 16) && (roadStartZ < 16)) && (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) {
|
if ((this.pathsize > 16)
|
||||||
setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1, w);
|
&& ((plotMinX > roadStartX) || (plotMinZ > roadStartZ))
|
||||||
|
&& !((roadStartX < 16) && (roadStartZ < 16))
|
||||||
|
&& (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) {
|
||||||
|
setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1,
|
||||||
|
w);
|
||||||
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, (16 - roadStartZ) + 1);
|
int start = Math.max((16 - plotMinZ - this.pathsize) + 1,
|
||||||
int end = Math.min(16 - plotMinZ - 1, (16 - roadStartZ) + this.pathsize);
|
(16 - roadStartZ) + 1);
|
||||||
|
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), Math.min(16, end), this.floor1, w);
|
setCuboidRegion(0, 16, 1, this.roadheight + 1, Math.max(start, 0),
|
||||||
|
Math.min(16, end), this.floor1, w);
|
||||||
}
|
}
|
||||||
if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) {
|
if (((plotMinX + 1) <= 16) || ((roadStartX <= 16) && (roadStartX > 0))) {
|
||||||
int start = Math.max((16 - plotMinX - this.pathsize) + 1, (16 - roadStartX) + 1);
|
int start = Math.max((16 - plotMinX - this.pathsize) + 1,
|
||||||
int end = Math.min(16 - plotMinX - 1, (16 - roadStartX) + this.pathsize);
|
(16 - roadStartX) + 1);
|
||||||
|
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, this.roadheight + 1, 0, 16, this.floor1, w);
|
setCuboidRegion(Math.max(start, 0), Math.min(16, end), 1,
|
||||||
|
this.roadheight + 1, 0, 16, this.floor1, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
// STRIPES
|
// STRIPES
|
||||||
@ -199,8 +213,11 @@ public class XPopulator extends BlockPopulator {
|
|||||||
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, 16 - value, (16 - value) + 1, this.floor2, w); //
|
setCuboidRegion(0, end, this.roadheight, this.roadheight + 1,
|
||||||
setCuboidRegion(start, 16, 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); //
|
||||||
}
|
}
|
||||||
if ((plotMinX + 2) <= 16) {
|
if ((plotMinX + 2) <= 16) {
|
||||||
int value = (plotMinX + 2);
|
int value = (plotMinX + 2);
|
||||||
@ -218,8 +235,10 @@ public class XPopulator extends BlockPopulator {
|
|||||||
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, this.roadheight + 1, 0, end, this.floor2, w); //
|
setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight,
|
||||||
setCuboidRegion(16 - value, (16 - value) + 1, this.roadheight, this.roadheight + 1, start, 16, 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); //
|
||||||
}
|
}
|
||||||
if ((roadStartZ <= 16) && (roadStartZ > 1)) {
|
if ((roadStartZ <= 16) && (roadStartZ > 1)) {
|
||||||
int val = roadStartZ;
|
int val = roadStartZ;
|
||||||
@ -237,8 +256,11 @@ public class XPopulator extends BlockPopulator {
|
|||||||
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, (16 - val) + 1, (16 - val) + 2, this.floor2, w);
|
setCuboidRegion(0, end, this.roadheight, this.roadheight + 1,
|
||||||
setCuboidRegion(start, 16, 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);
|
||||||
}
|
}
|
||||||
if ((roadStartX <= 16) && (roadStartX > 1)) {
|
if ((roadStartX <= 16) && (roadStartX > 1)) {
|
||||||
int val = roadStartX;
|
int val = roadStartX;
|
||||||
@ -256,8 +278,12 @@ public class XPopulator extends BlockPopulator {
|
|||||||
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, this.roadheight, this.roadheight + 1, 0, end, this.floor2, w); //
|
setCuboidRegion((16 - val) + 1, (16 - val) + 2,
|
||||||
setCuboidRegion((16 - val) + 1, (16 - val) + 2, this.roadheight, this.roadheight + 1, start, 16, this.floor2, w); //
|
this.roadheight, this.roadheight + 1, 0, end,
|
||||||
|
this.floor2, w); //
|
||||||
|
setCuboidRegion((16 - val) + 1, (16 - val) + 2,
|
||||||
|
this.roadheight, this.roadheight + 1, start, 16,
|
||||||
|
this.floor2, w); //
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// WALLS
|
// WALLS
|
||||||
@ -277,10 +303,16 @@ public class XPopulator extends BlockPopulator {
|
|||||||
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, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling, w);
|
setCuboidRegion(0, end, 1, this.wallheight + 1,
|
||||||
setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall, w);
|
16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling, w);
|
||||||
setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling, w);
|
setCuboidRegion(0, end, this.wallheight + 1,
|
||||||
setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ, this.wall, w);
|
this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ,
|
||||||
|
this.wall, w);
|
||||||
|
setCuboidRegion(start, 16, 1, this.wallheight + 1,
|
||||||
|
16 - plotMinZ - 1, 16 - plotMinZ, this.wallfilling, w);
|
||||||
|
setCuboidRegion(start, 16, this.wallheight + 1,
|
||||||
|
this.wallheight + 2, 16 - plotMinZ - 1, 16 - plotMinZ,
|
||||||
|
this.wall, w);
|
||||||
}
|
}
|
||||||
if ((plotMinX + 1) <= 16) {
|
if ((plotMinX + 1) <= 16) {
|
||||||
int start, end;
|
int start, end;
|
||||||
@ -297,10 +329,16 @@ public class XPopulator extends BlockPopulator {
|
|||||||
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, this.wallheight + 1, 0, end, this.wallfilling, w);
|
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1,
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, 0, end, this.wall, w);
|
this.wallheight + 1, 0, end, this.wallfilling, w);
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1, this.wallheight + 1, start, 16, this.wallfilling, w);
|
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX,
|
||||||
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall, w);
|
this.wallheight + 1, this.wallheight + 2, 0, end,
|
||||||
|
this.wall, w);
|
||||||
|
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX, 1,
|
||||||
|
this.wallheight + 1, start, 16, this.wallfilling, w);
|
||||||
|
setCuboidRegion(16 - plotMinX - 1, 16 - plotMinX,
|
||||||
|
this.wallheight + 1, this.wallheight + 2, start, 16,
|
||||||
|
this.wall, w);
|
||||||
}
|
}
|
||||||
if ((roadStartZ <= 16) && (roadStartZ > 0)) {
|
if ((roadStartZ <= 16) && (roadStartZ > 0)) {
|
||||||
int start, end;
|
int start, end;
|
||||||
@ -317,10 +355,18 @@ public class XPopulator extends BlockPopulator {
|
|||||||
if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) {
|
if (!(((plotMinX + 1) <= 16) || (roadStartX <= 16))) {
|
||||||
start = 0;
|
start = 0;
|
||||||
}
|
}
|
||||||
setCuboidRegion(0, end, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling, w);
|
setCuboidRegion(0, end, 1, this.wallheight + 1,
|
||||||
setCuboidRegion(0, end, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall, w);
|
16 - roadStartZ, (16 - roadStartZ) + 1,
|
||||||
setCuboidRegion(start, 16, 1, this.wallheight + 1, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wallfilling, w);
|
this.wallfilling, w);
|
||||||
setCuboidRegion(start, 16, this.wallheight + 1, this.wallheight + 2, 16 - roadStartZ, (16 - roadStartZ) + 1, this.wall, w);
|
setCuboidRegion(0, end, this.wallheight + 1,
|
||||||
|
this.wallheight + 2, 16 - roadStartZ,
|
||||||
|
(16 - roadStartZ) + 1, this.wall, w);
|
||||||
|
setCuboidRegion(start, 16, 1, this.wallheight + 1,
|
||||||
|
16 - roadStartZ, (16 - roadStartZ) + 1,
|
||||||
|
this.wallfilling, w);
|
||||||
|
setCuboidRegion(start, 16, this.wallheight + 1,
|
||||||
|
this.wallheight + 2, 16 - roadStartZ,
|
||||||
|
(16 - roadStartZ) + 1, this.wall, w);
|
||||||
}
|
}
|
||||||
if ((roadStartX <= 16) && (roadStartX > 0)) {
|
if ((roadStartX <= 16) && (roadStartX > 0)) {
|
||||||
int start, end;
|
int start, end;
|
||||||
@ -337,10 +383,16 @@ public class XPopulator extends BlockPopulator {
|
|||||||
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, this.wallheight + 1, 0, end, this.wallfilling, w);
|
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1,
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.roadheight + 2, 0, end, this.wall, w);
|
this.wallheight + 1, 0, end, this.wallfilling, w);
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1, this.wallheight + 1, start, 16, this.wallfilling, w);
|
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1,
|
||||||
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, this.wallheight + 1, this.wallheight + 2, start, 16, this.wall, w);
|
this.wallheight + 1, this.roadheight + 2, 0, end,
|
||||||
|
this.wall, w);
|
||||||
|
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1, 1,
|
||||||
|
this.wallheight + 1, start, 16, this.wallfilling, w);
|
||||||
|
setCuboidRegion(16 - roadStartX, (16 - roadStartX) + 1,
|
||||||
|
this.wallheight + 1, this.wallheight + 2, start, 16,
|
||||||
|
this.wall, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,36 +401,53 @@ 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, 16 - roadStartZ, this.filling, w);
|
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0,
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
|
16 - roadStartZ, this.filling, 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, 16 - plotMinZ, 16, this.filling, w);
|
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight,
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w);
|
16 - plotMinZ, 16, this.filling, w);
|
||||||
|
setCuboidRegion(0, 16 - roadStartX, this.plotheight,
|
||||||
|
this.plotheight + 1, 16 - plotMinZ, 16,
|
||||||
|
this.plotfloors, w);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (roadStartZ <= 16) {
|
if (roadStartZ <= 16) {
|
||||||
if (plotMinX > 16) {
|
if (plotMinX > 16) {
|
||||||
setCuboidRegion(0, 16, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w);
|
setCuboidRegion(0, 16, 1, this.plotheight, 0,
|
||||||
setCuboidRegion(0, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
|
16 - roadStartZ, this.filling, 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, 16 - plotMinZ, 16, this.filling, w);
|
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight,
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w);
|
16 - plotMinZ, 16, this.filling, w);
|
||||||
|
setCuboidRegion(16 - plotMinX, 16, this.plotheight,
|
||||||
|
this.plotheight + 1, 16 - plotMinZ, 16,
|
||||||
|
this.plotfloors, w);
|
||||||
} else {
|
} 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, z, this.filling, w);
|
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0,
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors, w);
|
z, this.filling, 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, 16 - roadStartZ, this.filling, w);
|
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0,
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
|
16 - roadStartZ, this.filling, w);
|
||||||
|
setCuboidRegion(16 - plotMinX, 16, this.plotheight,
|
||||||
|
this.plotheight + 1, 0, 16 - roadStartZ,
|
||||||
|
this.plotfloors, w);
|
||||||
} else {
|
} else {
|
||||||
if (roadStartX <= 16) {
|
if (roadStartX <= 16) {
|
||||||
if (plotMinZ > 16) {
|
if (plotMinZ > 16) {
|
||||||
@ -386,8 +455,11 @@ public class XPopulator extends BlockPopulator {
|
|||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
x = 16;
|
x = 16;
|
||||||
}
|
}
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 0, 16, this.filling, w);
|
setCuboidRegion(0, x, 1, this.plotheight, 0, 16,
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, 16, this.plotfloors, w);
|
this.filling, w);
|
||||||
|
setCuboidRegion(0, x, this.plotheight,
|
||||||
|
this.plotheight + 1, 0, 16,
|
||||||
|
this.plotfloors, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -398,8 +470,11 @@ public class XPopulator extends BlockPopulator {
|
|||||||
if (x < 0) {
|
if (x < 0) {
|
||||||
x = 16;
|
x = 16;
|
||||||
}
|
}
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w);
|
setCuboidRegion(0, x, 1, this.plotheight,
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w);
|
16 - plotMinZ, 16, this.filling, w);
|
||||||
|
setCuboidRegion(0, x, this.plotheight,
|
||||||
|
this.plotheight + 1, 16 - plotMinZ, 16,
|
||||||
|
this.plotfloors, w);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (roadStartZ > 16) {
|
if (roadStartZ > 16) {
|
||||||
@ -412,11 +487,17 @@ public class XPopulator extends BlockPopulator {
|
|||||||
z = 16;
|
z = 16;
|
||||||
}
|
}
|
||||||
if (roadStartX > 16) {
|
if (roadStartX > 16) {
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling, w);
|
setCuboidRegion(0, x, 1, this.plotheight, 0, z,
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors, w);
|
this.filling, w);
|
||||||
|
setCuboidRegion(0, x, this.plotheight,
|
||||||
|
this.plotheight + 1, 0, z, this.plotfloors,
|
||||||
|
w);
|
||||||
} else {
|
} else {
|
||||||
setCuboidRegion(0, x, 1, this.plotheight, 0, z, this.filling, w);
|
setCuboidRegion(0, x, 1, this.plotheight, 0, z,
|
||||||
setCuboidRegion(0, x, this.plotheight, this.plotheight + 1, 0, z, this.plotfloors, w);
|
this.filling, w);
|
||||||
|
setCuboidRegion(0, x, this.plotheight,
|
||||||
|
this.plotheight + 1, 0, z, this.plotfloors,
|
||||||
|
w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -424,22 +505,34 @@ public class XPopulator extends BlockPopulator {
|
|||||||
} else {
|
} else {
|
||||||
if (roadStartX <= 16) {
|
if (roadStartX <= 16) {
|
||||||
if (roadStartZ <= 16) {
|
if (roadStartZ <= 16) {
|
||||||
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0, 16 - roadStartZ, this.filling, w);
|
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight, 0,
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
|
16 - roadStartZ, this.filling, 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, 16 - plotMinZ, 16, this.filling, w);
|
setCuboidRegion(0, 16 - roadStartX, 1, this.plotheight,
|
||||||
setCuboidRegion(0, 16 - roadStartX, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w);
|
16 - plotMinZ, 16, this.filling, w);
|
||||||
|
setCuboidRegion(0, 16 - roadStartX, this.plotheight,
|
||||||
|
this.plotheight + 1, 16 - plotMinZ, 16,
|
||||||
|
this.plotfloors, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plotMinX <= 16) {
|
if (plotMinX <= 16) {
|
||||||
if (plotMinZ <= 16) {
|
if (plotMinZ <= 16) {
|
||||||
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 16 - plotMinZ, 16, this.filling, w);
|
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight,
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 16 - plotMinZ, 16, this.plotfloors, w);
|
16 - plotMinZ, 16, this.filling, 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, 16 - roadStartZ, this.filling, w);
|
setCuboidRegion(16 - plotMinX, 16, 1, this.plotheight, 0,
|
||||||
setCuboidRegion(16 - plotMinX, 16, this.plotheight, this.plotheight + 1, 0, 16 - roadStartZ, this.plotfloors, w);
|
16 - roadStartZ, this.filling, w);
|
||||||
|
setCuboidRegion(16 - plotMinX, 16, this.plotheight,
|
||||||
|
this.plotheight + 1, 0, 16 - roadStartZ,
|
||||||
|
this.plotfloors, w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import org.bukkit.event.block.BlockSpreadEvent;
|
import org.bukkit.event.block.BlockSpreadEvent;
|
||||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
@ -65,7 +64,6 @@ import org.bukkit.event.world.WorldLoadEvent;
|
|||||||
import com.intellectualcrafters.plot.C;
|
import com.intellectualcrafters.plot.C;
|
||||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.Plot;
|
import com.intellectualcrafters.plot.Plot;
|
||||||
import com.intellectualcrafters.plot.PlotHelper;
|
|
||||||
import com.intellectualcrafters.plot.PlotId;
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
import com.intellectualcrafters.plot.PlotWorld;
|
import com.intellectualcrafters.plot.PlotWorld;
|
||||||
@ -91,26 +89,36 @@ 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.getBlockX(),64,l1.getBlockZ()));
|
PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1
|
||||||
PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(),l2.getBlockX(),64,l2.getBlockZ()));
|
.getBlockX(), 64, l1.getBlockZ()));
|
||||||
if (p2==null)
|
PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2
|
||||||
|
.getBlockX(), 64, l2.getBlockZ()));
|
||||||
|
if (p2 == null) {
|
||||||
return false;
|
return false;
|
||||||
if (p1==null)
|
}
|
||||||
|
if (p1 == null) {
|
||||||
return true;
|
return true;
|
||||||
if (p1.equals(p2))
|
}
|
||||||
|
if (p1.equals(p2)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean leftPlot(Location l1, Location l2) {
|
public boolean leftPlot(Location l1, Location l2) {
|
||||||
PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(),l1.getBlockX(),64,l1.getBlockZ()));
|
PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1
|
||||||
PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(),l2.getBlockX(),64,l2.getBlockZ()));
|
.getBlockX(), 64, l1.getBlockZ()));
|
||||||
if (p1==null)
|
PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2
|
||||||
|
.getBlockX(), 64, l2.getBlockZ()));
|
||||||
|
if (p1 == null) {
|
||||||
return false;
|
return false;
|
||||||
if (p2==null)
|
}
|
||||||
|
if (p2 == null) {
|
||||||
return true;
|
return true;
|
||||||
if (p1.equals(p2))
|
}
|
||||||
|
if (p1.equals(p2)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +143,8 @@ 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>(), new ArrayList<UUID>(), loc.getWorld().getName());
|
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(),
|
||||||
|
new ArrayList<UUID>(), loc.getWorld().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -152,14 +161,16 @@ public class PlayerEvents implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void textures(Player p) {
|
private void textures(Player p) {
|
||||||
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld())) {
|
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)
|
||||||
|
&& isPlotWorld(p.getWorld())) {
|
||||||
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
|
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onChangeWorld(PlayerChangedWorldEvent event) {
|
public void onChangeWorld(PlayerChangedWorldEvent event) {
|
||||||
if (isPlotWorld(event.getFrom()) && (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) {
|
if (isPlotWorld(event.getFrom())
|
||||||
|
&& (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) {
|
||||||
event.getPlayer().setResourcePack("");
|
event.getPlayer().setResourcePack("");
|
||||||
} else {
|
} else {
|
||||||
textures(event.getPlayer());
|
textures(event.getPlayer());
|
||||||
@ -169,10 +180,14 @@ 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", plot.getDisplayName());
|
String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s",
|
||||||
String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner));
|
plot.getDisplayName());
|
||||||
ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s());
|
String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst(
|
||||||
ChatColor sTitleSubColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s());
|
"%s", getName(plot.owner));
|
||||||
|
ChatColor sTitleMainColor = ChatColor
|
||||||
|
.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s());
|
||||||
|
ChatColor sTitleSubColor = ChatColor
|
||||||
|
.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s());
|
||||||
Title title = new Title(sTitleMain, sTitleSub, 10, 20, 10);
|
Title title = new Title(sTitleMain, sTitleSub, 10, 20, 10);
|
||||||
title.setTitleColor(sTitleMainColor);
|
title.setTitleColor(sTitleMainColor);
|
||||||
title.setSubtitleColor(sTitleSubColor);
|
title.setSubtitleColor(sTitleSubColor);
|
||||||
@ -180,7 +195,8 @@ public class PlayerEvents implements Listener {
|
|||||||
title.send(player);
|
title.send(player);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot);
|
PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(
|
||||||
|
player, plot);
|
||||||
Bukkit.getPluginManager().callEvent(callEvent);
|
Bukkit.getPluginManager().callEvent(callEvent);
|
||||||
}
|
}
|
||||||
PlayerFunctions.sendMessage(player, plot.settings.getJoinMessage());
|
PlayerFunctions.sendMessage(player, plot.settings.getJoinMessage());
|
||||||
@ -192,9 +208,11 @@ public class PlayerEvents implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void plotExit(Player player, Plot plot) {
|
public void plotExit(Player player, Plot plot) {
|
||||||
{
|
{
|
||||||
PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
|
PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player,
|
||||||
|
plot);
|
||||||
Bukkit.getPluginManager().callEvent(callEvent);
|
Bukkit.getPluginManager().callEvent(callEvent);
|
||||||
}
|
}
|
||||||
player.resetPlayerTime();
|
player.resetPlayerTime();
|
||||||
@ -208,7 +226,8 @@ public class PlayerEvents implements Listener {
|
|||||||
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()) || (from.getBlockZ() != to.getBlockZ())) {
|
if ((from.getBlockX() != to.getBlockX())
|
||||||
|
|| (from.getBlockZ() != to.getBlockZ())) {
|
||||||
if (!isPlotWorld(player.getWorld())) {
|
if (!isPlotWorld(player.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -255,7 +274,8 @@ public class PlayerEvents implements Listener {
|
|||||||
recipients.add(p);
|
recipients.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
format = format.replaceAll("%plot_id%", id.x + ";" + id.y).replaceAll("%sender%", sender).replaceAll("%msg%", message);
|
format = format.replaceAll("%plot_id%", id.x + ";" + id.y)
|
||||||
|
.replaceAll("%sender%", sender).replaceAll("%msg%", message);
|
||||||
format = ChatColor.translateAlternateColorCodes('&', format);
|
format = ChatColor.translateAlternateColorCodes('&', format);
|
||||||
event.setFormat(format);
|
event.setFormat(format);
|
||||||
}
|
}
|
||||||
@ -467,7 +487,8 @@ public class PlayerEvents implements Listener {
|
|||||||
@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()) && (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) {
|
if (isPlotWorld(b.getLocation())
|
||||||
|
&& (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) {
|
||||||
if (!isInPlot(b.getLocation())) {
|
if (!isInPlot(b.getLocation())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -502,7 +523,12 @@ 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());
|
||||||
if (new ArrayList<>(Arrays.asList(new Material[] { Material.STONE_BUTTON, Material.WOOD_BUTTON, Material.LEVER, Material.STONE_PLATE, Material.WOOD_PLATE, Material.CHEST, Material.TRAPPED_CHEST, Material.TRAP_DOOR, Material.WOOD_DOOR, Material.WOODEN_DOOR, Material.DISPENSER, Material.DROPPER
|
if (new ArrayList<>(Arrays.asList(new Material[] {
|
||||||
|
Material.STONE_BUTTON, Material.WOOD_BUTTON,
|
||||||
|
Material.LEVER, Material.STONE_PLATE, Material.WOOD_PLATE,
|
||||||
|
Material.CHEST, Material.TRAPPED_CHEST, Material.TRAP_DOOR,
|
||||||
|
Material.WOOD_DOOR, Material.WOODEN_DOOR,
|
||||||
|
Material.DISPENSER, Material.DROPPER
|
||||||
|
|
||||||
})).contains(event.getClickedBlock().getType())) {
|
})).contains(event.getClickedBlock().getType())) {
|
||||||
return;
|
return;
|
||||||
@ -572,22 +598,24 @@ 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(), C.YOU_BE_DENIED);
|
PlayerFunctions.sendMessage(event.getPlayer(),
|
||||||
|
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) || (event.getTo().getBlockX() <= -29999999) || (event.getTo().getBlockZ() >= 29999999) || (event.getTo().getBlockZ() <= -29999999)) {
|
if ((event.getTo().getBlockX() >= 29999999)
|
||||||
|
|| (event.getTo().getBlockX() <= -29999999)
|
||||||
|
|| (event.getTo().getBlockZ() >= 29999999)
|
||||||
|
|| (event.getTo().getBlockZ() <= -29999999)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -597,7 +625,8 @@ public class PlayerEvents implements Listener {
|
|||||||
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().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock();
|
Block b = e.getBlockClicked().getLocation()
|
||||||
|
.add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock();
|
||||||
if (isPlotWorld(b.getLocation())) {
|
if (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);
|
||||||
@ -605,10 +634,12 @@ public class PlayerEvents implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
Plot plot = getCurrentPlot(b.getLocation());
|
Plot plot = getCurrentPlot(b.getLocation());
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
|
PlayerFunctions.sendMessage(e.getPlayer(),
|
||||||
|
C.NO_PERMISSION);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
} else if (!plot.hasRights(e.getPlayer())) {
|
} else if (!plot.hasRights(e.getPlayer())) {
|
||||||
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
|
PlayerFunctions.sendMessage(e.getPlayer(),
|
||||||
|
C.NO_PERMISSION);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -618,7 +649,8 @@ public class PlayerEvents implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) {
|
if (event.getInventory().getName()
|
||||||
|
.equalsIgnoreCase("PlotSquared Commands")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -634,10 +666,12 @@ public class PlayerEvents implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
Plot plot = getCurrentPlot(b.getLocation());
|
Plot plot = getCurrentPlot(b.getLocation());
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
|
PlayerFunctions.sendMessage(e.getPlayer(),
|
||||||
|
C.NO_PERMISSION);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
} else if (!plot.hasRights(e.getPlayer())) {
|
} else if (!plot.hasRights(e.getPlayer())) {
|
||||||
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
|
PlayerFunctions.sendMessage(e.getPlayer(),
|
||||||
|
C.NO_PERMISSION);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,10 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
|||||||
*/
|
*/
|
||||||
public class WorldEditListener implements Listener {
|
public class WorldEditListener implements Listener {
|
||||||
|
|
||||||
public final Set<String> blockedcmds = new HashSet<String>(Arrays.asList("/gmask", "//gmask", "/worldedit:gmask"));
|
public final Set<String> blockedcmds = new HashSet<String>(Arrays.asList(
|
||||||
public final Set<String> restrictedcmds = new HashSet<String>(Arrays.asList("/up", "//up", "/worldedit:up"));
|
"/gmask", "//gmask", "/worldedit:gmask"));
|
||||||
|
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()));
|
||||||
@ -52,12 +54,17 @@ public class WorldEditListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p.getItemInHand();
|
p.getItemInHand();
|
||||||
if ((p.getItemInHand() == null) || (p.getItemInHand().getType() == Material.AIR)) {
|
if ((p.getItemInHand() == null)
|
||||||
|
|| (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) && plot.hasOwner() && (plot.helpers != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
|
if ((plot != null)
|
||||||
|
&& plot.hasOwner()
|
||||||
|
&& (plot.helpers != null)
|
||||||
|
&& (plot.helpers.contains(DBFunc.everyone) || plot.helpers
|
||||||
|
.contains(p.getUniqueId()))) {
|
||||||
PWE.setMask(p, l);
|
PWE.setMask(p, l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +73,8 @@ public class WorldEditListener implements Listener {
|
|||||||
@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") || !PlotMain.isPlotWorld(p.getWorld())) {
|
if (PlotMain.hasPermission(p, "plots.worldedit.bypass")
|
||||||
|
|| !PlotMain.isPlotWorld(p.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String cmd = e.getMessage().toLowerCase();
|
String cmd = e.getMessage().toLowerCase();
|
||||||
@ -76,7 +84,9 @@ 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) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
|
if ((plot == null)
|
||||||
|
|| !(plot.helpers.contains(DBFunc.everyone) || plot.helpers
|
||||||
|
.contains(p.getUniqueId()))) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (this.blockedcmds.contains(cmd)) {
|
} else if (this.blockedcmds.contains(cmd)) {
|
||||||
@ -107,7 +117,8 @@ 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()) || (f.getBlockZ() != t.getBlockZ())) {
|
if ((f.getBlockX() != t.getBlockX())
|
||||||
|
|| (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")) {
|
||||||
|
@ -50,7 +50,8 @@ 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 " + (plot.id.x + "-" + plot.id.y) + " " + key);
|
requester.performCommand("region flag "
|
||||||
|
+ (plot.id.x + "-" + plot.id.y) + " " + key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -60,7 +61,8 @@ public class WorldGuardListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFlag(Player requester, World world, Plot plot, String key, String value) {
|
public void addFlag(Player requester, World world, Plot plot, String key,
|
||||||
|
String value) {
|
||||||
boolean op = requester.isOp();
|
boolean op = requester.isOp();
|
||||||
requester.setOp(true);
|
requester.setOp(true);
|
||||||
try {
|
try {
|
||||||
@ -68,7 +70,9 @@ 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 " + (plot.id.x + "-" + plot.id.y) + " " + key + " " + value);
|
requester.performCommand("region flag "
|
||||||
|
+ (plot.id.x + "-" + plot.id.y) + " " + key + " "
|
||||||
|
+ value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -95,12 +99,17 @@ 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.getPlotBottomLocAbs(world, plots.get(0));
|
Location location1 = PlotHelper
|
||||||
Location location2 = PlotHelper.getPlotTopLocAbs(world, plots.get(plots.size() - 1));
|
.getPlotBottomLocAbs(world, plots.get(0));
|
||||||
|
Location location2 = PlotHelper.getPlotTopLocAbs(world,
|
||||||
|
plots.get(plots.size() - 1));
|
||||||
|
|
||||||
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
|
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1,
|
||||||
BlockVector vector2 = new BlockVector(location2.getBlockX(), world.getMaxHeight(), location2.getBlockZ());
|
location1.getBlockZ());
|
||||||
ProtectedRegion rg = new ProtectedCuboidRegion(main.id.x + "-" + main.id.y, vector1, vector2);
|
BlockVector vector2 = new BlockVector(location2.getBlockX(),
|
||||||
|
world.getMaxHeight(), location2.getBlockZ());
|
||||||
|
ProtectedRegion rg = new ProtectedCuboidRegion(main.id.x + "-"
|
||||||
|
+ main.id.y, vector1, vector2);
|
||||||
|
|
||||||
rg.setFlags(flags);
|
rg.setFlags(flags);
|
||||||
|
|
||||||
@ -130,9 +139,12 @@ 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, location1.getBlockZ());
|
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1,
|
||||||
BlockVector vector2 = new BlockVector(location2.getBlockX(), w.getMaxHeight(), location2.getBlockZ());
|
location1.getBlockZ());
|
||||||
ProtectedRegion rg = new ProtectedCuboidRegion(id.x + "-" + id.y, vector1, vector2);
|
BlockVector vector2 = new BlockVector(location2.getBlockX(),
|
||||||
|
w.getMaxHeight(), location2.getBlockZ());
|
||||||
|
ProtectedRegion rg = new ProtectedCuboidRegion(id.x + "-" + id.y,
|
||||||
|
vector1, vector2);
|
||||||
|
|
||||||
rg.setFlags(flags);
|
rg.setFlags(flags);
|
||||||
|
|
||||||
@ -148,15 +160,21 @@ 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.getWorld());
|
RegionManager manager = PlotMain.worldGuard.getRegionManager(plot
|
||||||
|
.getWorld());
|
||||||
|
|
||||||
Location location1 = PlotHelper.getPlotBottomLoc(plot.getWorld(), plot.getId());
|
Location location1 = PlotHelper.getPlotBottomLoc(plot.getWorld(),
|
||||||
Location location2 = PlotHelper.getPlotTopLoc(plot.getWorld(), plot.getId());
|
plot.getId());
|
||||||
|
Location location2 = PlotHelper.getPlotTopLoc(plot.getWorld(),
|
||||||
|
plot.getId());
|
||||||
|
|
||||||
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1, location1.getBlockZ());
|
BlockVector vector1 = new BlockVector(location1.getBlockX(), 1,
|
||||||
BlockVector vector2 = new BlockVector(location2.getBlockX(), plot.getWorld().getMaxHeight(), location2.getBlockZ());
|
location1.getBlockZ());
|
||||||
|
BlockVector vector2 = new BlockVector(location2.getBlockX(), plot
|
||||||
|
.getWorld().getMaxHeight(), location2.getBlockZ());
|
||||||
|
|
||||||
ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-" + plot.getId().y, vector1, vector2);
|
ProtectedRegion region = new ProtectedCuboidRegion(plot.getId().x + "-"
|
||||||
|
+ plot.getId().y, vector1, vector2);
|
||||||
|
|
||||||
DefaultDomain owner = new DefaultDomain();
|
DefaultDomain owner = new DefaultDomain();
|
||||||
owner.addPlayer(PlotMain.worldGuard.wrapPlayer(player));
|
owner.addPlayer(PlotMain.worldGuard.wrapPlayer(player));
|
||||||
|
@ -35,8 +35,11 @@ public class NameFetcher implements Callable<Map<UUID, String>> {
|
|||||||
if (uuidStringMap.containsKey(uuid)) {
|
if (uuidStringMap.containsKey(uuid)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
HttpURLConnection connection = (HttpURLConnection) new URL(PROFILE_URL + uuid.toString().replace("-", "")).openConnection();
|
HttpURLConnection connection = (HttpURLConnection) new URL(
|
||||||
JSONObject response = (JSONObject) this.jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
PROFILE_URL + uuid.toString().replace("-", ""))
|
||||||
|
.openConnection();
|
||||||
|
JSONObject response = (JSONObject) this.jsonParser
|
||||||
|
.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;
|
||||||
|
@ -40,12 +40,15 @@ 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.ceil(this.names.size() / PROFILES_PER_REQUEST);
|
int requests = (int) Math
|
||||||
|
.ceil(this.names.size() / PROFILES_PER_REQUEST);
|
||||||
for (int i = 0; i < requests; i++) {
|
for (int i = 0; i < requests; i++) {
|
||||||
HttpURLConnection connection = createConnection();
|
HttpURLConnection connection = createConnection();
|
||||||
String body = JSONArray.toJSONString(this.names.subList(i * 100, Math.min((i + 1) * 100, this.names.size())));
|
String body = JSONArray.toJSONString(this.names.subList(i * 100,
|
||||||
|
Math.min((i + 1) * 100, this.names.size())));
|
||||||
writeBody(connection, body);
|
writeBody(connection, body);
|
||||||
JSONArray array = (JSONArray) this.jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
JSONArray array = (JSONArray) this.jsonParser
|
||||||
|
.parse(new InputStreamReader(connection.getInputStream()));
|
||||||
for (Object profile : array) {
|
for (Object profile : array) {
|
||||||
JSONObject jsonProfile = (JSONObject) profile;
|
JSONObject jsonProfile = (JSONObject) profile;
|
||||||
String id = (String) jsonProfile.get("id");
|
String id = (String) jsonProfile.get("id");
|
||||||
@ -60,7 +63,8 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
|||||||
return uuidMap;
|
return uuidMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void writeBody(HttpURLConnection connection, String body) throws Exception {
|
private static void writeBody(HttpURLConnection connection, String body)
|
||||||
|
throws Exception {
|
||||||
OutputStream stream = connection.getOutputStream();
|
OutputStream stream = connection.getOutputStream();
|
||||||
stream.write(body.getBytes());
|
stream.write(body.getBytes());
|
||||||
stream.flush();
|
stream.flush();
|
||||||
@ -79,7 +83,9 @@ 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) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32));
|
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12)
|
||||||
|
+ "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-"
|
||||||
|
+ id.substring(20, 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] toBytes(UUID uuid) {
|
public static byte[] toBytes(UUID uuid) {
|
||||||
@ -91,7 +97,8 @@ 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: " + array.length);
|
throw new IllegalArgumentException("Illegal byte array length: "
|
||||||
|
+ array.length);
|
||||||
}
|
}
|
||||||
ByteBuffer byteBuffer = ByteBuffer.wrap(array);
|
ByteBuffer byteBuffer = ByteBuffer.wrap(array);
|
||||||
long mostSignificant = byteBuffer.getLong();
|
long mostSignificant = byteBuffer.getLong();
|
||||||
|
@ -37,13 +37,15 @@ public class IndexHandler implements Container {
|
|||||||
|
|
||||||
if ((request.getInteger("page")) < 0) {
|
if ((request.getInteger("page")) < 0) {
|
||||||
}
|
}
|
||||||
if (((coverage = request.getTarget()) == null) || coverage.equals("/")) {
|
if (((coverage = request.getTarget()) == null)
|
||||||
|
|| coverage.equals("/")) {
|
||||||
coverage = "index";
|
coverage = "index";
|
||||||
}
|
}
|
||||||
|
|
||||||
coverage = coverage.toLowerCase();
|
coverage = coverage.toLowerCase();
|
||||||
|
|
||||||
List<String> list = new ArrayList<>(Arrays.asList(new String[] { "install", "index", "stylesheet" }));
|
List<String> list = new ArrayList<>(Arrays.asList(new String[] {
|
||||||
|
"install", "index", "stylesheet" }));
|
||||||
|
|
||||||
if (!list.contains(coverage)) {
|
if (!list.contains(coverage)) {
|
||||||
coverage = "index";
|
coverage = "index";
|
||||||
@ -55,7 +57,9 @@ 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.FileType.CSS, this.plugin.getDataFolder());
|
ResourceHandler stylesheet = new ResourceHandler("stylesheet",
|
||||||
|
ResourceHandler.FileType.CSS,
|
||||||
|
this.plugin.getDataFolder());
|
||||||
|
|
||||||
String stylesheetHTML = stylesheet.getHTML();
|
String stylesheetHTML = stylesheet.getHTML();
|
||||||
|
|
||||||
@ -68,11 +72,18 @@ public class IndexHandler implements Container {
|
|||||||
response.setDate("Date", time);
|
response.setDate("Date", time);
|
||||||
response.setDate("Last-Modified", time);
|
response.setDate("Last-Modified", time);
|
||||||
|
|
||||||
ResourceHandler header = new ResourceHandler("header", ResourceHandler.FileType.HTML, this.plugin.getDataFolder());
|
ResourceHandler header = new ResourceHandler("header",
|
||||||
ResourceHandler footer = new ResourceHandler("footer", ResourceHandler.FileType.HTML, this.plugin.getDataFolder());
|
ResourceHandler.FileType.HTML,
|
||||||
ResourceHandler cPage = new ResourceHandler(coverage, ResourceHandler.FileType.HTML, this.plugin.getDataFolder());
|
this.plugin.getDataFolder());
|
||||||
|
ResourceHandler footer = new ResourceHandler("footer",
|
||||||
|
ResourceHandler.FileType.HTML,
|
||||||
|
this.plugin.getDataFolder());
|
||||||
|
ResourceHandler cPage = new ResourceHandler(coverage,
|
||||||
|
ResourceHandler.FileType.HTML,
|
||||||
|
this.plugin.getDataFolder());
|
||||||
|
|
||||||
String headerHTML = header.getHTML().replace("@title", this.title);
|
String headerHTML = header.getHTML().replace("@title",
|
||||||
|
this.title);
|
||||||
String footerHTML = footer.getHTML();
|
String footerHTML = footer.getHTML();
|
||||||
String cPageHTML = cPage.getHTML();
|
String cPageHTML = cPage.getHTML();
|
||||||
|
|
||||||
|
@ -34,7 +34,8 @@ public class PlotWeb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void start() throws Exception {
|
public void start() throws Exception {
|
||||||
this.container = new IndexHandler(JavaPlugin.getPlugin(PlotMain.class), this.title);
|
this.container = new IndexHandler(JavaPlugin.getPlugin(PlotMain.class),
|
||||||
|
this.title);
|
||||||
this.server = new ContainerServer(this.container);
|
this.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);
|
||||||
|
@ -13,17 +13,23 @@ public class ResourceHandler {
|
|||||||
private File file;
|
private File file;
|
||||||
private BufferedReader reader;
|
private BufferedReader reader;
|
||||||
|
|
||||||
public ResourceHandler(String filePath, FileType fileType, File folder) throws Exception {
|
public ResourceHandler(String filePath, FileType fileType, File folder)
|
||||||
|
throws Exception {
|
||||||
if (fileType == FileType.CSS) {
|
if (fileType == FileType.CSS) {
|
||||||
this.file = new File(folder.toPath().toString() + File.separator + "web" + File.separator + "css" + File.separator + filePath + "." + fileType.toString());
|
this.file = new File(folder.toPath().toString() + File.separator
|
||||||
|
+ "web" + File.separator + "css" + File.separator
|
||||||
|
+ filePath + "." + fileType.toString());
|
||||||
} else {
|
} else {
|
||||||
this.file = new File(folder.toPath().toString() + File.separator + "web" + File.separator + filePath + "." + fileType.toString());
|
this.file = new File(folder.toPath().toString() + File.separator
|
||||||
|
+ "web" + File.separator + 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(new FileInputStream(this.file)));
|
this.reader = new BufferedReader(new InputStreamReader(
|
||||||
|
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user