mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Cleanup
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
@ -320,34 +320,6 @@ public class FancyMessage
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the behavior of the current editing component to display information about an achievement when the client hovers over the text.
|
||||
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p>
|
||||
*
|
||||
* @param which The achievement to display.
|
||||
* @return This builder instance.
|
||||
*/
|
||||
public FancyMessage achievementTooltip(final Achievement which) {
|
||||
try {
|
||||
Object achievement = Reflection
|
||||
.getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSAchievement",
|
||||
Achievement.class).invoke(null, which);
|
||||
return achievementTooltip(
|
||||
(String) Reflection.getField(Reflection.getNMSClass("Achievement"), "name")
|
||||
.get(achievement));
|
||||
} catch (IllegalAccessException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
||||
return this;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||
return this;
|
||||
} catch (InvocationTargetException e) {
|
||||
Bukkit.getLogger()
|
||||
.log(Level.WARNING, "A error has occurred during invoking of method.", e);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the behavior of the current editing component to display information about a parameterless statistic when the client hovers over the text.
|
||||
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p>
|
||||
@ -648,9 +620,7 @@ public class FancyMessage
|
||||
* @return This builder instance.
|
||||
*/
|
||||
public FancyMessage translationReplacements(final FancyMessage... replacements) {
|
||||
for (FancyMessage str : replacements) {
|
||||
latest().translationReplacements.add(str);
|
||||
}
|
||||
Collections.addAll(latest().translationReplacements, replacements);
|
||||
|
||||
dirty = true;
|
||||
|
||||
@ -869,7 +839,6 @@ public class FancyMessage
|
||||
* <li>The core text of the message part.</li>
|
||||
* </ol>
|
||||
* The primary omissions are tooltips and clickable actions. Consequently, this method should be used only as a last resort.
|
||||
* </p>
|
||||
* <p>
|
||||
* Color and formatting can be removed from the returned string by using {@link ChatColor#stripColor(String)}.</p>
|
||||
*
|
||||
|
@ -171,126 +171,114 @@ import java.util.Map.Entry;
|
||||
}
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Replacing cache");
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override public void run() {
|
||||
for (Entry<UUID, UUID> entry : uCMap.entrySet()) {
|
||||
String name = UUIDHandler.getName(entry.getKey());
|
||||
if (name != null) {
|
||||
UUIDHandler.add(new StringWrapper(name), entry.getValue());
|
||||
}
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
for (Entry<UUID, UUID> entry : uCMap.entrySet()) {
|
||||
String name = UUIDHandler.getName(entry.getKey());
|
||||
if (name != null) {
|
||||
UUIDHandler.add(new StringWrapper(name), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Scanning for applicable files (uuids.txt)");
|
||||
|
||||
File file = new File(PlotSquared.get().IMP.getDirectory(), "uuids.txt");
|
||||
if (file.exists()) {
|
||||
try {
|
||||
List<String> lines =
|
||||
Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
|
||||
for (String line : lines) {
|
||||
try {
|
||||
line = line.trim();
|
||||
if (line.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
line = line.replaceAll("[\\|][0-9]+[\\|][0-9]+[\\|]", "");
|
||||
String[] split = line.split("\\|");
|
||||
String name = split[0];
|
||||
if (name.isEmpty() || name.length() > 16 || !StringMan
|
||||
.isAlphanumericUnd(name)) {
|
||||
continue;
|
||||
}
|
||||
UUID old = currentUUIDWrapper.getUUID(name);
|
||||
if (old == null) {
|
||||
continue;
|
||||
}
|
||||
UUID now = newWrapper.getUUID(name);
|
||||
UUIDHandler.add(new StringWrapper(name), now);
|
||||
uCMap.put(old, now);
|
||||
uCReverse.put(now, old);
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Replacing wrapper");
|
||||
UUIDHandler.setUUIDWrapper(newWrapper);
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Updating plot objects");
|
||||
|
||||
for (Plot plot : PlotSquared.get().getPlots()) {
|
||||
UUID value = uCMap.get(plot.owner);
|
||||
if (value != null) {
|
||||
plot.owner = value;
|
||||
}
|
||||
plot.getTrusted().clear();
|
||||
plot.getMembers().clear();
|
||||
plot.getDenied().clear();
|
||||
}
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Deleting database");
|
||||
boolean result = DBFunc.deleteTables();
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Creating tables");
|
||||
MainUtil.sendMessage(player, "&7 - Scanning for applicable files (uuids.txt)");
|
||||
|
||||
File file = new File(PlotSquared.get().IMP.getDirectory(), "uuids.txt");
|
||||
if (file.exists()) {
|
||||
try {
|
||||
DBFunc.createTables();
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, "&cConversion failed! Attempting recovery");
|
||||
for (Plot plot : PlotSquared.get().getPlots()) {
|
||||
UUID value = uCReverse.get(plot.owner);
|
||||
if (value != null) {
|
||||
plot.owner = value;
|
||||
List<String> lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
|
||||
for (String line : lines) {
|
||||
try {
|
||||
line = line.trim();
|
||||
if (line.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
line = line.replaceAll("[\\|][0-9]+[\\|][0-9]+[\\|]", "");
|
||||
String[] split = line.split("\\|");
|
||||
String name = split[0];
|
||||
if (name.isEmpty() || name.length() > 16 || !StringMan
|
||||
.isAlphanumericUnd(name)) {
|
||||
continue;
|
||||
}
|
||||
UUID old = currentUUIDWrapper.getUUID(name);
|
||||
if (old == null) {
|
||||
continue;
|
||||
}
|
||||
UUID now = newWrapper.getUUID(name);
|
||||
UUIDHandler.add(new StringWrapper(name), now);
|
||||
uCMap.put(old, now);
|
||||
uCReverse.put(now, old);
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
DBFunc.createPlotsAndData(new ArrayList<>(PlotSquared.get().getPlots()),
|
||||
new Runnable() {
|
||||
@Override public void run() {
|
||||
MainUtil.sendMessage(player, "&6Recovery was successful!");
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Replacing wrapper");
|
||||
UUIDHandler.setUUIDWrapper(newWrapper);
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Updating plot objects");
|
||||
|
||||
for (Plot plot : PlotSquared.get().getPlots()) {
|
||||
UUID value = uCMap.get(plot.owner);
|
||||
if (value != null) {
|
||||
plot.owner = value;
|
||||
}
|
||||
plot.getTrusted().clear();
|
||||
plot.getMembers().clear();
|
||||
plot.getDenied().clear();
|
||||
}
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Deleting database");
|
||||
boolean result = DBFunc.deleteTables();
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Creating tables");
|
||||
|
||||
try {
|
||||
DBFunc.createTables();
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, "&cConversion failed! Attempting recovery");
|
||||
for (Plot plot : PlotSquared.get().getPlots()) {
|
||||
UUID value = uCReverse.get(plot.owner);
|
||||
if (value != null) {
|
||||
plot.owner = value;
|
||||
}
|
||||
}
|
||||
DBFunc.createPlotsAndData(new ArrayList<>(PlotSquared.get().getPlots()),
|
||||
() -> MainUtil.sendMessage(player, "&6Recovery was successful!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (newWrapper instanceof OfflineUUIDWrapper) {
|
||||
PlotSquared.get().worlds.set("UUID.force-lowercase", false);
|
||||
PlotSquared.get().worlds.set("UUID.offline", true);
|
||||
} else if (newWrapper instanceof DefaultUUIDWrapper) {
|
||||
PlotSquared.get().worlds.set("UUID.force-lowercase", false);
|
||||
PlotSquared.get().worlds.set("UUID.offline", false);
|
||||
}
|
||||
try {
|
||||
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
|
||||
} catch (IOException ignored) {
|
||||
MainUtil.sendMessage(player,
|
||||
"Could not save configuration. It will need to be manual set!");
|
||||
}
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Populating tables");
|
||||
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override public void run() {
|
||||
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots());
|
||||
DBFunc.createPlotsAndData(plots, new Runnable() {
|
||||
@Override public void run() {
|
||||
MainUtil.sendMessage(player, "&aConversion complete!");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
MainUtil.sendMessage(player, "&aIt is now safe for players to join");
|
||||
MainUtil.sendMessage(player,
|
||||
"&cConversion is still in progress, you will be notified when it is complete");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
if (newWrapper instanceof OfflineUUIDWrapper) {
|
||||
PlotSquared.get().worlds.set("UUID.force-lowercase", false);
|
||||
PlotSquared.get().worlds.set("UUID.offline", true);
|
||||
} else if (newWrapper instanceof DefaultUUIDWrapper) {
|
||||
PlotSquared.get().worlds.set("UUID.force-lowercase", false);
|
||||
PlotSquared.get().worlds.set("UUID.offline", false);
|
||||
}
|
||||
try {
|
||||
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
|
||||
} catch (IOException ignored) {
|
||||
MainUtil.sendMessage(player,
|
||||
"Could not save configuration. It will need to be manual set!");
|
||||
}
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Populating tables");
|
||||
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots());
|
||||
DBFunc.createPlotsAndData(plots,
|
||||
() -> MainUtil.sendMessage(player, "&aConversion complete!"));
|
||||
});
|
||||
|
||||
MainUtil.sendMessage(player, "&aIt is now safe for players to join");
|
||||
MainUtil.sendMessage(player,
|
||||
"&cConversion is still in progress, you will be notified when it is complete");
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -46,12 +46,12 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
||||
|
||||
private LocalBlockQueue queue;
|
||||
|
||||
@Override public void populate(World world, Random r, Chunk c) {
|
||||
@Override public void populate(World world, Random random, Chunk source) {
|
||||
if (queue == null) {
|
||||
queue = GlobalBlockQueue.IMP.getNewQueue(world.getName(), false);
|
||||
}
|
||||
PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null);
|
||||
ChunkWrapper wrap = new ChunkWrapper(area.worldname, c.getX(), c.getZ());
|
||||
ChunkWrapper wrap = new ChunkWrapper(area.worldname, source.getX(), source.getZ());
|
||||
ScopedLocalBlockQueue chunk = queue.getForChunk(wrap.x, wrap.z);
|
||||
if (BukkitPlotGenerator.this.plotGenerator.populateChunk(chunk, area)) {
|
||||
queue.flush();
|
||||
|
@ -135,9 +135,8 @@ public class EntitySpawnListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler public void spawn(CreatureSpawnEvent event) {
|
||||
switch (event.getEntityType()) {
|
||||
case ARMOR_STAND:
|
||||
test(event.getEntity());
|
||||
if (event.getEntityType() == EntityType.ARMOR_STAND) {
|
||||
test(event.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,8 +105,7 @@ import java.util.UUID;
|
||||
if (event.getEntityType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getEntity();
|
||||
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
|
||||
Plot plot = BukkitUtil.getLocation(event.getEntity()).getOwnedPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import java.util.stream.Collectors;
|
||||
public class BukkitPlayer extends PlotPlayer {
|
||||
|
||||
public final Player player;
|
||||
public boolean offline;
|
||||
private boolean offline;
|
||||
private UUID uuid;
|
||||
private String name;
|
||||
|
||||
@ -147,7 +147,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
}
|
||||
|
||||
@Override public void sendMessage(String message) {
|
||||
if (!StringMan.isEqual(this.<String>getMeta("lastMessage"), message) || (
|
||||
if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (
|
||||
System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
|
||||
setMeta("lastMessage", message);
|
||||
setMeta("lastMessageTime", System.currentTimeMillis());
|
||||
|
@ -38,7 +38,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
if (depth == 0) {
|
||||
return;
|
||||
}
|
||||
Entity passenger = entity.getPassenger();
|
||||
Entity passenger = entity.getPassengers().get(0);
|
||||
if (passenger != null) {
|
||||
this.base.passenger = new ReplicatingEntityWrapper(passenger, depth);
|
||||
}
|
||||
@ -174,13 +174,14 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
// END AGEABLE //
|
||||
//todo this needs to be fixed
|
||||
case GUARDIAN:
|
||||
this.dataByte = (byte) (((Guardian) entity).isElder() ? 1 : 0);
|
||||
case ELDER_GUARDIAN:
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
//todo this needs to be fixed
|
||||
case SKELETON:
|
||||
this.dataByte = getOrdinal(Skeleton.SkeletonType.values(),
|
||||
((Skeleton) entity).getSkeletonType());
|
||||
case WITHER_SKELETON:
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
case ARMOR_STAND:
|
||||
@ -425,7 +426,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
}
|
||||
if (this.base.passenger != null) {
|
||||
try {
|
||||
entity.setPassenger(this.base.passenger.spawn(world, xOffset, zOffset));
|
||||
entity.addPassenger(this.base.passenger.spawn(world, xOffset, zOffset));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
@ -509,6 +510,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
// START LIVING ENTITY //
|
||||
// START AGEABLE //
|
||||
// START TAMEABLE //
|
||||
//todo this needs to be fixed
|
||||
case HORSE:
|
||||
Horse horse = (Horse) entity;
|
||||
horse.setJumpStrength(this.horse.jump);
|
||||
@ -558,17 +560,12 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
case GUARDIAN:
|
||||
if (this.dataByte != 0) {
|
||||
((Guardian) entity).setElder(true);
|
||||
}
|
||||
case ELDER_GUARDIAN:
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
case SKELETON:
|
||||
if (this.dataByte != 0) {
|
||||
((Skeleton) entity)
|
||||
.setSkeletonType(Skeleton.SkeletonType.values()[this.dataByte]);
|
||||
}
|
||||
storeLiving((LivingEntity) entity);
|
||||
case WITHER_SKELETON:
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
case ARMOR_STAND:
|
||||
// CHECK positions
|
||||
|
@ -8,6 +8,7 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* Minecraft 1.8 Title
|
||||
@ -17,8 +18,7 @@ import java.util.Map;
|
||||
* @version 1.1.0
|
||||
*/
|
||||
public class TitleManager_1_11 {
|
||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES =
|
||||
new HashMap<Class<?>, Class<?>>();
|
||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
||||
/* Title packet */
|
||||
private static Class<?> packetTitle;
|
||||
/* Title packet actions ENUM */
|
||||
@ -111,10 +111,8 @@ public class TitleManager_1_11 {
|
||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
if (a.length != o.length)
|
||||
return false;
|
||||
for (int i = 0; i < a.length; i++)
|
||||
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i]))
|
||||
return false;
|
||||
return true;
|
||||
return IntStream.range(0, a.length)
|
||||
.noneMatch(i -> !a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,8 +10,9 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.ChatManager;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BukkitChatManager extends ChatManager<FancyMessage> {
|
||||
|
||||
@ -24,10 +25,8 @@ public class BukkitChatManager extends ChatManager<FancyMessage> {
|
||||
}
|
||||
|
||||
@Override public void tooltip(PlotMessage message, PlotMessage... tooltips) {
|
||||
List<FancyMessage> lines = new ArrayList<>();
|
||||
for (PlotMessage tooltip : tooltips) {
|
||||
lines.add(tooltip.$(this));
|
||||
}
|
||||
List<FancyMessage> lines =
|
||||
Arrays.stream(tooltips).map(tooltip -> tooltip.$(this)).collect(Collectors.toList());
|
||||
message.$(this).formattedTooltip(lines);
|
||||
}
|
||||
|
||||
|
@ -106,9 +106,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
Set<ChunkLoc> chunks = super.getChunkChunks(world);
|
||||
for (Chunk chunk : Bukkit.getWorld(world).getLoadedChunks()) {
|
||||
ChunkLoc loc = new ChunkLoc(chunk.getX() >> 5, chunk.getZ() >> 5);
|
||||
if (!chunks.contains(loc)) {
|
||||
chunks.add(loc);
|
||||
}
|
||||
chunks.add(loc);
|
||||
}
|
||||
return chunks;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class BukkitInventoryUtil extends InventoryUtil {
|
||||
|
||||
@ -94,7 +95,7 @@ public class BukkitInventoryUtil extends InventoryUtil {
|
||||
}
|
||||
if (meta.hasLore()) {
|
||||
List<String> itemLore = meta.getLore();
|
||||
lore = itemLore.toArray(new String[itemLore.size()]);
|
||||
lore = itemLore.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
return new PlotItemStack(id.name(), amount, name, lore);
|
||||
@ -103,20 +104,17 @@ public class BukkitInventoryUtil extends InventoryUtil {
|
||||
@Override public PlotItemStack[] getItems(PlotPlayer player) {
|
||||
BukkitPlayer bp = (BukkitPlayer) player;
|
||||
PlayerInventory inv = bp.player.getInventory();
|
||||
PlotItemStack[] items = new PlotItemStack[36];
|
||||
for (int i = 0; i < 36; i++) {
|
||||
items[i] = getItem(inv.getItem(i));
|
||||
}
|
||||
return items;
|
||||
return IntStream.range(0, 36).mapToObj(i -> getItem(inv.getItem(i)))
|
||||
.toArray(PlotItemStack[]::new);
|
||||
}
|
||||
|
||||
@Override public boolean isOpen(PlotInventory inv) {
|
||||
if (!inv.isOpen()) {
|
||||
@Override public boolean isOpen(PlotInventory plotInventory) {
|
||||
if (!plotInventory.isOpen()) {
|
||||
return false;
|
||||
}
|
||||
BukkitPlayer bp = (BukkitPlayer) inv.player;
|
||||
BukkitPlayer bp = (BukkitPlayer) plotInventory.player;
|
||||
InventoryView opened = bp.player.getOpenInventory();
|
||||
return inv.isOpen() && opened.getType() == InventoryType.CRAFTING
|
||||
return plotInventory.isOpen() && opened.getType() == InventoryType.CRAFTING
|
||||
&& opened.getTitle() == null;
|
||||
}
|
||||
}
|
||||
|
@ -669,7 +669,7 @@ public final class BukkitLegacyMappings extends LegacyMappings {
|
||||
private static final Map<String, PlotBlock> NEW_STRING_TO_LEGACY_PLOT_BLOCK = new HashMap<>();
|
||||
private static final Map<String, PlotBlock> OLD_STRING_TO_STRING_PLOT_BLOCK = new HashMap<>();
|
||||
|
||||
public BukkitLegacyMappings() {
|
||||
@SuppressWarnings("deprecation") public BukkitLegacyMappings() {
|
||||
this.addAll(Arrays.asList(BLOCKS));
|
||||
// Make sure to add new blocks as well
|
||||
final List<LegacyBlock> missing = new ArrayList<>();
|
||||
|
@ -343,10 +343,8 @@ import java.util.*;
|
||||
return y;
|
||||
air = 0;
|
||||
} else {
|
||||
switch (type) {
|
||||
case WATER:
|
||||
case LAVA:
|
||||
return y;
|
||||
if (block.isLiquid()) {
|
||||
return y;
|
||||
}
|
||||
air++;
|
||||
}
|
||||
@ -366,11 +364,7 @@ import java.util.*;
|
||||
|
||||
@Override public String[] getBiomeList() {
|
||||
final Biome[] biomes = Biome.values();
|
||||
final String[] list = new String[biomes.length];
|
||||
for (int i = 0; i < biomes.length; i++) {
|
||||
list[i] = biomes[i].name();
|
||||
}
|
||||
return list;
|
||||
return Arrays.stream(biomes).map(Enum::name).toArray(String[]::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,11 +65,7 @@ public class SendChunk {
|
||||
int view = Bukkit.getServer().getViewDistance();
|
||||
for (Chunk chunk : chunks) {
|
||||
String world = chunk.getWorld().getName();
|
||||
ArrayList<Chunk> list = map.get(world);
|
||||
if (list == null) {
|
||||
list = new ArrayList<>();
|
||||
map.put(world, list);
|
||||
}
|
||||
ArrayList<Chunk> list = map.computeIfAbsent(world, k -> new ArrayList<>());
|
||||
list.add(chunk);
|
||||
Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||
this.methodInitLighting.of(c).call();
|
||||
@ -118,20 +114,17 @@ public class SendChunk {
|
||||
}
|
||||
}
|
||||
for (final Chunk chunk : chunks) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override public void run() {
|
||||
try {
|
||||
chunk.unload(true, false);
|
||||
} catch (Throwable ignored) {
|
||||
String worldName = chunk.getWorld().getName();
|
||||
PlotSquared.debug(
|
||||
"$4Could not save chunk: " + worldName + ';' + chunk.getX() + ";"
|
||||
+ chunk.getZ());
|
||||
PlotSquared
|
||||
.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
|
||||
PlotSquared.debug("$3 - $4" + worldName + "/level.dat or " + worldName
|
||||
+ "/level_old.dat may be corrupt (try repairing or removing these)");
|
||||
}
|
||||
TaskManager.runTask(() -> {
|
||||
try {
|
||||
chunk.unload(true, false);
|
||||
} catch (Throwable ignored) {
|
||||
String worldName = chunk.getWorld().getName();
|
||||
PlotSquared.debug(
|
||||
"$4Could not save chunk: " + worldName + ';' + chunk.getX() + ";" + chunk
|
||||
.getZ());
|
||||
PlotSquared.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
|
||||
PlotSquared.debug("$3 - $4" + worldName + "/level.dat or " + worldName
|
||||
+ "/level_old.dat may be corrupt (try repairing or removing these)");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -5,12 +5,10 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class SetGenCB {
|
||||
|
||||
@ -45,12 +43,8 @@ public class SetGenCB {
|
||||
}
|
||||
}
|
||||
if (!set) {
|
||||
Iterator<BlockPopulator> iterator = world.getPopulators().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (iterator.next() instanceof BukkitAugmentedGenerator) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
world.getPopulators()
|
||||
.removeIf(blockPopulator -> blockPopulator instanceof BukkitAugmentedGenerator);
|
||||
}
|
||||
PlotSquared.get()
|
||||
.loadWorld(world.getName(), PlotSquared.get().IMP.getGenerator(world.getName(), null));
|
||||
|
@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DefaultUUIDWrapper extends UUIDWrapper {
|
||||
@ -30,11 +31,7 @@ public class DefaultUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
@Override public OfflinePlotPlayer[] getOfflinePlayers() {
|
||||
OfflinePlayer[] ops = Bukkit.getOfflinePlayers();
|
||||
BukkitOfflinePlayer[] toReturn = new BukkitOfflinePlayer[ops.length];
|
||||
for (int i = 0; i < ops.length; i++) {
|
||||
toReturn[i] = new BukkitOfflinePlayer(ops[i]);
|
||||
}
|
||||
return toReturn;
|
||||
return Arrays.stream(ops).map(BukkitOfflinePlayer::new).toArray(BukkitOfflinePlayer[]::new);
|
||||
}
|
||||
|
||||
@Override public OfflinePlotPlayer getOfflinePlayer(String name) {
|
||||
|
@ -80,8 +80,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
HashBiMap<StringWrapper, UUID> toAdd =
|
||||
HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||
HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<>());
|
||||
if (Settings.UUID.NATIVE_UUID_PROVIDER) {
|
||||
HashSet<UUID> all = UUIDHandler.getAllUUIDS();
|
||||
PlotSquared.debug("&aFast mode UUID caching enabled!");
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -70,7 +71,7 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
public Player[] getOnlinePlayers() {
|
||||
if (this.getOnline == null) {
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
return onlinePlayers.toArray(new Player[0]);
|
||||
}
|
||||
try {
|
||||
Object players = this.getOnline.invoke(Bukkit.getServer(), this.arg);
|
||||
@ -79,13 +80,13 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
} else {
|
||||
@SuppressWarnings("unchecked") Collection<? extends Player> p =
|
||||
(Collection<? extends Player>) players;
|
||||
return p.toArray(new Player[p.size()]);
|
||||
return p.toArray(new Player[0]);
|
||||
}
|
||||
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException ignored) {
|
||||
PlotSquared.debug("Failed to resolve online players");
|
||||
this.getOnline = null;
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
return onlinePlayers.toArray(new Player[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,11 +96,7 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
@Override public OfflinePlotPlayer[] getOfflinePlayers() {
|
||||
OfflinePlayer[] ops = Bukkit.getOfflinePlayers();
|
||||
BukkitOfflinePlayer[] toReturn = new BukkitOfflinePlayer[ops.length];
|
||||
for (int i = 0; i < ops.length; i++) {
|
||||
toReturn[i] = new BukkitOfflinePlayer(ops[i]);
|
||||
}
|
||||
return toReturn;
|
||||
return Arrays.stream(ops).map(BukkitOfflinePlayer::new).toArray(BukkitOfflinePlayer[]::new);
|
||||
}
|
||||
|
||||
@Override public OfflinePlotPlayer getOfflinePlayer(String name) {
|
||||
|
@ -114,7 +114,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
while (!toFetch.isEmpty()) {
|
||||
try {
|
||||
for (int i = 0; i < Math.min(500, toFetch.size()); i++) {
|
||||
for (int i = 0; i < Math.min(MAX_REQUESTS, toFetch.size()); i++) {
|
||||
UUID uuid = toFetch.pop();
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(
|
||||
SQLUUIDHandler.this.PROFILE_URL + uuid.toString()
|
||||
|
Reference in New Issue
Block a user