forked from alkarinv/BattleArena
-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove needlessly confusing Match/Event subclasses that did nothing
- Loading branch information
Showing
9 changed files
with
23 additions
and
130 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
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
57 changes: 8 additions & 49 deletions
57
plugin/src/main/java/org/battleplugins/arena/competition/CompetitionType.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 |
---|---|---|
@@ -1,70 +1,29 @@ | ||
package org.battleplugins.arena.competition; | ||
|
||
import org.battleplugins.arena.Arena; | ||
import org.battleplugins.arena.competition.event.Event; | ||
import org.battleplugins.arena.competition.event.LiveEvent; | ||
import org.battleplugins.arena.competition.map.LiveCompetitionMap; | ||
import org.battleplugins.arena.competition.match.LiveMatch; | ||
import org.battleplugins.arena.competition.match.Match; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Represents a competition type. | ||
* | ||
* @param <T> the type of competition | ||
*/ | ||
public final class CompetitionType<T extends Competition<T>> { | ||
private static final Map<String, CompetitionType<?>> COMPETITION_TYPES = new HashMap<>(); | ||
public final class CompetitionType { | ||
private static final Map<String, CompetitionType> COMPETITION_TYPES = new HashMap<>(); | ||
|
||
public static final CompetitionType<Event> EVENT = new CompetitionType<>("Event", Event.class, LiveEvent::new); | ||
public static final CompetitionType<Match> MATCH = new CompetitionType<>("Match", Match.class, LiveMatch::new); | ||
public static final CompetitionType EVENT = new CompetitionType("Event"); | ||
public static final CompetitionType MATCH = new CompetitionType("Match"); | ||
|
||
private final Class<T> clazz; | ||
private final CompetitionFactory<T> factory; | ||
private final String name; | ||
|
||
CompetitionType(String name, Class<T> clazz, CompetitionFactory<T> factory) { | ||
this.clazz = clazz; | ||
this.factory = factory; | ||
CompetitionType(String name) { | ||
this.name = name; | ||
|
||
COMPETITION_TYPES.put(name, this); | ||
} | ||
|
||
public Class<T> getCompetitionType() { | ||
return this.clazz; | ||
} | ||
|
||
public T create(Arena arena, LiveCompetitionMap map) { | ||
return this.factory.create(arena, map); | ||
} | ||
|
||
@Nullable | ||
public static CompetitionType<?> get(String name) { | ||
public static CompetitionType get(String name) { | ||
return COMPETITION_TYPES.get(name); | ||
} | ||
|
||
public static <T extends Competition<T>> CompetitionType<T> create(String name, Class<T> clazz, CompetitionFactory<T> factory) { | ||
return new CompetitionType<>(name, clazz, factory); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object object) { | ||
if (this == object) return true; | ||
if (object == null || getClass() != object.getClass()) return false; | ||
CompetitionType<?> that = (CompetitionType<?>) object; | ||
return Objects.equals(this.clazz, that.clazz); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(this.clazz); | ||
} | ||
|
||
public interface CompetitionFactory<T extends Competition<T>> { | ||
|
||
T create(Arena arena, LiveCompetitionMap map); | ||
} | ||
} |
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
21 changes: 0 additions & 21 deletions
21
plugin/src/main/java/org/battleplugins/arena/competition/event/Event.java
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
plugin/src/main/java/org/battleplugins/arena/competition/event/LiveEvent.java
This file was deleted.
Oops, something went wrong.
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
15 changes: 0 additions & 15 deletions
15
plugin/src/main/java/org/battleplugins/arena/competition/match/LiveMatch.java
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
plugin/src/main/java/org/battleplugins/arena/competition/match/Match.java
This file was deleted.
Oops, something went wrong.