Adds a pronouns data entry
This commit is contained in:
parent
80d7b7f56c
commit
31dc02b425
7 changed files with 107 additions and 0 deletions
|
@ -6,12 +6,14 @@ import java.util.Map;
|
|||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import dev.zontreck.ase.homes.Home;
|
||||
import dev.zontreck.ase.profile.PlayerProfile;
|
||||
|
||||
/**
|
||||
* PLAYER SAVED DATA
|
||||
*/
|
||||
public class SavedData {
|
||||
public Map<String, Home> homes;
|
||||
public PlayerProfile profile;
|
||||
|
||||
public SavedData() {
|
||||
homes = new HashMap<>();
|
||||
|
@ -37,6 +39,8 @@ public class SavedData {
|
|||
}
|
||||
player.set("homes", homes);
|
||||
|
||||
player.set("profile", profile.serialize(player));
|
||||
|
||||
// Apply to main configuration
|
||||
AriasServerEssentials.getSelf().getConfig().getConfigurationSection("playerData").set(playerID, player);
|
||||
AriasServerEssentials.getSelf().SaveConfiguration();
|
||||
|
@ -54,6 +58,8 @@ public class SavedData {
|
|||
sd.homes.put(h.getName(), h);
|
||||
}
|
||||
|
||||
sd.profile = PlayerProfile.deserialize(section.getConfigurationSection("profile"));
|
||||
|
||||
return sd;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import dev.zontreck.ase.commands.homes.SetHomeCommand;
|
|||
import dev.zontreck.ase.commands.misc.BroadcastCommand;
|
||||
import dev.zontreck.ase.commands.misc.CloseInvCommand;
|
||||
import dev.zontreck.ase.commands.misc.CreditsCommand;
|
||||
import dev.zontreck.ase.commands.misc.PronounsCommand;
|
||||
import dev.zontreck.ase.commands.misc.ShareItemCommand;
|
||||
import dev.zontreck.ase.commands.tpa.TPACancelCommand;
|
||||
import dev.zontreck.ase.commands.tpa.TPACommand;
|
||||
|
@ -22,6 +23,7 @@ import dev.zontreck.ase.commands.warps.SetWarpCommand;
|
|||
import dev.zontreck.ase.commands.warps.WarpCommand;
|
||||
import dev.zontreck.ase.commands.warps.WarpsCommand;
|
||||
import dev.zontreck.ase.commands.warps.EditWarpCommand.EditTypes;
|
||||
import dev.zontreck.ase.profile.PlayerPronouns;
|
||||
import io.papermc.paper.command.brigadier.Commands;
|
||||
import io.papermc.paper.command.brigadier.argument.ArgumentTypes;
|
||||
import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver;
|
||||
|
@ -188,5 +190,17 @@ public class CommandRegistry {
|
|||
|
||||
cmds.register(Commands.literal("closeinv").executes(ctx -> CloseInvCommand.execute(ctx.getSource()))
|
||||
.build());
|
||||
|
||||
cmds.register(Commands.literal("pronouns")
|
||||
.requires(x -> x.getSender().isPermissionSet(PronounsCommand.PERMISSION))
|
||||
.then(Commands.literal("sheher").executes(
|
||||
ctx -> PronounsCommand.execute(ctx.getSource(), PlayerPronouns.SheHer)))
|
||||
.then(Commands.literal("hehim").executes(
|
||||
ctx -> PronounsCommand.execute(ctx.getSource(), PlayerPronouns.HeHim)))
|
||||
.then(Commands.literal("theythem")
|
||||
.executes(ctx -> PronounsCommand.execute(ctx.getSource(),
|
||||
PlayerPronouns.TheyThem)))
|
||||
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package dev.zontreck.ase.commands.misc;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
|
||||
import dev.zontreck.ase.AriasServerEssentials;
|
||||
import dev.zontreck.ase.SavedData;
|
||||
import dev.zontreck.ase.profile.PlayerPronouns;
|
||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class PronounsCommand {
|
||||
public static final String PERMISSION = "ase.commands.pronouns";
|
||||
|
||||
public static int execute(CommandSourceStack ctx, PlayerPronouns pronouns) {
|
||||
Player player = (Player) ctx.getSender();
|
||||
SavedData data = AriasServerEssentials.getPlayerData(player.getUniqueId().toString());
|
||||
|
||||
data.profile.pronouns = pronouns;
|
||||
data.save(player.getUniqueId().toString());
|
||||
|
||||
player.sendMessage(Component.text(
|
||||
"Your pronouns have been updated to '" + ChatColor.DARK_PURPLE + pronouns.name() + ChatColor.DARK_GREEN
|
||||
+ "'",
|
||||
NamedTextColor.DARK_GREEN));
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
}
|
||||
}
|
34
src/main/java/dev/zontreck/ase/profile/PlayerProfile.java
Normal file
34
src/main/java/dev/zontreck/ase/profile/PlayerProfile.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package dev.zontreck.ase.profile;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class PlayerProfile {
|
||||
public PlayerPronouns pronouns;
|
||||
public String nickname;
|
||||
|
||||
public ConfigurationSection serialize(ConfigurationSection parent) {
|
||||
ConfigurationSection profile = parent.createSection("profile");
|
||||
profile.set("nickname", nickname);
|
||||
profile.set("pronouns", pronouns.name());
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
public static PlayerProfile deserialize(ConfigurationSection section) {
|
||||
String nick = "";
|
||||
PlayerPronouns pronouns = PlayerPronouns.TheyThem;
|
||||
if (section.contains("nickname")) {
|
||||
nick = section.getString("nickname");
|
||||
}
|
||||
|
||||
if (section.contains("pronouns")) {
|
||||
pronouns = PlayerPronouns.valueOf(section.getString("pronouns"));
|
||||
}
|
||||
|
||||
PlayerProfile profile = new PlayerProfile();
|
||||
profile.nickname = nick;
|
||||
profile.pronouns = pronouns;
|
||||
|
||||
return profile;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package dev.zontreck.ase.profile;
|
||||
|
||||
public enum PlayerPronouns {
|
||||
SheHer,
|
||||
HeHim,
|
||||
TheyThem
|
||||
}
|
|
@ -63,6 +63,9 @@ commands:
|
|||
closeinv:
|
||||
description: Close inventory (Helper function)
|
||||
usage: "- /closeinv -"
|
||||
pronouns:
|
||||
description: Update your pronouns!
|
||||
usage: "- /pronouns [sheher,hehim,theythem] -"
|
||||
permissions:
|
||||
ase.commands.*:
|
||||
description: Allow all commands
|
||||
|
@ -84,6 +87,7 @@ permissions:
|
|||
ase.commands.warp: true
|
||||
ase.commands.warps: true
|
||||
ase.commands.editwarp: true
|
||||
ase.commands.pronouns: true
|
||||
ase.commands.home:
|
||||
description: Allows usage of the /home command
|
||||
default: true
|
||||
|
@ -141,3 +145,6 @@ permissions:
|
|||
ase.commands.editwarp:
|
||||
description: Allows editing warps
|
||||
default: true
|
||||
ase.commands.pronouns:
|
||||
description: Allow usage of /pronouns
|
||||
default: true
|
||||
|
|
|
@ -63,6 +63,9 @@ commands:
|
|||
closeinv:
|
||||
description: Close inventory (Helper function)
|
||||
usage: "- /closeinv -"
|
||||
pronouns:
|
||||
description: Update your pronouns!
|
||||
usage: "- /pronouns [sheher,hehim,theythem] -"
|
||||
permissions:
|
||||
ase.commands.*:
|
||||
description: Allow all commands
|
||||
|
@ -84,6 +87,7 @@ permissions:
|
|||
ase.commands.warp: true
|
||||
ase.commands.warps: true
|
||||
ase.commands.editwarp: true
|
||||
ase.commands.pronouns: true
|
||||
ase.commands.home:
|
||||
description: Allows usage of the /home command
|
||||
default: true
|
||||
|
@ -141,3 +145,6 @@ permissions:
|
|||
ase.commands.editwarp:
|
||||
description: Allows editing warps
|
||||
default: true
|
||||
ase.commands.pronouns:
|
||||
description: Allow usage of /pronouns
|
||||
default: true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue