mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-02 22:23:18 +00:00
Add focusable option to channels, allowing servers to prevent players (#47)
from focusing onto channels, ie preventing using /tc with no message.
This commit is contained in:
1 parent
945b66f803
commit
f9e8b22c51
4 files changed
+24
-1
No files matched your search
@@ -24,6 +24,11 @@
|
||||
# 0 = same world only
|
||||
# any positive value = limited range in the same world.
|
||||
|
||||
# focusable is a setting which allows players to set their focused channel,
|
||||
# ie: using the /tc command with no message. Channels are focusable by default,
|
||||
# so there is no point to adding focusable: true. You make a channel un-focusable
|
||||
# by adding focusable: false.
|
||||
|
||||
# Text colouring
|
||||
# --------------
|
||||
# Black = &0, Navy = &1, Green = &2, Blue = &3, Red = &4
|
||||
|
||||
+2
-1
@@ -46,7 +46,8 @@ public class ChannelJoinAliasCommand extends BukkitCommand {
|
||||
// - channel has no permission set [by default they don't] OR
|
||||
// - channel has permission set AND:
|
||||
// - player has channel permission
|
||||
if (!channel.hasPermission(player)) {
|
||||
// - the Channel is designated as being joinable (which they are by default.)
|
||||
if (!channel.hasPermission(player) || !channel.isFocusable()) {
|
||||
TownyMessaging.sendErrorMsg(player, Translatable.of("tc_err_you_cannot_join_channel", channel.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public abstract class Channel {
|
||||
private double range;
|
||||
private boolean hooked=false;
|
||||
private boolean autojoin=true;
|
||||
private boolean focusable = true;
|
||||
private double spamtime;
|
||||
private WeakHashMap<Player, Long> spammers = new WeakHashMap<>();
|
||||
protected ConcurrentMap<String, Integer> absentPlayers = null;
|
||||
@@ -261,6 +262,12 @@ public abstract class Channel {
|
||||
return autojoin;
|
||||
}
|
||||
|
||||
public boolean isFocusable() {
|
||||
return focusable;
|
||||
}
|
||||
public void setFocusable(boolean focusable) {
|
||||
this.focusable = focusable;
|
||||
}
|
||||
public double getSpam_time() {
|
||||
return spamtime;
|
||||
}
|
||||
|
||||
@@ -107,6 +107,16 @@ public class ChannelConfigurationHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (key.equalsIgnoreCase("focusable")) {
|
||||
if (element instanceof Boolean) {
|
||||
channel.setFocusable((Boolean)element);
|
||||
} else if (element instanceof String) {
|
||||
channel.setFocusable(Boolean.parseBoolean(element.toString()));
|
||||
} else if (element instanceof Integer) {
|
||||
channel.setFocusable(Integer.parseInt(element.toString()) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (key.equalsIgnoreCase("default")) {
|
||||
boolean set = false;
|
||||
if (element instanceof Boolean) {
|
||||
|
||||
Reference in new issue
Block a user