Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2da00a1

Browse files
authored
fix(events): a bunch of small fixes (#110)
* fix(HostAddMenu): filter players by correct permission Makes it so the player list in the menu is filtered by those who can host map parties (`community.event` as per MapPartyFeature) instead of `community.staff`. Signed-off-by: TTtie <[email protected]> * fix(events): require event type for `/event create`, fix NPE on null event type Creating an event using `/event create` without a type passed in throws a NPE in MapPartyFeature#create due to null event type. This commit fixes both the NPE and makes the event type required to ensure consistency between the event GUI and event commands. Signed-off-by: TTtie <[email protected]> * fix(events): require preset name for `/event preset` Makes the preset name in /event preset a required parameter as it doesn't make sense to create against a null preset. Signed-off-by: TTtie <[email protected]> * fix(events): allow removing online event hosts This commit fixes an issue where event hosts that were online couldn't be removed from the event host list due to them being resolved to a UUID. This fix is suboptimal, but given that this doesn't happen often, it is probably sufficient. Signed-off-by: TTtie <[email protected]> --------- Signed-off-by: TTtie <[email protected]>
1 parent d308674 commit 2da00a1

4 files changed

Lines changed: 6 additions & 4 deletions

File tree

core/src/main/java/dev/pgm/community/party/MapPartyCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void menu(CommandAudience viewer, Player sender) {
4747
}
4848
}
4949

50-
@Command("create [type]")
50+
@Command("create <type>")
5151
@Permission(CommunityPermissions.PARTY)
5252
public void create(
5353
CommandAudience viewer,
@@ -61,7 +61,7 @@ public void create(
6161
}
6262
}
6363

64-
@Command("preset [name]")
64+
@Command("preset <name>")
6565
@Permission(CommunityPermissions.PARTY)
6666
public void createPreset(
6767
CommandAudience viewer,

core/src/main/java/dev/pgm/community/party/feature/MapPartyFeature.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ public boolean create(CommandAudience viewer, Player sender, MapPartyType type,
184184
case REGULAR:
185185
this.party = new RegularPoolParty(sender, getEventConfig());
186186
break;
187+
case null:
187188
default:
188189
return false;
189190
// Catch unknown party type

core/src/main/java/dev/pgm/community/party/hosts/MapPartyHosts.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public void addSubHost(Player player) {
6767

6868
public boolean removeSubHost(String name) {
6969
Entry<UUID, String> cachedEntry = nameCache.entrySet().stream()
70-
.filter(e -> e.getValue().equalsIgnoreCase(name))
70+
.filter(e ->
71+
e.getKey().toString().equalsIgnoreCase(name) || e.getValue().equalsIgnoreCase(name))
7172
.findAny()
7273
.orElse(null);
7374

core/src/main/java/dev/pgm/community/party/menu/hosts/HostAddMenu.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void init(Player player, InventoryContents contents) {
4646

4747
@Override
4848
public Predicate<Player> relevantPlayerFilter() {
49-
return player -> player.hasPermission(CommunityPermissions.STAFF);
49+
return player -> player.hasPermission(CommunityPermissions.PARTY);
5050
}
5151

5252
@Override

0 commit comments

Comments
 (0)