No red files anymore. Some stuff still unfinished.

+ weekly code cleanup
This commit is contained in:
Jesse Boyd 2014-10-11 00:33:10 -07:00
parent 2f5f3ac8e2
commit a6375796c0
94 changed files with 14237 additions and 12908 deletions

View File

@ -18,7 +18,8 @@ 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

@ -21,31 +21,54 @@ 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 you will need to import this world. Otherwise you will need to add this world to the 'bukkit.yml' file (See installation tutorial for more info)"), SETUP_WORLD_TAKEN("&c%s is already a registered plotworld"), SETUP_MISSING_WORLD("&cYou need to specify a world name (&6/p setup {world}&c)\n&6Additional commands:\n&c - &6/p setup <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"),
SETUP_INIT("&6PlotSquared Setup -> Setup a new plotworld"), SETUP_STEP(
"&cStep &6%s&c: %s &c<Expecting: &6%s&c, Default: &6%s&c>"), SETUP_INVALID_ARG(
"&c%s is not a valid argument for step %s. To cancel setup use: /plot setup cancel"), SETUP_VALID_ARG(
"&cValue &6%s &cset for step %s"), SETUP_FINISHED(
"&cFinished setup for world &c%s.\n&4If you are using MULTIVERSE or MULTIWORLD you will need to import this world. Otherwise you will need to add this world to the 'bukkit.yml' file (See installation tutorial for more info)"), SETUP_WORLD_TAKEN(
"&c%s is already a registered plotworld"), SETUP_MISSING_WORLD(
"&cYou need to specify a world name (&6/p setup {world}&c)\n&6Additional commands:\n&c - &6/p setup <value>\n&c - &6/p setup back\n&c - &6/p setup cancel"),
/*
* Schematic Stuff
*/
SCHEMATIC_MISSING_ARG("&cYou need to specify an argument. Possible values: &6test {name}"), SCHEMATIC_INVALID("&cThat is not a valid schematic. Reason: &c%s"), SCHEMATIC_VALID("&cThat's a valid schematic"), SCHEMATIC_PASTE_FAILED("&cFailed to paste schematic"), SCHEMATIC_PASTE_SUCCESS("&cSchematic pasted successfully"),
SCHEMATIC_MISSING_ARG(
"&cYou need to specify an argument. Possible values: &6test {name}"), SCHEMATIC_INVALID(
"&cThat is not a valid schematic. Reason: &c%s"), SCHEMATIC_VALID(
"&cThat's a valid schematic"), SCHEMATIC_PASTE_FAILED(
"&cFailed to paste schematic"), SCHEMATIC_PASTE_SUCCESS(
"&cSchematic pasted successfully"),
/*
* Title Stuff
*/
TITLE_ENTERED_PLOT("You entered plot %s"), TITLE_ENTERED_PLOT_COLOR("GOLD"), TITLE_ENTERED_PLOT_SUB("Owned by %s"), TITLE_ENTERED_PLOT_SUB_COLOR("RED"), TITLE_LEFT_PLOT("You entered plot %s"), TITLE_LEFT_PLOT_COLOR("GOLD"), TITLE_LEFT_PLOT_SUB("Owned by %s"), TITLE_LEFT_PLOT_SUB_COLOR("RED"),
TITLE_ENTERED_PLOT("You entered plot %s"), TITLE_ENTERED_PLOT_COLOR("GOLD"), TITLE_ENTERED_PLOT_SUB(
"Owned by %s"), TITLE_ENTERED_PLOT_SUB_COLOR("RED"), TITLE_LEFT_PLOT(
"You entered plot %s"), TITLE_LEFT_PLOT_COLOR("GOLD"), TITLE_LEFT_PLOT_SUB(
"Owned by %s"), TITLE_LEFT_PLOT_SUB_COLOR("RED"),
/*
* Core Stuff
*/
PREFIX("&c[&6&lPlot&c] "), ENABLED("&6Plots are now enabled"), EXAMPLE_MESSAGE("&cThis is an example message &k!!!"),
PREFIX("&c[&6&lPlot&c] "), ENABLED("&6Plots are now enabled"), EXAMPLE_MESSAGE(
"&cThis is an example message &k!!!"),
/*
* Reload
*/
RELOADED_CONFIGS("&6The translation files has been reloaded"), RELOAD_FAILED("&cFailed to reload the translations file"),
RELOADED_CONFIGS("&6The translation files has been reloaded"), RELOAD_FAILED(
"&cFailed to reload the translations file"),
/*
* BarAPI
*/
@ -53,11 +76,16 @@ public enum C {
/*
* Alias
*/
ALIAS_SET_TO("&cPlot alias set to &6%alias%"), MISSING_ALIAS("&cYou need to specify the alias"), ALIAS_IS_TAKEN("&cThat alias is already taken"),
ALIAS_SET_TO("&cPlot alias set to &6%alias%"), MISSING_ALIAS(
"&cYou need to specify the alias"), ALIAS_IS_TAKEN(
"&cThat alias is already taken"),
/*
* Position
*/
MISSING_POSITION("&cYou need to specify a position. Possible values: &6default&c, &6center"), POSITION_SET("&cPlot home position set"), INVALID_POSITION("&cThat is not a valid position value"),
MISSING_POSITION(
"&cYou need to specify a position. Possible values: &6default&c, &6center"), POSITION_SET(
"&cPlot home position set"), INVALID_POSITION(
"&cThat is not a valid position value"),
/*
* Time
*/
@ -65,13 +93,23 @@ public enum C {
/*
* Permission
*/
NO_SCHEMATIC_PERMISSION("&cYou don't have the permission required to use schematic &6%s"), NO_PERMISSION("&cYou don't have the permissions required to use this command."), NO_PLOT_PERMS("&cYou don't have the permissions to do that in this plot"), CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."), YOU_BE_DENIED("&cYou are not allowed to enter this plot"),
NO_SCHEMATIC_PERMISSION(
"&cYou don't have the permission required to use schematic &6%s"), NO_PERMISSION(
"&cYou don't have the permissions required to use this command."), NO_PLOT_PERMS(
"&cYou don't have the permissions to do that in this plot"), CANT_CLAIM_MORE_PLOTS(
"&cYou can't claim more plots."), YOU_BE_DENIED(
"&cYou are not allowed to enter this plot"),
NO_PERM_MERGE("&cYou are not the owner of the plot: &6%plot%"), UNLINK_REQUIRED("&cAn unlink is required to do this."), UNLINK_IMPOSSIBLE("&cYou can only unlink a mega-plot"), NO_MERGE_TO_MEGA("&cMega plots cannot be merged into. Please merge from the desired mega plot."),
NO_PERM_MERGE("&cYou are not the owner of the plot: &6%plot%"), UNLINK_REQUIRED(
"&cAn unlink is required to do this."), UNLINK_IMPOSSIBLE(
"&cYou can only unlink a mega-plot"), NO_MERGE_TO_MEGA(
"&cMega plots cannot be merged into. Please merge from the desired mega plot."),
/*
* Commands
*/
NOT_VALID_SUBCOMMAND("&cThat is not a valid subcommand."), NO_COMMANDS("&cI'm sorry, but you're not permitted to use any subcommands."), SUBCOMMAND_SET_OPTIONS_HEADER("&cPossible Values: "),
NOT_VALID_SUBCOMMAND("&cThat is not a valid subcommand."), NO_COMMANDS(
"&cI'm sorry, but you're not permitted to use any subcommands."), SUBCOMMAND_SET_OPTIONS_HEADER(
"&cPossible Values: "),
/*
* Player not found
*/
@ -83,15 +121,22 @@ public enum C {
/*
* No {plot}
*/
NOT_IN_PLOT("&cYou're not in a plot"), NOT_IN_PLOT_WORLD("&cYou're not in a plot world"), NOT_VALID_WORLD("&cThat is not a valid world (case sensitive)"), NOT_VALID_PLOT_WORLD("&cThat is not a valid plot world (case sensitive)"), NO_PLOTS("&cYou don't have any plots"),
NOT_IN_PLOT("&cYou're not in a plot"), NOT_IN_PLOT_WORLD(
"&cYou're not in a plot world"), NOT_VALID_WORLD(
"&cThat is not a valid world (case sensitive)"), NOT_VALID_PLOT_WORLD(
"&cThat is not a valid plot world (case sensitive)"), NO_PLOTS(
"&cYou don't have any plots"),
/*
* Block List
*/
NOT_VALID_BLOCK_LIST_HEADER("&cThat's not a valid block. Valid blocks are:\\n"), BLOCK_LIST_ITEM(" &6%mat%&c,"), BLOCK_LIST_SEPARATER("&6,&c "),
NOT_VALID_BLOCK_LIST_HEADER(
"&cThat's not a valid block. Valid blocks are:\\n"), BLOCK_LIST_ITEM(
" &6%mat%&c,"), BLOCK_LIST_SEPARATER("&6,&c "),
/*
* Biome
*/
NEED_BIOME("&cYou've got to specify a biome"), BIOME_SET_TO("&cPlot biome set to &c"),
NEED_BIOME("&cYou've got to specify a biome"), BIOME_SET_TO(
"&cPlot biome set to &c"),
/*
* Teleport / Entry
*/
@ -103,39 +148,61 @@ public enum C {
/*
* Debug
*/
DEUBG_HEADER("&6Debug Information\\n"), DEBUG_SECTION("&c>> &6&l%val%"), DEBUG_LINE("&c>> &6%var%&c:&6 %val%\\n"),
DEUBG_HEADER("&6Debug Information\\n"), DEBUG_SECTION("&c>> &6&l%val%"), DEBUG_LINE(
"&c>> &6%var%&c:&6 %val%\\n"),
/*
* Invalid
*/
NOT_VALID_DATA("&cThat's not a valid data id."), NOT_VALID_BLOCK("&cThat's not a valid block."), NOT_VALID_NUMBER("&cThat's not a valid number"), NOT_VALID_PLOT_ID("&cThat's not a valid plot id."), NOT_YOUR_PLOT("&cThat is not your plot."), NO_SUCH_PLOT("&cThere is no such plot"), PLAYER_HAS_NOT_BEEN_ON("&cThat player hasn't been in the plotworld"), FOUND_NO_PLOTS("&cFound no plots with your search query"),
NOT_VALID_DATA("&cThat's not a valid data id."), NOT_VALID_BLOCK(
"&cThat's not a valid block."), NOT_VALID_NUMBER(
"&cThat's not a valid number"), NOT_VALID_PLOT_ID(
"&cThat's not a valid plot id."), NOT_YOUR_PLOT(
"&cThat is not your plot."), NO_SUCH_PLOT("&cThere is no such plot"), PLAYER_HAS_NOT_BEEN_ON(
"&cThat player hasn't been in the plotworld"), FOUND_NO_PLOTS(
"&cFound no plots with your search query"),
/*
* Camera
*/
CAMERA_STARTED("&cYou have entered camera mode for plot &6%s"), CAMERA_STOPPED("&cYou are no longer in camera mode"),
CAMERA_STARTED("&cYou have entered camera mode for plot &6%s"), CAMERA_STOPPED(
"&cYou are no longer in camera mode"),
/*
* Need
*/
NEED_PLOT_NUMBER("&cYou've got to specify a plot number or alias"), NEED_BLOCK("&cYou've got to specify a block"), NEED_PLOT_ID("&cYou've got to specify a plot id."), NEED_USER("&cYou need to specify a username"),
NEED_PLOT_NUMBER("&cYou've got to specify a plot number or alias"), NEED_BLOCK(
"&cYou've got to specify a block"), NEED_PLOT_ID(
"&cYou've got to specify a plot id."), NEED_USER(
"&cYou need to specify a username"),
/*
* Info
*/
PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"), PLOT_INFO("plot ID: &6%id%&c, plot Alias: &6%alias%&c, plot Owner: &6%owner%&c, plot Biome: &6%biome%&c, plot Time: &6%time%&c, plot Weather: &6%weather%&c, plot Helpers:&6%helpers%&c, plot Trusted:&6%trusted%&c, plot Denied:&6%denied%&c, plot Rating: &6%rating%, &cplot flags: &6%flags%"), PLOT_USER_LIST(" &6%user%&c,"),
PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"), PLOT_INFO(
"plot ID: &6%id%&c, plot Alias: &6%alias%&c, plot Owner: &6%owner%&c, plot Biome: &6%biome%&c, plot Time: &6%time%&c, plot Weather: &6%weather%&c, plot Helpers:&6%helpers%&c, plot Trusted:&6%trusted%&c, plot Denied:&6%denied%&c, plot Rating: &6%rating%, &cplot flags: &6%flags%"), PLOT_USER_LIST(
" &6%user%&c,"),
/*
* Generating
*/
GENERATING_FLOOR("&6Started generating floor from your settings. It will take %time%"), GENERATING_WALL("&6Started generating wall from your settings"), GENERATING_WALL_FILLING("&cStarted generating wall filling from your settings."),
GENERATING_FLOOR(
"&6Started generating floor from your settings. It will take %time%"), GENERATING_WALL(
"&6Started generating wall from your settings"), GENERATING_WALL_FILLING(
"&cStarted generating wall filling from your settings."),
/*
* Clearing
*/
CLEARING_PLOT("&cClearing plot."), CLEARING_DONE("&6Done, took &a%time%&6 ms!"), CLEARING_DONE_PACKETS("&6(&a%time% &6ms for packets)"),
CLEARING_PLOT("&cClearing plot."), CLEARING_DONE(
"&6Done, took &a%time%&6 ms!"), CLEARING_DONE_PACKETS(
"&6(&a%time% &6ms for packets)"),
/*
* Claiming
*/
PLOT_NOT_CLAIMED("&cCannot claim plot"), PLOT_IS_CLAIMED("&cThis plot is already claimed"), CLAIMED("&6You successfully claimed the plot"),
PLOT_NOT_CLAIMED("&cCannot claim plot"), PLOT_IS_CLAIMED(
"&cThis plot is already claimed"), CLAIMED(
"&6You successfully claimed the plot"),
/*
* List
*/
PLOT_LIST_HEADER("&6List of %word% plots"), PLOT_LIST_ITEM("&c>> &6%id% &c- &6%owner%"), PLOT_LIST_FOOTER("&c>> &6%word% a total of &c%num% &6claimed %plot%."),
PLOT_LIST_HEADER("&6List of %word% plots"), PLOT_LIST_ITEM(
"&c>> &6%id% &c- &6%owner%"), PLOT_LIST_FOOTER(
"&c>> &6%word% a total of &c%num% &6claimed %plot%."),
/*
* Left
*/
@ -143,7 +210,8 @@ public enum C {
/*
* Wait
*/
WAIT_FOR_TIMER("&cA setblock timer is bound to either the current plot or you. Please wait for it to finish"),
WAIT_FOR_TIMER(
"&cA setblock timer is bound to either the current plot or you. Please wait for it to finish"),
/*
* Chat
*/
@ -151,23 +219,40 @@ public enum C {
/*
* Denied
*/
DENIED_REMOVED("&cYou successfully undenied the player from this plot"), DENIED_ADDED("&cYou successfully denied the player from this plot"), DENIED_NEED_ARGUMENT("&cArguments are missing. &6/plot denied add {name} &cor &6/plot helpers remove {name}"), WAS_NOT_DENIED("&cThat player was not denied on this plot"),
DENIED_REMOVED("&cYou successfully undenied the player from this plot"), DENIED_ADDED(
"&cYou successfully denied the player from this plot"), DENIED_NEED_ARGUMENT(
"&cArguments are missing. &6/plot denied add {name} &cor &6/plot helpers remove {name}"), WAS_NOT_DENIED(
"&cThat player was not denied on this plot"),
/*
* Rain
*/
NEED_ON_OFF("&cYou need to specify a value. Possible values: &6on&c, &6off"), SETTING_UPDATED("&cYou successfully updated the setting"),
NEED_ON_OFF("&cYou need to specify a value. Possible values: &6on&c, &6off"), SETTING_UPDATED(
"&cYou successfully updated the setting"),
/*
* Flag
*/
NEED_KEY("&cPossible values: &6%values%"), NOT_VALID_FLAG("&cThat is not a valid flag"), NOT_VALID_VALUE("&cFlag values must be alphanumerical"), FLAG_NOT_IN_PLOT("&cThe plot does not have that flag"), FLAG_NOT_REMOVED("&cThe flag could not be removed"), FLAG_NOT_ADDED("&cThe flag could not be added"), FLAG_REMOVED("&6Successfully removed flag"), FLAG_ADDED("&6Successfully added flag"),
NEED_KEY("&cPossible values: &6%values%"), NOT_VALID_FLAG(
"&cThat is not a valid flag"), NOT_VALID_VALUE(
"&cFlag values must be alphanumerical"), FLAG_NOT_IN_PLOT(
"&cThe plot does not have that flag"), FLAG_NOT_REMOVED(
"&cThe flag could not be removed"), FLAG_NOT_ADDED(
"&cThe flag could not be added"), FLAG_REMOVED(
"&6Successfully removed flag"), FLAG_ADDED(
"&6Successfully added flag"),
/*
* Helper
*/
HELPER_ADDED("&6You successfully added a helper to the plot"), HELPER_REMOVED("&6You successfully removed a helper from the plot"), HELPER_NEED_ARGUMENT("&cArguments are missing. &6/plot helpers add {name} &cor &6/plot helpers remove {name}"), WAS_NOT_ADDED("&cThat player was not added as a helper on this plot"),
HELPER_ADDED("&6You successfully added a helper to the plot"), HELPER_REMOVED(
"&6You successfully removed a helper from the plot"), HELPER_NEED_ARGUMENT(
"&cArguments are missing. &6/plot helpers add {name} &cor &6/plot helpers remove {name}"), WAS_NOT_ADDED(
"&cThat player was not added as a helper on this plot"),
/*
* Trusted
*/
TRUSTED_ADDED("&6You successfully added a trusted user to the plot"), TRUSTED_REMOVED("&6You successfully removed a trusted user from the plot"), TRUSTED_NEED_ARGUMENT("&cArguments are missing. &6/plot trusted add {name} &cor &6/plot trusted remove {name}"), T_WAS_NOT_ADDED("&cThat player was not added as a trusted user on this plot"),
TRUSTED_ADDED("&6You successfully added a trusted user to the plot"), TRUSTED_REMOVED(
"&6You successfully removed a trusted user from the plot"), TRUSTED_NEED_ARGUMENT(
"&cArguments are missing. &6/plot trusted add {name} &cor &6/plot trusted remove {name}"), T_WAS_NOT_ADDED(
"&cThat player was not added as a trusted user on this plot"),
/*
* Set Owner
*/
@ -175,11 +260,16 @@ public enum C {
/*
* Signs
*/
OWNER_SIGN_LINE_1("&cID: &6%id%"), OWNER_SIGN_LINE_2("&cOwner:"), OWNER_SIGN_LINE_3("&6%plr%"), OWNER_SIGN_LINE_4("&2Claimed"),
OWNER_SIGN_LINE_1("&cID: &6%id%"), OWNER_SIGN_LINE_2("&cOwner:"), OWNER_SIGN_LINE_3(
"&6%plr%"), OWNER_SIGN_LINE_4("&2Claimed"),
/*
* Help
*/
HELP_CATEGORY("&6Current Category&c: &l%category%"), HELP_INFO("&6You need to specify a help category"), HELP_INFO_ITEM("&6/plots help %category% &c- &6%category_desc%"), HELP_PAGE("&c>> &6%usage% &c[&6%alias%&c] &c- &6%desc%"), HELP_HEADER("&6Help for Plots"),
HELP_CATEGORY("&6Current Category&c: &l%category%"), HELP_INFO(
"&6You need to specify a help category"), HELP_INFO_ITEM(
"&6/plots help %category% &c- &6%category_desc%"), HELP_PAGE(
"&c>> &6%usage% &c[&6%alias%&c] &c- &6%desc%"), HELP_HEADER(
"&6Help for Plots"),
/*
* Direction
*/

View File

@ -5,7 +5,6 @@ import java.util.List;
import org.bukkit.block.Biome;
public class Configuration {
public static final SettingValue STRING = new SettingValue("STRING") {
@Override
@ -125,7 +124,8 @@ 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]));
return new PlotBlock(Short.parseShort(split[0]),
Byte.parseByte(split[1]));
} else {
return new PlotBlock(Short.parseShort(string), (byte) 0);
}
@ -163,13 +163,16 @@ public class Configuration {
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]));
values[i] = new PlotBlock(Short.parseShort(split[0]),
Byte.parseByte(split[1]));
} else {
values[i] = new PlotBlock(Short.parseShort(string), (byte) 0);
values[i] = new PlotBlock(Short.parseShort(string),
(byte) 0);
}
}
return values;
}
@Override
public Object parseObject(Object object) {
List<String> list = new ArrayList<String>();
@ -182,7 +185,8 @@ public class Configuration {
/**
*
* Create your own SettingValue object to make the management of plotworld configuration easier
* Create your own SettingValue object to make the management of plotworld
* configuration easier
*
*/
public static abstract class SettingValue {

View File

@ -13,7 +13,8 @@ public class ConfigurationNode {
private Object value = 0;
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;
@ -25,6 +26,18 @@ public class ConfigurationNode {
return this.type.getType();
}
public boolean isValid(String string) {
try {
Object result = this.type.parseString(string);
if (result == null) {
return false;
}
return true;
} catch (Exception e) {
return false;
}
}
public boolean setValue(String string) {
if (!this.type.validateValue(string)) {
return false;

View File

@ -8,52 +8,64 @@ 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;
ConsoleColor(String lin) {
this.lin = lin;
this.win = win;
this.win = this.win;
}
public String getWin() {
return win;
return this.win;
}
public String getLin() {
return lin;
return this.lin;
}
}
/* public static final String ANSI_RESET = "\u001B[0m";
public static final String ANSI_BLACK = "\u001B[30m";
public static final String ANSI_RED = "\u001B[31m";
public static final String ANSI_GREEN = "\u001B[32m";
public static final String ANSI_YELLOW = "\u001B[33m";
public static final String ANSI_BLUE = "\u001B[34m";
public static final String ANSI_PURPLE = "\u001B[35m";
public static final String ANSI_CYAN = "\u001B[36m";
public static final String ANSI_WHITE = "\u001B[37m";
public static final String ANSI_BOLD = "\033[1m";
public static final String ANSI_UNDERLINE = "\033[0m";
public static final String ANSI_ITALIC = "\033[3m]";*/
/*
* public static final String ANSI_RESET = "\u001B[0m"; public static final
* String ANSI_BLACK = "\u001B[30m"; public static final String ANSI_RED =
* "\u001B[31m"; public static final String ANSI_GREEN = "\u001B[32m";
* public static final String ANSI_YELLOW = "\u001B[33m"; public static
* final String ANSI_BLUE = "\u001B[34m"; public static final String
* ANSI_PURPLE = "\u001B[35m"; public static final String ANSI_CYAN =
* "\u001B[36m"; public static final String ANSI_WHITE = "\u001B[37m";
* public static final String ANSI_BOLD = "\033[1m"; public static final
* String ANSI_UNDERLINE = "\033[0m"; public static final String ANSI_ITALIC
* = "\033[3m]";
*/
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 + ConsoleColor.RESET.toString();
}

View File

@ -78,7 +78,8 @@ 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

@ -79,6 +79,19 @@ public class FlagManager {
return flags.remove(flag);
}
public static Flag[] parseFlags(List<String> flagstrings) {
Flag[] flags = new Flag[flagstrings.size()];
for (int i = 0; i < flagstrings.size(); i++) {
String[] split = flagstrings.get(i).split(";");
if (split.length == 1) {
flags[i] = new Flag(getFlag(split[0], true), "");
} else {
flags[i] = new Flag(getFlag(split[0], true), split[1]);
}
}
return flags;
}
/**
* Get the flags for a plot
*

View File

@ -111,7 +111,9 @@ public class LSetCube {
* @return
*/
public boolean hasNext() {
return ((this.current.getBlockX() + 1) <= this.max.getBlockX()) && ((this.current.getBlockY() + 1) <= this.max.getBlockY()) && ((this.current.getBlockZ() + 1) <= this.max.getBlockZ());
return ((this.current.getBlockX() + 1) <= this.max.getBlockX())
&& ((this.current.getBlockY() + 1) <= this.max.getBlockY())
&& ((this.current.getBlockZ() + 1) <= this.max.getBlockZ());
}
/**

View File

@ -37,7 +37,8 @@ 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

@ -39,7 +39,8 @@ public class Logger {
}
reader.close();
} catch (IOException e) {
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "File setup error Logger#setup");
PlotMain.sendConsoleSenderMessage(C.PREFIX.s()
+ "File setup error Logger#setup");
}
}

View File

@ -79,7 +79,8 @@ 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
*/
@ -112,14 +113,16 @@ 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
@ -182,18 +185,22 @@ public class Metrics {
return true;
}
// Begin hitting the server with glorious data
this.task = this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, new Runnable() {
this.task = this.plugin.getServer().getScheduler()
.runTaskTimerAsynchronously(this.plugin, new Runnable() {
private boolean firstPost = true;
@Override
public void run() {
try {
// This has to be synchronized or it can collide with
// 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
// Disable Task, if it is running and the
// server
// owner decided to opt-out
if (isOptOut() && (Metrics.this.task != null)) {
if (isOptOut()
&& (Metrics.this.task != null)) {
Metrics.this.task.cancel();
Metrics.this.task = null;
// Tell all plotters to stop gathering
@ -203,18 +210,23 @@ public class Metrics {
}
}
}
// We use the inverse of firstPost because if it is the
// We use the inverse of firstPost because if it
// is the
// first time we are posting,
// it is not a interval ping, so it evaluates to FALSE
// Each time thereafter it will evaluate to TRUE, i.e
// 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
// 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());
Bukkit.getLogger().log(Level.INFO,
"[Metrics] " + e.getMessage());
}
}
}
@ -235,12 +247,14 @@ public class Metrics {
this.configuration.load(getConfigFile());
} 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) {
if (this.debug) {
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
Bukkit.getLogger().log(Level.INFO,
"[Metrics] " + ex.getMessage());
}
return true;
}
@ -321,8 +335,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;
@ -372,7 +388,8 @@ 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) {
@ -389,7 +406,8 @@ 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
@ -405,33 +423,40 @@ 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);
response = response
.substring(response.startsWith("7,") ? 2 : 1);
}
throw new IOException(response);
} 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()) {
@ -493,7 +518,8 @@ 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")) {
@ -565,7 +591,8 @@ 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");
}
@ -711,7 +738,8 @@ 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

@ -33,7 +33,10 @@ 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);
@ -46,13 +49,17 @@ public class PWE {
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;
@ -63,10 +70,13 @@ 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) {
// throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
// throw new
// PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY,
// "WorldEdit == Null?");
}
}
@ -98,7 +108,9 @@ public class PWE {
}
removeMask(p, s);
} catch (Exception e) {
// throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
// throw new
// PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY,
// "WorldEdit == Null?");
}
}
}

View File

@ -56,7 +56,8 @@ 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++) {
@ -69,20 +70,32 @@ 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;
}
@ -118,7 +131,8 @@ public class PlayerFunctions {
* @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);
}
/**
@ -150,7 +164,8 @@ 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());
}
@ -237,7 +252,8 @@ 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

@ -78,7 +78,8 @@ 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);
@ -109,7 +110,11 @@ 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);
@ -158,7 +163,17 @@ public class Plot implements Cloneable {
* @return true if the player is added as a helper or is the owner
*/
public boolean hasRights(Player player) {
return player.hasPermission("plots.admin") || ((this.helpers != null) && this.helpers.contains(DBFunc.everyone)) || ((this.helpers != null) && this.helpers.contains(player.getUniqueId())) || ((this.owner != null) && this.owner.equals(player.getUniqueId())) || ((this.owner != null) && (this.trusted != null) && (Bukkit.getPlayer(this.owner) != null) && (this.trusted.contains(player.getUniqueId()) || this.trusted.contains(DBFunc.everyone)));
return player.hasPermission("plots.admin")
|| ((this.helpers != null) && this.helpers
.contains(DBFunc.everyone))
|| ((this.helpers != null) && this.helpers.contains(player
.getUniqueId()))
|| ((this.owner != null) && this.owner.equals(player
.getUniqueId()))
|| ((this.owner != null) && (this.trusted != null)
&& (Bukkit.getPlayer(this.owner) != null) && (this.trusted
.contains(player.getUniqueId()) || this.trusted
.contains(DBFunc.everyone)));
}
/**
@ -168,7 +183,10 @@ public class Plot implements Cloneable {
* @return false if the player is allowed to enter
*/
public boolean deny_entry(Player player) {
return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.hasRights(player)) || (!this.hasRights(player) && this.denied.contains(player.getUniqueId())));
return (this.denied != null)
&& ((this.denied.contains(DBFunc.everyone) && !this
.hasRights(player)) || (!this.hasRights(player) && this.denied
.contains(player.getUniqueId())));
}
/**

View File

@ -3,6 +3,7 @@ package com.intellectualcrafters.plot;
public class PlotBlock {
public short id;
public byte data;
public PlotBlock(short id, byte data) {
this.id = id;
this.data = data;

View File

@ -9,11 +9,19 @@
package com.intellectualcrafters.plot;
import com.intellectualcrafters.plot.database.DBFunc;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
@ -21,8 +29,7 @@ import org.bukkit.block.Sign;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.io.File;
import java.util.*;
import com.intellectualcrafters.plot.database.DBFunc;
/**
* plot functions
@ -34,10 +41,6 @@ public class PlotHelper {
public static boolean canSetFast = false;
static long state = 1;
private static double calculateNeededTime(double blocks, double blocks_per_second) {
return (blocks / blocks_per_second);
}
/**
* direction 0 = north, 1 = south, etc:
*
@ -59,14 +62,16 @@ 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);
@ -111,12 +116,14 @@ 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.createRoadSouthEast(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);
@ -124,7 +131,8 @@ 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);
@ -209,9 +217,12 @@ 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);
}
@ -236,9 +247,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) {
canSetFast = false;
@ -249,23 +263,21 @@ 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);
}
}
}
public static void adjustWall(Player player, World w, Plot plot, short id, byte data) {
public static void adjustWall(Player player, Plot plot, PlotBlock block) {
World world = player.getWorld();
PlotManager manager = PlotMain.getPlotManager(world);
PlotWorld plotworld = PlotMain.getWorldSettings(world);
manager.setWall(player, plotworld, plot.id, new PlotBlock(id,data));
manager.setWall(player, plotworld, plot.id, block);
}
public static void autoMerge(World world, Plot plot, Player player) {
@ -285,25 +297,29 @@ 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);
@ -315,20 +331,24 @@ public class PlotHelper {
}
}
private static boolean ownsPlots(World world, ArrayList<PlotId> plots, Player player, int dir) {
private static boolean ownsPlots(World world, ArrayList<PlotId> plots,
Player player, int dir) {
PlotId id_min = plots.get(0);
PlotId id_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;
}
}
@ -337,7 +357,9 @@ 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);
@ -536,7 +558,8 @@ 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 World w, 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;
@ -550,7 +573,8 @@ 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;
@ -571,7 +595,8 @@ 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 };
}
@ -580,13 +605,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);
PlotMain.teleportPlayer((Player) entity,
entity.getLocation(), plot);
} else {
entity.remove();
}
@ -623,7 +650,8 @@ 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;
@ -639,7 +667,10 @@ 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);
@ -647,7 +678,8 @@ 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++) {
@ -655,8 +687,10 @@ 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);
}
}
}
@ -669,8 +703,10 @@ 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);
}
}
}
@ -680,7 +716,8 @@ public class PlotHelper {
}
}
public static void setSimpleCuboid(World world, Location pos1, Location pos2, PlotBlock newblock) {
public static void setSimpleCuboid(World world, Location pos1,
Location pos2, PlotBlock newblock) {
if (!canSetFast) {
for (int y = pos1.getBlockY(); y < pos2.getBlockY(); y++) {
for (int x = pos1.getBlockX(); x < pos2.getBlockX(); x++) {
@ -699,7 +736,8 @@ public class PlotHelper {
for (int z = pos1.getBlockZ(); z < pos2.getBlockZ(); z++) {
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);
}
}
}
@ -730,7 +768,9 @@ 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);
@ -782,6 +822,11 @@ public class PlotHelper {
return manager.getPlotBottomLocAbs(plotworld, id);
}
public static int getPlotWidth(World world, PlotId id) {
return getPlotTopLoc(world, id).getBlockX()
- getPlotBottomLoc(world, id).getBlockX();
}
public static Location getPlotTopLoc(World world, PlotId id) {
Plot plot = PlotMain.getPlots(world).get(id);
if (plot != null) {
@ -809,7 +854,8 @@ 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) {
@ -820,6 +866,7 @@ 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

@ -123,7 +123,8 @@ public class PlotMain extends JavaPlugin {
@SuppressWarnings("deprecation")
public static void checkForExpiredPlots() {
final JavaPlugin plugin = PlotMain.getMain();
Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin,
new Runnable() {
@Override
public void run() {
checkExpired(plugin, true);
@ -269,7 +270,6 @@ public class PlotMain extends JavaPlugin {
* @return
*/
public static Set<Plot> getPlots(World world, Player player) {
int i = 0;
UUID uuid = player.getUniqueId();
ArrayList<Plot> myplots = new ArrayList<Plot>();
for (Plot plot : getPlots(world).values()) {
@ -404,8 +404,8 @@ 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
* 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
@ -441,8 +441,10 @@ 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 {
@ -459,8 +461,10 @@ public class PlotMain extends JavaPlugin {
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 {
@ -474,15 +478,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) {
@ -495,7 +503,8 @@ 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"));
}
/**
@ -508,8 +517,10 @@ 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;
}
@ -522,7 +533,8 @@ public class PlotMain extends JavaPlugin {
metrics.start();
sendConsoleSenderMessage(C.PREFIX.s() + "&6Metrics enabled.");
} catch (Exception e) {
sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to load up metrics.");
sendConsoleSenderMessage(C.PREFIX.s()
+ "&cFailed to load up metrics.");
}
}
@ -535,7 +547,9 @@ public class PlotMain extends JavaPlugin {
}
if (Settings.DB.USE_MYSQL) {
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();
@ -546,9 +560,9 @@ public class PlotMain extends JavaPlugin {
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);
}
@ -557,8 +571,10 @@ public class PlotMain extends JavaPlugin {
}
} 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;
@ -566,10 +582,12 @@ public class PlotMain extends JavaPlugin {
plots = DBFunc.getPlots();
} else if (Settings.DB.USE_MONGO) {
sendConsoleSenderMessage(C.PREFIX.s() + "MongoDB is not yet implemented");
sendConsoleSenderMessage(C.PREFIX.s()
+ "MongoDB is not yet implemented");
} else if (Settings.DB.USE_SQLITE) {
try {
connection = new SQLite(this, Settings.DB.SQLITE_DB + ".db").openConnection();
connection = new SQLite(this, Settings.DB.SQLITE_DB + ".db")
.openConnection();
{
DatabaseMetaData meta = connection.getMetaData();
ResultSet res = meta.getTables(null, null, "plot", null);
@ -579,9 +597,9 @@ public class PlotMain extends JavaPlugin {
res = meta.getTables(null, null, "plot_trusted", null);
if (!res.next()) {
DBFunc.createTables("sqlite", false);
}
else {
res = meta.getTables(null, null, "plot_ratings", null);
} else {
res = meta.getTables(null, null, "plot_ratings",
null);
if (!res.next()) {
DBFunc.createTables("sqlite", false);
}
@ -590,7 +608,8 @@ public class PlotMain extends JavaPlugin {
}
} 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(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);
@ -629,17 +648,22 @@ 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) {
@ -647,16 +671,20 @@ 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 {
@ -708,18 +736,28 @@ public class PlotMain extends JavaPlugin {
*/
public static void sendConsoleSenderMessage(String string) {
if (getMain().getServer().getConsoleSender() == null) {
System.out.println(ChatColor.stripColor(ConsoleColors.fromString(string)));
System.out.println(ChatColor.stripColor(ConsoleColors
.fromString(string)));
} else {
getMain().getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', string));
getMain()
.getServer()
.getConsoleSender()
.sendMessage(
ChatColor.translateAlternateColorCodes('&', string));
}
}
public static boolean teleportPlayer(Player player, Location from, Plot plot) {
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;
}
@ -747,7 +785,8 @@ 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()));
}
/**
@ -771,7 +810,8 @@ 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 {
@ -783,7 +823,8 @@ 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();
@ -794,12 +835,15 @@ 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.");
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();
}
@ -810,7 +854,8 @@ public class PlotMain extends JavaPlugin {
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();
}
@ -821,11 +866,14 @@ public class PlotMain extends JavaPlugin {
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) {
Logger.add(LogLevel.DANGER, "Failed to save translations.yml");
@ -871,7 +919,9 @@ public class PlotMain extends JavaPlugin {
settings.put("Auto Clear Enabled", "" + Settings.AUTO_CLEAR);
settings.put("Auto Clear 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()));
sendConsoleSenderMessage(C.PREFIX.s()
+ String.format("&cKey: &6%s&c, Value: &6%s",
setting.getKey(), setting.getValue()));
}
}
}
@ -881,23 +931,27 @@ public class PlotMain extends JavaPlugin {
*/
@SuppressWarnings("deprecation")
public static void killAllEntities() {
Bukkit.getScheduler().scheduleAsyncRepeatingTask(getMain(), new Runnable() {
Bukkit.getScheduler().scheduleAsyncRepeatingTask(getMain(),
new Runnable() {
Location location;
long ticked = 0l;
long error = 0l;
{
sendConsoleSenderMessage(C.PREFIX.s() + "KillAllEntities started.");
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);
sendConsoleSenderMessage(C.PREFIX.s()
+ "KillAllEntities has been running for 60 minutes. Errors: "
+ this.error);
this.error = 0l;
}
for (String w : getPlotWorlds()) {
PlotWorld plotworld = getWorldSettings(w);
getWorldSettings(w);
World world = Bukkit.getServer().getWorld(w);
try {
if (world.getLoadedChunks().length < 1) {
@ -908,8 +962,10 @@ public class PlotMain extends JavaPlugin {
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)) {
this.location = entity
.getLocation();
if (!PlayerEvents
.isInPlot(this.location)) {
boolean tamed = false;
if (Settings.MOB_PATHFINDING) {
if (entity instanceof Tameable) {
@ -919,7 +975,8 @@ public class PlotMain extends JavaPlugin {
}
} else if (entity instanceof LivingEntity) {
LivingEntity livingEntity = ((LivingEntity) entity);
if (livingEntity.getCustomName() != null) {
if (livingEntity
.getCustomName() != null) {
tamed = true;
}
}
@ -927,26 +984,48 @@ public class PlotMain extends JavaPlugin {
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)) {
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);
pos = new Location(
world,
x
+ radius,
y, z);
dir++;
break;
case 1:
pos = new Location(world, x, y, z + radius);
pos = new Location(
world,
x,
y,
z
+ radius);
dir++;
break;
case 2:
pos = new Location(world, x - radius, y, z);
pos = new Location(
world,
x
- radius,
y, z);
dir++;
break;
case 3:
pos = new Location(world, x, y, z - radius);
pos = new Location(
world,
x,
y,
z
- radius);
dir = 0;
radius++;
break;
@ -955,15 +1034,25 @@ public class PlotMain extends JavaPlugin {
break;
}
if (PlayerEvents.isInPlot(pos)) {
entity.teleport(pos.add(0.5, 0, 0.5));
if (PlayerEvents
.isInPlot(pos)) {
entity.teleport(pos
.add(0.5,
0,
0.5));
found = true;
break;
}
}
// Welp! how did this entity get
// Welp! how did this
// entity get
// here?
entity.teleport(this.location.subtract(this.location.getDirection().normalize().multiply(2)));
entity.teleport(this.location
.subtract(this.location
.getDirection()
.normalize()
.multiply(
2)));
}
}
if (!tamed) {
@ -1008,7 +1097,8 @@ 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");
@ -1022,7 +1112,6 @@ public class PlotMain extends JavaPlugin {
}
public static void createConfiguration(PlotWorld plotworld) {
String w = plotworld.worldname;
Map<String, Object> options = new HashMap<String, Object>();
for (ConfigurationNode setting : plotworld.getSettingNodes()) {
@ -1044,9 +1133,10 @@ public class PlotMain extends JavaPlugin {
}
/**
* Adds an external world as a recognized PlotSquared world
* - The PlotWorld class created is based off the configuration in the settings.yml
* - Do not use this method unless the required world is preconfigured in the settings.yml
* Adds an external world as a recognized PlotSquared world - The PlotWorld
* class created is based off the configuration in the settings.yml - Do not
* use this method unless the required world is preconfigured in the
* settings.yml
*
* @param world
*/
@ -1057,13 +1147,13 @@ public class PlotMain extends JavaPlugin {
Set<String> worlds;
if (config.contains("worlds")) {
worlds = config.getConfigurationSection("worlds").getKeys(false);
}
else {
} else {
worlds = new HashSet<String>();
}
ChunkGenerator generator = world.getGenerator();
if (generator instanceof PlotGenerator) {
sendConsoleSenderMessage(C.PREFIX.s()+"&aDetected world load for '"+world.getName()+"'.");
sendConsoleSenderMessage(C.PREFIX.s()
+ "&aDetected world load for '" + world.getName() + "'.");
PlotGenerator plotgen = (PlotGenerator) generator;
PlotWorld plotworld = plotgen.getPlotWorld();
@ -1072,17 +1162,19 @@ public class PlotMain extends JavaPlugin {
config.createSection("worlds." + world.getName());
plotworld.saveConfiguration(config.getConfigurationSection("worlds."+world.getName()));
plotworld.saveConfiguration(config
.getConfigurationSection("worlds." + world.getName()));
plotworld.loadConfiguration(config.getConfigurationSection("worlds."+world.getName()));
plotworld.loadConfiguration(config
.getConfigurationSection("worlds." + world.getName()));
addPlotWorld(world.getName(), plotworld, manager);
}
else {
} else {
if (worlds.contains(world.getName())) {
sendConsoleSenderMessage("&cWorld '" + world.getName() + "' in settings.yml is not using PlotSquared generator!");
sendConsoleSenderMessage("&cWorld '"
+ world.getName()
+ "' in settings.yml is not using PlotSquared generator!");
}
}
}
@ -1146,7 +1238,8 @@ public class PlotMain extends JavaPlugin {
*/
}
public static void addPlotWorld(String world, PlotWorld plotworld, PlotManager manager) {
public static void addPlotWorld(String world, PlotWorld plotworld,
PlotManager manager) {
worlds.put(world, plotworld);
managers.put(world, manager);
if (!plots.containsKey(world)) {

View File

@ -5,7 +5,6 @@ import java.util.ArrayList;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
public abstract class PlotManager {
@ -19,30 +18,35 @@ 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);
/*
* Plot clearing (return false if you do not support some method)
*
*
*/
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);
@ -62,6 +66,7 @@ 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

@ -7,7 +7,8 @@ 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

@ -1,12 +1,124 @@
package com.intellectualcrafters.plot;
import static org.bukkit.Material.ACACIA_STAIRS;
import static org.bukkit.Material.BEACON;
import static org.bukkit.Material.BEDROCK;
import static org.bukkit.Material.BIRCH_WOOD_STAIRS;
import static org.bukkit.Material.BOOKSHELF;
import static org.bukkit.Material.BREWING_STAND;
import static org.bukkit.Material.BRICK;
import static org.bukkit.Material.BRICK_STAIRS;
import static org.bukkit.Material.BURNING_FURNACE;
import static org.bukkit.Material.CAKE_BLOCK;
import static org.bukkit.Material.CAULDRON;
import static org.bukkit.Material.CLAY;
import static org.bukkit.Material.CLAY_BRICK;
import static org.bukkit.Material.COAL_BLOCK;
import static org.bukkit.Material.COAL_ORE;
import static org.bukkit.Material.COBBLESTONE;
import static org.bukkit.Material.COBBLESTONE_STAIRS;
import static org.bukkit.Material.COBBLE_WALL;
import static org.bukkit.Material.COMMAND;
import static org.bukkit.Material.DARK_OAK_STAIRS;
import static org.bukkit.Material.DAYLIGHT_DETECTOR;
import static org.bukkit.Material.DIAMOND_BLOCK;
import static org.bukkit.Material.DIAMOND_ORE;
import static org.bukkit.Material.DIRT;
import static org.bukkit.Material.DISPENSER;
import static org.bukkit.Material.DROPPER;
import static org.bukkit.Material.EMERALD_BLOCK;
import static org.bukkit.Material.EMERALD_ORE;
import static org.bukkit.Material.ENCHANTMENT_TABLE;
import static org.bukkit.Material.ENDER_PORTAL_FRAME;
import static org.bukkit.Material.ENDER_STONE;
import static org.bukkit.Material.FURNACE;
import static org.bukkit.Material.GLASS;
import static org.bukkit.Material.GLOWSTONE;
import static org.bukkit.Material.GOLD_BLOCK;
import static org.bukkit.Material.GOLD_ORE;
import static org.bukkit.Material.GRASS;
import static org.bukkit.Material.GRAVEL;
import static org.bukkit.Material.HARD_CLAY;
import static org.bukkit.Material.HAY_BLOCK;
import static org.bukkit.Material.HUGE_MUSHROOM_1;
import static org.bukkit.Material.HUGE_MUSHROOM_2;
import static org.bukkit.Material.IRON_BLOCK;
import static org.bukkit.Material.IRON_ORE;
import static org.bukkit.Material.JACK_O_LANTERN;
import static org.bukkit.Material.JUKEBOX;
import static org.bukkit.Material.JUNGLE_WOOD_STAIRS;
import static org.bukkit.Material.LAPIS_BLOCK;
import static org.bukkit.Material.LAPIS_ORE;
import static org.bukkit.Material.LEAVES;
import static org.bukkit.Material.LEAVES_2;
import static org.bukkit.Material.LOG;
import static org.bukkit.Material.LOG_2;
import static org.bukkit.Material.MELON_BLOCK;
import static org.bukkit.Material.MOB_SPAWNER;
import static org.bukkit.Material.MOSSY_COBBLESTONE;
import static org.bukkit.Material.MYCEL;
import static org.bukkit.Material.NETHERRACK;
import static org.bukkit.Material.NETHER_BRICK;
import static org.bukkit.Material.NETHER_BRICK_STAIRS;
import static org.bukkit.Material.NOTE_BLOCK;
import static org.bukkit.Material.OBSIDIAN;
import static org.bukkit.Material.PACKED_ICE;
import static org.bukkit.Material.PUMPKIN;
import static org.bukkit.Material.QUARTZ_BLOCK;
import static org.bukkit.Material.QUARTZ_ORE;
import static org.bukkit.Material.QUARTZ_STAIRS;
import static org.bukkit.Material.REDSTONE_BLOCK;
import static org.bukkit.Material.SAND;
import static org.bukkit.Material.SANDSTONE;
import static org.bukkit.Material.SANDSTONE_STAIRS;
import static org.bukkit.Material.SMOOTH_BRICK;
import static org.bukkit.Material.SMOOTH_STAIRS;
import static org.bukkit.Material.SNOW_BLOCK;
import static org.bukkit.Material.SOUL_SAND;
import static org.bukkit.Material.SPONGE;
import static org.bukkit.Material.SPRUCE_WOOD_STAIRS;
import static org.bukkit.Material.STONE;
import static org.bukkit.Material.WOOD;
import static org.bukkit.Material.WOOD_STAIRS;
import static org.bukkit.Material.WOOL;
import static org.bukkit.Material.WORKBENCH;
import static org.bukkit.Material.getMaterial;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.configuration.ConfigurationSection;
public abstract class PlotWorld {
// TODO make this configurable
// make non static and static_default_valu + add config option
public static ArrayList<Material> BLOCKS = new ArrayList<Material>(
Arrays.asList(new Material[] { ACACIA_STAIRS, BEACON, BEDROCK,
BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK,
BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON,
CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL,
COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS,
DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT,
DISPENSER, DROPPER, EMERALD_BLOCK, EMERALD_ORE,
ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME, ENDER_STONE,
FURNACE, GLOWSTONE, GOLD_ORE, GOLD_BLOCK, GRASS, GRAVEL,
GLASS, HARD_CLAY, HAY_BLOCK, HUGE_MUSHROOM_1,
HUGE_MUSHROOM_2, IRON_BLOCK, IRON_ORE, JACK_O_LANTERN,
JUKEBOX, JUNGLE_WOOD_STAIRS, LAPIS_BLOCK, LAPIS_ORE,
LEAVES, LEAVES_2, LOG, LOG_2, MELON_BLOCK, MOB_SPAWNER,
MOSSY_COBBLESTONE, MYCEL, NETHER_BRICK,
NETHER_BRICK_STAIRS, NETHERRACK, NOTE_BLOCK, OBSIDIAN,
PACKED_ICE, PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE,
QUARTZ_STAIRS, REDSTONE_BLOCK, SANDSTONE, SAND,
SANDSTONE_STAIRS, SMOOTH_BRICK, SMOOTH_STAIRS, SNOW_BLOCK,
SOUL_SAND, SPONGE, SPRUCE_WOOD_STAIRS, STONE, WOOD,
WOOD_STAIRS, WORKBENCH, WOOL, getMaterial(44),
getMaterial(126) }));
public boolean AUTO_MERGE;
public static boolean AUTO_MERGE_DEFAULT = false;
@ -43,13 +155,17 @@ public abstract class PlotWorld {
public double MERGE_PRICE;
public static double MERGE_PRICE_DEFAULT = 100;
public double SELL_PRICE;
public static double SELL_PRICE_DEFAULT = 75;
public PlotWorld(String worldname) {
this.worldname = worldname;
}
/**
* When a world is created, the following method will be called for each node set in the configuration
* - You may ignore this if you generator does not support configuration, or if you want to implement your own methods
* When a world is created, the following method will be called for each
* node set in the configuration - You may ignore this if you generator does
* not support configuration, or if you want to implement your own methods
*
* @param key
* @param value
@ -57,14 +173,17 @@ public abstract class PlotWorld {
public void loadConfiguration(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");
this.MERGE_PRICE = config.getDouble("economy.prices.merge");
this.SELL_PRICE = config.getDouble("economy.prices.sell");
this.PLOT_CHAT = config.getBoolean("chat.enabled");
this.DEFAULT_FLAGS = config.getStringList("flags.default");
}
@ -84,6 +203,7 @@ public abstract class PlotWorld {
config.set("economy.use", this.USE_ECONOMY);
config.set("economy.prices.claim", this.PLOT_PRICE);
config.set("economy.prices.merge", this.MERGE_PRICE);
config.set("economy.prices.sell", this.SELL_PRICE);
config.set("chat.enabled", this.PLOT_CHAT);
config.set("flags.default", this.DEFAULT_FLAGS);
@ -100,8 +220,8 @@ public abstract class PlotWorld {
public String worldname;
/**
* Used for the <b>/plot setup</b> command
* Return null if you do not want to support this feature
* Used for the <b>/plot setup</b> command Return null if you do not want to
* support this feature
*
* @return ConfigurationNode[]
*/

View File

@ -43,7 +43,8 @@ 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 {

View File

@ -27,7 +27,8 @@ 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();
@ -38,7 +39,8 @@ 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("\\.");
@ -71,7 +73,9 @@ 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) {
}
@ -131,7 +135,8 @@ 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;
@ -147,7 +152,8 @@ public class ReflectionUtils {
try {
return new RefMethod(this.clazz.getMethod(name, classes));
} catch (NoSuchMethodException ignored) {
return new RefMethod(this.clazz.getDeclaredMethod(name, classes));
return new RefMethod(this.clazz.getDeclaredMethod(name,
classes));
}
} catch (Exception e) {
throw new RuntimeException(e);
@ -177,9 +183,11 @@ public class ReflectionUtils {
}
}
try {
return new RefConstructor(this.clazz.getConstructor(classes));
return new RefConstructor(
this.clazz.getConstructor(classes));
} catch (NoSuchMethodException ignored) {
return new RefConstructor(this.clazz.getDeclaredConstructor(classes));
return new RefConstructor(
this.clazz.getDeclaredConstructor(classes));
}
} catch (Exception e) {
throw new RuntimeException(e);
@ -297,7 +305,8 @@ 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);

View File

@ -31,9 +31,12 @@ 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;
@ -48,27 +51,35 @@ 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();
@ -114,7 +125,8 @@ 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

@ -27,12 +27,15 @@ 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);
@ -45,7 +48,9 @@ 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

@ -83,6 +83,7 @@ public class Settings {
public static class DB {
public static boolean USE_MONGO = false; /*
* TODO: Implement Mongo
*
* @Brandon
*/;
public static boolean USE_SQLITE = false;

View File

@ -80,7 +80,8 @@ 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;
@ -169,29 +170,56 @@ 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:" + this.titleColor.name().toLowerCase() + "}");
packet = this.packetTitle.getConstructor(this.packetActions, getNMSClass("IChatBaseComponent")).newInstance(actions[0], serialized);
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);
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) {
@ -220,10 +248,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) {
e.printStackTrace();
@ -242,10 +273,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) {
e.printStackTrace();
@ -264,9 +298,11 @@ 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) {
@ -310,7 +346,8 @@ 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) {
@ -343,7 +380,8 @@ public class Title {
}
}
private Method getMethod(String name, Class<?> clazz, Class<?>... paramTypes) {
private Method getMethod(String name, Class<?> clazz,
Class<?>... paramTypes) {
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
for (Method m : clazz.getMethods()) {
Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes());
@ -383,7 +421,9 @@ 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

@ -1,18 +1,19 @@
package com.intellectualcrafters.plot;
import com.google.common.base.Charsets;
import com.intellectualcrafters.plot.uuid.NameFetcher;
import com.intellectualcrafters.plot.uuid.UUIDFetcher;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Arrays;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.base.Charsets;
import com.intellectualcrafters.plot.uuid.NameFetcher;
import com.intellectualcrafters.plot.uuid.UUIDFetcher;
public class UUIDHandler {
private static ConcurrentHashMap<String, UUID> uuidMap = new ConcurrentHashMap<>();
@ -34,10 +35,12 @@ public class UUIDHandler {
* @param plugin
*/
public static void startFetch(JavaPlugin plugin) {
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
plugin.getServer().getScheduler()
.runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
OfflinePlayer[] offlinePlayers = Bukkit.getOfflinePlayers();
OfflinePlayer[] offlinePlayers = Bukkit
.getOfflinePlayers();
int lenght = offlinePlayers.length;
long start = System.currentTimeMillis();
@ -46,13 +49,19 @@ public class UUIDHandler {
for (OfflinePlayer player : offlinePlayers) {
name = player.getName();
uuid = player.getUniqueId();
if(!uuidExists(uuid))
if (!uuidExists(uuid)) {
add(name, uuid);
}
}
long time = System.currentTimeMillis() - start;
PlotMain.sendConsoleSenderMessage("&cFinished caching of offlineplayers! Took &6" + time + "&cms, &6" + lenght + " &cUUID's were cached" +
" and there is now a grand total of &6" + uuidMap.size() + " &ccached.");
PlotMain.sendConsoleSenderMessage("&cFinished caching of offlineplayers! Took &6"
+ time
+ "&cms, &6"
+ lenght
+ " &cUUID's were cached"
+ " and there is now a grand total of &6"
+ uuidMap.size() + " &ccached.");
}
});
}
@ -138,7 +147,8 @@ public class UUIDHandler {
* @return
*/
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;
}

View File

@ -149,7 +149,8 @@ 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);
}
/**
@ -227,7 +228,9 @@ 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), PlotHelper.getPlotHome(world, p.id) };
return new Location[] { PlotHelper.getPlotBottomLoc(world, p.id),
PlotHelper.getPlotTopLoc(world, p.id),
PlotHelper.getPlotHome(world, p.id) };
}
/**

View File

@ -8,16 +8,25 @@
*/
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
@SuppressWarnings("deprecation")
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!!!!!!!!!!!!
@ -54,7 +63,8 @@ public class Auto extends SubCommand {
}
} catch (Exception e) {
schematic = args[0];
//PlayerFunctions.sendMessage(plr, "&cError: Invalid size (X,Y)");
// PlayerFunctions.sendMessage(plr,
// "&cError: Invalid size (X,Y)");
// return false;
}
} else {
@ -63,7 +73,8 @@ public class Auto extends SubCommand {
// 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;
}
@ -84,11 +95,14 @@ 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;
}
}
@ -122,12 +136,14 @@ public class Auto extends SubCommand {
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;

View File

@ -17,8 +17,6 @@ import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
/**
* Created by Citymonstret on 2014-08-15.
@ -28,7 +26,8 @@ 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>();
}
@ -49,7 +48,8 @@ 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;
}
@ -68,8 +68,7 @@ public class Camera extends SubCommand implements Listener {
public CameraController getController(Player player, Plot plot) {
World w = Bukkit.getWorld(plot.world);
PlotWorld plotworld = PlotMain.getWorldSettings(w);
int seconds = plotworld.PLOT_WIDTH * 5;
int seconds = PlotHelper.getPlotWidth(w, plot.id) * 5;
Location loc1, loc2, loc3, loc4, loc5;
double y = player.getLocation().getY();
Location bottomLoc = PlotHelper.getPlotBottomLoc(w, plot.id);
@ -88,7 +87,8 @@ public class Camera extends SubCommand implements Listener {
loc4.setYaw(((2 / 4.0F) * 360.0F) - 0.5F);
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

@ -15,6 +15,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.FlagManager;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
@ -31,7 +32,8 @@ import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
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
@ -44,7 +46,8 @@ 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;
}
@ -69,11 +72,14 @@ 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;
}
}
@ -91,7 +97,8 @@ 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()) {
@ -115,7 +122,8 @@ public class Claim extends SubCommand {
}
handler.paste(player.getLocation(), sch, plot);
}
plot.settings.setFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS);
plot.settings.setFlags(FlagManager.parseFlags(PlotMain
.getWorldSettings(player.getWorld()).DEFAULT_FLAGS));
}
return event.isCancelled();
}

View File

@ -31,7 +31,9 @@ public class Clear extends SubCommand {
return false;
}
Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(
plr.getUniqueId()))
&& !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}

View File

@ -36,6 +36,7 @@ public class CommandPermission {
* @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

@ -31,7 +31,9 @@ public class Copy extends SubCommand {
return false;
}
Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(
plr.getUniqueId()))
&& !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}

View File

@ -34,7 +34,8 @@ 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.
@ -81,25 +82,36 @@ 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 ->
@ -116,7 +128,8 @@ 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

@ -9,18 +9,26 @@
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.database.DBFunc;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.database.DBFunc;
/**
* Created by Citymonstret on 2014-08-01.
*/
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
@ -30,11 +38,14 @@ 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()))) && !plr.hasPermission("plots.admin")) {
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(
plr.getUniqueId())))
&& !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}
@ -47,7 +58,8 @@ 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);

View File

@ -9,17 +9,17 @@
package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import java.util.UUID;
/**
* Created by Citymonstret on 2014-08-03.
@ -28,25 +28,8 @@ import java.util.UUID;
public class Denied extends SubCommand {
public Denied() {
super(Command.DENIED, "Manage plot helpers", "denied {add|remove} {player}", CommandCategory.ACTIONS);
}
private boolean hasBeenOnServer(String name) {
Player plr = Bukkit.getPlayer(name);
if (plr == null) {
OfflinePlayer oplr = Bukkit.getPlayer(name);
if (oplr == null) {
return false;
} else {
return oplr.hasPlayedBefore();
}
} else {
if (plr.isOnline()) {
return true;
} else {
return plr.hasPlayedBefore();
}
}
super(Command.DENIED, "Manage plot helpers",
"denied {add|remove} {player}", CommandCategory.ACTIONS);
}
@Override
@ -68,35 +51,38 @@ 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;
}
/*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 (!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; }
*/
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")) {
@ -107,32 +93,28 @@ public class Denied extends SubCommand {
return true;
}
plot.removeDenied(uuid);
DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
DBFunc.removeDenied(plr.getWorld().getName(), plot,
Bukkit.getOfflinePlayer(args[1]));
PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED);
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;
}*/
/*
* 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);
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 {

View File

@ -16,7 +16,8 @@ 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

@ -9,41 +9,24 @@
package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import java.util.UUID;
@SuppressWarnings("deprecation")
public class Helpers extends SubCommand {
public Helpers() {
super(Command.HELPERS, "Manage plot helpers", "helpers {add|remove} {player}", CommandCategory.ACTIONS);
}
private boolean hasBeenOnServer(String name) {
Player plr = Bukkit.getPlayer(name);
if (plr == null) {
OfflinePlayer oplr = Bukkit.getOfflinePlayer(name);
if (oplr == null) {
return false;
} else {
return oplr.hasPlayedBefore();
}
} else {
if (plr.isOnline()) {
return true;
} else {
return plr.hasPlayedBefore();
}
}
super(Command.HELPERS, "Manage plot helpers",
"helpers {add|remove} {player}", CommandCategory.ACTIONS);
}
@Override
@ -65,28 +48,26 @@ 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;
}
/*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 (!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; }
*/
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")) {
@ -97,32 +78,28 @@ public class Helpers extends SubCommand {
return true;
}
plot.removeHelper(uuid);
DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
DBFunc.removeHelper(plr.getWorld().getName(), plot,
Bukkit.getOfflinePlayer(args[1]));
PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED);
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;
}*/
/*
* 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);
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 {

View File

@ -9,8 +9,6 @@
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
@ -26,12 +24,14 @@ import com.intellectualcrafters.plot.PlotMain;
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;
}
}
@ -56,7 +56,8 @@ public class Home extends SubCommand {
if ((temp = isAlias(args[0])) != null) {
if (temp.hasOwner()) {
if (temp.getOwner().equals(plr.getUniqueId())) {
PlotMain.teleportPlayer(plr, plr.getLocation(), temp);
PlotMain.teleportPlayer(plr, plr.getLocation(),
temp);
return true;
}
}

View File

@ -9,8 +9,9 @@
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.database.DBFunc;
import java.util.ArrayList;
import java.util.UUID;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -18,8 +19,12 @@ import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.UUID;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc;
/**
*
@ -62,7 +67,8 @@ public class Info extends SubCommand {
// Unclaimed?
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;
}
@ -77,17 +83,27 @@ 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,
@ -105,7 +121,8 @@ 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(",", ""));
list.append(c.replace("%user%", getPlayerName(l.get(x)))
.replace(",", ""));
} else {
list.append(c.replace("%user%", getPlayerName(l.get(x))));
}
@ -117,15 +134,14 @@ 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";
}
/*
OfflinePlayer plr = Bukkit.getOfflinePlayer(uuid);
if (plr.getName() == null) {
return "unknown";
}
return plr.getName();*/
* OfflinePlayer plr = Bukkit.getOfflinePlayer(uuid); if (plr.getName()
* == null) { return "unknown"; } return plr.getName();
*/
return UUIDHandler.getName(uuid);
}

