Refactoring
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.API;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.Stairs;
|
||||
|
||||
public class API {
|
||||
public class Core {
|
||||
|
||||
/**
|
||||
* Use this if you want to change the language
|
||||
@@ -52,11 +57,11 @@ public class API {
|
||||
{
|
||||
if(cs instanceof Player)
|
||||
{
|
||||
return API.getl(id, (Player)cs);
|
||||
return Core.getl(id, (Player)cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
return API.getl(id, "en");
|
||||
return Core.getl(id, "en");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +73,7 @@ public class API {
|
||||
*/
|
||||
public static String getl(String id, Player P)
|
||||
{
|
||||
return API.getl(id, API.getPlayerLang(P));
|
||||
return Core.getl(id, Core.getPlayerLang(P));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +87,7 @@ public class API {
|
||||
ChatColor chatColor;
|
||||
if(status) chatColor = ChatColor.GREEN;
|
||||
else chatColor = ChatColor.RED;
|
||||
P.sendMessage(ChatColor.GRAY + "[Anura] "+chatColor+API.getl(id, API.getPlayerLang(P)));
|
||||
P.sendMessage(ChatColor.GRAY + "[Anura] "+chatColor+Core.getl(id, Core.getPlayerLang(P)));
|
||||
}
|
||||
/**
|
||||
* Sends a translated and colored message to the given CommandSender
|
||||
@@ -92,7 +97,7 @@ public class API {
|
||||
*/
|
||||
public static void statusMsg(CommandSender P, String id, ChatColor color)
|
||||
{
|
||||
P.sendMessage(ChatColor.GRAY + "[Anura] "+color+API.getl(id, API.getPlayerLang(P)));
|
||||
P.sendMessage(ChatColor.GRAY + "[Anura] "+color+Core.getl(id, Core.getPlayerLang(P)));
|
||||
}
|
||||
/**
|
||||
* Returns the language of the given CommandSender
|
||||
@@ -106,12 +111,12 @@ public class API {
|
||||
return "en";
|
||||
}
|
||||
Player p = (Player)P;
|
||||
if(!API.cachedPlayerLanguage.containsKey(p))
|
||||
if(!Core.cachedPlayerLanguage.containsKey(p))
|
||||
{
|
||||
ResultSet rs = AnuraCore.sql.querySelect("SELECT lang FROM players WHERE uuid = '"+p.getUniqueId().toString()+"'");
|
||||
try {
|
||||
rs.first();
|
||||
API.cachedPlayerLanguage.put(p, rs.getString("lang"));
|
||||
Core.cachedPlayerLanguage.put(p, rs.getString("lang"));
|
||||
return rs.getString("lang");
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("SQLException in getPlayerLang of API: "+ex.getLocalizedMessage());
|
||||
@@ -119,7 +124,7 @@ public class API {
|
||||
}
|
||||
else
|
||||
{
|
||||
return API.cachedPlayerLanguage.get(p);
|
||||
return Core.cachedPlayerLanguage.get(p);
|
||||
}
|
||||
return "en";
|
||||
}
|
||||
@@ -173,4 +178,49 @@ public class API {
|
||||
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))
|
||||
{
|
||||
MaterialData md = getMainClass().sittingBlocks.get(P).getState().getData();
|
||||
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);
|
||||
P.teleport(loc);
|
||||
a.remove();
|
||||
getMainClass().sittingPlayer.remove(P);
|
||||
getMainClass().sittingBlocks.remove(P);
|
||||
}
|
||||
else
|
||||
{
|
||||
Location loc = getMainClass().sittingPlayer.get(P).getLocation();
|
||||
P.teleport(loc);
|
||||
getMainClass().sittingPlayer.get(P).remove();
|
||||
getMainClass().sittingPlayer.remove(P);
|
||||
getMainClass().sittingBlocks.remove(P);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static boolean isInteger(String s) {
|
||||
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(Character.digit(s.charAt(i),radix) < 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.API;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -47,10 +48,10 @@ public class Inventories implements Listener {
|
||||
|
||||
public static void registerInventory(String type, String name, ChatColor nameColor) {
|
||||
HashMap<String, Inventory> langInvs = new HashMap<>();
|
||||
for (String lang : API.getAvailLangs()) {
|
||||
Inventory inv = Bukkit.createInventory(null, 9, nameColor + API.getl(name, lang));
|
||||
for (String lang : Core.getAvailLangs()) {
|
||||
Inventory inv = Bukkit.createInventory(null, 9, nameColor + Core.getl(name, lang));
|
||||
langInvs.put(lang, inv);
|
||||
invNames.put(nameColor + API.getl(name, lang), type);
|
||||
invNames.put(nameColor + Core.getl(name, lang), type);
|
||||
}
|
||||
invs.put(type, langInvs);
|
||||
invActions.put(type, new HashMap<Integer, Entry<Action, Object>>());
|
||||
@@ -58,13 +59,13 @@ public class Inventories implements Listener {
|
||||
|
||||
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 : API.getAvailLangs()) {
|
||||
for (String lang : Core.getAvailLangs()) {
|
||||
ItemStack stack = new ItemStack(m);
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
meta.setDisplayName(nameColor + API.getl(name, lang));
|
||||
meta.setDisplayName(nameColor + Core.getl(name, lang));
|
||||
if (loreColor != null) {
|
||||
for (int i = 0; i < lores.length; i++) {
|
||||
lores[i] = loreColor + API.getl(lores[i], lang);
|
||||
lores[i] = loreColor + Core.getl(lores[i], lang);
|
||||
}
|
||||
meta.setLore(Arrays.asList(lores));
|
||||
}
|
||||
@@ -80,13 +81,13 @@ public class Inventories implements Listener {
|
||||
|
||||
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 : API.getAvailLangs()) {
|
||||
for (String lang : Core.getAvailLangs()) {
|
||||
ItemStack stack = new ItemStack(m);
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
meta.setDisplayName(nameColor + API.getl(name, lang));
|
||||
meta.setDisplayName(nameColor + Core.getl(name, lang));
|
||||
if (loreColor != null) {
|
||||
for (int i = 0; i < lores.length; i++) {
|
||||
lores[i] = loreColor + API.getl(lores[i], lang);
|
||||
lores[i] = loreColor + Core.getl(lores[i], lang);
|
||||
}
|
||||
meta.setLore(Arrays.asList(lores));
|
||||
}
|
||||
@@ -116,11 +117,11 @@ public class Inventories implements Listener {
|
||||
}
|
||||
|
||||
public static Inventory getInventory(String type, Player P) {
|
||||
return invs.get(type).get(API.getPlayerLang(P));
|
||||
return invs.get(type).get(Core.getPlayerLang(P));
|
||||
}
|
||||
|
||||
public static ItemStack getItem(String type, Player P) {
|
||||
return items.get(type).get(API.getPlayerLang(P));
|
||||
return items.get(type).get(Core.getPlayerLang(P));
|
||||
}
|
||||
|
||||
public static void setItemInPlayerInv(String type, Integer position) {
|
||||
@@ -144,7 +145,7 @@ public class Inventories implements Listener {
|
||||
System.err.println("IOException whilst trying to connect to "+data);
|
||||
}
|
||||
} else if (action == Action.MESSAGE) {
|
||||
API.statusMsg(P, (String)data, true);
|
||||
Core.statusMsg(P, (String)data, true);
|
||||
} else if (action == Action.OPEN_INV) {
|
||||
P.openInventory(getInventory((String)data, P));
|
||||
} else if (action == Action.TELEPORT) {
|
||||
@@ -153,13 +154,13 @@ public class Inventories implements Listener {
|
||||
Bukkit.getServer().dispatchCommand(P, (String) data);
|
||||
} else if (action == Action.LANGUAGE) {
|
||||
String lang = (String)data;
|
||||
API.cachedPlayerLanguage.put(P,lang);
|
||||
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));
|
||||
}
|
||||
API.statusMsg(P, "lang_changed", true);
|
||||
Core.statusMsg(P, "lang_changed", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +171,7 @@ public class Inventories implements Listener {
|
||||
}
|
||||
|
||||
public static void openInventory(String inv, Player P) {
|
||||
P.openInventory(invs.get(inv).get(API.getPlayerLang(P)));
|
||||
P.openInventory(invs.get(inv).get(Core.getPlayerLang(P)));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -213,7 +214,7 @@ public class Inventories implements Listener {
|
||||
int slot = P.getInventory().getHeldItemSlot();
|
||||
if (itemPositions.containsValue(slot)) {
|
||||
event.setCancelled(true);
|
||||
String item = API.getKeyByValue(itemPositions, slot);
|
||||
String item = Core.getKeyByValue(itemPositions, slot);
|
||||
if (itemActions.containsKey(item)) {
|
||||
executeAction(P, itemActions.get(item).getKey(), itemActions.get(item).getValue());
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.API;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -19,12 +19,12 @@ public class Money {
|
||||
|
||||
public static void saveMoney(OfflinePlayer P) {
|
||||
if (!playerMoney.containsKey(P)) return;
|
||||
API.getMySql().queryUpdate("UPDATE coreStats SET money = '" + playerMoney.get(P) + "' WHERE player = (SELECT id FROM players WHERE uuid = '"+P.getUniqueId().toString()+"')");
|
||||
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 = API.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"));
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.API;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
@@ -1,4 +1,4 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.API;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@@ -48,7 +49,7 @@ public class Features implements Listener {
|
||||
{
|
||||
if(!mainLobby()) return;
|
||||
try {
|
||||
ResultSet rs = API.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>());
|
||||
@@ -85,12 +86,12 @@ public class Features implements Listener {
|
||||
if(!mainLobby()) return;
|
||||
if (f == Feature.DOUBLE_JUMP) {
|
||||
if (!hasFeature(P, f)) {
|
||||
API.statusMsg(P, "dont_have_dbl_jump", false);
|
||||
Core.statusMsg(P, "dont_have_dbl_jump", false);
|
||||
return;
|
||||
}
|
||||
featureEnabled.get(P).put(f, false);
|
||||
canDoubleJump.put(P, false);
|
||||
API.statusMsg(P, "dbl_jump_off", true);
|
||||
Core.statusMsg(P, "dbl_jump_off", true);
|
||||
if (P.getGameMode() != GameMode.CREATIVE) {
|
||||
P.setAllowFlight(false);
|
||||
}
|
||||
@@ -101,13 +102,13 @@ public class Features implements Listener {
|
||||
if(!mainLobby()) return;
|
||||
if (f == Feature.DOUBLE_JUMP) {
|
||||
if (!hasFeature(P, f)) {
|
||||
API.statusMsg(P, "dont_have_dbl_jump", false);
|
||||
Core.statusMsg(P, "dont_have_dbl_jump", false);
|
||||
return;
|
||||
}
|
||||
featureEnabled.get(P).put(f, true);
|
||||
P.setAllowFlight(true);
|
||||
canDoubleJump.put(P, true);
|
||||
API.statusMsg(P, "dbl_jump_on", true);
|
||||
Core.statusMsg(P, "dbl_jump_on", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.anura.core;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Money;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
@@ -156,17 +158,17 @@ public class FlowerPots {
|
||||
int waitTime = getPotWaitTime(pot);
|
||||
int toWait = (found + waitTime) - current;
|
||||
if (toWait <= 0) return;
|
||||
String text = ChatColor.RED + API.getl("ach_wait_1", P);
|
||||
String text = ChatColor.RED + Core.getl("ach_wait_1", P);
|
||||
if (toWait < 60) {
|
||||
text += " "+ChatColor.GREEN+toWait+" "+ChatColor.RED+API.getl("ach_wait_seconds", 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+API.getl("ach_wait_minutes", P);
|
||||
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+API.getl("ach_wait_hours", P);
|
||||
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+API.getl("ach_wait_days", P);
|
||||
text += " "+ChatColor.GREEN+Math.round(toWait/60/60/24)+" "+ChatColor.RED+Core.getl("ach_wait_days", P);
|
||||
}
|
||||
text += " "+API.getl("ach_wait_2", P);
|
||||
text += " "+Core.getl("ach_wait_2", P);
|
||||
|
||||
P.sendMessage(text);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.bukkit.map.MapCanvas;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
class ImgRenderer extends MapRenderer {
|
||||
public class ImgRenderer extends MapRenderer {
|
||||
|
||||
private final String name;
|
||||
public ImgRenderer(String name) {
|
||||
|
||||
61
src/de/anura/core/RealTime.java
Normal file
61
src/de/anura/core/RealTime.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package de.anura.core;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
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()) {
|
||||
world.setGameRuleValue("doDaylightCycle", "false");
|
||||
world.setTime(0);
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Core.getMainClass(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Integer[] time = getSystemTime();
|
||||
int TTime = convertTime(time[0], time[1]);
|
||||
setWorldTime(TTime);
|
||||
System.out.println("World Time synchronized");
|
||||
}
|
||||
}, 0, (20 * 60 * 10));
|
||||
}
|
||||
}
|
||||
|
||||
private static Integer[] getSystemTime() {
|
||||
Date date = new Date();
|
||||
Calendar calendar = GregorianCalendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = calendar.get(Calendar.MINUTE);
|
||||
Integer[] time = new Integer[]{hour, minute};
|
||||
return time;
|
||||
}
|
||||
|
||||
private static void setWorldTime(Integer ticks) {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
world.setGameRuleValue("doDaylightCycle", "false");
|
||||
world.setTime(ticks);
|
||||
}
|
||||
}
|
||||
|
||||
private static int convertTime(Integer hour, Integer minute) {
|
||||
int TMinute = (int) (83 * (round(minute, 5)) / 5);
|
||||
int THour;
|
||||
if (hour >= 6) {
|
||||
THour = (hour - 6) * 1000;
|
||||
} else {
|
||||
THour = ((hour + 24) - 6) * 1000;
|
||||
}
|
||||
return THour + TMinute;
|
||||
}
|
||||
|
||||
private static double round(double num, int multipleOf) {
|
||||
return Math.floor((num + (double) multipleOf / 2) / multipleOf) * multipleOf;
|
||||
}
|
||||
}
|
||||
285
src/de/anura/core/Setup.java
Normal file
285
src/de/anura/core/Setup.java
Normal file
@@ -0,0 +1,285 @@
|
||||
package de.anura.core;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Inventories;
|
||||
import de.anura.core.API.Tools;
|
||||
import static de.anura.core.AnuraCore.sql;
|
||||
import de.anura.core.commands.AdminCommands;
|
||||
import de.anura.core.commands.OtherCommands;
|
||||
import de.anura.core.commands.PlayerCommands;
|
||||
import de.anura.core.commands.TeamCommands;
|
||||
import de.anura.core.events.BlockBreak;
|
||||
import de.anura.core.events.BlockPlace;
|
||||
import de.anura.core.events.BlockSpread;
|
||||
import de.anura.core.events.CmdPreprocess;
|
||||
import de.anura.core.events.EntityDamage;
|
||||
import de.anura.core.events.EntityDamageByE;
|
||||
import de.anura.core.events.FoodChange;
|
||||
import de.anura.core.events.HangingEBreak;
|
||||
import de.anura.core.events.InvClick;
|
||||
import de.anura.core.events.LeavesDecay;
|
||||
import de.anura.core.events.PlayerChat;
|
||||
import de.anura.core.events.PlayerInteract;
|
||||
import de.anura.core.events.PlayerInteractE;
|
||||
import de.anura.core.events.PlayerJoin;
|
||||
import de.anura.core.events.PlayerKick;
|
||||
import de.anura.core.events.PlayerMove;
|
||||
import de.anura.core.events.PlayerQuit;
|
||||
import de.anura.core.events.PlayerTeleport;
|
||||
import de.anura.core.events.SignChange;
|
||||
import de.anura.core.events.WeatherChange;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
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-change-blocks", false);
|
||||
Core.getMainClass().getConfig().addDefault("is-main-lobby", false);
|
||||
Core.getMainClass().getConfig().addDefault("no-hunger", false);
|
||||
Core.getMainClass().getConfig().addDefault("no-rain", false);
|
||||
Core.getMainClass().getConfig().addDefault("enable-leaves-decay", true);
|
||||
Core.getMainClass().getConfig().addDefault("server-name", "lobby");
|
||||
Core.getMainClass().getConfig().addDefault("allow-stairs-sit", false);
|
||||
Core.getMainClass().getConfig().addDefault("disable-mushroom-spread", false);
|
||||
Core.getMainClass().getConfig().addDefault("on-join-to-spawn", false);
|
||||
Core.getMainClass().getConfig().addDefault("golf", false);
|
||||
Core.getMainClass().getConfig().addDefault("realtime-day", false);
|
||||
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());
|
||||
new PlayerInteract(Core.getMainClass());
|
||||
new BlockBreak(Core.getMainClass());
|
||||
new BlockPlace(Core.getMainClass());
|
||||
new PlayerQuit(Core.getMainClass());
|
||||
new PlayerKick(Core.getMainClass());
|
||||
new PlayerChat(Core.getMainClass());
|
||||
new EntityDamage(Core.getMainClass());
|
||||
new WeatherChange(Core.getMainClass());
|
||||
new CmdPreprocess(Core.getMainClass());
|
||||
new HangingEBreak(Core.getMainClass());
|
||||
new FoodChange(Core.getMainClass());
|
||||
new LeavesDecay(Core.getMainClass());
|
||||
new EntityDamageByE(Core.getMainClass());
|
||||
new PlayerInteractE(Core.getMainClass());
|
||||
new SignChange(Core.getMainClass());
|
||||
new PlayerTeleport(Core.getMainClass());
|
||||
new InvClick(Core.getMainClass());
|
||||
new BlockSpread(Core.getMainClass());
|
||||
}
|
||||
|
||||
public static void setupClasses() {
|
||||
Core.getMainClass().lang = new LanguageSupport(Core.getMainClass());
|
||||
new Inventories(Core.getMainClass());
|
||||
Core.getMainClass().perms = new Permissions(Core.getMainClass());
|
||||
Core.getMainClass().tools = new Tools();
|
||||
Core.getMainClass().pots = new FlowerPots();
|
||||
Core.getMainClass().signs = new Signs();
|
||||
RealTime.setup();
|
||||
ResultSet rs = sql.querySelect("SELECT id, X, Y, Z, world, type, waitTime FROM corePots");
|
||||
try {
|
||||
while(rs.next())
|
||||
{
|
||||
World w = Bukkit.getWorld(rs.getString("world"));
|
||||
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"))
|
||||
{
|
||||
Core.getMainClass().flowerPotsWait.put(rs.getInt("id"), rs.getInt("waitTime"));
|
||||
}
|
||||
l.getBlock().setType(Material.BROWN_MUSHROOM);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Error whilst trying to setup flower pots");
|
||||
}
|
||||
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))
|
||||
{
|
||||
P.setExp(0);
|
||||
int power = Core.getMainClass().golfPower.get(P);
|
||||
Entity i = Core.getMainClass().golfBall.get(P);
|
||||
if(i != null && i.isValid())
|
||||
{
|
||||
Vector v = P.getLocation().getDirection();
|
||||
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
|
||||
{
|
||||
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")+"'");
|
||||
try {
|
||||
while(rs.next())
|
||||
{
|
||||
World w = Bukkit.getWorld(rs.getString("world"));
|
||||
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)
|
||||
{
|
||||
Core.getMainClass().sittableBlocks.add(l.getBlock());
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.err.println("Error whilst trying to setup stairs");
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Core.getMainClass(), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
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);
|
||||
a.setPassenger(p);
|
||||
AnuraCore.getInstance().sittingPlayer.get(p).remove();
|
||||
AnuraCore.getInstance().sittingPlayer.put(p, a);
|
||||
}
|
||||
}
|
||||
|
||||
}, 600, 600);
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Core.getMainClass(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AnuraCore.getInstance().signs.updateServerSigns();
|
||||
}
|
||||
}, 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);
|
||||
Core.getMainClass().getCommand("money").setExecutor(pc);
|
||||
Core.getMainClass().getCommand("gm").setExecutor(tc);
|
||||
Core.getMainClass().getCommand("sun").setExecutor(tc);
|
||||
Core.getMainClass().getCommand("core").setExecutor(ac);
|
||||
Core.getMainClass().getCommand("hilfe").setExecutor(pc);
|
||||
Core.getMainClass().getCommand("none").setExecutor(oc);
|
||||
Core.getMainClass().getCommand("flyspeed").setExecutor(tc);
|
||||
Core.getMainClass().getCommand("setwarp").setExecutor(tc);
|
||||
Core.getMainClass().getCommand("warp").setExecutor(pc);
|
||||
Core.getMainClass().getCommand("remwarp").setExecutor(tc);
|
||||
Core.getMainClass().getCommand("flowerpot").setExecutor(tc);
|
||||
Core.getMainClass().getCommand("addmap").setExecutor(tc);
|
||||
Core.getMainClass().getCommand("rendermap").setExecutor(tc);
|
||||
Core.getMainClass().getCommand("cleararrows").setExecutor(ac);
|
||||
Core.getMainClass().getCommand("stairmode").setExecutor(tc);
|
||||
Core.getMainClass().getCommand("addcmd").setExecutor(tc);
|
||||
Core.getMainClass().getCommand("setcmd").setExecutor(tc);
|
||||
Core.getMainClass().getCommand("togglecommands").setExecutor(oc);
|
||||
Core.getMainClass().getCommand("addmap").setExecutor(tc);
|
||||
Core.getMainClass().getCommand("toggledbljump").setExecutor(pc);
|
||||
Core.getMainClass().getCommand("joinminigame").setExecutor(pc);
|
||||
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));
|
||||
Inventories.putIntoInventory("GAMEMODES", 2, Inventories.buildItems(Material.CARROT_STICK, "inv_lobby_minigames", ChatColor.BLUE));
|
||||
Inventories.putIntoInventory("GAMEMODES", 4, Inventories.buildItems(Material.IRON_PICKAXE, "inv_lobby_freebuild", ChatColor.GOLD));
|
||||
|
||||
Inventories.registerAction("GAMEMODES", 0, Inventories.Action.OPEN_INV, "LOBBY");
|
||||
Inventories.registerAction("GAMEMODES", 2, Inventories.Action.OPEN_INV, "MINIGAMES");
|
||||
Inventories.registerAction("GAMEMODES", 4, Inventories.Action.SERVER, "freebuild");
|
||||
|
||||
Inventories.registerInventory("MINIGAMES", "minigames_inv", ChatColor.DARK_BLUE);
|
||||
Inventories.putIntoInventory("MINIGAMES", 0, Inventories.buildItems(Material.BOW, "inv_lobby_smash", ChatColor.GREEN, ChatColor.BLUE, "smash_description_1", "smash_description_2", "smash_description_3", "smash_description_4", "smash_description_5", "smash_description_6"));
|
||||
Inventories.putIntoInventory("MINIGAMES", 2, Inventories.buildItems(Material.WHEAT, "inv_lobby_farmfight", ChatColor.YELLOW));
|
||||
Inventories.putIntoInventory("MINIGAMES", 4, Inventories.buildItems(Material.FIREWORK, "inv_lobby_rocketmatch", ChatColor.DARK_AQUA));
|
||||
Inventories.putIntoInventory("MINIGAMES", 8, Inventories.buildItems(Material.ENDER_PEARL, "inv_lobby_back", ChatColor.YELLOW));
|
||||
|
||||
Inventories.registerAction("MINIGAMES", 0, Inventories.Action.SERVER, "smash");
|
||||
Inventories.registerAction("MINIGAMES", 2, Inventories.Action.SERVER, "farmfight");
|
||||
Inventories.registerAction("MINIGAMES", 4, Inventories.Action.SERVER, "rocketmatch");
|
||||
Inventories.registerAction("MINIGAMES", 8, Inventories.Action.OPEN_INV, "GAMEMODES");
|
||||
|
||||
Inventories.registerInventory("LOBBY", "lobby_inv", ChatColor.DARK_BLUE);
|
||||
Inventories.putIntoInventory("LOBBY", 0, Inventories.buildItems(Material.SLIME_BALL, "inv_lobby_jump", ChatColor.DARK_GREEN));
|
||||
Inventories.putIntoInventory("LOBBY", 1, Inventories.buildItems(Material.WATER_BUCKET, "inv_lobby_swim", ChatColor.DARK_AQUA));
|
||||
Inventories.putIntoInventory("LOBBY", 3, Inventories.buildItems(Material.EXP_BOTTLE, "inv_lobby_xpbattle", ChatColor.GREEN));
|
||||
Inventories.putIntoInventory("LOBBY", 4, Inventories.buildItems(Material.POTION, "inv_lobby_pool", ChatColor.BLUE));
|
||||
Inventories.putIntoInventory("LOBBY", 6, Inventories.buildItems(Material.WOOD_DOOR, "tp_to_spawn", ChatColor.GOLD));
|
||||
Inventories.putIntoInventory("LOBBY", 8, Inventories.buildItems(Material.ENDER_PEARL, "inv_lobby_back", ChatColor.YELLOW));
|
||||
|
||||
Inventories.registerAction("LOBBY", 0, Inventories.Action.COMMAND, "jumpinv");
|
||||
Inventories.registerAction("LOBBY", 1, Inventories.Action.TELEPORT, new Location(Bukkit.getWorld("lobby"), -288, 32, -1714));
|
||||
Inventories.registerAction("LOBBY", 3, Inventories.Action.COMMAND, "toggleminigame xpbattle");
|
||||
Inventories.registerAction("LOBBY", 1, Inventories.Action.COMMAND, "toggleminigame pool");
|
||||
Inventories.registerAction("LOBBY", 6, Inventories.Action.COMMAND, "spawn");
|
||||
Inventories.registerAction("LOBBY", 8, Inventories.Action.OPEN_INV, "GAMEMODES");
|
||||
|
||||
Inventories.registerInventory("FEATURES", "features_inv", ChatColor.DARK_BLUE);
|
||||
Inventories.putIntoInventory("FEATURES", 2, Inventories.buildItems(Material.LEATHER_BOOTS, "inv_lobby_double_jump", ChatColor.DARK_AQUA));
|
||||
Inventories.registerAction("FEATURES", 2, Inventories.Action.COMMAND, "toggledbljump");
|
||||
|
||||
Inventories.registerInventory("LANGUAGE", "Select language", ChatColor.DARK_BLUE);
|
||||
int i = 0;
|
||||
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++;
|
||||
}
|
||||
|
||||
Inventories.buildInvItem("COMPASS", Material.COMPASS, "select_game", ChatColor.DARK_AQUA);
|
||||
Inventories.buildInvItem("SIGN", Material.SIGN, "Change language", ChatColor.DARK_GREEN);
|
||||
Inventories.buildInvItem("PAPER", Material.PAPER, "features_item", ChatColor.BLUE);
|
||||
Inventories.buildInvItem("DOOR", Material.WOOD_DOOR, "tp_to_spawn", ChatColor.YELLOW);
|
||||
Inventories.buildInvItem("EYE", Material.EYE_OF_ENDER, "inv_to_lobby", ChatColor.YELLOW);
|
||||
if (Core.getMainClass().getConfig().getString("server-name").equals("lobby")) {
|
||||
Inventories.setItemInPlayerInv("COMPASS", 0);
|
||||
Inventories.setItemInPlayerInv("SIGN", 1);
|
||||
Inventories.setItemInPlayerInv("PAPER", 2);
|
||||
Inventories.setItemInPlayerInv("DOOR", 8);
|
||||
}
|
||||
Inventories.registerItemAction("COMPASS", Inventories.Action.OPEN_INV, "GAMEMODES");
|
||||
Inventories.registerItemAction("SIGN", Inventories.Action.OPEN_INV, "LANGUAGE");
|
||||
Inventories.registerItemAction("PAPER", Inventories.Action.OPEN_INV, "FEATURES");
|
||||
Inventories.registerItemAction("DOOR", Inventories.Action.COMMAND, "spawn");
|
||||
Inventories.registerItemAction("EYE", Inventories.Action.SERVER, "lobby");
|
||||
}
|
||||
}
|
||||
174
src/de/anura/core/Signs.java
Normal file
174
src/de/anura/core/Signs.java
Normal file
@@ -0,0 +1,174 @@
|
||||
package de.anura.core;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import static de.anura.core.AnuraCore.sql;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
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")+"'");
|
||||
try {
|
||||
rs.last();
|
||||
if(rs.getRow() == 0) return;
|
||||
rs.beforeFirst();
|
||||
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")+"')");
|
||||
rs2.last();
|
||||
Boolean online = true;
|
||||
int maxPlayers = 0;
|
||||
if(rs2.getRow() == 0) {
|
||||
online = false;
|
||||
}
|
||||
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.last();
|
||||
if(rs2.getRow() == 0) continue;
|
||||
rs2.beforeFirst();
|
||||
while(rs2.next())
|
||||
{
|
||||
Boolean remove = false;
|
||||
World w = Bukkit.getWorld(rs2.getString("world"));
|
||||
BlockState bs = null;
|
||||
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
|
||||
{
|
||||
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")+"'";
|
||||
sql.queryUpdate(anotherSQL);
|
||||
continue;
|
||||
}
|
||||
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 + "--");
|
||||
s.setLine(3, ChatColor.RED + "Offline");
|
||||
s.update();
|
||||
continue;
|
||||
}
|
||||
s.setLine(1, rest + maxPlayers);
|
||||
s.setLine(3, info);
|
||||
s.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException | IOException ex) {
|
||||
System.err.println("Exception in updateServerSigns()(Core): "+ex.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
if (!channel.equals("BungeeCord")) {
|
||||
return;
|
||||
}
|
||||
|
||||
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
|
||||
|
||||
try {
|
||||
String subchannel = 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+"'";
|
||||
ResultSet rs = sql.querySelect(sqlQ);
|
||||
rs.last();
|
||||
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+"--");
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
99
src/de/anura/core/commands/AdminCommands.java
Normal file
99
src/de/anura/core/commands/AdminCommands.java
Normal file
@@ -0,0 +1,99 @@
|
||||
package de.anura.core.commands;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.AnuraCore;
|
||||
import de.anura.core.LanguageSupport;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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(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);
|
||||
return true;
|
||||
}
|
||||
for(Player pl : Core.getMainClass().sittingPlayer.keySet())
|
||||
{
|
||||
Core.endSitting(pl);
|
||||
}
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
if(args.length != 1)
|
||||
{
|
||||
Core.statusMsg(sender,"wrong_args_count",false);
|
||||
return false;
|
||||
}
|
||||
if((args[0].equalsIgnoreCase("reload") || args[0].equalsIgnoreCase("rl")) && sender.isOp())
|
||||
{
|
||||
try {
|
||||
Core.getMainClass().getConfig().load(new File("plugins/Core/","config.yml"));
|
||||
Core.getMainClass().lang = new LanguageSupport(Core.getMainClass());
|
||||
Core.statusMsg(sender,"config_rl_done",true);
|
||||
} catch (IOException ex) {
|
||||
Core.statusMsg(sender,"config_rl_error_io",false);
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
Core.statusMsg(sender,"config_rl_invalid",false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
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);
|
||||
} catch (IOException ex) {
|
||||
Core.statusMsg(sender,"config_save_io_err",false);
|
||||
}
|
||||
}
|
||||
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"))
|
||||
{
|
||||
Location l = P.getLocation();
|
||||
l.getWorld().setSpawnLocation((int)l.getX(), (int)l.getY(), (int)l.getZ());
|
||||
Core.statusMsg(P,"spawn_set",true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
40
src/de/anura/core/commands/OtherCommands.java
Normal file
40
src/de/anura/core/commands/OtherCommands.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package de.anura.core.commands;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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(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;
|
||||
String action = args[1];
|
||||
if(!action.equals("disable") && !action.equals("enable")) return true;
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]);
|
||||
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"))
|
||||
{
|
||||
Core.statusMsg(sender, "cmd_not_found", false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
346
src/de/anura/core/commands/PlayerCommands.java
Normal file
346
src/de/anura/core/commands/PlayerCommands.java
Normal file
@@ -0,0 +1,346 @@
|
||||
package de.anura.core.commands;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Money;
|
||||
import static de.anura.core.AnuraCore.sql;
|
||||
import de.anura.core.Features;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
|
||||
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(cmd.getName().equalsIgnoreCase("toggledbljump")) {
|
||||
if(P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if (P.getAllowFlight()) {
|
||||
Core.getMainClass().getFeatures().disableFeature(P, Features.Feature.DOUBLE_JUMP);
|
||||
} else {
|
||||
Core.getMainClass().getFeatures().enableFeature(P, Features.Feature.DOUBLE_JUMP);
|
||||
}
|
||||
return true;
|
||||
} else if (cmd.getName().equalsIgnoreCase("joinminigame")) {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
return false;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("xpbattle")) {
|
||||
Objective o = Bukkit.getScoreboardManager().getMainScoreboard().getObjective("xpBattleJoin");
|
||||
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;
|
||||
o.getScore(P).setScore(1);
|
||||
Core.statusMsg(sender, "joined_pool", true);
|
||||
return true;
|
||||
}
|
||||
} else if (cmd.getName().equalsIgnoreCase("leaveminigame")) {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
return false;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("xpbattle")) {
|
||||
Objective o = Bukkit.getScoreboardManager().getMainScoreboard().getObjective("xpBattleJoin");
|
||||
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;
|
||||
o.getScore(P).setScore(0);
|
||||
Core.statusMsg(sender, "left_pool", true);
|
||||
return true;
|
||||
}
|
||||
} else if (cmd.getName().equalsIgnoreCase("toggleminigame")) {
|
||||
if (P == null) {
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
return false;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("xpbattle")) {
|
||||
Objective o = Bukkit.getScoreboardManager().getMainScoreboard().getObjective("xpBattleJoin");
|
||||
if (o == null) return true;
|
||||
if (o.getScore(P).getScore() == 0) {
|
||||
Bukkit.dispatchCommand(sender, "joinminigame xpBattle");
|
||||
return true;
|
||||
} else {
|
||||
Bukkit.dispatchCommand(sender, "leaveminigame xpBattle");
|
||||
return true;
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("pool")) {
|
||||
Objective o = Bukkit.getScoreboardManager().getMainScoreboard().getObjective("poolJoin");
|
||||
if (o == null) return true;
|
||||
if (o.getScore(P).getScore() == 0) {
|
||||
Bukkit.dispatchCommand(sender, "joinminigame pool");
|
||||
return true;
|
||||
} else {
|
||||
Bukkit.dispatchCommand(sender, "leaveminigame pool");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} 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(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.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())
|
||||
{
|
||||
P = Bukkit.getPlayer(args[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
return true;
|
||||
} else if(cmd.getName().equalsIgnoreCase("warp"))
|
||||
{
|
||||
try {
|
||||
if(args.length == 0 || args.length > 2)
|
||||
{
|
||||
Core.statusMsg(P, "wrong_args_count", false);
|
||||
return false;
|
||||
}
|
||||
if(P == null)
|
||||
{
|
||||
if(args.length != 2)
|
||||
{
|
||||
Core.statusMsg(P, "wrong_args_count", false);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
if(args.length == 2)
|
||||
{
|
||||
String p = args[1];
|
||||
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+"'");
|
||||
rs.last();
|
||||
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"))
|
||||
{
|
||||
Core.statusMsg(P, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
int X = rs.getInt("X");
|
||||
int Y = rs.getInt("Y");
|
||||
int Z = rs.getInt("Z");
|
||||
String server = rs.getString("server");
|
||||
String world = rs.getString("world");
|
||||
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)
|
||||
{
|
||||
Core.statusMsg(P, "warp_not_avail", false);
|
||||
return true;
|
||||
}
|
||||
Location loc = new Location(w, X, Y, Z);
|
||||
P.teleport(loc);
|
||||
Core.statusMsg(P, "warp_tp_done", true);
|
||||
return true;
|
||||
} catch (SQLException ex) {
|
||||
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);
|
||||
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))
|
||||
{
|
||||
Integer money = Integer.parseInt(args[2]);
|
||||
boolean canPay;
|
||||
Integer geld = 0;
|
||||
if(sender.hasPermission("core.money.endless"))
|
||||
{
|
||||
if(P != null)
|
||||
{
|
||||
canPay = P.hasPermission("core.money.endless");
|
||||
}
|
||||
else
|
||||
{
|
||||
canPay = 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(!(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);
|
||||
canPay = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
geld = currentMoney;
|
||||
canPay = true;
|
||||
}
|
||||
}
|
||||
if(canPay)
|
||||
{
|
||||
OfflinePlayer oP = Bukkit.getOfflinePlayer(args[1]);
|
||||
if(!oP.hasPlayedBefore() && !oP.isOnline())
|
||||
{
|
||||
Core.statusMsg(P, "never_seen_player", false);
|
||||
return true;
|
||||
}
|
||||
int currentMoney2 = Money.getMoney(oP);
|
||||
if(currentMoney2 != -1)
|
||||
{
|
||||
Money.payMoney(oP, money);
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
380
src/de/anura/core/commands/TeamCommands.java
Normal file
380
src/de/anura/core/commands/TeamCommands.java
Normal file
@@ -0,0 +1,380 @@
|
||||
package de.anura.core.commands;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.AnuraCore;
|
||||
import static de.anura.core.AnuraCore.sql;
|
||||
import de.anura.core.ImgRenderer;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
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(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);
|
||||
return true;
|
||||
}
|
||||
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))
|
||||
{
|
||||
String command = "";
|
||||
for(String arg : args)
|
||||
{
|
||||
if(!command.equals(""))
|
||||
{
|
||||
command += " ";
|
||||
}
|
||||
command += arg;
|
||||
}
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
Block b = P.getTargetBlock(null, 100);
|
||||
if(b.getType().equals(Material.COMMAND))
|
||||
{
|
||||
CommandBlock cb = (CommandBlock)b.getState();
|
||||
String command = "";
|
||||
for(String arg : args)
|
||||
{
|
||||
if(!command.equals(""))
|
||||
{
|
||||
command += " ";
|
||||
}
|
||||
command += arg;
|
||||
}
|
||||
command = cb.getCommand() + command;
|
||||
cb.setCommand(command);
|
||||
cb.update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if(cmd.getName().equalsIgnoreCase("gm"))
|
||||
{
|
||||
String command = "gamemode ";
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
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);
|
||||
Core.getTools().sendStatusMsg(sender, "Done!", true);
|
||||
return true;
|
||||
}
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
if(args.length != 1)
|
||||
{
|
||||
Core.statusMsg(sender,"wrong_args_count",false);
|
||||
return false;
|
||||
}
|
||||
Location l = P.getLocation();
|
||||
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()+"'");
|
||||
try {
|
||||
rs.first();
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
if(args.length != 2)
|
||||
{
|
||||
Core.statusMsg(sender,"wrong_args_count",false);
|
||||
return false;
|
||||
}
|
||||
final CommandSender cs = sender;
|
||||
final String url = args[0];
|
||||
final String name = args[1];
|
||||
Core.getTools().sendStatusMsg(cs, "The rendering is starting...", true);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Core.getMainClass(), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
URI uri = URI.create(url);
|
||||
URL locUrl = uri.toURL();
|
||||
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);
|
||||
AnuraCore.getInstance().renderedImgs.put(name, imgScaled);
|
||||
Core.getTools().sendStatusMsg(cs, "The rendering has finished!", true);
|
||||
} catch (MalformedURLException ex) {
|
||||
Core.getTools().sendStatusMsg(cs, "Please provide a valid image url!", false);
|
||||
} catch (IOException ex) {
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
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())
|
||||
{
|
||||
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"))
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
else if(cmd.getName().equalsIgnoreCase("setwarp"))
|
||||
{
|
||||
try {
|
||||
if(P == null)
|
||||
{
|
||||
Core.statusMsg(sender, "only_player_cmd", false);
|
||||
return true;
|
||||
}
|
||||
if(!P.hasPermission("core.commands.setwarp"))
|
||||
{
|
||||
Core.statusMsg(P, "no_perms", false);
|
||||
return true;
|
||||
}
|
||||
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";
|
||||
}
|
||||
Location loc = P.getLocation();
|
||||
int X = loc.getBlockX();
|
||||
int Y = loc.getBlockY();
|
||||
int Z = loc.getBlockZ();
|
||||
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+"'");
|
||||
rs.last();
|
||||
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+"')");
|
||||
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)
|
||||
{
|
||||
Core.statusMsg(P, "wrong_args_count", false);
|
||||
return false;
|
||||
}
|
||||
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+"'");
|
||||
try {
|
||||
rs.last();
|
||||
if(rs.getRow() == 0)
|
||||
{
|
||||
Core.statusMsg(P, "warp_not_exist", false);
|
||||
return true;
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -28,7 +30,7 @@ public class BlockPlace implements Listener
|
||||
{
|
||||
event.setCancelled(true);
|
||||
final Block b = event.getBlock();
|
||||
final int pot = API.getKeyByValue(plugin.flowerPots, b.getLocation());
|
||||
final int pot = Core.getKeyByValue(plugin.flowerPots, b.getLocation());
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -21,13 +23,13 @@ public class CmdPreprocess implements Listener
|
||||
if(!event.getPlayer().hasPermission("core.commands.help"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
API.statusMsg(event.getPlayer(), "help_command_info", true);
|
||||
Core.statusMsg(event.getPlayer(), "help_command_info", true);
|
||||
}
|
||||
}
|
||||
else if(plugin.disableCommandsAdventure.containsKey(event.getPlayer()) && plugin.disableCommandsAdventure.get(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
API.statusMsg(event.getPlayer(), "no_command_red_mg", ChatColor.YELLOW);
|
||||
Core.statusMsg(event.getPlayer(), "no_command_red_mg", ChatColor.YELLOW);
|
||||
}
|
||||
}
|
||||
private final AnuraCore plugin;
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -48,7 +50,7 @@ public class PlayerInteract implements Listener
|
||||
}
|
||||
else
|
||||
{
|
||||
API.statusMsg(event.getPlayer(), "setjumper_block_not_supported", false);
|
||||
Core.statusMsg(event.getPlayer(), "setjumper_block_not_supported", false);
|
||||
plugin.selectableJumper.remove(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
@@ -59,7 +61,7 @@ public class PlayerInteract implements Listener
|
||||
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());
|
||||
API.statusMsg(event.getPlayer(), "setjumper_done", true);
|
||||
Core.statusMsg(event.getPlayer(), "setjumper_done", true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -89,7 +91,7 @@ public class PlayerInteract implements Listener
|
||||
rs2.last();
|
||||
if(rs2.getRow() == 0)
|
||||
{
|
||||
API.statusMsg(P, "warpsign_warp_not_exist", false);
|
||||
Core.statusMsg(P, "warpsign_warp_not_exist", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -130,32 +132,32 @@ public class PlayerInteract implements Listener
|
||||
if(plugin.sittableBlocks.contains(block))
|
||||
{
|
||||
plugin.sittableBlocks.remove(block);
|
||||
API.getTools().sendStatusMsg(event.getPlayer(), "Removed!", false);
|
||||
Core.getTools().sendStatusMsg(event.getPlayer(), "Removed!", false);
|
||||
int X = block.getLocation().getBlockX();
|
||||
int Y = block.getLocation().getBlockY();
|
||||
int Z = block.getLocation().getBlockZ();
|
||||
API.getMySql().queryUpdate("DELETE FROM coreStairs WHERE server = '"+plugin.getConfig().getString("server-name")+"' AND world = '"+block.getWorld().getName()+"' AND X = '"+X+"' AND Y = '"+Y+"' AND Z = '"+Z+"'");
|
||||
Core.getMySql().queryUpdate("DELETE FROM coreStairs WHERE server = '"+plugin.getConfig().getString("server-name")+"' AND world = '"+block.getWorld().getName()+"' AND X = '"+X+"' AND Y = '"+Y+"' AND Z = '"+Z+"'");
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.sittableBlocks.add(block);
|
||||
API.getTools().sendStatusMsg(event.getPlayer(), "Added!", true);
|
||||
Core.getTools().sendStatusMsg(event.getPlayer(), "Added!", true);
|
||||
int X = block.getLocation().getBlockX();
|
||||
int Y = block.getLocation().getBlockY();
|
||||
int Z = block.getLocation().getBlockZ();
|
||||
API.getMySql().queryUpdate("INSERT INTO coreStairs(server,world,X,Y,Z) VALUES('"+plugin.getConfig().getString("server-name")+"','"+block.getWorld().getName()+"','"+X+"','"+Y+"','"+Z+"')");
|
||||
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()))
|
||||
{
|
||||
API.statusMsg(event.getPlayer(), "sitting_already", false);
|
||||
Core.statusMsg(event.getPlayer(), "sitting_already", false);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if(plugin.sittingBlocks.containsValue(block))
|
||||
{
|
||||
API.statusMsg(event.getPlayer(), "sitting_occupied", false);
|
||||
Core.statusMsg(event.getPlayer(), "sitting_occupied", false);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else
|
||||
@@ -187,7 +189,7 @@ public class PlayerInteract implements Listener
|
||||
}
|
||||
|
||||
}, 3);
|
||||
plugin.pots.playerFoundPot(event.getPlayer(), API.getKeyByValue(plugin.flowerPots, block.getLocation()));
|
||||
plugin.pots.playerFoundPot(event.getPlayer(), Core.getKeyByValue(plugin.flowerPots, block.getLocation()));
|
||||
}
|
||||
}
|
||||
if(plugin.getConfig().getBoolean("no-change-blocks"))
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Chicken;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -21,7 +23,7 @@ public class PlayerKick implements Listener
|
||||
if(!plugin.getConfig().getBoolean("is-main-lobby"))
|
||||
{
|
||||
try {
|
||||
plugin.endSitting(event.getPlayer());
|
||||
Core.endSitting(event.getPlayer());
|
||||
event.setCancelled(true);
|
||||
ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import de.anura.core.ParticleEffect;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.bukkit.Material;
|
||||
@@ -1,5 +1,8 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.API.Money;
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@@ -15,7 +18,7 @@ public class PlayerQuit implements Listener
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
event.setQuitMessage(null);
|
||||
AnuraCore.getInstance().endSitting(event.getPlayer());
|
||||
Core.endSitting(event.getPlayer());
|
||||
AnuraCore.getInstance().disableCommandsAdventure.remove(event.getPlayer());
|
||||
Money.saveMoney(event.getPlayer());
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Arrow;
|
||||
@@ -1,5 +1,7 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.API.Core;
|
||||
import de.anura.core.AnuraCore;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
@@ -58,7 +60,7 @@ public class SignChange implements Listener
|
||||
event.setLine(1, ChatColor.DARK_GRAY+"--------");
|
||||
event.setLine(2, ChatColor.AQUA + event.getLine(2));
|
||||
event.setLine(3, ChatColor.BLUE + event.getLine(3));
|
||||
API.statusMsg(event.getPlayer(), "warpsign_created", true);
|
||||
Core.statusMsg(event.getPlayer(), "warpsign_created", true);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
System.out.println("Error: "+ex.getLocalizedMessage());
|
||||
@@ -77,7 +79,7 @@ public class SignChange implements Listener
|
||||
event.setLine(1, ChatColor.BLACK + "["+ChatColor.GREEN + "Spawn"+ ChatColor.BLACK + "]");
|
||||
event.setLine(2, ChatColor.DARK_GRAY + "---------");
|
||||
event.setLine(3, ChatColor.BLUE + event.getLine(3));
|
||||
API.statusMsg(event.getPlayer(), "spawnsign_created", true);
|
||||
Core.statusMsg(event.getPlayer(), "spawnsign_created", true);
|
||||
}
|
||||
else if(event.getLine(1).equalsIgnoreCase("server"))
|
||||
{
|
||||
@@ -93,7 +95,7 @@ public class SignChange implements Listener
|
||||
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));
|
||||
API.statusMsg(event.getPlayer(), "serversign_created", true);
|
||||
Core.statusMsg(event.getPlayer(), "serversign_created", true);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -114,7 +116,7 @@ public class SignChange implements Listener
|
||||
if(!first)
|
||||
{
|
||||
String num = s.split(" ")[0];
|
||||
if(plugin.isInteger(num))
|
||||
if(Core.isInteger(num))
|
||||
{
|
||||
int number = Integer.valueOf(num);
|
||||
Entry<String, String> e = new SimpleEntry<>("%"+number, Character.toString((char)number));
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.anura.core;
|
||||
package de.anura.core.events;
|
||||
|
||||
import de.anura.core.AnuraCore;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
@@ -67,9 +67,6 @@ commands:
|
||||
togglecommands:
|
||||
description: Only cmd block command!
|
||||
usage: /<command> <player> <enable|disable>
|
||||
updatecommandblocks:
|
||||
description: Updates command blocks at the given positions
|
||||
usage: /<command> {<x1>, <y1>, <z1>}...
|
||||
toggledbljump:
|
||||
description: Toggles the double jump
|
||||
usage: /<command>
|
||||
|
||||
Reference in New Issue
Block a user