Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hauptklasse:
- package mobileenchant;
- import org.bukkit.plugin.java.JavaPlugin;
- public class mobileenchantmain extends JavaPlugin {
- @Override
- public void onEnable()
- {
- System.out.println("Zaubertisch aktiviert");
- initConfig();
- Kommandos();
- Kommandos1();
- }
- public void initConfig(){
- this.reloadConfig();
- this.getConfig().options().header("Zaubertisch config");
- this.getConfig().options().copyDefaults(true);
- this.saveConfig();
- }
- public void Kommandos() {
- getCommand("zaubertisch").setExecutor(new mobileenchant_CMDzaubertisch(this));
- }
- public void Kommandos1() {
- getCommand("setzaubertisch").setExecutor(new mobileenchant_CMDsetzaubertisch (this));
- }
- @Override
- public void onDisable()
- {
- System.out.println("Zaubertisch deaktiviert");
- }
- }
- Die Klasse für den Kommand die den Zaubertisch für den Spieler öffnet:
- package mobileenchant;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- public class mobileenchant_CMDzaubertisch implements CommandExecutor {
- private mobileenchantmain me;
- public mobileenchant_CMDzaubertisch (mobileenchantmain me)
- {
- this.me = me;
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String [] args)
- {
- if(sender instanceof Player){
- Player p = (Player) sender;
- if(p.hasPermission("zaubertisch.use"))
- {
- String world = p.getLocation().getWorld().getName();
- Location location = new Location(Bukkit.getWorld(world),
- me.getConfig().getInt("MobileEnchant.commands.setzaubertisch." + world + ".coordx"),
- me.getConfig().getInt("MobileEnchant.commands.setzaubertisch." + world + ".coordy"),
- me.getConfig().getInt("MobileEnchant.commands.setzaubertisch." + world + ".coordz"));
- p.openEnchanting(location, true);
- }else {
- p.sendMessage(ChatColor.DARK_RED + "Du hast nicht die Rechte um diesen Befehl zu nutzen!");
- }
- }
- else{
- sender.sendMessage(ChatColor.DARK_RED + "Fehler: " + ChatColor.RED + "Dieser Befehl ist nur fuer Spieler benutzbar!");
- }
- return true;
- }
- }
- Die Klasse für den Kommand der die Posistion des Zaubertisches im Hintergrund macht
- package mobileenchant;
- import org.bukkit.ChatColor;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- public class mobileenchant_CMDsetzaubertisch implements CommandExecutor {
- private mobileenchantmain mes;
- public mobileenchant_CMDsetzaubertisch (mobileenchantmain mes)
- {
- this.mes = mes;
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String [] args)
- {
- if(sender.hasPermission("zaubertisch.set"))
- {
- if(args.length == 4)
- {
- try{
- String world = args[0];
- String xcoord = args[1];
- String ycoord = args[2];
- String zcoord = args[3];
- int coordx = Integer.parseInt(xcoord);
- int coordy = Integer.parseInt(ycoord);
- int coordz = Integer.parseInt(zcoord);
- mes.getConfig().addDefault("MobileEnchant.commands.setzaubertisch." + world + ".coordx", coordx);
- mes.getConfig().set("MobileEnchant.commands.setzaubertisch." + world + ".coordx", coordx);
- mes.getConfig().addDefault("MobileEnchant.commands.setzaubertisch." + world + ".coordy", coordy);
- mes.getConfig().set("MobileEnchant.commands.setzaubertisch." + world + ".coordy", coordy);
- mes.getConfig().addDefault("MobileEnchant.commands.setzaubertisch." + world + ".coordz", coordz);
- mes.getConfig().set("MobileEnchant.commands.setzaubertisch." + world + ".coordz", coordz);
- mes.saveConfig();
- mes.reloadConfig();
- sender.sendMessage(ChatColor.BLUE + "Zaubertisch gesetzt in Welt " + ChatColor.YELLOW + world + ChatColor.BLUE + " bei den Koordinaten x: " + ChatColor.YELLOW + coordx + ChatColor.BLUE + " y: " + ChatColor.YELLOW + coordy + ChatColor.BLUE + " z: " + ChatColor.YELLOW + coordz);
- }catch (NumberFormatException e){
- sender.sendMessage(ChatColor.DARK_RED + "Fehler:" + ChatColor.RED + " Hast du wirklich Zahlen als Koordinaten eingegeben?");
- }
- }
- else {
- sender.sendMessage(ChatColor.BLUE + "Benutzung: " + ChatColor.YELLOW + "/setzaubertisch <Welt> <x> <y> <z>");
- }
- }else {
- sender.sendMessage(ChatColor.DARK_RED + "Du hast nicht die Rechte um diesen Befehl zu nutzen!");
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement