Skip to content

Commit

Permalink
Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed May 15, 2019
1 parent ee1abaf commit df4e7bd
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
</repository>
<repository>
<id>articdive-repo</id>
<url>https://nexus.articdive.de/repository/maven-releases</url>
<url>http://maven.elmakers.com/repository</url>
</repository>
<repository>
<id>placeholderapi</id>
Expand Down Expand Up @@ -148,7 +148,7 @@
<dependency>
<groupId>com.palmergames</groupId>
<artifactId>Towny</artifactId>
<version>0.93.0.3</version>
<version>0.89.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
15 changes: 10 additions & 5 deletions src/net/tnemc/tnc/core/ChatManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,26 @@ public void loadReplacements() {
}

public void loadChats() {
System.out.println("Loading Chats");
final String baseNode = "Chats";
if(TheNewChat.instance().getChatsConfiguration().contains(baseNode)) {
Set<String> chatConfigs = TheNewChat.instance().getChatsConfiguration().getConfigurationSection(baseNode).getKeys(false);
for(String entry : chatConfigs) {
System.out.println("Loading Chat " + entry);
if(!TheNewChat.instance().getChatsConfiguration().contains(baseNode + "." + entry + ".Handler") ||
!TheNewChat.instance().getChatsConfiguration().contains(baseNode + "." + entry + ".Type")) {
continue;
}
final String handler = TheNewChat.instance().getChatsConfiguration().getString(baseNode + "." + entry + ".Handler");
final String type = TheNewChat.instance().getChatsConfiguration().getString(baseNode + "." + entry + ".Type");
final String handler = TheNewChat.instance().getChatsConfiguration().getString(baseNode + "." + entry + ".Handler").toLowerCase();
final String type = TheNewChat.instance().getChatsConfiguration().getString(baseNode + "." + entry + ".Type").toLowerCase();

System.out.println("Loading Chat Handler " + entry);
if(handlers.containsKey(handler) && handlers.get(handler).getTypes().containsKey(type)) {
System.out.println("Loading Chat Entry " + entry);
ChatEntry chatConfig = new ChatEntry(handler, type);

List<String> commands = TheNewChat.instance().getChatsConfiguration().getStringList(baseNode + "." + entry + ".Commands");
chatConfig.setCommands(commands.toArray(new String[commands.size()]));
chatConfig.setCommands(commands.toArray(new String[0]));
chatConfig.setIgnorable(TheNewChat.instance().getChatsConfiguration().getBoolean(baseNode + "." + entry + ".Ignorable", true));
chatConfig.setWorld(TheNewChat.instance().getChatsConfiguration().getBoolean(baseNode + "." + entry + ".WorldBased", false));
chatConfig.setRadial(TheNewChat.instance().getChatsConfiguration().getBoolean(baseNode + "." + entry + ".Radial", false));
Expand All @@ -131,6 +135,7 @@ public void loadChats() {
chatConfig.setFormat(TheNewChat.instance().getChatsConfiguration().getString(baseNode + "." + entry + ".Format", handlers.get(handler).getType(type).getDefaultFormat()));

addChatEntry(chatConfig);
System.out.println("Loading Chat Finalization " + entry);
}
}
}
Expand Down Expand Up @@ -337,8 +342,8 @@ public void setGeneralHandler(String generalHandler) {
}

public void addHandler(ChatHandler handler) {
handlers.put(handler.getName(), handler);
handlersMap.put(handler.getTypes().keySet(), handler.getName());
handlers.put(handler.getName().toLowerCase(), handler);
handlersMap.put(handler.getTypes().keySet(), handler.getName().toLowerCase());
}

public LinkedHashMap<String, ChatHandler> getHandlers() {
Expand Down
5 changes: 2 additions & 3 deletions src/net/tnemc/tnc/core/TheNewChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}

public void registerChatCommand() {
List<String> commands = new ArrayList<>();
commands.addAll(manager.getCommands().keySet());
List<String> commands = new ArrayList<>(manager.getCommands().keySet());
commands.add("gc");
commands.add("generalchat");
commands.add("generalchat");
commands.add("tnc");
final String[] commandsArray = commands.toArray(new String[commands.size()]);
final String[] commandsArray = commands.toArray(new String[0]);

registerCommand(commandsArray, new ChatCommand(this, commandsArray));
}
Expand Down
4 changes: 2 additions & 2 deletions src/net/tnemc/tnc/core/common/chat/ChatHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public void addVariable(final ChatVariable variable) {
}

public void addType(final ChatType type) {
types.put(type.getName(), type);
types.put(type.getName().toLowerCase(), type);
}

public ChatType getType(String name) {
return types.get(name);
return types.get(name.toLowerCase());
}

public Map<String, ChatType> getTypes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public CoreHandler() {

@Override
public String getName() {
return "core";
return "Core";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
public class BasicType extends ChatType {
public BasicType() {
super("basic", "<white>[<blue>$display<white>]: <yellow>$message");
super("Basic", "<white>[<blue>$display<white>]: <yellow>$message");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/net/tnemc/tnc/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#General Data
name: TheNewChat
version: 1.2.0.0
version: 1.3.0.0
description: A chat management plugin for non-player made chat channels. With TNK and Towny Support.
author: creatorfromhell
api-version: 1.13
Expand Down

0 comments on commit df4e7bd

Please sign in to comment.