Baran100

Untitled

Dec 17th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.05 KB | None | 0 0
  1. package com.gmail.KrzysiekRysiek;
  2.  
  3. import java.util.List;
  4. import java.util.Set;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.Location;
  9. import org.bukkit.command.Command;
  10. import org.bukkit.command.CommandExecutor;
  11. import org.bukkit.command.CommandSender;
  12. import org.bukkit.configuration.ConfigurationSection;
  13. import org.bukkit.entity.Player;
  14.  
  15. public class Configi implements CommandExecutor{
  16.  
  17. @Override
  18. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  19. if(cmd.getName().equalsIgnoreCase("config")){
  20. if(args.length !=1){
  21. return true;
  22. }
  23. if(!(sender instanceof Player)){
  24. return true;
  25. }
  26. Player p = (Player) sender;
  27. if(args[0].equalsIgnoreCase("set")){
  28. String pn = p.getName().toLowerCase();
  29. String ip = p.getAddress().getAddress().toString().replaceAll("/", "");
  30. String uuid = p.getUniqueId().toString();
  31. Main.getInst().getConfig().set("players." + pn + ".uuid", uuid);
  32. Main.getInst().getConfig().set("players." + pn + ".ip", ip);
  33. Main.getInst().saveConfig();
  34. return true;
  35. }
  36. if(args[0].equalsIgnoreCase("get")){
  37. String pn = p.getName().toLowerCase();
  38. if(Main.getInst().getConfig().get("players." + pn) !=null){
  39. p.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "IP ADRESS: " + ChatColor.GOLD + Main.getInst().getConfig().getString("players." + pn + ".ip"));
  40. p.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "UUID: " + ChatColor.GOLD + Main.getInst().getConfig().getString("players." + pn + ".uuid"));
  41. }
  42. return true;
  43. }
  44. }
  45. if(cmd.getName().equalsIgnoreCase("spawn")){
  46. if(args.length !=1){
  47. return true;
  48. }
  49. Player g = (Player) sender;
  50. if(args.length == 0){
  51. if(sender instanceof Player){
  52. double x = Main.getInst().getConfig().getDouble("spawn-locX");
  53. double y = Main.getInst().getConfig().getDouble("spawn-locY");
  54. double z = Main.getInst().getConfig().getDouble("spawn-locZ");
  55. String wName = Main.getInst().getConfig().getString("spawn-locWorld");
  56. Location l = new Location(Bukkit.getWorld(wName),x,y,z);
  57. g.teleport(l);
  58. g.sendMessage(ChatColor.GRAY + "Przeteleportowano!");
  59. return true;
  60. }
  61. }
  62. if(!(sender instanceof Player)){
  63. return true;
  64. }
  65. if(args.length == 1){
  66. Player p = (Player) sender;
  67. if(args[0].equalsIgnoreCase("set")){
  68. Location l = p.getLocation();
  69. Main.getInst().getConfig().set("spawn-locX", l.getX());
  70. Main.getInst().getConfig().set("spawn-locY", l.getY());
  71. Main.getInst().getConfig().set("spawn-locZ", l.getZ());
  72. Main.getInst().getConfig().set("spawn-locWorld", l.getWorld().getName());
  73. Main.getInst().saveConfig();
  74. return true;
  75. }
  76. }
  77. }
  78. if(cmd.getName().equalsIgnoreCase("warp")){
  79. if(!(sender instanceof Player)){
  80. sender.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "Nie jestes graczem!");
  81. return true;
  82. }
  83. if(args.length == 0){
  84. Set<String> keys = Main.getInst().getConfig().getKeys(false);
  85. String lista = "";
  86. for(String s : keys){
  87. if(!s.equals("autoMsg")){
  88. lista += ", " + s;
  89. }
  90. }
  91. sender.sendMessage(ChatColor.GREEN + "Warpy: " + ChatColor.WHITE + lista.replaceFirst(", ", ""));
  92. }
  93. if(args.length < 1){
  94. sender.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "Uzycie: /warp <nazwawarpu>");
  95. return true;
  96. }
  97. String warpName = args[0].toLowerCase();
  98. if(!Main.getInst().getConfig().contains(warpName)){
  99. sender.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "Nie ma takiego warpu!");
  100. return true;
  101. }
  102. ConfigurationSection warpData = Main.getInst().getConfig().getConfigurationSection(warpName);
  103. Location warpLocation = new Location(Bukkit.getWorld(warpData.getString("world")), warpData.getInt("x"), warpData.getInt("y"), warpData.getInt("z"));
  104. ((Player) sender).teleport(warpLocation);
  105. sender.sendMessage(ChatColor.GRAY + "Przetelportowano!");
  106. }
  107. if(cmd.getName().equalsIgnoreCase("setwarp")){
  108. if(Main.getInst().getConfig().get(args[1]) !=null){
  109. return true;
  110. }
  111. Main.getInst().getConfig().set(args[1] + ".x", 0);
  112. Main.getInst().getConfig().set(args[1] + ".y", 100);
  113. Main.getInst().getConfig().set(args[1] + ".z", 0);
  114. Main.getInst().getConfig().set(args[1] + ".world", "world");
  115. Main.getInst().saveConfig();
  116. }
  117. if(cmd.getName().equalsIgnoreCase("delwarp")){
  118. if(Main.getInst().getConfig().get(args[1]) !=null){
  119. Main.getInst().getConfig().set(args[1], null);
  120. Main.getInst().saveConfig();
  121. }
  122. }
  123. if(cmd.getName().equalsIgnoreCase("automsg")){
  124. if(!sender.hasPermission("ServerEssentials.automsg")){
  125. sender.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "Nie masz dostepu do tej komedy!");
  126. return true;
  127. }
  128. if(args.length == 0){
  129. sender.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "Za malo argumentow!");
  130. return true;
  131. }
  132. if(args.length == 1){
  133. if(args[0].equalsIgnoreCase("list")){
  134. for(int i = 0; i<Main.getInst().msgs.size(); i++){
  135. sender.sendMessage(ChatColor.DARK_RED + "[ServerEssentials] " + ChatColor.RED + "ID " + ChatColor.DARK_GRAY + i + ChatColor.RED + ": " + Main.getInst().msgs.get(i));
  136. }
  137. }
  138. }
  139. if(args.length == 2){
  140. if(args[0].equalsIgnoreCase("remove")){
  141. int numer = Integer.parseInt(args[1]);
  142. Main.getInst().msgs.remove(numer);
  143. Main.getInst().getConfig().set("autoMsg", Main.getInst().msgs);
  144. }
  145. } else{
  146. if(args[0].equalsIgnoreCase("add")){
  147. String msg = "";
  148. for(int i = 1; i<args.length; i++){
  149. msg += " " + args[i];
  150. Main.getInst().saveConfig();
  151. }
  152. msg.replaceFirst(" ", "");
  153. List<String> msgs = Main.getInst().getConfig().getStringList("autoMsg");
  154. msgs.add(msg);
  155. Main.getInst().msgs = msgs;
  156. Main.getInst().getConfig().set("autoMsg", msgs);
  157. }
  158. }
  159. }
  160. return false;
  161. }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment