Faction Disband Reason & Auto-Completion

- Add Faction Disband Reason
- Add Auto-Completion
- Optimization
This commit is contained in:
GenialJerome
2018-12-09 03:13:18 +01:00
parent c58ed305a8
commit 16aa87a16a
32 changed files with 365 additions and 403 deletions

View File

@@ -63,7 +63,7 @@ public class AutoLeaveProcessTask extends BukkitRunnable {
if (fplayer.getRole() == Role.LEADER) {
Faction faction = fplayer.getFaction();
if (faction != null) {
fplayer.getFaction().promoteNewLeader();
fplayer.getFaction().promoteNewLeader(true);
}
}

View File

@@ -20,7 +20,7 @@ public class MiscUtil {
/// TODO create tag whitelist!!
public static HashSet<String> substanceChars =
new HashSet<>(Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"));
new HashSet<>(Arrays.asList("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("")));
public static EntityType creatureTypeFromEntity(Entity entity) {
if (!(entity instanceof Creature)) {
@@ -100,25 +100,11 @@ public class MiscUtil {
}
switch (player.getRole()) {
case LEADER:
admins.add(player);
break;
case COLEADER:
admins.add(player);
break;
case MODERATOR:
moderators.add(player);
break;
case NORMAL:
normal.add(player);
break;
case RECRUIT:
recruit.add(player);
break;
case LEADER: admins.add(player); break;
case COLEADER: admins.add(player); break;
case MODERATOR: moderators.add(player); break;
case NORMAL: normal.add(player); break;
case RECRUIT: recruit.add(player); break;
}
}

View File

@@ -858,7 +858,8 @@ public enum MultiversionMaterials {
ZOMBIE_VILLAGER_SPAWN_EGG("MONSTER_EGG", 0),
ZOMBIE_WALL_HEAD("SKULL", 0),
;
static int newV = - 1;
static int newV = - 1;
private static HashMap<String, MultiversionMaterials> cachedSearch = new HashMap<>();
String m;
int data;
@@ -871,11 +872,13 @@ public enum MultiversionMaterials {
public static boolean isNewVersion() {
if (newV == 0) return false;
if (newV == 1) return true;
Material mat = Material.matchMaterial("RED_WOOL");
if (mat != null) {
newV = 1;
return true;
}
newV = 0;
return false;
}
@@ -894,20 +897,13 @@ public enum MultiversionMaterials {
}
public static MultiversionMaterials fromString(String key) {
MultiversionMaterials xmat = null;
try {
xmat = MultiversionMaterials.valueOf(key);
return xmat;
return MultiversionMaterials.valueOf(key);
} catch (IllegalArgumentException e) {
String[] split = key.split(":");
if (split.length == 1) {
xmat = requestXMaterial(key, (byte) 0);
} else {
xmat = requestXMaterial(split[0], (byte) Integer.parseInt(split[1]));
}
return xmat;
return split.length == 1 ? requestXMaterial(key, (byte) 0):requestXMaterial(split[0], (byte) Integer.parseInt(split[1]));
}
}
public ItemStack parseItem() {
@@ -948,34 +944,21 @@ public enum MultiversionMaterials {
public boolean isDamageable(MultiversionMaterials type) {
String[] split = type.toString().split("_");
int length = split.length;
switch (split[length - 1]) {
switch (split[split.length - 1]) {
case "HELMET":
return true;
case "CHESTPLATE":
return true;
case "LEGGINGS":
return true;
case "BOOTS":
return true;
case "SWORD":
return true;
case "AXE":
return true;
case "PICKAXE":
return true;
case "SHOVEL":
return true;
case "HOE":
return true;
case "ELYTRA":
return true;
case "TURTLE_HELMET":
return true;
case "TRIDENT":
return true;
case "HORSE_ARMOR":
return true;
case "SHEARS":
return true;
default:
@@ -985,10 +968,7 @@ public enum MultiversionMaterials {
public Material parseMaterial() {
Material mat = Material.matchMaterial(this.toString());
if (mat != null) {
return mat;
}
return Material.matchMaterial(m);
return mat != null ? mat:Material.matchMaterial(m);
}
}

View File

@@ -56,12 +56,9 @@ public class RelationUtil {
public static Relation getRelationTo(RelationParticipator me, RelationParticipator that, boolean ignorePeaceful) {
Faction fthat = getFaction(that);
if (fthat == null) {
return Relation.NEUTRAL; // ERROR
}
Faction fme = getFaction(me);
if (fme == null) {
if (fthat == null || fme == null) {
return Relation.NEUTRAL; // ERROR
}
@@ -99,18 +96,14 @@ public class RelationUtil {
public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me) {
Faction thatFaction = getFaction(that);
if (thatFaction != null) {
if (thatFaction.isPeaceful() && thatFaction != getFaction(me)) {
if (thatFaction != null && thatFaction != getFaction(me)) {
if (thatFaction.isPeaceful())
return Conf.colorPeaceful;
}
if (thatFaction.isSafeZone() && thatFaction != getFaction(me)) {
else if (thatFaction.isSafeZone())
return Conf.colorPeaceful;
}
if (thatFaction.isWarZone() && thatFaction != getFaction(me)) {
else if (thatFaction.isWarZone())
return Conf.colorWar;
}
}
return getRelationTo(that, me).getColor();