mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-03 22:21:20 +00:00
Fixed channels not using correct names, also fixed the default channel.
This commit is contained in:
1 parent
01b01c8509
commit
ef45920534
6 files changed
+38
-54
No files matched your search
@@ -38,6 +38,7 @@ Channels:
|
|||||||
channeltag: '&f[g]'
|
channeltag: '&f[g]'
|
||||||
messagecolour: '&f'
|
messagecolour: '&f'
|
||||||
permission: 'towny.chat.general'
|
permission: 'towny.chat.general'
|
||||||
|
default: true
|
||||||
craftIRCTag: 'admin'
|
craftIRCTag: 'admin'
|
||||||
range: '-1'
|
range: '-1'
|
||||||
|
|
||||||
|
|||||||
+14
-21
@@ -28,6 +28,7 @@ public class ChannelJoinAliasCommand extends BukkitCommand {
|
|||||||
if (commandSender instanceof Player) { // So a player has ran some /g command or something
|
if (commandSender instanceof Player) { // So a player has ran some /g command or something
|
||||||
if (channel.getCommands().contains(this.getName())) { // Should in theory always be true.
|
if (channel.getCommands().contains(this.getName())) { // Should in theory always be true.
|
||||||
final Player player = (Player) commandSender;
|
final Player player = (Player) commandSender;
|
||||||
|
final Channel defaultChannel = plugin.getChannelsHandler().getDefaultChannel();
|
||||||
String message = "";
|
String message = "";
|
||||||
if (split.length > 0) {
|
if (split.length > 0) {
|
||||||
message = StringMgmt.join(split, " ");
|
message = StringMgmt.join(split, " ");
|
||||||
@@ -36,18 +37,18 @@ public class ChannelJoinAliasCommand extends BukkitCommand {
|
|||||||
if (plugin.getTowny().hasPlayerMode(player, channel.getName())) {
|
if (plugin.getTowny().hasPlayerMode(player, channel.getName())) {
|
||||||
// Find what the next channel is if any
|
// Find what the next channel is if any
|
||||||
Channel nextChannel = null;
|
Channel nextChannel = null;
|
||||||
if (plugin.getChannelsHandler().getDefaultChannel() != null && plugin.getChannelsHandler().getDefaultChannel().isPresent(player.getName())) {
|
if (defaultChannel != null && defaultChannel.isPresent(player.getName())) {
|
||||||
nextChannel = plugin.getChannelsHandler().getDefaultChannel();
|
nextChannel = defaultChannel;
|
||||||
if (!nextChannel.getName().equalsIgnoreCase(channel.getName())) {
|
if (!nextChannel.getName().equalsIgnoreCase(channel.getName())) {
|
||||||
TownyUtil.removeAndSetPlayerMode(plugin.getTowny(), player, channel.getName(), nextChannel.getName(), true);
|
TownyUtil.removeAndSetPlayerMode(plugin.getTowny(), player, channel.getName(), nextChannel.getName(), true);
|
||||||
} else {
|
} else {
|
||||||
// They're talking on default channel and want to leave but can't because they'll be put default again
|
// They're talking on default channel and want to leave but can't because they'll be put default again
|
||||||
// Their only option out is to leave the channel if they have permission to do so.
|
// Their only option out is to leave the channel if they have permission to do so.
|
||||||
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("tc_err_you_are_already_talking_in_default_channel_help"));
|
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("tc_err_you_are_already_talking_in_default_channel_help"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
plugin.getTowny().removePlayerMode(player);
|
TownyUtil.removePlayerMode(plugin.getTowny(), player, channel.getName(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextChannel == null) {
|
if (nextChannel == null) {
|
||||||
@@ -56,7 +57,7 @@ public class ChannelJoinAliasCommand extends BukkitCommand {
|
|||||||
|
|
||||||
// If the new channel is not us, announce it
|
// If the new channel is not us, announce it
|
||||||
if (nextChannel != null && !channel.getName().equalsIgnoreCase(nextChannel.getName())) {
|
if (nextChannel != null && !channel.getName().equalsIgnoreCase(nextChannel.getName())) {
|
||||||
TownyMessaging.sendMsg(player, String.format(TownySettings.getLangString("tc_you_are_now_talking_in_channel"), channel.getName()));
|
TownyMessaging.sendMsg(player, String.format(TownySettings.getLangString("tc_you_are_now_talking_in_channel"), nextChannel.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -76,15 +77,7 @@ public class ChannelJoinAliasCommand extends BukkitCommand {
|
|||||||
final String msg = message;
|
final String msg = message;
|
||||||
|
|
||||||
// Fire this Async so we match other incoming chat.
|
// Fire this Async so we match other incoming chat.
|
||||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> player.chat(msg));
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
player.chat(msg);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package com.palmergames.bukkit.TownyChat.channels;
|
package com.palmergames.bukkit.TownyChat.channels;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.TownyChat.Chat;
|
||||||
|
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.palmergames.bukkit.TownyChat.Chat;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ElgarL
|
* @author ElgarL
|
||||||
*
|
*
|
||||||
@@ -37,7 +37,7 @@ public class ChannelsHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Container for all channels
|
// Container for all channels
|
||||||
private Map<String,Channel> channels = new HashMap<String,Channel>();
|
private Map<String,Channel> channels = new LinkedHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the channels
|
* @return the channels
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
package com.palmergames.bukkit.TownyChat.config;
|
package com.palmergames.bukkit.TownyChat.config;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.TownyChat.Chat;
|
import com.palmergames.bukkit.TownyChat.Chat;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
||||||
import com.palmergames.bukkit.TownyChat.channels.StandardChannel;
|
import com.palmergames.bukkit.TownyChat.channels.StandardChannel;
|
||||||
import com.palmergames.bukkit.TownyChat.channels.channelFormats;
|
import com.palmergames.bukkit.TownyChat.channels.channelFormats;
|
||||||
import com.palmergames.bukkit.TownyChat.channels.channelTypes;
|
import com.palmergames.bukkit.TownyChat.channels.channelTypes;
|
||||||
import com.palmergames.bukkit.TownyChat.util.FileMgmt;
|
import com.palmergames.bukkit.TownyChat.util.FileMgmt;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -151,6 +150,11 @@ public class ConfigurationHandler {
|
|||||||
|
|
||||||
//System.out.print("Channel: " + channel.getName() + " : Type : " + channel.getType().name());
|
//System.out.print("Channel: " + channel.getName() + " : Type : " + channel.getType().name());
|
||||||
}
|
}
|
||||||
|
if (plugin.getChannelsHandler().getDefaultChannel() == null) {
|
||||||
|
// If there is no default channel set it to the first one that was parsed (the top one in the config)
|
||||||
|
// This is because not everyone knows that you need to add a default: true into the channels.yml to make it the default channel!
|
||||||
|
plugin.getChannelsHandler().setDefaultChannel(plugin.getChannelsHandler().getAllChannels().entrySet().iterator().next().getValue());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package com.palmergames.bukkit.TownyChat.util;
|
package com.palmergames.bukkit.TownyChat.util;
|
||||||
|
|
||||||
|
import com.palmergames.bukkit.towny.Towny;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.Towny;
|
|
||||||
|
|
||||||
public class TownyUtil {
|
public class TownyUtil {
|
||||||
|
|
||||||
public TownyUtil() {
|
public TownyUtil() {
|
||||||
@@ -31,18 +30,7 @@ public class TownyUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean addPlayerMode(Towny towny, Player player, String mode, boolean notify) {
|
public static void removeAndSetPlayerMode(Towny towny, Player player, String removeMode, String addMode, boolean notify) {
|
||||||
if (towny.hasPlayerMode(player, mode)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> modes = towny.getPlayerMode(player);
|
|
||||||
modes.add(mode);
|
|
||||||
towny.setPlayerMode(player, modes.toArray(new String[modes.size()]), notify);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean removeAndSetPlayerMode(Towny towny, Player player, String removeMode, String addMode, boolean notify) {
|
|
||||||
List<String> modes = towny.getPlayerMode(player);
|
List<String> modes = towny.getPlayerMode(player);
|
||||||
boolean modesChanged = false;
|
boolean modesChanged = false;
|
||||||
if (removeMode != null && towny.hasPlayerMode(player, removeMode)) {
|
if (removeMode != null && towny.hasPlayerMode(player, removeMode)) {
|
||||||
@@ -61,9 +49,7 @@ public class TownyUtil {
|
|||||||
modesChanged = true;
|
modesChanged = true;
|
||||||
}
|
}
|
||||||
if (modesChanged) {
|
if (modesChanged) {
|
||||||
towny.setPlayerMode(player, modes.toArray(new String[modes.size()]), notify);
|
towny.setPlayerMode(player, modes.toArray(new String[0]), notify);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
name: TownyChat
|
name: TownyChat
|
||||||
main: com.palmergames.bukkit.TownyChat.Chat
|
main: com.palmergames.bukkit.TownyChat.Chat
|
||||||
version: 0.53
|
version: 0.54
|
||||||
authors: [ElgarL, Shade, phrstbrn, LlmDl]
|
authors: [ElgarL, Shade, phrstbrn, LlmDl]
|
||||||
website: http://towny.palmergames.com/towny/townychat/
|
website: http://towny.palmergames.com/towny/townychat/
|
||||||
description: >
|
description: >
|
||||||
|
|||||||
Reference in new issue
Block a user