This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace 'RankColors' with 'RankUtil' and update references (#6)
* Add new gamemode commands and update plugin descriptions This commit introduces new gamemode commands including 'gm', 'gmc', 'gms', 'gma', and 'gmsp' related to creative, survival, adventure, and spectator modes respectively. Command descriptions were added in plugin.yml file. Moreover, validations for player name were added using PlayerValidator class. Minor changes include addition of a description in pom.xml and command registerations in Loader class. * Replace 'RankColors' with 'RankUtil' and update references Developed the 'RankUtil' class by replacing 'RankColors' for more functional role. The old 'RankColors' class was deleted and references to it in chat and tablist subsystems were updated. These changes better support rank management's extended tasks and also retain the color assigning feature of the older class.
- Loading branch information
1 parent
e97b650
commit ecde408
Showing
5 changed files
with
103 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/net/cherrycraft/cherrycore/chatsystem/utils/PlayerRankUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.cherrycraft.cherrycore.chatsystem.utils; | ||
|
||
import net.luckperms.api.LuckPermsProvider; | ||
|
||
public class PlayerRankUtils { | ||
|
||
public static String getPlayerRank(String playerName) { | ||
Boolean player = PlayerValidator.isPlayerNameValid(playerName) ? PlayerValidator.isPlayerNameValid(playerName) : null; | ||
assert player != null; | ||
if (!player) { | ||
LuckPermsProvider.get().getUserManager().getUser(playerName).getPrimaryGroup(); | ||
return "success"; | ||
} | ||
return "error"; | ||
} | ||
|
||
public static String setPlayerRank(String playerName, String rank) { | ||
Boolean player = PlayerValidator.isPlayerNameValid(playerName) ? PlayerValidator.isPlayerNameValid(playerName) : null; | ||
assert player != null; | ||
if (!player) { | ||
if (LuckPermsProvider.get().getGroupManager().getGroup(rank) != null) { | ||
return "error"; | ||
} | ||
LuckPermsProvider.get().getUserManager().getUser(playerName).setPrimaryGroup(rank); | ||
return "success"; | ||
} | ||
return "error"; | ||
} | ||
|
||
|
||
} |
41 changes: 0 additions & 41 deletions
41
src/main/java/net/cherrycraft/cherrycore/chatsystem/utils/RankColors.java
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
src/main/java/net/cherrycraft/cherrycore/chatsystem/utils/RankUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package net.cherrycraft.cherrycore.chatsystem.utils; | ||
|
||
import net.luckperms.api.LuckPermsProvider; | ||
import net.luckperms.api.model.group.Group; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
public enum RankUtil { | ||
OWNER("<gradient:#fabf37:#fff024:0>", 1, "owner"), | ||
MANAGER("<gradient:#ff8624:#ff2479:1>", 2, "manager"), | ||
DEVELOPER("<#e3ff24>", 3, "developer"), | ||
GAME_MASTER("<#e3ff24>", 4, "game-master"), | ||
ADMIN("<#c624ff>", 5, "admin"), | ||
MODERATOR("<#24a8ff>", 6, "moderator"), | ||
TRAINEE("<#7bc9fc>", 7, "trainee"), | ||
DESIGNER("<gradient:#ee7bfc:#7bb7fc:0>", 8, "designer"), | ||
BUILDER("<#10c4b7>", 9, "builder"), | ||
YOUTUBE("<#ea4444>", 10, "youtube"), | ||
CHERRY_PLATINUM_LIFETIME("<gradient:#a0b2c6:#abcdf3:0>", 11, "cherry-platinum-lifetime"), | ||
CHERRY_PLATINUM("<#a0b2c6>", 12, "cherry-platinum"), | ||
CHERRY_GOLD_LIFETIME("<gradient:#f3dfab:#f8c373:1>", 13, "cherry-gold-lifetime"), | ||
CHERRY_GOLD("<#f3dfab>", 14, "cherry-gold"), | ||
CHERRY_LIFETIME("<gradient:#ae0a0a:#f32424:1>", 15, "cherry-lifetime"), | ||
CHERRY("<#f32424>", 16, "cherry"), | ||
DEFAULT("<gray>", 17, "default"); | ||
|
||
private final String color; | ||
private final int priority; | ||
private final String groupName; | ||
|
||
RankUtil(String color, int priority, String groupName) { | ||
this.color = color; | ||
this.priority = priority; | ||
this.groupName = groupName; | ||
} | ||
|
||
public static int compareRanks(RankUtil rank1, RankUtil rank2) { | ||
return Integer.compare(rank1.getPriority(), rank2.getPriority()); | ||
} | ||
|
||
public @Nullable Group getLPRank() { | ||
return LuckPermsProvider.get().getGroupManager().getGroup(this.groupName); | ||
} | ||
|
||
public String getColor() { | ||
return color; | ||
} | ||
|
||
public int getPriority() { | ||
return priority; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters