Fix compilation and issues

This commit is contained in:
Draycia committed 2020-07-10 02:10:47 -07:00
1 parent 067162e9e6
commit 6fd35ebba0
3 files changed
+24 -17

No files matched your search

@@ -20,14 +20,14 @@ import java.util.regex.Pattern;
public class SimpleChatChannel extends ChatChannel { public class SimpleChatChannel extends ChatChannel {
private String name; private String key;
private SimpleChat simpleChat; private SimpleChat simpleChat;
private SimpleChatChannel() { } private SimpleChatChannel() { }
public SimpleChatChannel(String name, SimpleChat simpleChat) { public SimpleChatChannel(String key, SimpleChat simpleChat) {
this.name = name; this.key = key;
this.simpleChat = simpleChat; this.simpleChat = simpleChat;
} }
@@ -258,7 +258,7 @@ public class SimpleChatChannel extends ChatChannel {
public Map<String, String> getFormats() { public Map<String, String> getFormats() {
HashMap<String, String> formats = new HashMap<>(); HashMap<String, String> formats = new HashMap<>();
ConfigurationSection section = simpleChat.getConfig().getConfigurationSection(getName()); ConfigurationSection section = simpleChat.getConfig().getConfigurationSection("channels").getConfigurationSection(getKey());
ConfigurationSection formatSection = section.getConfigurationSection("formats"); ConfigurationSection formatSection = section.getConfigurationSection("formats");
if (formatSection == null) { if (formatSection == null) {
@@ -299,7 +299,8 @@ public class SimpleChatChannel extends ChatChannel {
@Override @Override
public String getName() { public String getName() {
return name; String name = (String) getSetting("name");
return name == null ? key : name;
} }
@Override @Override
@@ -360,7 +361,7 @@ public class SimpleChatChannel extends ChatChannel {
} }
private Object getSetting(String key) { private Object getSetting(String key) {
ConfigurationSection section = simpleChat.getConfig().getConfigurationSection(getName()); ConfigurationSection section = simpleChat.getConfig().getConfigurationSection("channels").getConfigurationSection(getKey());
if (section.contains(key)) { if (section.contains(key)) {
return section.get(key); return section.get(key);
@@ -374,4 +375,9 @@ public class SimpleChatChannel extends ChatChannel {
return false; return false;
} }
private String getKey() {
return key;
}
} }
@@ -41,6 +41,7 @@ public class ToggleCommand extends BaseCommand {
} }
@CommandPermission("simplechat.toggle.others") @CommandPermission("simplechat.toggle.others")
@Subcommand("other")
@CommandCompletion("@chatchannel @players") @CommandCompletion("@chatchannel @players")
public void baseCommand(Player player, @Conditions("canuse:true") ChatChannel channel, ChatUser user) { public void baseCommand(Player player, @Conditions("canuse:true") ChatChannel channel, ChatUser user) {
String message; String message;
@@ -63,6 +64,6 @@ public class ToggleCommand extends BaseCommand {
simpleChat.getUserService().wrap(player).sendMessage(MiniMessage.get().parse(otherMessage, simpleChat.getUserService().wrap(player).sendMessage(MiniMessage.get().parse(otherMessage,
"br", "\n", "color", "<color:" + channel.getColor().toString() + ">", "br", "\n", "color", "<color:" + channel.getColor().toString() + ">",
"channel", channel.getName())); "channel", channel.getName(), "player", user.asOfflinePlayer().getName()));
} }
} }
@@ -21,9 +21,9 @@ public class ChannelManager {
ConfigurationSection section = simpleChat.getConfig().getConfigurationSection("channels").getConfigurationSection(key); ConfigurationSection section = simpleChat.getConfig().getConfigurationSection("channels").getConfigurationSection(key);
String name = section.contains("name") ? section.getString("name") : key; String name = section.getString("name");
if (name.length() > 16) { if (name != null && name.length() > 16) {
simpleChat.getLogger().warning("Channel name [" + name + "] too long! Max length: 16."); simpleChat.getLogger().warning("Channel name [" + name + "] too long! Max length: 16.");
simpleChat.getLogger().warning("Skipping channel, please check your settings!"); simpleChat.getLogger().warning("Skipping channel, please check your settings!");
continue; continue;
@@ -37,23 +37,23 @@ public class ChannelManager {
switch (type.toLowerCase()) { switch (type.toLowerCase()) {
case "towny": case "towny":
channel = new TownChatChannel(name, simpleChat); channel = new TownChatChannel(key, simpleChat);
hasTownChat = true; hasTownChat = true;
break; break;
case "nation": case "nation":
channel = new NationChatChannel(name, simpleChat); channel = new NationChatChannel(key, simpleChat);
hasNationChat = true; hasNationChat = true;
break; break;
case "alliance": case "alliance":
channel = new AllianceChatChannel(name, simpleChat); channel = new AllianceChatChannel(key, simpleChat);
hasAllianceChat = true; hasAllianceChat = true;
break; break;
case "party": case "party":
channel = new PartyChatChannel(name, simpleChat); channel = new PartyChatChannel(key, simpleChat);
hasPartyChat = true; hasPartyChat = true;
break; break;
case "normal": case "normal":
channel = new SimpleChatChannel(name, simpleChat); channel = new SimpleChatChannel(key, simpleChat);
break; break;
default: default:
simpleChat.getLogger().warning("Invalid channel type for channel [" + key + "]. Skipping channel."); simpleChat.getLogger().warning("Invalid channel type for channel [" + key + "]. Skipping channel.");
@@ -62,14 +62,14 @@ public class ChannelManager {
if (channel.isTownChat() || channel.isNationChat() || channel.isAllianceChat()) { if (channel.isTownChat() || channel.isNationChat() || channel.isAllianceChat()) {
if (!Bukkit.getPluginManager().isPluginEnabled("Towny")) { if (!Bukkit.getPluginManager().isPluginEnabled("Towny")) {
simpleChat.getLogger().warning("Towny related channel with name [" + channel.getName() + "] found, but Towny isn't installed. Skipping channel."); simpleChat.getLogger().warning("Towny related channel with key [" + key + "] found, but Towny isn't installed. Skipping channel.");
continue; continue;
} }
} }
if (channel.isPartyChat()) { if (channel.isPartyChat()) {
if (!Bukkit.getPluginManager().isPluginEnabled("mcMMO")) { if (!Bukkit.getPluginManager().isPluginEnabled("mcMMO")) {
simpleChat.getLogger().warning("mcMMO related channel with name [" + channel.getName() + "] found, but mcMMO isn't installed. Skipping channel."); simpleChat.getLogger().warning("mcMMO related channel with key [" + key + "] found, but mcMMO isn't installed. Skipping channel.");
continue; continue;
} }
} }
@@ -78,7 +78,7 @@ public class ChannelManager {
CommandManager commandManager = simpleChat.getCommandManager().getCommandManager(); CommandManager commandManager = simpleChat.getCommandManager().getCommandManager();
String commandName = section.contains("aliases") ? section.getString("aliases") : channel.getName(); String commandName = section.contains("aliases") ? section.getString("aliases") : key;
commandManager.getCommandReplacements().addReplacement("channelName", commandName); commandManager.getCommandReplacements().addReplacement("channelName", commandName);
commandManager.registerCommand(new AliasedChannelCommand(simpleChat, channel)); commandManager.registerCommand(new AliasedChannelCommand(simpleChat, channel));