Changelog will be posted, add alot
This commit is contained in:
@@ -3,12 +3,13 @@ package com.massivecraft.factions.util;
|
||||
/**
|
||||
* @author Saser
|
||||
*/
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CC {
|
||||
public static String Black = ChatColor.BLACK.toString();
|
||||
public static String BlackB = ChatColor.BLACK + ChatColor.BOLD.toString();
|
||||
public static String BlackI = ChatColor.BLACK + ChatColor.ITALIC.toString();;
|
||||
public static String BlackI = ChatColor.BLACK + ChatColor.ITALIC.toString();
|
||||
public static String BlackU = ChatColor.BLACK + ChatColor.UNDERLINE.toString();
|
||||
public static String DarkBlue = ChatColor.DARK_BLUE.toString();
|
||||
public static String DarkBlueB = ChatColor.DARK_BLUE + ChatColor.BOLD.toString();
|
||||
|
||||
@@ -121,7 +121,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
||||
case "faction_description":
|
||||
return faction.getDescription();
|
||||
case "faction_claims":
|
||||
return fPlayer.hasFaction() ? String.valueOf(faction.getAllClaims().size()) : "0";
|
||||
return fPlayer.hasFaction() ? String.valueOf(faction.getAllClaims().size()) : "0";
|
||||
case "faction_maxclaims":
|
||||
return String.valueOf(Conf.claimedLandsMax);
|
||||
case "faction_founded":
|
||||
@@ -169,10 +169,28 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
||||
return Econ.shouldBeUsed() ? Econ.moneyString(Econ.getBalance(faction.getAccountId())) : TL.ECON_OFF.format("balance");
|
||||
case "faction_allies":
|
||||
return String.valueOf(faction.getRelationCount(Relation.ALLY));
|
||||
case "faction_allies_players":
|
||||
return String.valueOf(this.countOn(faction, Relation.ALLY, null, fPlayer));
|
||||
case "faction_allies_players_online":
|
||||
return String.valueOf(this.countOn(faction, Relation.ALLY, true, fPlayer));
|
||||
case "faction_allies_players_offline":
|
||||
return String.valueOf(this.countOn(faction, Relation.ALLY, false, fPlayer));
|
||||
case "faction_enemies":
|
||||
return String.valueOf(faction.getRelationCount(Relation.ENEMY));
|
||||
case "faction_enemies_players":
|
||||
return String.valueOf(this.countOn(faction, Relation.ENEMY, null, fPlayer));
|
||||
case "faction_enemies_players_online":
|
||||
return String.valueOf(this.countOn(faction, Relation.ENEMY, true, fPlayer));
|
||||
case "faction_enemies_players_offline":
|
||||
return String.valueOf(this.countOn(faction, Relation.ENEMY, false, fPlayer));
|
||||
case "faction_truces":
|
||||
return String.valueOf(faction.getRelationCount(Relation.TRUCE));
|
||||
case "faction_truces_players":
|
||||
return String.valueOf(this.countOn(faction, Relation.TRUCE, null, fPlayer));
|
||||
case "faction_truces_players_online":
|
||||
return String.valueOf(this.countOn(faction, Relation.TRUCE, true, fPlayer));
|
||||
case "faction_truces_players_offline":
|
||||
return String.valueOf(this.countOn(faction, Relation.TRUCE, false, fPlayer));
|
||||
case "faction_online":
|
||||
return String.valueOf(faction.getOnlinePlayers().size());
|
||||
case "faction_offline":
|
||||
@@ -187,6 +205,8 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
||||
return String.valueOf(faction.getDeaths());
|
||||
case "faction_maxvaults":
|
||||
return String.valueOf(faction.getMaxVaults());
|
||||
case "faction_relation_color":
|
||||
return fPlayer.getColorTo(faction).toString();
|
||||
case "faction_grace":
|
||||
return String.valueOf(Conf.gracePeriod);
|
||||
case "faction_name_at_location":
|
||||
@@ -196,4 +216,21 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private int countOn(Faction f, Relation relation, Boolean status, FPlayer player) {
|
||||
int count = 0;
|
||||
for (Faction faction : Factions.getInstance().getAllFactions()) {
|
||||
if (faction.getRelationTo(f) == relation) {
|
||||
if (status == null) {
|
||||
count += faction.getFPlayers().size();
|
||||
} else if (status) {
|
||||
count += faction.getFPlayersWhereOnline(true, player).size();
|
||||
} else {
|
||||
count += faction.getFPlayersWhereOnline(false, player).size();
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -38,8 +38,8 @@ public class FactionWarpsFrame {
|
||||
GUIItems.add(new GuiItem(buildDummyItem(), e -> e.setCancelled(true)));
|
||||
slots.forEach(slot -> GUIItems.set(slot, new GuiItem(XMaterial.AIR.parseItem())));
|
||||
for (final Map.Entry<String, LazyLocation> warp : fplayer.getFaction().getWarps().entrySet()) {
|
||||
if (slots.size() < fplayer.getFaction().getWarps().entrySet().size()){
|
||||
slots.add(slots.get(slots.size()-1)+1);
|
||||
if (slots.size() < fplayer.getFaction().getWarps().entrySet().size()) {
|
||||
slots.add(slots.get(slots.size() - 1) + 1);
|
||||
FactionsPlugin.instance.log("Automatically setting F WARP GUI slot since slot not specified. Head config.yml and add more entries in warp-slots section.");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ public class ItemBuilder {
|
||||
public ItemBuilder(Material material, int amount) {
|
||||
this(new ItemStack(material, amount));
|
||||
}
|
||||
|
||||
public ItemBuilder(Material material) {
|
||||
this(material, 1);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.massivecraft.factions.util;
|
||||
/**
|
||||
* @author Saser
|
||||
*/
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -24,7 +24,7 @@ public class ItemUtil {
|
||||
} else {
|
||||
int itemsFound = 0;
|
||||
|
||||
for(int i = 0; i < inventory.getSize(); ++i) {
|
||||
for (int i = 0; i < inventory.getSize(); ++i) {
|
||||
ItemStack item = inventory.getItem(i);
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
++itemsFound;
|
||||
@@ -41,7 +41,7 @@ public class ItemUtil {
|
||||
return skull.clone();
|
||||
} else {
|
||||
skull = new ItemStack(XMaterial.PLAYER_HEAD.parseMaterial());
|
||||
SkullMeta sm = (SkullMeta)skull.getItemMeta();
|
||||
SkullMeta sm = (SkullMeta) skull.getItemMeta();
|
||||
sm.setOwner(name);
|
||||
skull.setItemMeta(sm);
|
||||
cachedSkulls.put(name, skull.clone());
|
||||
|
||||
@@ -3,15 +3,14 @@ package com.massivecraft.factions.util;
|
||||
/**
|
||||
* @author Saser
|
||||
*/
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.massivecraft.factions.cmd.audit.FactionLogs;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
public class JSONUtils {
|
||||
public static Gson gson = (new GsonBuilder()).enableComplexMapKeySerialization().create();
|
||||
@@ -94,7 +93,7 @@ public class JSONUtils {
|
||||
}
|
||||
|
||||
private static Type getTypeFromObject(Object object) {
|
||||
return object instanceof Type ? (Type)object : getTypeFromClass(object.getClass());
|
||||
return object instanceof Type ? (Type) object : getTypeFromClass(object.getClass());
|
||||
}
|
||||
|
||||
private static Type getTypeFromClass(Class<?> clazz) {
|
||||
|
||||
@@ -5,18 +5,17 @@ package com.massivecraft.factions.util;
|
||||
*/
|
||||
public class Pair<Left, Right> {
|
||||
|
||||
public static <Left, Right> Pair<Left, Right> of(Left left, Right right) {
|
||||
return new Pair<>(left, right);
|
||||
}
|
||||
|
||||
private final Left left;
|
||||
private final Right right;
|
||||
|
||||
private Pair(Left left, Right right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
public static <Left, Right> Pair<Left, Right> of(Left left, Right right) {
|
||||
return new Pair<>(left, right);
|
||||
}
|
||||
|
||||
public Left getLeft() {
|
||||
return this.left;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
|
||||
public class Updater {
|
||||
public static double currentVersion = 1.1;
|
||||
|
||||
public static void updateIfNeeded(FileConfiguration conf) {
|
||||
double version = conf.getDouble("Config-Version", 0);
|
||||
//Previous version
|
||||
@@ -41,6 +42,8 @@ public class Updater {
|
||||
try {
|
||||
conf.save(new File("plugins/Factions/config.yml"));
|
||||
FactionsPlugin.getInstance().reloadConfig();
|
||||
} catch (IOException e) {e.printStackTrace();}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public class UtilFly {
|
||||
}
|
||||
}, 0, FactionsPlugin.getInstance().getConfig().getInt("fly-task-interval", 10));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||
@@ -45,6 +46,7 @@ public class UtilFly {
|
||||
|
||||
setFallDamage(fp, fly, damage);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void checkFly(FPlayer me, Faction factionTo) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||
|
||||
@@ -1803,7 +1803,8 @@ public enum XMaterial {
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getId() {
|
||||
if (this.data != 0 || (this.legacy.length != 0 && Integer.parseInt(this.legacy[0].substring(2)) >= 13)) return -1;
|
||||
if (this.data != 0 || (this.legacy.length != 0 && Integer.parseInt(this.legacy[0].substring(2)) >= 13))
|
||||
return -1;
|
||||
Material material = this.parseMaterial();
|
||||
return material == null ? -1 : material.getId();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.util.serializable;
|
||||
/**
|
||||
* @author Saser
|
||||
*/
|
||||
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.util.serializable;
|
||||
/**
|
||||
* @author Saser
|
||||
*/
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
@@ -10,14 +11,12 @@ import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -26,9 +25,9 @@ import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public abstract class GUIMenu {
|
||||
private static Map<UUID, GUIMenu> menus = new HashMap<>();
|
||||
protected Inventory menu;
|
||||
private Map<Integer, ClickableItemStack> menuItems = new HashMap<>();
|
||||
private static Map<UUID, GUIMenu> menus = new HashMap<>();
|
||||
private Consumer<InventoryCloseEvent> closeCallback;
|
||||
private String name;
|
||||
private int size;
|
||||
@@ -44,6 +43,14 @@ public abstract class GUIMenu {
|
||||
this.menu = Bukkit.createInventory(null, size, name);
|
||||
}
|
||||
|
||||
public static int fitSlots(int size) {
|
||||
return size <= 9 ? 9 : (size <= 18 ? 18 : (size <= 27 ? 27 : (size <= 36 ? 36 : (size <= 45 ? 45 : (size <= 54 ? 54 : 54)))));
|
||||
}
|
||||
|
||||
public static Map<UUID, GUIMenu> getMenus() {
|
||||
return menus;
|
||||
}
|
||||
|
||||
public void setInventorySize(int size) {
|
||||
if (this.size != size) {
|
||||
int oldSize = this.size;
|
||||
@@ -59,11 +66,6 @@ public abstract class GUIMenu {
|
||||
}
|
||||
}
|
||||
|
||||
public GUIMenu setPreviousMenu(GUIMenu menu) {
|
||||
this.previousMenu = menu;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setItem(int slot, ClickableItemStack item) {
|
||||
this.menu.setItem(slot, item);
|
||||
this.menuItems.put(slot, item);
|
||||
@@ -82,9 +84,9 @@ public abstract class GUIMenu {
|
||||
}
|
||||
|
||||
public ClickableItemStack getBackButton(Material data, String name, String... lore) {
|
||||
return (new ClickableItemStack(new ItemStack(data != null ? data : Material.RED_STAINED_GLASS_PANE, 1, data != null ? (short) 0 : 0 ))).setDisplayName(name != null ? name : ChatColor.RED + ChatColor.BOLD.toString() + "Back").setLore(lore != null ? Lists.newArrayList(lore) : Lists.newArrayList(ChatColor.GRAY + "Click to return to previous menu.")).setClickCallback((e) -> {
|
||||
return (new ClickableItemStack(new ItemStack(data != null ? data : Material.RED_STAINED_GLASS_PANE, 1, data != null ? (short) 0 : 0))).setDisplayName(name != null ? name : ChatColor.RED + ChatColor.BOLD.toString() + "Back").setLore(lore != null ? Lists.newArrayList(lore) : Lists.newArrayList(ChatColor.GRAY + "Click to return to previous menu.")).setClickCallback((e) -> {
|
||||
if (this.previousMenu != null) {
|
||||
this.previousMenu.open((Player)e.getWhoClicked());
|
||||
this.previousMenu.open((Player) e.getWhoClicked());
|
||||
}
|
||||
|
||||
});
|
||||
@@ -113,7 +115,7 @@ public abstract class GUIMenu {
|
||||
}
|
||||
|
||||
public void fillEmpty(ClickableItemStack item) {
|
||||
for(int i = 0; i < this.menu.getSize(); ++i) {
|
||||
for (int i = 0; i < this.menu.getSize(); ++i) {
|
||||
ItemStack is = this.menu.getItem(i);
|
||||
if (is == null || is.getType() == Material.AIR) {
|
||||
this.setItem(i, item);
|
||||
@@ -122,18 +124,10 @@ public abstract class GUIMenu {
|
||||
|
||||
}
|
||||
|
||||
public static int fitSlots(int size) {
|
||||
return size <= 9 ? 9 : (size <= 18 ? 18 : (size <= 27 ? 27 : (size <= 36 ? 36 : (size <= 45 ? 45 : (size <= 54 ? 54 : 54)))));
|
||||
}
|
||||
|
||||
public Map<Integer, ClickableItemStack> getMenuItems() {
|
||||
return this.menuItems;
|
||||
}
|
||||
|
||||
public static Map<UUID, GUIMenu> getMenus() {
|
||||
return menus;
|
||||
}
|
||||
|
||||
public Consumer<InventoryCloseEvent> getCloseCallback() {
|
||||
return this.closeCallback;
|
||||
}
|
||||
@@ -153,4 +147,9 @@ public abstract class GUIMenu {
|
||||
public GUIMenu getPreviousMenu() {
|
||||
return this.previousMenu;
|
||||
}
|
||||
|
||||
public GUIMenu setPreviousMenu(GUIMenu menu) {
|
||||
this.previousMenu = menu;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@ public class InventoryItem {
|
||||
this.item = original;
|
||||
}
|
||||
|
||||
public InventoryItem(ItemBuilder original) { this(original.build()); }
|
||||
public InventoryItem(ItemBuilder original) {
|
||||
this(original.build());
|
||||
}
|
||||
|
||||
public InventoryItem click(ClickType type, Runnable runnable) {
|
||||
this.clickMap.put(type, runnable);
|
||||
|
||||
Reference in New Issue
Block a user