From cdab9c88cb1e96e7ed6ac76d4df1269b02415667 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sun, 30 Jun 2024 17:45:28 -0500 Subject: [PATCH] Improve map API --- .../arena/module/tournaments/Tournament.java | 4 +- plugin/build.gradle.kts | 2 - .../java/org/battleplugins/arena/Arena.java | 13 ++-- .../org/battleplugins/arena/BattleArena.java | 22 +++---- .../arena/command/ArenaCommandExecutor.java | 12 ++-- .../arena/competition/Competition.java | 2 +- .../arena/competition/CompetitionManager.java | 8 +-- .../arena/competition/CompetitionType.java | 4 +- .../arena/competition/LiveCompetition.java | 6 +- .../competition/event/EventScheduler.java | 4 +- .../arena/competition/event/LiveEvent.java | 2 +- .../arena/competition/map/CompetitionMap.java | 12 +--- .../competition/map/LiveCompetitionMap.java | 29 +++++---- .../arena/competition/map/MapFactory.java | 63 +++++++++++++++++++ .../arena/competition/match/LiveMatch.java | 2 +- .../arena/editor/ArenaEditorWizards.java | 6 +- .../editor/context/MapCreateContext.java | 4 +- 17 files changed, 127 insertions(+), 68 deletions(-) create mode 100644 plugin/src/main/java/org/battleplugins/arena/competition/map/MapFactory.java diff --git a/module/tournaments/src/main/java/org/battleplugins/arena/module/tournaments/Tournament.java b/module/tournaments/src/main/java/org/battleplugins/arena/module/tournaments/Tournament.java index 30daef6c..7abc264e 100644 --- a/module/tournaments/src/main/java/org/battleplugins/arena/module/tournaments/Tournament.java +++ b/module/tournaments/src/main/java/org/battleplugins/arena/module/tournaments/Tournament.java @@ -254,7 +254,7 @@ private void advance(List contestants) { // Check to see if any of the open competitions are dynamic and allocate as needed int requiredCompetitions = mapsNeeded - openCompetitions.size(); - List> dynamicMaps = this.arena.getPlugin().getMaps(this.arena) + List dynamicMaps = this.arena.getPlugin().getMaps(this.arena) .stream() .filter(map -> map.getType() == MapType.DYNAMIC) .toList(); @@ -265,7 +265,7 @@ private void advance(List contestants) { for (int i = 0; i < requiredCompetitions; i++) { // Now just walk through the dynamic maps and allocate them - LiveCompetitionMap map = dynamicMaps.get(i % dynamicMaps.size()); + LiveCompetitionMap map = dynamicMaps.get(i % dynamicMaps.size()); Competition competition = map.createDynamicCompetition(this.arena); this.arena.getPlugin().addCompetition(this.arena, competition); diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 67a9cc22..719c5794 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -1,5 +1,3 @@ -import xyz.jpenilla.runpaper.task.RunServer - plugins { id("maven-publish") id("xyz.jpenilla.run-paper") version "2.3.0" diff --git a/plugin/src/main/java/org/battleplugins/arena/Arena.java b/plugin/src/main/java/org/battleplugins/arena/Arena.java index 4a2c5309..5ef74380 100644 --- a/plugin/src/main/java/org/battleplugins/arena/Arena.java +++ b/plugin/src/main/java/org/battleplugins/arena/Arena.java @@ -4,6 +4,7 @@ import org.battleplugins.arena.competition.Competition; import org.battleplugins.arena.competition.CompetitionType; import org.battleplugins.arena.competition.map.LiveCompetitionMap; +import org.battleplugins.arena.competition.map.MapFactory; import org.battleplugins.arena.competition.phase.CompetitionPhase; import org.battleplugins.arena.competition.phase.CompetitionPhaseType; import org.battleplugins.arena.competition.victory.VictoryConditionType; @@ -116,12 +117,16 @@ public ArenaCommandExecutor createCommandExecutor() { } /** - * Returns the {@link LiveCompetitionMap} type for this arena. + * Returns the {@link MapFactory} for this arena. + *

+ * This factory controls the creation of maps for this + * arena, and can be overridden to provide custom map + * creation logic. * - * @return the {@link LiveCompetitionMap} type for this arena + * @return the map factory for this arena */ - public Class getCompetitionMapType() { - return LiveCompetitionMap.class; + public MapFactory getMapFactory() { + return LiveCompetitionMap.getFactory(); } /** diff --git a/plugin/src/main/java/org/battleplugins/arena/BattleArena.java b/plugin/src/main/java/org/battleplugins/arena/BattleArena.java index f5b5f93f..46fc95d4 100644 --- a/plugin/src/main/java/org/battleplugins/arena/BattleArena.java +++ b/plugin/src/main/java/org/battleplugins/arena/BattleArena.java @@ -65,7 +65,7 @@ public class BattleArena extends JavaPlugin implements Listener, LoggerHolder { final Map> arenaTypes = new HashMap<>(); final Map arenas = new HashMap<>(); - private final Map>> arenaMaps = new HashMap<>(); + private final Map> arenaMaps = new HashMap<>(); private final Map arenaLoaders = new HashMap<>(); private final CompetitionManager competitionManager = new CompetitionManager(this); @@ -257,12 +257,12 @@ private void postInitialize() { this.loadArenaMaps(); // Initialize matches - for (Map.Entry>> entry : this.arenaMaps.entrySet()) { + for (Map.Entry> entry : this.arenaMaps.entrySet()) { if (entry.getKey().getType() != CompetitionType.MATCH) { continue; } - for (LiveCompetitionMap map : entry.getValue()) { + for (LiveCompetitionMap map : entry.getValue()) { if (map.getType() == MapType.STATIC) { Competition competition = map.createCompetition(entry.getKey()); this.addCompetition(entry.getKey(), competition); @@ -368,8 +368,8 @@ public void registerArena(String name, Class arenaClass, Su * @param arena the arena to get the maps for * @return all the available maps for the given arena */ - public List> getMaps(Arena arena) { - List> maps = this.arenaMaps.get(arena); + public List getMaps(Arena arena) { + List maps = this.arenaMaps.get(arena); if (maps == null) { return List.of(); } @@ -384,7 +384,7 @@ public List> getMaps(Arena arena) { * @param name the name of the map * @return the map from the given arena and name */ - public Optional> map(Arena arena, String name) { + public Optional map(Arena arena, String name) { return Optional.ofNullable(this.getMap(arena, name)); } @@ -396,8 +396,8 @@ public Optional> map(Arena arena, String name) { * @return the map from the given arena and name, or null if not found */ @Nullable - public LiveCompetitionMap getMap(Arena arena, String name) { - List> maps = this.arenaMaps.get(arena); + public LiveCompetitionMap getMap(Arena arena, String name) { + List maps = this.arenaMaps.get(arena); if (maps == null) { return null; } @@ -414,7 +414,7 @@ public LiveCompetitionMap getMap(Arena arena, String name) { * @param arena the arena to add the map to * @param map the map to add */ - public void addArenaMap(Arena arena, LiveCompetitionMap map) { + public void addArenaMap(Arena arena, LiveCompetitionMap map) { this.arenaMaps.computeIfAbsent(arena, k -> new ArrayList<>()).add(map); } @@ -424,7 +424,7 @@ public void addArenaMap(Arena arena, LiveCompetitionMap map) { * @param arena the arena to remove the map from * @param map the map to remove */ - public void removeArenaMap(Arena arena, LiveCompetitionMap map) { + public void removeArenaMap(Arena arena, LiveCompetitionMap map) { this.arenaMaps.computeIfAbsent(arena, k -> new ArrayList<>()).remove(map); // If the map is removed, also remove the competition if applicable @@ -679,7 +679,7 @@ private void loadArenaMaps() { try { Configuration configuration = YamlConfiguration.loadConfiguration(Files.newBufferedReader(mapPath)); - LiveCompetitionMap map = ArenaConfigParser.newInstance(mapPath, arena.getCompetitionMapType(), configuration, this); + LiveCompetitionMap map = ArenaConfigParser.newInstance(mapPath, arena.getMapFactory().getMapClass(), configuration, this); if (map.getBounds() == null && map.getType() == MapType.DYNAMIC) { // Cannot create dynamic map without bounds this.warn("Map {} for arena {} is dynamic but does not have bounds!", map.getName(), arena.getName()); diff --git a/plugin/src/main/java/org/battleplugins/arena/command/ArenaCommandExecutor.java b/plugin/src/main/java/org/battleplugins/arena/command/ArenaCommandExecutor.java index 0df65d6c..6350434c 100644 --- a/plugin/src/main/java/org/battleplugins/arena/command/ArenaCommandExecutor.java +++ b/plugin/src/main/java/org/battleplugins/arena/command/ArenaCommandExecutor.java @@ -40,7 +40,7 @@ public ArenaCommandExecutor(String parentCommand, Arena arena) { @ArenaCommand(commands = { "join", "j" }, description = "Join an arena.", permissionNode = "join") public void join(Player player) { - List> maps = this.arena.getPlugin().getMaps(this.arena); + List maps = this.arena.getPlugin().getMaps(this.arena); if (maps.isEmpty()) { Messages.NO_OPEN_ARENAS.send(player); return; @@ -50,7 +50,7 @@ public void join(Player player) { } @ArenaCommand(commands = { "join", "j" }, description = "Join an arena.", permissionNode = "join") - public void join(Player player, @Argument(name = "map") CompetitionMap map) { + public void join(Player player, @Argument(name = "map") CompetitionMap map) { if (ArenaPlayer.getArenaPlayer(player) != null) { Messages.ALREADY_IN_ARENA.send(player); return; @@ -188,8 +188,8 @@ public void create(Player player) { } @ArenaCommand(commands = { "remove", "delete" }, description = "Removes an arena.", permissionNode = "remove") - public void remove(Player player, CompetitionMap map) { - if (!(map instanceof LiveCompetitionMap liveMap)) { + public void remove(Player player, CompetitionMap map) { + if (!(map instanceof LiveCompetitionMap liveMap)) { Messages.NO_ARENA_WITH_NAME.send(player); return; } @@ -209,8 +209,8 @@ public void remove(Player player, CompetitionMap map) { } @ArenaCommand(commands = "edit", description = "Edit an arena map.", permissionNode = "edit") - public void map(Player player, CompetitionMap map, MapOption option) { - if (!(map instanceof LiveCompetitionMap liveMap)) { + public void map(Player player, CompetitionMap map, MapOption option) { + if (!(map instanceof LiveCompetitionMap liveMap)) { Messages.NO_ARENA_WITH_NAME.send(player); return; } diff --git a/plugin/src/main/java/org/battleplugins/arena/competition/Competition.java b/plugin/src/main/java/org/battleplugins/arena/competition/Competition.java index e497c2d0..3669db8c 100644 --- a/plugin/src/main/java/org/battleplugins/arena/competition/Competition.java +++ b/plugin/src/main/java/org/battleplugins/arena/competition/Competition.java @@ -34,7 +34,7 @@ public interface Competition> extends CompetitionLike getMap(); + CompetitionMap getMap(); /** * Gets the current phase of the competition. diff --git a/plugin/src/main/java/org/battleplugins/arena/competition/CompetitionManager.java b/plugin/src/main/java/org/battleplugins/arena/competition/CompetitionManager.java index 324c2cde..57bc363b 100644 --- a/plugin/src/main/java/org/battleplugins/arena/competition/CompetitionManager.java +++ b/plugin/src/main/java/org/battleplugins/arena/competition/CompetitionManager.java @@ -62,7 +62,7 @@ public CompletableFuture getOrCreateCompetition(Arena arena, return invalidResult; } - List> maps = this.plugin.getMaps(arena); + List maps = this.plugin.getMaps(arena); if (maps == null) { // No maps, return return invalidResult; @@ -94,7 +94,7 @@ public CompletableFuture getOrCreateCompetition(Arena arena, Collections.shuffle(maps); } - for (LiveCompetitionMap map : maps) { + for (LiveCompetitionMap map : maps) { if (map.getType() != MapType.DYNAMIC) { continue; } @@ -185,7 +185,7 @@ public void removeCompetition(Arena arena, Competition competition) { } competitions.remove(competition); - if (competition.getMap().getType() == MapType.DYNAMIC && competition.getMap() instanceof LiveCompetitionMap map) { + if (competition.getMap().getType() == MapType.DYNAMIC && competition.getMap() instanceof LiveCompetitionMap map) { this.clearDynamicMap(map); } } @@ -198,7 +198,7 @@ public void completeAllActiveCompetitions() { } } - private void clearDynamicMap(LiveCompetitionMap map) { + private void clearDynamicMap(LiveCompetitionMap map) { if (map.getType() != MapType.DYNAMIC) { return; } diff --git a/plugin/src/main/java/org/battleplugins/arena/competition/CompetitionType.java b/plugin/src/main/java/org/battleplugins/arena/competition/CompetitionType.java index 9c7a77a4..f143a9ab 100644 --- a/plugin/src/main/java/org/battleplugins/arena/competition/CompetitionType.java +++ b/plugin/src/main/java/org/battleplugins/arena/competition/CompetitionType.java @@ -37,7 +37,7 @@ public Class getCompetitionType() { return this.clazz; } - public T create(Arena arena, LiveCompetitionMap map) { + public T create(Arena arena, LiveCompetitionMap map) { return this.factory.create(arena, map); } @@ -65,6 +65,6 @@ public int hashCode() { public interface CompetitionFactory> { - T create(Arena arena, LiveCompetitionMap map); + T create(Arena arena, LiveCompetitionMap map); } } diff --git a/plugin/src/main/java/org/battleplugins/arena/competition/LiveCompetition.java b/plugin/src/main/java/org/battleplugins/arena/competition/LiveCompetition.java index d67cab0c..ea2c0514 100644 --- a/plugin/src/main/java/org/battleplugins/arena/competition/LiveCompetition.java +++ b/plugin/src/main/java/org/battleplugins/arena/competition/LiveCompetition.java @@ -38,7 +38,7 @@ */ public abstract class LiveCompetition> implements ArenaLike, Competition { private final Arena arena; - private final LiveCompetitionMap map; + private final LiveCompetitionMap map; private final Map players = new HashMap<>(); private final Map> playersByRole = new HashMap<>(); @@ -51,7 +51,7 @@ public abstract class LiveCompetition> implements Arena private final OptionsListener optionsListener; private final StatListener statListener; - public LiveCompetition(Arena arena, LiveCompetitionMap map) { + public LiveCompetition(Arena arena, LiveCompetitionMap map) { this.arena = arena; this.map = map; @@ -144,7 +144,7 @@ public final Arena getArena() { } @Override - public final LiveCompetitionMap getMap() { + public final LiveCompetitionMap getMap() { return this.map; } diff --git a/plugin/src/main/java/org/battleplugins/arena/competition/event/EventScheduler.java b/plugin/src/main/java/org/battleplugins/arena/competition/event/EventScheduler.java index b0f69028..87b102bb 100644 --- a/plugin/src/main/java/org/battleplugins/arena/competition/event/EventScheduler.java +++ b/plugin/src/main/java/org/battleplugins/arena/competition/event/EventScheduler.java @@ -58,14 +58,14 @@ public void startEvent(Arena arena, EventOptions options) { } // Create the competition - List> maps = arena.getPlugin().getMaps(arena); + List maps = arena.getPlugin().getMaps(arena); if (maps.isEmpty()) { arena.getPlugin().warn("No maps found for arena {}, failed to start event!", arena.getName()); return; } // Get a random map - LiveCompetitionMap map = maps.get(ThreadLocalRandom.current().nextInt(maps.size())); + LiveCompetitionMap map = maps.get(ThreadLocalRandom.current().nextInt(maps.size())); Competition competition = map.getType() == MapType.DYNAMIC ? map.createDynamicCompetition(arena) : map.createCompetition(arena); // Create the competition diff --git a/plugin/src/main/java/org/battleplugins/arena/competition/event/LiveEvent.java b/plugin/src/main/java/org/battleplugins/arena/competition/event/LiveEvent.java index 297bf786..8f3abfc0 100644 --- a/plugin/src/main/java/org/battleplugins/arena/competition/event/LiveEvent.java +++ b/plugin/src/main/java/org/battleplugins/arena/competition/event/LiveEvent.java @@ -9,7 +9,7 @@ */ public class LiveEvent extends LiveCompetition implements Event { - public LiveEvent(Arena arena, LiveCompetitionMap map) { + public LiveEvent(Arena arena, LiveCompetitionMap map) { super(arena, map); } } diff --git a/plugin/src/main/java/org/battleplugins/arena/competition/map/CompetitionMap.java b/plugin/src/main/java/org/battleplugins/arena/competition/map/CompetitionMap.java index 4fcbadf7..491e46cf 100644 --- a/plugin/src/main/java/org/battleplugins/arena/competition/map/CompetitionMap.java +++ b/plugin/src/main/java/org/battleplugins/arena/competition/map/CompetitionMap.java @@ -1,12 +1,9 @@ package org.battleplugins.arena.competition.map; -import org.battleplugins.arena.competition.Competition; -import org.battleplugins.arena.competition.CompetitionType; - /** * A map for a competition. */ -public interface CompetitionMap> { +public interface CompetitionMap { /** * Gets the name of the map. @@ -15,13 +12,6 @@ public interface CompetitionMap> { */ String getName(); - /** - * Gets the competition this map is for. - * - * @return the competition this map is for - */ - CompetitionType getCompetitionType(); - /** * Gets the type of map. * diff --git a/plugin/src/main/java/org/battleplugins/arena/competition/map/LiveCompetitionMap.java b/plugin/src/main/java/org/battleplugins/arena/competition/map/LiveCompetitionMap.java index 1fba211b..4d6455f5 100644 --- a/plugin/src/main/java/org/battleplugins/arena/competition/map/LiveCompetitionMap.java +++ b/plugin/src/main/java/org/battleplugins/arena/competition/map/LiveCompetitionMap.java @@ -4,7 +4,6 @@ import org.battleplugins.arena.Arena; import org.battleplugins.arena.ArenaLike; import org.battleplugins.arena.competition.Competition; -import org.battleplugins.arena.competition.CompetitionType; import org.battleplugins.arena.competition.map.options.Bounds; import org.battleplugins.arena.competition.map.options.Spawns; import org.battleplugins.arena.config.ArenaOption; @@ -22,10 +21,10 @@ /** * Represents a map for a competition which is live on this server. - * - * @param the type of competition this map is for */ -public class LiveCompetitionMap> implements ArenaLike, CompetitionMap, PostProcessable { +public class LiveCompetitionMap implements ArenaLike, CompetitionMap, PostProcessable { + private static final MapFactory FACTORY = MapFactory.create(LiveCompetitionMap.class, LiveCompetitionMap::new); + @ArenaOption(name = "name", description = "The name of the map.", required = true) private String name; @@ -90,11 +89,6 @@ public final Arena getArena() { return this.arena; } - @Override - public final CompetitionType getCompetitionType() { - return (CompetitionType) this.arena.getType(); - } - /** * Gets the {@link MapType} of this map. * @@ -186,8 +180,8 @@ public final void setSpawns(Spawns spawns) { * @param arena the arena to create the competition for * @return the created competition */ - public T createCompetition(Arena arena) { - return this.getCompetitionType().create(arena, this); + public Competition createCompetition(Arena arena) { + return arena.getType().create(arena, this); } /** @@ -200,7 +194,7 @@ public T createCompetition(Arena arena) { * @return the created dynamic competition */ @Nullable - public final T createDynamicCompetition(Arena arena) { + public final Competition createDynamicCompetition(Arena arena) { if (this.type != MapType.DYNAMIC) { throw new IllegalStateException("Cannot create dynamic competition for non-dynamic map!"); } @@ -222,9 +216,18 @@ public final T createDynamicCompetition(Arena arena) { return null; // Failed to copy } - LiveCompetitionMap copy = new LiveCompetitionMap<>(this.name, arena, this.type, worldName, this.bounds, this.spawns); + LiveCompetitionMap copy = arena.getMapFactory().create(this.name, arena, this.type, worldName, this.bounds, this.spawns); copy.mapWorld = world; return copy.createCompetition(arena); } + + /** + * Gets the default factory for creating {@link LiveCompetitionMap live maps}. + * + * @return the factory for creating maps + */ + public static MapFactory getFactory() { + return FACTORY; + } } diff --git a/plugin/src/main/java/org/battleplugins/arena/competition/map/MapFactory.java b/plugin/src/main/java/org/battleplugins/arena/competition/map/MapFactory.java new file mode 100644 index 00000000..edf37d10 --- /dev/null +++ b/plugin/src/main/java/org/battleplugins/arena/competition/map/MapFactory.java @@ -0,0 +1,63 @@ +package org.battleplugins.arena.competition.map; + +import org.battleplugins.arena.Arena; +import org.battleplugins.arena.competition.map.options.Bounds; +import org.battleplugins.arena.competition.map.options.Spawns; +import org.jetbrains.annotations.Nullable; + +/** + * A factory for creating maps. + */ +public class MapFactory { + private final Class mapClass; + private final Provider provider; + + private MapFactory(Class mapClass, Provider provider) { + this.mapClass = mapClass; + this.provider = provider; + } + + /** + * Gets the class of the map. + * + * @return the class of the map + */ + public Class getMapClass() { + return this.mapClass; + } + + /** + * Creates a new {@link LiveCompetitionMap map} from the given parameters. + * + * @param name the name of the map + * @param arena the arena this map is for + * @param type the type of map + * @param world the world the map is located in + * @param bounds the bounds of the map + * @param spawns the spawn locations + * @return the created map + */ + public LiveCompetitionMap create(String name, Arena arena, MapType type, String world, @Nullable Bounds bounds, @Nullable Spawns spawns) { + return this.provider.create(name, arena, type, world, bounds, spawns); + } + + public static MapFactory create(Class mapClass, Provider provider) { + return new MapFactory(mapClass, provider); + } + + public interface Provider { + + /** + * Creates a new {@link M map} from the given parameters. + * + * @param name the name of the map + * @param arena the arena this map is for + * @param type the type of map + * @param world the world the map is located in + * @param bounds the bounds of the map + * @param spawns the spawn locations + * @return the created map + */ + M create(String name, Arena arena, MapType type, String world, @Nullable Bounds bounds, @Nullable Spawns spawns); + } +} diff --git a/plugin/src/main/java/org/battleplugins/arena/competition/match/LiveMatch.java b/plugin/src/main/java/org/battleplugins/arena/competition/match/LiveMatch.java index c3e0c1cd..8ba09f6f 100644 --- a/plugin/src/main/java/org/battleplugins/arena/competition/match/LiveMatch.java +++ b/plugin/src/main/java/org/battleplugins/arena/competition/match/LiveMatch.java @@ -9,7 +9,7 @@ */ public class LiveMatch extends LiveCompetition implements Match { - public LiveMatch(Arena arena, LiveCompetitionMap map) { + public LiveMatch(Arena arena, LiveCompetitionMap map) { super(arena, map); } } diff --git a/plugin/src/main/java/org/battleplugins/arena/editor/ArenaEditorWizards.java b/plugin/src/main/java/org/battleplugins/arena/editor/ArenaEditorWizards.java index fd8f588a..9d25d5f1 100644 --- a/plugin/src/main/java/org/battleplugins/arena/editor/ArenaEditorWizards.java +++ b/plugin/src/main/java/org/battleplugins/arena/editor/ArenaEditorWizards.java @@ -75,7 +75,7 @@ public final class ArenaEditorWizards { } )) .onEditComplete(ctx -> { - LiveCompetitionMap map = BattleArena.getInstance().getMap(ctx.getArena(), ctx.getMapName()); + LiveCompetitionMap map = BattleArena.getInstance().getMap(ctx.getArena(), ctx.getMapName()); if (map == null) { // Should not get here but *just* incase Messages.NO_ARENA_WITH_NAME.send(ctx.getPlayer()); @@ -128,11 +128,11 @@ public final class ArenaEditorWizards { ctx.getSpawns().forEach((team, spawns) -> teamSpawns.put(team, new TeamSpawns(spawns))); Spawns spawns = new Spawns(ctx.getWaitroomSpawn(), ctx.getSpectatorSpawn(), teamSpawns); - LiveCompetitionMap map = new LiveCompetitionMap<>(ctx.getMapName(), ctx.getArena(), ctx.getMapType(), ctx.getPlayer().getWorld().getName(), bounds, spawns); + LiveCompetitionMap map = ctx.getArena().getMapFactory().create(ctx.getMapName(), ctx.getArena(), ctx.getMapType(), ctx.getPlayer().getWorld().getName(), bounds, spawns); BattleArena.getInstance().addArenaMap(ctx.getArena(), map); // If our competition is a match, create it - if (map.getCompetitionType() == CompetitionType.MATCH && map.getType() == MapType.STATIC) { + if (ctx.getArena().getType() == CompetitionType.MATCH && map.getType() == MapType.STATIC) { Competition competition = map.createCompetition(ctx.getArena()); BattleArena.getInstance().addCompetition(ctx.getArena(), competition); } diff --git a/plugin/src/main/java/org/battleplugins/arena/editor/context/MapCreateContext.java b/plugin/src/main/java/org/battleplugins/arena/editor/context/MapCreateContext.java index 78cfc3f9..e0f175ec 100644 --- a/plugin/src/main/java/org/battleplugins/arena/editor/context/MapCreateContext.java +++ b/plugin/src/main/java/org/battleplugins/arena/editor/context/MapCreateContext.java @@ -105,7 +105,7 @@ public List getMissingTeams() { return missingTeams; } - public void reconstructFrom(LiveCompetitionMap map) { + public void reconstructFrom(LiveCompetitionMap map) { this.reconstructed = true; Bounds bounds = map.getBounds(); @@ -132,7 +132,7 @@ public void reconstructFrom(LiveCompetitionMap map) { spawns.getTeamSpawns().forEach((team, teamSpawns) -> this.spawns.put(team, teamSpawns.getSpawns())); } - public void saveTo(LiveCompetitionMap map) { + public void saveTo(LiveCompetitionMap map) { Bounds bounds = new Bounds( this.min.blockX(), this.min.blockY(),