cleaned up the code

This commit is contained in:
Alastair 2016-03-29 12:38:03 +01:00
parent 08d2a58c45
commit 5430c27999
25 changed files with 2309 additions and 2427 deletions

View File

@ -62,8 +62,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
inventory.addItem(regionselector);
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been given a \u00A7ePortal Region Selector\u00A7a!");
}
else if(args[0].toLowerCase().equals("portal") || args[0].toLowerCase().equals("portalblock")){
} else if (args[0].toLowerCase().equals("portal") || args[0].toLowerCase().equals("portalblock")) {
Player player = (Player) sender;
PlayerInventory inventory = player.getInventory();
@ -72,8 +71,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
inventory.addItem(portalBlock);
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been given a \u00A7ePortal Block\u00A7a!");
}
else if(args[0].toLowerCase().equals("create")) {
} else if (args[0].toLowerCase().equals("create")) {
Player player = (Player) sender;
if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) {
if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString()) && player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) {
@ -98,38 +96,30 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
if (args[i].toLowerCase().startsWith("name:") && args[i].length() > 5) {
hasName = true;
portalName = args[i].replaceFirst("name:", "");
}
else if(args[i].toLowerCase().startsWith("name:")) {
} else if (args[i].toLowerCase().startsWith("name:")) {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You must include a name for the portal that isnt nothing!");
return true;
}
else if(args[i].toLowerCase().startsWith("destination:") && args[i].length() > 12){
} else if (args[i].toLowerCase().startsWith("destination:") && args[i].length() > 12) {
hasDestination = true;
destination = args[i].toLowerCase().replaceFirst("destination:", "");
}
else if(args[i].toLowerCase().startsWith("desti:") && args[i].length() > 6){
} else if (args[i].toLowerCase().startsWith("desti:") && args[i].length() > 6) {
hasDestination = true;
destination = args[i].toLowerCase().replaceFirst("desti:", "");
}
else if(args[i].toLowerCase().startsWith("triggerblock:") && args[i].length() > 13){
} else if (args[i].toLowerCase().startsWith("triggerblock:") && args[i].length() > 13) {
hasTriggerBlock = true;
triggerBlock = args[i].toLowerCase().replaceFirst("triggerblock:", "");
}
else if(args[i].toLowerCase().startsWith("triggerblock:") && args[i].length() > 13){
} else if (args[i].toLowerCase().startsWith("triggerblock:") && args[i].length() > 13) {
hasTriggerBlock = true;
triggerBlock = args[i].toLowerCase().replaceFirst("triggerblock:", "");
}
else if(args[i].toLowerCase().startsWith("bungee:") && args[i].length() > 7){ // not completely implemented
} else if (args[i].toLowerCase().startsWith("bungee:") && args[i].length() > 7) { // not completely implemented
isBungeePortal = true;
serverName = args[i].toLowerCase().replaceFirst("bungee:", "");
//extraData.add(new PortalArgs("bungee", serverName));
}
else if(args[i].toLowerCase().startsWith("permission:") && args[i].length() > 11){ // not completely implemented
} else if (args[i].toLowerCase().startsWith("permission:") && args[i].length() > 11) { // not completely implemented
needsPermission = true;
permission = args[i].toLowerCase().replaceFirst("permission:", "");
extraData.add(new PortalArg("permission", permission));
}
else if(args[i].toLowerCase().startsWith("command:") && args[i].length() > 8){ // not completely implemented
} else if (args[i].toLowerCase().startsWith("command:") && args[i].length() > 8) { // not completely implemented
executesCommand = true;
portalCommand = parseArgVariable(args, i, "command:");
i += this.portalArgsStringLength - 1;
@ -155,11 +145,9 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
player.sendMessage("\u00A7aname: \u00A7e" + portalName);
if (hasDestination) {
player.sendMessage("\u00A7adestination: \u00A7e" + destination);
}
else if(destiPosX == null){
} else if (destiPosX == null) {
player.sendMessage("\u00A7cdestination: \u00A7e" + destination + " (destination does not exist)");
}
else{
} else {
player.sendMessage("\u00A7cdestination: \u00A7eN/A (will not work)");
}
@ -169,8 +157,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
if (needsPermission) {
player.sendMessage("\u00A7apermission: \u00A7e" + permission);
}
else{
} else {
player.sendMessage("\u00A7apermission: \u00A7e(none needed)");
}
@ -186,8 +173,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
PortalArg[] portalArgs = new PortalArg[extraData.size()];
portalArgs = extraData.toArray(portalArgs);
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, triggerBlockMat, serverName, portalArgs));
}
else{
} else {
hasTriggerBlock = false;
ConfigAccessor Config = new ConfigAccessor(plugin, "config.yml");
player.sendMessage("\u00A7ctriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")");
@ -197,42 +183,35 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
portalArgs = extraData.toArray(portalArgs);
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, portalArgs));
}
}
else{
} else {
ConfigAccessor Config = new ConfigAccessor(plugin, "config.yml");
player.sendMessage("\u00A7atriggerBlock: \u00A7edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")");
PortalArg[] portalArgs = new PortalArg[extraData.size()];
portalArgs = extraData.toArray(portalArgs);
player.sendMessage(Portal.create(pos1, pos2, portalName, destination, serverName, portalArgs));
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] A portal by that name already exists!");
}
// add code to save the portal to the portal config and reload the portals
player.sendMessage("");
}
else{
} else {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to at least add the name of the portal as a variable, \u00A7cType \u00A7e/portal variables\u00A7c"
+ " for a full list of currently available variables and an example command!");
}
}
else{
} else {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The points you have selected need to be in the same world!");
}
}
else{
} else {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to have two points selected to make a portal!");
}
}
else if(args[0].toLowerCase().equals("variables")) {
} else if (args[0].toLowerCase().equals("variables")) {
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Currently available variables: name, triggerBlock, destination");
sender.sendMessage("");
sender.sendMessage("\u00A7aExample command: \u00A7e/portal create name:test triggerId:portal");
}
else if(args[0].toLowerCase().equals("select")) {
} else if (args[0].toLowerCase().equals("select")) {
// TODO finish the select command and the hit block to replace!
Player player = (Player) sender;
@ -240,23 +219,19 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
if (args.length > 1) {
if (Portal.portalExists(args[1])) {
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
}
else{
} else {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal by the name \u00A7e" + args[1] + "\u00A7c exists (maybe you got the caps wrong)\n Try typing \u00A7e/portal select\u00A7c and hit inside the apropriate portals area!");
}
}
else{
} else {
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Hit a block inside the portal region to select the portal!");
player.setMetadata("selectingPortal", new FixedMetadataValue(plugin, true));
}
}
else{
} else {
player.removeMetadata("selectingPortal", plugin);
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] Portal selection cancelled!");
}
}
else if(args[0].toLowerCase().equals("gui")){
} else if (args[0].toLowerCase().equals("gui")) {
Player player = (Player) sender;
if (args.length > 1) {
if (args[1].toLowerCase().equals("remove") && args.length > 2) {
@ -268,37 +243,31 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
sender.sendMessage("");
}
}
}
else if(args[0].toLowerCase().equals("edit")) {
} else if (args[0].toLowerCase().equals("edit")) {
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "portals.yml");
if (args.length > 1) {
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
if (posX != null) {
portalEditMenu(sender, portalConfig, args[1]);
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal by the name \u00A7e" + args[1] + "\u00A7c exists!");
}
}
else{
} else {
Player player = (Player) sender;
if (player.hasMetadata("selectedPortal")) {
String portalName = player.getMetadata("selectedPortal").get(0).asString();
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
if (posX != null) {
portalEditMenu(sender, portalConfig, portalName);
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you had selected no longer seems to exist!");
player.removeMetadata("selectedPortal", plugin);
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal has been defined or selected!");
}
}
}
else if(args[0].toLowerCase().equals("rename")) {
} else if (args[0].toLowerCase().equals("rename")) {
// not finished yet /
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "portals.yml");
@ -314,28 +283,22 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
Portal.rename(portalName, args[1]);
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] The portal \u00A7e" + portalName + "\u00A7a has been renamed to \u00A7e" + args[1] + "\u00A7a.");
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, args[1]));
}
else if(newPortalPosX != null){
} else if (newPortalPosX != null) {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] There is already a portal with the name \u00A7e" + args[1] + "\u00A7c!");
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you had selected no longer seems to exist!");
player.removeMetadata("selectedPortal", plugin);
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you have selected is already called that!");
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal has been defined or selected!");
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You must select a portal first and then type \u00A7e/portal rename (new name)\u00A7c!");
}
}
else if(args[0].toLowerCase().equals("command")) {
} else if (args[0].toLowerCase().equals("command")) {
Player player = (Player) sender;
if (player.hasMetadata("selectedPortal")) {
String portalName = player.getMetadata("selectedPortal").get(0).asString();
@ -349,48 +312,38 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
}
if (Portal.addCommand(portalName, portalCommand)) {
sender.sendMessage("\u00A77a[\u00A77eAdvancedPortals\u00A77a] Command added to portal!");
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] Failed to add command to portal!");
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You must actually specify a command to execute!");
}
}
else if(args[1].toLowerCase().equals("remove")) {
} else if (args[1].toLowerCase().equals("remove")) {
// Specify what line to remove
}
else if(args[1].toLowerCase().equals("show")) {
} else if (args[1].toLowerCase().equals("show")) {
// Show all the commands the portal executes
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You must specify to \u00A7eadd\u00A7c or \u00A7eremove a command!");
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You must specify to \u00A7eadd\u00A7c or \u00A7eremove\u00A7c a command!");
}
}
else{
} else {
}
}
else if(args[0].toLowerCase().equals("remove")) {
} else if (args[0].toLowerCase().equals("remove")) {
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "portals.yml");
if (args.length > 1) {
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
if (posX != null) {
Portal.remove(args[1]);
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal \u00A7e" + args[1] + "\u00A7c has been removed!");
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal by that name exists!");
}
}
else{
} else {
Player player = (Player) sender;
if (player.hasMetadata("selectedPortal")) {
String portalName = player.getMetadata("selectedPortal").get(0).asString();
@ -398,69 +351,55 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
if (posX != null) {
Portal.remove(portalName);
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal \u00A77" + portalName + "\u00A7c has been removed!");
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you had selected no longer seems to exist!");
player.removeMetadata("selectedPortal", plugin);
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal has been defined or selected!");
}
}
}
else if(args[0].toLowerCase().equals("help")) {
} else if (args[0].toLowerCase().equals("help")) {
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Still designing in game help page :(");
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] For now please use the wiki http://bit.ly/portals-help");
}
else if(args[0].toLowerCase().equals("bukkitpage")) {
} else if (args[0].toLowerCase().equals("bukkitpage")) {
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Bukkit page: http://bit.ly/adv-portals!");
}
else if(args[0].toLowerCase().equals("helppage")) {
} else if (args[0].toLowerCase().equals("helppage")) {
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Help page: http://bit.ly/portals-help!");
}
else if(args[0].toLowerCase().equals("show")){
} else if (args[0].toLowerCase().equals("show")) {
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "portals.yml");
Player player = (Player) sender;
if (args.length > 1) {
String posX = portalConfig.getConfig().getString(args[1] + ".pos1.X");
if (posX != null) {
Selection.Show(player, this.plugin, args[1]);
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal by that name exists!");
}
}
else{
} else {
if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) {
if (player.getMetadata("Pos1World").get(0).asString().equals(player.getMetadata("Pos2World").get(0).asString()) && player.getMetadata("Pos1World").get(0).asString().equals(player.getLocation().getWorld().getName())) {
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Your currently selected area has been shown, it will dissapear shortly!");
Selection.Show(player, this.plugin);
}
else{
} else {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The points you have selected need to be in the same world!");
}
}
else{
} else {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to have both points selected!");
}
}
}
else if(args[0].toLowerCase().equals("reload")) {
} else if (args[0].toLowerCase().equals("reload")) {
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Reloaded values!");
Listeners.reloadValues(plugin);
Portal.loadPortals();
}
else{
} else {
PluginMessages.UnknownCommand(sender, command);
}
}
else{
} else {
PluginMessages.UnknownCommand(sender, command);
}
}
else{
} else {
PluginMessages.NoPermission(sender, command);
}
@ -482,8 +421,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
break;
}
}
}
else{
} else {
variableString = variableString.substring(0, variableString.length() - 1);
}
@ -507,16 +445,14 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
String destination = portalConfig.getConfig().getString(portalName + ".destination");
if (destination != null) {
sender.sendMessage(" \u00A7adestination\u00A7e: " + destination);
}
else{
} else {
sender.sendMessage(" \u00A7cdestination\u00A7e: null");
}
String trigger = portalConfig.getConfig().getString(portalName + ".triggerblock");
if (trigger != null) {
sender.sendMessage(" \u00A7atriggerBlock\u00A7e: " + trigger);
}
else{
} else {
sender.sendMessage(" \u00A7ctriggerBlock\u00A7e: null");
}
@ -529,12 +465,10 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
}
if (--commands > 1) {
sender.sendMessage(" \u00A7acommands\u00A7e: " + commands + " commands");
}
else{
} else {
sender.sendMessage(" \u00A7acommands\u00A7e: " + commands + " command");
}
}
else{
} else {
sender.sendMessage(" \u00A7ccommands\u00A7e: none");
}
sender.sendMessage("");
@ -557,8 +491,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
if (args.length == 1) {
autoComplete.addAll(Arrays.asList("create", "portal", "portalblock", "select", "selector"
, "show", "variables", "wand", "remove", "rename", "help", "bukkitpage", "helppage"));
}
else if(args[0].toLowerCase().equals("create")){
} else if (args[0].toLowerCase().equals("create")) {
boolean hasName = false;
boolean hasTriggerBlock = false;
@ -600,12 +533,25 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
}
if(!hasName){autoComplete.add("name:");}
if(!hasTriggerBlock){autoComplete.add("triggerblock:");}
if(!hasDestination){autoComplete.add("destination:");autoComplete.add("desti:");}
if(!isBungeePortal){autoComplete.add("bungee:");}
if(!needsPermission){autoComplete.add("permission:");}
if(!hasCommand){autoComplete.add("command:");}
if (!hasName) {
autoComplete.add("name:");
}
if (!hasTriggerBlock) {
autoComplete.add("triggerblock:");
}
if (!hasDestination) {
autoComplete.add("destination:");
autoComplete.add("desti:");
}
if (!isBungeePortal) {
autoComplete.add("bungee:");
}
if (!needsPermission) {
autoComplete.add("permission:");
}
if (!hasCommand) {
autoComplete.add("command:");
}
}
}
Collections.sort(autoComplete);

