Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.24 KB | None | 0 0
  1. else if (args.length > 0 && args[0].equalsIgnoreCase("menu")) {
  2.             if(!player.hasPermission("simpleinventorypets.create")) {
  3.                 msg(player, permission);
  4.             }
  5.            
  6.            
  7.             if (args[1].equalsIgnoreCase("add")) {
  8.                 Block targetedBlock = player.getTargetBlock(null, 10);
  9.                 Location location = targetedBlock.getLocation();
  10.                
  11.                 if(targetedBlock.getType() == Material.TURTLE_EGG) {
  12.                     List<String> list = plugin.getLocationsConfig().getStringList("locations");
  13.                     String testString = location.getX() + ", " + location.getY() + ", " + location.getZ();
  14.                     for (int i = 0; i < list.size(); i++) {
  15.                        
  16.                         String test = list.get(i);
  17.                        
  18.                         if (testString.equals(test)) {
  19.                             msg(player, sameLocation);
  20.                             return false;
  21.                         }
  22.                        
  23.                     }
  24.                    
  25.                     msg(player, successfulAdd);
  26.                     list.add(location.getX() + ", " + location.getY() + ", " + location.getZ());
  27.                     plugin.getLocationsConfig().set("locations", list);
  28.                     plugin.saveCustomYml(plugin.locationsConf, plugin.locationsYml);
  29.                     plugin.reloadCustomYml(plugin.locationsConf, plugin.locationsYml);
  30.                    
  31.                     location.getWorld().spawnEntity(location.add(0.5, 0, 0.5), EntityType.ARMOR_STAND);
  32.                
  33.                 }
  34.                 else {
  35.                     msg(player, turtleEgg);
  36.                 }
  37.             }
  38.            
  39.             else if (args.length > 0 && args[1].equalsIgnoreCase("remove")) {
  40.                
  41.                 Block targetBlock = player.getTargetBlock(null, 10);
  42.                 Location location = targetBlock.getLocation();
  43.                 if (targetBlock.getType() == Material.TURTLE_EGG) {
  44.                    
  45.                     List<String> list = plugin.getLocationsConfig().getStringList("locations");
  46.                     String testString = location.getX() + ", " + location.getY() + ", " + location.getZ();
  47.                     for (int i = 0; i < list.size(); i++) {
  48.                        
  49.                         String test = list.get(i);
  50.                        
  51.                         if (testString.equals(test)) {
  52.                             msg(player, successfulRemove);
  53.                             list.remove(test);
  54.                             plugin.getLocationsConfig().set("locations", list);
  55.                             plugin.saveCustomYml(plugin.locationsConf, plugin.locationsYml);
  56.                             plugin.reloadCustomYml(plugin.locationsConf, plugin.locationsYml);
  57.                             return true;
  58.                         }
  59.                        
  60.                     }
  61.                    
  62.                 }
  63.                 else {
  64.                     msg(player, turtleEgg);
  65.                 }
  66.             }
  67.            
  68.             else {
  69.                 msg(player, invalidArgs);
  70.             }
  71.            
  72.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement