mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-03 06:57:41 +01:00
Shifted some constants around.
This commit is contained in:
parent
417f767705
commit
ba62989788
@ -22,6 +22,7 @@ import us.tastybento.bskyblock.api.events.island.IslandEvent.IslandLockEvent;
|
||||
import us.tastybento.bskyblock.api.events.island.IslandEvent.IslandUnlockEvent;
|
||||
import us.tastybento.bskyblock.api.events.island.IslandEvent.Reason;
|
||||
import us.tastybento.bskyblock.api.flags.Flag;
|
||||
import us.tastybento.bskyblock.managers.RanksManager;
|
||||
import us.tastybento.bskyblock.util.Util;
|
||||
|
||||
/**
|
||||
@ -34,11 +35,6 @@ import us.tastybento.bskyblock.util.Util;
|
||||
*/
|
||||
public class Island implements DataObject {
|
||||
|
||||
private static final Integer OWNER_RANK = 1000;
|
||||
private static final Integer MEMBER_RANK = 900;
|
||||
private static final Integer VISITOR_RANK = 0;
|
||||
private static final Integer BANNED_RANK = -1;
|
||||
|
||||
private String uniqueId = "";
|
||||
|
||||
public String getUniqueId() {
|
||||
@ -102,7 +98,7 @@ public class Island implements DataObject {
|
||||
|
||||
public Island(Location location, UUID owner, int protectionRange) {
|
||||
this.owner = owner;
|
||||
this.members.put(owner, OWNER_RANK);
|
||||
this.members.put(owner, RanksManager.OWNER_RANK);
|
||||
this.createdDate = System.currentTimeMillis();
|
||||
this.updatedDate = System.currentTimeMillis();
|
||||
this.world = location.getWorld();
|
||||
@ -120,7 +116,7 @@ public class Island implements DataObject {
|
||||
* @param playerUUID
|
||||
*/
|
||||
public void addMember(UUID playerUUID) {
|
||||
members.put(playerUUID, MEMBER_RANK);
|
||||
members.put(playerUUID, RanksManager.MEMBER_RANK);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,7 +127,7 @@ public class Island implements DataObject {
|
||||
*/
|
||||
public boolean addToBanList(UUID targetUUID) {
|
||||
// TODO fire ban event
|
||||
members.put(targetUUID, BANNED_RANK);
|
||||
members.put(targetUUID, RanksManager.BANNED_RANK);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -141,7 +137,7 @@ public class Island implements DataObject {
|
||||
public Set<UUID> getBanned() {
|
||||
Set<UUID> result = new HashSet<>();
|
||||
for (Entry<UUID, Integer> member: members.entrySet()) {
|
||||
if (member.getValue() <= BANNED_RANK) {
|
||||
if (member.getValue() <= RanksManager.BANNED_RANK) {
|
||||
result.add(member.getKey());
|
||||
}
|
||||
}
|
||||
@ -189,7 +185,7 @@ public class Island implements DataObject {
|
||||
public Set<UUID> getMembers(){
|
||||
Set<UUID> result = new HashSet<>();
|
||||
for (Entry<UUID, Integer> member: members.entrySet()) {
|
||||
if (member.getValue() >= MEMBER_RANK) {
|
||||
if (member.getValue() >= RanksManager.MEMBER_RANK) {
|
||||
result.add(member.getKey());
|
||||
}
|
||||
}
|
||||
@ -312,7 +308,7 @@ public class Island implements DataObject {
|
||||
* @return Returns true if target is banned on this island
|
||||
*/
|
||||
public boolean isBanned(UUID targetUUID) {
|
||||
return members.containsKey(targetUUID) && members.get(targetUUID) == BANNED_RANK ? true : false;
|
||||
return members.containsKey(targetUUID) && members.get(targetUUID) == RanksManager.BANNED_RANK ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -466,7 +462,7 @@ public class Island implements DataObject {
|
||||
*/
|
||||
public void setOwner(UUID owner){
|
||||
this.owner = owner;
|
||||
this.members.put(owner, OWNER_RANK);
|
||||
this.members.put(owner, RanksManager.OWNER_RANK);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -628,7 +624,7 @@ public class Island implements DataObject {
|
||||
* @return rank integer
|
||||
*/
|
||||
public int getRank(User user) {
|
||||
return members.containsKey(user.getUniqueId()) ? members.get(user.getUniqueId()) : VISITOR_RANK;
|
||||
return members.containsKey(user.getUniqueId()) ? members.get(user.getUniqueId()) : RanksManager.VISITOR_RANK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,14 +10,14 @@ import us.tastybento.bskyblock.BSkyBlock;
|
||||
public class RanksManager {
|
||||
|
||||
// Constants that define the hard coded rank values
|
||||
private static final String OWNER_RANK_REF = "ranks.owner";
|
||||
private static final String MEMBER_RANK_REF = "ranks.member";
|
||||
private static final String VISITOR_RANK_REF = "ranks.visitor";
|
||||
private static final String BANNED_RANK_REF = "ranks.banned";
|
||||
private static final Integer OWNER_RANK = 1000;
|
||||
private static final Integer MEMBER_RANK = 900;
|
||||
private static final Integer VISITOR_RANK = 0;
|
||||
private static final Integer BANNED_RANK = -1;
|
||||
public static final String OWNER_RANK_REF = "ranks.owner";
|
||||
public static final String MEMBER_RANK_REF = "ranks.member";
|
||||
public static final String VISITOR_RANK_REF = "ranks.visitor";
|
||||
public static final String BANNED_RANK_REF = "ranks.banned";
|
||||
public static final int OWNER_RANK = 1000;
|
||||
public static final int MEMBER_RANK = 900;
|
||||
public static final int VISITOR_RANK = 0;
|
||||
public static final int BANNED_RANK = -1;
|
||||
|
||||
private BSkyBlock plugin;
|
||||
|
||||
@ -106,60 +106,5 @@ public class RanksManager {
|
||||
return new LinkedHashMap<>(ranks);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ownerRankRef
|
||||
*/
|
||||
public static String getOwnerRankRef() {
|
||||
return OWNER_RANK_REF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the memberRankRef
|
||||
*/
|
||||
public static String getMemberRankRef() {
|
||||
return MEMBER_RANK_REF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the visitorRankRef
|
||||
*/
|
||||
public static String getVisitorRankRef() {
|
||||
return VISITOR_RANK_REF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bannedRankRef
|
||||
*/
|
||||
public static String getBannedRankRef() {
|
||||
return BANNED_RANK_REF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ownerRank
|
||||
*/
|
||||
public static Integer getOwnerRank() {
|
||||
return OWNER_RANK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the memberRank
|
||||
*/
|
||||
public static Integer getMemberRank() {
|
||||
return MEMBER_RANK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the visitorRank
|
||||
*/
|
||||
public static Integer getVisitorRank() {
|
||||
return VISITOR_RANK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bannedRank
|
||||
*/
|
||||
public static Integer getBannedRank() {
|
||||
return BANNED_RANK;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import us.tastybento.bskyblock.api.commands.User;
|
||||
import us.tastybento.bskyblock.api.events.IslandBaseEvent;
|
||||
import us.tastybento.bskyblock.api.events.team.TeamEvent;
|
||||
import us.tastybento.bskyblock.database.objects.Island;
|
||||
import us.tastybento.bskyblock.managers.RanksManager;
|
||||
import us.tastybento.bskyblock.util.Util;
|
||||
|
||||
public class TestBSkyBlock {
|
||||
@ -282,8 +283,8 @@ public class TestBSkyBlock {
|
||||
assertNotNull(island);
|
||||
|
||||
User visitor = User.getInstance(UUID.randomUUID());
|
||||
assertEquals(1000, island.getRank(owner));
|
||||
assertEquals(0, island.getRank(visitor));
|
||||
assertEquals(RanksManager.OWNER_RANK, island.getRank(owner));
|
||||
assertEquals(RanksManager.VISITOR_RANK, island.getRank(visitor));
|
||||
|
||||
// Make members
|
||||
UUID member1 = UUID.randomUUID();
|
||||
|
Loading…
Reference in New Issue
Block a user