Skip to content

Commit

Permalink
Lang rework 27
Browse files Browse the repository at this point in the history
Disabled Entity settings once again, so it can get saved in a better way in the future

Regions does compile now too!
  • Loading branch information
FireInstall committed Feb 27, 2024
1 parent c1b9ad3 commit 3a9c292
Show file tree
Hide file tree
Showing 110 changed files with 1,141 additions and 813 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ private Component makeList(Minigame minigame, int page) {

listBuilder.append(MinigameMessageManager.getMgMessage(MinigameLangKey.REGION_DESCRIBE,
Placeholder.component(MinigamePlaceHolderKey.POSITION_1.getKey(),
MinigameMessageManager.getMgMessage(MinigameLangKey.REGION_POSITION,
MinigameMessageManager.getMgMessage(MinigameLangKey.POSITION,
Placeholder.unparsed(MinigamePlaceHolderKey.COORDINATE_X.getKey(), String.valueOf(region.getMinX())),
Placeholder.unparsed(MinigamePlaceHolderKey.COORDINATE_Y.getKey(), String.valueOf(region.getMinY())),
Placeholder.unparsed(MinigamePlaceHolderKey.COORDINATE_Z.getKey(), String.valueOf(region.getMinZ())))),
Placeholder.component(MinigamePlaceHolderKey.POSITION_2.getKey(),
MinigameMessageManager.getMgMessage(MinigameLangKey.REGION_POSITION,
MinigameMessageManager.getMgMessage(MinigameLangKey.POSITION,
Placeholder.unparsed(MinigamePlaceHolderKey.COORDINATE_X.getKey(), String.valueOf(region.getMaxX())),
Placeholder.unparsed(MinigamePlaceHolderKey.COORDINATE_Y.getKey(), String.valueOf(region.getMaxY())),
Placeholder.unparsed(MinigamePlaceHolderKey.COORDINATE_Z.getKey(), String.valueOf(region.getMaxZ()))))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void loadValue(@NotNull FileConfiguration config, @NotNull String path) {
* @param description will get ignored
*/
@Override
public MenuItemEnum getMenuItem(@Nullable Material displayMat, @Nullable Component name,
public MenuItemEnum<T> getMenuItem(@Nullable Material displayMat, @Nullable Component name,
@Nullable List<@NotNull Component> description) {
return new MenuItemEnum<>(displayMat, name, new Callback<>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public boolean joinMinigame(@NotNull MinigamePlayer mgPlayer, @NotNull Minigame
mgPlayer.setCheckpoint(mgPlayer.getStoredPlayerCheckpoints().getCheckpoint(mgm.getName()));
StoredPlayerCheckpoints spc = mgPlayer.getStoredPlayerCheckpoints();
if (spc.hasFlags(mgm.getName())) {
mgPlayer.setFlags(spc.getFlags(mgm.getName()));
mgPlayer.setSinglePlayerFlags(spc.getFlags(mgm.getName()));
}
if (spc.hasTime(mgm.getName())) {
mgPlayer.setStoredTime(spc.getTime(mgm.getName()));
Expand Down Expand Up @@ -122,8 +122,8 @@ public void quitMinigame(final @NotNull MinigamePlayer player, final @NotNull Mi
if (mgm.canSaveCheckpoint()) {
StoredPlayerCheckpoints spc = player.getStoredPlayerCheckpoints();
spc.addCheckpoint(mgm.getName(), player.getCheckpoint());
if (!player.getFlags().isEmpty()) {
spc.addFlags(mgm.getName(), player.getFlags());
if (!player.getSinglePlayerFlags().isEmpty()) {
spc.addFlags(mgm.getName(), player.getSinglePlayerFlags());
}
spc.addDeaths(mgm.getName(), player.getDeaths());
spc.addReverts(mgm.getName(), player.getReverts());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import static com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits.forActor;

public class DependencyManager {
private static Plugin worldEditPlugin = null; // cached for test if still enabled
Expand Down Expand Up @@ -112,7 +111,7 @@ public static void setPos2(@NotNull Player player, @NotNull Location location2)
CuboidRegionSelector cuboidRegionSelector = new CuboidRegionSelector(oldRegionSelector);
WorldEdit.getInstance().getSessionManager().get(actor).setRegionSelector(world, cuboidRegionSelector);

cuboidRegionSelector.selectSecondary(BlockVector3.at(location2.x(), location2.y(), location2.z()), forActor(actor));
cuboidRegionSelector.selectSecondary(BlockVector3.at(location2.x(), location2.y(), location2.z()), ActorSelectorLimits.forActor(actor));
cuboidRegionSelector.learnChanges();
cuboidRegionSelector.explainRegionAdjust(actor, session);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ public boolean hasMinigamePlayer(UUID uuid) {

public List<String> checkRequiredFlags(MinigamePlayer player, String minigame) {
List<String> checkpoints = new ArrayList<>(mgManager.getMinigame(minigame).getFlags());
List<String> pchecks = player.getFlags();
List<String> pchecks = player.getSinglePlayerFlags();

if (!pchecks.isEmpty()) {
checkpoints.removeAll(pchecks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public enum MinigamePlaceHolderKey implements PlaceHolderKey {
OTHER_TEAM("other_team"),
PERMISSION("permission"),
PLAYER("player"),
POSITION_1("pos1"),
POSITION_2("pos2"),
POSITION_1("postion1"),
POSITION_2("postion2"),
PRESET("preset"),
RARITY("rarity"),
REGION("region"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public enum MgMenuLangKey implements LangKey {
MENU_TEAM_GAMEAUTOBALANCEMSG_DESCRIPTION("menu.team.gameAutobalanceMsg.description"),
MENU_TEAM_GAMEAUTOBALANCEMSG_NAME("menu.team.gameAutobalanceMsg.name"),
MENU_TEAM_MAXPLAYERS("menu.team.maxPlayers"),
MENU_TEAM_NAME("menu.team.name"),
MENU_TEAM_NAME("menu.teams.name"),
MENU_TEAM_NAMEVISIBILITY_ALWAYSVISIBLE("menu.team.nameVisibility.alwaysVisible"),
MENU_TEAM_NAMEVISIBILITY_HIDEOTHERTEAM("menu.team.nameVisibility.hideOtherTeam"),
MENU_TEAM_NAMEVISIBILITY_HIDEOWNTEAM("menu.team.nameVisibility.hideOwnTeam"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ public enum MinigameLangKey implements LangKey { //todo this gets rather big. Sl
PLAYER_TEAM_ASSIGN_JOINTEAM("player.team.assign.joinTeam"),
PLAYER_TEAM_AUTOBALANCE_MINIGAMEMSG("player.team.autobalance.minigameMsg"),
PLAYER_TEAM_AUTOBALANCE_PLYMSG("player.team.autobalance.plyMsg"),
POSITION("position"),
PRESET_INFO_NOINFO("preset.info.noInfo"),
PRESET_LOAD_ERROR_NOTFOUND("preset.load.error.notFound"),
PRESET_LOAD_SUCCESS("preset.load.success"),
QUANTIFIER_NONE("quantifier.none"),
REGION_DESCRIBE("region.describe"),
REGION_ERROR_NOREGENREION("region.error.noRegenRegion"),
REGION_ERROR_NOSELECTION("region.error.noSelection"),
REGION_POSITION("region.position"),
REGION_REGENREGION_CREATED("region.regenRegion.created"),
REGION_REGENREGION_ERROR_LIMIT("region.regenRegion.error.limit"),
REGION_REGENREGION_REMOVED("region.regenregion.removed"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class GameMechanics {

static {
addGameMechanic(new CustomMechanic());
Arrays.stream(MG_MECHANICS.values()).forEach(s -> addGameMechanic(s.getMechanic()));
Arrays.stream(MgMechanics.values()).forEach(s -> addGameMechanic(s.getMechanic()));
}

/**
Expand Down Expand Up @@ -69,7 +69,7 @@ public static Set<GameMechanicBase> getGameMechanics() {
return null;
}

public enum MG_MECHANICS {
public enum MgMechanics {
KILLS(new PlayerKillsMechanic()),
CTF(new CTFMechanic()),
INFECTION(new InfectionMechanic()),
Expand All @@ -79,7 +79,7 @@ public enum MG_MECHANICS {

private final GameMechanicBase mechanic;

MG_MECHANICS(GameMechanicBase name) {
MgMechanics(GameMechanicBase name) {
this.mechanic = name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.ArrayList;
import java.util.List;

public class MenuItemBlockData extends MenuItem {
public class MenuItemBlockData extends MenuItem { //todo needs further testing. this menu items before the changes was faulty.
private static final @NotNull String DESCRIPTION_TOKEN = "BlockData_description";
private final @NotNull Callback<BlockData> dataCallback;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,32 @@ public MenuItemBoolean(@Nullable Material displayMat, @NotNull LangKey langKey,
@NotNull Callback<@NotNull Boolean> toggle) {
super(displayMat, langKey);
this.toggle = toggle;
updateDescription();
update();
}

public MenuItemBoolean(@Nullable Material displayMat, @Nullable Component name,
@NotNull Callback<@NotNull Boolean> toggle) {
super(displayMat, name);
this.toggle = toggle;
updateDescription();
update();
}

public MenuItemBoolean(@Nullable Material displayMat, @NotNull LangKey langKey, @Nullable List<@NotNull Component> description,
@NotNull Callback<@NotNull Boolean> toggle) {
super(displayMat, langKey, description);
this.toggle = toggle;
updateDescription();
update();
}

public MenuItemBoolean(@Nullable Material displayMat, @Nullable Component name, @Nullable List<@NotNull Component> description,
@NotNull Callback<@NotNull Boolean> toggle) {
super(displayMat, name, description);
this.toggle = toggle;
updateDescription();
update();
}

public void updateDescription() {
@Override
public void update() {
LangKey boolKey = toggle.getValue() ? MinigameLangKey.BOOL_TRUE : MinigameLangKey.BOOL_FALSE;
setDescriptionPart(DESCRIPTION_TOKEN, MinigameMessageManager.getMgMessageList(boolKey));
}
Expand All @@ -56,7 +57,7 @@ public ItemStack onClick() {
toggle.setValue(true);
}

updateDescription();
update();
return getDisplayItem();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,16 @@ public Map<String, PlayerLoadout> getLoadoutMap() {
}

public @Nullable PlayerLoadout getLoadout(@NotNull String name) {
PlayerLoadout playerLoadout = null;
if (extraLoadouts.containsKey(name)) {
playerLoadout = extraLoadouts.get(name);
return extraLoadouts.get(name);
} else {
for (String loadout : extraLoadouts.keySet()) {
if (loadout.equalsIgnoreCase(name)) {
playerLoadout = extraLoadouts.get(loadout);
break;
return extraLoadouts.get(loadout);
}
}
}
return playerLoadout;
return null;
}

public boolean hasLoadouts() {
Expand All @@ -201,12 +199,13 @@ public boolean hasLoadouts() {

public boolean hasLoadout(String name) {
if (!name.equalsIgnoreCase("default")) {
if (extraLoadouts.containsKey(name))
if (extraLoadouts.containsKey(name)) {
return extraLoadouts.containsKey(name);
else {
} else {
for (String loadout : extraLoadouts.keySet()) {
if (loadout.equalsIgnoreCase(name))
if (loadout.equalsIgnoreCase(name)) {
return true;
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

public class MinigamePlayer implements ScriptObject {
private final Player player;
private final List<String> flags = new ArrayList<>();
private final List<@NotNull String> singlePlayerFlags = new ArrayList<>();
private final List<String> tempClaimedRewards = new ArrayList<>();
private final List<ItemStack> tempRewardItems = new ArrayList<>();
private final List<ItemStack> rewardItems = new ArrayList<>();
Expand Down Expand Up @@ -274,28 +274,28 @@ public boolean setLoadout(final PlayerLoadout loadout) {
return false;
}

public List<String> getFlags() {
return this.flags;
public List<String> getSinglePlayerFlags() {
return this.singlePlayerFlags;
}

public void setFlags(final List<String> flags) {
this.flags.addAll(flags);
public void setSinglePlayerFlags(final List<String> singlePlayerFlags) {
this.singlePlayerFlags.addAll(singlePlayerFlags);
}

public boolean addFlag(final String flag) {
if (!this.flags.contains(flag)) {
this.flags.add(flag);
if (!this.singlePlayerFlags.contains(flag)) {
this.singlePlayerFlags.add(flag);
return true;
}
return false;
}

public boolean hasFlag(final String flagName) {
return this.flags.contains(flagName);
return this.singlePlayerFlags.contains(flagName);
}

public void clearFlags() {
this.flags.clear();
this.singlePlayerFlags.clear();
}

public Location getCheckpoint() {
Expand Down
7 changes: 4 additions & 3 deletions Minigames/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#todo clean duplicates
and=and
bool.false=<red>false</red>
bool.true=<green>true</green>
Expand Down Expand Up @@ -332,7 +333,7 @@ command.set.start.usage=/minigame set <Minigame> start [player number]<newline>/
command.set.startTime.description=Overrides the default game start timer in the lobby after waiting for players time has expired or maximum players are reached. If time is 0 then the default time is used. (Default: 0)
command.set.startTime.reset=Start time for <minigame> has been reset.
command.set.startTime.success=Start time has been set to <time> for <minigame>
command.set.startTime.usage=/minigame set <Minigame> starttime <Time>
command.set.startTime.usage=/minigame set <Minigame> starttime <time>
command.set.storeCheckpoint.description=When enabled, if a player quits from a single player Minigame, their checkpoint will be stored, so they can join at that position later.
command.set.storeCheckpoint.success=Checkpoint saving is <state> for <minigame>
command.set.storeCheckpoint.usage=/minigame set <Minigame> storecheckpoints <true/false>
Expand Down Expand Up @@ -624,7 +625,7 @@ menu.team.defaultWin.name=Default Winning Team
menu.team.gameAutobalanceMsg.description=Message sent to all players<newline>when someone is<newline>auto-balanced.<newline>Use <team>/<player> for team/player name
menu.team.gameAutobalanceMsg.name=Autobalance Broadcast Message
menu.team.maxPlayers=Max Players
menu.team.name=Teams
menu.teams.name=Teams
menu.team.nameVisibility.alwaysVisible=Always visible
menu.team.nameVisibility.hideOtherTeam=Hide for other teams
menu.team.nameVisibility.hideOwnTeam=Hide for own team
Expand Down Expand Up @@ -826,7 +827,7 @@ quantifier.none=<gray>None</gray>
region.describe=<region> from <postion1> to <postion2> (<number>)
region.error.noRegenRegion=No region by the name '<region>' exists.
region.error.noSelection=You have not made a selection!
region.position=<x>, <y>, <z>
position=<x>, <y>, <z>
region.regenRegion.created=Created a new regen region in <minigame> called <region>, <number> / <max>
region.regenRegion.error.limit=Error: the limit of Blocks of all regen areas together has been reached +(<number> / <max>). Please contact an admin if necessary.
region.regenRegion.updated=Updated regen region in <minigame> called <region> with a new area <number> / <max>
Expand Down
4 changes: 2 additions & 2 deletions Minigames/src/main/resources/messages_en_AU.properties
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ menu.team.defaultWin.name=Default Winning Team
menu.team.gameAutobalanceMsg.description=Message sent to all players<newline>when someone is<newline>auto-balanced.<newline>Use <team>/<player> for team/player name
menu.team.gameAutobalanceMsg.name=Autobalance Broadcast Message
menu.team.maxPlayers=Max Players
menu.team.name=Teams
menu.teams.name=Teams
menu.team.nameVisibility.alwaysVisible=Always visible
menu.team.nameVisibility.hideOtherTeam=Hide for other teams
menu.team.nameVisibility.hideOwnTeam=Hide for own team
Expand Down Expand Up @@ -826,7 +826,7 @@ quantifier.none=<gray>None</gray>
region.describe=<region> from <postion1> to <postion2> (<number>)
region.error.noRegenRegion=No region by the name '<region>' exists.
region.error.noSelection=You have not made a selection!
region.position=<x>, <y>, <z>
position=<x>, <y>, <z>
region.regenRegion.created=Created a new regen region in <minigame> called <region>, <number> / <max>
region.regenRegion.error.limit=Error: the limit of Blocks of all regen areas together has been reached +(<number> / <max>). Please contact an admin if necessary.
region.regenRegion.updated=Updated regen region in <minigame> called <region> with a new area <number> / <max>
Expand Down
4 changes: 2 additions & 2 deletions Minigames/src/main/resources/messages_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ menu.team.defaultWin.name=Default Winning Team
menu.team.gameAutobalanceMsg.description=Message sent to all players<newline>when someone is<newline>auto-balanced.<newline>Use <team>/<player> for team/player name
menu.team.gameAutobalanceMsg.name=Autobalance Broadcast Message
menu.team.maxPlayers=Max Players
menu.team.name=Teams
menu.teams.name=Teams
menu.team.nameVisibility.alwaysVisible=Always visible
menu.team.nameVisibility.hideOtherTeam=Hide for other teams
menu.team.nameVisibility.hideOwnTeam=Hide for own team
Expand Down Expand Up @@ -826,7 +826,7 @@ quantifier.none=<gray>None</gray>
region.describe=<region> from <postion1> to <postion2> (<number>)
region.error.noRegenRegion=No region by the name '<region>' exists.
region.error.noSelection=You have not made a selection!
region.position=<x>, <y>, <z>
position=<x>, <y>, <z>
region.regenRegion.created=Created a new regen region in <minigame> called <region>, <number> / <max>
region.regenRegion.error.limit=Error: the limit of Blocks of all regen areas together has been reached +(<number> / <max>). Please contact an admin if necessary.
region.regenRegion.updated=Updated regen region in <minigame> called <region> with a new area <number> / <max>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void setUp() {
MockBukkit.getMock().addWorld(testworld);
plugin.toggleDebug();
WorldMock world = (WorldMock) MockBukkit.getMock().getWorld("GAMES");
game = TestHelper.createMinigame(plugin, world, MinigameType.MULTIPLAYER, GameMechanics.MG_MECHANICS.KILLS.getMechanic());
game = TestHelper.createMinigame(plugin, world, MinigameType.MULTIPLAYER, GameMechanics.MgMechanics.KILLS.getMechanic());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Setup() {
MockBukkit.getMock().addWorld(world);
plugin = MockBootstrap.createPluginWithTestContext(server);
plugin.toggleDebug();
game = TestHelper.createMinigame(plugin, world, MinigameType.MULTIPLAYER, GameMechanics.MG_MECHANICS.KILLS.getMechanic());
game = TestHelper.createMinigame(plugin, world, MinigameType.MULTIPLAYER, GameMechanics.MgMechanics.KILLS.getMechanic());
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void Setup() {
plugin.toggleDebug();
world = (WorldMock) MockBukkit.getMock().getWorld("GAMES");
spawn = world.getSpawnLocation();
TestHelper.createMinigame(plugin, world, MinigameType.MULTIPLAYER, GameMechanics.MG_MECHANICS.CTF.getMechanic());
TestHelper.createMinigame(plugin, world, MinigameType.MULTIPLAYER, GameMechanics.MgMechanics.CTF.getMechanic());
player = new TestPlayer(MockBukkit.getMock(), "TestPlayer", UUID.randomUUID());
player.setLocation(spawn);
MockBukkit.getMock().addPlayer(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import be.seeseemelk.mockbukkit.ServerMock;
import io.papermc.paper.plugin.bootstrap.BootstrapContext;
import io.papermc.paper.plugin.configuration.PluginMeta;
import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager;
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
import org.bukkit.plugin.InvalidDescriptionException;
import org.bukkit.plugin.PluginDescriptionFile;
Expand All @@ -16,7 +17,17 @@

public class MockBootstrap {
public static @NotNull Minigames createPluginWithTestContext(ServerMock server) {
return new MinigameBootstrap().createPlugin(new BootstrapContext() {
return new MinigameBootstrap().createPlugin(new BootstrapContext() { //todo
@Override
public @NotNull PluginMeta getPluginMeta() {
return null;
}

@Override
public @NotNull LifecycleEventManager<BootstrapContext> getLifecycleManager() {
return null;
}

@Override
public @NotNull PluginMeta getConfiguration() {
Enumeration<URL> resources = null;
Expand Down
Loading

0 comments on commit 3a9c292

Please sign in to comment.