View File

@ -21,7 +21,8 @@ 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
@ -33,7 +34,8 @@ 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));
}
@ -45,12 +47,17 @@ 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

@ -22,7 +22,8 @@ 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
@ -32,7 +33,9 @@ public class Kick extends SubCommand {
return false;
}
Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(
plr.getUniqueId()))
&& !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}
@ -41,12 +44,17 @@ 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) || (PlayerFunctions.getCurrentPlot(player) == null) || !PlayerFunctions.getCurrentPlot(player).equals(plot)) {
PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
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]));
return false;
}
player.teleport(player.getWorld().getSpawnLocation());

View File

@ -9,17 +9,18 @@
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotMain;
import java.util.ArrayList;
import java.util.Arrays;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotMain;
/**
* PlotMain command class
@ -29,7 +30,12 @@ import java.util.Arrays;
*/
public class MainCommand implements CommandExecutor {
private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(), new Reload(), new Merge(), new Unlink(), new Kick(), new Setup() };
private static SubCommand[] _subCommands = new SubCommand[] { new Claim(),
new Auto(), new Home(), new Visit(), new TP(), new Set(),
new Clear(), new Delete(), new SetOwner(), new Denied(),
new Helpers(), new Trusted(), new Info(), new list(), new Help(),
new Debug(), new Schematic(), new plugin(), new Inventory(),
new Reload(), new Merge(), new Unlink(), new Kick(), new Setup() };
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
{
@ -43,14 +49,16 @@ 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());
PlotMain.sendConsoleSenderMessage(C.PREFIX.s()
+ C.HELP_HEADER.s());
PlotMain.sendConsoleSenderMessage("&6/plots reload &c-&6 reloads the plugin");
}
return false;
@ -59,19 +67,29 @@ public class MainCommand implements CommandExecutor {
if (!player.hasPermission("plots.use")) {
return no_permission(player);
}
if ((args.length < 1) || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) {
if ((args.length < 1)
|| ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0]
.equalsIgnoreCase("he")))) {
if (args.length < 2) {
StringBuilder builder = new StringBuilder();
builder.append(C.HELP_INFO.s());
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()));
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()));
}
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;
@ -80,8 +98,15 @@ 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()) {
builder.append("\n" + C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
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()));
}
PlayerFunctions.sendMessage(player, builder.toString());
return true;
@ -94,7 +119,8 @@ public class MainCommand implements CommandExecutor {
return true;
} 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];
@ -111,18 +137,23 @@ 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

