Skip to content

Commit

Permalink
🌈[main/Guild] Code Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepymalc committed Aug 24, 2021
1 parent 253bdf4 commit 6e446b3
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/main/java/com/linyuanlin/minecraft/models/Guild.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.*;

import org.bukkit.entity.Player;

import static java.util.Map.entry;

public class Guild {
Expand All @@ -14,6 +15,11 @@ public class Guild {
private static class LevelAttributes {
private int cost, memberNums, lordNums, vicePresidentNums;

public final static String COST = "cost";
public final static String MEMBER_NUMS = "memberNums";
public final static String LORD_NUMS = "lordNums";
public final static String VICE_PRESIDENT_NUMS = "vicePresidentNums";

public LevelAttributes(int cost, int memberNums, int lordNums, int vicePresidentNums) {
this.cost = cost;
this.memberNums = memberNums;
Expand Down Expand Up @@ -48,15 +54,16 @@ public int vicePresidentNums() {
entry(2, level_2), entry(3, level_3), entry(4, level_4), entry(5, level_5));

public boolean isMemberFull() {
return this.memberList.size() > getLevelAttributes(this.level, "memberNums");
return this.memberList.size() > getLevelAttributes(this.level, LevelAttributes.MEMBER_NUMS);
}

public boolean isLordFull() {
return this.lordList.size() > getLevelAttributes(this.level, "lordNums");
return this.lordList.size() > getLevelAttributes(this.level, LevelAttributes.LORD_NUMS);
}

public boolean isVicePresidentFull() {
return this.vicePresidentList.size() > getLevelAttributes(this.level, "vicePresidentNums");
return this.vicePresidentList.size() > getLevelAttributes(this.level,
LevelAttributes.VICE_PRESIDENT_NUMS);
}

public Player president() {
Expand Down Expand Up @@ -137,13 +144,13 @@ public boolean deleteVicePresident(PlayerData p) {

public int getLevelAttributes(int level, String key) {
switch (key) {
case "cost":
case LevelAttributes.COST:
return Guild.levelMap.get(level).cost();
case "memberNums":
case LevelAttributes.MEMBER_NUMS:
return Guild.levelMap.get(level).memberNums();
case "lordNums":
case LevelAttributes.LORD_NUMS:
return Guild.levelMap.get(level).lordNums();
case "vicePresidentNums":
case LevelAttributes.VICE_PRESIDENT_NUMS:
return Guild.levelMap.get(level).vicePresidentNums();
default:
return -1;
Expand Down

0 comments on commit 6e446b3

Please sign in to comment.