mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-03 06:28:57 +00:00
v0.5:
- Added auto modes for chat.
Type '/tc' to set town chat mode. All text typed from then on will be sent to town chat.
While in a chat mode you can still talk in other channels by using the channel commands eg. '/nc hi'.
While in a chat mode you can talk in global chat with '/g text here'.
to clear all chat modes '/g'.
- Added a new permission node for global chat ('/g') of 'towny.chat.global'.
This commit is contained in:
1 parent
bb326c93dd
commit
7629cddd02
3 files changed
+79
-19
No files matched your search
+8
-1
@@ -8,4 +8,11 @@ v0.3:
|
||||
- TownyChat now only enables itself if Towny successfully starts.
|
||||
- Fixed missing {} around modplayername.
|
||||
v0.4:
|
||||
- Fixed custom channel chat not showing in the console.
|
||||
- Fixed custom channel chat not showing in the console.
|
||||
v0.5:
|
||||
- Added auto modes for chat.
|
||||
Type '/tc' to set town chat mode. All text typed from then on will be sent to town chat.
|
||||
While in a chat mode you can still talk in other channels by using the channel commands eg. '/nc hi'.
|
||||
While in a chat mode you can talk in global chat with '/g text here'.
|
||||
to clear all chat modes '/g'.
|
||||
- Added a new permission node for global chat ('/g') of 'towny.chat.global'.
|
||||
@@ -37,40 +37,61 @@ public class TownyPlayerHighestListener extends PlayerListener {
|
||||
return;
|
||||
}
|
||||
String split[] = event.getMessage().split("\\ ");
|
||||
String command = split[0].trim().toLowerCase();
|
||||
String message = "";
|
||||
|
||||
if (split.length > 1) {
|
||||
String command = split[0].trim().toLowerCase();
|
||||
String message = StringMgmt.join(StringMgmt.remFirstArg(split), " ");
|
||||
if (split.length > 1)
|
||||
message = StringMgmt.join(StringMgmt.remFirstArg(split), " ");
|
||||
|
||||
if (TownySettings.chatChannelExists(command)) {
|
||||
event.setMessage(message);
|
||||
if (TownySettings.chatChannelExists(command)) {
|
||||
event.setMessage(message);
|
||||
|
||||
if (!plugin.isPermissions() || (plugin.isPermissions() && TownyUniverse.getPermissionSource().hasPermission(player, TownySettings.getChatChannelPermission(command)))) {
|
||||
// Deal with special cases
|
||||
if (command.equalsIgnoreCase("/tc")) {
|
||||
if (!plugin.isPermissions() || (plugin.isPermissions() && TownyUniverse.getPermissionSource().hasPermission(player, TownySettings.getChatChannelPermission(command)))) {
|
||||
// Deal with special cases
|
||||
if (command.equalsIgnoreCase("/tc")) {
|
||||
|
||||
if (message.isEmpty())
|
||||
plugin.setPlayerChatMode(player, "tc");
|
||||
else {
|
||||
// Town Chat
|
||||
parseTownChatCommand(event, command, player);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
||||
} else if (command.equalsIgnoreCase("/nc")) {
|
||||
} else if (command.equalsIgnoreCase("/nc")) {
|
||||
|
||||
if (message.isEmpty())
|
||||
plugin.setPlayerChatMode(player, "nc");
|
||||
else {
|
||||
// Nation Chat
|
||||
parseNationChatCommand(event, command, player);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
||||
} else {
|
||||
} else if (command.equalsIgnoreCase("/g")) {
|
||||
|
||||
if (message.isEmpty())
|
||||
plugin.setPlayerChatMode(player, "g");
|
||||
else {
|
||||
// Global Chat
|
||||
parseGlobalChannelChatCommand(event, command, player);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
||||
} else {
|
||||
|
||||
if (message.isEmpty())
|
||||
plugin.setPlayerChatMode(player, command.replace("/", ""));
|
||||
else {
|
||||
// Custom channel Chat
|
||||
parseDefaultChannelChatCommand(event, command, player);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_command_disable"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
}// channel doesn't exist
|
||||
} else {
|
||||
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_command_disable"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -93,6 +114,16 @@ public class TownyPlayerHighestListener extends PlayerListener {
|
||||
// Nation chat
|
||||
parseNationChatCommand(event, "/nc", player);
|
||||
} else {
|
||||
|
||||
for (String channel : TownySettings.getChatChannels()) {
|
||||
if (plugin.hasPlayerMode(player, channel.replace("/", ""))) {
|
||||
// Custom channel Chat
|
||||
parseDefaultChannelChatCommand(event, channel, player);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// All chat modes are disabled, or this is open chat.
|
||||
if (TownySettings.isUsingModifyChat()) {
|
||||
event.setFormat(TownySettings.getModifyChatFormat());
|
||||
@@ -152,6 +183,28 @@ public class TownyPlayerHighestListener extends PlayerListener {
|
||||
TownyMessaging.sendMessage(test, chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage()));
|
||||
}
|
||||
|
||||
} catch (NotRegisteredException x) {
|
||||
TownyMessaging.sendErrorMsg(player, x.getError());
|
||||
}
|
||||
}
|
||||
|
||||
private void parseGlobalChannelChatCommand(PlayerChatEvent event, String command, Player player) {
|
||||
try {
|
||||
Resident resident = plugin.getTownyUniverse().getResident(player.getName());
|
||||
|
||||
if (TownySettings.isUsingModifyChat()) {
|
||||
event.setFormat(TownySettings.getModifyChatFormat());
|
||||
}
|
||||
|
||||
TownyChatEvent chatEvent = new TownyChatEvent(event, resident);
|
||||
event.setFormat(TownyChatFormatter.getChatFormat(chatEvent));
|
||||
|
||||
TownyUniverse.plugin.log(chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage()));
|
||||
for (Player test : plugin.getTownyUniverse().getOnlinePlayers()) {
|
||||
if (!plugin.isPermissions() || (plugin.isPermissions() && TownyUniverse.getPermissionSource().hasPermission(test, TownySettings.getChatChannelPermission(command))))
|
||||
TownyMessaging.sendMessage(test, chatEvent.getFormat().replace("%1$s", event.getPlayer().getDisplayName()).replace("%2$s", event.getMessage()));
|
||||
}
|
||||
|
||||
// TownyMessaging.sendNationMessage(nation, chatEvent.getFormat());
|
||||
} catch (NotRegisteredException x) {
|
||||
TownyMessaging.sendErrorMsg(player, x.getError());
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
name: TownyChat
|
||||
main: com.palmergames.bukkit.TownyChat.Chat
|
||||
version: 0.4
|
||||
version: 0.5
|
||||
author: ElgarL
|
||||
website: http://code.google.com/a/eclipselabs.org/p/towny/
|
||||
description: >
|
||||
|
||||
Reference in new issue
Block a user