@ -9,15 +9,24 @@
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.events.PlotMergeEvent;
import java.util.ArrayList;
import net.milkbowl.vault.economy.Economy;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.SetBlockFast;
import com.intellectualcrafters.plot.events.PlotMergeEvent;
/**
*
@ -26,11 +35,14 @@ import java.util.ArrayList;
*/
public class Merge extends SubCommand {
public 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) {
@ -71,20 +83,35 @@ 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();
@ -93,24 +120,30 @@ 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,7 +17,8 @@ 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

View File

@ -21,7 +21,8 @@ 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

View File

@ -4,13 +4,15 @@ import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.SchematicHandler;
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
@ -34,7 +36,8 @@ 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 {
@ -52,11 +55,19 @@ public class Schematic extends SubCommand {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
break;
}
if (!PlayerFunctions.isInPlot(plr)) {
sendMessage(plr, C.NOT_IN_PLOT);
break;
}
int l1 = schematic.getSchematicDimension().getX();
int l2 = schematic.getSchematicDimension().getZ();
int length = PlotMain.getWorldSettings(plr.getWorld()).PLOT_WIDTH;
Plot plot = PlayerFunctions.getCurrentPlot(plr);
int length = PlotHelper.getPlotWidth(plr.getWorld(), plot.id);
if ((l1 != length) || (l2 != length)) {
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

@ -26,6 +26,7 @@ import com.intellectualcrafters.plot.Flag;
import com.intellectualcrafters.plot.FlagManager;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotBlock;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotHomePosition;
import com.intellectualcrafters.plot.PlotMain;
@ -42,11 +43,14 @@ import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
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
@ -85,18 +89,28 @@ 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");
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");
}
}
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;
}
@ -107,8 +121,10 @@ 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;
}
}
@ -129,17 +145,22 @@ 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()) {
@ -148,7 +169,8 @@ 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) {
@ -196,7 +218,8 @@ 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;
}
@ -218,7 +241,8 @@ 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")) {
@ -234,11 +258,13 @@ 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")) {
@ -259,7 +285,8 @@ 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;
@ -273,7 +300,8 @@ public class Set extends SubCommand {
}
}
PlayerFunctions.sendMessage(plr, C.GENERATING_WALL);
PlotHelper.adjustWall(plr.getWorld(), plot, (short) material.getId(), data);
PlotHelper.adjustWall(plr, plot,
new PlotBlock((short) material.getId(), data));
return true;
}
if (args[0].equalsIgnoreCase("floor")) {
@ -288,19 +316,19 @@ 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(",");
//
Material[] material = new Material[strings.length];
byte[] data = new byte[strings.length];
//
int index = 0;
//
byte b = (byte) 0;
Material m = null;
//
PlotBlock[] blocks = new PlotBlock[strings.length];
for (String s : strings) {
s = s.replaceAll(",", "");
String[] ss = s.split(";");
@ -315,8 +343,8 @@ public class Set extends SubCommand {
return true;
}
if (ss.length == 1) {
data[index] = (byte) 0;
material[index] = m;
blocks[index] = new PlotBlock((short) m.getId(), (byte) 0);
} else {
try {
b = (byte) Integer.parseInt(ss[1]);
@ -324,12 +352,11 @@ public class Set extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
return true;
}
data[index] = b;
material[index] = m;
blocks[index] = new PlotBlock((short) m.getId(), b);
}
index++;
}
PlotHelper.setFloor(plr, plot, material, data);
PlotHelper.setFloor(plr, plot, blocks);
return true;
}
if (args[0].equalsIgnoreCase("wall_filling")) {
@ -350,7 +377,8 @@ 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;
@ -363,7 +391,8 @@ public class Set extends SubCommand {
return true;
}
}
PlotHelper.adjustWallFilling(plr, plr.getWorld(), plot, (short) material.getId(), data);
PlotHelper.adjustWallFilling(plr, plot, new PlotBlock(
(short) material.getId(), data));
return true;
}
StringBuilder builder = new StringBuilder();
@ -374,15 +403,18 @@ 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) {
@ -395,7 +427,8 @@ 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));
}
@ -404,7 +437,8 @@ 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

