This commit is contained in:
Draycia committed 2021-12-09 20:50:54 -08:00
1 parent e756b865c2
commit 9a3416c57b
5 files changed
+20 -19

No files matched your search

@@ -22,7 +22,6 @@ package net.draycia.carbon.bukkit.users;
import java.util.Collection;
import java.util.Locale;
import java.util.Optional;
import net.draycia.carbon.api.channels.ChatChannel;
import net.draycia.carbon.api.util.InventorySlot;
import net.draycia.carbon.common.users.CarbonPlayerCommon;
import net.draycia.carbon.common.users.WrappedCarbonPlayer;
@@ -148,14 +147,4 @@ public final class CarbonPlayerBukkit extends WrappedCarbonPlayer implements For
.anyMatch(MetadataValue::asBoolean);
}
@Override
public @Nullable ChatChannel selectedChannel() {
return this.carbonPlayerCommon.selectedChannel();
}
@Override
public void selectedChannel(final @Nullable ChatChannel chatChannel) {
this.carbonPlayerCommon.selectedChannel(chatChannel);
}
}
@@ -252,11 +252,15 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
}
private void registerChannelCommands(final ChatChannel channel, final CommandManager<Commander> commandManager) {
final var command = commandManager.commandBuilder(channel.commandName(),
var builder = commandManager.commandBuilder(channel.commandName(),
channel.commandAliases(), commandManager.createDefaultCommandMeta())
.argument(StringArgument.<Commander>newBuilder("message").greedy().asOptional().build())
.permission("carbon.channel." + channel.key().value())
.senderType(PlayerCommander.class)
.argument(StringArgument.<Commander>newBuilder("message").greedy().asOptional().build());
if (channel instanceof ConfigChatChannel chatChannel) {
builder = builder.permission(chatChannel.permission());
}
final var command = builder.senderType(PlayerCommander.class)
.handler(handler -> {
final var sender = ((PlayerCommander) handler.getSender()).carbonPlayer();
@@ -137,7 +137,7 @@ public final class ConfigChatChannel implements ChatChannel {
@Override
public ChannelPermissionResult speechPermitted(final CarbonPlayer carbonPlayer) {
return ChannelPermissionResult.allowedIf(text("Insufficient permissions!"), () ->
carbonPlayer.hasPermission(this.permission + ".speak")); // carbon.channels.local.speak
carbonPlayer.hasPermission(this.permission() + ".speak")); // carbon.channels.local.speak
}
@Override
@@ -148,7 +148,7 @@ public final class ConfigChatChannel implements ChatChannel {
return ChannelPermissionResult.allowed();
}
if (permission.get().test(this.permission + ".see")) {
if (permission.get().test(this.permission())) {
return ChannelPermissionResult.allowed();
}
@@ -219,4 +219,12 @@ public final class ConfigChatChannel implements ChatChannel {
return requireNonNull(this.messageService, "Channel message service must not be null!");
}
public String permission() {
if (this.permission == null) {
return "carbon.channel.basic";
}
return this.permission;
}
}
@@ -86,7 +86,7 @@ public final class CarbonServerSponge implements CarbonServer, ForwardingAudienc
return this.userManager.carbonPlayer(uuid).thenCompose(result -> {
return CompletableFuture.supplyAsync(() -> {
if (result.player() != null) {
new ComponentPlayerResult<>(new CarbonPlayerSponge(result.player()), Component.empty());
return new ComponentPlayerResult<>(new CarbonPlayerSponge(result.player()), Component.empty());
}
final @Nullable String name = this.resolveName(uuid).join();
@@ -96,7 +96,7 @@ public final class CarbonServerVelocity implements CarbonServer, ForwardingAudie
return this.userManager.carbonPlayer(uuid).thenCompose(result -> {
return CompletableFuture.supplyAsync(() -> {
if (result.player() != null) {
new ComponentPlayerResult<>(new CarbonPlayerVelocity(this.server, result.player()), Component.empty());
return new ComponentPlayerResult<>(new CarbonPlayerVelocity(this.server, result.player()), Component.empty());
}
final @Nullable String name = this.resolveName(uuid).join();