Skip to content

Commit

Permalink
fix: handle gamemode edition with pa set - closes #163
Browse files Browse the repository at this point in the history
  • Loading branch information
Eredrim committed Jan 31, 2024
1 parent ee4d808 commit bd329b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/net/slipcor/pvparena/commands/PAA_Set.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.slipcor.pvparena.core.Language;
import net.slipcor.pvparena.core.Language.MSG;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
Expand All @@ -18,6 +19,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;

import static net.slipcor.pvparena.core.Utils.getSerializableItemStacks;

Expand Down Expand Up @@ -117,6 +119,13 @@ private void set(final CommandSender player, final Arena arena, final String nod
} else if (type == ConfigNodeType.STRING) {
arena.getConfig().setManually(node, String.valueOf(value));
arena.msg(player, Language.parse(MSG.SET_DONE, node, value));
} else if (type == ConfigNodeType.GAMEMODE) {
if(Stream.of(GameMode.values()).anyMatch(gm -> gm.name().equalsIgnoreCase(value))) {
arena.getConfig().setManually(node, value);
arena.msg(player, Language.parse(MSG.SET_DONE, node, value));
} else {
arena.msg(player, Language.parse(MSG.ERROR_ARGUMENT_TYPE, value, "Gamemode (e.g. SURVIVAL)"));
}
} else if (type == ConfigNodeType.INT) {
final int iValue;

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/slipcor/pvparena/managers/TabManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ private static List<String> getKeyMatchesInsideDefinition(final String key, fina
} else if ("{EntityType}".equals(definition)) {
final EntityType[] entityTypes = EntityType.values();
addEnumMatchesToList(result, key, asList(entityTypes));
} else if ("{GameMode}".equals(definition)) {
addEnumMatchesToList(result, key, asList(GameMode.values()));
}
}
return result;
Expand Down

0 comments on commit bd329b3

Please sign in to comment.