@ -9,24 +9,30 @@
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.database.DBFunc;
import java.util.UUID;
import org.bukkit.entity.Player;
import java.util.UUID;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc;
@SuppressWarnings("deprecation")
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);
}
/*
private UUID getUUID(String string) {
OfflinePlayer player = Bukkit.getOfflinePlayer(string);
return ((player != null) && player.hasPlayedBefore()) ? player.getUniqueId() : null;
}*/
* private UUID getUUID(String string) { OfflinePlayer player =
* Bukkit.getOfflinePlayer(string); return ((player != null) &&
* player.hasPlayedBefore()) ? player.getUniqueId() : null; }
*/
private UUID getUUID(String string) {
return UUIDHandler.getUUID(string);

View File

@ -1,16 +1,15 @@
package com.intellectualcrafters.plot.commands;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.bukkit.block.Biome;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.ConfigurationNode;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
@ -22,141 +21,15 @@ public class Setup extends SubCommand implements Listener {
public static Map<String, SetupObject> setupMap = new HashMap<>();
private static class SetupStep {
private String constant;
private Object default_value;
private String description;
private Object value = 0;
private String type;
public SetupStep(String constant, Object default_value, String description, String type, boolean require_previous) {
this.constant = constant;
this.default_value = default_value;
this.description = description;
this.type = type;
}
public String getType() {
return this.type;
}
public boolean setValue(String string) {
if (!validValue(string)) {
return false;
}
switch (this.type) {
case "integer":
this.value = Integer.parseInt(string);
break;
case "boolean":
this.value = Boolean.parseBoolean(string);
break;
case "double":
this.value = Double.parseDouble(string);
break;
case "float":
this.value = Float.parseFloat(string);
break;
case "biome":
this.value = (string.toUpperCase());
break;
case "block":
this.value = string;
break;
case "blocklist":
this.value = string.split(",");
break;
case "string":
this.value = string;
break;
}
return true;
}
public boolean validValue(String string) {
try {
if (this.type.equals("integer")) {
Integer.parseInt(string);
return true;
}
if (this.type.equals("boolean")) {
Boolean.parseBoolean(string);
return true;
}
if (this.type.equals("double")) {
Double.parseDouble(string);
return true;
}
if (this.type.equals("float")) {
Float.parseFloat(string);
return true;
}
if (this.type.equals("biome")) {
Biome.valueOf(string.toUpperCase());
return true;
}
if (this.type.equals("block")) {
if (string.contains(":")) {
String[] split = string.split(":");
Short.parseShort(split[0]);
Short.parseShort(split[1]);
} else {
Short.parseShort(string);
}
return true;
}
if (this.type.equals("blocklist")) {
for (String block : string.split(",")) {
if (block.contains(":")) {
String[] split = block.split(":");
Short.parseShort(split[0]);
Short.parseShort(split[1]);
} else {
Short.parseShort(block);
}
}
return true;
}
if (this.type.equals("string")) {
return true;
}
} catch (Exception e) {
}
return false;
}
public Object getValue() {
if (this.value instanceof String[]) {
return Arrays.asList((String[]) this.value);
}
return this.value;
}
public String getConstant() {
return this.constant;
}
public Object getDefaultValue() {
if (this.default_value instanceof String[]) {
return StringUtils.join((String[]) this.default_value, ",");
}
return this.default_value;
}
public String getDescription() {
return this.description;
}
}
private class SetupObject {
String world;
int current = 0;
SetupStep[] step = new SetupStep[] { new SetupStep("road.height", PlotWorld.ROAD_HEIGHT_DEFAULT, "Height of road", "integer", false), new SetupStep("plot.height", PlotWorld.PLOT_HEIGHT_DEFAULT, "Height of plot", "integer", false), new SetupStep("wall.height", PlotWorld.WALL_HEIGHT_DEFAULT, "Height of wall", "integer", false), new SetupStep("plot.size", PlotWorld.PLOT_WIDTH_DEFAULT, "Size of plot", "integer", false), new SetupStep("road.width", PlotWorld.ROAD_WIDTH_DEFAULT, "Width of road", "integer", false), new SetupStep("plot.biome", PlotWorld.PLOT_BIOME_DEFAULT, "Plot biome", "biome", false), new SetupStep("plot.filling", PlotWorld.MAIN_BLOCK_DEFAULT, "Plot filling", "blocklist", false), new SetupStep("plot.floor", PlotWorld.TOP_BLOCK_DEFAULT, "Plot floor", "blocklist", false), new SetupStep("wall.block", PlotWorld.WALL_BLOCK_DEFAULT, "Wall block", "block", false), new SetupStep("wall.filling", PlotWorld.WALL_FILLING_DEFAULT, "Wall filling", "block", false),
new SetupStep("road.enable_stripes", PlotWorld.ROAD_STRIPES_ENABLED_DEFAULT, "Enable road stripes", "boolean", false), new SetupStep("road.stripes", PlotWorld.ROAD_STRIPES_DEFAULT, "Road stripes block", "block", true), new SetupStep("road.block", PlotWorld.ROAD_BLOCK_DEFAULT, "Road block", "block", false), };
ConfigurationNode[] step;
public SetupObject(String world) {
public SetupObject(String world, PlotWorld plotworld) {
this.world = world;
this.step = plotworld.getSettingNodes();
}
public int getCurrent() {
@ -169,20 +42,33 @@ 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
public boolean execute(Player plr, String... args) {
boolean finished = false;
if (!finished) {
// TODO recode this to work with the multiple generators
PlayerFunctions
.sendMessage(plr, "&4CURRENTLY NOT IMPLEMENTED YET!");
return false;
}
if (setupMap.containsKey(plr.getName())) {
SetupObject object = setupMap.get(plr.getName());
if (object.getCurrent() == object.getMax()) {
sendMessage(plr, C.SETUP_FINISHED, object.world);
SetupStep[] steps = object.step;
ConfigurationNode[] steps = object.step;
String world = object.world;
for (SetupStep step : steps) {
PlotMain.config.set("worlds." + world + "." + step.constant, step.getValue());
for (ConfigurationNode step : steps) {
PlotMain.config.set(
"worlds." + world + "." + step.getConstant(),
step.getValue());
}
try {
PlotMain.config.save(PlotMain.configFile);
@ -198,9 +84,11 @@ public class Setup extends SubCommand implements Listener {
return true;
}
SetupStep step = object.step[object.current];
ConfigurationNode step = object.step[object.current];
if (args.length < 1) {
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
step.getDescription(), step.getType(),
step.getDefaultValue() + "");
return true;
} else {
if (args[0].equalsIgnoreCase("cancel")) {
@ -212,16 +100,21 @@ 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(), step.getDefaultValue() + "");
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
step.getDescription(), step.getType(),
step.getDefaultValue() + "");
return true;
} else {
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
step.getDescription(), step.getType(),
step.getDefaultValue() + "");
return true;
}
}
boolean valid = step.validValue(args[0]);
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()) {
@ -229,11 +122,16 @@ 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(), step.getDefaultValue() + "");
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
step.getDescription(), step.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(), step.getDefaultValue() + "");
sendMessage(plr, C.SETUP_INVALID_ARG, args[0],
step.getConstant());
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
step.getDescription(), step.getType(),
step.getDefaultValue() + "");
return true;
}
}
@ -251,11 +149,16 @@ public class Setup extends SubCommand implements Listener {
sendMessage(plr, C.SETUP_WORLD_TAKEN, world);
return true;
}
setupMap.put(plr.getName(), new SetupObject(world));
PlotWorld plotworld = PlotMain.getWorldSettings("//TODO"); // TODO
setupMap.put(plr.getName(), new SetupObject(world, plotworld));
sendMessage(plr, C.SETUP_INIT);
SetupObject object = setupMap.get(plr.getName());
SetupStep step = object.step[object.current];
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
ConfigurationNode step = object.step[object.current];
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "",
step.getDescription(), step.getType(),
step.getDefaultValue() + "");
return true;
}
}

View File

@ -61,7 +61,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;
@ -81,7 +82,8 @@ 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();
@ -117,7 +119,8 @@ 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

@ -29,7 +29,8 @@ import com.intellectualcrafters.plot.PlotMain;
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
@ -56,8 +57,10 @@ 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) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
@ -76,14 +79,16 @@ 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

@ -9,41 +9,24 @@
package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.UUIDHandler;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlayerPlotTrustedEvent;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import java.util.UUID;
@SuppressWarnings("deprecation")
public class Trusted extends SubCommand {
public Trusted() {
super(Command.TRUSTED, "Manage trusted users for a plot", "trusted {add|remove} {player}", CommandCategory.ACTIONS);
}
private boolean hasBeenOnServer(String name) {
Player plr = Bukkit.getPlayer(name);
if (plr == null) {
OfflinePlayer oplr = Bukkit.getOfflinePlayer(name);
if (oplr == null) {
return false;
} else {
return oplr.hasPlayedBefore();
}
} else {
if (plr.isOnline()) {
return true;
} else {
return plr.hasPlayedBefore();
}
}
super(Command.TRUSTED, "Manage trusted users for a plot",
"trusted {add|remove} {player}", CommandCategory.ACTIONS);
}
@Override
@ -65,28 +48,26 @@ 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;
}
/*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 (!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; }
*/
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")) {
@ -97,33 +78,28 @@ public class Trusted extends SubCommand {
return true;
}
plot.removeTrusted(uuid);
DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
DBFunc.removeTrusted(plr.getWorld().getName(), plot,
Bukkit.getOfflinePlayer(args[1]));
PlayerFunctions.sendMessage(plr, C.TRUSTED_REMOVED);
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;
}*/
* 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);
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 {

View File

@ -12,16 +12,15 @@ package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotManager;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.SetBlockFast;
import com.intellectualcrafters.plot.database.DBFunc;
@ -32,18 +31,9 @@ import com.intellectualcrafters.plot.events.PlotUnlinkEvent;
*/
public class Unlink extends SubCommand {
private short w_id;
private byte w_v;
private short wf_id;
private byte wf_v;
private short f1_id;
private byte f1_v;
private int pathsize;
private int wallheight;
private int roadheight;
public Unlink() {
super(Command.UNLINK, "Unlink a mega-plot", "unlink", CommandCategory.ACTIONS);
super(Command.UNLINK, "Unlink a mega-plot", "unlink",
CommandCategory.ACTIONS);
}
@Override
@ -53,18 +43,22 @@ public class Unlink extends SubCommand {
return true;
}
Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !plr.hasPermission("plots.admin")) {
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(
plr.getUniqueId()))
&& !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
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);
@ -85,49 +79,31 @@ 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);
this.pathsize = plotworld.ROAD_WIDTH;
this.roadheight = plotworld.ROAD_HEIGHT;
this.wallheight = plotworld.WALL_HEIGHT;
// WALL
short[] result_w = PlotHelper.getBlock(plotworld.WALL_BLOCK);
this.w_id = result_w[0];
this.w_v = (byte) result_w[1];
// WALL FILLING
short[] result_wf = PlotHelper.getBlock(plotworld.WALL_FILLING);
this.wf_id = result_wf[0];
this.wf_v = (byte) result_wf[1];
// ROAD
short[] result_f1 = PlotHelper.getBlock(plotworld.ROAD_BLOCK);
this.f1_id = result_f1[0];
this.f1_v = (byte) result_f1[1];
//
PlotHelper.getBlock(plotworld.ROAD_STRIPES);
for (int x = pos1.x; x <= pos2.x; x++) {
for (int y = pos1.y; y <= pos2.y; y++) {
boolean lx = x < pos2.x;
boolean ly = y < pos2.y;
PlotId id = new PlotId(x, y);
new PlotId(x, y);
if (lx) {
setRoadX(world, id);
manager.removeRoadEast(plotworld, plot);
if (ly) {
setRoadXY(world, id);
manager.removeRoadSouthEast(plotworld, plot);
}
}
if (ly) {
setRoadY(world, id);
manager.removeRoadSouth(plotworld, plot);
}
}
@ -142,76 +118,4 @@ public class Unlink extends SubCommand {
PlayerFunctions.sendMessage(plr, "&6Plots unlinked successfully!");
return true;
}
/**
* Setting the road with the greatest X value
*
* @param world
* @param id
*/
public void setRoadX(World w, PlotId id) {
Location pos1 = PlotHelper.getPlotBottomLocAbs(w, id);
Location pos2 = PlotHelper.getPlotTopLocAbs(w, id);
int sx = pos2.getBlockX();
int ex = (sx + this.pathsize);
int sz = pos1.getBlockZ() - 1;
int ez = pos2.getBlockZ() + 2;
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(this.wallheight, this.roadheight) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), (short) 0);
PlotHelper.setCuboid(w, new Location(w, sx, 1, sz + 1), new Location(w, sx + 1, this.wallheight + 1, ez), new short[] { this.wf_id }, new short[] { this.wf_v });
PlotHelper.setCuboid(w, new Location(w, sx, this.wallheight + 1, sz + 1), new Location(w, sx + 1, this.wallheight + 2, ez), new short[] { this.w_id }, new short[] { this.w_v });
PlotHelper.setCuboid(w, new Location(w, ex, 1, sz + 1), new Location(w, ex + 1, this.wallheight + 1, ez), new short[] { this.wf_id }, new short[] { this.wf_v });
PlotHelper.setCuboid(w, new Location(w, ex, this.wallheight + 1, sz + 1), new Location(w, ex + 1, this.wallheight + 2, ez), new short[] { this.w_id }, new short[] { this.w_v });
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, this.roadheight + 1, ez), new short[] { this.f1_id }, new short[] { this.f1_v });
}
/**
* Setting the road with the greatest Y value
*
* @param world
* @param id
*/
public void setRoadY(World w, PlotId id) {
Location pos1 = PlotHelper.getPlotBottomLocAbs(w, id);
Location pos2 = PlotHelper.getPlotTopLocAbs(w, id);
int sz = pos2.getBlockZ();
int ez = (sz + this.pathsize);
int sx = pos1.getBlockX() - 1;
int ex = pos2.getBlockX() + 2;
PlotHelper.setSimpleCuboid(w, new Location(w, sx, Math.min(this.wallheight, this.roadheight) + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), (short) 0);
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz), new Location(w, ex, this.wallheight + 1, sz + 1), new short[] { this.wf_id }, new short[] { this.wf_v });
PlotHelper.setCuboid(w, new Location(w, sx + 1, this.wallheight + 1, sz), new Location(w, ex, this.wallheight + 2, sz + 1), new short[] { this.w_id }, new short[] { this.w_v });
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, ez), new Location(w, ex, this.wallheight + 1, ez + 1), new short[] { this.wf_id }, new short[] { this.wf_v });
PlotHelper.setCuboid(w, new Location(w, sx + 1, this.wallheight + 1, ez), new Location(w, ex, this.wallheight + 2, ez + 1), new short[] { this.w_id }, new short[] { this.w_v });
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, this.roadheight + 1, ez), new short[] { this.f1_id }, new short[] { this.f1_v });
}
/**
* Setting the intersection with the greatest X and Y value
*
* @param world
* @param id
*/
public void setRoadXY(World w, PlotId id) {
Location pos2 = PlotHelper.getPlotTopLocAbs(w, id);
int sx = pos2.getBlockX() + 1;
int ex = (sx + this.pathsize) - 1;
int sz = pos2.getBlockZ() + 1;
int ez = (sz + this.pathsize) - 1;
PlotHelper.setSimpleCuboid(w, new Location(w, sx, this.roadheight + 1, sz + 1), new Location(w, ex + 1, 257 + 1, ez), (short) 0);
PlotHelper.setCuboid(w, new Location(w, sx + 1, 1, sz + 1), new Location(w, ex, this.roadheight + 1, ez), new short[] { this.f1_id }, new short[] { this.f1_v });
}
}

View File

@ -23,7 +23,8 @@ 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) {
@ -44,7 +45,8 @@ 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;

View File

@ -9,12 +9,18 @@
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.UUID;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.UUIDHandler;
/**
*
@ -24,7 +30,8 @@ import java.util.UUID;
public class list extends SubCommand {
public 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
@ -32,53 +39,96 @@ 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)) + "\n");
string.append(C.PLOT_LIST_ITEM
.s()
.replaceAll("%id%",
p.id.x + ";" + p.id.y + ";" + p.world)
.replaceAll("%owner%", getName(p.owner))
+ "\n");
idx++;
}
if (idx == 0) {
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");
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_ITEM
.s()
.replaceAll("%id%",
p.id.x + ";" + p.id.y + ";" + p.world)
.replaceAll("%owner%", getName(p.owner))
+ "\n");
}
}
string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", PlotMain.getPlots().size() + "").replaceAll("%plot%", PlotMain.getPlots().size() == 1 ? "plot" : "plots"));
string.append(C.PLOT_LIST_FOOTER
.s()
.replaceAll("%word%", "There is")
.replaceAll("%num%", PlotMain.getPlots().size() + "")
.replaceAll("%plot%",
PlotMain.getPlots().size() == 1 ? "plot" : "plots"));
PlayerFunctions.sendMessage(plr, string.toString());
return true;
} else if (args[0].equalsIgnoreCase("all")) {
StringBuilder string = new StringBuilder();
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") + "\n");
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all")
+ "\n");
for (Plot p : PlotMain.getPlots()) {
string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id%", p.id.x + ";" + p.id.y + ";" + p.world).replaceAll("%owner%", getName(p.owner)) + "\n");
string.append(C.PLOT_LIST_ITEM
.s()
.replaceAll("%id%",
p.id.x + ";" + p.id.y + ";" + p.world)
.replaceAll("%owner%", getName(p.owner))
+ "\n");
}
string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", PlotMain.getPlots().size() + "").replaceAll("%plot%", PlotMain.getPlots().size() == 1 ? "plot" : "plots"));
string.append(C.PLOT_LIST_FOOTER
.s()
.replaceAll("%word%", "There is")
.replaceAll("%num%", PlotMain.getPlots().size() + "")
.replaceAll("%plot%",
PlotMain.getPlots().size() == 1 ? "plot" : "plots"));
PlayerFunctions.sendMessage(plr, string.toString());
return true;
} else if (args[0].equalsIgnoreCase("world")) {
StringBuilder string = new StringBuilder();
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") + "\n");
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all")
+ "\n");
HashMap<PlotId, Plot> plots = PlotMain.getPlots(plr.getWorld());
for (Plot p : plots.values()) {
string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id%", p.id.x + ";" + p.id.y + ";" + p.world).replaceAll("%owner%", getName(p.owner)) + "\n");
string.append(C.PLOT_LIST_ITEM
.s()
.replaceAll("%id%",
p.id.x + ";" + p.id.y + ";" + p.world)
.replaceAll("%owner%", getName(p.owner))
+ "\n");
}
string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", plots.values().size() + "").replaceAll("%plot%", plots.values().size() == 1 ? "plot" : "plots"));
string.append(C.PLOT_LIST_FOOTER
.s()
.replaceAll("%word%", "There is")
.replaceAll("%num%", plots.values().size() + "")
.replaceAll("%plot%",
plots.values().size() == 1 ? "plot" : "plots"));
PlayerFunctions.sendMessage(plr, string.toString());
return true;
} else {
@ -91,11 +141,10 @@ public class list extends SubCommand {
if (id == null) {
return "none";
}
/*String name = Bukkit.getOfflinePlayer(id).getName();
if (name == null) {
return "none";
}
return name;*/
/*
* String name = Bukkit.getOfflinePlayer(id).getName(); if (name ==
* null) { return "none"; } return name;
*/
return UUIDHandler.getName(id);
}
@ -108,7 +157,8 @@ 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

@ -9,39 +9,49 @@
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotMain;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotMain;
public class plugin extends SubCommand {
public 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() {
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));
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) {
@ -61,7 +71,8 @@ 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");

View File

@ -24,7 +24,6 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.block.Biome;
import com.intellectualcrafters.plot.Flag;
@ -54,7 +53,8 @@ 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);
@ -62,7 +62,8 @@ public class DBFunc {
statement.close();
} 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);
}
}
});
@ -72,7 +73,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");
@ -105,7 +107,8 @@ 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("(?),");
}
@ -124,7 +127,8 @@ public class DBFunc {
// 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 + "(?, ?)");
@ -162,7 +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("(?, ?, ?, ?),");
@ -195,7 +200,8 @@ 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());
@ -213,27 +219,81 @@ 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`)" + ") 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` ("
+ "`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_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," + "`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_denied` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` (" + "`plot_plot_id` INT(11) NOT NULL," + "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` (" + " `plot_plot_id` INT(11) NOT NULL," + " `biome` VARCHAR(45) DEFAULT 'FOREST'," + " `rain` INT(1) DEFAULT 0," + " `custom_time` TINYINT(1) DEFAULT '0'," + " `time` INT(11) DEFAULT '8000'," + " `deny_entry` TINYINT(1) DEFAULT '0'," + " `alias` VARCHAR(50) DEFAULT NULL," + " `flags` VARCHAR(512) DEFAULT NULL," + " `merged` INT(11) DEFAULT NULL," + " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," + " PRIMARY KEY (`plot_plot_id`)" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot` ("
+ "`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,"
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_helpers` ("
+ "`plot_plot_id` INT(11) NOT NULL,"
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_trusted` ("
+ "`plot_plot_id` INT(11) NOT NULL,"
+ "`user_uuid` VARCHAR(40) NOT NULL" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_settings` ("
+ " `plot_plot_id` INT(11) NOT NULL,"
+ " `biome` VARCHAR(45) DEFAULT 'FOREST',"
+ " `rain` INT(1) DEFAULT 0,"
+ " `custom_time` TINYINT(1) DEFAULT '0',"
+ " `time` INT(11) DEFAULT '8000',"
+ " `deny_entry` TINYINT(1) DEFAULT '0',"
+ " `alias` VARCHAR(50) DEFAULT NULL,"
+ " `flags` VARCHAR(512) DEFAULT NULL,"
+ " `merged` INT(11) DEFAULT NULL,"
+ " `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT',"
+ " PRIMARY KEY (`plot_plot_id`)" + ")");
stmt.addBatch("CREATE TABLE IF NOT EXISTS `plot_ratings` (`plot_plot_id` INT(11) NOT NULL, `rating` INT(2) NOT NULL, `player` VARCHAR(40) NOT NULL, PRIMARY KEY(`plot_plot_id`))");
}
stmt.executeBatch();
@ -254,25 +314,30 @@ 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) {
e.printStackTrace();
Logger.add(LogLevel.DANGER, "Failed to delete plot " + plot.id);
Logger.add(LogLevel.DANGER, "Failed to delete plot "
+ plot.id);
}
}
});
@ -290,7 +355,9 @@ public class DBFunc {
public void run() {
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();
@ -305,7 +372,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);
@ -349,18 +417,32 @@ 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();
}
@ -373,16 +455,19 @@ 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);
@ -398,9 +483,11 @@ public class DBFunc {
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]);
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(
flags_string[i], true), "");
}
}
ArrayList<UUID> helpers = plotHelpers(id);
@ -426,25 +513,30 @@ 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 {
@ -452,9 +544,12 @@ public class DBFunc {
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+"' does not exist! Please create this world, or remove the plots from the DB!");
} 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!");
}
}
}
@ -470,27 +565,31 @@ 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) {
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
@ -500,20 +599,23 @@ 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) {
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;
@ -528,14 +630,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) {
e.printStackTrace();
Logger.add(LogLevel.WARNING, "Could not set flag for plot " + plot.id);
Logger.add(LogLevel.WARNING, "Could not set flag for plot "
+ plot.id);
}
}
});
@ -545,20 +649,23 @@ public class DBFunc {
* @param plot
* @param 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);
Logger.add(LogLevel.WARNING,
"Failed to set alias for plot " + plot.id);
e.printStackTrace();
}
@ -570,27 +677,31 @@ 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);
Logger.add(LogLevel.WARNING,
"Failed to set position for plot " + plot.id);
e.printStackTrace();
}
}
@ -605,7 +716,8 @@ 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;
@ -642,7 +754,8 @@ public class DBFunc {
stmt.close();
;
} catch (SQLException e) {
Logger.add(LogLevel.WARNING, "Failed to load settings for plot: " + id);
Logger.add(LogLevel.WARNING, "Failed to load settings for plot: "
+ id);
e.printStackTrace();
}
return h;
@ -661,7 +774,8 @@ 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;
@ -686,7 +800,9 @@ 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"));
@ -694,7 +810,8 @@ public class DBFunc {
}
stmt.close();
} catch (SQLException e) {
Logger.add(LogLevel.WARNING, "Failed to load helpers for plot: " + id);
Logger.add(LogLevel.WARNING, "Failed to load helpers for plot: "
+ id);
e.printStackTrace();
}
return l;
@ -709,7 +826,9 @@ 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"));
@ -717,7 +836,8 @@ public class DBFunc {
}
stmt.close();
} catch (SQLException e) {
Logger.add(LogLevel.WARNING, "Failed to load trusted users for plot: " + id);
Logger.add(LogLevel.WARNING,
"Failed to load trusted users for plot: " + id);
e.printStackTrace();
}
return l;
@ -727,19 +847,22 @@ 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) {
e.printStackTrace();
Logger.add(LogLevel.WARNING, "Failed to remove helper for plot " + plot.id);
Logger.add(LogLevel.WARNING,
"Failed to remove helper for plot " + plot.id);
}
}
});
@ -749,19 +872,22 @@ public class DBFunc {
* @param plot
* @param 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) {
e.printStackTrace();
Logger.add(LogLevel.WARNING, "Failed to remove trusted user for plot " + plot.id);
Logger.add(LogLevel.WARNING,
"Failed to remove trusted user for plot " + plot.id);
}
}
});
@ -771,18 +897,21 @@ public class DBFunc {
* @param plot
* @param 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);
Logger.add(LogLevel.WARNING,
"Failed to set helper for plot " + plot.id);
e.printStackTrace();
}
}
@ -793,18 +922,21 @@ 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);
Logger.add(LogLevel.WARNING,
"Failed to set plot trusted for plot " + plot.id);
e.printStackTrace();
}
}
@ -815,19 +947,22 @@ 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) {
e.printStackTrace();
Logger.add(LogLevel.WARNING, "Failed to remove denied for plot " + plot.id);
Logger.add(LogLevel.WARNING,
"Failed to remove denied for plot " + plot.id);
}
}
});
@ -837,18 +972,21 @@ public class DBFunc {
* @param plot
* @param 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);
Logger.add(LogLevel.WARNING,
"Failed to set denied for plot " + plot.id);
e.printStackTrace();
}
}
@ -857,7 +995,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;
@ -867,7 +1006,8 @@ public class DBFunc {
statement.close();
return rating;
} catch (SQLException e) {
Logger.add(LogLevel.WARNING, "Failed to fetch rating for plot " + plot.getId().toString());
Logger.add(LogLevel.WARNING, "Failed to fetch rating for plot "
+ plot.getId().toString());
e.printStackTrace();
}
return 0.0d;

View File

@ -39,7 +39,8 @@ 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
@ -79,7 +80,8 @@ 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>
@ -94,5 +96,6 @@ 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,7 +39,8 @@ 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;
@ -50,12 +51,15 @@ 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;
}
@ -79,7 +83,8 @@ 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();
}
@ -92,7 +97,8 @@ 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

@ -1,7 +1,5 @@
package com.intellectualcrafters.plot.database;
import java.io.File;
import java.io.FilenameFilter;
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.util.ArrayList;
@ -35,7 +33,8 @@ public class PlotMeConverter {
final PrintStream stream = new PrintStream("converter_log.txt");
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(this.plugin,
new Runnable() {
@Override
public void run() {
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has started");
@ -43,11 +42,18 @@ public class PlotMeConverter {
ArrayList<com.intellectualcrafters.plot.Plot> createdPlots = new ArrayList<com.intellectualcrafters.plot.Plot>();
boolean online = Bukkit.getServer().getOnlineMode();
for (World world : Bukkit.getWorlds()) {
HashMap<String, Plot> plots = PlotManager.getPlots(world);
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: &7Processing '"
+ plots.size()
+ "' plots for world '"
+ world.getName() + "'");
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting " + plots.size() + " plots for '" + world.toString() + "'...");
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting "
+ plots.size()
+ " plots for '"
+ world.toString() + "'...");
for (Plot plot : plots.values()) {
ArrayList<UUID> psAdded = new ArrayList<>();
ArrayList<UUID> psTrusted = new ArrayList<>();
@ -60,15 +66,28 @@ public class PlotMeConverter {
if (online) {
PlayerList denied = null;
PlayerList added = null;
Field fAdded = plot.getClass().getDeclaredField("allowed");
Field fDenied = plot.getClass().getDeclaredField("denied");
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("*")) {
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;
}
@ -77,9 +96,16 @@ public class PlotMeConverter {
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("*")) {
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;
}
@ -89,20 +115,26 @@ public class PlotMeConverter {
}
}
} else {
for (String user : plot.getAllowed().split(",")) {
for (String user : plot
.getAllowed().split(",")) {
if (user.equals("*")) {
psAdded.add(DBFunc.everyone);
} else {
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8));
UUID uuid = UUID
.nameUUIDFromBytes(("OfflinePlayer:" + user)
.getBytes(Charsets.UTF_8));
psAdded.add(uuid);
}
}
try {
for (String user : plot.getDenied().split(",")) {
for (String user : plot
.getDenied().split(",")) {
if (user.equals("*")) {
psDenied.add(DBFunc.everyone);
} else {
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + user).getBytes(Charsets.UTF_8));
UUID uuid = UUID
.nameUUIDFromBytes(("OfflinePlayer:" + user)
.getBytes(Charsets.UTF_8));
psDenied.add(uuid);
}
}
@ -117,16 +149,37 @@ public class PlotMeConverter {
eR3040bl230 = 232999304998392004l;
}
stream.println(eR3040bl230);
PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]), Integer.parseInt(plot.id.split(";")[1]));
PlotId id = new PlotId(
Integer.parseInt(plot.id.split(";")[0]),
Integer.parseInt(plot.id.split(";")[1]));
com.intellectualcrafters.plot.Plot pl = null;
if (online) {
pl = new com.intellectualcrafters.plot.Plot(id, plot.getOwnerId(), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false });
pl = new com.intellectualcrafters.plot.Plot(
id, plot.getOwnerId(), plot
.getBiome(), psAdded,
psTrusted, psDenied, false,
8000l, false, "",
PlotHomePosition.DEFAULT, null,
world.getName(), new boolean[] {
false, false, false,
false });
} else {
String owner = plot.getOwner();
pl = new com.intellectualcrafters.plot.Plot(id, UUID.nameUUIDFromBytes(("OfflinePlayer:" + owner).getBytes(Charsets.UTF_8)), plot.getBiome(), psAdded, psTrusted, psDenied, false, 8000l, false, "", PlotHomePosition.DEFAULT, null, world.getName(), new boolean[] { false, false, false, false });
pl = new com.intellectualcrafters.plot.Plot(
id,
UUID.nameUUIDFromBytes(("OfflinePlayer:" + owner)
.getBytes(Charsets.UTF_8)),
plot.getBiome(), psAdded,
psTrusted, psDenied, false,
8000l, false, "",
PlotHomePosition.DEFAULT, null,
world.getName(), new boolean[] {
false, false, false,
false });
}
// TODO createPlot doesn't add helpers / denied
// TODO createPlot doesn't add helpers /
// denied
// users
if (pl != null) {
createdPlots.add(pl);
@ -140,14 +193,19 @@ public class PlotMeConverter {
DBFunc.createAllSettingsAndHelpers(createdPlots);
stream.close();
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has finished");
// TODO disable PlotMe -> Unload all plot worlds, change the
// TODO disable PlotMe -> Unload all plot worlds, change
// the
// generator, restart the server automatically
// 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 +
// 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);
Bukkit.getPluginManager().disablePlugin(
PlotMeConverter.this.plugin);
}
});
}

View File

@ -36,7 +36,8 @@ public class SQLite extends Database {
}
@Override
public Connection openConnection() throws SQLException, ClassNotFoundException {
public Connection openConnection() throws SQLException,
ClassNotFoundException {
if (checkConnection()) {
return this.connection;
}
@ -48,11 +49,14 @@ public class SQLite extends Database {
try {
file.createNewFile();
} catch (IOException e) {
this.plugin.getLogger().log(Level.SEVERE, "Unable to create database!");
this.plugin.getLogger().log(Level.SEVERE,
"Unable to create database!");
}
}
Class.forName("org.sqlite.JDBC");
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;
}
@ -76,7 +80,8 @@ 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();
}
@ -89,7 +94,8 @@ 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

@ -28,7 +28,8 @@ 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,7 +27,8 @@ 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,7 +27,8 @@ 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

@ -20,7 +20,8 @@ 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,6 +1,7 @@
package com.intellectualcrafters.plot.generator;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@ -22,16 +23,15 @@ 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
*
* 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) {
@ -81,7 +81,8 @@ public class DefaultPlotManager extends PlotManager {
}
/*
* Some complex stuff for traversing mega plots (return getPlotIdAbs if you do not support mega plots)
* Some complex stuff for traversing mega plots (return getPlotIdAbs if you
* do not support mega plots)
*/
@Override
public PlotId getPlotId(PlotWorld plotworld, Location loc) {
@ -122,7 +123,8 @@ 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;
@ -135,7 +137,8 @@ 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;
@ -147,7 +150,8 @@ 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;
@ -166,8 +170,9 @@ public class DefaultPlotManager extends PlotManager {
}
/*
* Check if a location is inside a specific plot(non-Javadoc)
* - For this implementation, we don't need to do anything fancier than referring to getPlotIdAbs(...)
* Check if a location is inside a specific plot(non-Javadoc) - For this
* implementation, we don't need to do anything fancier than referring to
* getPlotIdAbs(...)
*/
@Override
public boolean isInPlotAbs(PlotWorld plotworld, Location loc, PlotId plotid) {
@ -179,8 +184,7 @@ public class DefaultPlotManager extends PlotManager {
}
/*
* Get the bottom plot loc
* (some basic math)
* Get the bottom plot loc (some basic math)
*/
@Override
public Location getPlotBottomLocAbs(PlotWorld plotworld, PlotId plotid) {
@ -189,15 +193,16 @@ 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);
}
/*
* Get the top plot loc
* (some basic math)
* Get the top plot loc (some basic math)
*/
@Override
public Location getPlotTopLocAbs(PlotWorld plotworld, PlotId plotid) {
@ -206,36 +211,58 @@ 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);
}
/*
* 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
* 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
*/
@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;
@ -252,41 +279,72 @@ 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);
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) {
@ -302,45 +360,161 @@ 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;
}
@ -352,21 +526,25 @@ 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();
@ -451,15 +629,30 @@ 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;
}
@ -477,15 +670,30 @@ 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;
}
@ -502,8 +710,11 @@ 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;
}
@ -521,9 +732,16 @@ 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.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;
}
@ -541,9 +759,16 @@ 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.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;
}
@ -560,10 +785,15 @@ 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;
}
@ -572,7 +802,8 @@ 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
@ -584,11 +815,16 @@ 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()) || (x == megaPlotTop.getBlockX())) {
world.getBlockAt(x, dpw.WALL_HEIGHT + 1, z).setTypeIdAndData(block.id, block.data, false);
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);
}
}
}

View File

