diff --git a/src/main/java/minevalley/core/api/users/OnlineUser.java b/src/main/java/minevalley/core/api/users/OnlineUser.java index 1a11ff23..13112707 100644 --- a/src/main/java/minevalley/core/api/users/OnlineUser.java +++ b/src/main/java/minevalley/core/api/users/OnlineUser.java @@ -11,7 +11,7 @@ import minevalley.core.api.enums.sounds.AmbientSound; import minevalley.core.api.enums.sounds.Sound; import minevalley.core.api.regions.utils.PlayerLocation; -import minevalley.core.api.users.enums.FractionService; +import minevalley.core.api.users.enums.Fraction; import minevalley.core.api.users.enums.McVersion; import minevalley.core.api.users.enums.TabListView; import minevalley.core.api.users.enums.TeamRank; @@ -328,9 +328,9 @@ public interface OnlineUser extends User { * * @return users fraction */ - FractionService getFractionService(); + Fraction getFractionService(); - void enterFractionService(FractionService service); + void enterFractionService(Fraction service); void leaveFractionService(); diff --git a/src/main/java/minevalley/core/api/users/enums/Fraction.java b/src/main/java/minevalley/core/api/users/enums/Fraction.java new file mode 100644 index 00000000..3b21b172 --- /dev/null +++ b/src/main/java/minevalley/core/api/users/enums/Fraction.java @@ -0,0 +1,21 @@ +package minevalley.core.api.users.enums; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public enum Fraction { + + POLICE("Polizei"), + MEDIC("Rettungsdienst"), + MAIL("Post"), + DISPOSAL("Müllabfuhr"); + + private final String name; + + public static Fraction getFraction(int value) { + return value >= values().length ? null : values()[value]; + } +} \ No newline at end of file diff --git a/src/main/java/minevalley/core/api/users/enums/FractionService.java b/src/main/java/minevalley/core/api/users/enums/FractionService.java deleted file mode 100644 index 3f44dda3..00000000 --- a/src/main/java/minevalley/core/api/users/enums/FractionService.java +++ /dev/null @@ -1,26 +0,0 @@ -package minevalley.core.api.users.enums; - -import lombok.AccessLevel; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.Arrays; - -@Getter -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) -public enum FractionService { - - NONE(0), - - POLICE(1), - MEDIC(2), - - MAIL(-2), - DISPOSAL(-1); - - private final int value; - - public static FractionService getFraction(int value) { - return Arrays.stream(values()).filter(fraction -> fraction.getValue() == value).findFirst().orElse(null); - } -} \ No newline at end of file diff --git a/src/main/java/minevalley/core/api/users/events/services/fractions/UserEnterFractionServiceEvent.java b/src/main/java/minevalley/core/api/users/events/services/fractions/UserEnterFractionServiceEvent.java index 17bca4c9..9c7f3f86 100644 --- a/src/main/java/minevalley/core/api/users/events/services/fractions/UserEnterFractionServiceEvent.java +++ b/src/main/java/minevalley/core/api/users/events/services/fractions/UserEnterFractionServiceEvent.java @@ -2,12 +2,12 @@ import lombok.Getter; import minevalley.core.api.users.OnlineUser; -import minevalley.core.api.users.enums.FractionService; +import minevalley.core.api.users.enums.Fraction; @Getter public class UserEnterFractionServiceEvent extends UserUpdateFractionServiceEvent { - public UserEnterFractionServiceEvent(OnlineUser user, FractionService fractionService) { + public UserEnterFractionServiceEvent(OnlineUser user, Fraction fractionService) { super(user, fractionService); } } \ No newline at end of file diff --git a/src/main/java/minevalley/core/api/users/events/services/fractions/UserLeaveFractionServiceEvent.java b/src/main/java/minevalley/core/api/users/events/services/fractions/UserLeaveFractionServiceEvent.java index 3f887c61..e4a5ad8e 100644 --- a/src/main/java/minevalley/core/api/users/events/services/fractions/UserLeaveFractionServiceEvent.java +++ b/src/main/java/minevalley/core/api/users/events/services/fractions/UserLeaveFractionServiceEvent.java @@ -2,12 +2,12 @@ import lombok.Getter; import minevalley.core.api.users.OnlineUser; -import minevalley.core.api.users.enums.FractionService; +import minevalley.core.api.users.enums.Fraction; @Getter public class UserLeaveFractionServiceEvent extends UserUpdateFractionServiceEvent { - public UserLeaveFractionServiceEvent(OnlineUser user, FractionService fractionService) { + public UserLeaveFractionServiceEvent(OnlineUser user, Fraction fractionService) { super(user, fractionService); } } \ No newline at end of file diff --git a/src/main/java/minevalley/core/api/users/events/services/fractions/UserUpdateFractionServiceEvent.java b/src/main/java/minevalley/core/api/users/events/services/fractions/UserUpdateFractionServiceEvent.java index ad0f6377..2aa062fc 100644 --- a/src/main/java/minevalley/core/api/users/events/services/fractions/UserUpdateFractionServiceEvent.java +++ b/src/main/java/minevalley/core/api/users/events/services/fractions/UserUpdateFractionServiceEvent.java @@ -2,15 +2,15 @@ import lombok.Getter; import minevalley.core.api.users.OnlineUser; -import minevalley.core.api.users.enums.FractionService; +import minevalley.core.api.users.enums.Fraction; import minevalley.core.api.users.events.OnlineUserEvent; @Getter public abstract class UserUpdateFractionServiceEvent extends OnlineUserEvent { - private final FractionService fractionService; + private final Fraction fractionService; - public UserUpdateFractionServiceEvent(OnlineUser user, FractionService fractionService) { + public UserUpdateFractionServiceEvent(OnlineUser user, Fraction fractionService) { super(user); this.fractionService = fractionService; }