Change code style
This commit is contained in:
@@ -15,33 +15,34 @@ import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.Stairs;
|
||||
|
||||
public class Core {
|
||||
|
||||
|
||||
/**
|
||||
* Use this if you want to change the language
|
||||
*/
|
||||
public final static HashMap<Player, String> cachedPlayerLanguage = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the current MySQL Object
|
||||
*
|
||||
* @return The working MySQL Object
|
||||
*/
|
||||
public static MySQL getMySql()
|
||||
{
|
||||
if(!AnuraCore.getSql().isValid) return null;
|
||||
public static MySQL getMySql() {
|
||||
if (!AnuraCore.getSql().isValid) {
|
||||
return null;
|
||||
}
|
||||
return AnuraCore.getSql();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a language value for the given id and language
|
||||
*
|
||||
* @param id The language id as used in the translation center
|
||||
* @param lang The short value of a language e.g. de, en
|
||||
* @return Returns the text for this id
|
||||
*/
|
||||
public static String getl(String id, String lang)
|
||||
{
|
||||
public static String getl(String id, String lang) {
|
||||
String val = AnuraCore.getInstance().lang.get(id, lang);
|
||||
if(val == null || val.equals(""))
|
||||
{
|
||||
if (val == null || val.equals("")) {
|
||||
val = AnuraCore.getInstance().lang.get(id, "en");
|
||||
}
|
||||
return val;
|
||||
@@ -49,81 +50,81 @@ public class Core {
|
||||
|
||||
/**
|
||||
* Gets a language value for the given id for a CommandSender
|
||||
*
|
||||
* @param id The language id as used in the translation center
|
||||
* @param cs A command sender to automatically detect the language
|
||||
* @return Returns the text for this id
|
||||
*/
|
||||
public static String getl(String id, CommandSender cs)
|
||||
{
|
||||
if(cs instanceof Player)
|
||||
{
|
||||
return Core.getl(id, (Player)cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
public static String getl(String id, CommandSender cs) {
|
||||
if (cs instanceof Player) {
|
||||
return Core.getl(id, (Player) cs);
|
||||
} else {
|
||||
return Core.getl(id, "en");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a language value for the given id for a Player
|
||||
*
|
||||
* @param id The language id as used in the translation center
|
||||
* @param P A player to use his language setting
|
||||
* @return Returns the text for this id
|
||||
*/
|
||||
public static String getl(String id, Player P)
|
||||
{
|
||||
public static String getl(String id, Player P) {
|
||||
return Core.getl(id, Core.getPlayerLang(P));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a translated and colored message to the given CommandSender
|
||||
* @param P The CommandSender, whose language is being determined and the language is sended to
|
||||
*
|
||||
* @param P The CommandSender, whose language is being determined and the
|
||||
* language is sended to
|
||||
* @param id The language id as used in the translation center
|
||||
* @param status The type of the message(true for green, false for red)
|
||||
* @param status The type of the message(true for green, false for red)
|
||||
*/
|
||||
public static void statusMsg(CommandSender P, String id, Boolean status)
|
||||
{
|
||||
public static void statusMsg(CommandSender P, String id, Boolean status) {
|
||||
ChatColor chatColor;
|
||||
if(status) chatColor = ChatColor.GREEN;
|
||||
else chatColor = ChatColor.RED;
|
||||
P.sendMessage(ChatColor.GRAY + "[Anura] "+chatColor+Core.getl(id, Core.getPlayerLang(P)));
|
||||
if (status) {
|
||||
chatColor = ChatColor.GREEN;
|
||||
} else {
|
||||
chatColor = ChatColor.RED;
|
||||
}
|
||||
P.sendMessage(ChatColor.GRAY + "[Anura] " + chatColor + Core.getl(id, Core.getPlayerLang(P)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a translated and colored message to the given CommandSender
|
||||
* @param P The CommandSender, whose language is being determined and the language is sended to
|
||||
*
|
||||
* @param P The CommandSender, whose language is being determined and the
|
||||
* language is sended to
|
||||
* @param id The language id as used in the translation center
|
||||
* @param color The color of the message
|
||||
* @param color The color of the message
|
||||
*/
|
||||
public static void statusMsg(CommandSender P, String id, ChatColor color)
|
||||
{
|
||||
P.sendMessage(ChatColor.GRAY + "[Anura] "+color+Core.getl(id, Core.getPlayerLang(P)));
|
||||
public static void statusMsg(CommandSender P, String id, ChatColor color) {
|
||||
P.sendMessage(ChatColor.GRAY + "[Anura] " + color + Core.getl(id, Core.getPlayerLang(P)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the language of the given CommandSender
|
||||
*
|
||||
* @param P The CommandSender, whose language is being determined
|
||||
* @return Returns the short language name of the player (like de or en)
|
||||
*/
|
||||
public static String getPlayerLang(CommandSender P)
|
||||
{
|
||||
if(!(P instanceof Player))
|
||||
{
|
||||
public static String getPlayerLang(CommandSender P) {
|
||||
if (!(P instanceof Player)) {
|
||||
return "en";
|
||||
}
|
||||
Player p = (Player)P;
|
||||
if(!Core.cachedPlayerLanguage.containsKey(p))
|
||||
{
|
||||
ResultSet rs = AnuraCore.sql.querySelect("SELECT lang FROM players WHERE uuid = '"+p.getUniqueId().toString()+"'");
|
||||
Player p = (Player) P;
|
||||
if (!Core.cachedPlayerLanguage.containsKey(p)) {
|
||||
ResultSet rs = AnuraCore.sql.querySelect("SELECT lang FROM players WHERE uuid = '" + p.getUniqueId().toString() + "'");
|
||||
try {
|
||||
rs.first();
|
||||
Core.cachedPlayerLanguage.put(p, rs.getString("lang"));
|
||||
return rs.getString("lang");
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLException in getPlayerLang of API: "+ex.getLocalizedMessage());
|
||||
System.out.println("SQLException in getPlayerLang of API: " + ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return Core.cachedPlayerLanguage.get(p);
|
||||
}
|
||||
return "en";
|
||||
@@ -131,24 +132,25 @@ public class Core {
|
||||
|
||||
/**
|
||||
* Returns an extra set of tools
|
||||
*
|
||||
* @return Tools
|
||||
*/
|
||||
public static Tools getTools()
|
||||
{
|
||||
public static Tools getTools() {
|
||||
return AnuraCore.getInstance().tools;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the available Languages
|
||||
*
|
||||
* @return Returns an iterable set of strings like de or en
|
||||
*/
|
||||
public static Set<String> getAvailLangs()
|
||||
{
|
||||
public static Set<String> getAvailLangs() {
|
||||
return AnuraCore.getInstance().lang.languages.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Key by a given value from a given HashMap
|
||||
*
|
||||
* @param <T> The type of the key in the map
|
||||
* @param <E> The type of the value in the map
|
||||
* @param map The HashMap to get the key from
|
||||
@@ -156,50 +158,46 @@ public class Core {
|
||||
* @return Returns the found key
|
||||
*/
|
||||
public static <T, E> T getKeyByValue(Map<T, E> map, E value) {
|
||||
for (Map.Entry<T, E> entry : map.entrySet()) {
|
||||
if (value.equals(entry.getValue())) {
|
||||
return entry.getKey();
|
||||
}
|
||||
for (Map.Entry<T, E> entry : map.entrySet()) {
|
||||
if (value.equals(entry.getValue())) {
|
||||
return entry.getKey();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates all lobby features for all players from the database
|
||||
*/
|
||||
public static void updateFeatures() {
|
||||
AnuraCore.getInstance().getFeatures().updateFeaturesAll();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates all lobby features for the given player from the database
|
||||
*
|
||||
* @param P The player to update the features
|
||||
*/
|
||||
public static void updateFeatures(Player P) {
|
||||
AnuraCore.getInstance().getFeatures().updateFeatures(P);
|
||||
}
|
||||
|
||||
|
||||
public static AnuraCore getMainClass() {
|
||||
return AnuraCore.getInstance();
|
||||
}
|
||||
|
||||
public static void endSitting(Player P)
|
||||
{
|
||||
if(getMainClass().sittingPlayer.containsKey(P))
|
||||
{
|
||||
|
||||
public static void endSitting(Player P) {
|
||||
if (getMainClass().sittingPlayer.containsKey(P)) {
|
||||
MaterialData md = getMainClass().sittingBlocks.get(P).getState().getData();
|
||||
if(md instanceof Stairs)
|
||||
{
|
||||
Stairs s = (Stairs)md;
|
||||
if (md instanceof Stairs) {
|
||||
Stairs s = (Stairs) md;
|
||||
Location loc = getMainClass().sittingBlocks.get(P).getRelative(s.getFacing()).getLocation();
|
||||
Entity a = (Entity)getMainClass().sittingPlayer.get(P);
|
||||
Entity a = (Entity) getMainClass().sittingPlayer.get(P);
|
||||
P.teleport(loc);
|
||||
a.remove();
|
||||
getMainClass().sittingPlayer.remove(P);
|
||||
getMainClass().sittingBlocks.remove(P);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Location loc = getMainClass().sittingPlayer.get(P).getLocation();
|
||||
P.teleport(loc);
|
||||
getMainClass().sittingPlayer.get(P).remove();
|
||||
@@ -208,18 +206,26 @@ public class Core {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isInteger(String s) {
|
||||
return isInteger(s,10);
|
||||
return isInteger(s, 10);
|
||||
}
|
||||
|
||||
public static boolean isInteger(String s, int radix) {
|
||||
if(s.isEmpty()) return false;
|
||||
for(int i = 0; i < s.length(); i++) {
|
||||
if(i == 0 && s.charAt(i) == '-') {
|
||||
if(s.length() == 1) return false;
|
||||
else continue;
|
||||
if (s.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (i == 0 && s.charAt(i) == '-') {
|
||||
if (s.length() == 1) {
|
||||
return false;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (Character.digit(s.charAt(i), radix) < 0) {
|
||||
return false;
|
||||
}
|
||||
if(Character.digit(s.charAt(i),radix) < 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,13 @@ import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class Inventories implements Listener {
|
||||
|
||||
|
||||
public Inventories(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
|
||||
public enum Action {
|
||||
|
||||
OPEN_INV,
|
||||
TELEPORT,
|
||||
MESSAGE,
|
||||
@@ -37,7 +38,7 @@ public class Inventories implements Listener {
|
||||
COMMAND,
|
||||
LANGUAGE
|
||||
}
|
||||
|
||||
|
||||
private static final HashMap<String, HashMap<String, Inventory>> invs = new HashMap<>();
|
||||
private static final HashMap<String, HashMap<Integer, Entry<Action, Object>>> invActions = new HashMap<>();
|
||||
private static final HashMap<String, String> invNames = new HashMap<>();
|
||||
@@ -45,7 +46,7 @@ public class Inventories implements Listener {
|
||||
private static final HashMap<String, Entry<Action, Object>> itemActions = new HashMap<>();
|
||||
private static final HashMap<String, Integer> itemPositions = new HashMap<>();
|
||||
public static final HashMap<Player, Boolean> checkInteracts = new HashMap<>();
|
||||
|
||||
|
||||
public static void registerInventory(String type, String name, ChatColor nameColor) {
|
||||
HashMap<String, Inventory> langInvs = new HashMap<>();
|
||||
for (String lang : Core.getAvailLangs()) {
|
||||
@@ -56,7 +57,7 @@ public class Inventories implements Listener {
|
||||
invs.put(type, langInvs);
|
||||
invActions.put(type, new HashMap<Integer, Entry<Action, Object>>());
|
||||
}
|
||||
|
||||
|
||||
public static void buildInvItem(String type, Material m, String name, ChatColor nameColor, ChatColor loreColor, String... lores) {
|
||||
HashMap<String, ItemStack> stacks = new HashMap<>();
|
||||
for (String lang : Core.getAvailLangs()) {
|
||||
@@ -74,11 +75,11 @@ public class Inventories implements Listener {
|
||||
}
|
||||
items.put(type, stacks);
|
||||
}
|
||||
|
||||
|
||||
public static void buildInvItem(String type, Material m, String name, ChatColor nameColor) {
|
||||
buildInvItem(type, m, name, nameColor, null, "none");
|
||||
}
|
||||
|
||||
|
||||
public static HashMap<String, ItemStack> buildItems(Material m, String name, ChatColor nameColor, ChatColor loreColor, String... lores) {
|
||||
HashMap<String, ItemStack> stacks = new HashMap<>();
|
||||
for (String lang : Core.getAvailLangs()) {
|
||||
@@ -96,66 +97,78 @@ public class Inventories implements Listener {
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
|
||||
public static HashMap<String, ItemStack> buildItems(Material m, String name, ChatColor nameColor) {
|
||||
return buildItems(m, name, nameColor, null, "none");
|
||||
}
|
||||
|
||||
|
||||
public static void putIntoInventory(String type, int position, HashMap<String, ItemStack> items) {
|
||||
for (Entry<String, ItemStack> item : items.entrySet()) {
|
||||
invs.get(type).get(item.getKey()).setItem(position, item.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void registerAction(String type, int slot, Action action, Object data) {
|
||||
if (action == Action.MESSAGE && !(data instanceof String)) return;
|
||||
if (action == Action.OPEN_INV && !(data instanceof String)) return;
|
||||
if (action == Action.SERVER && !(data instanceof String)) return;
|
||||
if (action == Action.COMMAND && !(data instanceof String)) return;
|
||||
if (action == Action.TELEPORT && !(data instanceof Location)) return;
|
||||
if (action == Action.MESSAGE && !(data instanceof String)) {
|
||||
return;
|
||||
}
|
||||
if (action == Action.OPEN_INV && !(data instanceof String)) {
|
||||
return;
|
||||
}
|
||||
if (action == Action.SERVER && !(data instanceof String)) {
|
||||
return;
|
||||
}
|
||||
if (action == Action.COMMAND && !(data instanceof String)) {
|
||||
return;
|
||||
}
|
||||
if (action == Action.TELEPORT && !(data instanceof Location)) {
|
||||
return;
|
||||
}
|
||||
invActions.get(type).put(slot, new AbstractMap.SimpleEntry<>(action, data));
|
||||
}
|
||||
|
||||
|
||||
public static Inventory getInventory(String type, Player P) {
|
||||
return invs.get(type).get(Core.getPlayerLang(P));
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack getItem(String type, Player P) {
|
||||
return items.get(type).get(Core.getPlayerLang(P));
|
||||
}
|
||||
|
||||
|
||||
public static void setItemInPlayerInv(String type, Integer position) {
|
||||
itemPositions.put(type, position);
|
||||
}
|
||||
|
||||
|
||||
public static void registerItemAction(String type, Action action, Object data) {
|
||||
if ((action == Action.TELEPORT && !(data instanceof Location)) || (action != Action.TELEPORT && !(data instanceof String))) return;
|
||||
if ((action == Action.TELEPORT && !(data instanceof Location)) || (action != Action.TELEPORT && !(data instanceof String))) {
|
||||
return;
|
||||
}
|
||||
itemActions.put(type, new AbstractMap.SimpleEntry<>(action, data));
|
||||
}
|
||||
|
||||
|
||||
public static void executeAction(Player P, Action action, Object data) {
|
||||
if (action == Action.SERVER) {
|
||||
try {
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF((String)data);
|
||||
out.writeUTF((String) data);
|
||||
P.sendPluginMessage(AnuraCore.getInstance(), "BungeeCord", b.toByteArray());
|
||||
} catch (IOException ex) {
|
||||
System.err.println("IOException whilst trying to connect to "+data);
|
||||
System.err.println("IOException whilst trying to connect to " + data);
|
||||
}
|
||||
} else if (action == Action.MESSAGE) {
|
||||
Core.statusMsg(P, (String)data, true);
|
||||
Core.statusMsg(P, (String) data, true);
|
||||
} else if (action == Action.OPEN_INV) {
|
||||
P.openInventory(getInventory((String)data, P));
|
||||
P.openInventory(getInventory((String) data, P));
|
||||
} else if (action == Action.TELEPORT) {
|
||||
P.teleport((Location)data);
|
||||
P.teleport((Location) data);
|
||||
} else if (action == Action.COMMAND) {
|
||||
Bukkit.getServer().dispatchCommand(P, (String) data);
|
||||
} else if (action == Action.LANGUAGE) {
|
||||
String lang = (String)data;
|
||||
Core.cachedPlayerLanguage.put(P,lang);
|
||||
AnuraCore.sql.queryUpdate("UPDATE players SET lang = '"+lang+"' WHERE uuid = '"+P.getUniqueId().toString()+"'");
|
||||
String lang = (String) data;
|
||||
Core.cachedPlayerLanguage.put(P, lang);
|
||||
AnuraCore.sql.queryUpdate("UPDATE players SET lang = '" + lang + "' WHERE uuid = '" + P.getUniqueId().toString() + "'");
|
||||
PlayerInventory pi = P.getInventory();
|
||||
for (Entry<String, Integer> item : itemPositions.entrySet()) {
|
||||
pi.setItem(item.getValue(), getItem(item.getKey(), P));
|
||||
@@ -163,20 +176,22 @@ public class Inventories implements Listener {
|
||||
Core.statusMsg(P, "lang_changed", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void addInvItems(Player P) {
|
||||
for (Entry<String, Integer> item : itemPositions.entrySet()) {
|
||||
P.getInventory().setItem(item.getValue(), getItem(item.getKey(), P));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void openInventory(String inv, Player P) {
|
||||
P.openInventory(invs.get(inv).get(Core.getPlayerLang(P)));
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onInvClick(InventoryClickEvent event) {
|
||||
if (checkInteracts.containsKey((Player)event.getWhoClicked()) && !checkInteracts.get((Player)event.getWhoClicked())) return;
|
||||
if (checkInteracts.containsKey((Player) event.getWhoClicked()) && !checkInteracts.get((Player) event.getWhoClicked())) {
|
||||
return;
|
||||
}
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
Inventory inventory = event.getClickedInventory();
|
||||
String invName = inventory.getName();
|
||||
@@ -191,8 +206,7 @@ public class Inventories implements Listener {
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AnuraCore.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
public void run() {
|
||||
player.setItemOnCursor(new ItemStack(Material.AIR));
|
||||
player.updateInventory();
|
||||
}
|
||||
@@ -204,10 +218,12 @@ public class Inventories implements Listener {
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (checkInteracts.containsKey((Player)event.getPlayer()) && !checkInteracts.get((Player)event.getPlayer())) return;
|
||||
if (checkInteracts.containsKey((Player) event.getPlayer()) && !checkInteracts.get((Player) event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
if (event.hasItem()) {
|
||||
if (event.getAction().equals(org.bukkit.event.block.Action.RIGHT_CLICK_AIR) || event.getAction().equals(org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK)) {
|
||||
final Player P = event.getPlayer();
|
||||
@@ -220,8 +236,7 @@ public class Inventories implements Listener {
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AnuraCore.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
public void run() {
|
||||
P.updateInventory();
|
||||
}
|
||||
}, 1);
|
||||
@@ -229,9 +244,9 @@ public class Inventories implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
event.getPlayer().getInventory().clear();
|
||||
addInvItems(event.getPlayer());
|
||||
}
|
||||
|
||||
@@ -6,8 +6,9 @@ import java.util.HashMap;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
public class Money {
|
||||
|
||||
private static final HashMap<OfflinePlayer, Integer> playerMoney = new HashMap<>();
|
||||
|
||||
|
||||
public static void payMoney(OfflinePlayer P, int count) {
|
||||
if (!playerMoney.containsKey(P)) {
|
||||
if (!loadMoney(P)) {
|
||||
@@ -16,25 +17,27 @@ public class Money {
|
||||
}
|
||||
playerMoney.put(P, playerMoney.get(P) + count);
|
||||
}
|
||||
|
||||
|
||||
public static void saveMoney(OfflinePlayer P) {
|
||||
if (!playerMoney.containsKey(P)) return;
|
||||
Core.getMySql().queryUpdate("UPDATE coreStats SET money = '" + playerMoney.get(P) + "' WHERE player = (SELECT id FROM players WHERE uuid = '"+P.getUniqueId().toString()+"')");
|
||||
if (!playerMoney.containsKey(P)) {
|
||||
return;
|
||||
}
|
||||
Core.getMySql().queryUpdate("UPDATE coreStats SET money = '" + playerMoney.get(P) + "' WHERE player = (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "')");
|
||||
playerMoney.remove(P);
|
||||
}
|
||||
|
||||
|
||||
public static boolean loadMoney(OfflinePlayer P) {
|
||||
ResultSet rs = Core.getMySql().querySelect("SELECT money FROM coreStats WHERE player = (SELECT id FROM players WHERE uuid = '"+P.getUniqueId().toString()+"')");
|
||||
ResultSet rs = Core.getMySql().querySelect("SELECT money FROM coreStats WHERE player = (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "')");
|
||||
try {
|
||||
rs.first();
|
||||
playerMoney.put(P, rs.getInt("money"));
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Could not load money for player "+P.getName());
|
||||
System.err.println("Could not load money for player " + P.getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static int getMoney(OfflinePlayer P) {
|
||||
if (!playerMoney.containsKey(P)) {
|
||||
if (!loadMoney(P)) {
|
||||
|
||||
@@ -15,191 +15,185 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public class MySQL {
|
||||
private final String host;
|
||||
private final int port;
|
||||
private final String username;
|
||||
private final String pw;
|
||||
private final String db;
|
||||
private Connection conn;
|
||||
public FileConfiguration config;
|
||||
private final AnuraCore plugin;
|
||||
public boolean isValid = true;
|
||||
private boolean reconnecting = false;
|
||||
public MySQL(AnuraCore plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
File file = new File("plugins/Core/","database.yml");
|
||||
FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
String dbLoc = "database.";
|
||||
cfg.addDefault(dbLoc+"host","localhost");
|
||||
cfg.addDefault(dbLoc+"port",3306);
|
||||
cfg.addDefault(dbLoc+"username","username");
|
||||
cfg.addDefault(dbLoc+"pw","pw");
|
||||
cfg.addDefault(dbLoc+"db","db");
|
||||
cfg.options().copyDefaults(true);
|
||||
try
|
||||
{
|
||||
cfg.save(file);
|
||||
}
|
||||
catch(IOException e)
|
||||
{}
|
||||
this.host = cfg.getString(dbLoc+"host");
|
||||
this.port = cfg.getInt(dbLoc+"port");
|
||||
this.username = cfg.getString(dbLoc+"username");
|
||||
this.pw = cfg.getString(dbLoc+"pw");
|
||||
this.db = cfg.getString(dbLoc+"db");
|
||||
if(!this.openConnection())
|
||||
{
|
||||
Bukkit.broadcastMessage(ChatColor.RED + "No database connection available, please contact a server administrator!");
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
this.config = cfg;
|
||||
|
||||
private final String host;
|
||||
private final int port;
|
||||
private final String username;
|
||||
private final String pw;
|
||||
private final String db;
|
||||
private Connection conn;
|
||||
public FileConfiguration config;
|
||||
private final AnuraCore plugin;
|
||||
public boolean isValid = true;
|
||||
private boolean reconnecting = false;
|
||||
|
||||
public MySQL(AnuraCore plugin) {
|
||||
this.plugin = plugin;
|
||||
File file = new File("plugins/Core/", "database.yml");
|
||||
FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
String dbLoc = "database.";
|
||||
cfg.addDefault(dbLoc + "host", "localhost");
|
||||
cfg.addDefault(dbLoc + "port", 3306);
|
||||
cfg.addDefault(dbLoc + "username", "username");
|
||||
cfg.addDefault(dbLoc + "pw", "pw");
|
||||
cfg.addDefault(dbLoc + "db", "db");
|
||||
cfg.options().copyDefaults(true);
|
||||
try {
|
||||
cfg.save(file);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
public String escapeString(String text)
|
||||
{
|
||||
return text;
|
||||
this.host = cfg.getString(dbLoc + "host");
|
||||
this.port = cfg.getInt(dbLoc + "port");
|
||||
this.username = cfg.getString(dbLoc + "username");
|
||||
this.pw = cfg.getString(dbLoc + "pw");
|
||||
this.db = cfg.getString(dbLoc + "db");
|
||||
if (!this.openConnection()) {
|
||||
Bukkit.broadcastMessage(ChatColor.RED + "No database connection available, please contact a server administrator!");
|
||||
this.isValid = false;
|
||||
return;
|
||||
}
|
||||
private Boolean openConnection() {
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
Connection connLoc = DriverManager.getConnection("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.db, this.username, this.pw);
|
||||
this.conn = connLoc;
|
||||
return true;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private boolean hasConnection() {
|
||||
try {
|
||||
Boolean validConn = true;
|
||||
if(this.conn == null) validConn = false;
|
||||
else if(!this.conn.isValid(1)) validConn = false;
|
||||
return validConn;
|
||||
} catch (SQLException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private Boolean reconnect()
|
||||
{
|
||||
if(this.reconnecting)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.reconnecting = true;
|
||||
System.out.println("Reconnecting...");
|
||||
Bukkit.broadcastMessage(ChatColor.YELLOW + "Bitte warten... Plugin-Daten werden geladen...");
|
||||
this.closeConnection();
|
||||
if(!this.openConnection())
|
||||
{
|
||||
Bukkit.broadcastMessage(ChatColor.RED + "Database reconnect failed! Please contact a server administrator!");
|
||||
}
|
||||
else System.out.println("Database reconnect successful!");
|
||||
this.reconnecting = false;
|
||||
this.config = cfg;
|
||||
}
|
||||
|
||||
public String escapeString(String text) {
|
||||
return text;
|
||||
}
|
||||
|
||||
private Boolean openConnection() {
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
Connection connLoc = DriverManager.getConnection("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.db, this.username, this.pw);
|
||||
this.conn = connLoc;
|
||||
return true;
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
return false;
|
||||
}
|
||||
private void queryRedo(final String query, final String type)
|
||||
{
|
||||
if(!this.reconnect())
|
||||
{
|
||||
this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
switch (type) {
|
||||
case "update":
|
||||
AnuraCore.sql.queryUpdate(query);
|
||||
break;
|
||||
case "select":
|
||||
AnuraCore.sql.querySelect(query);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, 4);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasConnection() {
|
||||
try {
|
||||
Boolean validConn = true;
|
||||
if (this.conn == null) {
|
||||
validConn = false;
|
||||
} else if (!this.conn.isValid(1)) {
|
||||
validConn = false;
|
||||
}
|
||||
return validConn;
|
||||
} catch (SQLException e) {
|
||||
return false;
|
||||
}
|
||||
public void queryUpdate(String query)
|
||||
{
|
||||
if(!this.hasConnection())
|
||||
{
|
||||
queryRedo(query, "update");
|
||||
}
|
||||
Connection connLoc = this.conn;
|
||||
PreparedStatement st = null;
|
||||
try {
|
||||
st = connLoc.prepareStatement(query);
|
||||
st.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Failed to send Update '" +query+"'! ("+e.getLocalizedMessage()+")");
|
||||
}
|
||||
this.closeRessources(null, st);
|
||||
}
|
||||
public ResultSet querySelect(final String query)
|
||||
{
|
||||
if(!this.hasConnection())
|
||||
{
|
||||
queryRedo(query, "select");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
PreparedStatement st = this.conn.prepareStatement(query);
|
||||
ResultSet returns = this.querySelect(st);
|
||||
if(returns == null)
|
||||
{
|
||||
queryRedo(query, "select");
|
||||
}
|
||||
|
||||
private Boolean reconnect() {
|
||||
if (this.reconnecting) {
|
||||
return false;
|
||||
}
|
||||
this.reconnecting = true;
|
||||
System.out.println("Reconnecting...");
|
||||
Bukkit.broadcastMessage(ChatColor.YELLOW + "Bitte warten... Plugin-Daten werden geladen...");
|
||||
this.closeConnection();
|
||||
if (!this.openConnection()) {
|
||||
Bukkit.broadcastMessage(ChatColor.RED + "Database reconnect failed! Please contact a server administrator!");
|
||||
} else {
|
||||
System.out.println("Database reconnect successful!");
|
||||
}
|
||||
this.reconnecting = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void queryRedo(final String query, final String type) {
|
||||
if (!this.reconnect()) {
|
||||
this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
switch (type) {
|
||||
case "update":
|
||||
AnuraCore.sql.queryUpdate(query);
|
||||
break;
|
||||
case "select":
|
||||
AnuraCore.sql.querySelect(query);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return returns;
|
||||
}
|
||||
}
|
||||
catch(SQLException e)
|
||||
{
|
||||
System.err.println("Unknown error whilst trying to build Prepared Statement!");
|
||||
queryRedo(query, "select");
|
||||
}
|
||||
}, 4);
|
||||
}
|
||||
}
|
||||
|
||||
public void queryUpdate(String query) {
|
||||
if (!this.hasConnection()) {
|
||||
queryRedo(query, "update");
|
||||
}
|
||||
Connection connLoc = this.conn;
|
||||
PreparedStatement st = null;
|
||||
try {
|
||||
st = connLoc.prepareStatement(query);
|
||||
st.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Failed to send Update '" + query + "'! (" + e.getLocalizedMessage() + ")");
|
||||
}
|
||||
this.closeRessources(null, st);
|
||||
}
|
||||
|
||||
public ResultSet querySelect(final String query) {
|
||||
if (!this.hasConnection()) {
|
||||
queryRedo(query, "select");
|
||||
return null;
|
||||
}
|
||||
private ResultSet querySelect(PreparedStatement st)
|
||||
{
|
||||
if(!this.hasConnection())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ResultSet rs;
|
||||
try {
|
||||
rs = st.executeQuery();
|
||||
}
|
||||
catch(SQLException e)
|
||||
{
|
||||
System.err.println("Failed to send 'SELECT'-Query!("+st.toString()+") Will try to reconnect to database just in case... you know...");
|
||||
System.err.println("Caused by: "+e.getMessage());
|
||||
return null;
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
private void closeRessources(ResultSet rs, PreparedStatement st) {
|
||||
if(rs != null) {
|
||||
try {
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
|
||||
}
|
||||
}
|
||||
if(st != null) {
|
||||
try {
|
||||
st.close();
|
||||
} catch (SQLException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public void closeConnection() {
|
||||
try {
|
||||
if(this.conn != null) this.conn.close();
|
||||
} catch (SQLException e) {}
|
||||
finally
|
||||
{
|
||||
this.conn = null;
|
||||
}
|
||||
try {
|
||||
PreparedStatement st = this.conn.prepareStatement(query);
|
||||
ResultSet returns = this.querySelect(st);
|
||||
if (returns == null) {
|
||||
queryRedo(query, "select");
|
||||
} else {
|
||||
return returns;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Unknown error whilst trying to build Prepared Statement!");
|
||||
queryRedo(query, "select");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private ResultSet querySelect(PreparedStatement st) {
|
||||
if (!this.hasConnection()) {
|
||||
return null;
|
||||
}
|
||||
ResultSet rs;
|
||||
try {
|
||||
rs = st.executeQuery();
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Failed to send 'SELECT'-Query!(" + st.toString() + ") Will try to reconnect to database just in case... you know...");
|
||||
System.err.println("Caused by: " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
private void closeRessources(ResultSet rs, PreparedStatement st) {
|
||||
if (rs != null) {
|
||||
try {
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
|
||||
}
|
||||
}
|
||||
if (st != null) {
|
||||
try {
|
||||
st.close();
|
||||
} catch (SQLException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void closeConnection() {
|
||||
try {
|
||||
if (this.conn != null) {
|
||||
this.conn.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} finally {
|
||||
this.conn = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,24 +4,21 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class Tools {
|
||||
|
||||
|
||||
/**
|
||||
* Sends a given message to a given player with the given status
|
||||
*
|
||||
* @param p The player to send the message to
|
||||
* @param msg The message to send
|
||||
* @param positive If the message should be green(true) or red(false)
|
||||
*/
|
||||
public void sendStatusMsg(CommandSender p, String msg, Boolean positive)
|
||||
{
|
||||
public void sendStatusMsg(CommandSender p, String msg, Boolean positive) {
|
||||
ChatColor chatColor;
|
||||
if(positive)
|
||||
{
|
||||
if (positive) {
|
||||
chatColor = ChatColor.GREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
chatColor = ChatColor.RED;
|
||||
}
|
||||
p.sendMessage(ChatColor.GRAY + "[Anura] "+chatColor+msg);
|
||||
p.sendMessage(ChatColor.GRAY + "[Anura] " + chatColor + msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class AnuraCore extends JavaPlugin{
|
||||
|
||||
public class AnuraCore extends JavaPlugin {
|
||||
|
||||
public static MySQL sql;
|
||||
public HashMap<Player, Double> selectableJumper = new HashMap<>();
|
||||
public HashMap<Player, String> permGroup = new HashMap<>();
|
||||
@@ -41,14 +41,12 @@ public class AnuraCore extends JavaPlugin{
|
||||
public Permissions perms;
|
||||
public Signs signs;
|
||||
public Tools tools;
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
public void onEnable() {
|
||||
AnuraCore.sql = new MySQL(this);
|
||||
AnuraCore.instance = this;
|
||||
if(AnuraCore.sql.isValid)
|
||||
{
|
||||
if (AnuraCore.sql.isValid) {
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
Setup.setupConfig();
|
||||
Setup.setupEvents();
|
||||
@@ -57,52 +55,43 @@ public class AnuraCore extends JavaPlugin{
|
||||
Setup.setupInventories();
|
||||
Setup.setupCommands();
|
||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", signs);
|
||||
sql.queryUpdate("DELETE FROM coreServers WHERE name = '"+this.getConfig().getString("server-name")+"'");
|
||||
sql.queryUpdate("INSERT INTO coreServers (name, maxPlayers) VALUES ('"+this.getConfig().getString("server-name")+"','"+this.getServer().getMaxPlayers()+"')");
|
||||
}
|
||||
else
|
||||
{
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
sql.queryUpdate("DELETE FROM coreServers WHERE name = '" + this.getConfig().getString("server-name") + "'");
|
||||
sql.queryUpdate("INSERT INTO coreServers (name, maxPlayers) VALUES ('" + this.getConfig().getString("server-name") + "','" + this.getServer().getMaxPlayers() + "')");
|
||||
} else {
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
if(!AnuraCore.sql.isValid)
|
||||
{
|
||||
public void onDisable() {
|
||||
if (!AnuraCore.sql.isValid) {
|
||||
return;
|
||||
}
|
||||
for (Player P : getServer().getOnlinePlayers()) {
|
||||
Money.saveMoney(P);
|
||||
}
|
||||
File configFile = new File("plugins/Core/","config.yml");
|
||||
File dbFile = new File("plugins/Core","database.yml");
|
||||
try
|
||||
{
|
||||
File configFile = new File("plugins/Core/", "config.yml");
|
||||
File dbFile = new File("plugins/Core", "database.yml");
|
||||
try {
|
||||
AnuraCore.sql.config.save(dbFile);
|
||||
this.getConfig().save(configFile);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch(IOException e)
|
||||
{ }
|
||||
sql.queryUpdate("DELETE FROM coreServers WHERE name = '"+this.getConfig().getString("server-name")+"'");
|
||||
sql.queryUpdate("DELETE FROM coreServers WHERE name = '" + this.getConfig().getString("server-name") + "'");
|
||||
features.reset();
|
||||
for(Player P : this.sittingPlayer.keySet())
|
||||
{
|
||||
for (Player P : this.sittingPlayer.keySet()) {
|
||||
Core.endSitting(P);
|
||||
}
|
||||
}
|
||||
|
||||
public static AnuraCore getInstance()
|
||||
{
|
||||
|
||||
public static AnuraCore getInstance() {
|
||||
return AnuraCore.instance;
|
||||
}
|
||||
|
||||
public static MySQL getSql()
|
||||
{
|
||||
|
||||
public static MySQL getSql() {
|
||||
return AnuraCore.sql;
|
||||
}
|
||||
|
||||
|
||||
public Features getFeatures() {
|
||||
return features;
|
||||
}
|
||||
|
||||
@@ -15,75 +15,76 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
||||
public class Features implements Listener {
|
||||
|
||||
|
||||
public enum Feature {
|
||||
|
||||
DOUBLE_JUMP(1);
|
||||
|
||||
private Feature(int id) {
|
||||
this.featureId = id;
|
||||
}
|
||||
private final int featureId;
|
||||
private static final HashMap<Integer, Feature> BY_ID = new HashMap<>();
|
||||
public static Feature getById(Integer id)
|
||||
{
|
||||
|
||||
public static Feature getById(Integer id) {
|
||||
return BY_ID.get(id);
|
||||
}
|
||||
|
||||
static {
|
||||
for (Feature feature : values()) {
|
||||
BY_ID.put(feature.featureId, feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Features()
|
||||
{
|
||||
|
||||
public Features() {
|
||||
Bukkit.getPluginManager().registerEvents(this, AnuraCore.getInstance());
|
||||
}
|
||||
|
||||
|
||||
private final HashMap<Player, ArrayList<Feature>> playerFeatures = new HashMap<>();
|
||||
private final HashMap<Player, Boolean> canDoubleJump = new HashMap<>();
|
||||
private final HashMap<Player, HashMap<Feature, Boolean>> featureEnabled = new HashMap<>();
|
||||
|
||||
public void updateFeatures(Player P)
|
||||
{
|
||||
if(!mainLobby()) return;
|
||||
|
||||
public void updateFeatures(Player P) {
|
||||
if (!mainLobby()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ResultSet rs = Core.getMySql().querySelect("SELECT featureId FROM coreFeatures WHERE playerId = (SELECT id FROM players WHERE uuid = '"+P.getUniqueId().toString()+"')");
|
||||
ResultSet rs = Core.getMySql().querySelect("SELECT featureId FROM coreFeatures WHERE playerId = (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "')");
|
||||
resetPlayerFeatures(P);
|
||||
playerFeatures.put(P, new ArrayList<Feature>());
|
||||
featureEnabled.put(P, new HashMap<Feature, Boolean>());
|
||||
while(rs.next())
|
||||
{
|
||||
if(Feature.getById(rs.getInt("featureId")) != null)
|
||||
{
|
||||
while (rs.next()) {
|
||||
if (Feature.getById(rs.getInt("featureId")) != null) {
|
||||
this.addFeature(P, Feature.getById(rs.getInt("featureId")));
|
||||
featureEnabled.get(P).put(Feature.DOUBLE_JUMP, true);
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Could not update player features because of a sql exception: "+ex.getLocalizedMessage());
|
||||
System.err.println("Could not update player features because of a sql exception: " + ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
public void updateFeaturesAll()
|
||||
{
|
||||
if(!mainLobby()) return;
|
||||
for(Player P : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
|
||||
public void updateFeaturesAll() {
|
||||
if (!mainLobby()) {
|
||||
return;
|
||||
}
|
||||
for (Player P : Bukkit.getOnlinePlayers()) {
|
||||
updateFeatures(P);
|
||||
}
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
for(Player P : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
|
||||
public void reset() {
|
||||
for (Player P : Bukkit.getOnlinePlayers()) {
|
||||
this.resetPlayerFeatures(P);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void disableFeature(Player P, Feature f) {
|
||||
if(!mainLobby()) return;
|
||||
if (!mainLobby()) {
|
||||
return;
|
||||
}
|
||||
if (f == Feature.DOUBLE_JUMP) {
|
||||
if (!hasFeature(P, f)) {
|
||||
Core.statusMsg(P, "dont_have_dbl_jump", false);
|
||||
@@ -97,9 +98,11 @@ public class Features implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void enableFeature(Player P, Feature f) {
|
||||
if(!mainLobby()) return;
|
||||
if (!mainLobby()) {
|
||||
return;
|
||||
}
|
||||
if (f == Feature.DOUBLE_JUMP) {
|
||||
if (!hasFeature(P, f)) {
|
||||
Core.statusMsg(P, "dont_have_dbl_jump", false);
|
||||
@@ -111,89 +114,88 @@ public class Features implements Listener {
|
||||
Core.statusMsg(P, "dbl_jump_on", true);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasFeature(Player P, Feature f)
|
||||
{
|
||||
if(!mainLobby()) return false;
|
||||
if(playerFeatures.containsKey(P))
|
||||
{
|
||||
|
||||
public boolean hasFeature(Player P, Feature f) {
|
||||
if (!mainLobby()) {
|
||||
return false;
|
||||
}
|
||||
if (playerFeatures.containsKey(P)) {
|
||||
return playerFeatures.get(P).contains(f);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void resetPlayerFeatures(Player P)
|
||||
{
|
||||
if(!playerFeatures.containsKey(P)) return;
|
||||
for(Feature f : (ArrayList<Feature>)playerFeatures.get(P).clone())
|
||||
{
|
||||
|
||||
private void resetPlayerFeatures(Player P) {
|
||||
if (!playerFeatures.containsKey(P)) {
|
||||
return;
|
||||
}
|
||||
for (Feature f : (ArrayList<Feature>) playerFeatures.get(P).clone()) {
|
||||
removeFeature(P, f);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFeature(Player P, Feature f)
|
||||
{
|
||||
if(!mainLobby()) return;
|
||||
if(playerFeatures.containsKey(P)) playerFeatures.get(P).remove(f);
|
||||
if(f.equals(Feature.DOUBLE_JUMP))
|
||||
{
|
||||
if(!P.getGameMode().equals(GameMode.CREATIVE))
|
||||
{
|
||||
|
||||
public void removeFeature(Player P, Feature f) {
|
||||
if (!mainLobby()) {
|
||||
return;
|
||||
}
|
||||
if (playerFeatures.containsKey(P)) {
|
||||
playerFeatures.get(P).remove(f);
|
||||
}
|
||||
if (f.equals(Feature.DOUBLE_JUMP)) {
|
||||
if (!P.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
P.setAllowFlight(false);
|
||||
P.setFoodLevel(20);
|
||||
}
|
||||
this.canDoubleJump.put(P, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void addFeature(Player P, Feature f)
|
||||
{
|
||||
if(!mainLobby()) return;
|
||||
if(playerFeatures.containsKey(P) && !hasFeature(P, f)) playerFeatures.get(P).add(f);
|
||||
if(f.equals(Feature.DOUBLE_JUMP))
|
||||
{
|
||||
|
||||
public void addFeature(Player P, Feature f) {
|
||||
if (!mainLobby()) {
|
||||
return;
|
||||
}
|
||||
if (playerFeatures.containsKey(P) && !hasFeature(P, f)) {
|
||||
playerFeatures.get(P).add(f);
|
||||
}
|
||||
if (f.equals(Feature.DOUBLE_JUMP)) {
|
||||
P.setAllowFlight(true);
|
||||
this.canDoubleJump.put(P, true);
|
||||
}
|
||||
}
|
||||
private boolean mainLobby()
|
||||
{
|
||||
|
||||
private boolean mainLobby() {
|
||||
return AnuraCore.getInstance().getConfig().getBoolean("is-main-lobby");
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
if(!mainLobby()) return;
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (!mainLobby()) {
|
||||
return;
|
||||
}
|
||||
Player P = event.getPlayer();
|
||||
if(this.hasFeature(P, Feature.DOUBLE_JUMP))
|
||||
{
|
||||
if(this.canDoubleJump.containsKey(P) && !this.canDoubleJump.get(P) && ((Entity)P).isOnGround())
|
||||
{
|
||||
if (this.hasFeature(P, Feature.DOUBLE_JUMP)) {
|
||||
if (this.canDoubleJump.containsKey(P) && !this.canDoubleJump.get(P) && ((Entity) P).isOnGround()) {
|
||||
this.canDoubleJump.put(P, true);
|
||||
P.setFoodLevel(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onToggleFlight(PlayerToggleFlightEvent event)
|
||||
{
|
||||
if(!mainLobby()) return;
|
||||
public void onToggleFlight(PlayerToggleFlightEvent event) {
|
||||
if (!mainLobby()) {
|
||||
return;
|
||||
}
|
||||
Player P = event.getPlayer();
|
||||
|
||||
if(this.hasFeature(P, Feature.DOUBLE_JUMP) && !P.getGameMode().equals(GameMode.CREATIVE))
|
||||
{
|
||||
if(this.canDoubleJump.containsKey(P) && this.canDoubleJump.get(P))
|
||||
{
|
||||
|
||||
if (this.hasFeature(P, Feature.DOUBLE_JUMP) && !P.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
if (this.canDoubleJump.containsKey(P) && this.canDoubleJump.get(P)) {
|
||||
this.canDoubleJump.put(P, false);
|
||||
P.setFoodLevel(1);
|
||||
Vector v = P.getLocation().getDirection();
|
||||
P.setVelocity(v.multiply(new Vector(1,2,1)));
|
||||
P.setVelocity(v.multiply(new Vector(1, 2, 1)));
|
||||
P.setVelocity(P.getVelocity().setY(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Vector v = P.getVelocity();
|
||||
P.setVelocity(v.setY(-0.4));
|
||||
}
|
||||
|
||||
@@ -13,20 +13,18 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class FlowerPots {
|
||||
|
||||
private final HashMap<Player, HashMap<Integer, Boolean>> foundCache = new HashMap<>();
|
||||
private final HashMap<Player, HashMap<Integer, Integer>> foundTimestamp = new HashMap<>();
|
||||
|
||||
public boolean foundPot(Player P, Integer pot)
|
||||
{
|
||||
if(!foundCache.containsKey(P)) refreshCache(P);
|
||||
if(foundCache.get(P).containsKey(pot))
|
||||
{
|
||||
if(foundCache.get(P).get(pot) && foundTimestamp.get(P).containsKey(pot))
|
||||
{
|
||||
if((System.currentTimeMillis() / 1000 - foundTimestamp.get(P).get(pot)) >= getPotWaitTime(pot))
|
||||
{
|
||||
|
||||
public boolean foundPot(Player P, Integer pot) {
|
||||
if (!foundCache.containsKey(P)) {
|
||||
refreshCache(P);
|
||||
}
|
||||
if (foundCache.get(P).containsKey(pot)) {
|
||||
if (foundCache.get(P).get(pot) && foundTimestamp.get(P).containsKey(pot)) {
|
||||
if ((System.currentTimeMillis() / 1000 - foundTimestamp.get(P).get(pot)) >= getPotWaitTime(pot)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -34,31 +32,25 @@ public class FlowerPots {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private int getPotWaitTime(Integer pot)
|
||||
{
|
||||
if (AnuraCore.getInstance().flowerPots.containsKey(pot))
|
||||
{
|
||||
if (AnuraCore.getInstance().flowerPotsWait.containsKey(pot))
|
||||
{
|
||||
|
||||
private int getPotWaitTime(Integer pot) {
|
||||
if (AnuraCore.getInstance().flowerPots.containsKey(pot)) {
|
||||
if (AnuraCore.getInstance().flowerPotsWait.containsKey(pot)) {
|
||||
return AnuraCore.getInstance().flowerPotsWait.get(pot);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void refreshCache(Player P)
|
||||
{
|
||||
|
||||
public void refreshCache(Player P) {
|
||||
try {
|
||||
ResultSet rs = AnuraCore.getSql().querySelect("SELECT id, timestamp, type FROM coreFoundPots WHERE player = (SELECT id FROM players WHERE uuid = '"+P.getUniqueId().toString()+"')");
|
||||
ResultSet rs = AnuraCore.getSql().querySelect("SELECT id, timestamp, type FROM coreFoundPots WHERE player = (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "')");
|
||||
HashMap<Integer, Boolean> list = new HashMap<>();
|
||||
HashMap<Integer, Integer> listTimes = new HashMap<>();
|
||||
while(rs.next())
|
||||
{
|
||||
while (rs.next()) {
|
||||
list.put(rs.getInt("id"), rs.getBoolean("type"));
|
||||
if(rs.getBoolean("type"))
|
||||
{
|
||||
if (rs.getBoolean("type")) {
|
||||
listTimes.put(rs.getInt("id"), rs.getInt("timestamp"));
|
||||
}
|
||||
}
|
||||
@@ -68,109 +60,90 @@ public class FlowerPots {
|
||||
System.out.println("Error refreshCache(FlowerPots)");
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshPot(Integer pot)
|
||||
{
|
||||
|
||||
public void refreshPot(Integer pot) {
|
||||
Location l = AnuraCore.getInstance().flowerPots.get(pot);
|
||||
for(Player P : l.getWorld().getPlayers())
|
||||
{
|
||||
if(P.getLocation().distance(l) < 20)
|
||||
{
|
||||
for (Player P : l.getWorld().getPlayers()) {
|
||||
if (P.getLocation().distance(l) < 20) {
|
||||
refreshPlayerPot(P, pot, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshPlayerPot(Player p, Integer pot, Location l)
|
||||
{
|
||||
if(!this.foundPot(p, pot))
|
||||
{
|
||||
p.sendBlockChange(l, Material.FLOWER_POT, (byte)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
p.sendBlockChange(l, Material.AIR, (byte)0);
|
||||
|
||||
public void refreshPlayerPot(Player p, Integer pot, Location l) {
|
||||
if (!this.foundPot(p, pot)) {
|
||||
p.sendBlockChange(l, Material.FLOWER_POT, (byte) 0);
|
||||
} else {
|
||||
p.sendBlockChange(l, Material.AIR, (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshPlayer(Player p)
|
||||
{
|
||||
for(Map.Entry<Integer, Location> pots : AnuraCore.getInstance().flowerPots.entrySet())
|
||||
{
|
||||
if(pots.getValue().getWorld().equals(p.getLocation().getWorld()) && pots.getValue().distance(p.getLocation()) < 20)
|
||||
{
|
||||
|
||||
public void refreshPlayer(Player p) {
|
||||
for (Map.Entry<Integer, Location> pots : AnuraCore.getInstance().flowerPots.entrySet()) {
|
||||
if (pots.getValue().getWorld().equals(p.getLocation().getWorld()) && pots.getValue().distance(p.getLocation()) < 20) {
|
||||
refreshPlayerPot(p, pots.getKey(), pots.getValue());
|
||||
}
|
||||
}
|
||||
AnuraCore.getInstance().lastLoc.put(p, p.getLocation());
|
||||
}
|
||||
|
||||
public void playerFoundPot(Player P, Integer pot)
|
||||
{
|
||||
if(!foundPot(P, pot))
|
||||
{
|
||||
|
||||
public void playerFoundPot(Player P, Integer pot) {
|
||||
if (!foundPot(P, pot)) {
|
||||
Integer time = getPotWaitTime(pot);
|
||||
boolean alreadyFound = foundCache.get(P).containsKey(pot);
|
||||
int type = 0;
|
||||
if(time == -1)
|
||||
{
|
||||
if (time == -1) {
|
||||
foundCache.get(P).put(pot, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
type = 1;
|
||||
foundCache.get(P).put(pot, true);
|
||||
foundTimestamp.get(P).put(pot, (int)(System.currentTimeMillis() / 1000));
|
||||
foundTimestamp.get(P).put(pot, (int) (System.currentTimeMillis() / 1000));
|
||||
}
|
||||
String sql;
|
||||
if(alreadyFound)
|
||||
{
|
||||
sql = "UPDATE coreFoundPots SET timestamp = '"+(System.currentTimeMillis() / 1000)+"', type = 1 WHERE player = (SELECT id FROM players WHERE uuid = '"+P.getUniqueId().toString()+"') AND id = '"+pot+"'";
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = "INSERT INTO coreFoundPots(id, player, timestamp, type) VALUES('"+pot+"', (SELECT id FROM players WHERE uuid = '"+P.getUniqueId().toString()+"'),'"+(int) (System.currentTimeMillis() / 1000)+"',"+type+")";
|
||||
if (alreadyFound) {
|
||||
sql = "UPDATE coreFoundPots SET timestamp = '" + (System.currentTimeMillis() / 1000) + "', type = 1 WHERE player = (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "') AND id = '" + pot + "'";
|
||||
} else {
|
||||
sql = "INSERT INTO coreFoundPots(id, player, timestamp, type) VALUES('" + pot + "', (SELECT id FROM players WHERE uuid = '" + P.getUniqueId().toString() + "'),'" + (int) (System.currentTimeMillis() / 1000) + "'," + type + ")";
|
||||
}
|
||||
AnuraCore.getSql().queryUpdate(sql);
|
||||
Location loc = AnuraCore.getInstance().flowerPots.get(pot);
|
||||
for(int i = 0; i < 20; i++)
|
||||
{
|
||||
for (int i = 0; i < 20; i++) {
|
||||
loc.getWorld().playEffect(loc, Effect.FIREWORKS_SPARK, 4);
|
||||
}
|
||||
P.playSound(loc, Sound.LEVEL_UP, 1, (float)1.5);
|
||||
ResultSet rs = AnuraCore.getSql().querySelect("SELECT url, name, money FROM corePots WHERE id = '"+pot+"'");
|
||||
P.playSound(loc, Sound.LEVEL_UP, 1, (float) 1.5);
|
||||
ResultSet rs = AnuraCore.getSql().querySelect("SELECT url, name, money FROM corePots WHERE id = '" + pot + "'");
|
||||
try {
|
||||
rs.first();
|
||||
Money.payMoney(P, rs.getInt("money"));
|
||||
P.sendMessage(ChatColor.RED + "---------- "+ChatColor.YELLOW + "Achievement"+ChatColor.RED+ " ----------");
|
||||
P.sendMessage(ChatColor.RED + "---------- " + ChatColor.YELLOW + "Achievement" + ChatColor.RED + " ----------");
|
||||
P.sendMessage(ChatColor.BLUE + rs.getString("name"));
|
||||
P.sendMessage("" + ChatColor.GOLD + ChatColor.UNDERLINE + rs.getString("url"));
|
||||
P.sendMessage("");
|
||||
P.sendMessage(ChatColor.RED + "---------- "+ChatColor.YELLOW + "Achievement"+ChatColor.RED+ " ----------");
|
||||
P.sendMessage(ChatColor.RED + "---------- " + ChatColor.YELLOW + "Achievement" + ChatColor.RED + " ----------");
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error playerFoundPot(FlowerPot)");
|
||||
}
|
||||
}
|
||||
else if(getPotWaitTime(pot) != -1 && foundCache.containsKey(P) && foundCache.get(P).containsKey(pot) && foundTimestamp.containsKey(P) && foundTimestamp.get(P).containsKey(pot))
|
||||
{
|
||||
int current = (int)(System.currentTimeMillis() / 1000);
|
||||
}
|
||||
} else if (getPotWaitTime(pot) != -1 && foundCache.containsKey(P) && foundCache.get(P).containsKey(pot) && foundTimestamp.containsKey(P) && foundTimestamp.get(P).containsKey(pot)) {
|
||||
int current = (int) (System.currentTimeMillis() / 1000);
|
||||
int found = foundTimestamp.get(P).get(pot);
|
||||
int waitTime = getPotWaitTime(pot);
|
||||
int toWait = (found + waitTime) - current;
|
||||
if (toWait <= 0) return;
|
||||
if (toWait <= 0) {
|
||||
return;
|
||||
}
|
||||
String text = ChatColor.RED + Core.getl("ach_wait_1", P);
|
||||
if (toWait < 60) {
|
||||
text += " "+ChatColor.GREEN+toWait+" "+ChatColor.RED+Core.getl("ach_wait_seconds", P);
|
||||
} else if (toWait < 60*60) {
|
||||
text += " "+ChatColor.GREEN+Math.round(toWait/60)+" "+ChatColor.RED+Core.getl("ach_wait_minutes", P);
|
||||
} else if (toWait < 60*60*24) {
|
||||
text += " "+ChatColor.GREEN+Math.round(toWait/60/60)+" "+ChatColor.RED+Core.getl("ach_wait_hours", P);
|
||||
text += " " + ChatColor.GREEN + toWait + " " + ChatColor.RED + Core.getl("ach_wait_seconds", P);
|
||||
} else if (toWait < 60 * 60) {
|
||||
text += " " + ChatColor.GREEN + Math.round(toWait / 60) + " " + ChatColor.RED + Core.getl("ach_wait_minutes", P);
|
||||
} else if (toWait < 60 * 60 * 24) {
|
||||
text += " " + ChatColor.GREEN + Math.round(toWait / 60 / 60) + " " + ChatColor.RED + Core.getl("ach_wait_hours", P);
|
||||
} else {
|
||||
text += " "+ChatColor.GREEN+Math.round(toWait/60/60/24)+" "+ChatColor.RED+Core.getl("ach_wait_days", P);
|
||||
text += " " + ChatColor.GREEN + Math.round(toWait / 60 / 60 / 24) + " " + ChatColor.RED + Core.getl("ach_wait_days", P);
|
||||
}
|
||||
text += " "+Core.getl("ach_wait_2", P);
|
||||
|
||||
text += " " + Core.getl("ach_wait_2", P);
|
||||
|
||||
P.sendMessage(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
package de.anura.core;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -9,13 +8,14 @@ import org.bukkit.map.MapView;
|
||||
public class ImgRenderer extends MapRenderer {
|
||||
|
||||
private final String name;
|
||||
|
||||
public ImgRenderer(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MapView mv, MapCanvas mc, Player player) {
|
||||
mc.drawImage(0, 0, AnuraCore.getInstance().renderedImgs.get(this.name));
|
||||
mc.drawImage(0, 0, AnuraCore.getInstance().renderedImgs.get(this.name));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,49 +5,44 @@ import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class LanguageSupport
|
||||
{
|
||||
public class LanguageSupport {
|
||||
|
||||
private final AnuraCore plugin;
|
||||
public HashMap<String, String> languages = new HashMap<>();
|
||||
private HashMap<String, HashMap<String, String>> languageValues = new HashMap<>();
|
||||
|
||||
public LanguageSupport(AnuraCore plugin)
|
||||
{
|
||||
|
||||
public LanguageSupport(AnuraCore plugin) {
|
||||
this.plugin = plugin;
|
||||
ResultSet al = AnuraCore.sql.querySelect("SELECT name, short_name FROM coreAvailableLanguages");
|
||||
try {
|
||||
if(!al.next()) return;
|
||||
if (!al.next()) {
|
||||
return;
|
||||
}
|
||||
al.beforeFirst();
|
||||
String languageString = "";
|
||||
while(al.next())
|
||||
{
|
||||
while (al.next()) {
|
||||
languages.put(al.getString("short_name"), al.getString("name"));
|
||||
languageString += ", "+al.getString("short_name");
|
||||
languageString += ", " + al.getString("short_name");
|
||||
languageValues.put(al.getString("short_name"), new HashMap<String, String>());
|
||||
}
|
||||
ResultSet lv = AnuraCore.sql.querySelect("SELECT id"+languageString+" FROM coreLanguages");
|
||||
while(lv.next())
|
||||
{
|
||||
for(String lang : languages.keySet())
|
||||
{
|
||||
ResultSet lv = AnuraCore.sql.querySelect("SELECT id" + languageString + " FROM coreLanguages");
|
||||
while (lv.next()) {
|
||||
for (String lang : languages.keySet()) {
|
||||
languageValues.get(lang).put(lv.getString("id"), lv.getString(lang));
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Language data could not be loaded: "+ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
public String get(String id, String lang)
|
||||
{
|
||||
String value;
|
||||
if(languageValues.get(lang).containsKey(id))
|
||||
{
|
||||
value = languageValues.get(lang).get(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = id;
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&', value);
|
||||
System.out.println("Language data could not be loaded: " + ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String get(String id, String lang) {
|
||||
String value;
|
||||
if (languageValues.get(lang).containsKey(id)) {
|
||||
value = languageValues.get(lang).get(id);
|
||||
} else {
|
||||
value = id;
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&', value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,240 +18,264 @@ import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* ParticleEffect Library v1.3
|
||||
*
|
||||
* This library was created by @DarkBlade12 based on content related to particles of @microgeek (names and packet values), it allows you to display all Minecraft particle effects on a Bukkit server
|
||||
*
|
||||
* You are welcome to use it, modify it and redistribute it under the following conditions:
|
||||
* 1. Don't claim this class as your own
|
||||
* 2. Don't remove this text
|
||||
*
|
||||
*
|
||||
* This library was created by @DarkBlade12 based on content related to
|
||||
* particles of @microgeek (names and packet values), it allows you to display
|
||||
* all Minecraft particle effects on a Bukkit server
|
||||
*
|
||||
* You are welcome to use it, modify it and redistribute it under the following
|
||||
* conditions: 1. Don't claim this class as your own 2. Don't remove this text
|
||||
*
|
||||
* (Would be nice if you provide credit to me)
|
||||
*
|
||||
*
|
||||
* @author DarkBlade12
|
||||
*/
|
||||
public enum ParticleEffect {
|
||||
HUGE_EXPLOSION("hugeexplosion", 0),
|
||||
LARGE_EXPLODE("largeexplode", 1),
|
||||
FIREWORKS_SPARK("fireworksSpark", 2),
|
||||
BUBBLE("bubble", 3),
|
||||
SUSPEND("suspend", 4),
|
||||
DEPTH_SUSPEND("depthSuspend", 5),
|
||||
TOWN_AURA("townaura", 6),
|
||||
CRIT("crit", 7),
|
||||
MAGIC_CRIT("magicCrit", 8),
|
||||
MOB_SPELL("mobSpell", 9),
|
||||
MOB_SPELL_AMBIENT("mobSpellAmbient", 10),
|
||||
SPELL("spell", 11),
|
||||
INSTANT_SPELL("instantSpell", 12),
|
||||
WITCH_MAGIC("witchMagic", 13),
|
||||
NOTE("note", 14),
|
||||
PORTAL("portal", 15),
|
||||
ENCHANTMENT_TABLE("enchantmenttable", 16),
|
||||
EXPLODE("explode", 17),
|
||||
FLAME("flame", 18),
|
||||
LAVA("lava", 19),
|
||||
FOOTSTEP("footstep", 20),
|
||||
SPLASH("splash", 21),
|
||||
LARGE_SMOKE("largesmoke", 22),
|
||||
CLOUD("cloud", 23),
|
||||
RED_DUST("reddust", 24),
|
||||
SNOWBALL_POOF("snowballpoof", 25),
|
||||
DRIP_WATER("dripWater", 26),
|
||||
DRIP_LAVA("dripLava", 27),
|
||||
SNOW_SHOVEL("snowshovel", 28),
|
||||
SLIME("slime", 29),
|
||||
HEART("heart", 30),
|
||||
ANGRY_VILLAGER("angryVillager", 31),
|
||||
HAPPY_VILLAGER("happyVillager", 32);
|
||||
|
||||
private static final Map<String, ParticleEffect> NAME_MAP = new HashMap<>();
|
||||
private static final Map<Integer, ParticleEffect> ID_MAP = new HashMap<>();
|
||||
private static final double MAX_RANGE = 20.0D;
|
||||
private static Constructor<?> PARTICLE_PACKET_CONSTRUCTOR;
|
||||
HUGE_EXPLOSION("hugeexplosion", 0),
|
||||
LARGE_EXPLODE("largeexplode", 1),
|
||||
FIREWORKS_SPARK("fireworksSpark", 2),
|
||||
BUBBLE("bubble", 3),
|
||||
SUSPEND("suspend", 4),
|
||||
DEPTH_SUSPEND("depthSuspend", 5),
|
||||
TOWN_AURA("townaura", 6),
|
||||
CRIT("crit", 7),
|
||||
MAGIC_CRIT("magicCrit", 8),
|
||||
MOB_SPELL("mobSpell", 9),
|
||||
MOB_SPELL_AMBIENT("mobSpellAmbient", 10),
|
||||
SPELL("spell", 11),
|
||||
INSTANT_SPELL("instantSpell", 12),
|
||||
WITCH_MAGIC("witchMagic", 13),
|
||||
NOTE("note", 14),
|
||||
PORTAL("portal", 15),
|
||||
ENCHANTMENT_TABLE("enchantmenttable", 16),
|
||||
EXPLODE("explode", 17),
|
||||
FLAME("flame", 18),
|
||||
LAVA("lava", 19),
|
||||
FOOTSTEP("footstep", 20),
|
||||
SPLASH("splash", 21),
|
||||
LARGE_SMOKE("largesmoke", 22),
|
||||
CLOUD("cloud", 23),
|
||||
RED_DUST("reddust", 24),
|
||||
SNOWBALL_POOF("snowballpoof", 25),
|
||||
DRIP_WATER("dripWater", 26),
|
||||
DRIP_LAVA("dripLava", 27),
|
||||
SNOW_SHOVEL("snowshovel", 28),
|
||||
SLIME("slime", 29),
|
||||
HEART("heart", 30),
|
||||
ANGRY_VILLAGER("angryVillager", 31),
|
||||
HAPPY_VILLAGER("happyVillager", 32);
|
||||
|
||||
static {
|
||||
for (ParticleEffect effect : values()) {
|
||||
NAME_MAP.put(effect.name, effect);
|
||||
ID_MAP.put(effect.id, effect);
|
||||
}
|
||||
try {
|
||||
PARTICLE_PACKET_CONSTRUCTOR = ReflectionUtil.getConstructor(ReflectionUtil.getClass("PacketPlayOutWorldParticles", DynamicPackage.MINECRAFT_SERVER), String.class, float.class, float.class,
|
||||
float.class, float.class, float.class, float.class, float.class, int.class);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getStackTrace());
|
||||
}
|
||||
}
|
||||
private static final Map<String, ParticleEffect> NAME_MAP = new HashMap<>();
|
||||
private static final Map<Integer, ParticleEffect> ID_MAP = new HashMap<>();
|
||||
private static final double MAX_RANGE = 20.0D;
|
||||
private static Constructor<?> PARTICLE_PACKET_CONSTRUCTOR;
|
||||
|
||||
private String name;
|
||||
private int id;
|
||||
static {
|
||||
for (ParticleEffect effect : values()) {
|
||||
NAME_MAP.put(effect.name, effect);
|
||||
ID_MAP.put(effect.id, effect);
|
||||
}
|
||||
try {
|
||||
PARTICLE_PACKET_CONSTRUCTOR = ReflectionUtil.getConstructor(ReflectionUtil.getClass("PacketPlayOutWorldParticles", DynamicPackage.MINECRAFT_SERVER), String.class, float.class, float.class,
|
||||
float.class, float.class, float.class, float.class, float.class, int.class);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
ParticleEffect(String name, int id) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
}
|
||||
private String name;
|
||||
private int id;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
ParticleEffect(String name, int id) {
|
||||
this.name = name;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static ParticleEffect fromName(String name) {
|
||||
if (name != null)
|
||||
for (Entry<String, ParticleEffect> e : NAME_MAP.entrySet())
|
||||
if (e.getKey().equalsIgnoreCase(name))
|
||||
return e.getValue();
|
||||
return null;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public static ParticleEffect fromId(int id) {
|
||||
return ID_MAP.get(id);
|
||||
}
|
||||
public static ParticleEffect fromName(String name) {
|
||||
if (name != null) {
|
||||
for (Entry<String, ParticleEffect> e : NAME_MAP.entrySet()) {
|
||||
if (e.getKey().equalsIgnoreCase(name)) {
|
||||
return e.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static List<Player> getPlayersInRange(Location loc, double range) {
|
||||
List<Player> players = new ArrayList<>();
|
||||
double sqr = range * range;
|
||||
for (Player p : loc.getWorld().getPlayers())
|
||||
if (p.getLocation().distanceSquared(loc) <= sqr)
|
||||
players.add(p);
|
||||
return players;
|
||||
}
|
||||
public static ParticleEffect fromId(int id) {
|
||||
return ID_MAP.get(id);
|
||||
}
|
||||
|
||||
private static Object createPacket(String name, Location loc, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
if (amount <= 0)
|
||||
throw new IllegalArgumentException("Amount of particles has to be greater than 0");
|
||||
try {
|
||||
Object p = PARTICLE_PACKET_CONSTRUCTOR.newInstance(name, (float) loc.getX(), (float) loc.getY(), (float) loc.getZ(), offsetX, offsetY, offsetZ, speed, amount);
|
||||
return p;
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InstantiationException | InvocationTargetException e) {
|
||||
Bukkit.getLogger().warning("[ParticleEffect] Failed to create a particle packet!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private static List<Player> getPlayersInRange(Location loc, double range) {
|
||||
List<Player> players = new ArrayList<>();
|
||||
double sqr = range * range;
|
||||
for (Player p : loc.getWorld().getPlayers()) {
|
||||
if (p.getLocation().distanceSquared(loc) <= sqr) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
private Object createPacket(Location loc, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
return createPacket(this.getName(), loc, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
private static Object createPacket(String name, Location loc, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
if (amount <= 0) {
|
||||
throw new IllegalArgumentException("Amount of particles has to be greater than 0");
|
||||
}
|
||||
try {
|
||||
Object p = PARTICLE_PACKET_CONSTRUCTOR.newInstance(name, (float) loc.getX(), (float) loc.getY(), (float) loc.getZ(), offsetX, offsetY, offsetZ, speed, amount);
|
||||
return p;
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InstantiationException | InvocationTargetException e) {
|
||||
Bukkit.getLogger().warning("[ParticleEffect] Failed to create a particle packet!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Object createIconCrackPacket(int id, Location loc, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
return createPacket("iconcrack_" + id, loc, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
private Object createPacket(Location loc, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
return createPacket(this.getName(), loc, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
|
||||
private static Object createBlockCrackPacket(int id, byte data, Location loc, float offsetX, float offsetY, float offsetZ, int amount) {
|
||||
return createPacket("blockcrack_" + id + "_" + data, loc, offsetX, offsetY, offsetZ, 1.0F, amount);
|
||||
}
|
||||
private static Object createIconCrackPacket(int id, Location loc, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
return createPacket("iconcrack_" + id, loc, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
|
||||
private static Object createBlockDustPacket(int id, byte data, Location loc, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
return createPacket("blockdust_" + id + "_" + data, loc, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
private static Object createBlockCrackPacket(int id, byte data, Location loc, float offsetX, float offsetY, float offsetZ, int amount) {
|
||||
return createPacket("blockcrack_" + id + "_" + data, loc, offsetX, offsetY, offsetZ, 1.0F, amount);
|
||||
}
|
||||
|
||||
private static void sendPacket(Player p, Object packet) {
|
||||
if (packet != null)
|
||||
try {
|
||||
Object entityPlayer = ReflectionUtil.invokeMethod("getHandle", p.getClass(), p);
|
||||
Object playerConnection = ReflectionUtil.getValue("playerConnection", entityPlayer);
|
||||
ReflectionUtil.invokeMethod("sendPacket", playerConnection.getClass(), playerConnection, packet);
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "[ParticleEffect] Failed to send a particle packet to {0}!", p.getName());
|
||||
}
|
||||
}
|
||||
private static Object createBlockDustPacket(int id, byte data, Location loc, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
return createPacket("blockdust_" + id + "_" + data, loc, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
|
||||
private static void sendPacket(Collection<Player> players, Object packet) {
|
||||
for (Player p : players)
|
||||
sendPacket(p, packet);
|
||||
}
|
||||
private static void sendPacket(Player p, Object packet) {
|
||||
if (packet != null) {
|
||||
try {
|
||||
Object entityPlayer = ReflectionUtil.invokeMethod("getHandle", p.getClass(), p);
|
||||
Object playerConnection = ReflectionUtil.getValue("playerConnection", entityPlayer);
|
||||
ReflectionUtil.invokeMethod("sendPacket", playerConnection.getClass(), playerConnection, packet);
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "[ParticleEffect] Failed to send a particle packet to {0}!", p.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a particle effect which is only visible for specific players
|
||||
*/
|
||||
public void display(Location loc, float offsetX, float offsetY, float offsetZ, float speed, int amount, Player... players) {
|
||||
sendPacket(Arrays.asList(players), createPacket(loc, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
private static void sendPacket(Collection<Player> players, Object packet) {
|
||||
for (Player p : players) {
|
||||
sendPacket(p, packet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a particle effect which is visible for all players whitin the maximum range of 20 blocks in the world of @param loc
|
||||
*/
|
||||
public void display(Location loc, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
display(loc, MAX_RANGE, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
/**
|
||||
* Displays a particle effect which is only visible for specific players
|
||||
*/
|
||||
public void display(Location loc, float offsetX, float offsetY, float offsetZ, float speed, int amount, Player... players) {
|
||||
sendPacket(Arrays.asList(players), createPacket(loc, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a particle effect which is visible for all players whitin a certain range in the the world of @param loc
|
||||
*/
|
||||
public void display(Location loc, double range, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
if (range > MAX_RANGE)
|
||||
throw new IllegalArgumentException("Range has to be lower/equal the maximum of 20");
|
||||
sendPacket(getPlayersInRange(loc, range), createPacket(loc, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
/**
|
||||
* Displays a particle effect which is visible for all players whitin the
|
||||
* maximum range of 20 blocks in the world of @param loc
|
||||
*/
|
||||
public void display(Location loc, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
display(loc, MAX_RANGE, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays an icon crack (item break) effect which is only visible for specific players
|
||||
*/
|
||||
public static void displayIconCrack(Location loc, int id, float offsetX, float offsetY, float offsetZ, float speed, int amount, Player... players) {
|
||||
sendPacket(Arrays.asList(players), createIconCrackPacket(id, loc, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
/**
|
||||
* Displays a particle effect which is visible for all players whitin a
|
||||
* certain range in the the world of @param loc
|
||||
*/
|
||||
public void display(Location loc, double range, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
if (range > MAX_RANGE) {
|
||||
throw new IllegalArgumentException("Range has to be lower/equal the maximum of 20");
|
||||
}
|
||||
sendPacket(getPlayersInRange(loc, range), createPacket(loc, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays an icon crack (item break) effect which is visible for all players whitin the maximum range of 20 blocks in the world of @param loc
|
||||
*/
|
||||
public static void displayIconCrack(Location loc, int id, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
displayIconCrack(loc, MAX_RANGE, id, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
/**
|
||||
* Displays an icon crack (item break) effect which is only visible for
|
||||
* specific players
|
||||
*/
|
||||
public static void displayIconCrack(Location loc, int id, float offsetX, float offsetY, float offsetZ, float speed, int amount, Player... players) {
|
||||
sendPacket(Arrays.asList(players), createIconCrackPacket(id, loc, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays an icon crack (item break) effect which is visible for all players whitin a certain range in the the world of @param loc
|
||||
*/
|
||||
public static void displayIconCrack(Location loc, double range, int id, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
if (range > MAX_RANGE)
|
||||
throw new IllegalArgumentException("Range has to be lower/equal the maximum of 20");
|
||||
sendPacket(getPlayersInRange(loc, range), createIconCrackPacket(id, loc, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
/**
|
||||
* Displays an icon crack (item break) effect which is visible for all
|
||||
* players whitin the maximum range of 20 blocks in the world of @param loc
|
||||
*/
|
||||
public static void displayIconCrack(Location loc, int id, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
displayIconCrack(loc, MAX_RANGE, id, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a block crack (block break) effect which is only visible for specific players
|
||||
*/
|
||||
public static void displayBlockCrack(Location loc, int id, byte data, float offsetX, float offsetY, float offsetZ, int amount, Player... players) {
|
||||
sendPacket(Arrays.asList(players), createBlockCrackPacket(id, data, loc, offsetX, offsetY, offsetZ, amount));
|
||||
}
|
||||
/**
|
||||
* Displays an icon crack (item break) effect which is visible for all
|
||||
* players whitin a certain range in the the world of @param loc
|
||||
*/
|
||||
public static void displayIconCrack(Location loc, double range, int id, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
if (range > MAX_RANGE) {
|
||||
throw new IllegalArgumentException("Range has to be lower/equal the maximum of 20");
|
||||
}
|
||||
sendPacket(getPlayersInRange(loc, range), createIconCrackPacket(id, loc, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a block crack (block break) effect which is visible for all players whitin the maximum range of 20 blocks in the world of @param loc
|
||||
*/
|
||||
public static void displayBlockCrack(Location loc, int id, byte data, float offsetX, float offsetY, float offsetZ, int amount) {
|
||||
displayBlockCrack(loc, MAX_RANGE, id, data, offsetX, offsetY, offsetZ, amount);
|
||||
}
|
||||
/**
|
||||
* Displays a block crack (block break) effect which is only visible for
|
||||
* specific players
|
||||
*/
|
||||
public static void displayBlockCrack(Location loc, int id, byte data, float offsetX, float offsetY, float offsetZ, int amount, Player... players) {
|
||||
sendPacket(Arrays.asList(players), createBlockCrackPacket(id, data, loc, offsetX, offsetY, offsetZ, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a block crack (block break) effect which is visible for all players whitin a certain range in the the world of @param loc
|
||||
*/
|
||||
public static void displayBlockCrack(Location loc, double range, int id, byte data, float offsetX, float offsetY, float offsetZ, int amount) {
|
||||
if (range > MAX_RANGE)
|
||||
throw new IllegalArgumentException("Range has to be lower/equal the maximum of 20");
|
||||
sendPacket(getPlayersInRange(loc, range), createBlockCrackPacket(id, data, loc, offsetX, offsetY, offsetZ, amount));
|
||||
}
|
||||
/**
|
||||
* Displays a block crack (block break) effect which is visible for all
|
||||
* players whitin the maximum range of 20 blocks in the world of @param loc
|
||||
*/
|
||||
public static void displayBlockCrack(Location loc, int id, byte data, float offsetX, float offsetY, float offsetZ, int amount) {
|
||||
displayBlockCrack(loc, MAX_RANGE, id, data, offsetX, offsetY, offsetZ, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a block dust effect which is only visible for specific players
|
||||
*/
|
||||
public static void displayBlockDust(Location loc, int id, byte data, float offsetX, float offsetY, float offsetZ, float speed, int amount, Player... players) {
|
||||
sendPacket(Arrays.asList(players), createBlockDustPacket(id, data, loc, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
/**
|
||||
* Displays a block crack (block break) effect which is visible for all
|
||||
* players whitin a certain range in the the world of @param loc
|
||||
*/
|
||||
public static void displayBlockCrack(Location loc, double range, int id, byte data, float offsetX, float offsetY, float offsetZ, int amount) {
|
||||
if (range > MAX_RANGE) {
|
||||
throw new IllegalArgumentException("Range has to be lower/equal the maximum of 20");
|
||||
}
|
||||
sendPacket(getPlayersInRange(loc, range), createBlockCrackPacket(id, data, loc, offsetX, offsetY, offsetZ, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a block dust effect which is visible for all players whitin the maximum range of 20 blocks in the world of @param loc
|
||||
*/
|
||||
public static void displayBlockDust(Location loc, int id, byte data, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
displayBlockDust(loc, MAX_RANGE, id, data, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
/**
|
||||
* Displays a block dust effect which is only visible for specific players
|
||||
*/
|
||||
public static void displayBlockDust(Location loc, int id, byte data, float offsetX, float offsetY, float offsetZ, float speed, int amount, Player... players) {
|
||||
sendPacket(Arrays.asList(players), createBlockDustPacket(id, data, loc, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a block dust effect which is visible for all players whitin a certain range in the the world of @param loc
|
||||
*/
|
||||
public static void displayBlockDust(Location loc, double range, int id, byte data, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
if (range > MAX_RANGE)
|
||||
throw new IllegalArgumentException("Range has to be lower/equal the maximum of 20");
|
||||
sendPacket(getPlayersInRange(loc, range), createBlockDustPacket(id, data, loc, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Displays a block dust effect which is visible for all players whitin the
|
||||
* maximum range of 20 blocks in the world of @param loc
|
||||
*/
|
||||
public static void displayBlockDust(Location loc, int id, byte data, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
displayBlockDust(loc, MAX_RANGE, id, data, offsetX, offsetY, offsetZ, speed, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a block dust effect which is visible for all players whitin a
|
||||
* certain range in the the world of @param loc
|
||||
*/
|
||||
public static void displayBlockDust(Location loc, double range, int id, byte data, float offsetX, float offsetY, float offsetZ, float speed, int amount) {
|
||||
if (range > MAX_RANGE) {
|
||||
throw new IllegalArgumentException("Range has to be lower/equal the maximum of 20");
|
||||
}
|
||||
sendPacket(getPlayersInRange(loc, range), createBlockDustPacket(id, data, loc, offsetX, offsetY, offsetZ, speed, amount));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
package de.anura.core;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
@@ -19,198 +18,190 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
|
||||
public final class Permissions implements Listener {
|
||||
|
||||
private final HashMap<Integer, String> groupNames = new HashMap<>();
|
||||
private final HashMap<Integer, ArrayList<String>> groupPerms = new HashMap<>();
|
||||
private final HashMap<UUID, ArrayList<Integer>> playerGroups = new HashMap<>();
|
||||
private final HashMap<Integer, Integer> groupParents = new HashMap<>();
|
||||
private final HashMap<Integer, String> groupPrefix = new HashMap<>();
|
||||
private final HashMap<Integer, String> groupSuffix = new HashMap<>();
|
||||
private final HashMap<Integer, String> groupListColor = new HashMap<>();
|
||||
private final HashMap<Player, PermissionAttachment> permAttachments = new HashMap<>();
|
||||
|
||||
private int groupAutoIncrement = 0;
|
||||
private final AnuraCore plugin;
|
||||
|
||||
public Permissions(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.reload();
|
||||
this.plugin = plugin;
|
||||
this.createPermAttachs();
|
||||
this.updateAllPlayers();
|
||||
}
|
||||
|
||||
//Event handlers
|
||||
@EventHandler
|
||||
public void playerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Player P = event.getPlayer();
|
||||
|
||||
private final HashMap<Integer, String> groupNames = new HashMap<>();
|
||||
private final HashMap<Integer, ArrayList<String>> groupPerms = new HashMap<>();
|
||||
private final HashMap<UUID, ArrayList<Integer>> playerGroups = new HashMap<>();
|
||||
private final HashMap<Integer, Integer> groupParents = new HashMap<>();
|
||||
private final HashMap<Integer, String> groupPrefix = new HashMap<>();
|
||||
private final HashMap<Integer, String> groupSuffix = new HashMap<>();
|
||||
private final HashMap<Integer, String> groupListColor = new HashMap<>();
|
||||
private final HashMap<Player, PermissionAttachment> permAttachments = new HashMap<>();
|
||||
|
||||
private int groupAutoIncrement = 0;
|
||||
private final AnuraCore plugin;
|
||||
|
||||
public Permissions(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.reload();
|
||||
this.plugin = plugin;
|
||||
this.createPermAttachs();
|
||||
this.updateAllPlayers();
|
||||
}
|
||||
|
||||
//Event handlers
|
||||
@EventHandler
|
||||
public void playerJoin(PlayerJoinEvent event) {
|
||||
Player P = event.getPlayer();
|
||||
this.permAttachments.put(P, P.addAttachment(this.plugin));
|
||||
this.updatePlayer(P);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerKick(PlayerKickEvent event) {
|
||||
Player P = event.getPlayer();
|
||||
if (this.permAttachments.get(P) == null) {
|
||||
return;
|
||||
}
|
||||
P.removeAttachment(this.permAttachments.get(P));
|
||||
this.permAttachments.remove(P);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event) {
|
||||
Player P = event.getPlayer();
|
||||
if (this.permAttachments.get(P) == null) {
|
||||
return;
|
||||
}
|
||||
P.removeAttachment(this.permAttachments.get(P));
|
||||
this.permAttachments.remove(P);
|
||||
}
|
||||
|
||||
//The permission stuff
|
||||
private void createPermAttachs() {
|
||||
for (Player P : Bukkit.getOnlinePlayers()) {
|
||||
this.permAttachments.put(P, P.addAttachment(this.plugin));
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAllPlayers() {
|
||||
for (Player P : Bukkit.getOnlinePlayers()) {
|
||||
this.updatePlayer(P);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerKick(PlayerKickEvent event)
|
||||
{
|
||||
Player P = event.getPlayer();
|
||||
if(this.permAttachments.get(P) == null) return;
|
||||
P.removeAttachment(this.permAttachments.get(P));
|
||||
this.permAttachments.remove(P);
|
||||
}
|
||||
|
||||
public void updatePlayer(Player P) {
|
||||
PermissionAttachment pa = this.permAttachments.get(P);
|
||||
for (String p : pa.getPermissions().keySet()) {
|
||||
pa.unsetPermission(p);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Player P = event.getPlayer();
|
||||
if(this.permAttachments.get(P) == null) return;
|
||||
P.removeAttachment(this.permAttachments.get(P));
|
||||
this.permAttachments.remove(P);
|
||||
if (!this.playerGroups.containsKey(P.getUniqueId())) {
|
||||
this.playerGroups.put(P.getUniqueId(), new ArrayList<Integer>());
|
||||
}
|
||||
|
||||
//The permission stuff
|
||||
private void createPermAttachs()
|
||||
{
|
||||
for(Player P : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
this.permAttachments.put(P, P.addAttachment(this.plugin));
|
||||
ArrayList<Integer> groups = this.playerGroups.get(P.getUniqueId());
|
||||
ArrayList<Integer> assignedGroups = new ArrayList<>();
|
||||
String prefixes = "";
|
||||
String suffixes = "";
|
||||
String listColor = "";
|
||||
for (Integer g : groups) {
|
||||
if (assignedGroups.contains(g)) {
|
||||
continue;
|
||||
}
|
||||
assignedGroups.add(g);
|
||||
for (String perm : this.groupPerms.get(g)) {
|
||||
pa.setPermission(perm, true);
|
||||
}
|
||||
ArrayList<String> perms = this.getParentPerms(g, assignedGroups);
|
||||
for (String perm : perms) {
|
||||
pa.setPermission(perm, true);
|
||||
}
|
||||
if (this.groupPrefix.containsKey(g)) {
|
||||
prefixes += this.groupPrefix.get(g);
|
||||
}
|
||||
if (this.groupSuffix.containsKey(g)) {
|
||||
suffixes += this.groupSuffix.get(g);
|
||||
}
|
||||
if (this.groupListColor.containsKey(g)) {
|
||||
listColor = this.groupListColor.get(g);
|
||||
}
|
||||
}
|
||||
public void updateAllPlayers()
|
||||
{
|
||||
for(Player P : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
this.updatePlayer(P);
|
||||
}
|
||||
}
|
||||
public void updatePlayer(Player P)
|
||||
{
|
||||
PermissionAttachment pa = this.permAttachments.get(P);
|
||||
for(String p : pa.getPermissions().keySet())
|
||||
{
|
||||
pa.unsetPermission(p);
|
||||
}
|
||||
if(!this.playerGroups.containsKey(P.getUniqueId()))
|
||||
{
|
||||
this.playerGroups.put(P.getUniqueId(), new ArrayList<Integer>());
|
||||
}
|
||||
ArrayList<Integer> groups = this.playerGroups.get(P.getUniqueId());
|
||||
ArrayList<Integer> assignedGroups = new ArrayList<>();
|
||||
String prefixes = "";
|
||||
String suffixes = "";
|
||||
String listColor = "";
|
||||
for(Integer g : groups)
|
||||
{
|
||||
if(assignedGroups.contains(g)) continue;
|
||||
assignedGroups.add(g);
|
||||
for(String perm : this.groupPerms.get(g))
|
||||
{
|
||||
pa.setPermission(perm, true);
|
||||
}
|
||||
ArrayList<String> perms = this.getParentPerms(g, assignedGroups);
|
||||
for(String perm : perms)
|
||||
{
|
||||
pa.setPermission(perm, true);
|
||||
}
|
||||
if(this.groupPrefix.containsKey(g)) prefixes += this.groupPrefix.get(g);
|
||||
if(this.groupSuffix.containsKey(g)) suffixes += this.groupSuffix.get(g);
|
||||
if(this.groupListColor.containsKey(g)) listColor = this.groupListColor.get(g);
|
||||
}
|
||||
String name = prefixes + P.getName() + suffixes;
|
||||
P.setDisplayName(name);
|
||||
P.setPlayerListName(listColor + P.getName());
|
||||
}
|
||||
private ArrayList<String> getParentPerms(Integer group, ArrayList<Integer> assigned)
|
||||
{
|
||||
ArrayList<String> toReturn = new ArrayList<>();
|
||||
if(this.groupParents.get(group) == -1)
|
||||
{
|
||||
return toReturn;
|
||||
}
|
||||
if(assigned.contains(this.groupParents.get(group)))
|
||||
{
|
||||
return toReturn;
|
||||
}
|
||||
for(String perm : this.groupPerms.get(this.groupParents.get(group)))
|
||||
{
|
||||
toReturn.add(perm);
|
||||
}
|
||||
for(String perm : this.getParentPerms(this.groupParents.get(group), assigned))
|
||||
{
|
||||
toReturn.add(perm);
|
||||
}
|
||||
String name = prefixes + P.getName() + suffixes;
|
||||
P.setDisplayName(name);
|
||||
P.setPlayerListName(listColor + P.getName());
|
||||
}
|
||||
|
||||
private ArrayList<String> getParentPerms(Integer group, ArrayList<Integer> assigned) {
|
||||
ArrayList<String> toReturn = new ArrayList<>();
|
||||
if (this.groupParents.get(group) == -1) {
|
||||
return toReturn;
|
||||
}
|
||||
public String reload()
|
||||
{
|
||||
ResultSet groupsRs = AnuraCore.sql.querySelect("SELECT prefix, suffix, parent, name, id, listColor FROM permGroups");
|
||||
ResultSet permsRs = AnuraCore.sql.querySelect("SELECT `group`, name FROM permPerms");
|
||||
ResultSet userRs = AnuraCore.sql.querySelect("SELECT playerUUID, `group` FROM permPlayerGroups");
|
||||
this.groupNames.clear();
|
||||
this.groupPerms.clear();
|
||||
this.playerGroups.clear();
|
||||
this.groupParents.clear();
|
||||
this.groupPrefix.clear();
|
||||
this.groupSuffix.clear();
|
||||
HashMap<Integer, Integer> groupIds = new HashMap<>();
|
||||
this.groupAutoIncrement = 0;
|
||||
try {
|
||||
groupsRs.last();
|
||||
if(groupsRs.getRow() != 0)
|
||||
{
|
||||
groupsRs.beforeFirst();
|
||||
while(groupsRs.next())
|
||||
{
|
||||
int id = this.groupAutoIncrement;
|
||||
this.groupNames.put(id, groupsRs.getString("name"));
|
||||
this.groupPerms.put(id, new ArrayList<String>());
|
||||
this.groupParents.put(id, groupsRs.getInt("parent"));
|
||||
if(groupsRs.getString("prefix") != null) this.groupPrefix.put(id, groupsRs.getString("prefix"));
|
||||
if(groupsRs.getString("suffix") != null) this.groupSuffix.put(id, groupsRs.getString("suffix"));
|
||||
if(groupsRs.getString("listColor") != null) this.groupListColor.put(id, groupsRs.getString("listColor"));
|
||||
groupIds.put(groupsRs.getInt("id"), id);
|
||||
this.groupAutoIncrement++;
|
||||
}
|
||||
}
|
||||
permsRs.last();
|
||||
if(permsRs.getRow() != 0)
|
||||
{
|
||||
permsRs.beforeFirst();
|
||||
while(permsRs.next())
|
||||
{
|
||||
int groupId = groupIds.get(permsRs.getInt("group"));
|
||||
if(this.groupNames.containsKey(groupId))
|
||||
{
|
||||
|
||||
this.groupPerms.get(groupId).add(permsRs.getString("name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
userRs.last();
|
||||
if(userRs.getRow() != 0)
|
||||
{
|
||||
userRs.beforeFirst();
|
||||
while(userRs.next())
|
||||
{
|
||||
int groupId = groupIds.get(userRs.getInt("group"));
|
||||
if(this.groupNames.containsKey(groupId))
|
||||
{
|
||||
ArrayList<Integer> groupList = this.playerGroups.get(UUID.fromString(userRs.getString("playerUUID")));
|
||||
if(groupList == null)
|
||||
{
|
||||
groupList = new ArrayList<>();
|
||||
}
|
||||
groupList.add(groupId);
|
||||
this.playerGroups.put(UUID.fromString(userRs.getString("playerUUID")), groupList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Was not able to load permissions. Sorry. ("+ex.getLocalizedMessage()+")");
|
||||
}
|
||||
return ChatColor.GREEN + "Permissions reloaded!";
|
||||
if (assigned.contains(this.groupParents.get(group))) {
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
for (String perm : this.groupPerms.get(this.groupParents.get(group))) {
|
||||
toReturn.add(perm);
|
||||
}
|
||||
for (String perm : this.getParentPerms(this.groupParents.get(group), assigned)) {
|
||||
toReturn.add(perm);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public String reload() {
|
||||
ResultSet groupsRs = AnuraCore.sql.querySelect("SELECT prefix, suffix, parent, name, id, listColor FROM permGroups");
|
||||
ResultSet permsRs = AnuraCore.sql.querySelect("SELECT `group`, name FROM permPerms");
|
||||
ResultSet userRs = AnuraCore.sql.querySelect("SELECT playerUUID, `group` FROM permPlayerGroups");
|
||||
this.groupNames.clear();
|
||||
this.groupPerms.clear();
|
||||
this.playerGroups.clear();
|
||||
this.groupParents.clear();
|
||||
this.groupPrefix.clear();
|
||||
this.groupSuffix.clear();
|
||||
HashMap<Integer, Integer> groupIds = new HashMap<>();
|
||||
this.groupAutoIncrement = 0;
|
||||
try {
|
||||
groupsRs.last();
|
||||
if (groupsRs.getRow() != 0) {
|
||||
groupsRs.beforeFirst();
|
||||
while (groupsRs.next()) {
|
||||
int id = this.groupAutoIncrement;
|
||||
this.groupNames.put(id, groupsRs.getString("name"));
|
||||
this.groupPerms.put(id, new ArrayList<String>());
|
||||
this.groupParents.put(id, groupsRs.getInt("parent"));
|
||||
if (groupsRs.getString("prefix") != null) {
|
||||
this.groupPrefix.put(id, groupsRs.getString("prefix"));
|
||||
}
|
||||
if (groupsRs.getString("suffix") != null) {
|
||||
this.groupSuffix.put(id, groupsRs.getString("suffix"));
|
||||
}
|
||||
if (groupsRs.getString("listColor") != null) {
|
||||
this.groupListColor.put(id, groupsRs.getString("listColor"));
|
||||
}
|
||||
groupIds.put(groupsRs.getInt("id"), id);
|
||||
this.groupAutoIncrement++;
|
||||
}
|
||||
}
|
||||
permsRs.last();
|
||||
if (permsRs.getRow() != 0) {
|
||||
permsRs.beforeFirst();
|
||||
while (permsRs.next()) {
|
||||
int groupId = groupIds.get(permsRs.getInt("group"));
|
||||
if (this.groupNames.containsKey(groupId)) {
|
||||
|
||||
this.groupPerms.get(groupId).add(permsRs.getString("name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
userRs.last();
|
||||
if (userRs.getRow() != 0) {
|
||||
userRs.beforeFirst();
|
||||
while (userRs.next()) {
|
||||
int groupId = groupIds.get(userRs.getInt("group"));
|
||||
if (this.groupNames.containsKey(groupId)) {
|
||||
ArrayList<Integer> groupList = this.playerGroups.get(UUID.fromString(userRs.getString("playerUUID")));
|
||||
if (groupList == null) {
|
||||
groupList = new ArrayList<>();
|
||||
}
|
||||
groupList.add(groupId);
|
||||
this.playerGroups.put(UUID.fromString(userRs.getString("playerUUID")), groupList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Was not able to load permissions. Sorry. (" + ex.getLocalizedMessage() + ")");
|
||||
}
|
||||
return ChatColor.GREEN + "Permissions reloaded!";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class RealTime {
|
||||
|
||||
|
||||
public static void setup() {
|
||||
if (Core.getMainClass().getConfig().getBoolean("realtime-day")) {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
@@ -26,7 +26,7 @@ public class RealTime {
|
||||
}, 0, (20 * 60 * 10));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Integer[] getSystemTime() {
|
||||
Date date = new Date();
|
||||
Calendar calendar = GregorianCalendar.getInstance();
|
||||
|
||||
@@ -10,149 +10,161 @@ import org.bukkit.Bukkit;
|
||||
|
||||
/**
|
||||
* ReflectionUtil v1.1
|
||||
*
|
||||
* You are welcome to use it, modify it and redistribute it under the condition to not claim this class as your own
|
||||
*
|
||||
*
|
||||
* You are welcome to use it, modify it and redistribute it under the condition
|
||||
* to not claim this class as your own
|
||||
*
|
||||
* @author DarkBlade12
|
||||
*/
|
||||
public abstract class ReflectionUtil {
|
||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
||||
|
||||
static {
|
||||
CORRESPONDING_TYPES.put(Byte.class, byte.class);
|
||||
CORRESPONDING_TYPES.put(Short.class, short.class);
|
||||
CORRESPONDING_TYPES.put(Integer.class, int.class);
|
||||
CORRESPONDING_TYPES.put(Long.class, long.class);
|
||||
CORRESPONDING_TYPES.put(Character.class, char.class);
|
||||
CORRESPONDING_TYPES.put(Float.class, float.class);
|
||||
CORRESPONDING_TYPES.put(Double.class, double.class);
|
||||
CORRESPONDING_TYPES.put(Boolean.class, boolean.class);
|
||||
}
|
||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
||||
|
||||
public enum DynamicPackage {
|
||||
MINECRAFT_SERVER {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "net.minecraft.server." + Bukkit.getServer().getClass().getPackage().getName().substring(23, 30);
|
||||
}
|
||||
},
|
||||
CRAFTBUKKIT {
|
||||
@Override
|
||||
public String toString() {
|
||||
return Bukkit.getServer().getClass().getPackage().getName();
|
||||
}
|
||||
};
|
||||
}
|
||||
static {
|
||||
CORRESPONDING_TYPES.put(Byte.class, byte.class);
|
||||
CORRESPONDING_TYPES.put(Short.class, short.class);
|
||||
CORRESPONDING_TYPES.put(Integer.class, int.class);
|
||||
CORRESPONDING_TYPES.put(Long.class, long.class);
|
||||
CORRESPONDING_TYPES.put(Character.class, char.class);
|
||||
CORRESPONDING_TYPES.put(Float.class, float.class);
|
||||
CORRESPONDING_TYPES.put(Double.class, double.class);
|
||||
CORRESPONDING_TYPES.put(Boolean.class, boolean.class);
|
||||
}
|
||||
|
||||
public static class FieldEntry {
|
||||
String key;
|
||||
Object value;
|
||||
public enum DynamicPackage {
|
||||
|
||||
public FieldEntry(String key, Object value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
MINECRAFT_SERVER {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "net.minecraft.server." + Bukkit.getServer().getClass().getPackage().getName().substring(23, 30);
|
||||
}
|
||||
},
|
||||
CRAFTBUKKIT {
|
||||
@Override
|
||||
public String toString() {
|
||||
return Bukkit.getServer().getClass().getPackage().getName();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
public static class FieldEntry {
|
||||
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
String key;
|
||||
Object value;
|
||||
|
||||
private static Class<?> getPrimitiveType(Class<?> clazz) {
|
||||
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz;
|
||||
}
|
||||
public FieldEntry(String key, Object value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private static Class<?>[] toPrimitiveTypeArray(Object[] objects) {
|
||||
int a = objects != null ? objects.length : 0;
|
||||
Class<?>[] types = new Class<?>[a];
|
||||
for (int i = 0; i < a; i++)
|
||||
types[i] = getPrimitiveType(objects[i].getClass());
|
||||
return types;
|
||||
}
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
private static Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
||||
int a = classes != null ? classes.length : 0;
|
||||
Class<?>[] types = new Class<?>[a];
|
||||
for (int i = 0; i < a; i++)
|
||||
types[i] = getPrimitiveType(classes[i]);
|
||||
return types;
|
||||
}
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
if (a.length != o.length)
|
||||
return false;
|
||||
for (int i = 0; i < a.length; i++)
|
||||
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
private static Class<?> getPrimitiveType(Class<?> clazz) {
|
||||
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz;
|
||||
}
|
||||
|
||||
public static Class<?> getClass(String name, DynamicPackage pack, String subPackage) throws Exception {
|
||||
return Class.forName(pack + (subPackage != null && subPackage.length() > 0 ? "." + subPackage : "") + "." + name);
|
||||
}
|
||||
private static Class<?>[] toPrimitiveTypeArray(Object[] objects) {
|
||||
int a = objects != null ? objects.length : 0;
|
||||
Class<?>[] types = new Class<?>[a];
|
||||
for (int i = 0; i < a; i++) {
|
||||
types[i] = getPrimitiveType(objects[i].getClass());
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
public static Class<?> getClass(String name, DynamicPackage pack) throws Exception {
|
||||
return getClass(name, pack, null);
|
||||
}
|
||||
private static Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
||||
int a = classes != null ? classes.length : 0;
|
||||
Class<?>[] types = new Class<?>[a];
|
||||
for (int i = 0; i < a; i++) {
|
||||
types[i] = getPrimitiveType(classes[i]);
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
public static Constructor<?> getConstructor(Class<?> clazz, Class<?>... paramTypes) {
|
||||
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
|
||||
for (Constructor<?> c : clazz.getConstructors()) {
|
||||
Class<?>[] types = toPrimitiveTypeArray(c.getParameterTypes());
|
||||
if (equalsTypeArray(types, t))
|
||||
return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
if (a.length != o.length) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Object newInstance(Class<?> clazz, Object... args) throws Exception {
|
||||
return getConstructor(clazz, toPrimitiveTypeArray(args)).newInstance(args);
|
||||
}
|
||||
public static Class<?> getClass(String name, DynamicPackage pack, String subPackage) throws Exception {
|
||||
return Class.forName(pack + (subPackage != null && subPackage.length() > 0 ? "." + subPackage : "") + "." + name);
|
||||
}
|
||||
|
||||
public static Object newInstance(String name, DynamicPackage pack, String subPackage, Object... args) throws Exception {
|
||||
return newInstance(getClass(name, pack, subPackage), args);
|
||||
}
|
||||
public static Class<?> getClass(String name, DynamicPackage pack) throws Exception {
|
||||
return getClass(name, pack, null);
|
||||
}
|
||||
|
||||
public static Object newInstance(String name, DynamicPackage pack, Object... args) throws Exception {
|
||||
return newInstance(getClass(name, pack, null), args);
|
||||
}
|
||||
public static Constructor<?> getConstructor(Class<?> clazz, Class<?>... paramTypes) {
|
||||
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
|
||||
for (Constructor<?> c : clazz.getConstructors()) {
|
||||
Class<?>[] types = toPrimitiveTypeArray(c.getParameterTypes());
|
||||
if (equalsTypeArray(types, t)) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Method getMethod(String name, Class<?> clazz, Class<?>... paramTypes) {
|
||||
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
|
||||
for (Method m : clazz.getMethods()) {
|
||||
Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes());
|
||||
if (m.getName().equals(name) && equalsTypeArray(types, t))
|
||||
return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static Object newInstance(Class<?> clazz, Object... args) throws Exception {
|
||||
return getConstructor(clazz, toPrimitiveTypeArray(args)).newInstance(args);
|
||||
}
|
||||
|
||||
public static Object invokeMethod(String name, Class<?> clazz, Object obj, Object... args) throws Exception {
|
||||
return getMethod(name, clazz, toPrimitiveTypeArray(args)).invoke(obj, args);
|
||||
}
|
||||
public static Object newInstance(String name, DynamicPackage pack, String subPackage, Object... args) throws Exception {
|
||||
return newInstance(getClass(name, pack, subPackage), args);
|
||||
}
|
||||
|
||||
public static Field getField(String name, Class<?> clazz) throws Exception {
|
||||
return clazz.getDeclaredField(name);
|
||||
}
|
||||
public static Object newInstance(String name, DynamicPackage pack, Object... args) throws Exception {
|
||||
return newInstance(getClass(name, pack, null), args);
|
||||
}
|
||||
|
||||
public static Object getValue(String name, Object obj) throws Exception {
|
||||
Field f = getField(name, obj.getClass());
|
||||
f.setAccessible(true);
|
||||
return f.get(obj);
|
||||
}
|
||||
public static Method getMethod(String name, Class<?> clazz, Class<?>... paramTypes) {
|
||||
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
|
||||
for (Method m : clazz.getMethods()) {
|
||||
Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes());
|
||||
if (m.getName().equals(name) && equalsTypeArray(types, t)) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setValue(Object obj, FieldEntry entry) throws Exception {
|
||||
Field f = getField(entry.getKey(), obj.getClass());
|
||||
f.setAccessible(true);
|
||||
f.set(obj, entry.getValue());
|
||||
}
|
||||
public static Object invokeMethod(String name, Class<?> clazz, Object obj, Object... args) throws Exception {
|
||||
return getMethod(name, clazz, toPrimitiveTypeArray(args)).invoke(obj, args);
|
||||
}
|
||||
|
||||
public static void setValues(Object obj, FieldEntry... entrys) throws Exception {
|
||||
for (FieldEntry f : entrys)
|
||||
setValue(obj, f);
|
||||
}
|
||||
}
|
||||
public static Field getField(String name, Class<?> clazz) throws Exception {
|
||||
return clazz.getDeclaredField(name);
|
||||
}
|
||||
|
||||
public static Object getValue(String name, Object obj) throws Exception {
|
||||
Field f = getField(name, obj.getClass());
|
||||
f.setAccessible(true);
|
||||
return f.get(obj);
|
||||
}
|
||||
|
||||
public static void setValue(Object obj, FieldEntry entry) throws Exception {
|
||||
Field f = getField(entry.getKey(), obj.getClass());
|
||||
f.setAccessible(true);
|
||||
f.set(obj, entry.getValue());
|
||||
}
|
||||
|
||||
public static void setValues(Object obj, FieldEntry... entrys) throws Exception {
|
||||
for (FieldEntry f : entrys) {
|
||||
setValue(obj, f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,11 +42,10 @@ import org.bukkit.material.Stairs;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Setup {
|
||||
|
||||
|
||||
|
||||
public static void setupConfig() {
|
||||
Core.getMainClass().getConfig().addDefault("no-damage", false);
|
||||
Core.getMainClass().getConfig().addDefault("no-void-death",false);
|
||||
Core.getMainClass().getConfig().addDefault("no-void-death", false);
|
||||
Core.getMainClass().getConfig().addDefault("no-change-blocks", false);
|
||||
Core.getMainClass().getConfig().addDefault("is-main-lobby", false);
|
||||
Core.getMainClass().getConfig().addDefault("no-hunger", false);
|
||||
@@ -61,7 +60,7 @@ public class Setup {
|
||||
Core.getMainClass().getConfig().options().copyDefaults(true);
|
||||
Core.getMainClass().getConfig().options().header("Config File of the Anura Core-Plugin:");
|
||||
}
|
||||
|
||||
|
||||
public static void setupEvents() {
|
||||
new PlayerJoin(Core.getMainClass());
|
||||
new PlayerMove(Core.getMainClass());
|
||||
@@ -84,7 +83,7 @@ public class Setup {
|
||||
new InvClick(Core.getMainClass());
|
||||
new BlockSpread(Core.getMainClass());
|
||||
}
|
||||
|
||||
|
||||
public static void setupClasses() {
|
||||
Core.getMainClass().lang = new LanguageSupport(Core.getMainClass());
|
||||
new Inventories(Core.getMainClass());
|
||||
@@ -95,14 +94,14 @@ public class Setup {
|
||||
RealTime.setup();
|
||||
ResultSet rs = sql.querySelect("SELECT id, X, Y, Z, world, type, waitTime FROM corePots");
|
||||
try {
|
||||
while(rs.next())
|
||||
{
|
||||
while (rs.next()) {
|
||||
World w = Bukkit.getWorld(rs.getString("world"));
|
||||
if(w == null) continue;
|
||||
if (w == null) {
|
||||
continue;
|
||||
}
|
||||
Location l = new Location(w, rs.getInt("X"), rs.getInt("Y"), rs.getInt("Z"));
|
||||
Core.getMainClass().flowerPots.put(rs.getInt("id"), l);
|
||||
if (rs.getBoolean("type"))
|
||||
{
|
||||
if (rs.getBoolean("type")) {
|
||||
Core.getMainClass().flowerPotsWait.put(rs.getInt("id"), rs.getInt("waitTime"));
|
||||
}
|
||||
l.getBlock().setType(Material.BROWN_MUSHROOM);
|
||||
@@ -113,45 +112,40 @@ public class Setup {
|
||||
Core.getMainClass().features = new Features();
|
||||
Core.getMainClass().features.updateFeaturesAll();
|
||||
}
|
||||
|
||||
|
||||
public static void setupTasks() {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Core.getMainClass(), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for(Player P : Core.getMainClass().golfPower.keySet())
|
||||
{
|
||||
if(Core.getMainClass().releaseGolf.get(P))
|
||||
{
|
||||
for (Player P : Core.getMainClass().golfPower.keySet()) {
|
||||
if (Core.getMainClass().releaseGolf.get(P)) {
|
||||
P.setExp(0);
|
||||
int power = Core.getMainClass().golfPower.get(P);
|
||||
Entity i = Core.getMainClass().golfBall.get(P);
|
||||
if(i != null && i.isValid())
|
||||
{
|
||||
if (i != null && i.isValid()) {
|
||||
Vector v = P.getLocation().getDirection();
|
||||
v.multiply(new Vector(power / 10 + 1,1.2,power / 10 + 1));
|
||||
v.multiply(new Vector(power / 10 + 1, 1.2, power / 10 + 1));
|
||||
i.setVelocity(v);
|
||||
}
|
||||
Core.getMainClass().golfPower.remove(P);
|
||||
Core.getMainClass().releaseGolf.remove(P);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Core.getMainClass().releaseGolf.put(P, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}, 5, 5);
|
||||
ResultSet rs = sql.querySelect("SELECT world, X, Y, Z FROM coreStairs WHERE server = '"+Core.getMainClass().getConfig().getString("server-name")+"'");
|
||||
ResultSet rs = sql.querySelect("SELECT world, X, Y, Z FROM coreStairs WHERE server = '" + Core.getMainClass().getConfig().getString("server-name") + "'");
|
||||
try {
|
||||
while(rs.next())
|
||||
{
|
||||
while (rs.next()) {
|
||||
World w = Bukkit.getWorld(rs.getString("world"));
|
||||
if(w == null) continue;
|
||||
if (w == null) {
|
||||
continue;
|
||||
}
|
||||
Location l = new Location(w, rs.getInt("X"), rs.getInt("Y"), rs.getInt("Z"));
|
||||
if(l.getBlock().getState().getData() instanceof Stairs)
|
||||
{
|
||||
if (l.getBlock().getState().getData() instanceof Stairs) {
|
||||
Core.getMainClass().sittableBlocks.add(l.getBlock());
|
||||
}
|
||||
}
|
||||
@@ -163,10 +157,9 @@ public class Setup {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for(Player p : AnuraCore.getInstance().sittingPlayer.keySet())
|
||||
{
|
||||
for (Player p : AnuraCore.getInstance().sittingPlayer.keySet()) {
|
||||
Location loc = AnuraCore.getInstance().sittingPlayer.get(p).getLocation();
|
||||
Arrow a = loc.getWorld().spawnArrow(loc, new Vector(0,0,0), 0, 0);
|
||||
Arrow a = loc.getWorld().spawnArrow(loc, new Vector(0, 0, 0), 0, 0);
|
||||
a.setPassenger(p);
|
||||
AnuraCore.getInstance().sittingPlayer.get(p).remove();
|
||||
AnuraCore.getInstance().sittingPlayer.put(p, a);
|
||||
@@ -179,15 +172,15 @@ public class Setup {
|
||||
public void run() {
|
||||
AnuraCore.getInstance().signs.updateServerSigns();
|
||||
}
|
||||
}, 20*5, 20*5);
|
||||
}, 20 * 5, 20 * 5);
|
||||
}
|
||||
|
||||
|
||||
public static void setupCommands() {
|
||||
TeamCommands tc = new TeamCommands();
|
||||
AdminCommands ac = new AdminCommands();
|
||||
PlayerCommands pc = new PlayerCommands();
|
||||
OtherCommands oc = new OtherCommands();
|
||||
|
||||
|
||||
Core.getMainClass().getCommand("setjumper").setExecutor(tc);
|
||||
Core.getMainClass().getCommand("setspawn").setExecutor(ac);
|
||||
Core.getMainClass().getCommand("spawn").setExecutor(pc);
|
||||
@@ -215,7 +208,7 @@ public class Setup {
|
||||
Core.getMainClass().getCommand("leaveminigame").setExecutor(pc);
|
||||
Core.getMainClass().getCommand("toggleminigame").setExecutor(pc);
|
||||
}
|
||||
|
||||
|
||||
public static void setupInventories() {
|
||||
Inventories.registerInventory("GAMEMODES", "select_gamemode_inv", ChatColor.DARK_BLUE);
|
||||
Inventories.putIntoInventory("GAMEMODES", 0, Inventories.buildItems(Material.RED_ROSE, "inv_lobby_tps", ChatColor.DARK_GREEN));
|
||||
@@ -258,8 +251,7 @@ public class Setup {
|
||||
|
||||
Inventories.registerInventory("LANGUAGE", "Select language", ChatColor.DARK_BLUE);
|
||||
int i = 0;
|
||||
for(String langu : Core.getMainClass().lang.languages.keySet())
|
||||
{
|
||||
for (String langu : Core.getMainClass().lang.languages.keySet()) {
|
||||
Inventories.putIntoInventory("LANGUAGE", i, Inventories.buildItems(Material.BOOK_AND_QUILL, Core.getMainClass().lang.languages.get(langu), ChatColor.DARK_GREEN, ChatColor.GOLD, "set_lang_to", Core.getMainClass().lang.languages.get(langu)));
|
||||
Inventories.registerAction("LANGUAGE", i, Inventories.Action.LANGUAGE, langu);
|
||||
i++;
|
||||
|
||||
@@ -19,68 +19,69 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
public class Signs implements PluginMessageListener {
|
||||
|
||||
public void updateServerSigns()
|
||||
{
|
||||
if(Bukkit.getOnlinePlayers().length == 0) return;
|
||||
ResultSet rs = sql.querySelect("SELECT DISTINCT value FROM coreWarpSigns WHERE type = 'server' AND server = '"+Core.getMainClass().getConfig().getString("server-name")+"'");
|
||||
|
||||
public void updateServerSigns() {
|
||||
if (Bukkit.getOnlinePlayers().length == 0) {
|
||||
return;
|
||||
}
|
||||
ResultSet rs = sql.querySelect("SELECT DISTINCT value FROM coreWarpSigns WHERE type = 'server' AND server = '" + Core.getMainClass().getConfig().getString("server-name") + "'");
|
||||
try {
|
||||
rs.last();
|
||||
if(rs.getRow() == 0) return;
|
||||
if (rs.getRow() == 0) {
|
||||
return;
|
||||
}
|
||||
rs.beforeFirst();
|
||||
while(rs.next())
|
||||
{
|
||||
while (rs.next()) {
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
out.writeUTF("PlayerCount");
|
||||
out.writeUTF(rs.getString("value"));
|
||||
Bukkit.getOnlinePlayers()[0].sendPluginMessage(Core.getMainClass(), "BungeeCord", b.toByteArray());
|
||||
ResultSet rs2 = sql.querySelect("SELECT maxPlayers FROM coreServers WHERE name = LOWER('"+rs.getString("value")+"')");
|
||||
ResultSet rs2 = sql.querySelect("SELECT maxPlayers FROM coreServers WHERE name = LOWER('" + rs.getString("value") + "')");
|
||||
rs2.last();
|
||||
Boolean online = true;
|
||||
int maxPlayers = 0;
|
||||
if(rs2.getRow() == 0) {
|
||||
if (rs2.getRow() == 0) {
|
||||
online = false;
|
||||
}
|
||||
else {
|
||||
rs2.first();
|
||||
} else {
|
||||
rs2.first();
|
||||
maxPlayers = rs2.getInt("maxPlayers");
|
||||
}
|
||||
|
||||
rs2 = sql.querySelect("SELECT X,Y,Z,world,info FROM coreWarpSigns WHERE type = 'server' AND server = '"+Core.getMainClass().getConfig().getString("server-name")+"' AND value = '"+rs.getString("value")+"'");
|
||||
}
|
||||
|
||||
rs2 = sql.querySelect("SELECT X,Y,Z,world,info FROM coreWarpSigns WHERE type = 'server' AND server = '" + Core.getMainClass().getConfig().getString("server-name") + "' AND value = '" + rs.getString("value") + "'");
|
||||
rs2.last();
|
||||
if(rs2.getRow() == 0) continue;
|
||||
if (rs2.getRow() == 0) {
|
||||
continue;
|
||||
}
|
||||
rs2.beforeFirst();
|
||||
while(rs2.next())
|
||||
{
|
||||
while (rs2.next()) {
|
||||
Boolean remove = false;
|
||||
World w = Bukkit.getWorld(rs2.getString("world"));
|
||||
BlockState bs = null;
|
||||
if(w == null) remove = true;
|
||||
else
|
||||
{
|
||||
if (w == null) {
|
||||
remove = true;
|
||||
} else {
|
||||
Block bl = w.getBlockAt(rs2.getInt("X"), rs2.getInt("Y"), rs2.getInt("Z"));
|
||||
if(bl== null || !(bl.getState() instanceof Sign)) remove = true;
|
||||
else
|
||||
{
|
||||
if (bl == null || !(bl.getState() instanceof Sign)) {
|
||||
remove = true;
|
||||
} else {
|
||||
bs = bl.getState();
|
||||
}
|
||||
}
|
||||
if(remove)
|
||||
{
|
||||
String anotherSQL = "DELETE FROM coreWarpSigns WHERE server = '"+Core.getMainClass().getConfig().getString("server-name")+"' AND type = 'server' AND value = '"+rs.getString("value")+"'";
|
||||
if (remove) {
|
||||
String anotherSQL = "DELETE FROM coreWarpSigns WHERE server = '" + Core.getMainClass().getConfig().getString("server-name") + "' AND type = 'server' AND value = '" + rs.getString("value") + "'";
|
||||
sql.queryUpdate(anotherSQL);
|
||||
continue;
|
||||
}
|
||||
if(bs == null) continue;
|
||||
Sign s = (Sign)bs;
|
||||
if (bs == null) {
|
||||
continue;
|
||||
}
|
||||
Sign s = (Sign) bs;
|
||||
String rest = s.getLine(1).substring(0, s.getLine(1).length() - 2);
|
||||
String info = rs2.getString("info");
|
||||
if(s.getLocation().getWorld().isChunkLoaded(s.getLocation().getBlockX()/16,s.getLocation().getBlockZ()/16))
|
||||
{
|
||||
if(!online)
|
||||
{
|
||||
s.setLine(1, ChatColor.RED + "--"+ChatColor.DARK_GRAY+"/"+ChatColor.RED + "--");
|
||||
if (s.getLocation().getWorld().isChunkLoaded(s.getLocation().getBlockX() / 16, s.getLocation().getBlockZ() / 16)) {
|
||||
if (!online) {
|
||||
s.setLine(1, ChatColor.RED + "--" + ChatColor.DARK_GRAY + "/" + ChatColor.RED + "--");
|
||||
s.setLine(3, ChatColor.RED + "Offline");
|
||||
s.update();
|
||||
continue;
|
||||
@@ -92,11 +93,11 @@ public class Signs implements PluginMessageListener {
|
||||
}
|
||||
}
|
||||
} catch (SQLException | IOException ex) {
|
||||
System.err.println("Exception in updateServerSigns()(Core): "+ex.getLocalizedMessage());
|
||||
System.err.println("Exception in updateServerSigns()(Core): " + ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
if (!channel.equals("BungeeCord")) {
|
||||
@@ -107,68 +108,65 @@ public class Signs implements PluginMessageListener {
|
||||
|
||||
try {
|
||||
String subchannel = in.readUTF();
|
||||
if(subchannel.equals("PlayerCount"))
|
||||
{
|
||||
String server = in.readUTF();
|
||||
if (subchannel.equals("PlayerCount")) {
|
||||
String server = in.readUTF();
|
||||
int playercount = in.readInt();
|
||||
String sqlQ = "SELECT X,Y,Z,world FROM coreWarpSigns WHERE server = '"+Core.getMainClass().getConfig().getString("server-name")+"' AND type = 'server' AND value = '"+server+"'";
|
||||
String sqlQ = "SELECT X,Y,Z,world FROM coreWarpSigns WHERE server = '" + Core.getMainClass().getConfig().getString("server-name") + "' AND type = 'server' AND value = '" + server + "'";
|
||||
ResultSet rs = sql.querySelect(sqlQ);
|
||||
rs.last();
|
||||
if(rs.getRow() == 0) return;
|
||||
if (rs.getRow() == 0) {
|
||||
return;
|
||||
}
|
||||
rs.beforeFirst();
|
||||
while(rs.next())
|
||||
{
|
||||
Boolean remove = false;
|
||||
World w = Bukkit.getWorld(rs.getString("world"));
|
||||
BlockState bs = null;
|
||||
if(w == null) remove = true;
|
||||
else
|
||||
{
|
||||
Block b = w.getBlockAt(rs.getInt("X"), rs.getInt("Y"), rs.getInt("Z"));
|
||||
if(b == null || !(b.getState() instanceof Sign)) remove = true;
|
||||
else
|
||||
{
|
||||
bs = b.getState();
|
||||
}
|
||||
}
|
||||
if(remove)
|
||||
{
|
||||
String anotherSQL = "DELETE FROM coreWarpSigns WHERE server = '"+Core.getMainClass().getConfig().getString("server-name")+"' AND type = 'server' AND value = '"+server+"'";
|
||||
sql.queryUpdate(anotherSQL);
|
||||
continue;
|
||||
}
|
||||
if(bs == null) continue;
|
||||
if(bs instanceof Sign)
|
||||
{
|
||||
Sign s = (Sign)bs;
|
||||
if(s.getLine(3).equalsIgnoreCase(ChatColor.RED + "Offline"))
|
||||
{
|
||||
s.setLine(1, ChatColor.RED + "--"+ChatColor.DARK_GRAY+"/"+ChatColor.RED+"--");
|
||||
while (rs.next()) {
|
||||
Boolean remove = false;
|
||||
World w = Bukkit.getWorld(rs.getString("world"));
|
||||
BlockState bs = null;
|
||||
if (w == null) {
|
||||
remove = true;
|
||||
} else {
|
||||
Block b = w.getBlockAt(rs.getInt("X"), rs.getInt("Y"), rs.getInt("Z"));
|
||||
if (b == null || !(b.getState() instanceof Sign)) {
|
||||
remove = true;
|
||||
} else {
|
||||
bs = b.getState();
|
||||
}
|
||||
}
|
||||
if (remove) {
|
||||
String anotherSQL = "DELETE FROM coreWarpSigns WHERE server = '" + Core.getMainClass().getConfig().getString("server-name") + "' AND type = 'server' AND value = '" + server + "'";
|
||||
sql.queryUpdate(anotherSQL);
|
||||
continue;
|
||||
}
|
||||
String maxplayers = s.getLine(1).substring(s.getLine(1).length()-2);
|
||||
Boolean hasPlace = true;
|
||||
if(maxplayers.equals("--")) hasPlace = true;
|
||||
else if(Integer.parseInt(maxplayers) == playercount) hasPlace = false;
|
||||
if(hasPlace)
|
||||
{
|
||||
s.setLine(1, ChatColor.GREEN + String.valueOf(playercount) + ChatColor.DARK_GRAY + "/" + ChatColor.GREEN+ maxplayers);
|
||||
if (bs == null) {
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.setLine(1, ChatColor.RED + String.valueOf(playercount) + ChatColor.DARK_GRAY + "/" + ChatColor.GREEN+ maxplayers);
|
||||
if (bs instanceof Sign) {
|
||||
Sign s = (Sign) bs;
|
||||
if (s.getLine(3).equalsIgnoreCase(ChatColor.RED + "Offline")) {
|
||||
s.setLine(1, ChatColor.RED + "--" + ChatColor.DARK_GRAY + "/" + ChatColor.RED + "--");
|
||||
continue;
|
||||
}
|
||||
String maxplayers = s.getLine(1).substring(s.getLine(1).length() - 2);
|
||||
Boolean hasPlace = true;
|
||||
if (maxplayers.equals("--")) {
|
||||
hasPlace = true;
|
||||
} else if (Integer.parseInt(maxplayers) == playercount) {
|
||||
hasPlace = false;
|
||||
}
|
||||
if (hasPlace) {
|
||||
s.setLine(1, ChatColor.GREEN + String.valueOf(playercount) + ChatColor.DARK_GRAY + "/" + ChatColor.GREEN + maxplayers);
|
||||
} else {
|
||||
s.setLine(1, ChatColor.RED + String.valueOf(playercount) + ChatColor.DARK_GRAY + "/" + ChatColor.GREEN + maxplayers);
|
||||
}
|
||||
s.update();
|
||||
}
|
||||
s.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(subchannel.equals("updatePermissions"))
|
||||
{
|
||||
} else if (subchannel.equals("updatePermissions")) {
|
||||
Core.getMainClass().perms.reload();
|
||||
Core.getMainClass().perms.updateAllPlayers();
|
||||
}
|
||||
} catch (IOException | SQLException ex) {
|
||||
System.err.println("Exception in updateServerSigns()(Core): "+ex.getLocalizedMessage());
|
||||
System.err.println("Exception in updateServerSigns()(Core): " + ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,82 +18,66 @@ public class AdminCommands implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
Player P = null;
|
||||
if(sender instanceof Player)
|
||||
{
|
||||
P = (Player)sender;
|
||||
if (sender instanceof Player) {
|
||||
P = (Player) sender;
|
||||
}
|
||||
if(cmd.getName().equalsIgnoreCase("clearArrows"))
|
||||
{
|
||||
if(P == null)
|
||||
{
|
||||
Core.statusMsg(sender,"only_player_cmd",false);
|
||||
if (cmd.getName().equalsIgnoreCase("clearArrows")) {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if(!sender.hasPermission("core.commands.cleararrows"))
|
||||
{
|
||||
Core.statusMsg(sender,"no_perms",false);
|
||||
if (!sender.hasPermission("core.commands.cleararrows")) {
|
||||
Core.statusMsg(sender, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
for(Player pl : Core.getMainClass().sittingPlayer.keySet())
|
||||
{
|
||||
for (Player pl : Core.getMainClass().sittingPlayer.keySet()) {
|
||||
Core.endSitting(pl);
|
||||
}
|
||||
for(Arrow a : P.getWorld().getEntitiesByClass(Arrow.class))
|
||||
{
|
||||
for (Arrow a : P.getWorld().getEntitiesByClass(Arrow.class)) {
|
||||
a.remove();
|
||||
}
|
||||
Core.getTools().sendStatusMsg(sender, "Done!", true);
|
||||
return true;
|
||||
} else if(cmd.getName().equalsIgnoreCase("core"))
|
||||
{
|
||||
if(!sender.hasPermission("core.commands.core"))
|
||||
{
|
||||
Core.statusMsg(sender,"no_perms",false);
|
||||
} else if (cmd.getName().equalsIgnoreCase("core")) {
|
||||
if (!sender.hasPermission("core.commands.core")) {
|
||||
Core.statusMsg(sender, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
if(args.length != 1)
|
||||
{
|
||||
Core.statusMsg(sender,"wrong_args_count",false);
|
||||
if (args.length != 1) {
|
||||
Core.statusMsg(sender, "wrong_args_count", false);
|
||||
return false;
|
||||
}
|
||||
if((args[0].equalsIgnoreCase("reload") || args[0].equalsIgnoreCase("rl")) && sender.isOp())
|
||||
{
|
||||
if ((args[0].equalsIgnoreCase("reload") || args[0].equalsIgnoreCase("rl")) && sender.isOp()) {
|
||||
try {
|
||||
Core.getMainClass().getConfig().load(new File("plugins/Core/","config.yml"));
|
||||
Core.getMainClass().getConfig().load(new File("plugins/Core/", "config.yml"));
|
||||
Core.getMainClass().lang = new LanguageSupport(Core.getMainClass());
|
||||
Core.statusMsg(sender,"config_rl_done",true);
|
||||
Core.statusMsg(sender, "config_rl_done", true);
|
||||
} catch (IOException ex) {
|
||||
Core.statusMsg(sender,"config_rl_error_io",false);
|
||||
Core.statusMsg(sender, "config_rl_error_io", false);
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
Core.statusMsg(sender,"config_rl_invalid",false);
|
||||
Core.statusMsg(sender, "config_rl_invalid", false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("save") && sender.isOp())
|
||||
{
|
||||
} else if (args[0].equalsIgnoreCase("save") && sender.isOp()) {
|
||||
try {
|
||||
Core.getMainClass().getConfig().save(new File("plugins/Core/","config.yml"));
|
||||
Core.statusMsg(sender,"config_save",true);
|
||||
Core.getMainClass().getConfig().save(new File("plugins/Core/", "config.yml"));
|
||||
Core.statusMsg(sender, "config_save", true);
|
||||
} catch (IOException ex) {
|
||||
Core.statusMsg(sender,"config_save_io_err",false);
|
||||
Core.statusMsg(sender, "config_save_io_err", false);
|
||||
}
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("debugclosemysql") && sender.isOp())
|
||||
{
|
||||
} else if (args[0].equalsIgnoreCase("debugclosemysql") && sender.isOp()) {
|
||||
AnuraCore.sql.closeConnection();
|
||||
Core.statusMsg(sender, "debug_mysql_closed", true);
|
||||
return true;
|
||||
}
|
||||
} else if(cmd.getName().equalsIgnoreCase("setspawn"))
|
||||
{
|
||||
if(P != null && P.hasPermission("core.commands.setspawn"))
|
||||
{
|
||||
} else if (cmd.getName().equalsIgnoreCase("setspawn")) {
|
||||
if (P != null && P.hasPermission("core.commands.setspawn")) {
|
||||
Location l = P.getLocation();
|
||||
l.getWorld().setSpawnLocation((int)l.getX(), (int)l.getY(), (int)l.getZ());
|
||||
Core.statusMsg(P,"spawn_set",true);
|
||||
l.getWorld().setSpawnLocation((int) l.getX(), (int) l.getY(), (int) l.getZ());
|
||||
Core.statusMsg(P, "spawn_set", true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,24 +14,29 @@ public class OtherCommands implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
Player P = null;
|
||||
if(sender instanceof Player) {
|
||||
P = (Player)sender;
|
||||
if (sender instanceof Player) {
|
||||
P = (Player) sender;
|
||||
}
|
||||
if(cmd.getName().equalsIgnoreCase("togglecommands")) {
|
||||
if(!(sender instanceof BlockCommandSender)) {
|
||||
Core.getTools().sendStatusMsg(sender,"Only command block cmd!",false);
|
||||
if (cmd.getName().equalsIgnoreCase("togglecommands")) {
|
||||
if (!(sender instanceof BlockCommandSender)) {
|
||||
Core.getTools().sendStatusMsg(sender, "Only command block cmd!", false);
|
||||
return true;
|
||||
}
|
||||
if(args.length != 2) return false;
|
||||
if (args.length != 2) {
|
||||
return false;
|
||||
}
|
||||
String action = args[1];
|
||||
if(!action.equals("disable") && !action.equals("enable")) return true;
|
||||
if (!action.equals("disable") && !action.equals("enable")) {
|
||||
return true;
|
||||
}
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]);
|
||||
if(!op.isOnline()) return true;
|
||||
if (!op.isOnline()) {
|
||||
return true;
|
||||
}
|
||||
Boolean b = action.equals("disable");
|
||||
Core.getMainClass().disableCommandsAdventure.put(op.getPlayer(), b);
|
||||
return true;
|
||||
} else if(cmd.getName().equalsIgnoreCase("none"))
|
||||
{
|
||||
} else if (cmd.getName().equalsIgnoreCase("none")) {
|
||||
Core.statusMsg(sender, "cmd_not_found", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,12 +23,11 @@ public class PlayerCommands implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
|
||||
Player P = null;
|
||||
if(sender instanceof Player)
|
||||
{
|
||||
P = (Player)sender;
|
||||
if (sender instanceof Player) {
|
||||
P = (Player) sender;
|
||||
}
|
||||
if(cmd.getName().equalsIgnoreCase("toggledbljump")) {
|
||||
if(P == null) {
|
||||
if (cmd.getName().equalsIgnoreCase("toggledbljump")) {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
@@ -48,13 +47,17 @@ public class PlayerCommands implements CommandExecutor {
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("xpbattle")) {
|
||||
Objective o = Bukkit.getScoreboardManager().getMainScoreboard().getObjective("xpBattleJoin");
|
||||
if (o == null) return true;
|
||||
if (o == null) {
|
||||
return true;
|
||||
}
|
||||
o.getScore(P).setScore(1);
|
||||
Core.statusMsg(sender, "joined_xpBattle", true);
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("pool")) {
|
||||
Objective o = Bukkit.getScoreboardManager().getMainScoreboard().getObjective("poolJoin");
|
||||
if (o == null) return true;
|
||||
if (o == null) {
|
||||
return true;
|
||||
}
|
||||
o.getScore(P).setScore(1);
|
||||
Core.statusMsg(sender, "joined_pool", true);
|
||||
return true;
|
||||
@@ -69,13 +72,17 @@ public class PlayerCommands implements CommandExecutor {
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("xpbattle")) {
|
||||
Objective o = Bukkit.getScoreboardManager().getMainScoreboard().getObjective("xpBattleJoin");
|
||||
if (o == null) return true;
|
||||
if (o == null) {
|
||||
return true;
|
||||
}
|
||||
o.getScore(P).setScore(0);
|
||||
Core.statusMsg(sender, "left_xpBattle", true);
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("pool")) {
|
||||
Objective o = Bukkit.getScoreboardManager().getMainScoreboard().getObjective("poolJoin");
|
||||
if (o == null) return true;
|
||||
if (o == null) {
|
||||
return true;
|
||||
}
|
||||
o.getScore(P).setScore(0);
|
||||
Core.statusMsg(sender, "left_pool", true);
|
||||
return true;
|
||||
@@ -90,7 +97,9 @@ public class PlayerCommands implements CommandExecutor {
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("xpbattle")) {
|
||||
Objective o = Bukkit.getScoreboardManager().getMainScoreboard().getObjective("xpBattleJoin");
|
||||
if (o == null) return true;
|
||||
if (o == null) {
|
||||
return true;
|
||||
}
|
||||
if (o.getScore(P).getScore() == 0) {
|
||||
Bukkit.dispatchCommand(sender, "joinminigame xpBattle");
|
||||
return true;
|
||||
@@ -100,7 +109,9 @@ public class PlayerCommands implements CommandExecutor {
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("pool")) {
|
||||
Objective o = Bukkit.getScoreboardManager().getMainScoreboard().getObjective("poolJoin");
|
||||
if (o == null) return true;
|
||||
if (o == null) {
|
||||
return true;
|
||||
}
|
||||
if (o.getScore(P).getScore() == 0) {
|
||||
Bukkit.dispatchCommand(sender, "joinminigame pool");
|
||||
return true;
|
||||
@@ -109,117 +120,94 @@ public class PlayerCommands implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if(cmd.getName().equalsIgnoreCase("hilfe"))
|
||||
{
|
||||
if(!cmdLabel.equals("hilfe") && !cmdLabel.equals("help") && !cmdLabel.equals("?"))
|
||||
{
|
||||
} else if (cmd.getName().equalsIgnoreCase("hilfe")) {
|
||||
if (!cmdLabel.equals("hilfe") && !cmdLabel.equals("help") && !cmdLabel.equals("?")) {
|
||||
cmdLabel = "hilfe";
|
||||
}
|
||||
if(sender.hasPermission("core.commands.help"))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Achtung: "+ChatColor.YELLOW+"Die echte Hilfe gibts mit "+ChatColor.BLUE+"/?"+ChatColor.YELLOW+"!");
|
||||
if (sender.hasPermission("core.commands.help")) {
|
||||
sender.sendMessage(ChatColor.RED + "Achtung: " + ChatColor.YELLOW + "Die echte Hilfe gibts mit " + ChatColor.BLUE + "/?" + ChatColor.YELLOW + "!");
|
||||
}
|
||||
if(args.length == 0)
|
||||
{
|
||||
sender.sendMessage(ChatColor.YELLOW+"-----------"+ChatColor.AQUA+"Hilfe"+ChatColor.YELLOW+"-----------");
|
||||
sender.sendMessage(ChatColor.GREEN+"Hilfe zu den Befehlen gibt es mit "+ChatColor.BLUE+"/"+cmdLabel+" commands");
|
||||
sender.sendMessage(ChatColor.GOLD+"Informationen zu unseren GameModes erhälst du mit "+ChatColor.BLUE+"/"+cmdLabel+" gamemodes");
|
||||
}
|
||||
else if(args.length == 1)
|
||||
{
|
||||
if(args[0].equalsIgnoreCase("commands"))
|
||||
{
|
||||
sender.sendMessage(ChatColor.YELLOW+"-----------"+ChatColor.AQUA+"Befehle"+ChatColor.YELLOW+"-----------");
|
||||
sender.sendMessage(ChatColor.BLUE+"/lobby "+ChatColor.GREEN+"Bringt dich jederzeit zurück zur Lobby.");
|
||||
sender.sendMessage(ChatColor.BLUE+"/spawn "+ChatColor.GOLD+"Teleportiert dich zum Spawn.");
|
||||
sender.sendMessage(ChatColor.BLUE+"/money "+ChatColor.GREEN+"Zeigt dein Geld an.");
|
||||
sender.sendMessage(ChatColor.RED+"Befehle für den Smash-Gamemode siehst du mit "+ChatColor.BLUE+"/"+cmdLabel+" commands smash");
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "-----------" + ChatColor.AQUA + "Hilfe" + ChatColor.YELLOW + "-----------");
|
||||
sender.sendMessage(ChatColor.GREEN + "Hilfe zu den Befehlen gibt es mit " + ChatColor.BLUE + "/" + cmdLabel + " commands");
|
||||
sender.sendMessage(ChatColor.GOLD + "Informationen zu unseren GameModes erhälst du mit " + ChatColor.BLUE + "/" + cmdLabel + " gamemodes");
|
||||
} else if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("commands")) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "-----------" + ChatColor.AQUA + "Befehle" + ChatColor.YELLOW + "-----------");
|
||||
sender.sendMessage(ChatColor.BLUE + "/lobby " + ChatColor.GREEN + "Bringt dich jederzeit zurück zur Lobby.");
|
||||
sender.sendMessage(ChatColor.BLUE + "/spawn " + ChatColor.GOLD + "Teleportiert dich zum Spawn.");
|
||||
sender.sendMessage(ChatColor.BLUE + "/money " + ChatColor.GREEN + "Zeigt dein Geld an.");
|
||||
sender.sendMessage(ChatColor.RED + "Befehle für den Smash-Gamemode siehst du mit " + ChatColor.BLUE + "/" + cmdLabel + " commands smash");
|
||||
} else if (args[0].equalsIgnoreCase("gamemodes")) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "-----------" + ChatColor.AQUA + "Gamemodes" + ChatColor.YELLOW + "-----------");
|
||||
sender.sendMessage(ChatColor.GRAY + "----------" + ChatColor.GREEN + "Smash PvP" + ChatColor.GRAY + "-----------");
|
||||
sender.sendMessage(ChatColor.BLUE + "In Smash PvP geht es darum, mithilfe von verschiedenen Klassen deine "
|
||||
+ "Gegner ins Wasser, in die Lava oder aus der Welt zu schlagen. "
|
||||
+ "Du kannst verschiedenen Arenen beitreten. Es gibt keine Begrenzung, wie "
|
||||
+ "lange du spielen kannst. Jeder Kill gibt dir Münzen. Stirbst du, verlierst du "
|
||||
+ "eine Münze.");
|
||||
sender.sendMessage(ChatColor.GOLD + "Mit " + ChatColor.RED + "/" + cmdLabel + " commands smash" + ChatColor.GOLD + " kannst du dir");
|
||||
sender.sendMessage(ChatColor.GOLD + "alle Befehle des Minigames anzeigen lassen.");
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("gamemodes"))
|
||||
{
|
||||
sender.sendMessage(ChatColor.YELLOW+"-----------"+ChatColor.AQUA+"Gamemodes"+ChatColor.YELLOW+"-----------");
|
||||
sender.sendMessage(ChatColor.GRAY+"----------"+ChatColor.GREEN+"Smash PvP"+ChatColor.GRAY+"-----------");
|
||||
sender.sendMessage(ChatColor.BLUE+"In Smash PvP geht es darum, mithilfe von verschiedenen Klassen deine "+
|
||||
"Gegner ins Wasser, in die Lava oder aus der Welt zu schlagen. "+
|
||||
"Du kannst verschiedenen Arenen beitreten. Es gibt keine Begrenzung, wie "+
|
||||
"lange du spielen kannst. Jeder Kill gibt dir Münzen. Stirbst du, verlierst du "+
|
||||
"eine Münze.");
|
||||
sender.sendMessage(ChatColor.GOLD+"Mit "+ChatColor.RED+"/"+cmdLabel+" commands smash"+ChatColor.GOLD+" kannst du dir");
|
||||
sender.sendMessage(ChatColor.GOLD+"alle Befehle des Minigames anzeigen lassen.");
|
||||
}
|
||||
}
|
||||
else if(args.length == 2)
|
||||
{
|
||||
if(args[0].equalsIgnoreCase("commands") && args[1].equalsIgnoreCase("smash"))
|
||||
{
|
||||
sender.sendMessage(ChatColor.YELLOW+"-----------"+ChatColor.AQUA+"Smash Befehle"+ChatColor.YELLOW+"-----------");
|
||||
sender.sendMessage(ChatColor.BLUE+"/join <Arena> "+ChatColor.GREEN+"Hiermit kannst du einem Smash Game beitreten.");
|
||||
sender.sendMessage(ChatColor.BLUE+"/leave "+ChatColor.GREEN+"Lässt dich ein Spiel verlassen.");
|
||||
sender.sendMessage(ChatColor.BLUE+"/class "+ChatColor.GREEN+"Damit kannst du während eines Spiels die Klasse wechseln.");
|
||||
sender.sendMessage(ChatColor.BLUE+"/classes "+ChatColor.GREEN+"Teleportiert dich in einen Raum, in dem du Klassen kaufen kannst.");
|
||||
sender.sendMessage(ChatColor.BLUE+"/bug <Beschreibung> "+ChatColor.GREEN+"Wenn du einen Bug gefunden hast, kannst du ihn so reporten.");
|
||||
} else if (args.length == 2) {
|
||||
if (args[0].equalsIgnoreCase("commands") && args[1].equalsIgnoreCase("smash")) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "-----------" + ChatColor.AQUA + "Smash Befehle" + ChatColor.YELLOW + "-----------");
|
||||
sender.sendMessage(ChatColor.BLUE + "/join <Arena> " + ChatColor.GREEN + "Hiermit kannst du einem Smash Game beitreten.");
|
||||
sender.sendMessage(ChatColor.BLUE + "/leave " + ChatColor.GREEN + "Lässt dich ein Spiel verlassen.");
|
||||
sender.sendMessage(ChatColor.BLUE + "/class " + ChatColor.GREEN + "Damit kannst du während eines Spiels die Klasse wechseln.");
|
||||
sender.sendMessage(ChatColor.BLUE + "/classes " + ChatColor.GREEN + "Teleportiert dich in einen Raum, in dem du Klassen kaufen kannst.");
|
||||
sender.sendMessage(ChatColor.BLUE + "/bug <Beschreibung> " + ChatColor.GREEN + "Wenn du einen Bug gefunden hast, kannst du ihn so reporten.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if(cmd.getName().equalsIgnoreCase("spawn"))
|
||||
{
|
||||
if(args.length == 1)
|
||||
{
|
||||
if(sender.hasPermission("core.commands.spawn-other") || sender instanceof BlockCommandSender)
|
||||
{
|
||||
if(Bukkit.getOfflinePlayer(args[0]).isOnline())
|
||||
{
|
||||
} else if (cmd.getName().equalsIgnoreCase("spawn")) {
|
||||
if (args.length == 1) {
|
||||
if (sender.hasPermission("core.commands.spawn-other") || sender instanceof BlockCommandSender) {
|
||||
if (Bukkit.getOfflinePlayer(args[0]).isOnline()) {
|
||||
P = Bukkit.getPlayer(args[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(P == null)
|
||||
{
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
P.teleport(P.getLocation().getWorld().getSpawnLocation());
|
||||
Core.statusMsg(P,"spawn_tp_done",true);
|
||||
Core.statusMsg(P, "spawn_tp_done", true);
|
||||
return true;
|
||||
} else if(cmd.getName().equalsIgnoreCase("warp"))
|
||||
{
|
||||
} else if (cmd.getName().equalsIgnoreCase("warp")) {
|
||||
try {
|
||||
if(args.length == 0 || args.length > 2)
|
||||
{
|
||||
if (args.length == 0 || args.length > 2) {
|
||||
Core.statusMsg(P, "wrong_args_count", false);
|
||||
return false;
|
||||
}
|
||||
if(P == null)
|
||||
{
|
||||
if(args.length != 2)
|
||||
{
|
||||
if (P == null) {
|
||||
if (args.length != 2) {
|
||||
Core.statusMsg(P, "wrong_args_count", false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(args.length == 2)
|
||||
{
|
||||
if (args.length == 2) {
|
||||
String p = args[1];
|
||||
if(!Bukkit.getOfflinePlayer(p).isOnline())
|
||||
{
|
||||
if (!Bukkit.getOfflinePlayer(p).isOnline()) {
|
||||
Core.statusMsg(P, "player_not_online", false);
|
||||
return false;
|
||||
}
|
||||
P = Bukkit.getPlayer(p);
|
||||
}
|
||||
String warpName = args[0];
|
||||
ResultSet rs = sql.querySelect("SELECT world, X, Y, Z, userWarp, server FROM coreWarps WHERE name = '"+warpName+"'");
|
||||
ResultSet rs = sql.querySelect("SELECT world, X, Y, Z, userWarp, server FROM coreWarps WHERE name = '" + warpName + "'");
|
||||
rs.last();
|
||||
if(rs.getRow() == 0)
|
||||
{
|
||||
if (rs.getRow() == 0) {
|
||||
Core.statusMsg(P, "warp_not_exist", false);
|
||||
return true;
|
||||
}
|
||||
rs.first();
|
||||
if(P == null) return false;
|
||||
if(!rs.getBoolean("userWarp") && !P.hasPermission("core.commands.adminWarp"))
|
||||
{
|
||||
if (P == null) {
|
||||
return false;
|
||||
}
|
||||
if (!rs.getBoolean("userWarp") && !P.hasPermission("core.commands.adminWarp")) {
|
||||
Core.statusMsg(P, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
@@ -228,14 +216,12 @@ public class PlayerCommands implements CommandExecutor {
|
||||
int Z = rs.getInt("Z");
|
||||
String server = rs.getString("server");
|
||||
String world = rs.getString("world");
|
||||
if(!server.equals(Core.getMainClass().getConfig().getString("server-name")))
|
||||
{
|
||||
if (!server.equals(Core.getMainClass().getConfig().getString("server-name"))) {
|
||||
Core.statusMsg(P, "warp_other_server", false);
|
||||
return true;
|
||||
}
|
||||
World w = Bukkit.getWorld(world);
|
||||
if(w == null)
|
||||
{
|
||||
if (w == null) {
|
||||
Core.statusMsg(P, "warp_not_avail", false);
|
||||
return true;
|
||||
}
|
||||
@@ -244,103 +230,76 @@ public class PlayerCommands implements CommandExecutor {
|
||||
Core.statusMsg(P, "warp_tp_done", true);
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error: "+ex.getLocalizedMessage());
|
||||
System.out.println("Error: " + ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
else if(cmd.getName().equalsIgnoreCase("money"))
|
||||
{
|
||||
if(args.length == 0)
|
||||
{
|
||||
if(P == null)
|
||||
{
|
||||
Core.getTools().sendStatusMsg(sender,"only_player_cmd",false);
|
||||
} else if (cmd.getName().equalsIgnoreCase("money")) {
|
||||
if (args.length == 0) {
|
||||
if (P == null) {
|
||||
Core.getTools().sendStatusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
Integer money = Money.getMoney(P);
|
||||
Core.getTools().sendStatusMsg(P,Core.getl("you_have", P)+" "+money+" "+ Core.getl("coins", P),true);
|
||||
return true;
|
||||
}
|
||||
else if((args[0].equalsIgnoreCase("pay")) && (args.length == 3))
|
||||
{
|
||||
Core.getTools().sendStatusMsg(P, Core.getl("you_have", P) + " " + money + " " + Core.getl("coins", P), true);
|
||||
return true;
|
||||
} else if ((args[0].equalsIgnoreCase("pay")) && (args.length == 3)) {
|
||||
Integer money = Integer.parseInt(args[2]);
|
||||
boolean canPay;
|
||||
Integer geld = 0;
|
||||
if(sender.hasPermission("core.money.endless"))
|
||||
{
|
||||
if(P != null)
|
||||
{
|
||||
if (sender.hasPermission("core.money.endless")) {
|
||||
if (P != null) {
|
||||
canPay = P.hasPermission("core.money.endless");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
canPay = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(P == null)
|
||||
{
|
||||
Core.statusMsg(sender,"only_player_cmd",false);
|
||||
return true;
|
||||
} else {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if(P.getName().equals(args[1]))
|
||||
{
|
||||
Core.statusMsg(P,"money_pay_yourself",false);
|
||||
return true;
|
||||
if (P.getName().equals(args[1])) {
|
||||
Core.statusMsg(P, "money_pay_yourself", false);
|
||||
return true;
|
||||
}
|
||||
if(!(money > 0))
|
||||
{
|
||||
Core.statusMsg(P,"number_must_positive",false);
|
||||
return true;
|
||||
if (!(money > 0)) {
|
||||
Core.statusMsg(P, "number_must_positive", false);
|
||||
return true;
|
||||
}
|
||||
int currentMoney = Money.getMoney(P);
|
||||
if(currentMoney < money)
|
||||
{
|
||||
Core.statusMsg(P,"not_enough_money",false);
|
||||
if (currentMoney < money) {
|
||||
Core.statusMsg(P, "not_enough_money", false);
|
||||
canPay = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
geld = currentMoney;
|
||||
canPay = true;
|
||||
}
|
||||
}
|
||||
if(canPay)
|
||||
{
|
||||
if (canPay) {
|
||||
OfflinePlayer oP = Bukkit.getOfflinePlayer(args[1]);
|
||||
if(!oP.hasPlayedBefore() && !oP.isOnline())
|
||||
{
|
||||
if (!oP.hasPlayedBefore() && !oP.isOnline()) {
|
||||
Core.statusMsg(P, "never_seen_player", false);
|
||||
return true;
|
||||
}
|
||||
int currentMoney2 = Money.getMoney(oP);
|
||||
if(currentMoney2 != -1)
|
||||
{
|
||||
if (currentMoney2 != -1) {
|
||||
Money.payMoney(oP, money);
|
||||
if(P == null){}
|
||||
else if(!P.hasPermission("core.money.endless"))
|
||||
{
|
||||
if (P == null) {
|
||||
} else if (!P.hasPermission("core.money.endless")) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Core.statusMsg(sender,"never_seen_player", false);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Core.statusMsg(sender, "never_seen_player", false);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,69 +33,55 @@ public class TeamCommands implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
Player P = null;
|
||||
if(sender instanceof Player)
|
||||
{
|
||||
P = (Player)sender;
|
||||
if (sender instanceof Player) {
|
||||
P = (Player) sender;
|
||||
}
|
||||
if(cmd.getName().equalsIgnoreCase("setcmd"))
|
||||
{
|
||||
if(P == null)
|
||||
{
|
||||
Core.statusMsg(sender,"only_player_cmd",false);
|
||||
if (cmd.getName().equalsIgnoreCase("setcmd")) {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if(!sender.hasPermission("core.commands.editcmd"))
|
||||
{
|
||||
Core.statusMsg(sender,"no_perms",false);
|
||||
if (!sender.hasPermission("core.commands.editcmd")) {
|
||||
Core.statusMsg(sender, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
if(args.length < 1)
|
||||
{
|
||||
Core.statusMsg(sender,"wrong_args_count",false);
|
||||
if (args.length < 1) {
|
||||
Core.statusMsg(sender, "wrong_args_count", false);
|
||||
return false;
|
||||
}
|
||||
Block b = P.getTargetBlock(null, 100);
|
||||
if(b.getType().equals(Material.COMMAND))
|
||||
{
|
||||
if (b.getType().equals(Material.COMMAND)) {
|
||||
String command = "";
|
||||
for(String arg : args)
|
||||
{
|
||||
if(!command.equals(""))
|
||||
{
|
||||
for (String arg : args) {
|
||||
if (!command.equals("")) {
|
||||
command += " ";
|
||||
}
|
||||
command += arg;
|
||||
}
|
||||
CommandBlock cb = (CommandBlock)b.getState();
|
||||
CommandBlock cb = (CommandBlock) b.getState();
|
||||
cb.setCommand(command);
|
||||
cb.update();
|
||||
}
|
||||
return true;
|
||||
} else if(cmd.getName().equalsIgnoreCase("addcmd")) {
|
||||
if(P == null)
|
||||
{
|
||||
Core.statusMsg(sender,"only_player_cmd",false);
|
||||
} else if (cmd.getName().equalsIgnoreCase("addcmd")) {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if(!sender.hasPermission("core.commands.editcmd"))
|
||||
{
|
||||
Core.statusMsg(sender,"no_perms",false);
|
||||
if (!sender.hasPermission("core.commands.editcmd")) {
|
||||
Core.statusMsg(sender, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
if(args.length != 1)
|
||||
{
|
||||
Core.statusMsg(sender,"wrong_args_count",false);
|
||||
if (args.length != 1) {
|
||||
Core.statusMsg(sender, "wrong_args_count", false);
|
||||
return false;
|
||||
}
|
||||
Block b = P.getTargetBlock(null, 100);
|
||||
if(b.getType().equals(Material.COMMAND))
|
||||
{
|
||||
CommandBlock cb = (CommandBlock)b.getState();
|
||||
if (b.getType().equals(Material.COMMAND)) {
|
||||
CommandBlock cb = (CommandBlock) b.getState();
|
||||
String command = "";
|
||||
for(String arg : args)
|
||||
{
|
||||
if(!command.equals(""))
|
||||
{
|
||||
for (String arg : args) {
|
||||
if (!command.equals("")) {
|
||||
command += " ";
|
||||
}
|
||||
command += arg;
|
||||
@@ -105,80 +91,67 @@ public class TeamCommands implements CommandExecutor {
|
||||
cb.update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if(cmd.getName().equalsIgnoreCase("gm"))
|
||||
{
|
||||
} else if (cmd.getName().equalsIgnoreCase("gm")) {
|
||||
String command = "gamemode ";
|
||||
for(String arg : args)
|
||||
{
|
||||
command += arg+" ";
|
||||
for (String arg : args) {
|
||||
command += arg + " ";
|
||||
}
|
||||
Bukkit.dispatchCommand(sender, command);
|
||||
return true;
|
||||
}else if(cmd.getName().equalsIgnoreCase("stairmode"))
|
||||
{
|
||||
if(P == null)
|
||||
{
|
||||
Core.statusMsg(sender,"only_player_cmd",false);
|
||||
} else if (cmd.getName().equalsIgnoreCase("stairmode")) {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if(!P.hasPermission("core.commands.stairmode"))
|
||||
{
|
||||
Core.statusMsg(sender,"no_perms",false);
|
||||
if (!P.hasPermission("core.commands.stairmode")) {
|
||||
Core.statusMsg(sender, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
if(Core.getMainClass().stairMode.contains(P)) Core.getMainClass().stairMode.remove(P);
|
||||
else Core.getMainClass().stairMode.add(P);
|
||||
if (Core.getMainClass().stairMode.contains(P)) {
|
||||
Core.getMainClass().stairMode.remove(P);
|
||||
} else {
|
||||
Core.getMainClass().stairMode.add(P);
|
||||
}
|
||||
Core.getTools().sendStatusMsg(sender, "Done!", true);
|
||||
return true;
|
||||
}
|
||||
else if(cmd.getName().equalsIgnoreCase("flowerpot"))
|
||||
{
|
||||
if(P == null)
|
||||
{
|
||||
Core.statusMsg(sender,"only_player_cmd",false);
|
||||
} else if (cmd.getName().equalsIgnoreCase("flowerpot")) {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if(!P.hasPermission("core.commands.flowerpot"))
|
||||
{
|
||||
Core.statusMsg(sender,"no_perms",false);
|
||||
if (!P.hasPermission("core.commands.flowerpot")) {
|
||||
Core.statusMsg(sender, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
if(args.length != 1)
|
||||
{
|
||||
Core.statusMsg(sender,"wrong_args_count",false);
|
||||
if (args.length != 1) {
|
||||
Core.statusMsg(sender, "wrong_args_count", false);
|
||||
return false;
|
||||
}
|
||||
Location l = P.getLocation();
|
||||
if(Core.getMainClass().flowerPots.containsValue(l))
|
||||
{
|
||||
if (Core.getMainClass().flowerPots.containsValue(l)) {
|
||||
Core.statusMsg(sender, "set_arch_exists", false);
|
||||
return true;
|
||||
}
|
||||
Core.getMySql().queryUpdate("INSERT INTO corePots(X,Y,Z,world,url,name,money,type) VALUES('"+l.getBlockX()+"','"+l.getBlockY()+"','"+l.getBlockZ()+"','"+l.getWorld().getName()+"','http://mc-anura.de','"+args[0]+"','1','0')");
|
||||
ResultSet rs = Core.getMySql().querySelect("SELECT id FROM corePots WHERE X = '"+l.getBlockX()+"' AND Y = '"+l.getBlockY()+"' AND Z = '"+l.getBlockZ()+"' AND world = '"+l.getWorld().getName()+"'");
|
||||
Core.getMySql().queryUpdate("INSERT INTO corePots(X,Y,Z,world,url,name,money,type) VALUES('" + l.getBlockX() + "','" + l.getBlockY() + "','" + l.getBlockZ() + "','" + l.getWorld().getName() + "','http://mc-anura.de','" + args[0] + "','1','0')");
|
||||
ResultSet rs = Core.getMySql().querySelect("SELECT id FROM corePots WHERE X = '" + l.getBlockX() + "' AND Y = '" + l.getBlockY() + "' AND Z = '" + l.getBlockZ() + "' AND world = '" + l.getWorld().getName() + "'");
|
||||
try {
|
||||
rs.first();
|
||||
Core.getMainClass().flowerPots.put(rs.getInt("id"), new Location(l.getWorld(),l.getBlockX(),l.getBlockY(),l.getBlockZ()));
|
||||
Core.getMainClass().flowerPots.put(rs.getInt("id"), new Location(l.getWorld(), l.getBlockX(), l.getBlockY(), l.getBlockZ()));
|
||||
l.getBlock().setType(Material.BROWN_MUSHROOM);
|
||||
Core.getMainClass().pots.refreshPot(rs.getInt("id"));
|
||||
Core.statusMsg(sender, "set_arch_ok", true);
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error onCommand. Setpot");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else if(cmd.getName().equalsIgnoreCase("renderMap"))
|
||||
{
|
||||
if(!sender.hasPermission("core.commands.addmap"))
|
||||
{
|
||||
Core.statusMsg(sender,"no_perms",false);
|
||||
} else if (cmd.getName().equalsIgnoreCase("renderMap")) {
|
||||
if (!sender.hasPermission("core.commands.addmap")) {
|
||||
Core.statusMsg(sender, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
if(args.length != 2)
|
||||
{
|
||||
Core.statusMsg(sender,"wrong_args_count",false);
|
||||
if (args.length != 2) {
|
||||
Core.statusMsg(sender, "wrong_args_count", false);
|
||||
return false;
|
||||
}
|
||||
final CommandSender cs = sender;
|
||||
@@ -195,7 +168,7 @@ public class TeamCommands implements CommandExecutor {
|
||||
BufferedImage imgSrc = ImageIO.read(locUrl.openStream());
|
||||
Image i = imgSrc.getScaledInstance(128, 128, Image.SCALE_SMOOTH);
|
||||
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);
|
||||
Core.getTools().sendStatusMsg(cs, "The rendering has finished!", true);
|
||||
} catch (MalformedURLException ex) {
|
||||
@@ -204,126 +177,102 @@ public class TeamCommands implements CommandExecutor {
|
||||
Core.getTools().sendStatusMsg(cs, "Image rendering not working! Did you provide a valid url?", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}, 1);
|
||||
return true;
|
||||
}
|
||||
else if(cmd.getName().equalsIgnoreCase("addMap"))
|
||||
{
|
||||
if(P == null)
|
||||
{
|
||||
Core.statusMsg(sender,"only_player_cmd",false);
|
||||
} else if (cmd.getName().equalsIgnoreCase("addMap")) {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if(!P.hasPermission("core.commands.addmap"))
|
||||
{
|
||||
Core.statusMsg(sender,"no_perms",false);
|
||||
if (!P.hasPermission("core.commands.addmap")) {
|
||||
Core.statusMsg(sender, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
if(args.length != 1)
|
||||
{
|
||||
Core.statusMsg(sender,"wrong_args_count",false);
|
||||
if (args.length != 1) {
|
||||
Core.statusMsg(sender, "wrong_args_count", 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);
|
||||
return true;
|
||||
}
|
||||
MapView mv = Bukkit.createMap(P.getWorld());
|
||||
for(MapRenderer mr : mv.getRenderers())
|
||||
{
|
||||
for (MapRenderer mr : mv.getRenderers()) {
|
||||
mv.removeRenderer(mr);
|
||||
}
|
||||
mv.addRenderer(new ImgRenderer(args[0]));
|
||||
P.setItemInHand(new ItemStack(Material.MAP, 0, mv.getId()));
|
||||
Core.statusMsg(sender, "addmap_done", true);
|
||||
return true;
|
||||
} else if(cmd.getName().equalsIgnoreCase("sun"))
|
||||
{
|
||||
if(P != null)
|
||||
{
|
||||
if(P.hasPermission("core.commands.sun"))
|
||||
{
|
||||
} else if (cmd.getName().equalsIgnoreCase("sun")) {
|
||||
if (P != null) {
|
||||
if (P.hasPermission("core.commands.sun")) {
|
||||
World w = P.getLocation().getWorld();
|
||||
w.setTime(2000);
|
||||
w.setThundering(false);
|
||||
w.setStorm(false);
|
||||
Core.getMainClass().tools.sendStatusMsg(sender, "Sun!", true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(cmd.getName().equalsIgnoreCase("setjumper"))
|
||||
{
|
||||
if(P == null)
|
||||
{
|
||||
Core.statusMsg(sender,"only_player_cmd",false);
|
||||
return true;
|
||||
}
|
||||
if(args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!P.hasPermission("core.commands.setjumper"))
|
||||
{
|
||||
Core.statusMsg(sender,"no_perms",false);
|
||||
return true;
|
||||
}
|
||||
if(Double.valueOf(args[0]) > 10 || Double.valueOf(args[0]) < 0.2)
|
||||
{
|
||||
Core.statusMsg(sender,"setjumper_wrong_number",false);
|
||||
return true;
|
||||
}
|
||||
Core.getMainClass().selectableJumper.put(P, Double.valueOf(args[0]));
|
||||
sender.sendMessage(ChatColor.GRAY + "[Anura] " +ChatColor.GREEN +Core.getl("setjumper_select_now",sender)+" "+Double.valueOf(args[0])+")");
|
||||
return true;
|
||||
} else if(cmd.getName().equalsIgnoreCase("flyspeed"))
|
||||
{
|
||||
if(P == null)
|
||||
{
|
||||
} else if (cmd.getName().equalsIgnoreCase("setjumper")) {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if(!P.hasPermission("core.commands.flyspeed"))
|
||||
{
|
||||
if (args.length != 1) {
|
||||
return false;
|
||||
}
|
||||
if (!P.hasPermission("core.commands.setjumper")) {
|
||||
Core.statusMsg(sender, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
if (Double.valueOf(args[0]) > 10 || Double.valueOf(args[0]) < 0.2) {
|
||||
Core.statusMsg(sender, "setjumper_wrong_number", false);
|
||||
return true;
|
||||
}
|
||||
Core.getMainClass().selectableJumper.put(P, Double.valueOf(args[0]));
|
||||
sender.sendMessage(ChatColor.GRAY + "[Anura] " + ChatColor.GREEN + Core.getl("setjumper_select_now", sender) + " " + Double.valueOf(args[0]) + ")");
|
||||
return true;
|
||||
} else if (cmd.getName().equalsIgnoreCase("flyspeed")) {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if (!P.hasPermission("core.commands.flyspeed")) {
|
||||
Core.statusMsg(P, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
if(args.length != 1)
|
||||
{
|
||||
if (args.length != 1) {
|
||||
return false;
|
||||
}
|
||||
if(Float.parseFloat(args[0]) >= 10 || Float.parseFloat(args[0]) < 0)
|
||||
{
|
||||
if (Float.parseFloat(args[0]) >= 10 || Float.parseFloat(args[0]) < 0) {
|
||||
Core.statusMsg(P, "flyspeed_wrong_number", false);
|
||||
return true;
|
||||
}
|
||||
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);
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
else if(cmd.getName().equalsIgnoreCase("setwarp"))
|
||||
{
|
||||
} else if (cmd.getName().equalsIgnoreCase("setwarp")) {
|
||||
try {
|
||||
if(P == null)
|
||||
{
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if(!P.hasPermission("core.commands.setwarp"))
|
||||
{
|
||||
if (!P.hasPermission("core.commands.setwarp")) {
|
||||
Core.statusMsg(P, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
if(args.length < 1)
|
||||
{
|
||||
if (args.length < 1) {
|
||||
Core.statusMsg(P, "wrong_args_count", false);
|
||||
return false;
|
||||
}
|
||||
String userWarp = "0";
|
||||
if(args.length == 2)
|
||||
{
|
||||
if(args[1].equalsIgnoreCase("true")) userWarp = "1";
|
||||
if (args.length == 2) {
|
||||
if (args[1].equalsIgnoreCase("true")) {
|
||||
userWarp = "1";
|
||||
}
|
||||
}
|
||||
Location loc = P.getLocation();
|
||||
int X = loc.getBlockX();
|
||||
@@ -332,49 +281,43 @@ public class TeamCommands implements CommandExecutor {
|
||||
String world = loc.getWorld().getName();
|
||||
String server = Core.getMainClass().getConfig().getString("server-name");
|
||||
String name = args[0];
|
||||
ResultSet rs = sql.querySelect("SELECT `name` FROM coreWarps WHERE name = '"+name+"'");
|
||||
ResultSet rs = sql.querySelect("SELECT `name` FROM coreWarps WHERE name = '" + name + "'");
|
||||
rs.last();
|
||||
if(rs.getRow() != 0)
|
||||
{
|
||||
if (rs.getRow() != 0) {
|
||||
Core.statusMsg(P, "warp_alr_exist", false);
|
||||
return true;
|
||||
}
|
||||
sql.queryUpdate("INSERT INTO coreWarps(`name`, server, world, X, Y, Z, userWarp) VALUES('"+name+"', '"+server+"', '"+world+"', '"+X+"', '"+Y+"', '"+Z+"', '"+userWarp+"')");
|
||||
sql.queryUpdate("INSERT INTO coreWarps(`name`, server, world, X, Y, Z, userWarp) VALUES('" + name + "', '" + server + "', '" + world + "', '" + X + "', '" + Y + "', '" + Z + "', '" + userWarp + "')");
|
||||
Core.statusMsg(P, "warp_set", true);
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error: "+ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
else if(cmd.getName().equalsIgnoreCase("remwarp"))
|
||||
{
|
||||
if(args.length != 1)
|
||||
{
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error: " + ex.getLocalizedMessage());
|
||||
}
|
||||
} else if (cmd.getName().equalsIgnoreCase("remwarp")) {
|
||||
if (args.length != 1) {
|
||||
Core.statusMsg(P, "wrong_args_count", false);
|
||||
return false;
|
||||
}
|
||||
if(!sender.hasPermission("core.commands.remwarp"))
|
||||
{
|
||||
if (!sender.hasPermission("core.commands.remwarp")) {
|
||||
Core.statusMsg(P, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
String map = args[0];
|
||||
ResultSet rs = sql.querySelect("SELECT name FROM coreWarps WHERE name = '"+map+"'");
|
||||
ResultSet rs = sql.querySelect("SELECT name FROM coreWarps WHERE name = '" + map + "'");
|
||||
try {
|
||||
rs.last();
|
||||
if(rs.getRow() == 0)
|
||||
{
|
||||
if (rs.getRow() == 0) {
|
||||
Core.statusMsg(P, "warp_not_exist", false);
|
||||
return true;
|
||||
}
|
||||
sql.queryUpdate("DELETE FROM coreWarps WHERE name = '"+map+"'");
|
||||
sql.queryUpdate("DELETE FROM coreWarps WHERE name = '" + map + "'");
|
||||
Core.statusMsg(P, "warp_rem_done", true);
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error: "+ex.getLocalizedMessage());
|
||||
System.out.println("Error: " + ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,53 +9,45 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.material.Stairs;
|
||||
|
||||
public class BlockBreak implements Listener {
|
||||
|
||||
public class BlockBreak implements Listener
|
||||
{
|
||||
public BlockBreak(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if(plugin.getConfig().getBoolean("no-change-blocks"))
|
||||
{
|
||||
if(!event.getPlayer().hasPermission("core.rules.blocks.break"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
public BlockBreak(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (plugin.getConfig().getBoolean("no-change-blocks")) {
|
||||
if (!event.getPlayer().hasPermission("core.rules.blocks.break")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(plugin.flowerPots.containsValue(event.getBlock().getLocation())) event.setCancelled(true);
|
||||
if((event.getBlock().getType() == Material.ENDER_CHEST || event.getBlock().getType() == Material.RAILS))
|
||||
{
|
||||
int X = (int)event.getBlock().getLocation().getX();
|
||||
int Y = (int)event.getBlock().getLocation().getY();
|
||||
int Z = (int)event.getBlock().getLocation().getZ();
|
||||
String world = event.getBlock().getLocation().getWorld().getName();
|
||||
String sql = "DELETE FROM coreJumpers WHERE X = '"+X+"' AND Y = '"+Y+"' AND Z = '"+Z+"' AND world = '"+world+"'";
|
||||
AnuraCore.getSql().queryUpdate(sql);
|
||||
}
|
||||
if (plugin.flowerPots.containsValue(event.getBlock().getLocation())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if ((event.getBlock().getType() == Material.ENDER_CHEST || event.getBlock().getType() == Material.RAILS)) {
|
||||
int X = (int) event.getBlock().getLocation().getX();
|
||||
int Y = (int) event.getBlock().getLocation().getY();
|
||||
int Z = (int) event.getBlock().getLocation().getZ();
|
||||
String world = event.getBlock().getLocation().getWorld().getName();
|
||||
String sql = "DELETE FROM coreJumpers WHERE X = '" + X + "' AND Y = '" + Y + "' AND Z = '" + Z + "' AND world = '" + world + "'";
|
||||
AnuraCore.getSql().queryUpdate(sql);
|
||||
} else if (event.getBlock().getState() instanceof Sign) {
|
||||
Sign s = (Sign) event.getBlock().getState();
|
||||
Location loc = s.getLocation();
|
||||
int X = loc.getBlockX();
|
||||
int Y = loc.getBlockY();
|
||||
int Z = loc.getBlockZ();
|
||||
String world = loc.getWorld().getName();
|
||||
String server = plugin.getConfig().getString("server-name");
|
||||
AnuraCore.sql.queryUpdate("DELETE FROM coreWarpSigns WHERE X = '" + X + "' AND Y = '" + Y + "' AND Z = '" + Z + "' AND world = '" + world + "' AND server = '" + server + "'");
|
||||
} else if (event.getBlock().getState().getData() instanceof Stairs) {
|
||||
if (plugin.sittingBlocks.containsValue(event.getBlock())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if(event.getBlock().getState() instanceof Sign)
|
||||
{
|
||||
Sign s = (Sign)event.getBlock().getState();
|
||||
Location loc = s.getLocation();
|
||||
int X = loc.getBlockX();
|
||||
int Y = loc.getBlockY();
|
||||
int Z = loc.getBlockZ();
|
||||
String world = loc.getWorld().getName();
|
||||
String server = plugin.getConfig().getString("server-name");
|
||||
AnuraCore.sql.queryUpdate("DELETE FROM coreWarpSigns WHERE X = '"+X+"' AND Y = '"+Y+"' AND Z = '"+Z+"' AND world = '"+world+"' AND server = '"+server+"'");
|
||||
}
|
||||
else if(event.getBlock().getState().getData() instanceof Stairs)
|
||||
{
|
||||
if(plugin.sittingBlocks.containsValue(event.getBlock()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -8,39 +8,34 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class BlockPlace implements Listener {
|
||||
|
||||
public class BlockPlace implements Listener
|
||||
{
|
||||
public BlockPlace(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if(plugin.getConfig().getBoolean("no-change-blocks"))
|
||||
{
|
||||
if(!event.getPlayer().hasPermission("core.rules.blocks.place"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
if(plugin.flowerPots.containsValue(event.getBlock().getLocation()))
|
||||
{
|
||||
public BlockPlace(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (plugin.getConfig().getBoolean("no-change-blocks")) {
|
||||
if (!event.getPlayer().hasPermission("core.rules.blocks.place")) {
|
||||
event.setCancelled(true);
|
||||
final Block b = event.getBlock();
|
||||
final int pot = Core.getKeyByValue(plugin.flowerPots, b.getLocation());
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
b.setType(Material.BROWN_MUSHROOM);
|
||||
AnuraCore.getInstance().pots.refreshPot(pot);
|
||||
}
|
||||
|
||||
}, 3);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
if (plugin.flowerPots.containsValue(event.getBlock().getLocation())) {
|
||||
event.setCancelled(true);
|
||||
final Block b = event.getBlock();
|
||||
final int pot = Core.getKeyByValue(plugin.flowerPots, b.getLocation());
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
b.setType(Material.BROWN_MUSHROOM);
|
||||
AnuraCore.getInstance().pots.refreshPot(pot);
|
||||
}
|
||||
|
||||
}, 3);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -6,21 +6,18 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
|
||||
public class BlockSpread implements Listener
|
||||
{
|
||||
public BlockSpread(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockSpread(BlockSpreadEvent event)
|
||||
{
|
||||
if(event.getNewState().getType().equals(Material.BROWN_MUSHROOM) && plugin.getConfig().getBoolean("disable-mushroom-spread"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
public class BlockSpread implements Listener {
|
||||
|
||||
public BlockSpread(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockSpread(BlockSpreadEvent event) {
|
||||
if (event.getNewState().getType().equals(Material.BROWN_MUSHROOM) && plugin.getConfig().getBoolean("disable-mushroom-spread")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -7,30 +7,24 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
public class CmdPreprocess implements Listener
|
||||
{
|
||||
public CmdPreprocess(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if(event.getMessage().startsWith("/?"))
|
||||
{
|
||||
if(!event.getPlayer().hasPermission("core.commands.help"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
Core.statusMsg(event.getPlayer(), "help_command_info", true);
|
||||
}
|
||||
}
|
||||
else if(plugin.disableCommandsAdventure.containsKey(event.getPlayer()) && plugin.disableCommandsAdventure.get(event.getPlayer()))
|
||||
{
|
||||
public class CmdPreprocess implements Listener {
|
||||
|
||||
public CmdPreprocess(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
if (event.getMessage().startsWith("/?")) {
|
||||
if (!event.getPlayer().hasPermission("core.commands.help")) {
|
||||
event.setCancelled(true);
|
||||
Core.statusMsg(event.getPlayer(), "no_command_red_mg", ChatColor.YELLOW);
|
||||
Core.statusMsg(event.getPlayer(), "help_command_info", true);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
} else if (plugin.disableCommandsAdventure.containsKey(event.getPlayer()) && plugin.disableCommandsAdventure.get(event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
Core.statusMsg(event.getPlayer(), "no_command_red_mg", ChatColor.YELLOW);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -6,21 +6,18 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
public class EntityDamage implements Listener
|
||||
{
|
||||
public EntityDamage(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
{
|
||||
if(event.getEntity() instanceof Player && plugin.getConfig().getBoolean("no-damage"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
public class EntityDamage implements Listener {
|
||||
|
||||
public EntityDamage(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event.getEntity() instanceof Player && plugin.getConfig().getBoolean("no-damage")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -7,27 +7,22 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class EntityDamageByE implements Listener
|
||||
{
|
||||
public EntityDamageByE(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamageByE(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if(event.getEntity() instanceof ItemFrame && plugin.getConfig().getBoolean("no-change-blocks"))
|
||||
{
|
||||
if(event.getDamager() instanceof Player)
|
||||
{
|
||||
if(!((Player)event.getDamager()).hasPermission("core.rules.blocks.break"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
public class EntityDamageByE implements Listener {
|
||||
|
||||
public EntityDamageByE(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamageByE(EntityDamageByEntityEvent event) {
|
||||
if (event.getEntity() instanceof ItemFrame && plugin.getConfig().getBoolean("no-change-blocks")) {
|
||||
if (event.getDamager() instanceof Player) {
|
||||
if (!((Player) event.getDamager()).hasPermission("core.rules.blocks.break")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -6,25 +6,21 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
|
||||
public class FoodChange implements Listener {
|
||||
|
||||
public class FoodChange implements Listener
|
||||
{
|
||||
public FoodChange(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@EventHandler
|
||||
public void onFoodLChange(FoodLevelChangeEvent event)
|
||||
{
|
||||
if(plugin.getConfig().getBoolean("no-hunger"))
|
||||
{
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
((Player)event.getEntity()).setFoodLevel(20);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
public FoodChange(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFoodLChange(FoodLevelChangeEvent event) {
|
||||
if (plugin.getConfig().getBoolean("no-hunger")) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
((Player) event.getEntity()).setFoodLevel(20);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -6,33 +6,26 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
|
||||
public class HangingEBreak implements Listener {
|
||||
|
||||
public class HangingEBreak implements Listener
|
||||
{
|
||||
public HangingEBreak(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@EventHandler
|
||||
public void onHangingBreakByE(HangingBreakByEntityEvent event)
|
||||
{
|
||||
Player P;
|
||||
if(event.getRemover() instanceof Player)
|
||||
{
|
||||
P = (Player)event.getRemover();
|
||||
public HangingEBreak(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHangingBreakByE(HangingBreakByEntityEvent event) {
|
||||
Player P;
|
||||
if (event.getRemover() instanceof Player) {
|
||||
P = (Player) event.getRemover();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (plugin.getConfig().getBoolean("no-change-blocks")) {
|
||||
if (!P.hasPermission("core.rules.blocks.break")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(plugin.getConfig().getBoolean("no-change-blocks"))
|
||||
{
|
||||
if(!P.hasPermission("core.rules.blocks.break"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -9,27 +9,24 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class InvClick implements Listener
|
||||
{
|
||||
public class InvClick implements Listener {
|
||||
|
||||
private final AnuraCore plugin;
|
||||
public InvClick(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
|
||||
public InvClick(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onInvClick(InventoryClickEvent event)
|
||||
{
|
||||
public void onInvClick(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if(!player.hasPermission("core.inventory.interact") && plugin.getConfig().getBoolean("is-main-lobby"))
|
||||
{
|
||||
if (!player.hasPermission("core.inventory.interact") && plugin.getConfig().getBoolean("is-main-lobby")) {
|
||||
event.setCancelled(true);
|
||||
final Player p = player;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
public void run() {
|
||||
p.setItemOnCursor(new ItemStack(Material.AIR));
|
||||
p.updateInventory();
|
||||
}
|
||||
|
||||
@@ -6,28 +6,24 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
|
||||
public class LeavesDecay implements Listener
|
||||
{
|
||||
public LeavesDecay(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeavesDecay(LeavesDecayEvent event)
|
||||
{
|
||||
if(!plugin.getConfig().getBoolean("enable-leaves-decay"))
|
||||
{
|
||||
Block b = event.getBlock();
|
||||
byte data = b.getData();
|
||||
if((data & 0x4) == 0)
|
||||
{
|
||||
data = (byte) (data | 0x4);
|
||||
}
|
||||
b.setData(data);
|
||||
event.setCancelled(true);
|
||||
public class LeavesDecay implements Listener {
|
||||
|
||||
public LeavesDecay(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeavesDecay(LeavesDecayEvent event) {
|
||||
if (!plugin.getConfig().getBoolean("enable-leaves-decay")) {
|
||||
Block b = event.getBlock();
|
||||
byte data = b.getData();
|
||||
if ((data & 0x4) == 0) {
|
||||
data = (byte) (data | 0x4);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
b.setData(data);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -6,21 +6,18 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
public class PlayerChat implements Listener
|
||||
{
|
||||
public PlayerChat(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
if(event.isAsynchronous())
|
||||
{
|
||||
event.setFormat(event.getPlayer().getDisplayName() + ChatColor.GRAY + ":" + ChatColor.WHITE + " " + event.getMessage());
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
public class PlayerChat implements Listener {
|
||||
|
||||
public PlayerChat(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
if (event.isAsynchronous()) {
|
||||
event.setFormat(event.getPlayer().getDisplayName() + ChatColor.GRAY + ":" + ChatColor.WHITE + " " + event.getMessage());
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -21,196 +20,159 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.material.Stairs;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class PlayerInteract implements Listener
|
||||
{
|
||||
public PlayerInteract(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
final Block block = event.getClickedBlock();
|
||||
if(plugin.selectableJumper.containsKey(event.getPlayer()))
|
||||
{
|
||||
if(event.getPlayer().hasPermission("core.commands.setjumper"))
|
||||
{
|
||||
if(event.getAction().equals(Action.RIGHT_CLICK_BLOCK) || event.getAction().equals(Action.LEFT_CLICK_BLOCK))
|
||||
{
|
||||
String type;
|
||||
if(event.getClickedBlock().getType().equals(Material.ENDER_CHEST))
|
||||
{
|
||||
type = "high";
|
||||
}
|
||||
else if(event.getClickedBlock().getType().equals(Material.RAILS))
|
||||
{
|
||||
type = "far";
|
||||
}
|
||||
else
|
||||
{
|
||||
Core.statusMsg(event.getPlayer(), "setjumper_block_not_supported", false);
|
||||
plugin.selectableJumper.remove(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
Double X = event.getClickedBlock().getLocation().getX();
|
||||
Double Y = event.getClickedBlock().getLocation().getY();
|
||||
Double Z = event.getClickedBlock().getLocation().getZ();
|
||||
String world = event.getClickedBlock().getLocation().getWorld().getName();
|
||||
String sql = "INSERT INTO coreJumpers(X,Y,Z,world,height,type) VALUES('"+X+"','"+Y+"','"+Z+"','"+world+"','"+plugin.selectableJumper.get(event.getPlayer())+"','"+type+"')";
|
||||
AnuraCore.getSql().queryUpdate(sql);
|
||||
plugin.selectableJumper.remove(event.getPlayer());
|
||||
Core.statusMsg(event.getPlayer(), "setjumper_done", true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(block != null)
|
||||
{
|
||||
if(block.getState() instanceof Sign && event.getAction().equals(Action.RIGHT_CLICK_BLOCK))
|
||||
{
|
||||
Sign sign = (Sign)block.getState();
|
||||
Location loc = sign.getLocation();
|
||||
Player P = event.getPlayer();
|
||||
int X = loc.getBlockX();
|
||||
int Y = loc.getBlockY();
|
||||
int Z = loc.getBlockZ();
|
||||
String world = loc.getWorld().getName();
|
||||
String server = plugin.getConfig().getString("server-name");
|
||||
ResultSet rs = AnuraCore.sql.querySelect("SELECT type, value FROM coreWarpSigns WHERE X = '"+X+"' AND Y = '"+Y+"' AND Z = '"+Z+"' AND world = '"+world+"' AND server = '"+server+"'");
|
||||
try {
|
||||
rs.last();
|
||||
if(rs.getRow() != 0)
|
||||
{
|
||||
rs.first();
|
||||
if(rs.getString("type").equalsIgnoreCase("warp"))
|
||||
{
|
||||
String warp = rs.getString("value");
|
||||
ResultSet rs2 = AnuraCore.sql.querySelect("SELECT world, X, Y, Z FROM coreWarps WHERE name = '"+warp+"' AND server = '"+plugin.getConfig().getString("server-name")+"'");
|
||||
rs2.last();
|
||||
if(rs2.getRow() == 0)
|
||||
{
|
||||
Core.statusMsg(P, "warpsign_warp_not_exist", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(plugin.getServer().getWorld(rs2.getString("world")) != null)
|
||||
{
|
||||
Location target = new Location(plugin.getServer().getWorld(rs2.getString("world")), rs2.getInt("X"), rs2.getInt("Y"), rs2.getInt("Z"));
|
||||
P.teleport(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(rs.getString("type").equalsIgnoreCase("spawn"))
|
||||
{
|
||||
P.teleport(loc.getWorld().getSpawnLocation());
|
||||
}
|
||||
else if(rs.getString("type").equalsIgnoreCase("server"))
|
||||
{
|
||||
String targetServer = rs.getString("value");
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(targetServer);
|
||||
P.sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLException in playerInteract: "+ex.getLocalizedMessage());
|
||||
} catch (IOException ex) {
|
||||
System.out.println("IOException in playerInteract: "+ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if(block.getState().getData() instanceof Stairs)
|
||||
{
|
||||
if(plugin.stairMode.contains(event.getPlayer()) && event.getAction().equals(Action.RIGHT_CLICK_BLOCK))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
if(plugin.sittableBlocks.contains(block))
|
||||
{
|
||||
plugin.sittableBlocks.remove(block);
|
||||
Core.getTools().sendStatusMsg(event.getPlayer(), "Removed!", false);
|
||||
int X = block.getLocation().getBlockX();
|
||||
int Y = block.getLocation().getBlockY();
|
||||
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+"'");
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.sittableBlocks.add(block);
|
||||
Core.getTools().sendStatusMsg(event.getPlayer(), "Added!", true);
|
||||
int X = block.getLocation().getBlockX();
|
||||
int Y = block.getLocation().getBlockY();
|
||||
int Z = block.getLocation().getBlockZ();
|
||||
Core.getMySql().queryUpdate("INSERT INTO coreStairs(server,world,X,Y,Z) VALUES('"+plugin.getConfig().getString("server-name")+"','"+block.getWorld().getName()+"','"+X+"','"+Y+"','"+Z+"')");
|
||||
}
|
||||
}
|
||||
else if(plugin.getConfig().getBoolean("allow-stairs-sit") && event.getAction().equals(Action.RIGHT_CLICK_BLOCK) && plugin.sittableBlocks.contains(block))
|
||||
{
|
||||
if(plugin.sittingPlayer.containsKey(event.getPlayer()))
|
||||
{
|
||||
Core.statusMsg(event.getPlayer(), "sitting_already", false);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if(plugin.sittingBlocks.containsValue(block))
|
||||
{
|
||||
Core.statusMsg(event.getPlayer(), "sitting_occupied", false);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stairs s = (Stairs)block.getState().getData();
|
||||
if(!s.isInverted())
|
||||
{
|
||||
Location loc = block.getLocation();
|
||||
loc = loc.add(0.5, 0.05, 0.5);
|
||||
loc.add(s.getFacing().getModX()*0.2, 0, s.getFacing().getModZ()*0.2);
|
||||
Arrow a = loc.getWorld().spawnArrow(loc, new Vector(0,0,0), 0, 0);
|
||||
a.setPassenger(event.getPlayer());
|
||||
plugin.sittingPlayer.put(event.getPlayer(), a);
|
||||
plugin.sittingBlocks.put(event.getPlayer(), block);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(plugin.flowerPots.containsValue(block.getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
final Player p = event.getPlayer();
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public class PlayerInteract implements Listener {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
p.sendBlockChange(block.getLocation(), Material.AIR, (byte)0);
|
||||
public PlayerInteract(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
final Block block = event.getClickedBlock();
|
||||
if (plugin.selectableJumper.containsKey(event.getPlayer())) {
|
||||
if (event.getPlayer().hasPermission("core.commands.setjumper")) {
|
||||
if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK) || event.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
|
||||
String type;
|
||||
if (event.getClickedBlock().getType().equals(Material.ENDER_CHEST)) {
|
||||
type = "high";
|
||||
} else if (event.getClickedBlock().getType().equals(Material.RAILS)) {
|
||||
type = "far";
|
||||
} else {
|
||||
Core.statusMsg(event.getPlayer(), "setjumper_block_not_supported", false);
|
||||
plugin.selectableJumper.remove(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
Double X = event.getClickedBlock().getLocation().getX();
|
||||
Double Y = event.getClickedBlock().getLocation().getY();
|
||||
Double Z = event.getClickedBlock().getLocation().getZ();
|
||||
String world = event.getClickedBlock().getLocation().getWorld().getName();
|
||||
String sql = "INSERT INTO coreJumpers(X,Y,Z,world,height,type) VALUES('" + X + "','" + Y + "','" + Z + "','" + world + "','" + plugin.selectableJumper.get(event.getPlayer()) + "','" + type + "')";
|
||||
AnuraCore.getSql().queryUpdate(sql);
|
||||
plugin.selectableJumper.remove(event.getPlayer());
|
||||
Core.statusMsg(event.getPlayer(), "setjumper_done", true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else if (block != null) {
|
||||
if (block.getState() instanceof Sign && event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||
Sign sign = (Sign) block.getState();
|
||||
Location loc = sign.getLocation();
|
||||
Player P = event.getPlayer();
|
||||
int X = loc.getBlockX();
|
||||
int Y = loc.getBlockY();
|
||||
int Z = loc.getBlockZ();
|
||||
String world = loc.getWorld().getName();
|
||||
String server = plugin.getConfig().getString("server-name");
|
||||
ResultSet rs = AnuraCore.sql.querySelect("SELECT type, value FROM coreWarpSigns WHERE X = '" + X + "' AND Y = '" + Y + "' AND Z = '" + Z + "' AND world = '" + world + "' AND server = '" + server + "'");
|
||||
try {
|
||||
rs.last();
|
||||
if (rs.getRow() != 0) {
|
||||
rs.first();
|
||||
if (rs.getString("type").equalsIgnoreCase("warp")) {
|
||||
String warp = rs.getString("value");
|
||||
ResultSet rs2 = AnuraCore.sql.querySelect("SELECT world, X, Y, Z FROM coreWarps WHERE name = '" + warp + "' AND server = '" + plugin.getConfig().getString("server-name") + "'");
|
||||
rs2.last();
|
||||
if (rs2.getRow() == 0) {
|
||||
Core.statusMsg(P, "warpsign_warp_not_exist", false);
|
||||
} else {
|
||||
if (plugin.getServer().getWorld(rs2.getString("world")) != null) {
|
||||
Location target = new Location(plugin.getServer().getWorld(rs2.getString("world")), rs2.getInt("X"), rs2.getInt("Y"), rs2.getInt("Z"));
|
||||
P.teleport(target);
|
||||
}
|
||||
}
|
||||
} else if (rs.getString("type").equalsIgnoreCase("spawn")) {
|
||||
P.teleport(loc.getWorld().getSpawnLocation());
|
||||
} else if (rs.getString("type").equalsIgnoreCase("server")) {
|
||||
String targetServer = rs.getString("value");
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(targetServer);
|
||||
P.sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
|
||||
}
|
||||
|
||||
}, 3);
|
||||
plugin.pots.playerFoundPot(event.getPlayer(), Core.getKeyByValue(plugin.flowerPots, block.getLocation()));
|
||||
}
|
||||
}
|
||||
if(plugin.getConfig().getBoolean("no-change-blocks"))
|
||||
{
|
||||
if(!event.getPlayer().hasPermission("core.rules.blocks.interact"))
|
||||
{
|
||||
Boolean cancelled = true;
|
||||
if(event.getAction().equals(Action.RIGHT_CLICK_BLOCK))
|
||||
{
|
||||
if(event.getClickedBlock().getType().equals(Material.STONE_BUTTON)) cancelled = false;
|
||||
else if(event.getClickedBlock().getType().equals(Material.WOOD_BUTTON)) cancelled = false;
|
||||
}
|
||||
else if(event.getAction().equals(Action.PHYSICAL)) cancelled = false;
|
||||
else if(event.getAction().equals(Action.RIGHT_CLICK_AIR))
|
||||
{
|
||||
if(event.getPlayer().getItemInHand().getType().equals(Material.BOW)) cancelled = false;
|
||||
else if(event.getPlayer().getItemInHand().getType().equals(Material.EXP_BOTTLE)) cancelled = false;
|
||||
}
|
||||
event.setCancelled(cancelled);
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLException in playerInteract: " + ex.getLocalizedMessage());
|
||||
} catch (IOException ex) {
|
||||
System.out.println("IOException in playerInteract: " + ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
} else if (block.getState().getData() instanceof Stairs) {
|
||||
if (plugin.stairMode.contains(event.getPlayer()) && event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||
event.setCancelled(true);
|
||||
if (plugin.sittableBlocks.contains(block)) {
|
||||
plugin.sittableBlocks.remove(block);
|
||||
Core.getTools().sendStatusMsg(event.getPlayer(), "Removed!", false);
|
||||
int X = block.getLocation().getBlockX();
|
||||
int Y = block.getLocation().getBlockY();
|
||||
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 + "'");
|
||||
} else {
|
||||
plugin.sittableBlocks.add(block);
|
||||
Core.getTools().sendStatusMsg(event.getPlayer(), "Added!", true);
|
||||
int X = block.getLocation().getBlockX();
|
||||
int Y = block.getLocation().getBlockY();
|
||||
int Z = block.getLocation().getBlockZ();
|
||||
Core.getMySql().queryUpdate("INSERT INTO coreStairs(server,world,X,Y,Z) VALUES('" + plugin.getConfig().getString("server-name") + "','" + block.getWorld().getName() + "','" + X + "','" + Y + "','" + Z + "')");
|
||||
}
|
||||
} else if (plugin.getConfig().getBoolean("allow-stairs-sit") && event.getAction().equals(Action.RIGHT_CLICK_BLOCK) && plugin.sittableBlocks.contains(block)) {
|
||||
if (plugin.sittingPlayer.containsKey(event.getPlayer())) {
|
||||
Core.statusMsg(event.getPlayer(), "sitting_already", false);
|
||||
event.setCancelled(true);
|
||||
} else if (plugin.sittingBlocks.containsValue(block)) {
|
||||
Core.statusMsg(event.getPlayer(), "sitting_occupied", false);
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
Stairs s = (Stairs) block.getState().getData();
|
||||
if (!s.isInverted()) {
|
||||
Location loc = block.getLocation();
|
||||
loc = loc.add(0.5, 0.05, 0.5);
|
||||
loc.add(s.getFacing().getModX() * 0.2, 0, s.getFacing().getModZ() * 0.2);
|
||||
Arrow a = loc.getWorld().spawnArrow(loc, new Vector(0, 0, 0), 0, 0);
|
||||
a.setPassenger(event.getPlayer());
|
||||
plugin.sittingPlayer.put(event.getPlayer(), a);
|
||||
plugin.sittingBlocks.put(event.getPlayer(), block);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (plugin.flowerPots.containsValue(block.getLocation())) {
|
||||
event.setCancelled(true);
|
||||
final Player p = event.getPlayer();
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
p.sendBlockChange(block.getLocation(), Material.AIR, (byte) 0);
|
||||
}
|
||||
|
||||
}, 3);
|
||||
plugin.pots.playerFoundPot(event.getPlayer(), Core.getKeyByValue(plugin.flowerPots, block.getLocation()));
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
if (plugin.getConfig().getBoolean("no-change-blocks")) {
|
||||
if (!event.getPlayer().hasPermission("core.rules.blocks.interact")) {
|
||||
Boolean cancelled = true;
|
||||
if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||
if (event.getClickedBlock().getType().equals(Material.STONE_BUTTON)) {
|
||||
cancelled = false;
|
||||
} else if (event.getClickedBlock().getType().equals(Material.WOOD_BUTTON)) {
|
||||
cancelled = false;
|
||||
}
|
||||
} else if (event.getAction().equals(Action.PHYSICAL)) {
|
||||
cancelled = false;
|
||||
} else if (event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
|
||||
if (event.getPlayer().getItemInHand().getType().equals(Material.BOW)) {
|
||||
cancelled = false;
|
||||
} else if (event.getPlayer().getItemInHand().getType().equals(Material.EXP_BOTTLE)) {
|
||||
cancelled = false;
|
||||
}
|
||||
}
|
||||
event.setCancelled(cancelled);
|
||||
}
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -9,53 +9,41 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
public class PlayerInteractE implements Listener
|
||||
{
|
||||
public PlayerInteractE(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractE(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if(event.getRightClicked().getType().equals(EntityType.ITEM_FRAME) && plugin.getConfig().getBoolean("no-change-blocks"))
|
||||
{
|
||||
if(!event.getPlayer().hasPermission("core.rules.blocks.interact"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
public class PlayerInteractE implements Listener {
|
||||
|
||||
public PlayerInteractE(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractE(PlayerInteractEntityEvent event) {
|
||||
if (event.getRightClicked().getType().equals(EntityType.ITEM_FRAME) && plugin.getConfig().getBoolean("no-change-blocks")) {
|
||||
if (!event.getPlayer().hasPermission("core.rules.blocks.interact")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if(event.getRightClicked().getType().equals(EntityType.CHICKEN) && plugin.getConfig().getBoolean("golf"))
|
||||
{
|
||||
Player P = event.getPlayer();
|
||||
// Item i = (Item)event.getRightClicked();
|
||||
Chicken b = (Chicken)event.getRightClicked();
|
||||
if(P.getItemInHand().getType().equals(Material.STICK))
|
||||
{
|
||||
int power;
|
||||
|
||||
if(!plugin.golfPower.containsKey(P))
|
||||
{
|
||||
power = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
power = plugin.golfPower.get(P);
|
||||
power++;
|
||||
}
|
||||
if(power > 40)
|
||||
{
|
||||
power = 40;
|
||||
}
|
||||
System.out.println(power);
|
||||
plugin.golfPower.put(P, power);
|
||||
plugin.releaseGolf.put(P, false);
|
||||
plugin.golfBall.put(P, b);
|
||||
|
||||
} else if (event.getRightClicked().getType().equals(EntityType.CHICKEN) && plugin.getConfig().getBoolean("golf")) {
|
||||
Player P = event.getPlayer();
|
||||
Chicken b = (Chicken) event.getRightClicked();
|
||||
if (P.getItemInHand().getType().equals(Material.STICK)) {
|
||||
int power;
|
||||
|
||||
if (!plugin.golfPower.containsKey(P)) {
|
||||
power = 1;
|
||||
} else {
|
||||
power = plugin.golfPower.get(P);
|
||||
power++;
|
||||
}
|
||||
if (power > 40) {
|
||||
power = 40;
|
||||
}
|
||||
System.out.println(power);
|
||||
plugin.golfPower.put(P, power);
|
||||
plugin.releaseGolf.put(P, false);
|
||||
plugin.golfBall.put(P, b);
|
||||
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -5,50 +5,42 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class PlayerJoin implements Listener {
|
||||
|
||||
public class PlayerJoin implements Listener
|
||||
{
|
||||
public PlayerJoin(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
ResultSet rs;
|
||||
try {
|
||||
rs = AnuraCore.getSql().querySelect("SELECT name FROM players WHERE uuid LIKE '"+uuid.toString()+"'");
|
||||
if(rs==null) {
|
||||
event.getPlayer().kickPlayer("Please try again");
|
||||
event.setJoinMessage(null);
|
||||
return;
|
||||
}
|
||||
rs.last();
|
||||
if(rs.getRow() != 1)
|
||||
{
|
||||
AnuraCore.getSql().queryUpdate("INSERT INTO players(`uuid`,`game`,`waiting`,`gameName`) VALUES('"+uuid.toString()+"','none','none','')");
|
||||
}
|
||||
public PlayerJoin(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
ResultSet rs;
|
||||
try {
|
||||
rs = AnuraCore.getSql().querySelect("SELECT name FROM players WHERE uuid LIKE '" + uuid.toString() + "'");
|
||||
if (rs == null) {
|
||||
event.getPlayer().kickPlayer("Please try again");
|
||||
event.setJoinMessage(null);
|
||||
return;
|
||||
}
|
||||
catch(SQLException e) {
|
||||
rs.last();
|
||||
if (rs.getRow() != 1) {
|
||||
AnuraCore.getSql().queryUpdate("INSERT INTO players(`uuid`,`game`,`waiting`,`gameName`) VALUES('" + uuid.toString() + "','none','none','')");
|
||||
}
|
||||
event.setJoinMessage(null);
|
||||
plugin.pots.refreshCache(event.getPlayer());
|
||||
plugin.pots.refreshPlayer(event.getPlayer());
|
||||
plugin.getFeatures().updateFeatures(event.getPlayer());
|
||||
plugin.disableCommandsAdventure.put(event.getPlayer(), false);
|
||||
if(plugin.getConfig().getBoolean("on-join-to-spawn"))
|
||||
{
|
||||
event.getPlayer().teleport(event.getPlayer().getWorld().getSpawnLocation());
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
event.setJoinMessage(null);
|
||||
plugin.pots.refreshCache(event.getPlayer());
|
||||
plugin.pots.refreshPlayer(event.getPlayer());
|
||||
plugin.getFeatures().updateFeatures(event.getPlayer());
|
||||
plugin.disableCommandsAdventure.put(event.getPlayer(), false);
|
||||
if (plugin.getConfig().getBoolean("on-join-to-spawn")) {
|
||||
event.getPlayer().teleport(event.getPlayer().getWorld().getSpawnLocation());
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -9,32 +9,30 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
|
||||
public class PlayerKick implements Listener
|
||||
{
|
||||
public PlayerKick(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerKick(PlayerKickEvent event)
|
||||
{
|
||||
AnuraCore.getInstance().disableCommandsAdventure.remove(event.getPlayer());
|
||||
if(!plugin.getConfig().getBoolean("is-main-lobby"))
|
||||
{
|
||||
try {
|
||||
Core.endSitting(event.getPlayer());
|
||||
event.setCancelled(true);
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF("lobby");
|
||||
event.getPlayer().sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
|
||||
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
public class PlayerKick implements Listener {
|
||||
|
||||
public PlayerKick(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
AnuraCore.getInstance().disableCommandsAdventure.remove(event.getPlayer());
|
||||
if (!plugin.getConfig().getBoolean("is-main-lobby")) {
|
||||
try {
|
||||
Core.endSitting(event.getPlayer());
|
||||
event.setCancelled(true);
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF("lobby");
|
||||
event.getPlayer().sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
|
||||
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
event.setLeaveMessage(null);
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
event.setLeaveMessage(null);
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -15,99 +15,92 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class PlayerMove implements Listener
|
||||
{
|
||||
public class PlayerMove implements Listener {
|
||||
|
||||
private final AnuraCore plugin;
|
||||
public PlayerMove(AnuraCore plugin)
|
||||
{
|
||||
|
||||
public PlayerMove(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
Block block = event.getTo().clone().getBlock();
|
||||
Block under = block.getLocation().subtract(0,1,0).getBlock();
|
||||
|
||||
if(event.getTo().getY() <= -40 && plugin.getConfig().getBoolean("no-void-death"))
|
||||
{
|
||||
Block under = block.getLocation().subtract(0, 1, 0).getBlock();
|
||||
|
||||
if (event.getTo().getY() <= -40 && plugin.getConfig().getBoolean("no-void-death")) {
|
||||
p.performCommand("spawn");
|
||||
}
|
||||
if(block.getType().equals(Material.CARPET) && under.getType().equals(Material.SIGN_POST))
|
||||
{
|
||||
if (block.getType().equals(Material.CARPET) && under.getType().equals(Material.SIGN_POST)) {
|
||||
p.setWalkSpeed(0.6F);
|
||||
}
|
||||
else if(block.getType().equals(Material.CARPET) && under.getType().equals(Material.ENDER_CHEST))
|
||||
{
|
||||
} else if (block.getType().equals(Material.CARPET) && under.getType().equals(Material.ENDER_CHEST)) {
|
||||
try {
|
||||
double X = under.getLocation().getX();
|
||||
double Y = under.getLocation().getY();
|
||||
double Z = under.getLocation().getZ();
|
||||
String world = under.getLocation().getWorld().getName();
|
||||
String sql = "SELECT * FROM coreJumpers WHERE X = '"+(int)X+"' AND Y = '"+(int)Y+"' AND Z = '"+(int)Z+"' AND world = '"+world+"' AND type = 'high'";
|
||||
String sql = "SELECT * FROM coreJumpers WHERE X = '" + (int) X + "' AND Y = '" + (int) Y + "' AND Z = '" + (int) Z + "' AND world = '" + world + "' AND type = 'high'";
|
||||
ResultSet rs = AnuraCore.getSql().querySelect(sql);
|
||||
rs.last();
|
||||
if(rs.getRow() > 0)
|
||||
{
|
||||
p.setVelocity(new Vector(0,rs.getDouble("height"),0));
|
||||
ParticleEffect.FIREWORKS_SPARK.display(p.getLocation(), (float)0.1, (float)0.1, (float)0.1, (float)0.3, 10);
|
||||
if (rs.getRow() > 0) {
|
||||
p.setVelocity(new Vector(0, rs.getDouble("height"), 0));
|
||||
ParticleEffect.FIREWORKS_SPARK.display(p.getLocation(), (float) 0.1, (float) 0.1, (float) 0.1, (float) 0.3, 10);
|
||||
}
|
||||
p.setWalkSpeed(0.2F);
|
||||
} catch (SQLException ex) {
|
||||
System.err.println(ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
else if(block.getType().equals(Material.CARPET) && under.getType().equals(Material.RAILS))
|
||||
{
|
||||
|
||||
} else if (block.getType().equals(Material.CARPET) && under.getType().equals(Material.RAILS)) {
|
||||
try {
|
||||
double X = under.getLocation().getX();
|
||||
double Y = under.getLocation().getY();
|
||||
double Z = under.getLocation().getZ();
|
||||
String world = under.getLocation().getWorld().getName();
|
||||
String sql = "SELECT * FROM coreJumpers WHERE X = '"+(int)X+"' AND Y = '"+(int)Y+"' AND Z = '"+(int)Z+"' AND world = '"+world+"' AND type = 'far'";
|
||||
String sql = "SELECT * FROM coreJumpers WHERE X = '" + (int) X + "' AND Y = '" + (int) Y + "' AND Z = '" + (int) Z + "' AND world = '" + world + "' AND type = 'far'";
|
||||
ResultSet rs = AnuraCore.getSql().querySelect(sql);
|
||||
rs.last();
|
||||
if(rs.getRow() > 0)
|
||||
{
|
||||
p.setVelocity(p.getLocation().getDirection().multiply(new Vector(rs.getDouble("height"),1,rs.getDouble("height"))));
|
||||
if (rs.getRow() > 0) {
|
||||
p.setVelocity(p.getLocation().getDirection().multiply(new Vector(rs.getDouble("height"), 1, rs.getDouble("height"))));
|
||||
p.setVelocity(p.getVelocity().setY(1.3));
|
||||
ParticleEffect.LAVA.display(p.getLocation(), (float)0.1, (float)0.1, (float)0.1, (float)0.3, 10);
|
||||
ParticleEffect.LAVA.display(p.getLocation(), (float) 0.1, (float) 0.1, (float) 0.1, (float) 0.3, 10);
|
||||
p.playSound(p.getLocation(), Sound.EXPLODE, 1, 1);
|
||||
}
|
||||
p.setWalkSpeed(0.2F);
|
||||
} catch (SQLException ex) {
|
||||
System.err.println(ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p.setWalkSpeed(0.2F);
|
||||
}
|
||||
Block sign = null;
|
||||
Block isSign = block.getLocation().getWorld().getBlockAt(block.getLocation().add(0, 1, 0));
|
||||
if(isSign.getType().equals(Material.WALL_SIGN))
|
||||
{
|
||||
if (isSign.getType().equals(Material.WALL_SIGN)) {
|
||||
sign = isSign;
|
||||
}
|
||||
else if(block.getType().equals(Material.WALL_SIGN))
|
||||
{
|
||||
} else if (block.getType().equals(Material.WALL_SIGN)) {
|
||||
sign = block;
|
||||
}
|
||||
if(sign != null && !event.getPlayer().hasPermission("core.rules.hideSign"))
|
||||
{
|
||||
Sign s = (Sign)sign.getState().getData();
|
||||
if (sign != null && !event.getPlayer().hasPermission("core.rules.hideSign")) {
|
||||
Sign s = (Sign) sign.getState().getData();
|
||||
BlockFace bf = s.getFacing();
|
||||
if(bf.equals(BlockFace.EAST)) event.getPlayer().setVelocity(new Vector(0.3,0,0));
|
||||
if(bf.equals(BlockFace.WEST)) event.getPlayer().setVelocity(new Vector(-0.3,0,0));
|
||||
if(bf.equals(BlockFace.SOUTH)) event.getPlayer().setVelocity(new Vector(0,0,0.3));
|
||||
if(bf.equals(BlockFace.NORTH)) event.getPlayer().setVelocity(new Vector(0,0,-0.3));
|
||||
if (bf.equals(BlockFace.EAST)) {
|
||||
event.getPlayer().setVelocity(new Vector(0.3, 0, 0));
|
||||
}
|
||||
if (bf.equals(BlockFace.WEST)) {
|
||||
event.getPlayer().setVelocity(new Vector(-0.3, 0, 0));
|
||||
}
|
||||
if (bf.equals(BlockFace.SOUTH)) {
|
||||
event.getPlayer().setVelocity(new Vector(0, 0, 0.3));
|
||||
}
|
||||
if (bf.equals(BlockFace.NORTH)) {
|
||||
event.getPlayer().setVelocity(new Vector(0, 0, -0.3));
|
||||
}
|
||||
}
|
||||
if(!plugin.lastLoc.containsKey(p) || !plugin.lastLoc.get(p).getWorld().equals(p.getLocation().getWorld()) || plugin.lastLoc.get(p).distance(p.getLocation()) > 1)
|
||||
{
|
||||
if (!plugin.lastLoc.containsKey(p) || !plugin.lastLoc.get(p).getWorld().equals(p.getLocation().getWorld()) || plugin.lastLoc.get(p).distance(p.getLocation()) > 1) {
|
||||
plugin.pots.refreshPlayer(p);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,16 +7,14 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class PlayerQuit implements Listener
|
||||
{
|
||||
public PlayerQuit(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
public class PlayerQuit implements Listener {
|
||||
|
||||
public PlayerQuit(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
event.setQuitMessage(null);
|
||||
Core.endSitting(event.getPlayer());
|
||||
AnuraCore.getInstance().disableCommandsAdventure.remove(event.getPlayer());
|
||||
|
||||
@@ -13,38 +13,34 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.Stairs;
|
||||
|
||||
public class PlayerTeleport implements Listener
|
||||
{
|
||||
public PlayerTeleport(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
if(plugin.sittingPlayer.containsKey(event.getPlayer()) && !event.getCause().equals(TeleportCause.PLUGIN))
|
||||
{
|
||||
if(event.getPlayer().isSneaking())
|
||||
{
|
||||
Player P = event.getPlayer();
|
||||
Block b = plugin.sittingBlocks.get(P);
|
||||
MaterialData md = b.getState().getData();
|
||||
if(md instanceof Stairs)
|
||||
{
|
||||
Stairs s = (Stairs)md;
|
||||
Location loc = b.getRelative(s.getFacing()).getLocation();
|
||||
Arrow a = plugin.sittingPlayer.get(P);
|
||||
event.setTo(loc);
|
||||
P.setSneaking(false);
|
||||
a.remove();
|
||||
plugin.sittingPlayer.remove(P);
|
||||
plugin.sittingBlocks.remove(P);
|
||||
return;
|
||||
}
|
||||
public class PlayerTeleport implements Listener {
|
||||
|
||||
public PlayerTeleport(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
if (plugin.sittingPlayer.containsKey(event.getPlayer()) && !event.getCause().equals(TeleportCause.PLUGIN)) {
|
||||
if (event.getPlayer().isSneaking()) {
|
||||
Player P = event.getPlayer();
|
||||
Block b = plugin.sittingBlocks.get(P);
|
||||
MaterialData md = b.getState().getData();
|
||||
if (md instanceof Stairs) {
|
||||
Stairs s = (Stairs) md;
|
||||
Location loc = b.getRelative(s.getFacing()).getLocation();
|
||||
Arrow a = plugin.sittingPlayer.get(P);
|
||||
event.setTo(loc);
|
||||
P.setSneaking(false);
|
||||
a.remove();
|
||||
plugin.sittingPlayer.remove(P);
|
||||
plugin.sittingBlocks.remove(P);
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -13,127 +13,106 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
public class SignChange implements Listener {
|
||||
|
||||
public class SignChange implements Listener
|
||||
{
|
||||
public SignChange(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@EventHandler
|
||||
public void onSignChange(SignChangeEvent event)
|
||||
{
|
||||
|
||||
if(event.getLine(0).equalsIgnoreCase("[Warp]"))
|
||||
{
|
||||
if(!event.getPlayer().hasPermission("core.signs.warp"))
|
||||
{
|
||||
event.setLine(0, ChatColor.STRIKETHROUGH + "[Warp]");
|
||||
event.setLine(1, ChatColor.RED + "You don't");
|
||||
event.setLine(2, ChatColor.RED + "have");
|
||||
event.setLine(3, ChatColor.RED + "Permission!");
|
||||
return;
|
||||
}
|
||||
if(event.getLine(1).equalsIgnoreCase("warp"))
|
||||
{
|
||||
ResultSet rs = AnuraCore.sql.querySelect("SELECT name FROM coreWarps WHERE name = '"+event.getLine(2)+"'");
|
||||
try {
|
||||
rs.last();
|
||||
if(rs.getRow() == 0)
|
||||
{
|
||||
event.setLine(0, ChatColor.STRIKETHROUGH+ "[Warp]");
|
||||
event.setLine(1, ChatColor.RED + "Der Warp");
|
||||
event.setLine(2, ChatColor.YELLOW + event.getLine(2) + ChatColor.RED + "exis-");
|
||||
event.setLine(3, ChatColor.RED + "tiert nicht!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Location loc = event.getBlock().getLocation();
|
||||
int X = loc.getBlockX();
|
||||
int Y = loc.getBlockY();
|
||||
int Z = loc.getBlockZ();
|
||||
String world = loc.getWorld().getName();
|
||||
String server = plugin.getConfig().getString("server-name");
|
||||
AnuraCore.sql.queryUpdate("INSERT INTO coreWarpSigns(X,Y,Z,world,server,type,value,info) VALUES('"+X+"','"+Y+"','"+Z+"','"+world+"','"+server+"','warp','"+event.getLine(2)+"','"+event.getLine(3)+"')");
|
||||
event.setLine(0, "["+ChatColor.GREEN+"Warp"+ChatColor.BLACK+"]");
|
||||
event.setLine(1, ChatColor.DARK_GRAY+"--------");
|
||||
event.setLine(2, ChatColor.AQUA + event.getLine(2));
|
||||
event.setLine(3, ChatColor.BLUE + event.getLine(3));
|
||||
Core.statusMsg(event.getPlayer(), "warpsign_created", true);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error: "+ex.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
else if(event.getLine(1).equalsIgnoreCase("spawn"))
|
||||
{
|
||||
Location loc = event.getBlock().getLocation();
|
||||
int X = loc.getBlockX();
|
||||
int Y = loc.getBlockY();
|
||||
int Z = loc.getBlockZ();
|
||||
String world = loc.getWorld().getName();
|
||||
String server = plugin.getConfig().getString("server-name");
|
||||
AnuraCore.sql.queryUpdate("INSERT INTO coreWarpSigns(X,Y,Z,world,server,type,value,info) VALUES('"+X+"','"+Y+"','"+Z+"','"+world+"','"+server+"','spawn','none','"+event.getLine(3)+"')");
|
||||
event.setLine(0, ChatColor.DARK_GRAY + "---------");
|
||||
event.setLine(1, ChatColor.BLACK + "["+ChatColor.GREEN + "Spawn"+ ChatColor.BLACK + "]");
|
||||
event.setLine(2, ChatColor.DARK_GRAY + "---------");
|
||||
event.setLine(3, ChatColor.BLUE + event.getLine(3));
|
||||
Core.statusMsg(event.getPlayer(), "spawnsign_created", true);
|
||||
}
|
||||
else if(event.getLine(1).equalsIgnoreCase("server"))
|
||||
{
|
||||
Location loc = event.getBlock().getLocation();
|
||||
int X = loc.getBlockX();
|
||||
int Y = loc.getBlockY();
|
||||
int Z = loc.getBlockZ();
|
||||
String world = loc.getWorld().getName();
|
||||
String server = event.getLine(2);
|
||||
String curServer = plugin.getConfig().getString("server-name");
|
||||
AnuraCore.sql.queryUpdate("INSERT INTO coreWarpSigns(X,Y,Z,world,server,type,value,info) VALUES('"+X+"','"+Y+"','"+Z+"','"+world+"','"+curServer+"','server','"+server+"','"+event.getLine(3)+"')");
|
||||
event.setLine(0, ChatColor.BLACK + "["+ChatColor.GREEN + "Server"+ ChatColor.BLACK + "]");
|
||||
event.setLine(1, ChatColor.GREEN + "--"+ChatColor.DARK_GRAY+"/"+ChatColor.GREEN+"--");
|
||||
event.setLine(2, ChatColor.AQUA + event.getLine(2));
|
||||
event.setLine(3, ChatColor.BLUE + event.getLine(3));
|
||||
Core.statusMsg(event.getPlayer(), "serversign_created", true);
|
||||
}
|
||||
public SignChange(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
|
||||
if (event.getLine(0).equalsIgnoreCase("[Warp]")) {
|
||||
if (!event.getPlayer().hasPermission("core.signs.warp")) {
|
||||
event.setLine(0, ChatColor.STRIKETHROUGH + "[Warp]");
|
||||
event.setLine(1, ChatColor.RED + "You don't");
|
||||
event.setLine(2, ChatColor.RED + "have");
|
||||
event.setLine(3, ChatColor.RED + "Permission!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(event.getPlayer().hasPermission("core.signs.chars"))
|
||||
{
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
String l = event.getLine(i);
|
||||
l = ChatColor.translateAlternateColorCodes('&', l);
|
||||
if(l.contains("%"))
|
||||
{
|
||||
String[] parts = l.split("%");
|
||||
ArrayList<Entry<String, String>> toReplace = new ArrayList<>();
|
||||
Boolean first = true;
|
||||
for(String s : parts)
|
||||
{
|
||||
if(!first)
|
||||
{
|
||||
String num = s.split(" ")[0];
|
||||
if(Core.isInteger(num))
|
||||
{
|
||||
int number = Integer.valueOf(num);
|
||||
Entry<String, String> e = new SimpleEntry<>("%"+number, Character.toString((char)number));
|
||||
toReplace.add(e);
|
||||
}
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
for(Entry<String, String> entry : toReplace)
|
||||
{
|
||||
l = l.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
event.setLine(i, l);
|
||||
if (event.getLine(1).equalsIgnoreCase("warp")) {
|
||||
ResultSet rs = AnuraCore.sql.querySelect("SELECT name FROM coreWarps WHERE name = '" + event.getLine(2) + "'");
|
||||
try {
|
||||
rs.last();
|
||||
if (rs.getRow() == 0) {
|
||||
event.setLine(0, ChatColor.STRIKETHROUGH + "[Warp]");
|
||||
event.setLine(1, ChatColor.RED + "Der Warp");
|
||||
event.setLine(2, ChatColor.YELLOW + event.getLine(2) + ChatColor.RED + "exis-");
|
||||
event.setLine(3, ChatColor.RED + "tiert nicht!");
|
||||
} else {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
int X = loc.getBlockX();
|
||||
int Y = loc.getBlockY();
|
||||
int Z = loc.getBlockZ();
|
||||
String world = loc.getWorld().getName();
|
||||
String server = plugin.getConfig().getString("server-name");
|
||||
AnuraCore.sql.queryUpdate("INSERT INTO coreWarpSigns(X,Y,Z,world,server,type,value,info) VALUES('" + X + "','" + Y + "','" + Z + "','" + world + "','" + server + "','warp','" + event.getLine(2) + "','" + event.getLine(3) + "')");
|
||||
event.setLine(0, "[" + ChatColor.GREEN + "Warp" + ChatColor.BLACK + "]");
|
||||
event.setLine(1, ChatColor.DARK_GRAY + "--------");
|
||||
event.setLine(2, ChatColor.AQUA + event.getLine(2));
|
||||
event.setLine(3, ChatColor.BLUE + event.getLine(3));
|
||||
Core.statusMsg(event.getPlayer(), "warpsign_created", true);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error: " + ex.getLocalizedMessage());
|
||||
}
|
||||
} else if (event.getLine(1).equalsIgnoreCase("spawn")) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
int X = loc.getBlockX();
|
||||
int Y = loc.getBlockY();
|
||||
int Z = loc.getBlockZ();
|
||||
String world = loc.getWorld().getName();
|
||||
String server = plugin.getConfig().getString("server-name");
|
||||
AnuraCore.sql.queryUpdate("INSERT INTO coreWarpSigns(X,Y,Z,world,server,type,value,info) VALUES('" + X + "','" + Y + "','" + Z + "','" + world + "','" + server + "','spawn','none','" + event.getLine(3) + "')");
|
||||
event.setLine(0, ChatColor.DARK_GRAY + "---------");
|
||||
event.setLine(1, ChatColor.BLACK + "[" + ChatColor.GREEN + "Spawn" + ChatColor.BLACK + "]");
|
||||
event.setLine(2, ChatColor.DARK_GRAY + "---------");
|
||||
event.setLine(3, ChatColor.BLUE + event.getLine(3));
|
||||
Core.statusMsg(event.getPlayer(), "spawnsign_created", true);
|
||||
} else if (event.getLine(1).equalsIgnoreCase("server")) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
int X = loc.getBlockX();
|
||||
int Y = loc.getBlockY();
|
||||
int Z = loc.getBlockZ();
|
||||
String world = loc.getWorld().getName();
|
||||
String server = event.getLine(2);
|
||||
String curServer = plugin.getConfig().getString("server-name");
|
||||
AnuraCore.sql.queryUpdate("INSERT INTO coreWarpSigns(X,Y,Z,world,server,type,value,info) VALUES('" + X + "','" + Y + "','" + Z + "','" + world + "','" + curServer + "','server','" + server + "','" + event.getLine(3) + "')");
|
||||
event.setLine(0, ChatColor.BLACK + "[" + ChatColor.GREEN + "Server" + ChatColor.BLACK + "]");
|
||||
event.setLine(1, ChatColor.GREEN + "--" + ChatColor.DARK_GRAY + "/" + ChatColor.GREEN + "--");
|
||||
event.setLine(2, ChatColor.AQUA + event.getLine(2));
|
||||
event.setLine(3, ChatColor.BLUE + event.getLine(3));
|
||||
Core.statusMsg(event.getPlayer(), "serversign_created", true);
|
||||
}
|
||||
} else {
|
||||
if (event.getPlayer().hasPermission("core.signs.chars")) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
String l = event.getLine(i);
|
||||
l = ChatColor.translateAlternateColorCodes('&', l);
|
||||
if (l.contains("%")) {
|
||||
String[] parts = l.split("%");
|
||||
ArrayList<Entry<String, String>> toReplace = new ArrayList<>();
|
||||
Boolean first = true;
|
||||
for (String s : parts) {
|
||||
if (!first) {
|
||||
String num = s.split(" ")[0];
|
||||
if (Core.isInteger(num)) {
|
||||
int number = Integer.valueOf(num);
|
||||
Entry<String, String> e = new SimpleEntry<>("%" + number, Character.toString((char) number));
|
||||
toReplace.add(e);
|
||||
}
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
for (Entry<String, String> entry : toReplace) {
|
||||
l = l.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
event.setLine(i, l);
|
||||
}
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
@@ -5,22 +5,19 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
|
||||
public class WeatherChange implements Listener
|
||||
{
|
||||
public WeatherChange(AnuraCore plugin)
|
||||
{
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWeatherChange(WeatherChangeEvent event)
|
||||
{
|
||||
if(event.toWeatherState() && plugin.getConfig().getBoolean("no-rain"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
System.out.println("Stopped rain!");
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
public class WeatherChange implements Listener {
|
||||
|
||||
public WeatherChange(AnuraCore plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWeatherChange(WeatherChangeEvent event) {
|
||||
if (event.toWeatherState() && plugin.getConfig().getBoolean("no-rain")) {
|
||||
event.setCancelled(true);
|
||||
System.out.println("Stopped rain!");
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user