Merge branch 'v5' into features/v5/road-respect-flags

This commit is contained in:
dordsor21
2020-07-07 17:48:46 +01:00
7 changed files with 60 additions and 10 deletions

View File

@ -125,7 +125,6 @@ import org.bukkit.World;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
@ -354,7 +353,10 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
}
impromptuPipeline.storeImmediately("*", DBFunc.EVERYONE);
this.startUuidCatching(sqLiteUUIDService, cacheUUIDService);
if (Settings.UUID.BACKGROUND_CACHING_ENABLED) {
this.startUuidCaching(sqLiteUUIDService, cacheUUIDService);
}
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new Placeholders().register();
@ -491,7 +493,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
}
}
private void startUuidCatching(@NotNull final SQLiteUUIDService sqLiteUUIDService,
private void startUuidCaching(@NotNull final SQLiteUUIDService sqLiteUUIDService,
@NotNull final CacheUUIDService cacheUUIDService) {
// Load all uuids into a big chunky boi queue
final Queue<UUID> uuidQueue = new LinkedBlockingQueue<>();

View File

@ -56,6 +56,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Level;
/**
@ -74,6 +75,7 @@ public class FancyMessage
private static Constructor<?> nmsPacketPlayOutChatConstructor;
// The ChatSerializer's instance of Gson
private static Object nmsChatSerializerGsonInstance;
private static Object chatMessageType;
private static Method fromJsonMethod;
private static JsonParser _stringParser = new JsonParser();
@ -101,8 +103,16 @@ public class FancyMessage
dirty = false;
if (nmsPacketPlayOutChatConstructor == null) {
try {
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat")
.getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent"));
Class<?> componentClass = Reflection.getNMSClass("IChatBaseComponent");
if (!Reflection.getVersion().startsWith("v1_16")) { // < 1.16 TODO needs to be fixed before 1.17 :P
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat")
.getDeclaredConstructor(componentClass);
} else {
Class<Enum> chatMessageTypeClass = (Class<Enum>) Reflection.getNMSClass("ChatMessageType");
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat")
.getDeclaredConstructor(componentClass, chatMessageTypeClass, UUID.class);
chatMessageType = Enum.valueOf(chatMessageTypeClass, "SYSTEM");
}
nmsPacketPlayOutChatConstructor.setAccessible(true);
} catch (NoSuchMethodException e) {
Bukkit.getLogger()
@ -773,7 +783,7 @@ public class FancyMessage
Reflection.getField(handle.getClass(), "playerConnection").get(handle);
Reflection
.getMethod(connection.getClass(), "sendPacket", Reflection.getNMSClass("Packet"))
.invoke(connection, createChatPacket(jsonString));
.invoke(connection, createChatPacket(jsonString, ((Player) sender).getUniqueId()));
} catch (IllegalArgumentException e) {
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
} catch (IllegalAccessException e) {
@ -790,7 +800,7 @@ public class FancyMessage
}
}
private Object createChatPacket(String json)
private Object createChatPacket(String json, UUID receiver)
throws IllegalArgumentException, IllegalAccessException, InstantiationException,
InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
if (nmsChatSerializerGsonInstance == null) {
@ -838,7 +848,11 @@ public class FancyMessage
Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json,
Reflection.getNMSClass("IChatBaseComponent"));
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent);
if (!Reflection.getVersion().startsWith("v1_16")) {
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent);
} else {
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent, chatMessageType, receiver);
}
}
/**

View File

@ -32,6 +32,7 @@ import com.plotsquared.core.location.Location;
import com.plotsquared.core.location.PlotLoc;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotManager;
import com.plotsquared.core.queue.GlobalBlockQueue;
import com.plotsquared.core.queue.LocalBlockQueue;
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
@ -109,6 +110,10 @@ public class BukkitRegionManager extends RegionManager {
return chunks;
}
@Override public boolean handleClear(Plot plot, Runnable whenDone, PlotManager manager) {
return false;
}
@Override public int[] countEntities(Plot plot) {
int[] existing = (int[]) plot.getMeta("EntityCount");
if (existing != null && (System.currentTimeMillis() - (long) plot.getMeta("EntityCountTime")