Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- import java.io.File;
- import java.io.IOException;
- import java.util.List;
- import org.bukkit.Bukkit;
- import org.bukkit.GameMode;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.plugin.PluginManager;
- public class Commands implements CommandExecutor{
- private Jumping plugin;
- public Commands(Jumping main){
- this.plugin = main;
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
- if(sender instanceof Player){
- File file = new File("plugins/Jumping", "Arenas.yml");
- FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- FileConfiguration config = this.plugin.getConfig();
- Player p = (Player) sender;
- //Args length == 0
- if(args.length == 0){
- p.sendMessage(plugin.prefix + "§7/jumping help");
- }
- //Args length == 1
- if(args.length == 1){
- //help
- if(args[0].equalsIgnoreCase("help")){
- p.sendMessage("§8[]===============( §r§6Jumping Help §8)===============[]");
- p.sendMessage("§8Version: §9" + this.plugin.getDescription().getVersion());
- p.sendMessage("§8Developer: §9" + this.plugin.getDescription().getAuthors());
- p.sendMessage("§8Copyright: §9© by bapf");
- p.sendMessage("§8<<===========================================>>");
- p.sendMessage("§8/Jumping help - §9Hilfe seite!");
- p.sendMessage("§8/Jumping reloadPlugin - §9Reloade das Plugin!");
- p.sendMessage("§8/Jumping reloadConfig - §9Reloade die Config!");
- p.sendMessage("§8/Jumping leave - §9Spiel verlassen!");
- p.sendMessage("§8/Jumping jumpnruns - §9Liste aller JumpnRuns!");
- p.sendMessage("§8/Jumping list <jumpnrun> - §9Liste aller Spieler in einem JumpnRuns!");
- p.sendMessage("§8/Jumping join <jumpnrun> - §9Spiel joinen");
- p.sendMessage("§8/Jumping tp <jumpnrun> - §9Tp dich zu einem JumpnRun Spawn!");
- p.sendMessage("§8/Jumping create <jumpnrun> - §9JumpnRun Spawn setzen!");
- p.sendMessage("§8/Jumping delete <jumpnrun> - §9JumpnRun loeschen!");
- p.sendMessage("§8/Jumping finish <player> - §9Hole einen Spieler aus einem JumpnRun!");
- p.sendMessage("§8/Jumping find <player> - §9Finde einen Spieler in einer Arena!");
- p.sendMessage("§8/Jumping send <player> <jumpnrun> - §9Sende einen Spieler in ein JumpnRun!");
- p.sendMessage("§8<<===========================================>>");
- }
- //ReloadPlugin
- if(args[0].equalsIgnoreCase("reloadPlugin")){
- if(p.hasPermission("Jumping.reloadPlugin")){
- PluginManager plg = Bukkit.getPluginManager();
- Plugin jumping = plg.getPlugin("Jumping");
- if(plg.getPlugin("Jumping") == null){
- p.sendMessage("§cFehler: Das Plugin gibt es nicht. Schau mal bitte im Plugins Ordner nach ob es das Plugin 'Jumping' gibt.");
- }else{
- plg.disablePlugin(jumping);
- plg.enablePlugin(jumping);
- }
- p.sendMessage(plugin.prefix + "§7Plugin erfolgreich neu geladen!");
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //ReloadConfig
- if(args[0].equalsIgnoreCase("reloadConfig")){
- if(p.hasPermission("Jumping.reloadConfig")){
- plugin.reloadConfig();
- p.sendMessage(plugin.prefix + "§7Config erfolgreich neu geladen!");
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //leave
- if(args[0].equalsIgnoreCase("leave")){
- if(p.hasPermission("Jumping.leave")){
- plugin.leaveArena(p);
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //list
- if(args[0].equalsIgnoreCase("list")){
- if(p.hasPermission("Jumping.list")){
- p.sendMessage("§cFehler: §c/jumping list <JumpnRun>");
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //jumpnruns
- if(args[0].equalsIgnoreCase("jumpnruns")){
- if(p.hasPermission("Jumping.jumpnruns")){
- String arenen = "";
- List arenas = cfg.getStringList("arenas");
- for (int i = 0; i < arenas.size(); i++) {
- arenen = arenen + (String)arenas.get(i) + "§f, §8";
- }
- p.sendMessage(this.plugin.prefix + "§7JumpnRuns: §8" + arenen);
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //join
- if(args[0].equalsIgnoreCase("join")){
- if(p.hasPermission("Jumping.join")){
- p.sendMessage("§cFehler: §c/jumping join <JumpnRun>");
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //tp
- if(args[0].equalsIgnoreCase("tp")){
- if(p.hasPermission("Jumping.tp")){
- p.sendMessage("§cFehler: §c/jumping tp <JumpnRun>");
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //create
- if(args[0].equalsIgnoreCase("create")){
- if(p.hasPermission("Jumping.create")){
- p.sendMessage("§cFehler: §c/jumping create <JumpnRun Name> <Leicht:Mittel:Schwer:SSchwer>");
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //delete
- if(args[0].equalsIgnoreCase("delete")){
- if(p.hasPermission("Jumping.delete")){
- p.sendMessage("§cFehler: §c/jumping delete <JumpnRun>");
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //finish
- if(args[0].equalsIgnoreCase("finish")){
- if(p.hasPermission("Jumping.finish")){
- p.sendMessage("§cFehler: §c/jumping finish <Player>");
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //find
- if(args[0].equalsIgnoreCase("find")){
- if(p.hasPermission("Jumping.find")){
- p.sendMessage("§cFehler: §c/jumping find <Player>");
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //send
- if(args[0].equalsIgnoreCase("send")){
- if(p.hasPermission("Jumping.send")){
- p.sendMessage("§cFehler: §c/jumping send <Player> <JumpnRun>");
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- }
- //Args length == 2
- if(args.length == 2){
- //jumpnruns
- if(args[0].equalsIgnoreCase("jumpnruns")){
- if(p.hasPermission("Jumping.jumpnruns")){
- if(args[1].equalsIgnoreCase("leicht")){
- String arenen = "";
- List arenas = cfg.getStringList("leicht");
- for (int i = 0; i < arenas.size(); i++) {
- arenen = arenen + (String)arenas.get(i) + "§f, §8";
- }
- p.sendMessage(this.plugin.prefix + "§7Leichte JumpnRuns: §8" + arenen);
- }
- if(args[1].equalsIgnoreCase("Mittel")){
- String arenen = "";
- List arenas = cfg.getStringList("mittel");
- for (int i = 0; i < arenas.size(); i++) {
- arenen = arenen + (String)arenas.get(i) + "§f, §8";
- }
- p.sendMessage(this.plugin.prefix + "§7Mittlere JumpnRuns: §8" + arenen);
- }
- if(args[1].equalsIgnoreCase("Schwer")){
- String arenen = "";
- List arenas = cfg.getStringList("schwer");
- for (int i = 0; i < arenas.size(); i++) {
- arenen = arenen + (String)arenas.get(i) + "§f, §8";
- }
- p.sendMessage(this.plugin.prefix + "§7Schwere JumpnRuns: §8" + arenen);
- }
- if(args[1].equalsIgnoreCase("SSchwer")){
- String arenen = "";
- List arenas = cfg.getStringList("sschwer");
- for (int i = 0; i < arenas.size(); i++) {
- arenen = arenen + (String)arenas.get(i) + "§f, §8";
- }
- p.sendMessage(this.plugin.prefix + "§7Sehr Schwere JumpnRuns: §8" + arenen);
- }
- }
- }else{
- p.sendMessage(plugin.noperm);
- }
- //join
- if(args[0].equalsIgnoreCase("join")){
- //if(p.hasPermission("Jumping.join")){
- if(!plugin.inJump.contains(p.getName())){
- plugin.inJump.add(p.getName());
- plugin.oldItems.put(p.getUniqueId(), p.getInventory().getContents());
- plugin.oldLoc.put(p.getUniqueId(), p.getLocation());
- p.getInventory().clear();
- p.updateInventory();
- String world = cfg.getString("JumpnRuns." + args[1] + ".World");
- double x = cfg.getDouble("JumpnRuns." + args[1] + ".PosX");
- double y = cfg.getDouble("JumpnRuns." + args[1] + ".PosY");
- double z = cfg.getDouble("JumpnRuns." + args[1] + ".PosZ");
- double yaw = cfg.getDouble("JumpnRuns." + args[1] + ".PosYam");
- double pitch = cfg.getDouble("JumpnRuns." + args[1] + ".PosPitch");
- Location loc = new Location(Bukkit.getWorld(world), x, y, z);
- loc.setPitch((float)pitch);
- loc.setYaw((float)yaw);
- plugin.arena.put(p.getName(), args[1]);
- plugin.gamemode.put(p.getName(), p.getGameMode());
- p.setGameMode(GameMode.ADVENTURE);
- p.teleport(loc);
- p.setHealth(20);
- p.setFoodLevel(20);
- p.sendMessage(plugin.prefix + "§7" + p.getName() + " §8> §7" + args[1]);
- plugin.jumpnrunPlayers.put(p, args[1]);
- p.sendMessage(plugin.prefix + "§7Um das JumpnRun zu verlassen: §8/jumping leave");
- if(config.getString("notify").equalsIgnoreCase("true")){
- for (Player all : Bukkit.getOnlinePlayers()){
- if(all.hasPermission("Jumping.notify")){
- all.sendMessage(plugin.prefix + "§7" + p.getName() + "§8 > §7" + args[1]);
- }
- }
- }
- }else{
- p.sendMessage(plugin.prefix + "§7Fehler: Du bist schon in einem JumpnRun! §8/jumping leave §7um ein JumpnRun zu verlassen!");
- }
- //}else{
- //p.sendMessage(plugin.noperm);
- //}
- }
- //delete
- if(args[0].equalsIgnoreCase("delete")){
- if(p.hasPermission("Jumping.delete")){
- cfg.set("JumpnRuns." + args[1], null);
- File fileC = new File("plugins/Jumping", "Arenas.yml");
- FileConfiguration cfgC = YamlConfiguration.loadConfiguration(fileC);
- List arenas = cfg.getStringList("arenas");
- arenas.remove(args[1]);
- cfg.set("arenas", arenas);
- try {
- cfg.save(fileC);
- } catch (IOException e) {
- e.printStackTrace();
- }
- try {
- cfg.save(file);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- p.sendMessage(plugin.prefix + "§7JumpnRun §8" + args[1] + " §7erfolgreich geloescht!");
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //list
- if (args[0].equalsIgnoreCase("list")) {
- if (p.hasPermission("Jumping.list")) {
- String players = "";
- for (Player players_ : this.plugin.jumpnrunPlayers.keySet()) {
- if (((String)this.plugin.jumpnrunPlayers.get(players_)).equalsIgnoreCase(args[1])) {
- players = players + players_.getName() + "§f, §8";
- }
- }
- p.sendMessage(this.plugin.prefix + "§7Spieler: §8" + players);
- } else {
- p.sendMessage(this.plugin.noperm);
- }
- }
- //tp
- if(args[0].equalsIgnoreCase("tp")){
- if(p.hasPermission("Jumping.tp")){
- try{
- String world = cfg.getString("JumpnRuns." + args[1] + ".World");
- double x = cfg.getDouble("JumpnRuns." + args[1] + ".PosX");
- double y = cfg.getDouble("JumpnRuns." + args[1] + ".PosY");
- double z = cfg.getDouble("JumpnRuns." + args[1] + ".PosZ");
- double yaw = cfg.getDouble("JumpnRuns." + args[1] + ".PosYam");
- double pitch = cfg.getDouble("JumpnRuns." + args[1] + ".PosPitch");
- Location loc = new Location(Bukkit.getWorld(world), x, y, z);
- loc.setPitch((float)pitch);
- loc.setYaw((float)yaw);
- p.teleport(loc);
- p.sendMessage(this.plugin.prefix + "§7Du hast dich zum §8" + args[1] + " §7teleportiert!");
- }catch(Exception e){
- p.sendMessage(this.plugin.prefix + "§cFehler: Dieses JumpnRun gibt es nicht!");
- }
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //find
- if(args[0].equalsIgnoreCase("find")){
- if(p.hasPermission("Jumping.find")){
- Player target = UUIDManager.getPlayer(args[1]);
- if(target == null){
- p.sendMessage("§cFehler: Dieser Spieler ist nicht Online!");
- }else{
- if(plugin.inJump.contains(target.getName())){
- p.sendMessage(plugin.prefix + "§8" + target.getName() + " §7ist im JumpnRun §8" + plugin.arena.get(target.getName()) + " §7!");
- }else{
- p.sendMessage("§cFehler: Der Spieler ist in keinem JumpnRun!");
- }
- }
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //finish
- if(args[0].equalsIgnoreCase("finish")){
- if(p.hasPermission("Jumping.finish")){
- Player target = UUIDManager.getPlayer(args[1]);
- if(plugin.inJump.contains(target.getName())){
- target.getInventory().clear();
- ItemStack[] old = (ItemStack[])plugin.oldItems.get(target.getUniqueId());
- target.getInventory().setContents(old);
- target.updateInventory();
- target.setGameMode(plugin.gamemode.get(target.getName()));
- Location loc = (Location)plugin.oldLoc.get(target.getUniqueId());
- target.teleport(loc);
- plugin.inJump.remove(target.getName());
- plugin.jumpnrunPlayers.remove(target.getName());
- plugin.oldItems.remove(target.getName());
- plugin.oldLoc.remove(target.getName());
- target.sendMessage(plugin.prefix + "§7Du wurdest von §8" + p.getName() + " §7aus dem JumpnRun geholt!");
- p.sendMessage(plugin.prefix + "§7Du hast §8" + target.getName() + " §7aus dem JumpnRun geholt!");
- if(config.getString("notify").equalsIgnoreCase("true")){
- for (Player all : Bukkit.getOnlinePlayers()){
- if (all.hasPermission("Jumping.notify"))
- {
- all.sendMessage(plugin.prefix + "§7" + target.getName() + "§8 < §7" + plugin.arena.get(target.getName()) + " §7(§8" + p.getName() + "§7)");
- }
- }
- }
- plugin.arena.remove(target.getName());
- }else{
- p.sendMessage("§cFehler: Der Spieler ist in keinem JumpnRun!");
- }
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- //ENDE ARGS 2
- }
- //Args length == 3
- if(args.length == 3){
- //create
- if (args[0].equalsIgnoreCase("create")) {
- if (p.hasPermission("Jumping.create")) {
- String world = p.getWorld().getName();
- double x = p.getLocation().getX();
- double y = p.getLocation().getY();
- double z = p.getLocation().getZ();
- double yaw = p.getLocation().getYaw();
- double pitch = p.getLocation().getPitch();
- cfg.set("JumpnRuns." + args[1] + ".World", world);
- cfg.set("JumpnRuns." + args[1] + ".PosX", Double.valueOf(x));
- cfg.set("JumpnRuns." + args[1] + ".PosY", Double.valueOf(y));
- cfg.set("JumpnRuns." + args[1] + ".PosZ", Double.valueOf(z));
- cfg.set("JumpnRuns." + args[1] + ".PosYaw", Double.valueOf(yaw));
- cfg.set("JumpnRuns." + args[1] + ".PosPitch", Double.valueOf(pitch));
- try
- {
- cfg.save(file);
- }
- catch (IOException e1) {
- e1.printStackTrace();
- }
- File fileC = new File("plugins/Jumping", "Arenas.yml");
- FileConfiguration cfgC = YamlConfiguration.loadConfiguration(fileC);
- if(args[2].equalsIgnoreCase("leicht")){
- List leicht = cfg.getStringList("leicht");
- leicht.add(args[1]);
- cfg.set("leicht", leicht);
- p.sendMessage(this.plugin.prefix + "§7Das JumpnRun §8" + args[1] + " §7wurde erfolgreich erstellt! (§8Leicht§7)");
- }
- if(args[2].equalsIgnoreCase("mittel")){
- List mittel = cfg.getStringList("mittel");
- mittel.add(args[1]);
- cfg.set("mittel", mittel);
- p.sendMessage(this.plugin.prefix + "§7Das JumpnRun §8" + args[1] + " §7wurde erfolgreich erstellt! (§8Mittel§7)");
- }
- if(args[2].equalsIgnoreCase("schwer")){
- List schwer = cfg.getStringList("schwer");
- schwer.add(args[1]);
- cfg.set("schwer", schwer);
- p.sendMessage(this.plugin.prefix + "§7Das JumpnRun §8" + args[1] + " §7wurde erfolgreich erstellt! (§8Schwer§7)");
- }
- if(args[2].equalsIgnoreCase("sschwer")){
- List sschwer = cfg.getStringList("sschwer");
- sschwer.add(args[1]);
- cfg.set("sschwer", sschwer);
- p.sendMessage(this.plugin.prefix + "§7Das JumpnRun §8" + args[1] + " §7wurde erfolgreich erstellt! (§8Sehr Schwer§7)");
- }
- List arenas = cfg.getStringList("arenas");
- arenas.add(args[1]);
- cfg.set("arenas", arenas);
- try {
- cfg.save(fileC);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- else{
- p.sendMessage(this.plugin.noperm);
- }
- }
- //send
- if(args[0].equalsIgnoreCase("send")){
- if(p.hasPermission("Jumping.send")){
- Player target = UUIDManager.getPlayer(args[1]);
- if(plugin.inJump.contains(target.getName())){
- p.sendMessage("§cFehler: Der Spieler ist schon in einem JumpnRun!");
- }else{
- try{
- plugin.inJump.add(target.getName());
- plugin.oldLoc.put(target.getUniqueId(), target.getLocation());
- plugin.oldItems.put(target.getUniqueId(), target.getInventory().getContents());
- plugin.arena.put(target.getName(), args[2]);
- plugin.gamemode.put(target.getName(), target.getGameMode());
- plugin.jumpnrunPlayers.put(target, args[2]);
- target.getInventory().clear();
- target.updateInventory();
- String world = cfg.getString("JumpnRuns." + args[2] + ".World");
- double x = cfg.getDouble("JumpnRuns." + args[2] + ".PosX");
- double y = cfg.getDouble("JumpnRuns." + args[2] + ".PosY");
- double z = cfg.getDouble("JumpnRuns." + args[2] + ".PosZ");
- double yaw = cfg.getDouble("JumpnRuns." + args[2] + ".PosYam");
- double pitch = cfg.getDouble("JumpnRuns." + args[2] + ".PosPitch");
- Location loc = new Location(Bukkit.getWorld(world), x, y, z);
- loc.setPitch((float)pitch);
- loc.setYaw((float)yaw);
- target.setGameMode(GameMode.ADVENTURE);
- target.teleport(loc);
- target.setHealth(20);
- target.setFoodLevel(20);
- target.sendMessage(plugin.prefix + "§7Du wurdest von §8" + p.getName() + " §7in das JumpnRun §8" + args[2] + " §7geschickt!");
- target.sendMessage(plugin.prefix + "§7Um das JumpnRun zu verlassen: §8/jumping leave");
- p.sendMessage(plugin.prefix + "§7Du hast §8" + target.getName() + " §7in das JumpnRun §8" + args[2] + " §7geschickt!");
- p.sendMessage(plugin.prefix + "§7Um §8" + target.getName() + " §7wieder aus dem JumpnRun zu holen: §8/jumping finish " + target.getName());
- if(config.getString("notify").equalsIgnoreCase("true")){
- for(Player all : Bukkit.getOnlinePlayers()){
- if(all.hasPermission("Jumping.notify")){
- all.sendMessage(plugin.prefix + "§7" + target.getName() + "§8 > §7" + args[2] + " §7(§8" + p.getName() + "§7)");
- }
- }
- }
- }catch (Exception e){
- target.sendMessage(this.plugin.prefix + "§7Du wurdest von §8" + p.getName() + " §7in das JumpnRun §8" + args[2] + " §7gesendet!");
- target.sendMessage(this.plugin.prefix + "§cDieses JumpnRun gibt aber es nicht! Du wurdest wieder aus dem JumpnRun geholt!");
- this.plugin.leaveArena(target);
- p.sendMessage(this.plugin.prefix + "§cDieses JumpnRun gibt es nicht!");
- }
- }
- }else{
- p.sendMessage(plugin.noperm);
- }
- }
- }
- }else{
- sender.sendMessage("Du musst ein Spieler sein!");
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement