mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
Improve the channel permissions API (#523)
* Improve the channel permissions API * Don't check join permission when leaving a channel * Adjust suggestions
This commit is contained in:
1 parent
a1c37ad84a
commit
2faaa2dcda
17 files changed
+239
-217
No files matched your search
+4
-22
@@ -28,11 +28,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.draycia.carbon.api.channels.ChannelPermissionResult;
|
||||
import net.draycia.carbon.api.channels.ChannelPermissions;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
import net.draycia.carbon.common.channels.messages.ConfigChannelMessageSource;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -50,7 +49,6 @@ public class AllianceChannel extends AbstractFactionsChannel {
|
||||
|
||||
public static final String FILE_NAME = "factionsuuid-alliancechat.conf";
|
||||
|
||||
private transient @MonotonicNonNull @Inject CarbonMessages messages;
|
||||
private transient @MonotonicNonNull @Inject UserManager<?> users;
|
||||
|
||||
public AllianceChannel() {
|
||||
@@ -65,27 +63,11 @@ public class AllianceChannel extends AbstractFactionsChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult joinPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
public ChannelPermissions permissions() {
|
||||
return ChannelPermissions.uniformDynamic(player -> channelPermissionResult(
|
||||
this.hasRelations(player, Relation.ALLY),
|
||||
() -> this.messages.cannotUseFactionAllianceChannel(player)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult speechPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
this.hasRelations(player, Relation.ALLY),
|
||||
() -> this.messages.cannotUseFactionAllianceChannel(player)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult hearingPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
this.hasRelations(player, Relation.ALLY),
|
||||
() -> this.messages.cannotUseFactionAllianceChannel(player)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,11 +25,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.draycia.carbon.api.channels.ChannelPermissionResult;
|
||||
import net.draycia.carbon.api.channels.ChannelPermissions;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
import net.draycia.carbon.common.channels.messages.ConfigChannelMessageSource;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -47,7 +46,6 @@ public class FactionChannel extends AbstractFactionsChannel {
|
||||
|
||||
public static final String FILE_NAME = "factionsuuid-factionchat.conf";
|
||||
|
||||
private transient @MonotonicNonNull @Inject CarbonMessages messages;
|
||||
private transient @MonotonicNonNull @Inject UserManager<?> users;
|
||||
|
||||
public FactionChannel() {
|
||||
@@ -62,27 +60,11 @@ public class FactionChannel extends AbstractFactionsChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult joinPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
public ChannelPermissions permissions() {
|
||||
return ChannelPermissions.uniformDynamic(player -> channelPermissionResult(
|
||||
this.faction(player) != null,
|
||||
() -> this.messages.cannotUseFactionChannel(player)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult speechPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
this.faction(player) != null,
|
||||
() -> this.messages.cannotUseFactionChannel(player)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult hearingPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
this.faction(player) != null,
|
||||
() -> this.messages.cannotUseFactionChannel(player)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.draycia.carbon.api.channels.ChannelPermissionResult;
|
||||
import net.draycia.carbon.api.channels.ChannelPermissions;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
import net.draycia.carbon.common.channels.messages.ConfigChannelMessageSource;
|
||||
@@ -65,27 +65,11 @@ public class TruceChannel extends AbstractFactionsChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult joinPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
public ChannelPermissions permissions() {
|
||||
return ChannelPermissions.uniformDynamic(player -> channelPermissionResult(
|
||||
this.hasRelations(player, Relation.TRUCE),
|
||||
() -> this.messages.cannotUseTruceChannel(player)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult speechPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
this.hasRelations(player, Relation.TRUCE),
|
||||
() -> this.messages.cannotUseTruceChannel(player)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult hearingPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
this.hasRelations(player, Relation.TRUCE),
|
||||
() -> this.messages.cannotUseTruceChannel(player)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-20
@@ -26,7 +26,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.draycia.carbon.api.channels.ChannelPermissionResult;
|
||||
import net.draycia.carbon.api.channels.ChannelPermissions;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
import net.draycia.carbon.common.channels.ConfigChatChannel;
|
||||
@@ -65,27 +65,11 @@ public class McmmoPartyChannel extends ConfigChatChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult joinPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
public ChannelPermissions permissions() {
|
||||
return ChannelPermissions.uniformDynamic(player -> channelPermissionResult(
|
||||
this.party(player) != null,
|
||||
() -> this.messages.cannotUseMcmmoPartyChannel(player)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult speechPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
this.party(player) != null,
|
||||
() -> this.messages.cannotUseMcmmoPartyChannel(player)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult hearingPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
this.party(player) != null,
|
||||
() -> this.messages.cannotUseMcmmoPartyChannel(player)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-20
@@ -25,7 +25,7 @@ import com.palmergames.bukkit.towny.object.ResidentList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.draycia.carbon.api.channels.ChannelPermissionResult;
|
||||
import net.draycia.carbon.api.channels.ChannelPermissions;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.users.UserManager;
|
||||
import net.draycia.carbon.common.channels.ConfigChatChannel;
|
||||
@@ -53,27 +53,11 @@ abstract class ResidentListChannel<T extends ResidentList> extends ConfigChatCha
|
||||
protected abstract @Nullable T residentList(CarbonPlayer player);
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult joinPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
public ChannelPermissions permissions() {
|
||||
return ChannelPermissions.uniformDynamic(player -> channelPermissionResult(
|
||||
this.residentList(player) != null,
|
||||
() -> this.cannotUseChannel(player)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult speechPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
this.residentList(player) != null,
|
||||
() -> this.cannotUseChannel(player)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelPermissionResult hearingPermitted(final CarbonPlayer player) {
|
||||
return channelPermissionResult(
|
||||
this.residentList(player) != null,
|
||||
() -> this.cannotUseChannel(player)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user