Make the tools method static
This commit is contained in:
@@ -139,15 +139,6 @@ public class Core {
|
|||||||
return "en";
|
return "en";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an extra set of tools
|
|
||||||
*
|
|
||||||
* @return Tools
|
|
||||||
*/
|
|
||||||
public static Tools getTools() {
|
|
||||||
return AnuraCore.getInstance().tools;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the available Languages
|
* Returns the available Languages
|
||||||
*
|
*
|
||||||
@@ -198,6 +189,7 @@ public class Core {
|
|||||||
/**
|
/**
|
||||||
* Makes a player stand up
|
* Makes a player stand up
|
||||||
* @param P The player to end the sitting of
|
* @param P The player to end the sitting of
|
||||||
|
* @param noRemove If the player should stay in the sittingPlayer HashMap, used to prevent a Concurrent Modif Exc
|
||||||
*/
|
*/
|
||||||
public static void endSitting(Player P, boolean noRemove) {
|
public static void endSitting(Player P, boolean noRemove) {
|
||||||
try {
|
try {
|
||||||
@@ -228,6 +220,10 @@ public class Core {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a player stand up
|
||||||
|
* @param P The player to end the sitting of
|
||||||
|
*/
|
||||||
public static void endSitting(Player P) {
|
public static void endSitting(Player P) {
|
||||||
endSitting(P, false);
|
endSitting(P, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class Tools {
|
|||||||
* @param msg The message to send
|
* @param msg The message to send
|
||||||
* @param positive If the message should be green(true) or red(false)
|
* @param positive If the message should be green(true) or red(false)
|
||||||
*/
|
*/
|
||||||
public void sendStatusMsg(CommandSender p, String msg, Boolean positive) {
|
public static void sendStatusMsg(CommandSender p, String msg, Boolean positive) {
|
||||||
ChatColor chatColor;
|
ChatColor chatColor;
|
||||||
if (positive) {
|
if (positive) {
|
||||||
chatColor = ChatColor.GREEN;
|
chatColor = ChatColor.GREEN;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package de.anura.core.commands;
|
|||||||
|
|
||||||
import de.anura.core.API.Core;
|
import de.anura.core.API.Core;
|
||||||
import de.anura.core.API.Errors;
|
import de.anura.core.API.Errors;
|
||||||
|
import de.anura.core.API.Tools;
|
||||||
import de.anura.core.AnuraCore;
|
import de.anura.core.AnuraCore;
|
||||||
import de.anura.core.AnuraVillager;
|
import de.anura.core.AnuraVillager;
|
||||||
import de.anura.core.AnuraVillager.VillagerType;
|
import de.anura.core.AnuraVillager.VillagerType;
|
||||||
@@ -44,7 +45,7 @@ public class AdminCommands implements CommandExecutor {
|
|||||||
for (Arrow a : P.getWorld().getEntitiesByClass(Arrow.class)) {
|
for (Arrow a : P.getWorld().getEntitiesByClass(Arrow.class)) {
|
||||||
a.remove();
|
a.remove();
|
||||||
}
|
}
|
||||||
Core.getTools().sendStatusMsg(sender, "Done!", true);
|
Tools.sendStatusMsg(sender, "Done!", true);
|
||||||
return true;
|
return true;
|
||||||
} else if (cmd.getName().equalsIgnoreCase("core")) {
|
} else if (cmd.getName().equalsIgnoreCase("core")) {
|
||||||
if (!sender.hasPermission("core.commands.core")) {
|
if (!sender.hasPermission("core.commands.core")) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package de.anura.core.commands;
|
|||||||
import de.anura.core.API.Core;
|
import de.anura.core.API.Core;
|
||||||
import de.anura.core.API.Errors;
|
import de.anura.core.API.Errors;
|
||||||
import de.anura.core.API.Inventories;
|
import de.anura.core.API.Inventories;
|
||||||
|
import de.anura.core.API.Tools;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.BlockCommandSender;
|
import org.bukkit.command.BlockCommandSender;
|
||||||
@@ -23,7 +24,7 @@ public class OtherCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
if (cmd.getName().equalsIgnoreCase("togglecommands")) {
|
if (cmd.getName().equalsIgnoreCase("togglecommands")) {
|
||||||
if (!(sender instanceof BlockCommandSender) && !(sender instanceof ConsoleCommandSender)) {
|
if (!(sender instanceof BlockCommandSender) && !(sender instanceof ConsoleCommandSender)) {
|
||||||
Core.getTools().sendStatusMsg(sender, "Only command block cmd!", false);
|
Tools.sendStatusMsg(sender, "Only command block cmd!", false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
@@ -45,7 +46,7 @@ public class OtherCommands implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
} else if (cmd.getName().equalsIgnoreCase("addAimTWWin")) {
|
} else if (cmd.getName().equalsIgnoreCase("addAimTWWin")) {
|
||||||
if (!(sender instanceof BlockCommandSender) && !(sender instanceof ConsoleCommandSender)) {
|
if (!(sender instanceof BlockCommandSender) && !(sender instanceof ConsoleCommandSender)) {
|
||||||
Core.getTools().sendStatusMsg(sender, "Only command block cmd!", false);
|
Tools.sendStatusMsg(sender, "Only command block cmd!", false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length != 1) return false;
|
if (args.length != 1) return false;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package de.anura.core.commands;
|
|||||||
import de.anura.core.API.Core;
|
import de.anura.core.API.Core;
|
||||||
import de.anura.core.API.Errors;
|
import de.anura.core.API.Errors;
|
||||||
import de.anura.core.API.Money;
|
import de.anura.core.API.Money;
|
||||||
|
import de.anura.core.API.Tools;
|
||||||
import static de.anura.core.AnuraCore.sql;
|
import static de.anura.core.AnuraCore.sql;
|
||||||
import de.anura.core.Features;
|
import de.anura.core.Features;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -250,11 +251,11 @@ public class PlayerCommands implements CommandExecutor {
|
|||||||
} else if (cmd.getName().equalsIgnoreCase("money")) {
|
} else if (cmd.getName().equalsIgnoreCase("money")) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
if (P == null) {
|
if (P == null) {
|
||||||
Core.getTools().sendStatusMsg(sender, "only_player_cmd", false);
|
Tools.sendStatusMsg(sender, "only_player_cmd", false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Integer money = Money.getMoney(P);
|
Integer money = Money.getMoney(P);
|
||||||
Core.getTools().sendStatusMsg(P, Core.getl("you_have", P) + " " + money + " " + Core.getl("coins", P), true);
|
Tools.sendStatusMsg(P, Core.getl("you_have", P) + " " + money + " " + Core.getl("coins", P), true);
|
||||||
return true;
|
return true;
|
||||||
} else if ((args[0].equalsIgnoreCase("pay")) && (args.length == 3)) {
|
} else if ((args[0].equalsIgnoreCase("pay")) && (args.length == 3)) {
|
||||||
Integer money = Integer.parseInt(args[2]);
|
Integer money = Integer.parseInt(args[2]);
|
||||||
@@ -301,9 +302,9 @@ public class PlayerCommands implements CommandExecutor {
|
|||||||
} else if (!P.hasPermission("core.money.endless")) {
|
} else if (!P.hasPermission("core.money.endless")) {
|
||||||
Money.payMoney(P, -money);
|
Money.payMoney(P, -money);
|
||||||
}
|
}
|
||||||
Core.getTools().sendStatusMsg(sender, Core.getl("money_payed_1", sender) + " " + args[1] + " " + Core.getl("money_payed_2", sender) + " " + args[2] + " " + Core.getl("money_payed_3", sender), true);
|
Tools.sendStatusMsg(sender, Core.getl("money_payed_1", sender) + " " + args[1] + " " + Core.getl("money_payed_2", sender) + " " + args[2] + " " + Core.getl("money_payed_3", sender), true);
|
||||||
if (oP.isOnline()) {
|
if (oP.isOnline()) {
|
||||||
Core.getTools().sendStatusMsg(oP.getPlayer(), Core.getl("money_got_1", oP.getPlayer()) + " " + args[2] + " " + Core.getl("money_got_2", oP.getPlayer()) + " " + sender.getName() + " " + Core.getl("money_got_3", oP.getPlayer()), true);
|
Tools.sendStatusMsg(oP.getPlayer(), Core.getl("money_got_1", oP.getPlayer()) + " " + args[2] + " " + Core.getl("money_got_2", oP.getPlayer()) + " " + sender.getName() + " " + Core.getl("money_got_3", oP.getPlayer()), true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package de.anura.core.commands;
|
|||||||
|
|
||||||
import de.anura.core.API.Core;
|
import de.anura.core.API.Core;
|
||||||
import de.anura.core.API.Errors;
|
import de.anura.core.API.Errors;
|
||||||
|
import de.anura.core.API.Tools;
|
||||||
import de.anura.core.AnuraCore;
|
import de.anura.core.AnuraCore;
|
||||||
import static de.anura.core.AnuraCore.sql;
|
import static de.anura.core.AnuraCore.sql;
|
||||||
import de.anura.core.Features;
|
import de.anura.core.Features;
|
||||||
@@ -114,7 +115,7 @@ public class TeamCommands implements CommandExecutor {
|
|||||||
} else {
|
} else {
|
||||||
Core.getMainClass().stairMode.add(P);
|
Core.getMainClass().stairMode.add(P);
|
||||||
}
|
}
|
||||||
Core.getTools().sendStatusMsg(sender, "Done!", true);
|
Tools.sendStatusMsg(sender, "Done!", true);
|
||||||
return true;
|
return true;
|
||||||
} else if (cmd.getName().equalsIgnoreCase("flowerpot")) {
|
} else if (cmd.getName().equalsIgnoreCase("flowerpot")) {
|
||||||
if (P == null) {
|
if (P == null) {
|
||||||
@@ -154,7 +155,7 @@ public class TeamCommands implements CommandExecutor {
|
|||||||
final CommandSender cs = sender;
|
final CommandSender cs = sender;
|
||||||
final String url = args[0];
|
final String url = args[0];
|
||||||
final String name = args[1];
|
final String name = args[1];
|
||||||
Core.getTools().sendStatusMsg(cs, "The rendering is starting...", true);
|
Tools.sendStatusMsg(cs, "The rendering is starting...", true);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Core.getMainClass(), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Core.getMainClass(), new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -167,11 +168,11 @@ public class TeamCommands implements CommandExecutor {
|
|||||||
BufferedImage imgScaled = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB);
|
BufferedImage imgScaled = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB);
|
||||||
imgScaled.getGraphics().drawImage(i, 0, 0, null);
|
imgScaled.getGraphics().drawImage(i, 0, 0, null);
|
||||||
AnuraCore.getInstance().renderedImgs.put(name, imgScaled);
|
AnuraCore.getInstance().renderedImgs.put(name, imgScaled);
|
||||||
Core.getTools().sendStatusMsg(cs, "The rendering has finished!", true);
|
Tools.sendStatusMsg(cs, "The rendering has finished!", true);
|
||||||
} catch (MalformedURLException ex) {
|
} catch (MalformedURLException ex) {
|
||||||
Core.getTools().sendStatusMsg(cs, "Please provide a valid image url!", false);
|
Tools.sendStatusMsg(cs, "Please provide a valid image url!", false);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Core.getTools().sendStatusMsg(cs, "Image rendering not working! Did you provide a valid url?", false);
|
Tools.sendStatusMsg(cs, "Image rendering not working! Did you provide a valid url?", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +192,7 @@ public class TeamCommands implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Core.getMainClass().renderedImgs.containsKey(args[0])) {
|
if (!Core.getMainClass().renderedImgs.containsKey(args[0])) {
|
||||||
Core.getTools().sendStatusMsg(sender, "The image with the given name does not exist or this not rendered yet.", true);
|
Tools.sendStatusMsg(sender, "The image with the given name does not exist or this not rendered yet.", true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
MapView mv = Bukkit.createMap(P.getWorld());
|
MapView mv = Bukkit.createMap(P.getWorld());
|
||||||
@@ -249,7 +250,7 @@ public class TeamCommands implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
P.setFlySpeed(Float.parseFloat(args[0]) / 10);
|
P.setFlySpeed(Float.parseFloat(args[0]) / 10);
|
||||||
Core.getTools().sendStatusMsg(P, Core.getl("flyspeed_set_1", P) + " " + args[0] + Core.getl("flyspeed_set_2", P), true);
|
Tools.sendStatusMsg(P, Core.getl("flyspeed_set_1", P) + " " + args[0] + Core.getl("flyspeed_set_2", P), true);
|
||||||
return true;
|
return true;
|
||||||
} else if (cmd.getName().equalsIgnoreCase("setwarp")) {
|
} else if (cmd.getName().equalsIgnoreCase("setwarp")) {
|
||||||
if (P == null) {
|
if (P == null) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package de.anura.core.events;
|
|||||||
|
|
||||||
import de.anura.core.API.Core;
|
import de.anura.core.API.Core;
|
||||||
import de.anura.core.API.Errors;
|
import de.anura.core.API.Errors;
|
||||||
|
import de.anura.core.API.Tools;
|
||||||
import de.anura.core.AnuraCore;
|
import de.anura.core.AnuraCore;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@@ -98,14 +99,14 @@ public class PlayerInteract implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (plugin.sittableBlocks.contains(block)) {
|
if (plugin.sittableBlocks.contains(block)) {
|
||||||
plugin.sittableBlocks.remove(block);
|
plugin.sittableBlocks.remove(block);
|
||||||
Core.getTools().sendStatusMsg(event.getPlayer(), "Removed!", false);
|
Tools.sendStatusMsg(event.getPlayer(), "Removed!", false);
|
||||||
int X = block.getLocation().getBlockX();
|
int X = block.getLocation().getBlockX();
|
||||||
int Y = block.getLocation().getBlockY();
|
int Y = block.getLocation().getBlockY();
|
||||||
int Z = block.getLocation().getBlockZ();
|
int Z = block.getLocation().getBlockZ();
|
||||||
Core.getMySql().queryUpdate("DELETE FROM coreStairs WHERE server = '" + plugin.getConfig().getString("server-name") + "' AND world = '" + block.getWorld().getName() + "' AND X = '" + X + "' AND Y = '" + Y + "' AND Z = '" + Z + "'");
|
Core.getMySql().queryUpdate("DELETE FROM coreStairs WHERE server = '" + plugin.getConfig().getString("server-name") + "' AND world = '" + block.getWorld().getName() + "' AND X = '" + X + "' AND Y = '" + Y + "' AND Z = '" + Z + "'");
|
||||||
} else {
|
} else {
|
||||||
plugin.sittableBlocks.add(block);
|
plugin.sittableBlocks.add(block);
|
||||||
Core.getTools().sendStatusMsg(event.getPlayer(), "Added!", true);
|
Tools.sendStatusMsg(event.getPlayer(), "Added!", true);
|
||||||
int X = block.getLocation().getBlockX();
|
int X = block.getLocation().getBlockX();
|
||||||
int Y = block.getLocation().getBlockY();
|
int Y = block.getLocation().getBlockY();
|
||||||
int Z = block.getLocation().getBlockZ();
|
int Z = block.getLocation().getBlockZ();
|
||||||
|
|||||||
Reference in New Issue
Block a user