Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1.  
  2.  
  3. Hauptklasse:
  4.  
  5. package mobileenchant;
  6.  
  7. import org.bukkit.plugin.java.JavaPlugin;
  8.  
  9. public class mobileenchantmain extends JavaPlugin {
  10.  
  11. @Override
  12. public void onEnable()
  13. {
  14. System.out.println("Zaubertisch aktiviert");
  15. initConfig();
  16. Kommandos();
  17. Kommandos1();
  18.  
  19. }
  20. public void initConfig(){
  21. this.reloadConfig();
  22. this.getConfig().options().header("Zaubertisch config");
  23. this.getConfig().options().copyDefaults(true);
  24. this.saveConfig();
  25. }
  26.  
  27. public void Kommandos() {
  28. getCommand("zaubertisch").setExecutor(new mobileenchant_CMDzaubertisch(this));
  29.  
  30.  
  31. }
  32.  
  33. public void Kommandos1() {
  34. getCommand("setzaubertisch").setExecutor(new mobileenchant_CMDsetzaubertisch (this));
  35.  
  36.  
  37. }
  38.  
  39.  
  40. @Override
  41. public void onDisable()
  42. {
  43. System.out.println("Zaubertisch deaktiviert");
  44. }
  45. }
  46.  
  47. Die Klasse für den Kommand die den Zaubertisch für den Spieler öffnet:
  48.  
  49. package mobileenchant;
  50.  
  51. import org.bukkit.Bukkit;
  52. import org.bukkit.ChatColor;
  53. import org.bukkit.Location;
  54. import org.bukkit.command.Command;
  55. import org.bukkit.command.CommandExecutor;
  56. import org.bukkit.command.CommandSender;
  57. import org.bukkit.entity.Player;
  58.  
  59. public class mobileenchant_CMDzaubertisch implements CommandExecutor {
  60.  
  61.  
  62. private mobileenchantmain me;
  63.  
  64.  
  65.  
  66.  
  67.  
  68. public mobileenchant_CMDzaubertisch (mobileenchantmain me)
  69. {
  70. this.me = me;
  71. }
  72.  
  73.  
  74.  
  75. public boolean onCommand(CommandSender sender, Command cmd, String label, String [] args)
  76. {
  77. if(sender instanceof Player){
  78. Player p = (Player) sender;
  79. if(p.hasPermission("zaubertisch.use"))
  80. {
  81.  
  82. String world = p.getLocation().getWorld().getName();
  83. Location location = new Location(Bukkit.getWorld(world),
  84. me.getConfig().getInt("MobileEnchant.commands.setzaubertisch." + world + ".coordx"),
  85. me.getConfig().getInt("MobileEnchant.commands.setzaubertisch." + world + ".coordy"),
  86. me.getConfig().getInt("MobileEnchant.commands.setzaubertisch." + world + ".coordz"));
  87. p.openEnchanting(location, true);
  88. }else {
  89.  
  90. p.sendMessage(ChatColor.DARK_RED + "Du hast nicht die Rechte um diesen Befehl zu nutzen!");
  91. }
  92.  
  93. }
  94. else{
  95. sender.sendMessage(ChatColor.DARK_RED + "Fehler: " + ChatColor.RED + "Dieser Befehl ist nur fuer Spieler benutzbar!");
  96. }
  97. return true;
  98. }
  99.  
  100. }
  101.  
  102. Die Klasse für den Kommand der die Posistion des Zaubertisches im Hintergrund macht
  103.  
  104. package mobileenchant;
  105.  
  106. import org.bukkit.ChatColor;
  107.  
  108. import org.bukkit.command.Command;
  109. import org.bukkit.command.CommandExecutor;
  110. import org.bukkit.command.CommandSender;
  111.  
  112.  
  113.  
  114.  
  115. public class mobileenchant_CMDsetzaubertisch implements CommandExecutor {
  116.  
  117. private mobileenchantmain mes;
  118.  
  119.  
  120. public mobileenchant_CMDsetzaubertisch (mobileenchantmain mes)
  121. {
  122. this.mes = mes;
  123. }
  124.  
  125. public boolean onCommand(CommandSender sender, Command cmd, String label, String [] args)
  126. {
  127. if(sender.hasPermission("zaubertisch.set"))
  128. {
  129. if(args.length == 4)
  130. {
  131. try{
  132. String world = args[0];
  133. String xcoord = args[1];
  134. String ycoord = args[2];
  135. String zcoord = args[3];
  136. int coordx = Integer.parseInt(xcoord);
  137. int coordy = Integer.parseInt(ycoord);
  138. int coordz = Integer.parseInt(zcoord);
  139. mes.getConfig().addDefault("MobileEnchant.commands.setzaubertisch." + world + ".coordx", coordx);
  140. mes.getConfig().set("MobileEnchant.commands.setzaubertisch." + world + ".coordx", coordx);
  141. mes.getConfig().addDefault("MobileEnchant.commands.setzaubertisch." + world + ".coordy", coordy);
  142. mes.getConfig().set("MobileEnchant.commands.setzaubertisch." + world + ".coordy", coordy);
  143. mes.getConfig().addDefault("MobileEnchant.commands.setzaubertisch." + world + ".coordz", coordz);
  144. mes.getConfig().set("MobileEnchant.commands.setzaubertisch." + world + ".coordz", coordz);
  145. mes.saveConfig();
  146. mes.reloadConfig();
  147. 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);
  148. }catch (NumberFormatException e){
  149. sender.sendMessage(ChatColor.DARK_RED + "Fehler:" + ChatColor.RED + " Hast du wirklich Zahlen als Koordinaten eingegeben?");
  150. }
  151.  
  152. }
  153. else {
  154. sender.sendMessage(ChatColor.BLUE + "Benutzung: " + ChatColor.YELLOW + "/setzaubertisch <Welt> <x> <y> <z>");
  155. }
  156. }else {
  157. sender.sendMessage(ChatColor.DARK_RED + "Du hast nicht die Rechte um diesen Befehl zu nutzen!");
  158. }
  159. return true;
  160. }
  161.  
  162.  
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement