mirror of
https://github.com/GeyserExtensionists/GeyserModelEngine.git
synced 2025-12-19 15:09:18 +00:00
added a check for client brand being null (tho weird)
This commit is contained in:
@@ -6,6 +6,7 @@ import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import re.imc.geysermodelengine.hooks.FloodgateAPIHook;
|
||||
import re.imc.geysermodelengine.listener.ModelListener;
|
||||
import re.imc.geysermodelengine.listener.MountPacketListener;
|
||||
import re.imc.geysermodelengine.managers.ConfigManager;
|
||||
@@ -59,11 +60,12 @@ public class GeyserModelEngine extends JavaPlugin {
|
||||
|
||||
private void loadHooks() {
|
||||
PacketEvents.getAPI().init();
|
||||
FloodgateAPIHook.loadHook(this);
|
||||
// CommandAPI.onEnable();
|
||||
}
|
||||
|
||||
private void loadBStats() {
|
||||
if (configManager.getConfig().getBoolean("metrics.bstats", true)) new Metrics(this, 26981);
|
||||
if (this.configManager.getConfig().getBoolean("metrics.bstats", true)) new Metrics(this, 26981);
|
||||
}
|
||||
|
||||
private void loadManagers() {
|
||||
@@ -77,9 +79,8 @@ public class GeyserModelEngine extends JavaPlugin {
|
||||
|
||||
private void loadRunnables() {
|
||||
this.schedulerPool = Executors.newScheduledThreadPool(configManager.getConfig().getInt("models.thread-pool-size", 4));
|
||||
|
||||
schedulerPool.scheduleAtFixedRate(new UpdateTaskRunnable(this), 10, configManager.getConfig().getLong("models.entity-position-update-period", 35), TimeUnit.MILLISECONDS);
|
||||
schedulerPool.scheduleAtFixedRate(new BedrockMountControlRunnable(this), 1, 1, TimeUnit.MILLISECONDS);
|
||||
this.schedulerPool.scheduleAtFixedRate(new UpdateTaskRunnable(this), 10, configManager.getConfig().getLong("models.entity-position-update-period", 35), TimeUnit.MILLISECONDS);
|
||||
this.schedulerPool.scheduleAtFixedRate(new BedrockMountControlRunnable(this), 1, 1, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public ConfigManager getConfigManager() {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package re.imc.geysermodelengine.hooks;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import re.imc.geysermodelengine.GeyserModelEngine;
|
||||
|
||||
public class FloodgateAPIHook {
|
||||
|
||||
private static FloodgateApi floodgateAPI;
|
||||
|
||||
public static void loadHook(GeyserModelEngine plugin) {
|
||||
if (Bukkit.getPluginManager().getPlugin("floodgate") == null) {
|
||||
plugin.getLogger().info("floodgate hook not enabled!");
|
||||
return;
|
||||
}
|
||||
|
||||
floodgateAPI = FloodgateApi.getInstance();
|
||||
|
||||
plugin.getLogger().info("Hooking into floodgate!");
|
||||
|
||||
}
|
||||
|
||||
public static FloodgateApi getAPI() {
|
||||
return floodgateAPI;
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,16 @@ package re.imc.geysermodelengine.util;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import re.imc.geysermodelengine.hooks.FloodgateAPIHook;
|
||||
|
||||
public class BedrockUtils {
|
||||
|
||||
private static FloodgateApi FLOODGATE_API;
|
||||
private static final FloodgateApi floodgateAPIHook = FloodgateAPIHook.getAPI();
|
||||
|
||||
public static boolean isBedrockPlayer(Player player) {
|
||||
if (FLOODGATE_API != null) return FLOODGATE_API.isFloodgatePlayer(player.getUniqueId());
|
||||
return player.getClientBrandName().contains("Geyser");
|
||||
}
|
||||
|
||||
public static FloodgateApi getFloodgateApi() {
|
||||
return FLOODGATE_API;
|
||||
if (floodgateAPIHook != null) return floodgateAPIHook.isFloodgatePlayer(player.getUniqueId());
|
||||
String clientBrand = player.getClientBrandName();
|
||||
if (clientBrand == null) return false;
|
||||
return clientBrand.contains("Geyser");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user