mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 14:38:49 +00:00
progress
This commit is contained in:
1 parent
a47ff4e7b2
commit
29bdcc8061
48 files changed
+303
-307
No files matched your search
@@ -11,7 +11,7 @@ public class DistanceContext implements Function<MessageContext, Boolean> {
|
||||
@Override
|
||||
@NonNull
|
||||
public Boolean apply(@NonNull MessageContext context) {
|
||||
if (!context.getSender().isOnline() || !context.getTarget().isOnline()) {
|
||||
if (!context.getSender().online() || !context.getTarget().online()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ public class DistanceContext implements Function<MessageContext, Boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
Location senderLocation = context.getSender().asPlayer().getLocation();
|
||||
Location targetLocation = context.getTarget().asPlayer().getLocation();
|
||||
Location senderLocation = context.getSender().player().getLocation();
|
||||
Location targetLocation = context.getTarget().player().getLocation();
|
||||
|
||||
if (!senderLocation.getWorld().equals(targetLocation.getWorld())) {
|
||||
return false;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class EconomyContext implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getUser().asPlayer();
|
||||
Player player = event.getUser().player();
|
||||
|
||||
if (!economy.has(player, requiredBal)) {
|
||||
event.setCancelled(true);
|
||||
@@ -67,7 +67,7 @@ public class EconomyContext implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getUser().asPlayer();
|
||||
Player player = event.getUser().player();
|
||||
|
||||
if (!economy.has(player, cost)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class TownyContext implements Listener {
|
||||
public void onResidentRemove(TownRemoveResidentEvent event) {
|
||||
String name = event.getResident().getName();
|
||||
ChatUser user = carbonChat.getUserService().wrap(name);
|
||||
Object town = user.getSelectedChannel().getContext(KEY);
|
||||
Object town = user.selectedChannel().getContext(KEY);
|
||||
|
||||
if ((town instanceof Boolean) && ((Boolean) town)) {
|
||||
user.clearSelectedChannel();
|
||||
@@ -71,7 +71,7 @@ public final class TownyContext implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
ChatUser user = carbonChat.getUserService().wrap(event.getPlayer());
|
||||
Object town = user.getSelectedChannel().getContext(KEY);
|
||||
Object town = user.selectedChannel().getContext(KEY);
|
||||
|
||||
if ((town instanceof Boolean) && ((Boolean) town) && !isInTown(user)) {
|
||||
user.clearSelectedChannel();
|
||||
@@ -80,7 +80,7 @@ public final class TownyContext implements Listener {
|
||||
|
||||
public boolean isInTown(@NonNull ChatUser user) {
|
||||
try {
|
||||
return TownyAPI.getInstance().getDataSource().getResident(user.asPlayer().getName()).hasTown();
|
||||
return TownyAPI.getInstance().getDataSource().getResident(user.player().getName()).hasTown();
|
||||
} catch (NotRegisteredException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -89,15 +89,15 @@ public final class TownyContext implements Listener {
|
||||
}
|
||||
|
||||
public boolean isInSameTown(@NonNull ChatUser user1, @NonNull ChatUser user2) {
|
||||
if (!user1.isOnline() || !user2.isOnline()) {
|
||||
if (!user1.online() || !user2.online()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
Resident resident = TownyAPI.getInstance().getDataSource().getResident(user1.asPlayer().getName());
|
||||
Resident resident = TownyAPI.getInstance().getDataSource().getResident(user1.player().getName());
|
||||
|
||||
if (resident.hasTown()) {
|
||||
return resident.getTown().hasResident(user2.asPlayer().getName());
|
||||
return resident.getTown().hasResident(user2.player().getName());
|
||||
}
|
||||
} catch (NotRegisteredException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -93,12 +93,12 @@ public final class WorldGuardContext implements Listener {
|
||||
}
|
||||
|
||||
public boolean isInSameRegion(@NonNull ChatUser user1, @NonNull ChatUser user2) {
|
||||
if (!user1.isOnline() || !user2.isOnline()) {
|
||||
if (!user1.online() || !user2.online()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Location user1Location = BukkitAdapter.adapt(user1.asPlayer().getLocation());
|
||||
Location user2Location = BukkitAdapter.adapt(user2.asPlayer().getLocation());
|
||||
Location user1Location = BukkitAdapter.adapt(user1.player().getLocation());
|
||||
Location user2Location = BukkitAdapter.adapt(user2.player().getLocation());
|
||||
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionQuery regionQuery = container.createQuery();
|
||||
@@ -117,14 +117,14 @@ public final class WorldGuardContext implements Listener {
|
||||
|
||||
public boolean isInRegion(@NonNull String region, @NonNull ChatUser user) {
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
World world = BukkitAdapter.adapt(user.asPlayer().getWorld());
|
||||
World world = BukkitAdapter.adapt(user.player().getWorld());
|
||||
ProtectedRegion protection = container.get(world).getRegion(region);
|
||||
|
||||
return isInRegion(protection, user);
|
||||
}
|
||||
|
||||
public boolean isInRegion(@NonNull ProtectedRegion region, @NonNull ChatUser user) {
|
||||
Location location = BukkitAdapter.adapt(user.asPlayer().getLocation());
|
||||
Location location = BukkitAdapter.adapt(user.player().getLocation());
|
||||
|
||||
return region.contains(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class mcMMOContext implements Listener {
|
||||
}
|
||||
|
||||
ChatUser user = carbonChat.getUserService().wrap(event.getPlayer());
|
||||
Object party = user.getSelectedChannel().getContext("mcmmo-party");
|
||||
Object party = user.selectedChannel().getContext("mcmmo-party");
|
||||
|
||||
if ((party instanceof Boolean) && ((Boolean) party)) {
|
||||
user.clearSelectedChannel();
|
||||
@@ -71,7 +71,7 @@ public final class mcMMOContext implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
ChatUser user = carbonChat.getUserService().wrap(event.getPlayer());
|
||||
Object party = user.getSelectedChannel().getContext("mcmmo-party");
|
||||
Object party = user.selectedChannel().getContext("mcmmo-party");
|
||||
|
||||
if ((party instanceof Boolean) && ((Boolean) party) && !isInParty(user)) {
|
||||
user.clearSelectedChannel();
|
||||
@@ -79,15 +79,15 @@ public final class mcMMOContext implements Listener {
|
||||
}
|
||||
|
||||
public boolean isInParty(@NonNull ChatUser user) {
|
||||
return PartyAPI.inParty(user.asPlayer());
|
||||
return PartyAPI.inParty(user.player());
|
||||
}
|
||||
|
||||
public boolean isInSameParty(@NonNull ChatUser user1, @NonNull ChatUser user2) {
|
||||
if (!user1.isOnline() || !user2.isOnline()) {
|
||||
if (!user1.online() || !user2.online()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return PartyAPI.inSameParty(user1.asPlayer(), user2.asPlayer());
|
||||
return PartyAPI.inSameParty(user1.player(), user2.player());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
@Nullable
|
||||
private final ConfigurationSection config;
|
||||
|
||||
public CarbonChatChannel(@NonNull String key, @NonNull CarbonChat carbonChat, @Nullable ConfigurationSection config) {
|
||||
public CarbonChatChannel(@NonNull final String key, @NonNull final CarbonChat carbonChat, @Nullable final ConfigurationSection config) {
|
||||
this.key = key;
|
||||
this.carbonChat = carbonChat;
|
||||
this.config = config;
|
||||
@@ -50,13 +50,13 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testContext(@NonNull ChatUser sender, @NonNull ChatUser target) {
|
||||
public boolean testContext(@NonNull final ChatUser sender, @NonNull final ChatUser target) {
|
||||
return carbonChat.getContextManager().testContext(sender, target, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerUse(@NonNull ChatUser user) {
|
||||
return user.asPlayer().hasPermission("carbonchat.channels." + getName() + ".use");
|
||||
public boolean canPlayerUse(@NonNull final ChatUser user) {
|
||||
return user.player().hasPermission("carbonchat.channels." + getName() + ".use");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,17 +76,17 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
}
|
||||
|
||||
private void updateUserNickname(@NonNull ChatUser user) {
|
||||
if (user.isOnline()) {
|
||||
String nickname = user.getNickname();
|
||||
if (user.online()) {
|
||||
String nickname = user.nickname();
|
||||
|
||||
if (nickname != null) {
|
||||
Component component = carbonChat.getAdventureManager().processMessage(nickname);
|
||||
nickname = CarbonChat.LEGACY.serialize(component);
|
||||
|
||||
user.asPlayer().setDisplayName(nickname);
|
||||
user.player().setDisplayName(nickname);
|
||||
|
||||
if (carbonChat.getConfig().getBoolean("nicknames-set-tab-name")) {
|
||||
user.asPlayer().setPlayerListName(nickname);
|
||||
user.player().setPlayerListName(nickname);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,13 +112,13 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
|
||||
String displayName;
|
||||
|
||||
if (user.getNickname() != null) {
|
||||
displayName = user.getNickname();
|
||||
if (user.nickname() != null) {
|
||||
displayName = user.nickname();
|
||||
} else {
|
||||
if (user.isOnline()) {
|
||||
displayName = user.asPlayer().getDisplayName();
|
||||
if (user.online()) {
|
||||
displayName = user.player().getDisplayName();
|
||||
} else {
|
||||
displayName = user.asOfflinePlayer().getName();
|
||||
displayName = user.offlinePlayer().getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,8 +181,8 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
// Route message to bungee / discord (if message originates from this server)
|
||||
// Use instanceof and not isOnline, if this message originates from another then the instanceof will
|
||||
// fail, but isOnline may succeed if the player is online on both servers (somehow).
|
||||
if (user.isOnline() && !fromRemote && (shouldBungee() || isCrossServer())) {
|
||||
sendMessageToBungee(user.asPlayer(), consoleEvent.getComponent());
|
||||
if (user.online() && !fromRemote && (shouldBungee() || isCrossServer())) {
|
||||
sendMessageToBungee(user.player(), consoleEvent.getComponent());
|
||||
}
|
||||
|
||||
return consoleEvent.getComponent();
|
||||
@@ -214,18 +214,18 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
}
|
||||
|
||||
private boolean userHasGroup(@NonNull ChatUser user, @NonNull String group) {
|
||||
if (user.isOnline()) {
|
||||
if (carbonChat.getPermission().playerInGroup(user.asPlayer(), group)) {
|
||||
if (user.online()) {
|
||||
if (carbonChat.getPermission().playerInGroup(user.player(), group)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (carbonChat.getPermission().playerInGroup(null, user.asOfflinePlayer(), group)) {
|
||||
if (carbonChat.getPermission().playerInGroup(null, user.offlinePlayer(), group)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (user.isOnline() && this.permissionGroupMatching()) {
|
||||
return user.asPlayer().hasPermission("carbonchat.group." + group);
|
||||
if (user.online() && this.permissionGroupMatching()) {
|
||||
return user.player().hasPermission("carbonchat.group." + group);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -235,10 +235,10 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
private String getFirstFoundUserFormat(@NonNull ChatUser user) {
|
||||
String[] playerGroups;
|
||||
|
||||
if (user.isOnline()) {
|
||||
playerGroups = carbonChat.getPermission().getPlayerGroups(user.asPlayer());
|
||||
if (user.online()) {
|
||||
playerGroups = carbonChat.getPermission().getPlayerGroups(user.player());
|
||||
} else {
|
||||
playerGroups = carbonChat.getPermission().getPlayerGroups(null, user.asOfflinePlayer());
|
||||
playerGroups = carbonChat.getPermission().getPlayerGroups(null, user.offlinePlayer());
|
||||
}
|
||||
|
||||
for (String group : playerGroups) {
|
||||
@@ -256,10 +256,10 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
private String getPrimaryGroupFormat(@NonNull ChatUser user) {
|
||||
String primaryGroup;
|
||||
|
||||
if (user.isOnline()) {
|
||||
primaryGroup = carbonChat.getPermission().getPrimaryGroup(user.asPlayer());
|
||||
if (user.online()) {
|
||||
primaryGroup = carbonChat.getPermission().getPrimaryGroup(user.player());
|
||||
} else {
|
||||
primaryGroup = carbonChat.getPermission().getPrimaryGroup(null, user.asOfflinePlayer());
|
||||
primaryGroup = carbonChat.getPermission().getPrimaryGroup(null, user.offlinePlayer());
|
||||
}
|
||||
|
||||
String primaryGroupFormat = getFormat(primaryGroup);
|
||||
@@ -284,7 +284,7 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
|
||||
private boolean isUserSpying(@NonNull ChatUser sender, @NonNull ChatUser target) {
|
||||
if (!canPlayerSee(sender, target, false)) {
|
||||
return target.getChannelSettings(this).isSpying();
|
||||
return target.getChannelSettings(this).spying();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -308,10 +308,10 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
|
||||
@Override
|
||||
public boolean canPlayerSee(@NonNull ChatUser target, boolean checkSpying) {
|
||||
Player targetPlayer = target.asPlayer();
|
||||
Player targetPlayer = target.player();
|
||||
|
||||
if (checkSpying && targetPlayer.hasPermission("carbonchat.spy." + getName())) {
|
||||
if (target.getChannelSettings(this).isSpying()) {
|
||||
if (target.getChannelSettings(this).spying()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -321,14 +321,14 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
}
|
||||
|
||||
if (isIgnorable()) {
|
||||
return !target.getChannelSettings(this).isIgnored();
|
||||
return !target.getChannelSettings(this).ignored();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canPlayerSee(@NonNull ChatUser sender, @NonNull ChatUser target, boolean checkSpying) {
|
||||
Player targetPlayer = target.asPlayer();
|
||||
Player targetPlayer = target.player();
|
||||
|
||||
if (!canPlayerSee(target, checkSpying)) {
|
||||
return false;
|
||||
@@ -344,7 +344,7 @@ public class CarbonChatChannel extends ChatChannel {
|
||||
@Override
|
||||
@Nullable
|
||||
public TextColor getChannelColor(@NonNull ChatUser user) {
|
||||
TextColor userColor = user.getChannelSettings(this).getColor();
|
||||
TextColor userColor = user.getChannelSettings(this).color();
|
||||
|
||||
if (userColor != null) {
|
||||
System.out.println("user color found!");
|
||||
|
||||
@@ -51,7 +51,7 @@ public class AliasedChannelCommand {
|
||||
private void setChannel(@NonNull Player player, @NonNull Object @NonNull [] args) {
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
|
||||
if (user.getChannelSettings(getChatChannel()).isIgnored()) {
|
||||
if (user.getChannelSettings(getChatChannel()).ignored()) {
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, getChatChannel().getCannotUseMessage(),
|
||||
"br", "\n",
|
||||
"color", "<" + getChatChannel().getChannelColor(user).toString() + ">",
|
||||
@@ -60,7 +60,7 @@ public class AliasedChannelCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
user.setSelectedChannel(getChatChannel());
|
||||
user.selectedChannel(getChatChannel());
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, getChatChannel().getSwitchMessage(),
|
||||
"br", "\n",
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ChannelCommand {
|
||||
public ChannelCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ public class ChannelCommand {
|
||||
LinkedHashMap<String, Argument> setChannelArguments = new LinkedHashMap<>();
|
||||
setChannelArguments.put("channel", CarbonUtils.channelArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(setChannelArguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.channel"))
|
||||
.executesPlayer(this::setChannel)
|
||||
.register();
|
||||
@@ -44,9 +44,9 @@ public class ChannelCommand {
|
||||
sendMessageArguments.put("channel", CarbonUtils.channelArgument());
|
||||
sendMessageArguments.put("message", new GreedyStringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(sendMessageArguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.channel.message"))
|
||||
.executesPlayer(this::sendMessage)
|
||||
.register();
|
||||
@@ -56,7 +56,7 @@ public class ChannelCommand {
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
ChatChannel channel = (ChatChannel) args[0];
|
||||
|
||||
if (user.getChannelSettings(channel).isIgnored()) {
|
||||
if (user.getChannelSettings(channel).ignored()) {
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, channel.getCannotUseMessage(),
|
||||
"br", "\n",
|
||||
"color", "<" + channel.getChannelColor(user).toString() + ">",
|
||||
@@ -65,7 +65,7 @@ public class ChannelCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
user.setSelectedChannel(channel);
|
||||
user.selectedChannel(channel);
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player, channel.getSwitchMessage(),
|
||||
"br", "\n",
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ChannelListCommand {
|
||||
public ChannelListCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ public class ChannelListCommand {
|
||||
|
||||
LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(channelArguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.channellist"))
|
||||
.executesPlayer(this::executeSelf)
|
||||
.register();
|
||||
@@ -48,9 +48,9 @@ public class ChannelListCommand {
|
||||
LinkedHashMap<String, Argument> argumentsOther = new LinkedHashMap<>();
|
||||
argumentsOther.put("player", CarbonUtils.onlineChatUserArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(argumentsOther)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.channellist.other"))
|
||||
.executes(this::executeOther)
|
||||
.register();
|
||||
@@ -67,9 +67,9 @@ public class ChannelListCommand {
|
||||
Audience cmdSender = carbonChat.getAdventureManager().getAudiences().audience(sender);
|
||||
ChatUser user = (ChatUser) args[0];
|
||||
|
||||
if (!user.isOnline()) {
|
||||
if (!user.online()) {
|
||||
String mustBeOnline = carbonChat.getLanguage().getString("user-must-be-online");
|
||||
cmdSender.sendMessage(carbonChat.getAdventureManager().processMessage(mustBeOnline, "br", "\n", "player", user.asOfflinePlayer().getName()));
|
||||
cmdSender.sendMessage(carbonChat.getAdventureManager().processMessage(mustBeOnline, "br", "\n", "player", user.offlinePlayer().getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,14 +17,14 @@ public class ChatReloadCommand {
|
||||
public ChatReloadCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.reload"))
|
||||
.executes(this::execute)
|
||||
.register();
|
||||
|
||||
@@ -21,14 +21,14 @@ public class ClearChatCommand {
|
||||
public ClearChatCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
CommandUtils.handleDuplicateCommands(commandSettings);
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.clearchat.clear"))
|
||||
.executes(this::execute)
|
||||
.register();
|
||||
|
||||
@@ -24,7 +24,7 @@ public class IgnoreCommand {
|
||||
public IgnoreCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ public class IgnoreCommand {
|
||||
LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
channelArguments.put("player", CarbonUtils.chatUserArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(channelArguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.ignore"))
|
||||
.executesPlayer(this::execute)
|
||||
.register();
|
||||
@@ -49,13 +49,13 @@ public class IgnoreCommand {
|
||||
user.setIgnoringUser(targetUser, false);
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player,
|
||||
carbonChat.getLanguage().getString("not-ignoring-user"),
|
||||
"br", "\n", "player", targetUser.asOfflinePlayer().getName()));
|
||||
"br", "\n", "player", targetUser.offlinePlayer().getName()));
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(carbonChat, () -> {
|
||||
Permission permission = carbonChat.getPermission();
|
||||
String format;
|
||||
|
||||
if (permission.playerHas(null, targetUser.asOfflinePlayer(), "carbonchat.ignore.exempt")) {
|
||||
if (permission.playerHas(null, targetUser.offlinePlayer(), "carbonchat.ignore.exempt")) {
|
||||
format = carbonChat.getLanguage().getString("ignore-exempt");
|
||||
} else {
|
||||
user.setIgnoringUser(targetUser, true);
|
||||
@@ -64,7 +64,7 @@ public class IgnoreCommand {
|
||||
|
||||
Component message = carbonChat.getAdventureManager().processMessageWithPapi(player, format,
|
||||
"br", "\n", "sender", player.getDisplayName(), "player",
|
||||
targetUser.asOfflinePlayer().getName());
|
||||
targetUser.offlinePlayer().getName());
|
||||
|
||||
user.sendMessage(message);
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ public class MeCommand {
|
||||
public MeCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ public class MeCommand {
|
||||
LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
channelArguments.put("message", new GreedyStringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(channelArguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.me"))
|
||||
.executesPlayer(this::execute)
|
||||
.register();
|
||||
|
||||
@@ -22,7 +22,7 @@ public class MessageCommand {
|
||||
public MessageCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ public class MessageCommand {
|
||||
arguments.put("player", CarbonUtils.chatUserArgument());
|
||||
arguments.put("message", new GreedyStringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(arguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.message"))
|
||||
.executesPlayer(this::execute)
|
||||
.register();
|
||||
|
||||
@@ -25,7 +25,7 @@ public class MuteCommand {
|
||||
public MuteCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ public class MuteCommand {
|
||||
LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("player", CarbonUtils.chatUserArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(arguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.mute"))
|
||||
.executes(this::execute)
|
||||
.register();
|
||||
@@ -51,7 +51,7 @@ public class MuteCommand {
|
||||
String format = carbonChat.getLanguage().getString("no-longer-muted");
|
||||
|
||||
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
|
||||
"player", user.asOfflinePlayer().getName());
|
||||
"player", user.offlinePlayer().getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
} else {
|
||||
@@ -59,7 +59,7 @@ public class MuteCommand {
|
||||
Permission permission = carbonChat.getPermission();
|
||||
String format;
|
||||
|
||||
if (permission.playerHas(null, user.asOfflinePlayer(), "carbonchat.mute.exempt")) {
|
||||
if (permission.playerHas(null, user.offlinePlayer(), "carbonchat.mute.exempt")) {
|
||||
format = carbonChat.getLanguage().getString("mute-exempt");
|
||||
} else {
|
||||
user.setMuted(true);
|
||||
@@ -67,7 +67,7 @@ public class MuteCommand {
|
||||
}
|
||||
|
||||
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
|
||||
"player", user.asOfflinePlayer().getName());
|
||||
"player", user.offlinePlayer().getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ public class NicknameCommand {
|
||||
public NicknameCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ public class NicknameCommand {
|
||||
LinkedHashMap<String, Argument> selfArguments = new LinkedHashMap<>();
|
||||
selfArguments.put("nickname", new StringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(selfArguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.nickname"))
|
||||
.executesPlayer(this::executeSelf)
|
||||
.register();
|
||||
@@ -44,9 +44,9 @@ public class NicknameCommand {
|
||||
otherArguments.put("player", CarbonUtils.chatUserArgument());
|
||||
otherArguments.put("nickname", new StringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(otherArguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.nickname.others"))
|
||||
.executes(this::executeOther)
|
||||
.register();
|
||||
@@ -60,7 +60,7 @@ public class NicknameCommand {
|
||||
nickname = null;
|
||||
}
|
||||
|
||||
sender.setNickname(nickname);
|
||||
sender.nickname(nickname);
|
||||
|
||||
String message;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class NicknameCommand {
|
||||
|
||||
sender.sendMessage(carbonChat.getAdventureManager().processMessage(
|
||||
message, "nickname", nickname == null ? "" : nickname,
|
||||
"user", sender.asOfflinePlayer().getName()));
|
||||
"user", sender.offlinePlayer().getName()));
|
||||
}
|
||||
|
||||
private void executeOther(@NonNull CommandSender sender, @NonNull Object @NonNull [] args) {
|
||||
@@ -81,11 +81,11 @@ public class NicknameCommand {
|
||||
String nickname = (String) args[1];
|
||||
|
||||
if (nickname.equalsIgnoreCase("off") ||
|
||||
nickname.equalsIgnoreCase(target.asOfflinePlayer().getName())) {
|
||||
nickname.equalsIgnoreCase(target.offlinePlayer().getName())) {
|
||||
nickname = null;
|
||||
}
|
||||
|
||||
target.setNickname(nickname);
|
||||
target.nickname(nickname);
|
||||
|
||||
String message;
|
||||
|
||||
@@ -97,7 +97,7 @@ public class NicknameCommand {
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessage(
|
||||
message, "nickname", nickname == null ? "" : nickname,
|
||||
"user", target.asOfflinePlayer().getName()));
|
||||
"user", target.offlinePlayer().getName()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public class ReplyCommand {
|
||||
public ReplyCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ public class ReplyCommand {
|
||||
LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("message", new GreedyStringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(arguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.reply"))
|
||||
.executesPlayer(this::execute)
|
||||
.register();
|
||||
|
||||
@@ -24,7 +24,7 @@ public class SetColorCommand {
|
||||
public SetColorCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ public class SetColorCommand {
|
||||
arguments.put("channel", new LiteralArgument(channel.getKey()));
|
||||
arguments.put("color", CarbonUtils.textColorArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(arguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.setcolor"))
|
||||
.executesPlayer((player, args) -> {
|
||||
TextColor color = (TextColor) args[0];
|
||||
@@ -54,7 +54,7 @@ public class SetColorCommand {
|
||||
|
||||
UserChannelSettings settings = user.getChannelSettings(channel);
|
||||
|
||||
settings.setColor(color);
|
||||
settings.color(color);
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(player,
|
||||
carbonChat.getLanguage().getString("channel-color-set"),
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ShadowMuteCommand {
|
||||
public ShadowMuteCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ public class ShadowMuteCommand {
|
||||
LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("player", CarbonUtils.chatUserArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(arguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.shadowmute"))
|
||||
.executes(this::execute)
|
||||
.register();
|
||||
@@ -51,7 +51,7 @@ public class ShadowMuteCommand {
|
||||
String format = carbonChat.getLanguage().getString("no-longer-shadow-muted");
|
||||
|
||||
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
|
||||
"player", user.asOfflinePlayer().getName());
|
||||
"player", user.offlinePlayer().getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
} else {
|
||||
@@ -59,7 +59,7 @@ public class ShadowMuteCommand {
|
||||
Permission permission = carbonChat.getPermission();
|
||||
String format;
|
||||
|
||||
if (permission.playerHas(null, user.asOfflinePlayer(), "carbonchat.shadowmute.exempt")) {
|
||||
if (permission.playerHas(null, user.offlinePlayer(), "carbonchat.shadowmute.exempt")) {
|
||||
format = carbonChat.getLanguage().getString("shadow-mute-exempt");
|
||||
} else {
|
||||
user.setShadowMuted(true);
|
||||
@@ -67,7 +67,7 @@ public class ShadowMuteCommand {
|
||||
}
|
||||
|
||||
Component message = carbonChat.getAdventureManager().processMessage(format, "br", "\n",
|
||||
"player", user.asOfflinePlayer().getName());
|
||||
"player", user.offlinePlayer().getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ public class SpyChannelCommand {
|
||||
public SpyChannelCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ public class SpyChannelCommand {
|
||||
LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
channelArguments.put("channel", CarbonUtils.channelArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(channelArguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.spy"))
|
||||
.executesPlayer(this::execute)
|
||||
.register();
|
||||
@@ -44,9 +44,9 @@ public class SpyChannelCommand {
|
||||
LinkedHashMap<String, Argument> whisperArguments = new LinkedHashMap<>();
|
||||
whisperArguments.put("channel", new LiteralArgument("whispers"));
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(whisperArguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.spy"))
|
||||
.executesPlayer(this::executeWhispers)
|
||||
.register();
|
||||
@@ -55,9 +55,9 @@ public class SpyChannelCommand {
|
||||
everythingArguments.put("channel", new LiteralArgument("*"));
|
||||
everythingArguments.put("should-spy", new BooleanArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(everythingArguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.spy"))
|
||||
.executesPlayer(this::executeEverything) // lul
|
||||
.register();
|
||||
@@ -71,11 +71,11 @@ public class SpyChannelCommand {
|
||||
|
||||
UserChannelSettings settings = user.getChannelSettings(chatChannel);
|
||||
|
||||
if (settings.isSpying()) {
|
||||
settings.setSpying(false);
|
||||
if (settings.spying()) {
|
||||
settings.spying(false);
|
||||
message = carbonChat.getLanguage().getString("spy-toggled-off");
|
||||
} else {
|
||||
settings.setSpying(true);
|
||||
settings.spying(true);
|
||||
message = carbonChat.getLanguage().getString("spy-toggled-on");
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class SpyChannelCommand {
|
||||
user.setSpyingWhispers(true);
|
||||
|
||||
for (ChatChannel channel : carbonChat.getChannelManager().getRegistry().values()) {
|
||||
user.getChannelSettings(channel).setSpying(true);
|
||||
user.getChannelSettings(channel).spying(true);
|
||||
}
|
||||
|
||||
message = carbonChat.getLanguage().getString("spy-everything-off");
|
||||
@@ -118,7 +118,7 @@ public class SpyChannelCommand {
|
||||
user.setSpyingWhispers(false);
|
||||
|
||||
for (ChatChannel channel : carbonChat.getChannelManager().getRegistry().values()) {
|
||||
user.getChannelSettings(channel).setSpying(false);
|
||||
user.getChannelSettings(channel).spying(false);
|
||||
}
|
||||
|
||||
message = carbonChat.getLanguage().getString("spy-everything-on");
|
||||
|
||||
@@ -24,7 +24,7 @@ public class SudoChannelCommand {
|
||||
public SudoChannelCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ public class SudoChannelCommand {
|
||||
setOtherChannelArguments.put("player", CarbonUtils.onlineChatUserArgument());
|
||||
setOtherChannelArguments.put("channel", CarbonUtils.channelArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(setOtherChannelArguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.channel.others"))
|
||||
.executes((sender, args) -> {
|
||||
this.setOtherChannel(sender, (ChatUser) args[0], (ChatChannel) args[1]);
|
||||
@@ -48,9 +48,9 @@ public class SudoChannelCommand {
|
||||
sendMessageOtherArguments.put("channel", CarbonUtils.channelArgument());
|
||||
sendMessageOtherArguments.put("message", new GreedyStringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(sendMessageOtherArguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.channel.others.message"))
|
||||
.executes((sender, args) -> {
|
||||
this.sendMessageOther(sender, (ChatUser) args[0], (ChatChannel) args[1], (String) args[2]);
|
||||
@@ -59,7 +59,7 @@ public class SudoChannelCommand {
|
||||
}
|
||||
|
||||
private void setOtherChannel(@NonNull CommandSender sender, @NonNull ChatUser user, @NonNull ChatChannel channel) {
|
||||
user.setSelectedChannel(channel);
|
||||
user.selectedChannel(channel);
|
||||
|
||||
String message = channel.getSwitchMessage();
|
||||
String otherMessage = channel.getSwitchOtherMessage();
|
||||
@@ -69,7 +69,7 @@ public class SudoChannelCommand {
|
||||
|
||||
carbonChat.getAdventureManager().getAudiences().audience(sender).sendMessage(carbonChat.getAdventureManager().processMessage(otherMessage, "br", "\n",
|
||||
"color", "<color:" + channel.getChannelColor(user).toString() + ">", "channel", channel.getName(),
|
||||
"player", user.asOfflinePlayer().getName()));
|
||||
"player", user.offlinePlayer().getName()));
|
||||
}
|
||||
|
||||
private void sendMessageOther(@NonNull CommandSender sender, @NonNull ChatUser user, @NonNull ChatChannel channel, @NonNull String message) {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class ToggleCommand {
|
||||
public ToggleCommand(@NonNull CarbonChat carbonChat, @NonNull CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.isEnabled()) {
|
||||
if (!commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ public class ToggleCommand {
|
||||
LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
channelArguments.put("channel", CarbonUtils.channelArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(channelArguments)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.toggle"))
|
||||
.executesPlayer(this::executeSelf)
|
||||
.register();
|
||||
@@ -44,9 +44,9 @@ public class ToggleCommand {
|
||||
argumentsOther.put("players", CarbonUtils.chatUserArgument());
|
||||
argumentsOther.put("channel", CarbonUtils.channelArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.getName())
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(argumentsOther)
|
||||
.withAliases(commandSettings.getAliasesArray())
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.toggle"))
|
||||
.executes(this::executeOther)
|
||||
.register();
|
||||
@@ -62,11 +62,11 @@ public class ToggleCommand {
|
||||
|
||||
if (!channel.isIgnorable()) {
|
||||
message = channel.getCannotIgnoreMessage();
|
||||
} else if (settings.isIgnored()) {
|
||||
settings.setIgnoring(false);
|
||||
} else if (settings.ignored()) {
|
||||
settings.ignoring(false);
|
||||
message = channel.getToggleOffMessage();
|
||||
} else {
|
||||
settings.setIgnoring(true);
|
||||
settings.ignoring(true);
|
||||
message = channel.getToggleOnMessage();
|
||||
}
|
||||
|
||||
@@ -83,12 +83,12 @@ public class ToggleCommand {
|
||||
|
||||
UserChannelSettings settings = user.getChannelSettings(channel);
|
||||
|
||||
if (settings.isIgnored()) {
|
||||
settings.setIgnoring(false);
|
||||
if (settings.ignored()) {
|
||||
settings.ignoring(false);
|
||||
message = channel.getToggleOffMessage();
|
||||
otherMessage = channel.getToggleOtherOffMessage();
|
||||
} else {
|
||||
settings.setIgnoring(true);
|
||||
settings.ignoring(true);
|
||||
message = channel.getToggleOnMessage();
|
||||
otherMessage = channel.getToggleOtherOnMessage();
|
||||
}
|
||||
@@ -98,6 +98,6 @@ public class ToggleCommand {
|
||||
|
||||
carbonChat.getAdventureManager().getAudiences().audience(sender).sendMessage(carbonChat.getAdventureManager().processMessage(otherMessage,
|
||||
"br", "\n", "color", "<color:" + channel.getChannelColor(user).toString() + ">",
|
||||
"channel", channel.getName(), "player", user.asOfflinePlayer().getName()));
|
||||
"channel", channel.getName(), "player", user.offlinePlayer().getName()));
|
||||
}
|
||||
}
|
||||
@@ -27,15 +27,15 @@ public class BukkitChatListener implements Listener {
|
||||
|
||||
// Chat messages
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerchat(AsyncPlayerChatEvent event) {
|
||||
public void onPlayerchat(@NonNull final AsyncPlayerChatEvent event) {
|
||||
ChatUser user = carbonChat.getUserService().wrap(event.getPlayer());
|
||||
ChatChannel channel = user.getSelectedChannel();
|
||||
ChatChannel channel = user.selectedChannel();
|
||||
|
||||
if (channel.shouldCancelChatEvent()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
for (ChatChannel entry : carbonChat.getChannelManager().getRegistry().values()) {
|
||||
for (final ChatChannel entry : carbonChat.getChannelManager().getRegistry().values()) {
|
||||
if (entry.getMessagePrefix() == null || entry.getMessagePrefix().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ public class FilterHandler implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getUser().isOnline()) {
|
||||
if (event.getUser().asPlayer().hasPermission("carbonchat.filter.exempt")) {
|
||||
if (event.getUser().online()) {
|
||||
if (event.getUser().player().hasPermission("carbonchat.filter.exempt")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ public class ItemLinkHandler implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onItemLink(ChatComponentEvent event) {
|
||||
// Handle item linking placeholders
|
||||
if (event.getSender().isOnline()) {
|
||||
Player player = event.getSender().asPlayer();
|
||||
if (event.getSender().online()) {
|
||||
Player player = event.getSender().player();
|
||||
|
||||
if (!player.hasPermission("carbonchat.itemlink")) {
|
||||
return;
|
||||
|
||||
@@ -10,7 +10,7 @@ public class OfflineNameHandler implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onOfflineMessage(PreChatFormatEvent event) {
|
||||
// If the player isn't online (cross server message), use their normal name
|
||||
if (!event.getUser().isOnline()) {
|
||||
if (!event.getUser().online()) {
|
||||
event.setFormat(event.getFormat().replace("%player_displayname%", "%player_name%"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class PingHandler implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
String targetName = event.getTarget().asOfflinePlayer().getName();
|
||||
String targetName = event.getTarget().offlinePlayer().getName();
|
||||
String prefix = carbonChat.getConfig().getString("pings.prefix", "");
|
||||
boolean caseSensitive = carbonChat.getConfig().getBoolean("pings.case-sensitive", false);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public class PlaceholderHandler implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPapiPlaceholder(PreChatFormatEvent event) {
|
||||
event.setFormat(PlaceholderAPI.setPlaceholders(event.getUser().asOfflinePlayer(), event.getFormat()));
|
||||
event.setFormat(PlaceholderAPI.setPlaceholders(event.getUser().offlinePlayer(), event.getFormat()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,8 +24,8 @@ public class PlayerJoinListener implements Listener {
|
||||
|
||||
carbonChat.getUserService().validate(user);
|
||||
|
||||
if (user.getNickname() != null) {
|
||||
user.setNickname(user.getNickname());
|
||||
if (user.nickname() != null) {
|
||||
user.nickname(user.nickname());
|
||||
}
|
||||
|
||||
String channel = carbonChat.getConfig().getString("channel-on-join");
|
||||
@@ -35,14 +35,14 @@ public class PlayerJoinListener implements Listener {
|
||||
}
|
||||
|
||||
if (channel.equals("DEFAULT")) {
|
||||
user.setSelectedChannel(carbonChat.getChannelManager().getDefaultChannel());
|
||||
user.selectedChannel(carbonChat.getChannelManager().getDefaultChannel());
|
||||
return;
|
||||
}
|
||||
|
||||
ChatChannel chatChannel = carbonChat.getChannelManager().getRegistry().get(channel);
|
||||
|
||||
if (chatChannel != null) {
|
||||
user.setSelectedChannel(chatChannel);
|
||||
user.selectedChannel(chatChannel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ public class RelationalPlaceholderHandler implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.getSender().isOnline() || !event.getTarget().isOnline()) {
|
||||
if (!event.getSender().online() || !event.getTarget().online()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player sender = event.getSender().asPlayer();
|
||||
Player target = event.getTarget().asPlayer();
|
||||
Player sender = event.getSender().player();
|
||||
Player target = event.getTarget().player();
|
||||
|
||||
event.setFormat(PlaceholderAPI.setRelationalPlaceholders(sender, target, event.getFormat()));
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ public class UserFormattingHandler implements Listener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onFormat(PreChatFormatEvent event) {
|
||||
if (!event.getUser().isOnline()) {
|
||||
if (!event.getUser().online()) {
|
||||
suppressFormatting(event);
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getUser().asPlayer();
|
||||
Player player = event.getUser().player();
|
||||
|
||||
if (!player.hasPermission("carbonchat.formatting") &&
|
||||
!player.hasPermission("carbonchat.channels." + event.getChannel().getKey() + ".formatting")) {
|
||||
|
||||
@@ -20,11 +20,11 @@ public class WhisperPingHandler implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPing(PrivateMessageEvent event) {
|
||||
if (event.getSender().getUUID().equals(event.getTarget().getUUID())) {
|
||||
if (event.getSender().uuid().equals(event.getTarget().uuid())) {
|
||||
return;
|
||||
}
|
||||
|
||||
String senderName = event.getSender().asOfflinePlayer().getName();
|
||||
String senderName = event.getSender().offlinePlayer().getName();
|
||||
|
||||
if (senderName == null || !event.getMessage().contains(senderName)) {
|
||||
return;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ContextManager {
|
||||
@NonNull
|
||||
private final Map<@NonNull String, @NonNull Function<@NonNull MessageContext, @NonNull Boolean>> handlers = new HashMap<>();
|
||||
|
||||
public boolean register(@NonNull String key, @NonNull Function<@NonNull MessageContext, @NonNull Boolean> handler) {
|
||||
public boolean register(@NonNull final String key, @NonNull final Function<@NonNull MessageContext, @NonNull Boolean> handler) {
|
||||
if (this.handlers.containsKey(key)) {
|
||||
return false;
|
||||
}
|
||||
@@ -24,17 +24,17 @@ public class ContextManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean testContext(@NonNull ChatUser user, @NonNull ChatUser target, @NonNull ChatChannel channel) {
|
||||
for (Map.Entry<String, Function<MessageContext, Boolean>> handler : handlers.entrySet()) {
|
||||
String key = handler.getKey();
|
||||
public boolean testContext(@NonNull final ChatUser user, @NonNull final ChatUser target, @NonNull final ChatChannel channel) {
|
||||
for (final Map.Entry<String, Function<MessageContext, Boolean>> handler : this.handlers.entrySet()) {
|
||||
final String key = handler.getKey();
|
||||
|
||||
Object value = channel.getContext(key);
|
||||
final Object value = channel.getContext(key);
|
||||
|
||||
if (value == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MessageContext context = new SimpleMessageContext(user, target, channel, value);
|
||||
final MessageContext context = new SimpleMessageContext(user, target, channel, value);
|
||||
|
||||
return handler.getValue().apply(context);
|
||||
}
|
||||
|
||||
@@ -61,28 +61,28 @@ public class MessageManager {
|
||||
getMessageService().registerUserMessageListener("nickname", (user, byteArray) -> {
|
||||
String nickname = byteArray.readUTF();
|
||||
|
||||
user.setNickname(nickname, true);
|
||||
user.nickname(nickname, true);
|
||||
|
||||
if (user.isOnline()) {
|
||||
if (user.online()) {
|
||||
String message = carbonChat.getLanguage().getString("nickname-set");
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(user.asPlayer(),
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(user.player(),
|
||||
message, "nickname", nickname));
|
||||
}
|
||||
});
|
||||
|
||||
getMessageService().registerUserMessageListener("nickname-reset", (user, byteArray) -> {
|
||||
user.setNickname(null, true);
|
||||
user.nickname(null, true);
|
||||
|
||||
if (user.isOnline()) {
|
||||
if (user.online()) {
|
||||
String message = carbonChat.getLanguage().getString("nickname-reset");
|
||||
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(user.asPlayer(), message));
|
||||
user.sendMessage(carbonChat.getAdventureManager().processMessageWithPapi(user.player(), message));
|
||||
}
|
||||
});
|
||||
|
||||
getMessageService().registerUserMessageListener("selected-channel", (user, byteArray) -> {
|
||||
user.setSelectedChannel(carbonChat.getChannelManager().getRegistry().get(byteArray.readUTF()), true);
|
||||
user.selectedChannel(carbonChat.getChannelManager().getRegistry().get(byteArray.readUTF()), true);
|
||||
});
|
||||
|
||||
getMessageService().registerUserMessageListener("spying-whispers", (user, byteArray) -> {
|
||||
@@ -107,22 +107,22 @@ public class MessageManager {
|
||||
|
||||
getMessageService().registerUserMessageListener("ignoring-channel", (user, byteArray) -> {
|
||||
user.getChannelSettings(carbonChat.getChannelManager().getRegistry().get(byteArray.readUTF()))
|
||||
.setIgnoring(byteArray.readBoolean(), true);
|
||||
.ignoring(byteArray.readBoolean(), true);
|
||||
});
|
||||
|
||||
getMessageService().registerUserMessageListener("spying-channel", (user, byteArray) -> {
|
||||
user.getChannelSettings(carbonChat.getChannelManager().getRegistry().get(byteArray.readUTF()))
|
||||
.setSpying(byteArray.readBoolean(), true);
|
||||
.spying(byteArray.readBoolean(), true);
|
||||
});
|
||||
|
||||
getMessageService().registerUserMessageListener("channel-color", (user, byteArray) -> {
|
||||
user.getChannelSettings(carbonChat.getChannelManager().getRegistry().get(byteArray.readUTF()))
|
||||
.setColor(TextColor.fromHexString(byteArray.readUTF()), true);
|
||||
.color(TextColor.fromHexString(byteArray.readUTF()), true);
|
||||
});
|
||||
|
||||
getMessageService().registerUserMessageListener("channel-color-reset", (user, byteArray) -> {
|
||||
user.getChannelSettings(carbonChat.getChannelManager().getRegistry().get(byteArray.readUTF()))
|
||||
.setColor(null, true);
|
||||
.color(null, true);
|
||||
});
|
||||
|
||||
getMessageService().registerUUIDMessageListener("channel-component", (uuid, byteArray) -> {
|
||||
|
||||
@@ -11,12 +11,12 @@ import java.util.function.Consumer;
|
||||
|
||||
public interface MessageService {
|
||||
|
||||
void registerUserMessageListener(@NonNull String key, @NonNull BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput> listener);
|
||||
void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput> listener);
|
||||
|
||||
void registerUUIDMessageListener(@NonNull String key, @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener);
|
||||
void registerUUIDMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener);
|
||||
|
||||
void unregisterMessageListener(@NonNull String key);
|
||||
void unregisterMessageListener(@NonNull final String key);
|
||||
|
||||
void sendMessage(@NonNull String key, @NonNull UUID uuid, @NonNull Consumer<@NonNull ByteArrayDataOutput> consumer);
|
||||
void sendMessage(@NonNull final String key, @NonNull final UUID uuid, @NonNull final Consumer<@NonNull ByteArrayDataOutput> consumer);
|
||||
|
||||
}
|
||||
@@ -12,33 +12,33 @@ import java.util.UUID;
|
||||
public interface ChatUser extends Audience {
|
||||
|
||||
@Nullable
|
||||
Player asPlayer();
|
||||
Player player();
|
||||
|
||||
@NonNull
|
||||
OfflinePlayer asOfflinePlayer();
|
||||
OfflinePlayer offlinePlayer();
|
||||
|
||||
@NonNull
|
||||
UUID getUUID();
|
||||
UUID uuid();
|
||||
|
||||
boolean isOnline();
|
||||
boolean online();
|
||||
|
||||
@Nullable
|
||||
String getNickname();
|
||||
String nickname();
|
||||
|
||||
default void setNickname(@NonNull String nickname) {
|
||||
this.setNickname(nickname, false);
|
||||
default void nickname(@NonNull String nickname) {
|
||||
this.nickname(nickname, false);
|
||||
}
|
||||
|
||||
void setNickname(@Nullable String nickname, boolean fromRemote);
|
||||
void nickname(@Nullable String nickname, boolean fromRemote);
|
||||
|
||||
@Nullable
|
||||
ChatChannel getSelectedChannel();
|
||||
ChatChannel selectedChannel();
|
||||
|
||||
default void setSelectedChannel(@NonNull ChatChannel channel) {
|
||||
this.setSelectedChannel(channel, false);
|
||||
default void selectedChannel(@NonNull ChatChannel channel) {
|
||||
this.selectedChannel(channel, false);
|
||||
}
|
||||
|
||||
void setSelectedChannel(@NonNull ChatChannel channel, boolean fromRemote);
|
||||
void selectedChannel(@NonNull ChatChannel channel, boolean fromRemote);
|
||||
|
||||
void clearSelectedChannel();
|
||||
|
||||
@@ -77,13 +77,13 @@ public interface ChatUser extends Audience {
|
||||
}
|
||||
|
||||
default void setReplyTarget(@Nullable ChatUser user) {
|
||||
this.setReplyTarget(user.getUUID(), false);
|
||||
this.setReplyTarget(user.uuid(), false);
|
||||
}
|
||||
|
||||
void setReplyTarget(@Nullable UUID target, boolean fromRemote);
|
||||
|
||||
default void setReplyTarget(@Nullable ChatUser user, boolean fromRemote) {
|
||||
this.setReplyTarget(user.getUUID(), fromRemote);
|
||||
this.setReplyTarget(user.uuid(), fromRemote);
|
||||
}
|
||||
|
||||
boolean isIgnoringUser(@NonNull UUID uuid);
|
||||
@@ -95,15 +95,15 @@ public interface ChatUser extends Audience {
|
||||
}
|
||||
|
||||
default boolean isIgnoringUser(@NonNull ChatUser user) {
|
||||
return this.isIgnoringUser(user.getUUID());
|
||||
return this.isIgnoringUser(user.uuid());
|
||||
}
|
||||
|
||||
default void setIgnoringUser(@NonNull ChatUser user, boolean ignoring, boolean fromRemote) {
|
||||
this.setIgnoringUser(user.getUUID(), ignoring, fromRemote);
|
||||
this.setIgnoringUser(user.uuid(), ignoring, fromRemote);
|
||||
}
|
||||
|
||||
default void setIgnoringUser(@NonNull ChatUser user, boolean ignoring) {
|
||||
this.setIgnoringUser(user.getUUID(), ignoring, false);
|
||||
this.setIgnoringUser(user.uuid(), ignoring, false);
|
||||
}
|
||||
|
||||
void sendMessage(@NonNull ChatUser sender, @NonNull String message);
|
||||
|
||||
@@ -14,27 +14,22 @@ public class CommandSettings {
|
||||
@NonNull
|
||||
private final List<@NonNull String> aliases;
|
||||
|
||||
public CommandSettings(boolean enabled, @NonNull String name, @NonNull List<@NonNull String> aliases) {
|
||||
public CommandSettings(final boolean enabled, @NonNull final String name, @NonNull final List<@NonNull String> aliases) {
|
||||
this.enabled = enabled;
|
||||
this.name = name;
|
||||
this.aliases = aliases;
|
||||
}
|
||||
|
||||
public @NonNull String @NonNull [] getAliasesArray() {
|
||||
return aliases.toArray(new String[0]);
|
||||
public @NonNull String @NonNull [] aliases() {
|
||||
return this.aliases.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public List<@NonNull String> getAliases() {
|
||||
return aliases;
|
||||
public String name() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
public boolean enabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
}
|
||||
@@ -5,29 +5,29 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface UserChannelSettings {
|
||||
|
||||
boolean isSpying();
|
||||
boolean spying();
|
||||
|
||||
default void setSpying(boolean spying) {
|
||||
this.setSpying(spying, false);
|
||||
default void spying(boolean spying) {
|
||||
this.spying(spying, false);
|
||||
}
|
||||
|
||||
void setSpying(boolean spying, boolean fromRemote);
|
||||
void spying(boolean spying, boolean fromRemote);
|
||||
|
||||
boolean isIgnored();
|
||||
boolean ignored();
|
||||
|
||||
void setIgnoring(boolean ignored, boolean fromRemote);
|
||||
void ignoring(boolean ignored, boolean fromRemote);
|
||||
|
||||
default void setIgnoring(boolean ignored) {
|
||||
this.setIgnoring(ignored, false);
|
||||
default void ignoring(boolean ignored) {
|
||||
this.ignoring(ignored, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
TextColor getColor();
|
||||
TextColor color();
|
||||
|
||||
default void setColor(@Nullable TextColor color) {
|
||||
this.setColor(color, false);
|
||||
default void color(@Nullable TextColor color) {
|
||||
this.color(color, false);
|
||||
}
|
||||
|
||||
void setColor(@Nullable TextColor color, boolean fromRemote);
|
||||
void color(@Nullable TextColor color, boolean fromRemote);
|
||||
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public interface UserService {
|
||||
|
||||
@Nullable
|
||||
default ChatUser wrapIfLoaded(@NonNull OfflinePlayer player) {
|
||||
return wrapIfLoaded(player.getUniqueId());
|
||||
return this.wrapIfLoaded(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -65,56 +65,56 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Player asPlayer() {
|
||||
public Player player() {
|
||||
return Bukkit.getPlayer(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public OfflinePlayer asOfflinePlayer() {
|
||||
public OfflinePlayer offlinePlayer() {
|
||||
return Bukkit.getOfflinePlayer(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return asOfflinePlayer().isOnline();
|
||||
public boolean online() {
|
||||
return offlinePlayer().isOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public UUID getUUID() {
|
||||
public UUID uuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getNickname() {
|
||||
public String nickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNickname(@Nullable String newNickname, boolean fromRemote) {
|
||||
public void nickname(@Nullable String newNickname, boolean fromRemote) {
|
||||
this.nickname = newNickname;
|
||||
|
||||
if (isOnline()) {
|
||||
if (online()) {
|
||||
if (newNickname != null) {
|
||||
Component component = carbonChat.getAdventureManager().processMessage(nickname);
|
||||
newNickname = CarbonChat.LEGACY.serialize(component);
|
||||
}
|
||||
|
||||
this.asPlayer().setDisplayName(newNickname);
|
||||
this.player().setDisplayName(newNickname);
|
||||
|
||||
if (carbonChat.getConfig().getBoolean("nicknames-set-tab-name")) {
|
||||
this.asPlayer().setPlayerListName(newNickname);
|
||||
this.player().setPlayerListName(newNickname);
|
||||
}
|
||||
}
|
||||
|
||||
if (!fromRemote) {
|
||||
if (nickname == null) {
|
||||
carbonChat.getMessageManager().sendMessage("nickname-reset", this.getUUID(), (byteArray) -> {
|
||||
carbonChat.getMessageManager().sendMessage("nickname-reset", this.uuid(), (byteArray) -> {
|
||||
});
|
||||
} else {
|
||||
carbonChat.getMessageManager().sendMessage("nickname", this.getUUID(), (byteArray) -> {
|
||||
carbonChat.getMessageManager().sendMessage("nickname", this.uuid(), (byteArray) -> {
|
||||
byteArray.writeUTF(this.nickname);
|
||||
});
|
||||
}
|
||||
@@ -123,12 +123,12 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ChatChannel getSelectedChannel() {
|
||||
public ChatChannel selectedChannel() {
|
||||
return carbonChat.getChannelManager().getChannelOrDefault(selectedChannel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedChannel(@NonNull ChatChannel chatChannel, boolean fromRemote) {
|
||||
public void selectedChannel(@NonNull ChatChannel chatChannel, boolean fromRemote) {
|
||||
String failureMessage = chatChannel.getSwitchFailureMessage();
|
||||
|
||||
ChannelSwitchEvent event = new ChannelSwitchEvent(chatChannel, this, failureMessage);
|
||||
@@ -145,7 +145,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
this.selectedChannel = chatChannel.getKey();
|
||||
|
||||
if (!fromRemote) {
|
||||
carbonChat.getMessageManager().sendMessage("selected-channel", this.getUUID(), (byteArray) -> {
|
||||
carbonChat.getMessageManager().sendMessage("selected-channel", this.uuid(), (byteArray) -> {
|
||||
byteArray.writeUTF(chatChannel.getKey());
|
||||
});
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
|
||||
@Override
|
||||
public void clearSelectedChannel() {
|
||||
setSelectedChannel(carbonChat.getChannelManager().getDefaultChannel());
|
||||
selectedChannel(carbonChat.getChannelManager().getDefaultChannel());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,7 +170,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
}
|
||||
|
||||
if (!fromRemote) {
|
||||
carbonChat.getMessageManager().sendMessage("ignoring-user", this.getUUID(), (byteArray) -> {
|
||||
carbonChat.getMessageManager().sendMessage("ignoring-user", this.uuid(), (byteArray) -> {
|
||||
byteArray.writeLong(uuid.getMostSignificantBits());
|
||||
byteArray.writeLong(uuid.getLeastSignificantBits());
|
||||
byteArray.writeBoolean(ignoring);
|
||||
@@ -188,7 +188,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
this.muted = muted;
|
||||
|
||||
if (!fromRemote) {
|
||||
carbonChat.getMessageManager().sendMessage("muted", this.getUUID(), (byteArray) -> {
|
||||
carbonChat.getMessageManager().sendMessage("muted", this.uuid(), (byteArray) -> {
|
||||
byteArray.writeBoolean(muted);
|
||||
});
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
this.shadowMuted = shadowMuted;
|
||||
|
||||
if (!fromRemote) {
|
||||
carbonChat.getMessageManager().sendMessage("shadow-muted", this.getUUID(), (byteArray) -> {
|
||||
carbonChat.getMessageManager().sendMessage("shadow-muted", this.uuid(), (byteArray) -> {
|
||||
byteArray.writeBoolean(shadowMuted);
|
||||
});
|
||||
}
|
||||
@@ -226,7 +226,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
this.replyTarget = target;
|
||||
|
||||
if (!fromRemote) {
|
||||
carbonChat.getMessageManager().sendMessage("reply-target", this.getUUID(), (byteArray) -> {
|
||||
carbonChat.getMessageManager().sendMessage("reply-target", this.uuid(), (byteArray) -> {
|
||||
byteArray.writeLong(target.getMostSignificantBits());
|
||||
byteArray.writeLong(target.getLeastSignificantBits());
|
||||
});
|
||||
@@ -251,7 +251,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
this.spyingWhispers = spyingWhispers;
|
||||
|
||||
if (!fromRemote) {
|
||||
carbonChat.getMessageManager().sendMessage("spying-whispers", this.getUUID(), (byteArray) -> {
|
||||
carbonChat.getMessageManager().sendMessage("spying-whispers", this.uuid(), (byteArray) -> {
|
||||
byteArray.writeBoolean(spyingWhispers);
|
||||
});
|
||||
}
|
||||
@@ -271,18 +271,18 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
String toPlayerFormat = carbonChat.getLanguage().getString("message-to-other");
|
||||
String fromPlayerFormat = carbonChat.getLanguage().getString("message-from-other");
|
||||
|
||||
String senderName = sender.asOfflinePlayer().getName();
|
||||
String senderName = sender.offlinePlayer().getName();
|
||||
String senderOfflineName = senderName;
|
||||
|
||||
String targetName = this.asOfflinePlayer().getName();
|
||||
String targetName = this.offlinePlayer().getName();
|
||||
String targetOfflineName = targetName;
|
||||
|
||||
if (sender.isOnline()) {
|
||||
senderName = sender.asPlayer().getDisplayName();
|
||||
if (sender.online()) {
|
||||
senderName = sender.player().getDisplayName();
|
||||
}
|
||||
|
||||
if (this.isOnline()) {
|
||||
targetName = this.asPlayer().getDisplayName();
|
||||
if (this.online()) {
|
||||
targetName = this.player().getDisplayName();
|
||||
}
|
||||
|
||||
Component toPlayerComponent = carbonChat.getAdventureManager().processMessage(toPlayerFormat, "br", "\n",
|
||||
@@ -303,8 +303,8 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isOnline()) {
|
||||
if (sender.isOnline()) {
|
||||
if (this.online()) {
|
||||
if (sender.online()) {
|
||||
sender.sendMessage(toPlayerComponent);
|
||||
|
||||
if (sender.isShadowMuted()) {
|
||||
@@ -325,7 +325,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
this.playSound(Sound.of(key, source, volume, pitch));
|
||||
}
|
||||
}
|
||||
} else if (sender.isOnline()) {
|
||||
} else if (sender.online()) {
|
||||
final String targetNameFinal = targetName;
|
||||
final String senderNameFinal = senderName;
|
||||
|
||||
@@ -344,7 +344,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
}
|
||||
|
||||
BungeeChannelApi.of(carbonChat).getPlayerList("ALL").thenAccept(list -> {
|
||||
if (!list.contains(this.asOfflinePlayer().getName())) {
|
||||
if (!list.contains(this.offlinePlayer().getName())) {
|
||||
String playerOfflineFormat = carbonChat.getLanguage().getString("other-player-offline");
|
||||
|
||||
Component playerOfflineComponent = carbonChat.getAdventureManager().processMessage(playerOfflineFormat,
|
||||
@@ -360,9 +360,9 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
|
||||
sender.sendMessage(toPlayerComponent);
|
||||
|
||||
carbonChat.getMessageManager().sendMessage("whisper-component", sender.getUUID(), (byteArray) -> {
|
||||
byteArray.writeLong(this.getUUID().getMostSignificantBits());
|
||||
byteArray.writeLong(this.getUUID().getLeastSignificantBits());
|
||||
carbonChat.getMessageManager().sendMessage("whisper-component", sender.uuid(), (byteArray) -> {
|
||||
byteArray.writeLong(this.uuid().getMostSignificantBits());
|
||||
byteArray.writeLong(this.uuid().getLeastSignificantBits());
|
||||
byteArray.writeUTF(carbonChat.getAdventureManager().getAudiences().gsonSerializer().serialize(fromPlayerComponent));
|
||||
});
|
||||
});
|
||||
@@ -375,7 +375,7 @@ public class CarbonChatUser implements ChatUser, ForwardingAudience {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (user.getUUID().equals(sender.getUUID()) || user.getUUID().equals(getUUID())) {
|
||||
if (user.uuid().equals(sender.uuid()) || user.uuid().equals(uuid())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,12 +97,12 @@ public class JSONUserService implements UserService {
|
||||
|
||||
@Override
|
||||
public void invalidate(@NonNull ChatUser user) {
|
||||
userCache.invalidate(user.getUUID());
|
||||
userCache.invalidate(user.uuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(@NonNull ChatUser user) {
|
||||
userCache.put(user.getUUID(), (CarbonChatUser) user);
|
||||
userCache.put(user.uuid(), (CarbonChatUser) user);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -131,12 +131,12 @@ public class MySQLUserService implements UserService {
|
||||
|
||||
@Override
|
||||
public void invalidate(@NonNull ChatUser user) {
|
||||
userCache.invalidate(user.getUUID());
|
||||
userCache.invalidate(user.uuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(@NonNull ChatUser user) {
|
||||
userCache.put(user.getUUID(), (CarbonChatUser) user);
|
||||
userCache.put(user.uuid(), (CarbonChatUser) user);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -158,13 +158,13 @@ public class MySQLUserService implements UserService {
|
||||
ChatChannel channel = carbonChat.getChannelManager().getChannelOrDefault(users.getString("channel"));
|
||||
|
||||
if (channel != null) {
|
||||
user.setSelectedChannel(channel, true);
|
||||
user.selectedChannel(channel, true);
|
||||
}
|
||||
|
||||
String nickname = users.getString("nickname");
|
||||
|
||||
if (nickname != null) {
|
||||
user.setNickname(nickname, true);
|
||||
user.nickname(nickname, true);
|
||||
}
|
||||
|
||||
user.setMuted(users.<Boolean>get("muted"), true);
|
||||
@@ -177,13 +177,13 @@ public class MySQLUserService implements UserService {
|
||||
if (chatChannel != null) {
|
||||
UserChannelSettings settings = user.getChannelSettings(chatChannel);
|
||||
|
||||
settings.setSpying(channelSetting.<Boolean>get("spying"), true);
|
||||
settings.setIgnoring(channelSetting.<Boolean>get("ignored"), true);
|
||||
settings.spying(channelSetting.<Boolean>get("spying"), true);
|
||||
settings.ignoring(channelSetting.<Boolean>get("ignored"), true);
|
||||
|
||||
String color = channelSetting.getString("color");
|
||||
|
||||
if (color != null) {
|
||||
settings.setColor(TextColor.fromHexString(color), true);
|
||||
settings.color(TextColor.fromHexString(color), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -205,15 +205,15 @@ public class MySQLUserService implements UserService {
|
||||
// Save user general data
|
||||
String selectedName = null;
|
||||
|
||||
if (user.getSelectedChannel() != null) {
|
||||
selectedName = user.getSelectedChannel().getKey();
|
||||
if (user.selectedChannel() != null) {
|
||||
selectedName = user.selectedChannel().getKey();
|
||||
}
|
||||
|
||||
carbonChat.getLogger().info("Saving user data!");
|
||||
stm.executeUpdateQuery("INSERT INTO sc_users (uuid, channel, muted, shadowmuted, spyingwhispers, nickname) VALUES (?, ?, ?, ?, ?, ?) " +
|
||||
"ON DUPLICATE KEY UPDATE channel = ?, muted = ?, shadowmuted = ?, spyingwhispers = ?, nickname =?",
|
||||
user.getUUID().toString(), selectedName, user.isMuted(), user.isShadowMuted(), user.isSpyingWhispers(), user.getNickname(),
|
||||
selectedName, user.isMuted(), user.isShadowMuted(), user.isSpyingWhispers(), user.getNickname());
|
||||
user.uuid().toString(), selectedName, user.isMuted(), user.isShadowMuted(), user.isSpyingWhispers(), user.nickname(),
|
||||
selectedName, user.isMuted(), user.isShadowMuted(), user.isSpyingWhispers(), user.nickname());
|
||||
|
||||
carbonChat.getLogger().info("Saving user channel settings!");
|
||||
// Save user channel settings
|
||||
@@ -222,24 +222,24 @@ public class MySQLUserService implements UserService {
|
||||
|
||||
String colorString = null;
|
||||
|
||||
if (value.getColor() != null) {
|
||||
colorString = value.getColor().asHexString();
|
||||
if (value.color() != null) {
|
||||
colorString = value.color().asHexString();
|
||||
}
|
||||
|
||||
stm.executeUpdateQuery("INSERT INTO sc_channel_settings (uuid, channel, spying, ignored, color) VALUES (?, ?, ?, ?, ?) " +
|
||||
"ON DUPLICATE KEY UPDATE spying = ?, ignored = ?, color = ?",
|
||||
user.getUUID().toString(), entry.getKey(), value.isSpying(), value.isIgnored(), colorString,
|
||||
value.isSpying(), value.isIgnored(), colorString);
|
||||
user.uuid().toString(), entry.getKey(), value.spying(), value.ignored(), colorString,
|
||||
value.spying(), value.ignored(), colorString);
|
||||
}
|
||||
|
||||
carbonChat.getLogger().info("Saving user ignores!");
|
||||
// Save user ignore list (remove old entries then add new ones)
|
||||
// TODO: keep DB up to date with settings as settings are mutated
|
||||
stm.executeUpdateQuery("DELETE FROM sc_ignored_users WHERE uuid = ?", user.getUUID().toString());
|
||||
stm.executeUpdateQuery("DELETE FROM sc_ignored_users WHERE uuid = ?", user.uuid().toString());
|
||||
|
||||
for (UUID entry : user.getIgnoredUsers()) {
|
||||
stm.executeUpdateQuery("INSERT INTO sc_ignored_users (uuid, user) VALUES (?, ?)",
|
||||
user.getUUID().toString(), entry.toString());
|
||||
user.uuid().toString(), entry.toString());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -40,12 +40,12 @@ public class SimpleUserChannelSettings implements UserChannelSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSpying() {
|
||||
public boolean spying() {
|
||||
return this.spying;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpying(boolean spying, boolean fromRemote) {
|
||||
public void spying(boolean spying, boolean fromRemote) {
|
||||
this.spying = spying;
|
||||
|
||||
if (!fromRemote) {
|
||||
@@ -57,12 +57,12 @@ public class SimpleUserChannelSettings implements UserChannelSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnored() {
|
||||
public boolean ignored() {
|
||||
return ignored;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoring(boolean ignored, boolean fromRemote) {
|
||||
public void ignoring(boolean ignored, boolean fromRemote) {
|
||||
this.ignored = ignored;
|
||||
|
||||
if (!fromRemote) {
|
||||
@@ -75,7 +75,7 @@ public class SimpleUserChannelSettings implements UserChannelSettings {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public TextColor getColor() {
|
||||
public TextColor color() {
|
||||
if (color == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class SimpleUserChannelSettings implements UserChannelSettings {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(@Nullable TextColor color, boolean fromRemote) {
|
||||
public void color(@Nullable TextColor color, boolean fromRemote) {
|
||||
if (color == null) {
|
||||
this.color = null;
|
||||
} else {
|
||||
|
||||
@@ -80,9 +80,9 @@ public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
|
||||
ChatUser user = carbonChat.getUserService().wrap(player);
|
||||
|
||||
return String.valueOf(user.getChannelSettings(channel).isIgnored());
|
||||
return String.valueOf(user.getChannelSettings(channel).ignored());
|
||||
} else if (key.startsWith("selected_channel")) {
|
||||
ChatChannel channel = carbonChat.getUserService().wrap(player).getSelectedChannel();
|
||||
ChatChannel channel = carbonChat.getUserService().wrap(player).selectedChannel();
|
||||
|
||||
return channel == null ? carbonChat.getChannelManager().getDefaultChannel().getName() : channel.getName();
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ public final class CarbonUtils {
|
||||
input = "white";
|
||||
}
|
||||
|
||||
if (user != null && user.isOnline()) {
|
||||
input = PlaceholderAPI.setPlaceholders(user.asPlayer(), input);
|
||||
if (user != null && user.online()) {
|
||||
input = PlaceholderAPI.setPlaceholders(user.player(), input);
|
||||
}
|
||||
|
||||
for (NamedTextColor namedColor : NamedTextColor.values()) {
|
||||
|
||||
@@ -6,10 +6,14 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class CommandUtils {
|
||||
|
||||
public static void handleDuplicateCommands(@NonNull CommandSettings settings) {
|
||||
CommandAPI.unregister(settings.getName());
|
||||
private CommandUtils() {
|
||||
|
||||
for (String command : settings.getAliases()) {
|
||||
}
|
||||
|
||||
public static void handleDuplicateCommands(@NonNull final CommandSettings settings) {
|
||||
CommandAPI.unregister(settings.name());
|
||||
|
||||
for (final String command : settings.aliases()) {
|
||||
CommandAPI.unregister(command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,15 @@ public final class FunctionalityConstants {
|
||||
|
||||
public static final boolean HAS_HOVER_EVENT_METHOD = noThrow(() -> ItemFactory.class.getMethod("hoverContentOf", ItemStack.class));
|
||||
|
||||
private static boolean noThrow(@NonNull ThrowingRunnable runnable) {
|
||||
private FunctionalityConstants() {
|
||||
|
||||
}
|
||||
|
||||
private static boolean noThrow(@NonNull final ThrowingRunnable runnable) {
|
||||
try {
|
||||
runnable.run();
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
} catch (final Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user