mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 14:38:49 +00:00
Move proxy check to funconstants
This commit is contained in:
1 parent
93c7d7fb15
commit
39b7c68818
3 files changed
+18
-19
No files matched your search
@@ -43,7 +43,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public final class CarbonChat extends JavaPlugin {
|
public final class CarbonChat extends JavaPlugin {
|
||||||
|
|
||||||
@@ -80,8 +79,6 @@ public final class CarbonChat extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.checkForBungee();
|
|
||||||
|
|
||||||
CommandAPI.onEnable(this);
|
CommandAPI.onEnable(this);
|
||||||
final Metrics metrics = new Metrics(this, BSTATS_PLUGIN_ID);
|
final Metrics metrics = new Metrics(this, BSTATS_PLUGIN_ID);
|
||||||
|
|
||||||
@@ -200,21 +197,6 @@ public final class CarbonChat extends JavaPlugin {
|
|||||||
this.filterHandler.reloadFilters();
|
this.filterHandler.reloadFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean bungeeEnabled = false;
|
|
||||||
|
|
||||||
private void checkForBungee() {
|
|
||||||
try {
|
|
||||||
final Class<?> spigotConfig = Class.forName("org.spigotmc.Spigotconfig");
|
|
||||||
final Field bungee = spigotConfig.getField("bungee");
|
|
||||||
this.bungeeEnabled = bungee.getBoolean(null);
|
|
||||||
} catch (final ClassNotFoundException | NoSuchFieldException | IllegalAccessException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean bungeeEnabled() {
|
|
||||||
return this.bungeeEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadModConfig() {
|
private void loadModConfig() {
|
||||||
this.modConfig = YamlConfiguration.loadConfiguration(new File(this.getDataFolder(), "moderation.yml"));
|
this.modConfig = YamlConfiguration.loadConfiguration(new File(this.getDataFolder(), "moderation.yml"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import net.draycia.carbon.events.ChannelSwitchEvent;
|
|||||||
import net.draycia.carbon.events.PrivateMessageEvent;
|
import net.draycia.carbon.events.PrivateMessageEvent;
|
||||||
import net.draycia.carbon.storage.ChatUser;
|
import net.draycia.carbon.storage.ChatUser;
|
||||||
import net.draycia.carbon.storage.UserChannelSettings;
|
import net.draycia.carbon.storage.UserChannelSettings;
|
||||||
|
import net.draycia.carbon.util.FunctionalityConstants;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.audience.ForwardingAudience;
|
import net.kyori.adventure.audience.ForwardingAudience;
|
||||||
import net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
@@ -329,7 +330,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
|||||||
final String targetNameFinal = targetName;
|
final String targetNameFinal = targetName;
|
||||||
final String senderNameFinal = senderName;
|
final String senderNameFinal = senderName;
|
||||||
|
|
||||||
if (!this.carbonChat.bungeeEnabled()) {
|
if (!FunctionalityConstants.HAS_PROXY) {
|
||||||
final String playerOfflineFormat = this.carbonChat.language().getString("other-player-offline");
|
final String playerOfflineFormat = this.carbonChat.language().getString("other-player-offline");
|
||||||
|
|
||||||
final Component playerOfflineComponent = this.carbonChat.adventureManager().processMessage(playerOfflineFormat,
|
final Component playerOfflineComponent = this.carbonChat.adventureManager().processMessage(playerOfflineFormat,
|
||||||
|
|||||||
@@ -4,10 +4,26 @@ import org.bukkit.inventory.ItemFactory;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
@SuppressWarnings("ResultOfMethodCallIgnored") // This is a common pattern in this class.
|
@SuppressWarnings("ResultOfMethodCallIgnored") // This is a common pattern in this class.
|
||||||
public final class FunctionalityConstants {
|
public final class FunctionalityConstants {
|
||||||
|
|
||||||
public static final boolean HAS_HOVER_EVENT_METHOD = noThrow(() -> ItemFactory.class.getMethod("hoverContentOf", ItemStack.class));
|
public static final boolean HAS_HOVER_EVENT_METHOD = noThrow(() -> ItemFactory.class.getMethod("hoverContentOf", ItemStack.class));
|
||||||
|
public static final boolean HAS_PROXY;
|
||||||
|
|
||||||
|
static {
|
||||||
|
boolean hasProxy = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
final Class<?> spigotConfig = Class.forName("org.spigotmc.SpigotConfig");
|
||||||
|
final Field bungee = spigotConfig.getField("bungee");
|
||||||
|
hasProxy = bungee.getBoolean(null);
|
||||||
|
} catch (final ClassNotFoundException | NoSuchFieldException | IllegalAccessException ignored) {
|
||||||
|
}
|
||||||
|
|
||||||
|
HAS_PROXY = hasProxy;
|
||||||
|
}
|
||||||
|
|
||||||
private FunctionalityConstants() {
|
private FunctionalityConstants() {
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user