Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.27 KB | None | 0 0
  1.     public void onPlayerWorldRange(Player player) {
  2.         Location location = player.getLocation();
  3.         WorldPlots.count.put(player, 0);
  4.         WorldPlots.confirmation.put(player, 0);
  5.  
  6.         try {
  7.             for (String key : WorldPlots.config.getConfigurationSection("World").getKeys(false)) {
  8.                 int x1 = WorldPlots.config.getInt("World." + key + ".X1");
  9.                 int x2 = WorldPlots.config.getInt("World." + key + ".X2");
  10.                 int z1 = WorldPlots.config.getInt("World." + key + ".Z1");
  11.                 int z2 = WorldPlots.config.getInt("World." + key + ".Z2");
  12.                 int px = (int) location.getX();
  13.                 int pz = (int) location.getZ();
  14.                 int size = WorldPlots.config.getConfigurationSection("World").getKeys(false).size();
  15.  
  16.                 int[] x = {x1, x2};
  17.                 int[] z = {z1, z2};
  18.  
  19.                 Arrays.sort(x);
  20.                 Arrays.sort(z);
  21.  
  22.                 if ((x[0] <= px) && (x[1] >= px-1) && (z[0] <= pz) && (z[1] >= pz-1)) {
  23.                     if (WorldPlots.nowPlayerRange.get(player).equalsIgnoreCase(key)) {
  24.                         StringBuilder string = new StringBuilder("");
  25.                         String length = WorldPlots.nowPlayerRange.get(player);
  26.                         for (int i=0; i<45-length.length(); i++) {
  27.                             string.append(" ");
  28.                         }
  29.                         player.sendTitle(length + string, "", 10, 60, 10);
  30.                         WorldPlots.nowPlayerRange.put(player, key);
  31.                     }
  32.                     WorldPlots.count.put(player, WorldPlots.count.get(player) + 1);
  33.                     WorldPlots.confirmation.put(player, 1);
  34.  
  35.                     /*for (String key2 : WorldPlots.config.getConfigurationSection("World." + key + ".Land.Rental").getKeys(false)) {
  36.  
  37.                     }*/
  38.                 }
  39.  
  40.                 if ((size == WorldPlots.count.get(player)) && (WorldPlots.confirmation.get(player) == 0)) {
  41.                     if (WorldPlots.nowPlayerRange.get(player).equalsIgnoreCase(WorldPlots.config.getString("Title.OverWorld"))) {
  42.                         StringBuilder string = new StringBuilder("");
  43.                         String length = WorldPlots.nowPlayerRange.get(player);
  44.                         for (int i=0; i<45-length.length(); i++) {
  45.                             string.append(" ");
  46.                         }
  47.                         player.sendTitle(length + string, "", 10, 60, 10);
  48.                     }
  49.                     WorldPlots.nowPlayerRange.put(player, WorldPlots.config.getString("Title.OverWorld"));
  50.                 }
  51.  
  52.             }
  53.         } catch (NullPointerException ei) {
  54.             if (WorldPlots.nowPlayerRange.get(player).equalsIgnoreCase(WorldPlots.config.getString("Title.OverWorld"))) {
  55.                 StringBuilder string = new StringBuilder("");
  56.                 String length = WorldPlots.nowPlayerRange.get(player);
  57.                 for (int i=0; i<45-length.length(); i++) {
  58.                     string.append(" ");
  59.                 }
  60.                 player.sendTitle(length + string, "", 10, 60, 10);
  61.             }
  62.             WorldPlots.nowPlayerRange.put(player, WorldPlots.config.getString("Title.OverWorld"));
  63.         }
  64.         return;
  65.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement