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:
2
.idea/workspace.xml
generated
2
.idea/workspace.xml
generated
@@ -11,7 +11,7 @@
|
|||||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="DarkyenusTimeTracker">
|
<component name="DarkyenusTimeTracker">
|
||||||
<option name="totalTimeSeconds" value="25458" />
|
<option name="totalTimeSeconds" value="26083" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ExternalProjectsData">
|
<component name="ExternalProjectsData">
|
||||||
<projectState path="$PROJECT_DIR$">
|
<projectState path="$PROJECT_DIR$">
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder
|
|||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import re.imc.geysermodelengine.hooks.FloodgateAPIHook;
|
||||||
import re.imc.geysermodelengine.listener.ModelListener;
|
import re.imc.geysermodelengine.listener.ModelListener;
|
||||||
import re.imc.geysermodelengine.listener.MountPacketListener;
|
import re.imc.geysermodelengine.listener.MountPacketListener;
|
||||||
import re.imc.geysermodelengine.managers.ConfigManager;
|
import re.imc.geysermodelengine.managers.ConfigManager;
|
||||||
@@ -59,11 +60,12 @@ public class GeyserModelEngine extends JavaPlugin {
|
|||||||
|
|
||||||
private void loadHooks() {
|
private void loadHooks() {
|
||||||
PacketEvents.getAPI().init();
|
PacketEvents.getAPI().init();
|
||||||
|
FloodgateAPIHook.loadHook(this);
|
||||||
// CommandAPI.onEnable();
|
// CommandAPI.onEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadBStats() {
|
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() {
|
private void loadManagers() {
|
||||||
@@ -77,9 +79,8 @@ public class GeyserModelEngine extends JavaPlugin {
|
|||||||
|
|
||||||
private void loadRunnables() {
|
private void loadRunnables() {
|
||||||
this.schedulerPool = Executors.newScheduledThreadPool(configManager.getConfig().getInt("models.thread-pool-size", 4));
|
this.schedulerPool = Executors.newScheduledThreadPool(configManager.getConfig().getInt("models.thread-pool-size", 4));
|
||||||
|
this.schedulerPool.scheduleAtFixedRate(new UpdateTaskRunnable(this), 10, configManager.getConfig().getLong("models.entity-position-update-period", 35), TimeUnit.MILLISECONDS);
|
||||||
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);
|
||||||
schedulerPool.scheduleAtFixedRate(new BedrockMountControlRunnable(this), 1, 1, TimeUnit.MILLISECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigManager getConfigManager() {
|
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.bukkit.entity.Player;
|
||||||
import org.geysermc.floodgate.api.FloodgateApi;
|
import org.geysermc.floodgate.api.FloodgateApi;
|
||||||
|
import re.imc.geysermodelengine.hooks.FloodgateAPIHook;
|
||||||
|
|
||||||
public class BedrockUtils {
|
public class BedrockUtils {
|
||||||
|
|
||||||
private static FloodgateApi FLOODGATE_API;
|
private static final FloodgateApi floodgateAPIHook = FloodgateAPIHook.getAPI();
|
||||||
|
|
||||||
public static boolean isBedrockPlayer(Player player) {
|
public static boolean isBedrockPlayer(Player player) {
|
||||||
if (FLOODGATE_API != null) return FLOODGATE_API.isFloodgatePlayer(player.getUniqueId());
|
if (floodgateAPIHook != null) return floodgateAPIHook.isFloodgatePlayer(player.getUniqueId());
|
||||||
return player.getClientBrandName().contains("Geyser");
|
String clientBrand = player.getClientBrandName();
|
||||||
}
|
if (clientBrand == null) return false;
|
||||||
|
return clientBrand.contains("Geyser");
|
||||||
public static FloodgateApi getFloodgateApi() {
|
|
||||||
return FLOODGATE_API;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user