mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
Check for bungee before checking for player
This commit is contained in:
1 parent
a99f445c3c
commit
cae78d848a
2 files changed
+31
No files matched your search
@@ -23,6 +23,7 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
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 {
|
||||||
|
|
||||||
@@ -59,6 +60,8 @@ public final class CarbonChat extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
checkForBungee();
|
||||||
|
|
||||||
CommandAPI.onEnable(this);
|
CommandAPI.onEnable(this);
|
||||||
Metrics metrics = new Metrics(this, BSTATS_PLUGIN_ID);
|
Metrics metrics = new Metrics(this, BSTATS_PLUGIN_ID);
|
||||||
|
|
||||||
@@ -173,6 +176,20 @@ public final class CarbonChat extends JavaPlugin {
|
|||||||
filterHandler.reloadFilters();
|
filterHandler.reloadFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean bungeeEnabled = false;
|
||||||
|
|
||||||
|
private void checkForBungee() {
|
||||||
|
try {
|
||||||
|
Class<?> spigotConfig = Class.forName("org.spigotmc.Spigotconfig");
|
||||||
|
Field bungee = spigotConfig.getField("bungee");
|
||||||
|
bungeeEnabled = bungee.getBoolean(null);
|
||||||
|
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException ignored) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBungeeEnabled() {
|
||||||
|
return bungeeEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
private void loadModConfig() {
|
private void loadModConfig() {
|
||||||
modConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "moderation.yml"));
|
modConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "moderation.yml"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -307,6 +307,20 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
|||||||
final String targetNameFinal = targetName;
|
final String targetNameFinal = targetName;
|
||||||
final String senderNameFinal = senderName;
|
final String senderNameFinal = senderName;
|
||||||
|
|
||||||
|
if (!carbonChat.isBungeeEnabled()) {
|
||||||
|
String playerOfflineFormat = carbonChat.getLanguage().getString("other-player-offline");
|
||||||
|
|
||||||
|
Component playerOfflineComponent = carbonChat.getAdventureManager().processMessage(playerOfflineFormat,
|
||||||
|
"br", "\n",
|
||||||
|
"message", message,
|
||||||
|
"targetname", targetOfflineName, "sendername", senderOfflineName,
|
||||||
|
"target", targetNameFinal, "sender", senderNameFinal);
|
||||||
|
|
||||||
|
sender.sendMessage(playerOfflineComponent);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BungeeChannelApi.of(carbonChat).getPlayerList("ALL").thenAccept(list -> {
|
BungeeChannelApi.of(carbonChat).getPlayerList("ALL").thenAccept(list -> {
|
||||||
if (!list.contains(this.asOfflinePlayer().getName())) {
|
if (!list.contains(this.asOfflinePlayer().getName())) {
|
||||||
String playerOfflineFormat = carbonChat.getLanguage().getString("other-player-offline");
|
String playerOfflineFormat = carbonChat.getLanguage().getString("other-player-offline");
|
||||||
|
|||||||
Reference in new issue
Block a user