Refactoring

This commit is contained in:
kaenganxt
2014-10-27 17:08:16 +01:00
parent 36645c4071
commit a290afdb6a
37 changed files with 1570 additions and 1342 deletions

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}