@ -11,12 +11,11 @@ import com.intellectualcrafters.plot.PlotWorld;
public class DefaultPlotWorld extends PlotWorld {
/*
* These variables are set to ensure fast access to config settings
* Strings are used as little as possible to optimize math performance in many of the functions/algorithms
*
* These variables are set to ensure fast access to config settings Strings
* are used as little as possible to optimize math performance in many of
* the functions/algorithms
*/
/**
* Road Height
*/
@ -69,7 +68,8 @@ 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,7 +77,8 @@ 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
@ -95,7 +96,8 @@ 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
@ -104,7 +106,8 @@ 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
*/
@ -117,8 +120,8 @@ 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
@ -128,52 +131,73 @@ public class DefaultPlotWorld extends PlotWorld {
}
/*
* CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED FOR INITIAL SETUP
*
* Set the last boolean to false if you do not require a specific config node to be set while using the setup command
* - this may be useful if a config value can be changed at a later date, and has no impact on the actual world generation
* CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED
* FOR INITIAL SETUP
*
* Set the last boolean to false if you do not require a specific config
* node to be set while using the setup command - this may be useful if a
* config value can be changed at a later date, and has no impact on the
* actual world generation
*/
@Override
public ConfigurationNode[] getSettingNodes() {
// TODO return a set of configuration nodes (used for setup command)
return
new ConfigurationNode[] {
new ConfigurationNode("plot.height", PLOT_HEIGHT, "Plot height", Configuration.INTEGER, true),
new ConfigurationNode("plot.width", PLOT_WIDTH, "Plot width", Configuration.INTEGER, true),
new ConfigurationNode("plot.filling", MAIN_BLOCK, "Plot block", Configuration.BLOCKLIST, true),
new ConfigurationNode("plot.floor", TOP_BLOCK, "Plot floor block", Configuration.BLOCKLIST, true),
new ConfigurationNode("wall.block", WALL_BLOCK, "Top wall block", Configuration.BLOCK, true),
new ConfigurationNode("road.width", ROAD_WIDTH, "Road width", Configuration.INTEGER, true),
new ConfigurationNode("road.height", ROAD_HEIGHT, "Road height", Configuration.INTEGER, true),
new ConfigurationNode("road.enable_stripes", ROAD_STRIPES_ENABLED, "Enable road stripes", Configuration.BOOLEAN, true),
new ConfigurationNode("road.block", ROAD_BLOCK, "Road block", Configuration.BLOCK, true),
new ConfigurationNode("road.stripes", ROAD_STRIPES, "Road stripe block", Configuration.BLOCK, true),
new ConfigurationNode("wall.filling", WALL_FILLING, "Wall filling block", Configuration.BLOCK, true),
new ConfigurationNode("wall.height", WALL_HEIGHT, "Wall height", Configuration.INTEGER, true),
};
return new ConfigurationNode[] {
new ConfigurationNode("plot.height", this.PLOT_HEIGHT,
"Plot height", Configuration.INTEGER, true),
new ConfigurationNode("plot.width", this.PLOT_WIDTH,
"Plot width", Configuration.INTEGER, true),
new ConfigurationNode("plot.filling", this.MAIN_BLOCK,
"Plot block", Configuration.BLOCKLIST, true),
new ConfigurationNode("plot.floor", this.TOP_BLOCK,
"Plot floor block", Configuration.BLOCKLIST, true),
new ConfigurationNode("wall.block", this.WALL_BLOCK,
"Top wall block", Configuration.BLOCK, true),
new ConfigurationNode("road.width", this.ROAD_WIDTH,
"Road width", Configuration.INTEGER, true),
new ConfigurationNode("road.height", this.ROAD_HEIGHT,
"Road height", Configuration.INTEGER, true),
new ConfigurationNode("road.enable_stripes",
this.ROAD_STRIPES_ENABLED, "Enable road stripes",
Configuration.BOOLEAN, true),
new ConfigurationNode("road.block", this.ROAD_BLOCK,
"Road block", Configuration.BLOCK, true),
new ConfigurationNode("road.stripes", this.ROAD_STRIPES,
"Road stripe block", Configuration.BLOCK, true),
new ConfigurationNode("wall.filling", this.WALL_FILLING,
"Wall filling block", Configuration.BLOCK, true),
new ConfigurationNode("wall.height", this.WALL_HEIGHT,
"Wall height", Configuration.INTEGER, true), };
}
/*
* This method is called when a world loads. Make sure you set all your constants here.
* You are provided with the configuration section for that specific world.
* This method is called when a world loads. Make sure you set all your
* constants here. You are provided with the configuration section for that
* specific world.
*/
@Override
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

@ -8,7 +8,6 @@ import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import com.intellectualcrafters.plot.PlotBlock;
import com.intellectualcrafters.plot.PlotGenerator;
@ -20,9 +19,11 @@ 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 perfectly fine to do, it will just mean world generation may take somewhat longer
* 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,7 +60,6 @@ public class WorldGenerator extends PlotGenerator {
/*
* Return the plot manager for this type of generator, or create one
*
*/
@Override
public PlotManager getPlotManager() {
@ -80,6 +80,7 @@ public class WorldGenerator extends PlotGenerator {
* Faster sudo-random number generator than java.util.random
*/
private long state;
public final long nextLong() {
long a = this.state;
this.state = xorShift64(a);
@ -99,10 +100,12 @@ public class WorldGenerator extends PlotGenerator {
}
/*
* Cuboid based plot generation is quick, as it requires no calculations inside the loop
* - You don't have to use this this method, but you may find it useful.
* Cuboid based plot generation is quick, as it requires no calculations
* inside the loop - You don't have to use this this method, but you may
* find it useful.
*/
public void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock block) {
public void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2,
PlotBlock block) {
for (int x = x1; x < x2; x++) {
for (int z = z1; z < z2; z++) {
for (int y = y1; y < y2; y++) {
@ -112,7 +115,8 @@ public class WorldGenerator extends PlotGenerator {
}
}
private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks) {
private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1,
int z2, PlotBlock[] blocks) {
if (blocks.length == 1) {
setCuboidRegion(x1, x2, y1, y2, z1, z2, blocks[0]);
} else {
@ -143,23 +147,23 @@ public class WorldGenerator extends PlotGenerator {
public WorldGenerator(String world) {
this.plotworld = new DefaultPlotWorld(world);
plotsize = plotworld.PLOT_WIDTH;
pathsize = plotworld.ROAD_WIDTH;
this.plotsize = this.plotworld.PLOT_WIDTH;
this.pathsize = this.plotworld.ROAD_WIDTH;
floor1 = plotworld.ROAD_BLOCK;
floor2 = plotworld.ROAD_STRIPES;
this.floor1 = this.plotworld.ROAD_BLOCK;
this.floor2 = this.plotworld.ROAD_STRIPES;
wallfilling = plotworld.WALL_FILLING;
size = pathsize + plotsize;
wall = plotworld.WALL_BLOCK;
this.wallfilling = this.plotworld.WALL_FILLING;
this.size = this.pathsize + this.plotsize;
this.wall = this.plotworld.WALL_BLOCK;
plotfloors = plotworld.TOP_BLOCK;
filling = plotworld.MAIN_BLOCK;
wallheight = plotworld.WALL_HEIGHT;
roadheight = plotworld.ROAD_HEIGHT;
plotheight = plotworld.PLOT_HEIGHT;
this.plotfloors = this.plotworld.TOP_BLOCK;
this.filling = this.plotworld.MAIN_BLOCK;
this.wallheight = this.plotworld.WALL_HEIGHT;
this.roadheight = this.plotworld.ROAD_HEIGHT;
this.plotheight = this.plotworld.PLOT_HEIGHT;
biome = plotworld.PLOT_BIOME;
this.biome = this.plotworld.PLOT_BIOME;
}
/*
@ -175,8 +179,9 @@ public class WorldGenerator extends PlotGenerator {
world.setMonsterSpawnLimit(0);
world.setWaterAnimalSpawnLimit(0);
}
// You can have as many populators as you would like, e.g. tree populator, ore populator
return Arrays.asList((BlockPopulator) new XPopulator(plotworld));
// You can have as many populators as you would like, e.g. tree
// populator, ore populator
return Arrays.asList((BlockPopulator) new XPopulator(this.plotworld));
}
/*
@ -184,15 +189,16 @@ public class WorldGenerator extends PlotGenerator {
*/
@Override
public Location getFixedSpawnLocation(World world, Random random) {
return new Location(world, 0, plotworld.ROAD_HEIGHT + 2, 0);
return new Location(world, 0, this.plotworld.ROAD_HEIGHT + 2, 0);
}
/*
* This part is a fucking mess.
* - Refer to a proper tutorial if you would like to learn how to make a world generator
* This part is a fucking mess. - Refer to a proper tutorial if you would
* like to learn how to make a world generator
*/
@Override
public short[][] generateExtBlockSections(World world, Random random, int cx, int cz, BiomeGrid biomes) {
public short[][] generateExtBlockSections(World world, Random random,
int cx, int cz, BiomeGrid biomes) {
final int prime = 31;
int h = 1;
@ -235,26 +241,35 @@ public class WorldGenerator extends PlotGenerator {
// ROAD (0/24) The following is an inefficient placeholder as it is too
// much work to finish it
if ((this.pathsize > 16) && ((plotMinX > roadStartX) || (plotMinZ > roadStartZ)) && !((roadStartX < 16) && (roadStartZ < 16)) && (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) {
if ((this.pathsize > 16)
&& ((plotMinX > roadStartX) || (plotMinZ > roadStartZ))
&& !((roadStartX < 16) && (roadStartZ < 16))
&& (((roadStartX > 16) && (roadStartZ > 16)) || ((plotMinX > roadStartX) && (plotMinZ > roadStartZ)))) {
setCuboidRegion(0, 16, 1, this.roadheight + 1, 0, 16, this.floor1);
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
@ -275,8 +290,11 @@ public class WorldGenerator extends PlotGenerator {
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);
@ -294,8 +312,10 @@ public class WorldGenerator extends PlotGenerator {
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;
@ -313,8 +333,11 @@ public class WorldGenerator extends PlotGenerator {
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;
@ -332,8 +355,12 @@ public class WorldGenerator extends PlotGenerator {
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); //
}
}
@ -341,36 +368,53 @@ 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 {
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);
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);
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) {
@ -378,8 +422,10 @@ public class WorldGenerator extends PlotGenerator {
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);
}
}
}
@ -390,8 +436,11 @@ public class WorldGenerator extends PlotGenerator {
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 {
if (roadStartZ > 16) {
@ -404,11 +453,15 @@ 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);
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);
}
}
}
@ -416,22 +469,34 @@ public class WorldGenerator extends PlotGenerator {
} 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);
}
}
}
@ -453,10 +518,16 @@ public class WorldGenerator extends PlotGenerator {
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;
@ -473,10 +544,16 @@ public class WorldGenerator extends PlotGenerator {
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;
@ -493,10 +570,18 @@ public class WorldGenerator extends PlotGenerator {
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;
@ -513,10 +598,16 @@ public class WorldGenerator extends PlotGenerator {
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

@ -20,8 +20,8 @@ public class XPopulator extends BlockPopulator {
/*
* Sorry, this isn't well documented at the moment.
*
* We advise you to take a look at a world generation tutorial for information about how a BlockPopulator works.
*
* We advise you to take a look at a world generation tutorial for
* information about how a BlockPopulator works.
*/
private int X;
@ -46,7 +46,8 @@ 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;
}
@ -59,7 +60,8 @@ public class XPopulator extends BlockPopulator {
}
}
private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1, int z2, PlotBlock[] blocks, World w) {
private void setCuboidRegion(int x1, int x2, int y1, int y2, int z1,
int z2, PlotBlock[] blocks, World w) {
if (blocks.length == 1) {
setCuboidRegion(x1, x2, y1, y2, z1, z2, blocks[0], w);
} else {
@ -80,7 +82,8 @@ 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 };
}
@ -107,22 +110,22 @@ public class XPopulator extends BlockPopulator {
// save configuration
plotsize = plotworld.PLOT_WIDTH;
pathsize = plotworld.ROAD_WIDTH;
this.plotsize = this.plotworld.PLOT_WIDTH;
this.pathsize = this.plotworld.ROAD_WIDTH;
floor1 = plotworld.ROAD_BLOCK;
floor2 = plotworld.ROAD_STRIPES;
this.floor1 = this.plotworld.ROAD_BLOCK;
this.floor2 = this.plotworld.ROAD_STRIPES;
wallfilling = plotworld.WALL_FILLING;
size = pathsize + plotsize;
wall = plotworld.WALL_BLOCK;
this.wallfilling = this.plotworld.WALL_FILLING;
this.size = this.pathsize + this.plotsize;
this.wall = this.plotworld.WALL_BLOCK;
plotfloors = plotworld.TOP_BLOCK;
filling = plotworld.MAIN_BLOCK;
this.plotfloors = this.plotworld.TOP_BLOCK;
this.filling = this.plotworld.MAIN_BLOCK;
wallheight = plotworld.WALL_HEIGHT;
roadheight = plotworld.ROAD_HEIGHT;
plotheight = plotworld.PLOT_HEIGHT;
this.wallheight = this.plotworld.WALL_HEIGHT;
this.roadheight = this.plotworld.ROAD_HEIGHT;
this.plotheight = this.plotworld.PLOT_HEIGHT;
if ((this.pathsize % 2) == 0) {
this.pathWidthLower = Math.floor(this.pathsize / 2) - 1;
@ -145,7 +148,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);
@ -159,26 +163,36 @@ public class XPopulator extends BlockPopulator {
// ROADS
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);
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);
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
@ -199,8 +213,11 @@ public class XPopulator extends BlockPopulator {
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);
@ -218,8 +235,10 @@ public class XPopulator extends BlockPopulator {
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;
@ -237,8 +256,11 @@ public class XPopulator extends BlockPopulator {
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;
@ -256,8 +278,12 @@ public class XPopulator extends BlockPopulator {
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
@ -277,10 +303,16 @@ public class XPopulator extends BlockPopulator {
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;
@ -297,10 +329,16 @@ public class XPopulator extends BlockPopulator {
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;
@ -317,10 +355,18 @@ public class XPopulator extends BlockPopulator {
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;
@ -337,10 +383,16 @@ public class XPopulator extends BlockPopulator {
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);
}
}
@ -349,36 +401,53 @@ 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 {
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);
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);
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) {
@ -386,8 +455,11 @@ public class XPopulator extends BlockPopulator {
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);
}
}
}
@ -398,8 +470,11 @@ public class XPopulator extends BlockPopulator {
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 {
if (roadStartZ > 16) {
@ -412,11 +487,17 @@ 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);
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);
}
}
}
@ -424,22 +505,34 @@ public class XPopulator extends BlockPopulator {
} 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

@ -42,7 +42,6 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.EntityBlockFormEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
@ -65,7 +64,6 @@ import org.bukkit.event.world.WorldLoadEvent;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
@ -91,26 +89,36 @@ 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()));
if (p2==null)
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;
if (p1==null)
}
if (p1 == null) {
return true;
if (p1.equals(p2))
}
if (p1.equals(p2)) {
return false;
}
return true;
}
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()));
if (p1==null)
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;
if (p2==null)
}
if (p2 == null) {
return true;
if (p1.equals(p2))
}
if (p1.equals(p2)) {
return false;
}
return true;
}
@ -135,7 +143,8 @@ 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
@ -152,14 +161,16 @@ 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 {
textures(event.getPlayer());
@ -169,10 +180,14 @@ 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);
@ -180,7 +195,8 @@ 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());
@ -192,9 +208,11 @@ 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();
@ -208,7 +226,8 @@ public class PlayerEvents implements Listener {
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;
}
@ -255,7 +274,8 @@ 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);
}
@ -467,7 +487,8 @@ public class PlayerEvents implements Listener {
@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);
}
@ -502,7 +523,12 @@ public class PlayerEvents implements Listener {
}
if (isInPlot(event.getClickedBlock().getLocation())) {
Plot plot = getCurrentPlot(event.getClickedBlock().getLocation());
if (new ArrayList<>(Arrays.asList(new Material[] { Material.STONE_BUTTON, Material.WOOD_BUTTON, Material.LEVER, Material.STONE_PLATE, Material.WOOD_PLATE, Material.CHEST, Material.TRAPPED_CHEST, Material.TRAP_DOOR, Material.WOOD_DOOR, Material.WOODEN_DOOR, Material.DISPENSER, Material.DROPPER
if (new ArrayList<>(Arrays.asList(new Material[] {
Material.STONE_BUTTON, Material.WOOD_BUTTON,
Material.LEVER, Material.STONE_PLATE, Material.WOOD_PLATE,
Material.CHEST, Material.TRAPPED_CHEST, Material.TRAP_DOOR,
Material.WOOD_DOOR, Material.WOODEN_DOOR,
Material.DISPENSER, Material.DROPPER
})).contains(event.getClickedBlock().getType())) {
return;
@ -572,22 +598,24 @@ 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);
}
}
@ -597,7 +625,8 @@ public class PlayerEvents implements Listener {
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);
@ -605,10 +634,12 @@ public class PlayerEvents implements Listener {
} else {
Plot plot = getCurrentPlot(b.getLocation());
if (plot == null) {
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);
PlayerFunctions.sendMessage(e.getPlayer(),
C.NO_PERMISSION);
e.setCancelled(true);
}
}
@ -618,7 +649,8 @@ public class PlayerEvents implements Listener {
@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);
}
}
@ -634,10 +666,12 @@ public class PlayerEvents implements Listener {
} else {
Plot plot = getCurrentPlot(b.getLocation());
if (plot == null) {
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);
PlayerFunctions.sendMessage(e.getPlayer(),
C.NO_PERMISSION);
e.setCancelled(true);
}
}

View File

@ -33,8 +33,10 @@ import com.intellectualcrafters.plot.database.DBFunc;
*/
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()));
@ -52,12 +54,17 @@ 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);
}
}
@ -66,7 +73,8 @@ public class WorldEditListener implements Listener {
@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();
@ -76,7 +84,9 @@ 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)) {
@ -107,7 +117,8 @@ 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")) {

View File

@ -50,7 +50,8 @@ 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) {
@ -60,7 +61,8 @@ public class WorldGuardListener implements Listener {
}
}
public void addFlag(Player requester, World world, Plot plot, String key, String value) {
public void addFlag(Player requester, World world, Plot plot, String key,
String value) {
boolean op = requester.isOp();
requester.setOp(true);
try {
@ -68,7 +70,9 @@ 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) {
@ -95,12 +99,17 @@ 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);
@ -130,9 +139,12 @@ 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);
@ -148,15 +160,21 @@ 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

@ -35,8 +35,11 @@ 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,12 +40,15 @@ 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");
@ -60,7 +63,8 @@ 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();
@ -79,7 +83,9 @@ 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) {
@ -91,7 +97,8 @@ 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,13 +37,15 @@ 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";
@ -55,7 +57,9 @@ 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();
@ -68,11 +72,18 @@ public class IndexHandler implements Container {
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();

View File

@ -34,7 +34,8 @@ 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,17 +13,23 @@ 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());
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 + 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);