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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,10 +8,18 @@ import org.bukkit.ChatColor;
public class ConsoleColors {
static enum ConsoleColor {
RESET("\u001B[0m"), BLACK("\u001B[30m"), RED("\u001B[31m"), GREEN(
"\u001B[32m"), YELLOW("\u001B[33m"), BLUE("\u001B[34m"), PURPLE(
"\u001B[35m"), CYAN("\u001B[36m"), WHITE("\u001B[37m"), BOLD(
"\033[1m"), UNDERLINE("\033[0m"), ITALIC("\033[3m");
RESET("\u001B[0m"),
BLACK("\u001B[30m"),
RED("\u001B[31m"),
GREEN("\u001B[32m"),
YELLOW("\u001B[33m"),
BLUE("\u001B[34m"),
PURPLE("\u001B[35m"),
CYAN("\u001B[36m"),
WHITE("\u001B[37m"),
BOLD("\033[1m"),
UNDERLINE("\033[0m"),
ITALIC("\033[3m");
private String win;
private String lin;
@ -44,28 +52,8 @@ public class ConsoleColors {
*/
public static String fromString(String input) {
input = input.replaceAll("&0", fromChatColor(ChatColor.BLACK))
.replaceAll("&1", fromChatColor(ChatColor.DARK_BLUE))
.replaceAll("&2", fromChatColor(ChatColor.DARK_GREEN))
.replaceAll("&3", fromChatColor(ChatColor.DARK_AQUA))
.replaceAll("&4", fromChatColor(ChatColor.DARK_RED))
.replaceAll("&5", fromChatColor(ChatColor.DARK_PURPLE))
.replaceAll("&6", fromChatColor(ChatColor.GOLD))
.replaceAll("&7", fromChatColor(ChatColor.GRAY))
.replaceAll("&8", fromChatColor(ChatColor.DARK_GRAY))
.replaceAll("&9", fromChatColor(ChatColor.BLUE))
.replaceAll("&a", fromChatColor(ChatColor.GREEN))
.replaceAll("&b", fromChatColor(ChatColor.AQUA))
.replaceAll("&c", fromChatColor(ChatColor.RED))
.replaceAll("&d", fromChatColor(ChatColor.LIGHT_PURPLE))
.replaceAll("&e", fromChatColor(ChatColor.YELLOW))
.replaceAll("&f", fromChatColor(ChatColor.WHITE))
.replaceAll("&k", fromChatColor(ChatColor.MAGIC))
.replaceAll("&l", fromChatColor(ChatColor.BOLD))
.replaceAll("&m", fromChatColor(ChatColor.STRIKETHROUGH))
.replaceAll("&n", fromChatColor(ChatColor.UNDERLINE))
.replaceAll("&o", fromChatColor(ChatColor.ITALIC))
.replaceAll("&r", fromChatColor(ChatColor.RESET));
input =
input.replaceAll("&0", fromChatColor(ChatColor.BLACK)).replaceAll("&1", fromChatColor(ChatColor.DARK_BLUE)).replaceAll("&2", fromChatColor(ChatColor.DARK_GREEN)).replaceAll("&3", fromChatColor(ChatColor.DARK_AQUA)).replaceAll("&4", fromChatColor(ChatColor.DARK_RED)).replaceAll("&5", fromChatColor(ChatColor.DARK_PURPLE)).replaceAll("&6", fromChatColor(ChatColor.GOLD)).replaceAll("&7", fromChatColor(ChatColor.GRAY)).replaceAll("&8", fromChatColor(ChatColor.DARK_GRAY)).replaceAll("&9", fromChatColor(ChatColor.BLUE)).replaceAll("&a", fromChatColor(ChatColor.GREEN)).replaceAll("&b", fromChatColor(ChatColor.AQUA)).replaceAll("&c", fromChatColor(ChatColor.RED)).replaceAll("&d", fromChatColor(ChatColor.LIGHT_PURPLE)).replaceAll("&e", fromChatColor(ChatColor.YELLOW)).replaceAll("&f", fromChatColor(ChatColor.WHITE)).replaceAll("&k", fromChatColor(ChatColor.MAGIC)).replaceAll("&l", fromChatColor(ChatColor.BOLD)).replaceAll("&m", fromChatColor(ChatColor.STRIKETHROUGH)).replaceAll("&n", fromChatColor(ChatColor.UNDERLINE)).replaceAll("&o", fromChatColor(ChatColor.ITALIC)).replaceAll("&r", fromChatColor(ChatColor.RESET));
return input + "\u001B[0m";
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -97,28 +97,18 @@ public abstract class PlotWorld {
// TODO make this configurable
// make non static and static_default_valu + add config option
public static ArrayList<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 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 static boolean AUTO_MERGE_DEFAULT = false;
@ -172,12 +162,10 @@ public abstract class PlotWorld {
public void loadDefaultConfiguration(ConfigurationSection config) {
this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning");
this.AUTO_MERGE = config.getBoolean("plot.auto_merge");
this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config
.getString("plot.biome"));
this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config.getString("plot.biome"));
this.SCHEMATIC_ON_CLAIM = config.getBoolean("schematic.on_claim");
this.SCHEMATIC_FILE = config.getString("schematic.file");
this.SCHEMATIC_CLAIM_SPECIFY = config
.getBoolean("schematic.specify_on_claim");
this.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("schematic.specify_on_claim");
this.SCHEMATICS = config.getStringList("schematic.schematics");
this.USE_ECONOMY = config.getBoolean("economy.use");
this.PLOT_PRICE = config.getDouble("economy.prices.claim");
@ -187,7 +175,7 @@ public abstract class PlotWorld {
this.DEFAULT_FLAGS = config.getStringList("flags.default");
loadConfiguration(config);
}
public abstract void loadConfiguration(ConfigurationSection config);
public void saveConfiguration(ConfigurationSection config) {
@ -195,22 +183,22 @@ public abstract class PlotWorld {
/*
* Saving core plotworld settings
*/
HashMap<String, Object> options = new HashMap<String, Object>();
options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT);
options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT);
options.put("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT.toString());
options.put("schematic.on_claim", PlotWorld.SCHEMATIC_ON_CLAIM_DEFAULT);
options.put("schematic.file", PlotWorld.SCHEMATIC_FILE_DEFAULT);
options.put("schematic.specify_on_claim", PlotWorld.SCHEMATIC_CLAIM_SPECIFY_DEFAULT);
options.put("schematic.schematics", PlotWorld.SCHEMATICS_DEFAULT);
options.put("economy.use", PlotWorld.USE_ECONOMY_DEFAULT);
options.put("economy.prices.claim", PlotWorld.PLOT_PRICE_DEFAULT);
options.put("economy.prices.merge", PlotWorld.MERGE_PRICE_DEFAULT);
options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT);
options.put("chat.enabled", PlotWorld.PLOT_CHAT_DEFAULT);
options.put("flags.default", PlotWorld.DEFAULT_FLAGS_DEFAULT);
HashMap<String, Object> options = new HashMap<String, Object>();
options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT);
options.put("plot.auto_merge", PlotWorld.AUTO_MERGE_DEFAULT);
options.put("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT.toString());
options.put("schematic.on_claim", PlotWorld.SCHEMATIC_ON_CLAIM_DEFAULT);
options.put("schematic.file", PlotWorld.SCHEMATIC_FILE_DEFAULT);
options.put("schematic.specify_on_claim", PlotWorld.SCHEMATIC_CLAIM_SPECIFY_DEFAULT);
options.put("schematic.schematics", PlotWorld.SCHEMATICS_DEFAULT);
options.put("economy.use", PlotWorld.USE_ECONOMY_DEFAULT);
options.put("economy.prices.claim", PlotWorld.PLOT_PRICE_DEFAULT);
options.put("economy.prices.merge", PlotWorld.MERGE_PRICE_DEFAULT);
options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT);
options.put("chat.enabled", PlotWorld.PLOT_CHAT_DEFAULT);
options.put("flags.default", PlotWorld.DEFAULT_FLAGS_DEFAULT);
ConfigurationNode[] settings = getSettingNodes();
@ -220,11 +208,11 @@ public abstract class PlotWorld {
for (ConfigurationNode setting : settings) {
options.put(setting.getConstant(), setting.getType().parseObject(setting.getValue()));
}
for (String option:options.keySet()) {
if (!config.contains(option)) {
config.set(option, options.get(option));
}
for (String option : options.keySet()) {
if (!config.contains(option)) {
config.set(option, options.get(option));
}
}
}
@ -237,4 +225,4 @@ public abstract class PlotWorld {
* @return ConfigurationNode[]
*/
public abstract ConfigurationNode[] getSettingNodes();
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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