|
@ -39,42 +39,44 @@ public class Data { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!data.contains("version")) { |
|
|
if (!data.contains("version")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data.contains("hoppers")) { |
|
|
if (data.contains("hoppers")) { |
|
|
for (String rawh : data.getConfigurationSection("hoppers").getKeys(false)) { |
|
|
for (String rawh : data.getConfigurationSection("hoppers").getKeys(false)) { |
|
|
String loc = "hoppers." + rawh; |
|
|
String loc = "hoppers." + rawh; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> values = data.getStringList(loc); |
|
|
List<String> values = data.getStringList(loc); |
|
|
data.set(loc, null); |
|
|
data.set(loc, null); |
|
|
data.set(loc + ".materials", values); |
|
|
data.set(loc + ".materials", values); |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data.set("version", 1); |
|
|
data.set("version", 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
saveData(); |
|
|
saveData(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static long last; |
|
|
|
|
|
|
|
|
private static void saveData() { |
|
|
private static void saveData() { |
|
|
//
|
|
|
|
|
|
// if (System.currentTimeMillis() - last < 1000) {
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
//
|
|
|
|
|
|
// Bukkit.getScheduler().runTaskAsynchronously(Main.p, () -> {
|
|
|
|
|
|
try { |
|
|
|
|
|
data.save(dataf); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (System.currentTimeMillis() - last < 3000) { |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
last = System.currentTimeMillis(); |
|
|
|
|
|
|
|
|
|
|
|
Bukkit.getScheduler().runTaskAsynchronously(Main.p, () -> { |
|
|
|
|
|
try { |
|
|
|
|
|
data.save(dataf); |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static short genMapId() { |
|
|
private static short genMapId() { |
|
@ -99,32 +101,32 @@ public class Data { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void deleteHopper(Hopper h) { |
|
|
public static void deleteHopper(Hopper h) { |
|
|
String cloc = "hoppers." + WorldMgr.serializeLocation(h.getLocation()); |
|
|
String cloc = "hoppers." + WorldMgr.serializeLocation(h.getLocation()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data.set(cloc, null); |
|
|
data.set(cloc, null); |
|
|
saveData(); |
|
|
saveData(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean isSellHopper(Location loc) { |
|
|
public static boolean isSellHopper(Location loc) { |
|
|
String cloc = "hoppers." + WorldMgr.serializeLocation(loc); |
|
|
String cloc = "hoppers." + WorldMgr.serializeLocation(loc); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return data.getBoolean(cloc + ".sellhopper", false); |
|
|
return data.getBoolean(cloc + ".sellhopper", false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean toggleSellHopper(Player p, Location loc) { |
|
|
public static boolean toggleSellHopper(Player p, Location loc) { |
|
|
String cloc = "hoppers." + WorldMgr.serializeLocation(loc); |
|
|
String cloc = "hoppers." + WorldMgr.serializeLocation(loc); |
|
|
|
|
|
|
|
|
String owner = data.getString(cloc + ".owner", "NONE"); |
|
|
String owner = data.getString(cloc + ".owner", "NONE"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!(p.getUniqueId().toString().equals(owner) || p.hasPermission("lagassist.hopper.bypass"))) { |
|
|
if (!(p.getUniqueId().toString().equals(owner) || p.hasPermission("lagassist.hopper.bypass"))) { |
|
|
p.sendMessage(Main.PREFIX + "You can't toggle selling for a hopper not owned by you"); |
|
|
p.sendMessage(Main.PREFIX + "You can't toggle selling for a hopper not owned by you"); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String percentage = "§e" + SellHoppers.getMultiplierPercentage(Bukkit.getOfflinePlayer(p.getUniqueId())) + "%"; |
|
|
String percentage = "§e" + SellHoppers.getMultiplierPercentage(Bukkit.getOfflinePlayer(p.getUniqueId())) + "%"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isSellHopper(loc)) { |
|
|
if (isSellHopper(loc)) { |
|
|
data.set(cloc + ".sellhopper", false); |
|
|
data.set(cloc + ".sellhopper", false); |
|
|
p.sendMessage(Main.PREFIX + "This sellhopper has been §cdisabled§f at " + percentage + "§f."); |
|
|
p.sendMessage(Main.PREFIX + "This sellhopper has been §cdisabled§f at " + percentage + "§f."); |
|
@ -138,7 +140,7 @@ public class Data { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static OfflinePlayer getOwningPlayer(Location loc) { |
|
|
|
|
|
|
|
|
public static OfflinePlayer getOwningPlayer(Location loc) { |
|
|
String cloc = "hoppers." + WorldMgr.serializeLocation(loc); |
|
|
String cloc = "hoppers." + WorldMgr.serializeLocation(loc); |
|
|
|
|
|
|
|
|
if (data.contains(cloc + ".owner")) { |
|
|
if (data.contains(cloc + ".owner")) { |
|
|