View File

@ -39,8 +39,7 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
Class<?> nmsClass = Class.forName("com.sekwah.advancedportals.compat.bukkit." + version);
if (NMS.class.isAssignableFrom(nmsClass)) {
this.nmsAccess = (NMS) nmsClass.getConstructor().newInstance();
}else
{
} else {
System.out.println("Something went wrong, please notify the author and tell them this version v:" + version);
this.setEnabled(false);
}

View File

@ -21,26 +21,27 @@ public class DataCollector {
*
*/
/**public static void playerWarped() {
try {
Metrics metrics = new Metrics(plugin);
Graph TotalWarps = metrics.createGraph("Total Warps");
TotalWarps.addPlotter(new Metrics.Plotter("Internal Warps") {
@Override
public int getValue() {
return 1; // number of warps
}
});
metrics.start();
} catch (IOException e) {
plugin.getLogger().log(Level.SEVERE, "Could not submit data", e);
}
}*/
/**
* public static void playerWarped() {
* try {
* Metrics metrics = new Metrics(plugin);
* <p>
* Graph TotalWarps = metrics.createGraph("Total Warps");
* <p>
* TotalWarps.addPlotter(new Metrics.Plotter("Internal Warps") {
*
* @Override public int getValue() {
* return 1; // number of warps
* }
* <p>
* });
* <p>
* metrics.start();
* } catch (IOException e) {
* plugin.getLogger().log(Level.SEVERE, "Could not submit data", e);
* }
* }
*/
public static void setupMetrics() {
@ -55,8 +56,7 @@ public class DataCollector {
/**TotalWarps.addPlotter(new Metrics.Plotter(triggerName) {
@Override
public int getValue() {
@Override public int getValue() {
return 1; // number of portals created
}

View File

@ -43,36 +43,29 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
sender.sendMessage("§a[\u00A7eAdvancedPortals\u00A7a] You have created a new destination called \u00A7e" + args[1] + "!");
Player player = sender.getServer().getPlayer(sender.getName());
Destination.create(player.getLocation(), args[1]);
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] A destination by that name already exists!");
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] Please state the name of the destination you would like to create!");
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You do not have permission to create portals so you cannot give yourself a \u00A7ePortal Region Selector\u00A7c!");
}
}
else if(args[0].toLowerCase().equals("remove")) {
} else if (args[0].toLowerCase().equals("remove")) {
ConfigAccessor portalConfig = new ConfigAccessor(plugin, "destinations.yml");
if (args.length > 1) {
String posX = portalConfig.getConfig().getString(args[1] + ".pos.X");
if (posX != null) {
Destination.remove(args[1]);
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination \u00A7e" + args[1] + "\u00A7c has been removed!");
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No destination by that name exists.");
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to state the name of the destination you wish to remove.");
}
}
else if(args[0].toLowerCase().equals("goto") || args[0].toLowerCase().equals("warp")) {
} else if (args[0].toLowerCase().equals("goto") || args[0].toLowerCase().equals("warp")) {
if (args.length > 1) {
//System.out.println(args[1]);
ConfigAccessor configDesti = new ConfigAccessor(plugin, "destinations.yml");
@ -82,28 +75,23 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
sender.sendMessage("");
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + args[1].replaceAll("_", " ") + "\u00A7a.");
sender.sendMessage("");
}
else if(PortalMessagesDisplay == 2){
} else if (PortalMessagesDisplay == 2) {
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
plugin.nmsAccess.sendActionBarMessage("{\"text\":\"\u00A7aYou have warped to \u00A7e" + args[1].replaceAll("_", " ") + "\u00A7a.\"}", (Player) sender);
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ")
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No destination by that name exists.");
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to state the name of the destination you wish to exemptPlayer to.");
}
}
else if(args[0].toLowerCase().equals("list")) {
} else if (args[0].toLowerCase().equals("list")) {
List<String> destiList = Destination.destiList();
if (destiList.size() >= 1) {
if (args.length > 1) {
try
{
try {
int page = Integer.parseInt(args[1]);
if (page * 5 >= destiList.size() - 5) { // add this if statement so that the user cant select a list page higher than the max
if (destiList.size() / 5 == destiList.size()) {
@ -118,9 +106,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
sender.sendMessage(" \u00A7e" + destiList.get(i));
}
return true;
}
catch(Exception e)
{
} catch (Exception e) {
}
}
@ -139,13 +125,11 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
}
sender.sendMessage(" \u00A7e" + destiList.get(i));
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] There are currently no defined destinations.");
}
}
}
else{
} else {
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to type something after /" + command + ", if you do not know what you can put or would like some help with the commands please type /" + command + " help");
}
return true;
@ -159,8 +143,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
if (sender.hasPermission("AdvancedPortals.CreatePortal")) {
if (args.length == 1) {
autoComplete.addAll(Arrays.asList("create", "goto", "redefine", "move", "rename", "remove"));
}
else if(args[0].toLowerCase().equals("create")){
} else if (args[0].toLowerCase().equals("create")) {
}
}
Collections.sort(autoComplete);

View File

@ -18,12 +18,9 @@ public class Selection {
timeout = config.getConfig().getInt("ShowSelectionShowDuration");
String BlockID = config.getConfig().getString("ShowSelectionBlockID");
try
{
try {
blockType = Material.getMaterial(Integer.parseInt(BlockID));
}
catch(Exception e)
{
} catch (Exception e) {
blockType = Material.getMaterial(BlockID);
}
@ -127,24 +124,21 @@ public class Selection {
if (player.getMetadata("Pos1X").get(0).asInt() > player.getMetadata("Pos2X").get(0).asInt()) {
LowX = player.getMetadata("Pos2X").get(0).asInt();
HighX = player.getMetadata("Pos1X").get(0).asInt();
}
else{
} else {
LowX = player.getMetadata("Pos1X").get(0).asInt();
HighX = player.getMetadata("Pos2X").get(0).asInt();
}
if (player.getMetadata("Pos1Y").get(0).asInt() > player.getMetadata("Pos2Y").get(0).asInt()) {
LowY = player.getMetadata("Pos2Y").get(0).asInt();
HighY = player.getMetadata("Pos1Y").get(0).asInt();
}
else{
} else {
LowY = player.getMetadata("Pos1Y").get(0).asInt();
HighY = player.getMetadata("Pos2Y").get(0).asInt();
}
if (player.getMetadata("Pos1Z").get(0).asInt() > player.getMetadata("Pos2Z").get(0).asInt()) {
LowZ = player.getMetadata("Pos2Z").get(0).asInt();
HighZ = player.getMetadata("Pos1Z").get(0).asInt();
}
else{
} else {
LowZ = player.getMetadata("Pos1Z").get(0).asInt();
HighZ = player.getMetadata("Pos2Z").get(0).asInt();
}

View File

@ -34,21 +34,18 @@ public class WarpCommand implements CommandExecutor, TabCompleter {
sender.sendMessage("");
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + args[0].replaceAll("_", " ") + "\u00A7a.");
sender.sendMessage("");
}
else if(DestinationCommand.PortalMessagesDisplay == 2){
} else if (DestinationCommand.PortalMessagesDisplay == 2) {
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
plugin.nmsAccess.sendActionBarMessage("{\"text\":\"\u00A7aYou have warped to \u00A7e" + args[0].replaceAll("_", " ") + "\u00A7a.\"}", (Player) sender);
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ")
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
}
}
else{
} else {
sender.sendMessage("");
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination you tried to warp to does not exist!");
sender.sendMessage("");
}
}
else{
} else {
sender.sendMessage("");
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] You need to type a destination after /" + command + "!");
sender.sendMessage("");

View File

@ -117,8 +117,7 @@ public class Destination {
riding.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
riding.setPassenger(player);
}
else{
} else {
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
}
WarpEffects.activateParticles(player);
@ -126,8 +125,7 @@ public class Destination {
return true;
}
else{
} else {
if (senderror) {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination you are trying to warp to seems to be linked to a world that doesn't exist!");
plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' is linked to the world "
@ -135,8 +133,7 @@ public class Destination {
}
return false;
}
}
else{
} else {
if (senderror) {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] There has been a problem warping you to the selected destination!");
plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' has just had a warp "

View File

@ -10,11 +10,9 @@ import org.bukkit.entity.Player;
public class WarpEffects {
public boolean oldSoundLoc = true;
public static Sound[] sounds = new Sound[1];
public static boolean soundError = false;
public boolean oldSoundLoc = true;
public WarpEffects(AdvancedPortalsPlugin plugin) {
try {
@ -43,7 +41,8 @@ public class WarpEffects {
for (int i = 0; i < 10; i++) {
world.playEffect(loc, Effect.ENDER_SIGNAL, 0);
}
default: break;
default:
break;
}
}
@ -55,7 +54,8 @@ public class WarpEffects {
switch (Assets.currentWarpParticles) {
case 1:
world.playSound(loc, sounds[0], 1F, 1F);
default: break;
default:
break;
}
}
}

View File

@ -30,6 +30,9 @@ public final class WarpEvent extends Event implements Cancellable {
this.portalData = portalData;
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Returns if the event has been cancelled
@ -44,16 +47,8 @@ public final class WarpEvent extends Event implements Cancellable {
cancelled = cancel;
}
public AdvancedPortal getPortalData(){return portalData;}
/**
* If the
*
* @param warped
*/
@SuppressWarnings("unused")
public void setHasWarped(boolean warped){
this.hasWarped = warped;
public AdvancedPortal getPortalData() {
return portalData;
}
/**
@ -65,16 +60,21 @@ public final class WarpEvent extends Event implements Cancellable {
return hasWarped;
}
/**
* If the
*
* @param warped
*/
@SuppressWarnings("unused")
public void setHasWarped(boolean warped) {
this.hasWarped = warped;
}
public Player getPlayer() {
return player;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -25,17 +25,13 @@ import org.bukkit.metadata.FixedMetadataValue;
public class Listeners implements Listener {
private final AdvancedPortalsPlugin plugin;
private int PortalMessagesDisplay = 2;
// The needed config values will be stored so they are easier to access later
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("\u00A7eP...
private static boolean UseOnlyServerAxe = false;
private static Material WandMaterial;
private static boolean ShowBungeeMessage;
private final AdvancedPortalsPlugin plugin;
private int PortalMessagesDisplay = 2;
@SuppressWarnings("deprecation")
public Listeners(AdvancedPortalsPlugin plugin) {
@ -48,12 +44,9 @@ public class Listeners implements Listener {
PortalMessagesDisplay = config.getConfig().getInt("WarpMessageDisplay");
try
{
try {
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
}
catch(Exception e)
{
} catch (Exception e) {
WandMaterial = Material.getMaterial(ItemID);
}
@ -70,12 +63,9 @@ public class Listeners implements Listener {
String ItemID = config.getConfig().getString("AxeItemId");
try
{
try {
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
}
catch(Exception e)
{
} catch (Exception e) {
WandMaterial = Material.getMaterial(ItemID);
}
}
@ -115,8 +105,7 @@ public class Listeners implements Listener {
player.sendMessage("");
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + portal.destiation.replaceAll("_", " ") + "\u00A7.");
player.sendMessage("");
}
else if(PortalMessagesDisplay == 2 && warped){
} else if (PortalMessagesDisplay == 2 && warped) {
ConfigAccessor config = new ConfigAccessor(plugin, "portals.yml");
plugin.nmsAccess.sendActionBarMessage("{\"text\":\"\u00A7aYou have been warped to \u00A7e" + portal.destiation.replaceAll("_", " ") + "\u00A7a.\"}", player);
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ")
@ -128,8 +117,7 @@ public class Listeners implements Listener {
//event.setTo(player.getLocation());
//event.setCancelled(true);
}
else{
} else {
player.teleport(fromloc, PlayerTeleportEvent.TeleportCause.PLUGIN);
event.setCancelled(true);
}
@ -146,8 +134,7 @@ public class Listeners implements Listener {
}
}, 10);
}
}
else if(portal.trigger.equals(Material.LAVA)){
} else if (portal.trigger.equals(Material.LAVA)) {
player.setMetadata("lavaWarped", new FixedMetadataValue(plugin, true));
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
@ -318,8 +305,7 @@ public class Listeners implements Listener {
event.setCancelled(true);
// Returns the event so no more code is executed(stops unnecessary code being executed)
}
else if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Location blockloc = event.getClickedBlock().getLocation();
player.setMetadata("Pos2X", new FixedMetadataValue(plugin, blockloc.getBlockX()));
player.setMetadata("Pos2Y", new FixedMetadataValue(plugin, blockloc.getBlockY()));
@ -340,5 +326,4 @@ public class Listeners implements Listener {
}
}

View File

@ -39,8 +39,7 @@ public class PortalPlacer implements Listener {
public void onBlockPhysics(BlockPhysicsEvent event) {
Block block = event.getBlock();
Material material = block.getType();
if (material == Material.PORTAL)
{
if (material == Material.PORTAL) {
for (AdvancedPortal portal : Portal.Portals) {
if (portal.worldName.equals(block.getWorld().getName())) {

View File

@ -132,6 +132,121 @@ public class Metrics {
debug = configuration.getBoolean("debug", false);
}
/**
* GZip compress a string of bytes
*
* @param input
* @return
*/
public static byte[] gzip(String input) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzos = null;
try {
gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8"));
} catch (IOException e) {
e.printStackTrace();
} finally {
if (gzos != null) try {
gzos.close();
} catch (IOException ignore) {
}
}
return baos.toByteArray();
}
/**
* Appends a json encoded key/value pair to the given string builder.
*
* @param json
* @param key
* @param value
* @throws UnsupportedEncodingException
*/
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false;
try {
if (value.equals("0") || !value.endsWith("0")) {
Double.parseDouble(value);
isValueNumeric = true;
}
} catch (NumberFormatException e) {
isValueNumeric = false;
}
if (json.charAt(json.length() - 1) != '{') {
json.append(',');
}
json.append(escapeJSON(key));
json.append(':');
if (isValueNumeric) {
json.append(value);
} else {
json.append(escapeJSON(value));
}
}
/**
* Escape a string to create a valid JSON string
*
* @param text
* @return
*/
private static String escapeJSON(String text) {
StringBuilder builder = new StringBuilder();
builder.append('"');
for (int index = 0; index < text.length(); index++) {
char chr = text.charAt(index);
switch (chr) {
case '"':
case '\\':
builder.append('\\');
builder.append(chr);
break;
case '\b':
builder.append("\\b");
break;
case '\t':
builder.append("\\t");
break;
case '\n':
builder.append("\\n");
break;
case '\r':
builder.append("\\r");
break;
default:
if (chr < ' ') {
String t = "000" + Integer.toHexString(chr);
builder.append("\\u" + t.substring(t.length() - 4));
} else {
builder.append(chr);
}
break;
}
}
builder.append('"');
return builder.toString();
}
/**
* Encode text as UTF-8
*
* @param text the text to encode
* @return the encoded text, as UTF-8
*/
private static String urlEncode(final String text) throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8");
}
/**
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
* website. Plotters can be added to the graph object returned.
@ -475,31 +590,6 @@ public class Metrics {
}
}
/**
* GZip compress a string of bytes
*
* @param input
* @return
*/
public static byte[] gzip(String input) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzos = null;
try {
gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8"));
} catch (IOException e) {
e.printStackTrace();
} finally {
if (gzos != null) try {
gzos.close();
} catch (IOException ignore) {
}
}
return baos.toByteArray();
}
/**
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
*
@ -514,96 +604,6 @@ public class Metrics {
}
}
/**
* Appends a json encoded key/value pair to the given string builder.
*
* @param json
* @param key
* @param value
* @throws UnsupportedEncodingException
*/
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false;
try {
if (value.equals("0") || !value.endsWith("0")) {
Double.parseDouble(value);
isValueNumeric = true;
}
} catch (NumberFormatException e) {
isValueNumeric = false;
}
if (json.charAt(json.length() - 1) != '{') {
json.append(',');
}
json.append(escapeJSON(key));
json.append(':');
if (isValueNumeric) {
json.append(value);
} else {
json.append(escapeJSON(value));
}
}
/**
* Escape a string to create a valid JSON string
*
* @param text
* @return
*/
private static String escapeJSON(String text) {
StringBuilder builder = new StringBuilder();
builder.append('"');
for (int index = 0; index < text.length(); index++) {
char chr = text.charAt(index);
switch (chr) {
case '"':
case '\\':
builder.append('\\');
builder.append(chr);
break;
case '\b':
builder.append("\\b");
break;
case '\t':
builder.append("\\t");
break;
case '\n':
builder.append("\\n");
break;
case '\r':
builder.append("\\r");
break;
default:
if (chr < ' ') {
String t = "000" + Integer.toHexString(chr);
builder.append("\\u" + t.substring(t.length() - 4));
} else {
builder.append(chr);
}
break;
}
}
builder.append('"');
return builder.toString();
}
/**
* Encode text as UTF-8
*
* @param text the text to encode
* @return the encoded text, as UTF-8
*/
private static String urlEncode(final String text) throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8");
}
/**
* Represents a custom graph on the website
*/

View File

@ -2,7 +2,7 @@ package com.sekwah.advancedportals.portals;
/**
* Created by on 29/02/2016.
*
* <p>
* TODO create argument registry for easier altering and control :) also allows other coders to add custom args
*
* @author sekwah41
@ -10,5 +10,4 @@ package com.sekwah.advancedportals.portals;
public class ArgRegistry {
}

View File

@ -19,15 +19,11 @@ import java.util.logging.Level;
public class Portal {
private static AdvancedPortalsPlugin plugin;
public static boolean portalsActive = false;
public static AdvancedPortal[] Portals = new AdvancedPortal[0];
private static boolean ShowBungeeMessage;
private static AdvancedPortalsPlugin plugin;
public static ConfigAccessor portalData = new ConfigAccessor(plugin, "portals.yml");
private static boolean ShowBungeeMessage;
public Portal(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
@ -39,11 +35,10 @@ public class Portal {
/**
* This can be used to move the get keys to different sections
*
* <p>
* ConfigurationSection section = portalData.getSection("sectionname");
*
* <p>
* section.getKeys(false);
*
*/
public static void loadPortals() {
@ -64,13 +59,10 @@ public class Portal {
Material blockType = Material.PORTAL;
String BlockID = portalConfigSection.getString("triggerblock");
try
{
try {
Integer.parseInt(BlockID);
System.out.println("Block names must be given not IDs");
}
catch(NumberFormatException e)
{
} catch (NumberFormatException e) {
blockType = Material.getMaterial(BlockID);
}
@ -93,7 +85,6 @@ public class Portal {
}
String worldName = portalData.getConfig().getString(portal.toString() + ".world");
World world = Bukkit.getWorld(worldName);
@ -112,8 +103,7 @@ public class Portal {
portalId++;
}
portalsActive = true;
}
else{
} else {
portalsActive = false;
}
@ -141,24 +131,21 @@ public class Portal {
if (pos1.getX() > pos2.getX()) {
LowX = (int) pos2.getX();
HighX = (int) pos1.getX();
}
else{
} else {
LowX = (int) pos1.getX();
HighX = (int) pos2.getX();
}
if (pos1.getY() > pos2.getY()) {
LowY = (int) pos2.getY();
HighY = (int) pos1.getY();
}
else{
} else {
LowY = (int) pos1.getY();
HighY = (int) pos2.getY();
}
if (pos1.getZ() > pos2.getZ()) {
LowZ = (int) pos2.getZ();
HighZ = (int) pos1.getZ();
}
else{
} else {
LowZ = (int) pos1.getZ();
HighZ = (int) pos2.getZ();
}
@ -205,21 +192,37 @@ public class Portal {
int portalId = 0;
for (@SuppressWarnings("unused") Object portal : Portal.Portals) {
if (Portals[portalId].worldName.equals(pos2.getWorld().getName())) { // checks that the cubes arnt overlapping by seeing if all 4 corners are not in side another
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
if (checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos1.getBlockZ())) {
return true;
}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
if (checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos2.getBlockZ())) {
return true;
}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
if (checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos1.getBlockZ())) {
return true;
}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
if (checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos1.getBlockZ())) {
return true;
}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
if (checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos2.getBlockZ())) {
return true;
}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
if (checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos1.getBlockY(), Portals[portalId].pos2.getBlockZ())) {
return true;
}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos2.getBlockZ())){return true;}
if (checkOverLapPortal(pos1, pos2, Portals[portalId].pos1.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos2.getBlockZ())) {
return true;
}
if(checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos1.getBlockZ())){return true;}
if (checkOverLapPortal(pos1, pos2, Portals[portalId].pos2.getBlockX(), Portals[portalId].pos2.getBlockY(), Portals[portalId].pos1.getBlockZ())) {
return true;
}
}
portalId++;
}
@ -240,8 +243,7 @@ public class Portal {
private static String checkMaterial(Material triggerBlock) {
if (triggerBlock.equals(Material.WATER)) {
return "STATIONARY_WATER";
}
else if(triggerBlock.equals(Material.LAVA)){
} else if (triggerBlock.equals(Material.LAVA)) {
return "STATIONARY_LAVA";
}
return triggerBlock.toString();
@ -253,12 +255,9 @@ public class Portal {
Material triggerBlockType;
String BlockID = config.getConfig().getString("DefaultPortalTriggerBlock");
try
{
try {
triggerBlockType = Material.getMaterial(Integer.parseInt(BlockID));
}
catch(Exception e)
{
} catch (Exception e) {
triggerBlockType = Material.getMaterial(BlockID);
}
@ -339,12 +338,7 @@ public class Portal {
String posX = portalData.getConfig().getString(portalName + ".pos1.X");
if(posX == null){
return false;
}
else{
return true;
}
return posX != null;
}
public static boolean activate(Player player, String portalName) {
@ -376,8 +370,7 @@ public class Portal {
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
return false;
}
else{
} else {
boolean showFailMessage = true;
if (portal.getArg("command.1") != null) {
@ -392,30 +385,25 @@ public class Portal {
command = command.substring(1);
plugin.getLogger().log(Level.SEVERE, "Portal command: " + command);
plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
}
else if(command.startsWith("!")){
} else if (command.startsWith("!")) {
command = command.substring(1);
boolean wasOp = player.isOp();
try {
player.setOp(true);
player.performCommand(command);
}
finally {
} finally {
player.setOp(wasOp);
}
}
else if(command.startsWith("^")){
} else if (command.startsWith("^")) {
command = command.substring(1);
PermissionAttachment permissionAttachment = null;
try {
permissionAttachment = player.addAttachment(plugin, "*", true);
player.performCommand(command);
}
finally {
} finally {
player.removeAttachment(permissionAttachment);
}
}
else{
} else {
player.performCommand(command);
}
command = portal.getArg("command." + ++commandLine);
@ -427,15 +415,13 @@ public class Portal {
if (configDesti.getConfig().getString(portal.destiation + ".world") != null) {
boolean warped = Destination.warp(player, portal.destiation);
return warped;
}
else{
} else {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The destination you are currently attempting to warp to doesnt exist!");
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp "
+ "attempt and either the data is corrupt or that destination listed doesn't exist!");
return false;
}
}
else{
} else {
if (showFailMessage) {
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] The portal you are trying to use doesn't have a destination!");
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp "
@ -475,13 +461,10 @@ public class Portal {
for (String key : keys) {
if (key.startsWith(oldName + ".")) {
if (config.getConfig().getString(key) != null) {
try
{
try {
int intData = Integer.parseInt(config.getConfig().getString(key));
config.getConfig().set(key.replace(oldName + ".", newName + "."), intData);
}
catch(Exception e)
{
} catch (Exception e) {
config.getConfig().set(key.replace(oldName + ".", newName + "."), config.getConfig().getString(key));
}
@ -500,13 +483,13 @@ public class Portal {
ConfigAccessor config = new ConfigAccessor(plugin, "portals.yml");
if (portalExists(portalName)) {
int commandLine = 0;
while(config.getConfig().getString(portalName + ".portalArgs.command." + ++commandLine) != null); //Loops increasing commandLine till 1 is null
while (config.getConfig().getString(portalName + ".portalArgs.command." + ++commandLine) != null)
; //Loops increasing commandLine till 1 is null
config.getConfig().set(portalName + ".portalArgs.command." + commandLine, portalCommand);
config.saveConfig();
loadPortals();
return true;
}
else{
} else {
return false;
}
}

View File

@ -6,7 +6,7 @@ import java.util.Map;
/**
* Created by on 29/03/2016.
*
* <p>
* TODO add all the normal tags then add the extradata tags
*
* @author sekwah41