mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 02:25:41 +01:00
Another huge commit. Style once again, hopefully for the last time.
And we're now using CheckStyle-suppression-comments, thanks @lithium3141.
This commit is contained in:
parent
10d849dc51
commit
bb0b26e03c
@ -5,7 +5,9 @@
|
||||
~ with this project. ~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
|
||||
|
||||
<!DOCTYPE module SYSTEM "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
<!-- Future reference: valid severity values are 'ignore', 'info', 'warning', 'error' -->
|
||||
<module name="Checker">
|
||||
<module name="JavadocPackage">
|
||||
@ -23,7 +25,19 @@
|
||||
<property name="message" value="Line has trailing spaces."/>
|
||||
<property name="format" value="\s+$"/>
|
||||
</module>
|
||||
<module name="SuppressWithNearbyCommentFilter"/>
|
||||
<module name="SuppressWithNearbyCommentFilter">
|
||||
<property name="commentFormat" value="SUPPRESS CHECKSTYLE: (\w+)"/>
|
||||
<property name="checkFormat" value="$1"/>
|
||||
</module>
|
||||
<module name="SuppressionCommentFilter">
|
||||
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: (\w+)"/>
|
||||
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: (\w+)"/>
|
||||
<property name="checkFormat" value="$1"/>
|
||||
</module>
|
||||
<module name="SuppressionCommentFilter">
|
||||
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: ALL"/>
|
||||
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: ALL"/>
|
||||
</module>
|
||||
<module name="TreeWalker">
|
||||
<!-- Make suppression possible -->
|
||||
<module name="FileContentsHolder"/>
|
||||
@ -98,17 +112,7 @@
|
||||
<module name="IllegalInstantiation"/>
|
||||
<module name="InnerAssignment"/>
|
||||
<module name="MagicNumber">
|
||||
<property name="ignoreNumbers" value="-1, 0, 0.5, 1, 2, 3, 4, 5 7, 8, 127, 45, 90, 135, 180, 225, 270, 315, 22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, 337.5, 180, 360, 5000"/>
|
||||
<!-- Explanations why we ignore certain magic numbers: -->
|
||||
<!-- 3: Log-level -->
|
||||
<!-- 4, 5: Array-indexes in Destinations -->
|
||||
<!-- 8: Default nether scale in MVWorld -->
|
||||
<!-- 7: max number of args in CreateCommand -->
|
||||
<!-- 127: max Y-coord in BlockSafety -->
|
||||
<!-- 45, 90, 135, 180, 225, 270, 315: Orientation-degrees in LocationManipulation -->
|
||||
<!-- 22.5, 67.5, 112.5, 157.5, 202.5, 247.5, 292.5, 337.5: Orientation-degrees in LocationManipulation -->
|
||||
<!-- 180, 360: Orientation-degrees in LocationManipulation -->
|
||||
<!-- 5000: Default messagecooldown in MultiverseCore -->
|
||||
<property name="ignoreNumbers" value="-1, 0, 0.5, 1, 2, 3"/>
|
||||
</module>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="RedundantThrows"/>
|
||||
|
@ -35,6 +35,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -66,14 +67,18 @@ public class MVWorld implements MultiverseWorld {
|
||||
private Map<String, String> propertyAliases;
|
||||
private Permission ignoreperm;
|
||||
|
||||
private static final Map<String, String> staticTimes = new HashMap<String, String>();
|
||||
private static final Map<String, String> TIME_ALIASES;
|
||||
|
||||
static {
|
||||
Map<String, String> staticTimes = new HashMap<String, String>();
|
||||
staticTimes.put("morning", "8:00");
|
||||
staticTimes.put("day", "12:00");
|
||||
staticTimes.put("noon", "12:00");
|
||||
staticTimes.put("midnight", "0:00");
|
||||
staticTimes.put("night", "20:00");
|
||||
|
||||
// now set TIME_ALIASES to a "frozen" map
|
||||
TIME_ALIASES = Collections.unmodifiableMap(staticTimes);
|
||||
}
|
||||
|
||||
public MVWorld(World world, FileConfiguration config, MultiverseCore instance, Long seed, String generatorString, boolean fixSpawn) {
|
||||
@ -239,7 +244,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
|
||||
private double getDefaultScale(Environment environment) {
|
||||
if (environment == Environment.NETHER) {
|
||||
return 8.0;
|
||||
return 8.0; // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
@ -931,7 +936,8 @@ public class MVWorld implements MultiverseWorld {
|
||||
if (newerSpawn != null) {
|
||||
this.setSpawnLocation(newerSpawn);
|
||||
configLocation = this.getSpawnLocation();
|
||||
this.plugin.log(Level.INFO, "New Spawn for '" + this.getName() + "' is Located at: " + LocationManipulation.locationToString(configLocation));
|
||||
this.plugin.log(Level.INFO, "New Spawn for '" + this.getName()
|
||||
+ "' is Located at: " + LocationManipulation.locationToString(configLocation));
|
||||
} else {
|
||||
this.plugin.log(Level.SEVERE, "New safe spawn NOT found!!!");
|
||||
}
|
||||
@ -1052,8 +1058,12 @@ public class MVWorld implements MultiverseWorld {
|
||||
long time = this.getCBWorld().getTime();
|
||||
// I'm tired, so they get time in 24 hour for now.
|
||||
// Someone else can add 12 hr format if they want :P
|
||||
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
int hours = (int) ((time / 1000 + 8) % 24);
|
||||
int minutes = (int) (60 * (time % 1000) / 1000);
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
|
||||
return String.format("%d:%02d", hours, minutes);
|
||||
}
|
||||
|
||||
@ -1061,9 +1071,10 @@ public class MVWorld implements MultiverseWorld {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
public boolean setTime(String timeAsString) {
|
||||
if (staticTimes.containsKey(timeAsString.toLowerCase())) {
|
||||
return this.setTime(staticTimes.get(timeAsString.toLowerCase()));
|
||||
if (TIME_ALIASES.containsKey(timeAsString.toLowerCase())) {
|
||||
return this.setTime(TIME_ALIASES.get(timeAsString.toLowerCase()));
|
||||
}
|
||||
// Regex that extracts a time in the following formats:
|
||||
// 11:11pm, 11:11, 23:11, 1111, 1111p, and the aliases at the top of this file.
|
||||
@ -1087,7 +1098,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
}
|
||||
}
|
||||
// Translate 24th hour to 0th hour.
|
||||
if (hour == 24) {
|
||||
if (hour == 24) { // SUPPRESS CHECKSTYLE MagicNumberCheck
|
||||
hour = 0;
|
||||
}
|
||||
// Clamp the hour
|
||||
@ -1110,6 +1121,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
this.getCBWorld().setTime((long) totaltime);
|
||||
return true;
|
||||
}
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -70,6 +70,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// Multiverse should stop other plugins from teleporting players
|
||||
// to worlds.
|
||||
// TODO This is REALLY bad style! We have to change this!
|
||||
// No, I'm NOT going to suppress these warnings because we HAVE TO CHANGE THIS!
|
||||
public static boolean EnforceAccess;
|
||||
public static boolean PrefixChat;
|
||||
public static boolean DisplayPermErrors;
|
||||
@ -367,7 +368,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// Should permissions errors display to users?
|
||||
DisplayPermErrors = this.multiverseConfig.getBoolean("displaypermerrors", true);
|
||||
|
||||
this.messaging.setCooldown(this.multiverseConfig.getInt("messagecooldown", 5000));
|
||||
this.messaging.setCooldown(this.multiverseConfig.getInt("messagecooldown", 5000)); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
// Update the version of the config!
|
||||
this.multiverseConfig.set("version", coreDefaults.get("version"));
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
|
||||
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething " + ChatColor.RED + "-d");
|
||||
this.addCommandExample("/mv anchors ");
|
||||
this.setPermission("multiverse.core.anchor", "Allows management of Anchor Destinations.", PermissionDefault.OP);
|
||||
this.setItemsPerPage(8);
|
||||
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
|
||||
private List<String> getFancyAnchorList(Player p) {
|
||||
|
@ -29,7 +29,7 @@ public class CreateCommand extends MultiverseCommand {
|
||||
super(plugin);
|
||||
this.setName("Create World");
|
||||
this.setCommandUsage("/mv create" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]] [-n]");
|
||||
this.setArgRange(2, 7);
|
||||
this.setArgRange(2, 7); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.addKey("mvcreate");
|
||||
this.addKey("mvc");
|
||||
this.addKey("mv create");
|
||||
|
@ -5,6 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
// TODO maybe remove this comment...?
|
||||
// This file is no longer licensed under that silly CC license. I have blanked it out and will start implementaiton of my own in a few days. For now there is no help.
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
@ -36,7 +37,7 @@ public class HelpCommand extends PaginatedCoreCommand<Command> {
|
||||
this.addKey("mv search");
|
||||
this.addCommandExample("/mv help ?");
|
||||
this.setPermission("multiverse.help", "Displays a nice help menu.", PermissionDefault.TRUE);
|
||||
this.setItemsPerPage(7);
|
||||
this.setItemsPerPage(7); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,7 +32,7 @@ public class ListCommand extends PaginatedCoreCommand<String> {
|
||||
this.addKey("mvl");
|
||||
this.addKey("mv list");
|
||||
this.setPermission("multiverse.core.list.worlds", "Displays a listing of all worlds that you can enter.", PermissionDefault.OP);
|
||||
this.setItemsPerPage(8);
|
||||
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
|
||||
private List<String> getFancyWorldList(Player p) {
|
||||
|
@ -39,7 +39,8 @@ public class ModifyAddCommand extends MultiverseCommand {
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "sheep " + ChatColor.RED + "animals");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "creeper " + ChatColor.RED + "monsters");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "add " + ChatColor.GREEN + "MyWorld " + ChatColor.RED + "worldblacklist");
|
||||
this.setPermission("multiverse.core.modify.add", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
|
||||
this.setPermission("multiverse.core.modify.add", "Modify various aspects of worlds. See the help wiki for how to use this command properly. "
|
||||
+ "If you do not include a world, the current world will be used.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,8 @@ public class ModifyClearCommand extends MultiverseCommand {
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "animals");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "monsters");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "clear " + ChatColor.RED + "worldblacklist");
|
||||
this.setPermission("multiverse.core.modify.clear", "Removes all values from a property. This will work on properties that contain lists.", PermissionDefault.OP);
|
||||
this.setPermission("multiverse.core.modify.clear",
|
||||
"Removes all values from a property. This will work on properties that contain lists.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@ -76,9 +77,11 @@ public class ModifyClearCommand extends MultiverseCommand {
|
||||
}
|
||||
if (world.clearList(property)) {
|
||||
sender.sendMessage(property + " was cleared. It contains 0 values now.");
|
||||
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + property + ChatColor.WHITE + " was " + ChatColor.GREEN + "CLEARED" + ChatColor.WHITE + ". It contains " + ChatColor.LIGHT_PURPLE + "0" + ChatColor.WHITE + " values now.");
|
||||
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + property + ChatColor.WHITE + " was "
|
||||
+ ChatColor.GREEN + "CLEARED" + ChatColor.WHITE + ". It contains " + ChatColor.LIGHT_PURPLE + "0" + ChatColor.WHITE + " values now.");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Error: " + ChatColor.GOLD + property + ChatColor.WHITE + " was " + ChatColor.GOLD + "NOT" + ChatColor.WHITE + " cleared.");
|
||||
sender.sendMessage(ChatColor.RED + "Error: " + ChatColor.GOLD + property
|
||||
+ ChatColor.WHITE + " was " + ChatColor.GOLD + "NOT" + ChatColor.WHITE + " cleared.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,8 @@ public class ModifyCommand extends MultiverseCommand {
|
||||
children.put("multiverse.core.modify.modify", true);
|
||||
children.put("multiverse.core.modify.clear", true);
|
||||
children.put("multiverse.core.modify.remove", true);
|
||||
Permission modify = new Permission("multiverse.core.modify", "Modify various aspects of worlds. It requires add/set/clear/remove. See the examples below", PermissionDefault.OP, children);
|
||||
Permission modify = new Permission("multiverse.core.modify",
|
||||
"Modify various aspects of worlds. It requires add/set/clear/remove. See the examples below", PermissionDefault.OP, children);
|
||||
this.addCommandExample(ChatColor.AQUA + "/mv modify set ?");
|
||||
this.addCommandExample(ChatColor.GREEN + "/mv modify add ?");
|
||||
this.addCommandExample(ChatColor.BLUE + "/mv modify clear ?");
|
||||
|
@ -40,7 +40,8 @@ public class ModifyRemoveCommand extends MultiverseCommand {
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "sheep " + ChatColor.RED + "animals");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "creeper " + ChatColor.RED + "monsters");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "remove " + ChatColor.GREEN + "MyWorld " + ChatColor.RED + "worldblacklist");
|
||||
this.setPermission("multiverse.core.modify.remove", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
|
||||
this.setPermission("multiverse.core.modify.remove", "Modify various aspects of worlds. See the help wiki for how to use this command properly. "
|
||||
+ "If you do not include a world, the current world will be used.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,8 @@ public class ModifySetCommand extends MultiverseCommand {
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "heal " + ChatColor.RED + "true");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "adjustspawn " + ChatColor.RED + "false");
|
||||
this.addCommandExample("/mvm " + ChatColor.GOLD + "set " + ChatColor.GREEN + "spawn");
|
||||
this.setPermission("multiverse.core.modify.set", "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used.", PermissionDefault.OP);
|
||||
this.setPermission("multiverse.core.modify.set", "Modify various aspects of worlds. See the help wiki for how to use this command properly. "
|
||||
+ "If you do not include a world, the current world will be used.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -108,7 +109,8 @@ public class ModifySetCommand extends MultiverseCommand {
|
||||
}
|
||||
try {
|
||||
if (world.setProperty(property, value, sender)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property + ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
|
||||
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property
|
||||
+ ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
|
||||
} else {
|
||||
sender.sendMessage(world.getProperty(property, Object.class).getHelp());
|
||||
}
|
||||
|
@ -51,10 +51,13 @@ public class SpoutCommand extends MultiverseCommand {
|
||||
}
|
||||
PopupScreen pop = new GenericPopup();
|
||||
GenericButton button = new GenericButton("Fish");
|
||||
// TODO maybe use constants for these
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
button.setX(50);
|
||||
button.setY(50);
|
||||
button.setWidth(100);
|
||||
button.setHeight(40);
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
pop.attachWidget(this.plugin, button);
|
||||
sender.sendMessage(ChatColor.GREEN + "YAY!");
|
||||
p.getMainScreen().attachPopupScreen(pop);
|
||||
|
@ -32,16 +32,25 @@ public class BooleanConfigProperty implements MVConfigProperty<Boolean> {
|
||||
this.setValue(this.section.getBoolean(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Boolean getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(Boolean value) {
|
||||
if (value == null) {
|
||||
@ -52,6 +61,9 @@ public class BooleanConfigProperty implements MVConfigProperty<Boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
if (value == null) {
|
||||
@ -64,18 +76,24 @@ public class BooleanConfigProperty implements MVConfigProperty<Boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getConfigNode() {
|
||||
return this.configNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
}
|
||||
|
@ -33,16 +33,25 @@ public class ColorConfigProperty implements MVConfigProperty<EnglishChatColor> {
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public EnglishChatColor getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(EnglishChatColor value) {
|
||||
if (value == null) {
|
||||
@ -53,6 +62,9 @@ public class ColorConfigProperty implements MVConfigProperty<EnglishChatColor> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
EnglishChatColor color = EnglishChatColor.fromString(value);
|
||||
@ -63,18 +75,24 @@ public class ColorConfigProperty implements MVConfigProperty<EnglishChatColor> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getConfigNode() {
|
||||
return this.configNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
}
|
||||
|
@ -33,16 +33,25 @@ public class DifficultyConfigProperty implements MVConfigProperty<Difficulty> {
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Difficulty getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(Difficulty value) {
|
||||
if (value == null) {
|
||||
@ -53,6 +62,9 @@ public class DifficultyConfigProperty implements MVConfigProperty<Difficulty> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
try {
|
||||
@ -66,18 +78,24 @@ public class DifficultyConfigProperty implements MVConfigProperty<Difficulty> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getConfigNode() {
|
||||
return this.configNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
}
|
||||
|
@ -32,16 +32,25 @@ public class DoubleConfigProperty implements MVConfigProperty<Double> {
|
||||
this.setValue(this.section.getDouble(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Double getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(Double value) {
|
||||
if (value == null) {
|
||||
@ -52,6 +61,9 @@ public class DoubleConfigProperty implements MVConfigProperty<Double> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
try {
|
||||
@ -62,18 +74,24 @@ public class DoubleConfigProperty implements MVConfigProperty<Double> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getConfigNode() {
|
||||
return this.configNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
}
|
||||
|
@ -33,16 +33,25 @@ public class GameModeConfigProperty implements MVConfigProperty<GameMode> {
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public GameMode getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(GameMode value) {
|
||||
if (value == null) {
|
||||
@ -53,6 +62,9 @@ public class GameModeConfigProperty implements MVConfigProperty<GameMode> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
try {
|
||||
@ -66,18 +78,24 @@ public class GameModeConfigProperty implements MVConfigProperty<GameMode> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getConfigNode() {
|
||||
return this.configNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
}
|
||||
|
@ -32,16 +32,25 @@ public class IntegerConfigProperty implements MVConfigProperty<Integer> {
|
||||
this.setValue(this.section.getInt(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(Integer value) {
|
||||
if (value == null) {
|
||||
@ -52,6 +61,9 @@ public class IntegerConfigProperty implements MVConfigProperty<Integer> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
try {
|
||||
@ -62,18 +74,24 @@ public class IntegerConfigProperty implements MVConfigProperty<Integer> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getConfigNode() {
|
||||
return this.configNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
}
|
||||
|
@ -34,37 +34,50 @@ public class LocationConfigProperty implements MVConfigProperty<Location> {
|
||||
this.setValue(this.getLocationFromConfig(defaultValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
Location parsed = LocationManipulation.stringToLocation(value);
|
||||
return this.setValue(parsed);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getConfigNode() {
|
||||
return this.configNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return LocationManipulation.strCoordsRaw(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(Location value) {
|
||||
if (value == null) {
|
||||
@ -94,4 +107,9 @@ public class LocationConfigProperty implements MVConfigProperty<Location> {
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return LocationManipulation.strCoordsRaw(this.value);
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,17 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
/*
|
||||
* This is a mess, so I'm just going to suppress all warnings here.
|
||||
* BEGIN CHECKSTYLE-SUPPRESSION: ALL
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated This isn't used any more, is it?
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class MVConfigMigrator {
|
||||
|
||||
public List<String> createdDefaults = new ArrayList<String>();
|
||||
|
||||
public abstract boolean migrate(String name, File folder);
|
||||
@ -60,3 +69,7 @@ public abstract class MVConfigMigrator {
|
||||
return oldFolder;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* END CHECKSTYLE-SUPPRESSION: ALL
|
||||
*/
|
||||
|
@ -32,16 +32,25 @@ public class StringConfigProperty implements MVConfigProperty<String> {
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
if (value == null) {
|
||||
@ -51,21 +60,25 @@ public class StringConfigProperty implements MVConfigProperty<String> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getConfigNode() {
|
||||
return this.configNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(String value) {
|
||||
if (value == null) {
|
||||
@ -75,4 +88,9 @@ public class StringConfigProperty implements MVConfigProperty<String> {
|
||||
this.section.set(configNode, this.value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
@ -28,20 +28,33 @@ public class TempStringConfigProperty implements MVConfigProperty<String> {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the method used to set this {@link TempStringConfigProperty}.
|
||||
* @return The name of that method.
|
||||
*/
|
||||
public String getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
if (value == null) {
|
||||
@ -51,21 +64,25 @@ public class TempStringConfigProperty implements MVConfigProperty<String> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getConfigNode() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(String value) {
|
||||
if (value == null) {
|
||||
@ -74,4 +91,9 @@ public class TempStringConfigProperty implements MVConfigProperty<String> {
|
||||
this.value = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
@ -81,9 +81,11 @@ public class CannonDestination implements MVDestination {
|
||||
}
|
||||
|
||||
try {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
Float.parseFloat(parsed.get(3));
|
||||
Float.parseFloat(parsed.get(4));
|
||||
Float.parseFloat(parsed.get(5));
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
@ -151,9 +153,11 @@ public class CannonDestination implements MVDestination {
|
||||
this.location.setZ(coords[2]);
|
||||
|
||||
try {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
this.location.setPitch(Float.parseFloat(parsed.get(3)));
|
||||
this.location.setYaw(Float.parseFloat(parsed.get(4)));
|
||||
this.speed = Math.abs(Float.parseFloat(parsed.get(5)));
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
} catch (NumberFormatException e) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
@ -196,15 +200,6 @@ public class CannonDestination implements MVDestination {
|
||||
this.isValid = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (isValid) {
|
||||
return "ca:" + location.getWorld().getName() + ":" + location.getX() + "," + location.getY()
|
||||
+ "," + location.getZ() + ":" + location.getPitch() + ":" + location.getYaw() + ":" + this.speed;
|
||||
}
|
||||
return "i:Invalid Destination";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ -220,4 +215,13 @@ public class CannonDestination implements MVDestination {
|
||||
public boolean useSafeTeleporter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (isValid) {
|
||||
return "ca:" + location.getWorld().getName() + ":" + location.getX() + "," + location.getY()
|
||||
+ "," + location.getZ() + ":" + location.getPitch() + ":" + location.getYaw() + ":" + this.speed;
|
||||
}
|
||||
return "i:Invalid Destination";
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class ExactDestination implements MVDestination {
|
||||
// Need at least: e:world:x,y,z
|
||||
// OR e:world:x,y,z:pitch:yaw
|
||||
// so basically 3 or 5
|
||||
if (!(parsed.size() == 3 || parsed.size() == 5)) {
|
||||
if (!(parsed.size() == 3 || parsed.size() == 5)) { // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
return false;
|
||||
}
|
||||
// If it's not an Exact type
|
||||
@ -76,7 +76,7 @@ public class ExactDestination implements MVDestination {
|
||||
|
||||
try {
|
||||
Float.parseFloat(parsed.get(3));
|
||||
Float.parseFloat(parsed.get(4));
|
||||
Float.parseFloat(parsed.get(4)); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
@ -111,7 +111,7 @@ public class ExactDestination implements MVDestination {
|
||||
// Need at least: e:world:x,y,z
|
||||
// OR e:world:x,y,z:pitch:yaw
|
||||
// so basically 3 or 5
|
||||
if (!(parsed.size() == 3 || parsed.size() == 5)) {
|
||||
if (!(parsed.size() == 3 || parsed.size() == 5)) { // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
@ -152,7 +152,7 @@ public class ExactDestination implements MVDestination {
|
||||
|
||||
try {
|
||||
this.location.setPitch(Float.parseFloat(parsed.get(3)));
|
||||
this.location.setYaw(Float.parseFloat(parsed.get(4)));
|
||||
this.location.setYaw(Float.parseFloat(parsed.get(4))); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
} catch (NumberFormatException e) {
|
||||
this.isValid = false;
|
||||
return;
|
||||
|
@ -106,7 +106,7 @@ public class BlockSafety {
|
||||
*/
|
||||
public Location getTopBlock(Location l) {
|
||||
Location check = l.clone();
|
||||
check.setY(127);
|
||||
check.setY(127); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
while (check.getY() > 0) {
|
||||
if (this.playerCanSpawnHereSafely(check)) {
|
||||
return check;
|
||||
@ -124,7 +124,7 @@ public class BlockSafety {
|
||||
public Location getBottomBlock(Location l) {
|
||||
Location check = l.clone();
|
||||
check.setY(0);
|
||||
while (check.getY() < 127) {
|
||||
while (check.getY() < 127) { // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
if (this.playerCanSpawnHereSafely(check)) {
|
||||
return check;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ public class LocationManipulation {
|
||||
private static Map<String, Integer> orientationInts = new HashMap<String, Integer>();
|
||||
|
||||
static {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
orientationInts.put("n", 180);
|
||||
orientationInts.put("ne", 225);
|
||||
orientationInts.put("e", 270);
|
||||
@ -39,6 +40,7 @@ public class LocationManipulation {
|
||||
|
||||
// "freeze" the map:
|
||||
orientationInts = Collections.unmodifiableMap(orientationInts);
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,7 +94,7 @@ public class LocationManipulation {
|
||||
// Split the whole string, format is:
|
||||
// {'world', 'x,y,z'[, 'pitch', 'yaw']}
|
||||
String[] split = locationString.split(":");
|
||||
if (split.length < 2 || split.length > 4) {
|
||||
if (split.length < 2 || split.length > 4) { // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
return null;
|
||||
}
|
||||
// Split the xyz string, format is:
|
||||
@ -114,7 +116,7 @@ public class LocationManipulation {
|
||||
if (split.length >= 3) {
|
||||
yaw = (float) Double.parseDouble(split[2]);
|
||||
}
|
||||
if (split.length == 4) {
|
||||
if (split.length == 4) { // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
pitch = (float) Double.parseDouble(split[3]);
|
||||
}
|
||||
return new Location(w, Double.parseDouble(xyzsplit[0]), Double.parseDouble(xyzsplit[1]), Double.parseDouble(xyzsplit[2]), yaw, pitch);
|
||||
@ -171,6 +173,7 @@ public class LocationManipulation {
|
||||
* @return The NESW Direction
|
||||
*/
|
||||
public static String getDirection(Location location) {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
double r = (location.getYaw() % 360) + 180;
|
||||
// Remember, these numbers are every 45 degrees with a 22.5 offset, to detect boundaries.
|
||||
String dir;
|
||||
@ -192,6 +195,7 @@ public class LocationManipulation {
|
||||
dir = "nw";
|
||||
else
|
||||
dir = "n";
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class MVMessaging {
|
||||
|
||||
public MVMessaging() {
|
||||
this.sentList = new HashMap<String, Long>();
|
||||
this.cooldown = 5000;
|
||||
this.cooldown = 5000; // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,6 +42,6 @@ public class MVPlayerSession {
|
||||
*/
|
||||
public boolean getTeleportable() {
|
||||
long time = (new Date()).getTime();
|
||||
return ((time - this.teleportLast) > this.config.getInt("portalcooldown", 5000));
|
||||
return ((time - this.teleportLast) > this.config.getInt("portalcooldown", 5000)); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
}
|
||||
|
@ -61,8 +61,8 @@ public class SafeTTeleporter {
|
||||
// TODO: Make this configurable
|
||||
Location safe = checkAboveAndBelowLocation(l, tolerance, radius);
|
||||
if (safe != null) {
|
||||
safe.setX(safe.getBlockX() + .5);
|
||||
safe.setZ(safe.getBlockZ() + .5);
|
||||
safe.setX(safe.getBlockX() + .5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
safe.setZ(safe.getBlockZ() + .5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.plugin.log(Level.FINE, "Hey! I found one: " + LocationManipulation.strCoordsRaw(safe));
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Uh oh! No safe place found!");
|
||||
|
@ -18,6 +18,17 @@ import java.util.TimerTask;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/*
|
||||
* Apparently this isn't used and I don't know if we'll ever use this,
|
||||
* so I'm just going to deprecate it for now and suppress the warnings.
|
||||
*
|
||||
* BEGIN CHECKSTYLE-SUPPRESSION: ALL
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated Currently unused.
|
||||
*/
|
||||
@Deprecated
|
||||
public class UpdateChecker {
|
||||
|
||||
public static final Logger log = Logger.getLogger("Minecraft");
|
||||
@ -104,3 +115,7 @@ public class UpdateChecker {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* END CHECKSTYLE-SUPPRESSION: ALL
|
||||
*/
|
||||
|
@ -1,5 +1,8 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
/**
|
||||
* Thrown when pasting failed.
|
||||
*/
|
||||
public class PasteFailedException extends Exception {
|
||||
public PasteFailedException() {
|
||||
super();
|
||||
|
@ -37,6 +37,7 @@ public interface PasteService {
|
||||
* @param encodedData A URL-encoded String containing the full request to post to
|
||||
* the given URL. Can be the result of calling #encodeData().
|
||||
* @param url The URL to which to paste. Can be the result of calling #getPostURL().
|
||||
* @throws PasteFailedException When pasting/posting the data failed.
|
||||
* @return The URL at which the new paste is visible.
|
||||
*/
|
||||
String postData(String encodedData, URL url) throws PasteFailedException;
|
||||
|
@ -1,13 +1,25 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
/**
|
||||
* Used to construct {@link PasteService}s.
|
||||
*/
|
||||
public class PasteServiceFactory {
|
||||
private PasteServiceFactory() { }
|
||||
|
||||
/**
|
||||
* Constructs a new {@link PasteService}.
|
||||
* @param type The {@link PasteServiceType}.
|
||||
* @param isPrivate Whether the new {@link PasteService} should create private pastes.
|
||||
* @return The newly created {@link PasteService}.
|
||||
*/
|
||||
public static PasteService getService(PasteServiceType type, boolean isPrivate) {
|
||||
switch(type) {
|
||||
case PASTEBIN: return new PastebinPasteService(isPrivate);
|
||||
case PASTIE: return new PastiePasteService(isPrivate);
|
||||
default: return null;
|
||||
case PASTEBIN:
|
||||
return new PastebinPasteService(isPrivate);
|
||||
case PASTIE:
|
||||
return new PastiePasteService(isPrivate);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,18 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
/**
|
||||
* An enum containing all known {@link PasteService}s.
|
||||
*
|
||||
* @see PasteService
|
||||
* @see PasteServiceFactory
|
||||
*/
|
||||
public enum PasteServiceType {
|
||||
/**
|
||||
* @see PastebinPasteService
|
||||
*/
|
||||
PASTEBIN,
|
||||
/**
|
||||
* @see PastiePasteService
|
||||
*/
|
||||
PASTIE
|
||||
}
|
||||
|
@ -10,14 +10,21 @@ import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Pastes to {@code pastebin.com}.
|
||||
*/
|
||||
public class PastebinPasteService implements PasteService {
|
||||
|
||||
protected boolean isPrivate;
|
||||
private boolean isPrivate;
|
||||
|
||||
public PastebinPasteService(boolean isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URL getPostURL() {
|
||||
try {
|
||||
return new URL("http://pastebin.com/api/api_post.php");
|
||||
@ -26,6 +33,10 @@ public class PastebinPasteService implements PasteService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String encodeData(String data) {
|
||||
try {
|
||||
String encData = URLEncoder.encode("api_dev_key", "UTF-8") + "=" + URLEncoder.encode("d61d68d31e8e0392b59b50b277411c71", "UTF-8");
|
||||
@ -39,6 +50,10 @@ public class PastebinPasteService implements PasteService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String postData(String encodedData, URL url) throws PasteFailedException {
|
||||
try {
|
||||
URLConnection conn = url.openConnection();
|
||||
@ -61,6 +76,7 @@ public class PastebinPasteService implements PasteService {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO maybe remove this?
|
||||
private Pattern getURLMatchingPattern() {
|
||||
if (this.isPrivate) {
|
||||
return Pattern.compile(".*http://pastie.org/.*key=([0-9a-z]+).*");
|
||||
@ -69,6 +85,7 @@ public class PastebinPasteService implements PasteService {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO maybe remove this?
|
||||
private String formatURL(String pastieID) {
|
||||
return "http://pastie.org/" + (this.isPrivate ? "private/" : "") + pastieID;
|
||||
}
|
||||
|
@ -11,14 +11,21 @@ import java.net.URLEncoder;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Pastes to {@code pastie.org}.
|
||||
*/
|
||||
public class PastiePasteService implements PasteService {
|
||||
|
||||
protected boolean isPrivate;
|
||||
private boolean isPrivate;
|
||||
|
||||
public PastiePasteService(boolean isPrivate) {
|
||||
this.isPrivate = isPrivate;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public URL getPostURL() {
|
||||
try {
|
||||
return new URL("http://pastie.org/pastes");
|
||||
@ -27,6 +34,10 @@ public class PastiePasteService implements PasteService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String encodeData(String data) {
|
||||
try {
|
||||
String encData = URLEncoder.encode("paste[authorization]", "UTF-8") + "=" + URLEncoder.encode("burger", "UTF-8"); // burger is magic
|
||||
@ -39,6 +50,10 @@ public class PastiePasteService implements PasteService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String postData(String encodedData, URL url) throws PasteFailedException {
|
||||
try {
|
||||
URLConnection conn = url.openConnection();
|
||||
|
Loading…
Reference in New Issue
Block a user