diff --git a/.classpath b/.classpath
index cdc6834..d2f7488 100644
--- a/.classpath
+++ b/.classpath
@@ -6,11 +6,6 @@
-
-
-
-
-
@@ -21,5 +16,10 @@
+
+
+
+
+
diff --git a/config.yml b/config.yml
index d972434..07a5bc3 100644
--- a/config.yml
+++ b/config.yml
@@ -32,6 +32,16 @@ Page_Price_Items:
#If you wish to cap the EnderBank page counts, simply put specific items for all
#the pages you wish to include, and then make the default item something unobtainable.
+Enable_Permission_Mode: false
+#If this is enabled, pages still can be bought like before, however they will now
+#ALSO require permission nodes. The permission node for players to be able to buy
+#pages is: 'enderbank.buypage.#'
+#You must add this permission for EACH page # the player is meant to be able to buy.
+
+Maximum_Pages_Allowed: -1
+#This is the maximum number of pages a player can buy.
+#Set it to -1 for there to be no maximum.
+
Must_Look_At_Chest_To_Search: true
#This makes it so players must be looking at an EnderChest
#to utilize the search feature, resulting in a "never left
@@ -83,6 +93,9 @@ Dump_Into_Inventory_Blacklist:
#id: DIRT (Required)
#amount: 1 (Optional)
#name: "Dirt" (Optional)
+#lore: (Optional)
+# - "Lore line 1" (Optional)
+# - "Lore line 2" (Optional)
#enchantments: (Optional)
# - "arrowdamage:1" (Optional)
# - "arrowfire:1" (Optional)
@@ -163,5 +176,5 @@ GUI:
# Version #
##########################################################
-VERSION: 7
+VERSION: 9
#Do not touch this. No touchy.
\ No newline at end of file
diff --git a/messages.yml b/messages.yml
new file mode 100644
index 0000000..bc6bdb5
--- /dev/null
+++ b/messages.yml
@@ -0,0 +1,15 @@
+Attempt_To_Purchase_More_Than_Max_Pages: "&l[&b&l!&f&l]&r You can't purchase that many pages!"
+Attempt_To_Purchase_More_Pages_Than_Perms: "&l[&b&l!&f&l]&r You don't have permission to purchase that many pages!"
+Attempt_To_Purchase_More_Pages_Without_Item: "&l[&b&l!&f&l]&r You don't have required items!"
+Attempt_To_Purchase_More_Pages_Without_Money: "&l[&b&l!&f&l]&r You don't have enough money!"
+
+Open_Inventory_Of_Offline_Player: "That player is not online. Opening last save of inventory."
+Open_Inventory_Player_Hasnt_Made_Yet: "That bank does not exist yet. The player must log in at least once."
+Open_Inventory_Not_Looking_At_Ender: "&l[&b&l!&f&l]&r You must be looking at an ender chest!"
+
+Missing_Perms: "&c&lYou are missing permissions!"
+
+Server_Disabled_Dump_Into_Inventory: "&l[&b&l!&f&l]&r The server has disabled this feature!"
+
+Search_In_Chat: "&l[&b&l?&f&l]&r Please search in chat.\nType 'cancel' to cancel."
+Search_Cancelled: "&l[&b&l!&f&l]&r Cancelled successfully."
\ No newline at end of file
diff --git a/plugin.yml b/plugin.yml
index a60b089..1d988a6 100644
--- a/plugin.yml
+++ b/plugin.yml
@@ -1,7 +1,7 @@
name: "EnderBank"
author: TheTealViper
-version: "1.15.2.b.4"
-api-version: 1.13
+version: "1.16.5.a.1"
+api-version: 1.16
description: "Bank system from popular RPG's."
main: me.TheTealViper.enderbank.EnderBank
commands:
diff --git a/spigot-1.14.4.jar b/spigot-1.14.4.jar
deleted file mode 100644
index 5ba8928..0000000
Binary files a/spigot-1.14.4.jar and /dev/null differ
diff --git a/src/me/TheTealViper/enderbank/BankStorage.java b/src/me/TheTealViper/enderbank/BankStorage.java
index d7d742f..2addda0 100644
--- a/src/me/TheTealViper/enderbank/BankStorage.java
+++ b/src/me/TheTealViper/enderbank/BankStorage.java
@@ -17,6 +17,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import me.TheTealViper.enderbank.utils.LoadItemstackFromConfig;
import me.TheTealViper.enderbank.utils.PluginFile;
+import me.TheTealViper.enderbank.utils.ViperStringUtils;
import net.milkbowl.vault.economy.Economy;
public class BankStorage {
@@ -101,6 +102,9 @@ public class BankStorage {
}
public void openPage(int page, Player opener) {
+ //Backup check to make sure bank has been made
+ BankStorage.getBank(bankOwnerUUID);
+
if(page == 1 && EnderBank.pf.getBoolean("Enable_Open_Bank_Noise")) {
if(EnderBank.pf.getBoolean("Open_Bank_Noise_Global")) {
opener.getWorld().playSound(opener.getLocation(), Sound.valueOf(EnderBank.pf.getString("Open_Bank_Noise")), 1, 1);
@@ -242,6 +246,20 @@ public class BankStorage {
@SuppressWarnings("deprecation")
public void attemptToPurchasePage(Economy econ, Player opener, Inventory inv) {
+ int maxPage = EnderBank.pf.getInt("Maximum_Pages_Allowed");
+ if(maxPage != -1 && unlockedPages >= maxPage) {
+ opener.sendMessage(ViperStringUtils.makeColors(EnderBank.formatString(EnderBank.messages.getString("Attempt_To_Purchase_More_Than_Max_Pages"), opener.getUniqueId())));
+// opener.sendMessage(EnderBank.notificationString + " You can't purchase that many pages!");
+ return;
+ }
+ if(EnderBank.pf.getBoolean("Enable_Permission_Mode")) {
+ if(!opener.hasPermission("enderbank.buypage." + (unlockedPages + 1))) {
+ opener.sendMessage(ViperStringUtils.makeColors(EnderBank.formatString(EnderBank.messages.getString("Attempt_To_Purchase_More_Pages_Than_Perms"), opener.getUniqueId())));
+// opener.sendMessage(EnderBank.notificationString + " You don't have permission to purchase that many pages!");
+ return;
+ }
+ }
+
if(EnderBank.pf.getBoolean("Use_Item_For_Page_Price")) {
ConfigurationSection sec = EnderBank.pf.contains("Page_Price_Items." + (lastOpenedPage+1)) ? EnderBank.pf.getConfigurationSection("Page_Price_Items." + (lastOpenedPage+1)) : EnderBank.pf.getConfigurationSection("Page_Price_Items.Default");
ItemStack itemRequiredForPay = new LoadItemstackFromConfig().getItem(sec);
@@ -254,13 +272,15 @@ public class BankStorage {
amountPlayerHas += i.getAmount();
}
if(amountPlayerHas < amountRequiredForPayment) {
- opener.sendMessage(EnderBank.notificationString + " You don't have required items!");
+ opener.sendMessage(ViperStringUtils.makeColors(EnderBank.formatString(EnderBank.messages.getString("Attempt_To_Purchase_More_Pages_Without_Item"), opener.getUniqueId())));
+// opener.sendMessage(EnderBank.notificationString + " You don't have required items!");
return;
}
//Check balance of player if funds also involved
if(!econ.has(opener.getName(), BankStorage.getPageCost(unlockedPages + 1))) {
- opener.sendMessage(EnderBank.notificationString + " You don't have enough money!");
+ opener.sendMessage(ViperStringUtils.makeColors(EnderBank.formatString(EnderBank.messages.getString("Attempt_To_Purchase_More_Pages_Without_Money"), opener.getUniqueId())));
+// opener.sendMessage(EnderBank.notificationString + " You don't have enough money!");
return;
}
@@ -289,7 +309,8 @@ public class BankStorage {
}else {
//Check balance of player if funds also involved
if(!econ.has(opener.getName(), BankStorage.getPageCost(unlockedPages + 1))) {
- opener.sendMessage(EnderBank.notificationString + " You don't have enough money!");
+ opener.sendMessage(ViperStringUtils.makeColors(EnderBank.formatString(EnderBank.messages.getString("Attempt_To_Purchase_More_Pages_Without_Money"), opener.getUniqueId())));
+// opener.sendMessage(EnderBank.notificationString + " You don't have enough money!");
return;
}
diff --git a/src/me/TheTealViper/enderbank/CustomItemHandler.java b/src/me/TheTealViper/enderbank/CustomItemHandler.java
index dde3762..af060a2 100644
--- a/src/me/TheTealViper/enderbank/CustomItemHandler.java
+++ b/src/me/TheTealViper/enderbank/CustomItemHandler.java
@@ -105,8 +105,7 @@ public class CustomItemHandler implements Listener{
ItemStack pageCostItem = null;
for(int i = 0;i < dummy.size();i++) {
String s = dummy.get(i);
- while(s.contains("%eb_pagecost%"))
- s = s.replace("%eb_pagecost%", BankStorage.getPageCost(bank.unlockedPages + 1) + "");
+ s = EnderBank.formatString(s, uuid);
while(s.contains("%eb_pagecostitemname%")) {
if(pageCostItem == null) {
if(BankStorage.pagePriceItems.containsKey(bank.unlockedPages + 1)) {
diff --git a/src/me/TheTealViper/enderbank/EnderBank.java b/src/me/TheTealViper/enderbank/EnderBank.java
index 4eb2876..0a59e67 100644
--- a/src/me/TheTealViper/enderbank/EnderBank.java
+++ b/src/me/TheTealViper/enderbank/EnderBank.java
@@ -1,5 +1,10 @@
package me.TheTealViper.enderbank;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -44,7 +49,7 @@ public class EnderBank extends JavaPlugin implements Listener {
public static String notificationString = ChatColor.BOLD + "[" + ChatColor.AQUA + ChatColor.BOLD + "!" + ChatColor.WHITE + ChatColor.BOLD + "]" + ChatColor.RESET
, questionString = ChatColor.BOLD + "[" + ChatColor.AQUA + ChatColor.BOLD + "?" + ChatColor.WHITE + ChatColor.BOLD + "]" + ChatColor.RESET;
private List disabledWorlds;
- public static PluginFile pf;
+ public static PluginFile pf, messages;
//Chat Queue (for asking which tracker you'd like to add)
public static Map> chatHandlerQueue = new HashMap>();
@@ -69,6 +74,21 @@ public class EnderBank extends JavaPlugin implements Listener {
//Load values from config
saveDefaultConfig();
pf = new PluginFile(this, "config.yml", "f.yml", false);
+ if(!new File("plugins/EnderBank/messages.yml").exists()) {
+ try {
+ InputStream inStream = getResource("messages.yml");
+ File targetFile = new File("plugins/EnderBank/messages.yml");
+ OutputStream outStream = new FileOutputStream(targetFile);
+ byte[] buffer = new byte[inStream.available()];
+ inStream.read(buffer);
+ outStream.write(buffer);
+ outStream.close();
+ inStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ messages = new PluginFile(this, "messages.yml", "f.yml", false);
//Set initial values
equipmentTypes.add(Material.CHAINMAIL_BOOTS);
@@ -115,6 +135,34 @@ public class EnderBank extends JavaPlugin implements Listener {
}
}
+ public void reloadProcedure() {
+// Do cleanup in case this is a reload
+ Bukkit.getServer().getScheduler().cancelTasks(this);
+
+ //Load values from config
+ pf.reload();
+ disabledWorlds = pf.contains("Disabled_Worlds") ? pf.getStringList("Disabled_Worlds") : new ArrayList();
+
+ BankStorage.dumpBlacklistedItems.clear();
+ ConfigurationSection mainSec = pf.getConfigurationSection("Dump_Into_Inventory_Blacklist");
+ for(String itemIdentifier : mainSec.getKeys(false)) {
+ ItemStack item = new LoadItemstackFromConfig().getItem(mainSec.getConfigurationSection(itemIdentifier));
+ BankStorage.dumpBlacklistedItems.add(item);
+ }
+
+ BankStorage.pagePriceItems.clear();
+ if(pf.getBoolean("Use_Item_For_Page_Price")) {
+ for(String pageIdentifier : pf.getConfigurationSection("Page_Price_Items").getKeys(false)) {
+ ItemStack item = new LoadItemstackFromConfig().getItem(pf.getConfigurationSection("Page_Price_Items." + pageIdentifier));
+ if(pageIdentifier.equalsIgnoreCase("default")) {
+ BankStorage.pagePriceItems.put(0, item);
+ }else {
+ BankStorage.pagePriceItems.put(Integer.valueOf(pageIdentifier), item);
+ }
+ }
+ }
+ }
+
public void onDisable() {
}
@@ -131,10 +179,14 @@ public class EnderBank extends JavaPlugin implements Listener {
warnmissingperms = true;
}
} else if(args.length == 1){
- if(p.hasPermission("enderbank.staff")){
- explain = true;
- }else
- warnmissingperms = true;
+ if(args[0].equalsIgnoreCase("reload")) {
+ if(p.hasPermission("enderbank.staff")){
+ p.sendMessage(EnderBank.notificationString + " Reloading...");
+ reloadProcedure();
+ p.sendMessage(EnderBank.notificationString + " Successfully reloaded!");
+ }else
+ warnmissingperms = true;
+ }
}else if(args.length == 2){
if(args[0].equalsIgnoreCase("open")){
if(p.hasPermission("enderbank.staff")) {
@@ -146,10 +198,12 @@ public class EnderBank extends JavaPlugin implements Listener {
BankStorage bank = BankStorage.getBank(oPlayerUUID);
bank.openPage(1, p);
if(!oPlayerOffline.isOnline()){
- p.sendMessage("That player is not online. Opening last save of inventory.");
+ p.sendMessage(ViperStringUtils.makeColors(formatString(messages.getString("Open_Inventory_Of_Offline_Player"), p.getUniqueId())));
+// p.sendMessage("That player is not online. Opening last save of inventory.");
}
}else {
- p.sendMessage("That bank does not exist yet. The player must sign in at least once.");
+ p.sendMessage(ViperStringUtils.makeColors(formatString(messages.getString("Open_Inventory_Player_Hasnt_Made_Yet"), p.getUniqueId())));
+// p.sendMessage("That bank does not exist yet. The player must sign in at least once.");
}
}else {
warnmissingperms = true;
@@ -164,11 +218,13 @@ public class EnderBank extends JavaPlugin implements Listener {
}
}
if(warnmissingperms) {
- p.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "You are missing permissions!");
+ p.sendMessage(ViperStringUtils.makeColors(formatString(messages.getString("Missing_Perms"), p.getUniqueId())));
+// p.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "You are missing permissions!");
}
if(!warnmissingperms && explain){
p.sendMessage("EnderBank Commands");
p.sendMessage("/enderbank open " + ChatColor.GRAY + " - Opens online player's inventory.");
+ p.sendMessage("/enderbank reload" + ChatColor.GRAY + " - Reloads configs.");
}
}else{
//Not a player
@@ -222,7 +278,8 @@ public class EnderBank extends JavaPlugin implements Listener {
e.setCancelled(true);
if(pf.getBoolean("Disable_Dump_Into_Inventory")) {
- e.getWhoClicked().sendMessage(EnderBank.notificationString + " The server has disabled this feature!");
+ e.getWhoClicked().sendMessage(ViperStringUtils.makeColors(formatString(messages.getString("Server_Disabled_Dump_Into_Inventory"), e.getWhoClicked().getUniqueId())));
+// e.getWhoClicked().sendMessage(EnderBank.notificationString + " The server has disabled this feature!");
return;
}
@@ -237,7 +294,8 @@ public class EnderBank extends JavaPlugin implements Listener {
e.setCancelled(true);
if(pf.getBoolean("Disable_Dump_Into_Inventory")) {
- e.getWhoClicked().sendMessage(EnderBank.notificationString + " The server has disabled this feature!");
+ e.getWhoClicked().sendMessage(ViperStringUtils.makeColors(formatString(messages.getString("Server_Disabled_Dump_Into_Inventory"), e.getWhoClicked().getUniqueId())));
+// e.getWhoClicked().sendMessage(EnderBank.notificationString + " The server has disabled this feature!");
return;
}
@@ -275,8 +333,9 @@ public class EnderBank extends JavaPlugin implements Listener {
queue.add("banksearch");
chatHandlerQueue.put(opener, queue);
- opener.sendMessage(EnderBank.questionString + " Please search in chat."
- + "\nType 'cancel' to cancel.");
+ opener.sendMessage(ViperStringUtils.makeColors(formatString(messages.getString("Search_In_Chat"), opener.getUniqueId())));
+// opener.sendMessage(EnderBank.questionString + " Please search in chat."
+// + "\nType 'cancel' to cancel.");
}else{
e.setCancelled(false);
}
@@ -337,16 +396,6 @@ public class EnderBank extends JavaPlugin implements Listener {
@EventHandler
public void onChat(AsyncPlayerChatEvent e) {
Player p = e.getPlayer();
- //DEBUG
- Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {public void run() {
- Map dummy = new HashMap(BankStorage.pagePriceItems);
- for(int pageID : dummy.keySet()) {
- Bukkit.broadcastMessage(pageID + " : " + BankStorage.pagePriceItems.get(pageID));
- }
- p.getWorld().dropItem(p.getLocation(), BankStorage.pagePriceItems.get(2));
- Bukkit.broadcastMessage(pf.getStringList("Page_Price_Items.Default.lore").get(0));
- }}, 1);
- //
if(!chatHandlerQueue.containsKey(p))
return;
List queue = chatHandlerQueue.get(p);
@@ -356,7 +405,8 @@ public class EnderBank extends JavaPlugin implements Listener {
if(e.getMessage().equalsIgnoreCase("cancel")) {
queue.remove(queue.size() - 1);
e.setCancelled(true);
- p.sendMessage(EnderBank.notificationString + " Cancelled successfully.");
+ p.sendMessage(ViperStringUtils.makeColors(formatString(messages.getString("Search_Cancelled"), p.getUniqueId())));
+// p.sendMessage(EnderBank.notificationString + " Cancelled successfully.");
return;
}
if(handler.equals("banksearch")) {
@@ -368,10 +418,23 @@ public class EnderBank extends JavaPlugin implements Listener {
BankStorage bank = BankStorage.searchDatabase.get(p);
bank.openSearch(search, p);
}else {
- p.sendMessage(EnderBank.notificationString + " You must be looking at an ender chest!");
+ p.sendMessage(ViperStringUtils.makeColors(formatString(messages.getString("Open_Inventory_Not_Looking_At_Ender"), p.getUniqueId())));
+// p.sendMessage(EnderBank.notificationString + " You must be looking at an ender chest!");
}
BankStorage.searchDatabase.remove(p);
}
}
+ //Handles general formatting stuff
+ public static String formatString(String s, UUID uuid) {
+ BankStorage bank = BankStorage.getBank(uuid);
+ while(s.contains("%eb_pagecost%"))
+ s = s.replace("%eb_pagecost%", BankStorage.getPageCost(bank.unlockedPages + 1) + "");
+ while(s.contains("%eb_currentpage%"))
+ s = s.replace("%eb_currentpage%", bank.lastOpenedPage + "");
+ while(s.contains("%eb_playername%"))
+ s = s.replace("%eb_playername%", Bukkit.getPlayer(uuid).getName());
+ return s;
+ }
+
}
diff --git a/src/me/TheTealViper/enderbank/utils/LoadItemstackFromConfig.java b/src/me/TheTealViper/enderbank/utils/LoadItemstackFromConfig.java
index 4185b4c..3534253 100644
--- a/src/me/TheTealViper/enderbank/utils/LoadItemstackFromConfig.java
+++ b/src/me/TheTealViper/enderbank/utils/LoadItemstackFromConfig.java
@@ -6,7 +6,6 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
-import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.craftbukkit.libs.org.apache.commons.codec.binary.Base64;
@@ -173,7 +172,6 @@ public class LoadItemstackFromConfig {
meta = skullMeta;
break;
case "vanilladurability":
- Bukkit.broadcastMessage("changing durability: " + value);
Damageable dam = (Damageable) meta;
dam.setDamage(Integer.valueOf(value));
meta = (ItemMeta) dam;