Showing Dropping Anvil Something (Ignore)
This commit is contained in:
@@ -9,26 +9,26 @@ import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdShop extends FCommand {
|
||||
|
||||
public CmdShop() {
|
||||
super();
|
||||
this.aliases.add("shop");
|
||||
this.requirements = new CommandRequirements.Builder(Permission.SHOP)
|
||||
.memberOnly()
|
||||
.playerOnly()
|
||||
.build();
|
||||
}
|
||||
public CmdShop() {
|
||||
super();
|
||||
this.aliases.add("shop");
|
||||
this.requirements = new CommandRequirements.Builder(Permission.SHOP)
|
||||
.memberOnly()
|
||||
.playerOnly()
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled")) {
|
||||
return;
|
||||
}
|
||||
ShopGUI.openShop(context.fPlayer);
|
||||
}
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("F-Shop.Enabled")) {
|
||||
return;
|
||||
}
|
||||
ShopGUI.openShop(context.fPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,75 +18,75 @@ import java.util.List;
|
||||
|
||||
public class ShopClickPersistence implements Listener {
|
||||
|
||||
public static String color(String line) {
|
||||
line = ChatColor.translateAlternateColorCodes('&', line);
|
||||
return line;
|
||||
}
|
||||
public static String color(String line) {
|
||||
line = ChatColor.translateAlternateColorCodes('&', line);
|
||||
return line;
|
||||
}
|
||||
|
||||
public static List<String> colorList(List<String> lore) {
|
||||
for (int i = 0; i <= lore.size() - 1; i++) {
|
||||
lore.set(i, color(lore.get(i)));
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
public static List<String> colorList(List<String> lore) {
|
||||
for (int i = 0; i <= lore.size() - 1; i++) {
|
||||
lore.set(i, color(lore.get(i)));
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
|
||||
public void runCommands(List<String> list, Player p) {
|
||||
for (String cmd : list) {
|
||||
cmd = cmd.replace("%player%", p.getName());
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
}
|
||||
public void runCommands(List<String> list, Player p) {
|
||||
for (String cmd : list) {
|
||||
cmd = cmd.replace("%player%", p.getName());
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void click(InventoryClickEvent e) {
|
||||
Inventory i = e.getClickedInventory();
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
FileConfiguration config = FactionsPlugin.getInstance().getConfig();
|
||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(p);
|
||||
@EventHandler
|
||||
public void click(InventoryClickEvent e) {
|
||||
Inventory i = e.getClickedInventory();
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
FileConfiguration config = FactionsPlugin.getInstance().getConfig();
|
||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(p);
|
||||
|
||||
if (e.getView().getTitle().equalsIgnoreCase(color(config.getString("F-Shop.GUI.Name")))) {
|
||||
ItemStack item = e.getCurrentItem();
|
||||
if (item == null) return;
|
||||
String name = color(item.getItemMeta().getDisplayName());
|
||||
e.setCancelled(true);
|
||||
int t = e.getSlot();
|
||||
int items = ShopConfig.getShop().getConfigurationSection("items").getKeys(false).size();
|
||||
for (int a = 1; a <= items; a++) {
|
||||
String s = a + "";
|
||||
int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
|
||||
if (t == slot) {
|
||||
String n = ShopConfig.getShop().getString("items." + s + ".name");
|
||||
if (name.contains(color(n))) {
|
||||
String c = ChatColor.stripColor(color(name));
|
||||
c = c.replace(ChatColor.stripColor(color(n)), "");
|
||||
c = c.replace(color(" ("), "");
|
||||
c = c.replace(color(" Points)"), "");
|
||||
int cost = Integer.parseInt(c);
|
||||
if (fplayer.getFaction().getPoints() >= cost) {
|
||||
if (e.getView().getTitle().equalsIgnoreCase(color(config.getString("F-Shop.GUI.Name")))) {
|
||||
ItemStack item = e.getCurrentItem();
|
||||
if (item == null) return;
|
||||
String name = color(item.getItemMeta().getDisplayName());
|
||||
e.setCancelled(true);
|
||||
int t = e.getSlot();
|
||||
int items = ShopConfig.getShop().getConfigurationSection("items").getKeys(false).size();
|
||||
for (int a = 1; a <= items; a++) {
|
||||
String s = a + "";
|
||||
int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
|
||||
if (t == slot) {
|
||||
String n = ShopConfig.getShop().getString("items." + s + ".name");
|
||||
if (name.contains(color(n))) {
|
||||
String c = ChatColor.stripColor(color(name));
|
||||
c = c.replace(ChatColor.stripColor(color(n)), "");
|
||||
c = c.replace(color(" ("), "");
|
||||
c = c.replace(color(" Points)"), "");
|
||||
int cost = Integer.parseInt(c);
|
||||
if (fplayer.getFaction().getPoints() >= cost) {
|
||||
|
||||
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
|
||||
runCommands(ShopConfig.getShop().getStringList("items." + s + ".cmds"), fplayer.getPlayer());
|
||||
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) {
|
||||
// if (fplayer == fme) { continue; } //Idk if I wanna not send the title to the player
|
||||
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString()
|
||||
.replace("{player}", fplayer.getPlayer().getName())
|
||||
.replace("{item}", name));
|
||||
}
|
||||
fplayer.sendMessage(color(ShopConfig.getShop().getString("prefix").replace("%item%", n).replace("%points%", cost + "")));
|
||||
p.closeInventory();
|
||||
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
|
||||
runCommands(ShopConfig.getShop().getStringList("items." + s + ".cmds"), fplayer.getPlayer());
|
||||
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) {
|
||||
// if (fplayer == fme) { continue; } //Idk if I wanna not send the title to the player
|
||||
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString()
|
||||
.replace("{player}", fplayer.getPlayer().getName())
|
||||
.replace("{item}", name));
|
||||
}
|
||||
fplayer.sendMessage(color(ShopConfig.getShop().getString("prefix").replace("%item%", n).replace("%points%", cost + "")));
|
||||
p.closeInventory();
|
||||
|
||||
} else {
|
||||
fplayer.sendMessage(TL.SHOP_NOT_ENOUGH_POINTS.toString());
|
||||
p.closeInventory();
|
||||
}
|
||||
} else {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
} else {
|
||||
fplayer.sendMessage(TL.SHOP_NOT_ENOUGH_POINTS.toString());
|
||||
p.closeInventory();
|
||||
}
|
||||
} else {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,47 +9,47 @@ import java.util.ArrayList;
|
||||
|
||||
public class ShopConfig {
|
||||
|
||||
//TODO: Shop YAML Converter mySQL
|
||||
//TODO: Shop YAML Converter mySQL
|
||||
|
||||
public static File shop = new File("plugins/Factions/shop.yml");
|
||||
public static FileConfiguration s = YamlConfiguration.loadConfiguration(shop);
|
||||
public static File shop = new File("plugins/Factions/shop.yml");
|
||||
public static FileConfiguration s = YamlConfiguration.loadConfiguration(shop);
|
||||
|
||||
public static FileConfiguration getShop() {
|
||||
return s;
|
||||
}
|
||||
public static FileConfiguration getShop() {
|
||||
return s;
|
||||
}
|
||||
|
||||
public static void loadShop() {
|
||||
s = YamlConfiguration.loadConfiguration(shop);
|
||||
}
|
||||
public static void loadShop() {
|
||||
s = YamlConfiguration.loadConfiguration(shop);
|
||||
}
|
||||
|
||||
public static void saveShop() {
|
||||
try {
|
||||
getShop().save(shop);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void saveShop() {
|
||||
try {
|
||||
getShop().save(shop);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setup() {
|
||||
if (!shop.exists()) {
|
||||
try {
|
||||
shop.createNewFile();
|
||||
getShop().set("prefix", "&4&lFactionShop&8» &7Purchased &f%item% &7for &b%points% Points&7!");
|
||||
getShop().set("items.1.slot", 1);
|
||||
getShop().set("items.1.block", "STONE");
|
||||
getShop().set("items.1.name", "&aTest Shop");
|
||||
ArrayList lore = new ArrayList();
|
||||
lore.add("&cFully Customizable Lore!");
|
||||
getShop().set("items.1.lore", lore);
|
||||
ArrayList t = new ArrayList();
|
||||
t.add("broadcast %player% bought Test Shop!");
|
||||
getShop().set("items.1.cmds", t);
|
||||
getShop().set("items.1.cost", 5);
|
||||
getShop().set("items.1.glowing", true);
|
||||
saveShop();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void setup() {
|
||||
if (!shop.exists()) {
|
||||
try {
|
||||
shop.createNewFile();
|
||||
getShop().set("prefix", "&4&lFactionShop&8» &7Purchased &f%item% &7for &b%points% Points&7!");
|
||||
getShop().set("items.1.slot", 1);
|
||||
getShop().set("items.1.block", "STONE");
|
||||
getShop().set("items.1.name", "&aTest Shop");
|
||||
ArrayList lore = new ArrayList();
|
||||
lore.add("&cFully Customizable Lore!");
|
||||
getShop().set("items.1.lore", lore);
|
||||
ArrayList t = new ArrayList();
|
||||
t.add("broadcast %player% bought Test Shop!");
|
||||
getShop().set("items.1.cmds", t);
|
||||
getShop().set("items.1.cost", 5);
|
||||
getShop().set("items.1.glowing", true);
|
||||
saveShop();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,79 +22,79 @@ public class ShopGUI {
|
||||
Made simplistic format for shop for the time being until I get time.
|
||||
*/
|
||||
|
||||
public static void openShop(FPlayer p) {
|
||||
FileConfiguration config = FactionsPlugin.getInstance().getConfig();
|
||||
Faction fac = p.getFaction();
|
||||
public static void openShop(FPlayer p) {
|
||||
FileConfiguration config = FactionsPlugin.getInstance().getConfig();
|
||||
Faction fac = p.getFaction();
|
||||
|
||||
Inventory i = Bukkit.createInventory(null, FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Size"), color(config.getString("F-Shop.GUI.Name")));
|
||||
ItemStack glass = new ItemStack(XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial(), 1, (short) 7);
|
||||
ItemMeta glassmeta = glass.getItemMeta();
|
||||
glassmeta.setDisplayName(ChatColor.GOLD + " ");
|
||||
glass.setItemMeta(glassmeta);
|
||||
Inventory i = Bukkit.createInventory(null, FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Size"), color(config.getString("F-Shop.GUI.Name")));
|
||||
ItemStack glass = new ItemStack(XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial(), 1, (short) 7);
|
||||
ItemMeta glassmeta = glass.getItemMeta();
|
||||
glassmeta.setDisplayName(ChatColor.GOLD + " ");
|
||||
glass.setItemMeta(glassmeta);
|
||||
|
||||
for (int fill = 0; fill < FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Size"); ++fill) {
|
||||
i.setItem(fill, glass);
|
||||
}
|
||||
for (int fill = 0; fill < FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Size"); ++fill) {
|
||||
i.setItem(fill, glass);
|
||||
}
|
||||
|
||||
int items = ShopConfig.getShop().getConfigurationSection("items").getKeys(false).size();
|
||||
for (int shopitems = 1; shopitems <= items; shopitems++) {
|
||||
String s = shopitems + "";
|
||||
int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
|
||||
ItemStack material = XMaterial.matchXMaterial(ShopConfig.getShop().getString("items." + s + ".block")).parseItem();
|
||||
// int size = ShopConfig.getShop().getInt("items." + s + ".size");
|
||||
int cost = ShopConfig.getShop().getInt("items." + s + ".cost");
|
||||
String name = ShopConfig.getShop().getString("items." + s + ".name") + " &f(" + cost + " Points)";
|
||||
List<String> lore = ShopConfig.getShop().getStringList("items." + s + ".lore");
|
||||
String command = ShopConfig.getShop().getString("items." + s + ".cmd");
|
||||
String type = ShopConfig.getShop().getString("items." + s + ".type");
|
||||
boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing");
|
||||
int items = ShopConfig.getShop().getConfigurationSection("items").getKeys(false).size();
|
||||
for (int shopitems = 1; shopitems <= items; shopitems++) {
|
||||
String s = shopitems + "";
|
||||
int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
|
||||
ItemStack material = XMaterial.matchXMaterial(ShopConfig.getShop().getString("items." + s + ".block")).parseItem();
|
||||
// int size = ShopConfig.getShop().getInt("items." + s + ".size");
|
||||
int cost = ShopConfig.getShop().getInt("items." + s + ".cost");
|
||||
String name = ShopConfig.getShop().getString("items." + s + ".name") + " &f(" + cost + " Points)";
|
||||
List<String> lore = ShopConfig.getShop().getStringList("items." + s + ".lore");
|
||||
String command = ShopConfig.getShop().getString("items." + s + ".cmd");
|
||||
String type = ShopConfig.getShop().getString("items." + s + ".type");
|
||||
boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing");
|
||||
|
||||
|
||||
ItemStack count = new ItemStack(XMaterial.PAPER.parseMaterial(), 1);
|
||||
ItemMeta countmeta = count.getItemMeta();
|
||||
countmeta.setDisplayName(color(config.getString("F-Shop.GUI.Information.name")));
|
||||
List<String> PointInfo = new LinkedList<>();
|
||||
for (String list : config.getStringList("F-Shop.GUI.Information.lore")) {
|
||||
PointInfo.add(list.replace("%points%", fac.getPoints() + ""));
|
||||
}
|
||||
countmeta.setLore(colorList(PointInfo));
|
||||
count.setItemMeta(countmeta);
|
||||
i.setItem(FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Information.slot"), count);
|
||||
ItemStack count = new ItemStack(XMaterial.PAPER.parseMaterial(), 1);
|
||||
ItemMeta countmeta = count.getItemMeta();
|
||||
countmeta.setDisplayName(color(config.getString("F-Shop.GUI.Information.name")));
|
||||
List<String> PointInfo = new LinkedList<>();
|
||||
for (String list : config.getStringList("F-Shop.GUI.Information.lore")) {
|
||||
PointInfo.add(list.replace("%points%", fac.getPoints() + ""));
|
||||
}
|
||||
countmeta.setLore(colorList(PointInfo));
|
||||
count.setItemMeta(countmeta);
|
||||
i.setItem(FactionsPlugin.getInstance().getConfig().getInt("F-Shop.GUI.Information.slot"), count);
|
||||
|
||||
ItemStack item = new ItemStack(material);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(color(name));
|
||||
meta.addItemFlags();
|
||||
ItemStack item = new ItemStack(material);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(color(name));
|
||||
meta.addItemFlags();
|
||||
|
||||
if (glowing) {
|
||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
meta.addEnchant(Enchantment.DURABILITY, 1, true);
|
||||
}
|
||||
if (!glowing) {
|
||||
meta.removeEnchant(Enchantment.DURABILITY);
|
||||
}
|
||||
if (glowing) {
|
||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
meta.addEnchant(Enchantment.DURABILITY, 1, true);
|
||||
}
|
||||
if (!glowing) {
|
||||
meta.removeEnchant(Enchantment.DURABILITY);
|
||||
}
|
||||
|
||||
if (lore.contains("")) {
|
||||
meta.setLore(null);
|
||||
} else {
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(lore));
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
i.setItem(slot, item);
|
||||
}
|
||||
p.getPlayer().openInventory(i);
|
||||
}
|
||||
if (lore.contains("")) {
|
||||
meta.setLore(null);
|
||||
} else {
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(lore));
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
i.setItem(slot, item);
|
||||
}
|
||||
p.getPlayer().openInventory(i);
|
||||
}
|
||||
|
||||
public static String color(String line) {
|
||||
line = ChatColor.translateAlternateColorCodes('&', line);
|
||||
return line;
|
||||
}
|
||||
public static String color(String line) {
|
||||
line = ChatColor.translateAlternateColorCodes('&', line);
|
||||
return line;
|
||||
}
|
||||
|
||||
public static List<String> colorList(List<String> lore) {
|
||||
for (int i = 0; i <= lore.size() - 1; i++) {
|
||||
lore.set(i, color(lore.get(i)));
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
public static List<String> colorList(List<String> lore) {
|
||||
for (int i = 0; i <= lore.size() - 1; i++) {
|
||||
lore.set(i, color(lore.get(i)));
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user