Blacklisted Names & Misc changes to setup for new revamp
This commit is contained in:
@@ -3,6 +3,7 @@ package com.massivecraft.factions.util;
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.tag.Tag;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import me.clip.placeholderapi.expansion.Relational;
|
||||
@@ -104,6 +105,10 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
||||
// Then Faction stuff
|
||||
case "faction_name":
|
||||
return fPlayer.hasFaction() ? faction.getTag() : TL.NOFACTION_PREFIX.toString();
|
||||
case "faction_name_custom":
|
||||
return fPlayer.hasFaction() ? Tag.parsePlain(fPlayer, TL.PLACEHOLDER_CUSTOM_FACTION.toString()) : "";
|
||||
case "faction_only_space":
|
||||
return fPlayer.hasFaction() ? " " : "";
|
||||
case "faction_power":
|
||||
return String.valueOf(faction.getPowerRounded());
|
||||
case "faction_powermax":
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBuilder {
|
||||
private ItemMeta meta;
|
||||
private ItemStack item;
|
||||
|
||||
public ItemBuilder(ItemStack item) {
|
||||
this.item = item;
|
||||
this.meta = item.getItemMeta();
|
||||
}
|
||||
|
||||
public ItemBuilder(Material material, int amount, int durability) {
|
||||
this(new ItemStack(material, amount, (short) durability));
|
||||
}
|
||||
|
||||
public ItemBuilder(Material material, int amount) {
|
||||
this(material, amount, 0);
|
||||
}
|
||||
|
||||
public ItemBuilder(Material material) {
|
||||
this(material, 1);
|
||||
}
|
||||
|
||||
public static List<String> color(List<String> string) {
|
||||
List<String> colored = new ArrayList<>();
|
||||
for (String line : string) {
|
||||
colored.add(FactionsPlugin.instance.color(line));
|
||||
}
|
||||
return colored;
|
||||
}
|
||||
|
||||
public ItemBuilder durability(short durability) {
|
||||
this.item.setDurability(durability);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder lore(String... lore) {
|
||||
if (lore != null) {
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
for (String line : lore) {
|
||||
arrayList.add(FactionsPlugin.instance.color(line));
|
||||
}
|
||||
this.meta.setLore(arrayList);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder lore(List<String> lore) {
|
||||
this.meta.setLore(color(lore));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder name(String name) {
|
||||
this.meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack build() {
|
||||
this.item.setItemMeta(this.meta);
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public ItemBuilder amount(int amount) {
|
||||
this.item.setAmount(amount);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder glowing(boolean status) {
|
||||
if (status) {
|
||||
this.meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
this.meta.addEnchant(Enchantment.DURABILITY, 1, true);
|
||||
} else {
|
||||
this.meta.removeItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
this.meta.removeEnchant(Enchantment.DURABILITY);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addLineToLore(String line) {
|
||||
List<String> lore = this.meta.getLore();
|
||||
lore.add(FactionsPlugin.instance.color(line));
|
||||
this.meta.setLore(lore);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,13 @@ public class MiscUtil {
|
||||
public static ArrayList<String> validateTag(String str) {
|
||||
ArrayList<String> errors = new ArrayList<>();
|
||||
|
||||
for (String blacklistItem : Conf.blacklistedFactionNames) {
|
||||
if (str.toLowerCase().contains(blacklistItem.toLowerCase())) {
|
||||
errors.add(FactionsPlugin.instance.txt.parse(TL.GENERIC_FACTIONTAG_BLACKLIST.toString()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (getComparisonString(str).length() < Conf.factionTagLengthMin) {
|
||||
errors.add(FactionsPlugin.getInstance().txt.parse(TL.GENERIC_FACTIONTAG_TOOSHORT.toString(), Conf.factionTagLengthMin));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class RomanNumber {
|
||||
private static TreeMap<Integer, String> map;
|
||||
|
||||
static {
|
||||
(map = new TreeMap<>()).put(1000, "M");
|
||||
RomanNumber.map.put(900, "CM");
|
||||
RomanNumber.map.put(500, "D");
|
||||
RomanNumber.map.put(400, "CD");
|
||||
RomanNumber.map.put(100, "C");
|
||||
RomanNumber.map.put(90, "XC");
|
||||
RomanNumber.map.put(50, "L");
|
||||
RomanNumber.map.put(40, "XL");
|
||||
RomanNumber.map.put(10, "X");
|
||||
RomanNumber.map.put(9, "IX");
|
||||
RomanNumber.map.put(5, "V");
|
||||
RomanNumber.map.put(4, "IV");
|
||||
RomanNumber.map.put(1, "I");
|
||||
}
|
||||
|
||||
public static String toRoman(int number) {
|
||||
int l = RomanNumber.map.floorKey(number);
|
||||
if (number == l) {
|
||||
return RomanNumber.map.get(number);
|
||||
}
|
||||
return RomanNumber.map.get(l) + toRoman(number - l);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.massivecraft.factions.util.serializable;
|
||||
|
||||
public class InventoryUtils {
|
||||
private int x;
|
||||
private int y;
|
||||
private int rows;
|
||||
|
||||
public InventoryUtils(int x, int y, int rows) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.rows = rows;
|
||||
}
|
||||
|
||||
public void increment() {
|
||||
if (this.x == 9) {
|
||||
this.x = 0;
|
||||
++this.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.massivecraft.factions.util.serializable;
|
||||
|
||||
|
||||
import com.massivecraft.factions.util.ItemBuilder;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Item {
|
||||
private String name;
|
||||
private List<String> lore;
|
||||
private XMaterial material;
|
||||
private int amount;
|
||||
private int slot;
|
||||
|
||||
public Item(String name, List<String> lore, XMaterial material, int amount, int slot) {
|
||||
this.name = name;
|
||||
this.lore = lore;
|
||||
this.material = material;
|
||||
this.amount = amount;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public ItemStack buildItemStack(boolean isSelected) {
|
||||
return new ItemBuilder(material.parseItem()).name(name).lore(lore).glowing(isSelected).amount(amount).build();
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user