Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.37 KB | None | 0 0
  1. package me.Geekenex.creativetour;
  2.  
  3. import java.util.Arrays;
  4. import java.util.List;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.Location;
  8. import org.bukkit.World;
  9. import org.bukkit.command.Command;
  10. import org.bukkit.command.CommandSender;
  11. import org.bukkit.entity.Player;
  12. import org.bukkit.plugin.java.JavaPlugin;
  13. import com.intellectualcrafters.plot.api.PlotAPI;
  14. import com.intellectualcrafters.plot.object.Plot;
  15.  
  16. public class creative_tour extends JavaPlugin {
  17.  
  18. PlotAPI API;
  19.  
  20. @SuppressWarnings("deprecation")
  21. @Override
  22. public void onEnable() {
  23. API = new PlotAPI(null);
  24. }
  25.  
  26. @Override
  27. public void onDisable() {
  28.  
  29. }
  30.  
  31. public Plot getplot2(Player p) {
  32. Plot plot = API.getPlot(p.getLocation());
  33. return plot;
  34. }
  35.  
  36. public String plottostring(Plot plot){
  37. String msg = plot.toString();
  38. msg = msg.replace(";", ",");
  39. return msg;
  40.  
  41. }
  42. public void tptoplot(Player p, Plot plot) {
  43.  
  44. double x = API.getHomeLocation(plot).getX();
  45. double y = API.getHomeLocation(plot).getY();
  46. double z = API.getHomeLocation(plot).getZ();
  47. World world = API.getHomeLocation(plot).getWorld();
  48. Location loc = new Location(world,x,y,z);
  49. p.teleport(loc);
  50.  
  51. }
  52.  
  53. public Plot stringtoplot(String word){
  54.  
  55. List<String> items = Arrays.asList(word.split("\\s*,\\s*"));
  56.  
  57. Bukkit.broadcastMessage(items.toString());
  58.  
  59. String name = items.get(0);
  60. World world= Bukkit.getWorld(name);
  61. int one = Integer.valueOf(items.get(1));
  62. int two =Integer.valueOf(items.get(2));
  63. @SuppressWarnings("deprecation")
  64. Plot plot = API.getPlot(world, one, two);
  65. return plot;
  66.  
  67. }
  68.  
  69.  
  70. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  71. Player player = (Player) sender;
  72. if (cmd.getName().equalsIgnoreCase("tour") && sender instanceof Player) {
  73. if(args.length == 0) {
  74. player.sendMessage("Specify a tour");
  75. } else {
  76. if (args[0].equalsIgnoreCase(args[0])) {
  77. if (getConfig().contains(args[0])) {
  78.  
  79. player.sendMessage("Welcome to the tour of " + args[0]);
  80. }
  81. if (!args[0].equalsIgnoreCase("add") && !args[0].equalsIgnoreCase("remove")) {
  82. if(!getConfig().contains(args[0])) {
  83. player.sendMessage("That tour doesn't exist!");
  84. }
  85. }
  86. }
  87. //creative manager command add plot to list
  88. if (args[0].equalsIgnoreCase("add") && player.hasPermission("creative")) {
  89. if (args.length == 2) {
  90. if (!args[1].equalsIgnoreCase("add") && !args[1].equalsIgnoreCase("remove")) {
  91. List<String> playerlist = getConfig().getStringList(args[1]);
  92. if (!playerlist.contains(plottostring(getplot2(player)))) {
  93. playerlist.add(plottostring(getplot2(player)));
  94. if (playerlist.size() == 1) {
  95. player.sendMessage(playerlist + " is now in " + args[1]);
  96. }
  97. if (playerlist.size() != 1) {
  98. player.sendMessage(playerlist + " are now in " + args[1]);
  99. }
  100. }
  101. this.getConfig().set(args[1], playerlist);
  102. saveConfig();
  103. reloadConfig();
  104. }
  105. }
  106. else {
  107. player.sendMessage("Please use /tour add <tourtype>.");
  108. }
  109. }
  110. //creative manager command remove plot from list
  111. if (args[0].equalsIgnoreCase("remove") && player.hasPermission("creative")) {
  112. if (args.length == 2) {
  113.  
  114. List<String> playerlist = getConfig().getStringList(args[1]);
  115.  
  116. if (playerlist.size() != 0) {
  117. if (playerlist.contains(plottostring(getplot2(player)))) {
  118. playerlist.remove(plottostring(getplot2(player)));
  119. if (playerlist.size() == 1) {
  120. player.sendMessage(playerlist + " is now in " + args[1]);
  121. }
  122. if (playerlist.size() > 1) {
  123. player.sendMessage(playerlist + " are now in " + args[1]);
  124. }
  125. this.getConfig().set(args[1], playerlist);
  126. if (playerlist.isEmpty()) {
  127. this.getConfig().set(args[1],null);
  128. player.sendMessage(args[1] + " was empty and was removed");
  129. }
  130. }
  131. }
  132. saveConfig();
  133. reloadConfig();
  134.  
  135. }
  136. else {
  137. player.sendMessage("Please use /tour remove <tourtype>.");
  138. }
  139. }
  140. }
  141. return true;
  142.  
  143. }
  144. return false;
  145. }
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement