mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
Language and canUse improvements
This commit is contained in:
1 parent
b6cca97104
commit
191eaa1b3a
8 files changed
+57
-9
No files matched your search
@@ -34,6 +34,19 @@ public class AllianceChatChannel extends SimpleChatChannel {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlayerUse(Player player) {
|
||||||
|
if (super.canPlayerUse(player)) {
|
||||||
|
try {
|
||||||
|
return TownyAPI.getInstance().getDataSource().getResident(player.getName()).hasTown();
|
||||||
|
} catch (NotRegisteredException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAllianceChat() {
|
public boolean isAllianceChat() {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -38,6 +38,19 @@ public class NationChatChannel extends SimpleChatChannel {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlayerUse(Player player) {
|
||||||
|
if (super.canPlayerUse(player)) {
|
||||||
|
try {
|
||||||
|
return TownyAPI.getInstance().getDataSource().getResident(player.getName()).hasNation();
|
||||||
|
} catch (NotRegisteredException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static NationChatChannel.Builder nationBuilder(String name) {
|
public static NationChatChannel.Builder nationBuilder(String name) {
|
||||||
return new NationChatChannel.Builder(name);
|
return new NationChatChannel.Builder(name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,15 @@ public class PartyChatChannel extends SimpleChatChannel {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlayerUse(Player player) {
|
||||||
|
if (super.canPlayerUse(player)) {
|
||||||
|
return PartyAPI.inParty(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static PartyChatChannel.Builder partyBuilder(String name) {
|
public static PartyChatChannel.Builder partyBuilder(String name) {
|
||||||
return new PartyChatChannel.Builder(name);
|
return new PartyChatChannel.Builder(name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,7 +216,9 @@ public class SimpleChatChannel extends ChatChannel {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Send message as normal
|
// Send message as normal
|
||||||
for (Player onlinePlayer : getAudience(player)) {
|
List<Player> receivers = getAudience(player);
|
||||||
|
|
||||||
|
for (Player onlinePlayer : receivers) {
|
||||||
Audience audience = simpleChat.getAudiences().player(onlinePlayer);
|
Audience audience = simpleChat.getAudiences().player(onlinePlayer);
|
||||||
|
|
||||||
if (message.contains(onlinePlayer.getName())) {
|
if (message.contains(onlinePlayer.getName())) {
|
||||||
|
|||||||
@@ -33,6 +33,19 @@ public class TownChatChannel extends SimpleChatChannel {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canPlayerUse(Player player) {
|
||||||
|
if (super.canPlayerUse(player)) {
|
||||||
|
try {
|
||||||
|
return TownyAPI.getInstance().getDataSource().getResident(player.getName()).hasTown();
|
||||||
|
} catch (NotRegisteredException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static TownChatChannel.Builder townBuilder(String name) {
|
public static TownChatChannel.Builder townBuilder(String name) {
|
||||||
return new TownChatChannel.Builder(name);
|
return new TownChatChannel.Builder(name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,7 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
public class ChannelManager {
|
public class ChannelManager {
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
|
||||||
|
|
||||||
public ChannelManager(SimpleChat simpleChat) {
|
public ChannelManager(SimpleChat simpleChat) {
|
||||||
this.simpleChat = simpleChat;
|
|
||||||
|
|
||||||
boolean hasTownChat = false;
|
boolean hasTownChat = false;
|
||||||
boolean hasNationChat = false;
|
boolean hasNationChat = false;
|
||||||
boolean hasAllianceChat = false;
|
boolean hasAllianceChat = false;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class CommandManager {
|
|||||||
|
|
||||||
manager.getCommandConditions().addCondition(ChatChannel.class,"canuse", (context, execution, value) -> {
|
manager.getCommandConditions().addCondition(ChatChannel.class,"canuse", (context, execution, value) -> {
|
||||||
if (!value.canPlayerUse(context.getIssuer().getPlayer())) {
|
if (!value.canPlayerUse(context.getIssuer().getPlayer())) {
|
||||||
throw new ConditionFailedException("You cannot use that channel!");
|
throw new ConditionFailedException(simpleChat.getConfig().getString("language.cannot-use-channel"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -48,9 +48,11 @@ language:
|
|||||||
not-ignoring-user: '<green>You are no longer ignoring <gold><player><green>!'
|
not-ignoring-user: '<green>You are no longer ignoring <gold><player><green>!'
|
||||||
is-now-shadow-muted: '<yellow>User <user> is now shadow muted!'
|
is-now-shadow-muted: '<yellow>User <user> is now shadow muted!'
|
||||||
no-longer-shadow-muted: '<yellow>User <user> is no longer shadow muted!'
|
no-longer-shadow-muted: '<yellow>User <user> is no longer shadow muted!'
|
||||||
player-left: '%player_displayname% has left <server>!' # Not MiniMessage compatible
|
# The following messages are not MiniMessage compatible
|
||||||
player-joined: '%player_displayname% has joined <server>!' # Not MiniMessage compatible
|
player-left: '%player_displayname% has left <server>!'
|
||||||
vote-received: '<name> has voted on <service>!' # Not MiniMessage compatible
|
player-joined: '%player_displayname% has joined <server>!'
|
||||||
|
vote-received: '<name> has voted on <service>!'
|
||||||
|
cannot-use-channel: "You cannot use that channel!"
|
||||||
|
|
||||||
server-name: 'Server'
|
server-name: 'Server'
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user