Merge branch 'master' of git+ssh://git@github.com/dmulloy2/ChestShop-3.git

This commit is contained in:
Dan Mulloy 2016-11-21 11:42:24 -05:00
commit be96a17968
6 changed files with 41 additions and 42 deletions

View File

@ -6,6 +6,7 @@ import com.Acrobot.ChestShop.UUIDs.NameManager;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -20,11 +21,11 @@ import java.math.BigDecimal;
* @author Acrobot
*/
public class VaultListener implements Listener {
private final Economy provider;
private static Economy provider;
private VaultListener(Economy provider) {
this.provider = provider;
}
private VaultListener(Economy provider) { this.provider = provider; }
public static Economy getProvider() { return provider; }
public boolean transactionCanFail() {
return provider.getName().equals("Gringotts") || provider.getName().equals("GoldIsMoney") || provider.getName().equals("MultiCurrency");
@ -62,7 +63,8 @@ public class VaultListener implements Listener {
}
double balance = 0;
String lastSeen = NameManager.getLastSeenName(event.getAccount());
//String lastSeen = NameManager.getLastSeenName(event.getAccount());
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getAccount());
if (lastSeen != null) {
balance = provider.getBalance(lastSeen, event.getWorld().getName());
@ -82,7 +84,8 @@ public class VaultListener implements Listener {
}
World world = event.getWorld();
String lastSeen = NameManager.getLastSeenName(event.getAccount());
//String lastSeen = NameManager.getLastSeenName(event.getAccount());
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getAccount());
if (lastSeen != null) {
if (provider.has(lastSeen, world.getName(), event.getDoubleAmount())) {
@ -100,7 +103,9 @@ public class VaultListener implements Listener {
}
World world = event.getWorld();
String lastSeen = NameManager.getLastSeenName(event.getAccount());
//String lastSeen = NameManager.getLastSeenName(event.getAccount());
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getAccount());
event.hasAccount(lastSeen != null && provider.hasAccount(lastSeen, world.getName()));
}
@ -121,7 +126,8 @@ public class VaultListener implements Listener {
}
World world = event.getWorld();
String lastSeen = NameManager.getLastSeenName(event.getTarget());
//String lastSeen = NameManager.getLastSeenName(event.getTarget());
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getTarget());
if (lastSeen != null) {
provider.depositPlayer(lastSeen, world.getName(), event.getDoubleAmount());
@ -135,10 +141,11 @@ public class VaultListener implements Listener {
}
World world = event.getWorld();
String lastSeen = NameManager.getLastSeenName(event.getTarget());
//String lastSeen = NameManager.getLastSeenName(event.getTarget());
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getTarget());
if (lastSeen != null) {
provider.withdrawPlayer(NameManager.getLastSeenName(event.getTarget()), world.getName(), event.getDoubleAmount());
provider.withdrawPlayer(lastSeen, world.getName(), event.getDoubleAmount());
}
}
@ -165,7 +172,8 @@ public class VaultListener implements Listener {
return;
}
String lastSeen = NameManager.getLastSeenName(event.getAccount());
//String lastSeen = NameManager.getLastSeenName(event.getAccount());
OfflinePlayer lastSeen = Bukkit.getOfflinePlayer(event.getAccount());
String world = event.getWorld().getName();
if (lastSeen == null) {

View File

@ -6,6 +6,7 @@ import com.Acrobot.ChestShop.Configuration.Properties;
import com.Acrobot.ChestShop.Containers.AdminInventory;
import com.Acrobot.ChestShop.Events.PreTransactionEvent;
import com.Acrobot.ChestShop.Events.TransactionEvent;
import com.Acrobot.ChestShop.Listeners.Economy.Plugins.VaultListener;
import com.Acrobot.ChestShop.Permission;
import com.Acrobot.ChestShop.Plugins.ChestShop;
import com.Acrobot.ChestShop.Security;
@ -45,12 +46,11 @@ import static org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK;
public class PlayerInteract implements Listener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public static void onInteract(PlayerInteractEvent event) {
public static void onInteract(PlayerInteractEvent event)
{
Block block = event.getClickedBlock();
if (block == null) {
if (block == null)
return;
}
Action action = event.getAction();
Player player = event.getPlayer();
@ -68,12 +68,10 @@ public class PlayerInteract implements Listener {
return;
}
if (!isSign(block) || player.getItemInHand().getType() == Material.SIGN) { // Blocking accidental sign edition
if (!isSign(block) || player.getItemInHand().getType() == Material.SIGN) // Blocking accidental sign edition
return;
}
Sign sign = (Sign) block.getState();
if (!ChestShopSign.isValid(sign)) {
return;
}
@ -95,17 +93,14 @@ public class PlayerInteract implements Listener {
event.setCancelled(true);
}
//Bukkit.getLogger().info("ChestShop - DEBUG - "+block.getWorld().getName()+": "+block.getLocation().getBlockX()+", "+block.getLocation().getBlockY()+", "+block.getLocation().getBlockZ());
PreTransactionEvent pEvent = preparePreTransactionEvent(sign, player, action);
if (pEvent == null) {
if (pEvent == null)
return;
}
Bukkit.getPluginManager().callEvent(pEvent);
if (pEvent.isCancelled()) {
if (pEvent.isCancelled())
return;
}
TransactionEvent tEvent = new TransactionEvent(pEvent, sign);
Bukkit.getPluginManager().callEvent(tEvent);
@ -118,17 +113,19 @@ public class PlayerInteract implements Listener {
String material = sign.getLine(ITEM_LINE);
String ownerName = NameManager.getFullUsername(name);
if (ownerName == null || ownerName.isEmpty()) {
if (ownerName == null || ownerName.isEmpty())
return null;
}
UUID uuid = NameManager.getUUID(ownerName);
if (uuid == null) {
if (uuid == null)
return null;
}
OfflinePlayer owner = Bukkit.getOfflinePlayer(uuid);
// check if player exists in economy
if(!ChestShopSign.isAdminShop(sign) && (owner == null || owner.getName() == null || !VaultListener.getProvider().hasAccount(owner)))
return null;
Action buy = Properties.REVERSE_BUTTONS ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
double price = (action == buy ? PriceUtil.getBuyPrice(prices) : PriceUtil.getSellPrice(prices));
@ -136,7 +133,6 @@ public class PlayerInteract implements Listener {
Inventory ownerInventory = (ChestShopSign.isAdminShop(sign) ? new AdminInventory() : chest != null ? chest.getInventory() : null);
ItemStack item = MaterialUtil.getItem(material);
if (item == null || !NumberUtil.isInteger(quantity)) {
player.sendMessage(Messages.prefix(Messages.INVALID_SHOP_DETECTED));
return null;

View File

@ -25,7 +25,7 @@ public class EconomicModule implements Listener {
CurrencyAddEvent currencyAddEvent = new CurrencyAddEvent(BigDecimal.valueOf(event.getPrice()),
event.getOwner().getUniqueId(),
event.getSign().getWorld());
ChestShop.callEvent(currencyAddEvent);
ChestShop.callEvent(currencyAddEvent); // java.lang.StackOverflowError
CurrencySubtractEvent currencySubtractEvent = new CurrencySubtractEvent(BigDecimal.valueOf(event.getPrice()), event.getClient());
ChestShop.callEvent(currencySubtractEvent);

View File

@ -76,7 +76,10 @@ public class ItemDatabase {
* @param code Item code
* @return ItemStack represented by this code
*/
public ItemStack getFromCode(String code) {
public ItemStack getFromCode(String code)
{
// TODO java.lang.StackOverflowError - http://pastebin.com/eRD8wUFM - Corrupt item DB?
try {
int id = Base62.decode(code);
Item item = itemDao.queryBuilder().where().eq("id", id).queryForFirst();

View File

@ -205,6 +205,7 @@ public class NameManager {
account = new Account(player.getName(), player.getUniqueId());
if (!usernameToUUID.inverse().containsKey(uuid)) {
usernameToUUID.remove(player.getName()); // https://github.com/dmulloy2/ChestShop-3/issues/11
usernameToUUID.inverse().put(uuid, player.getName());
}

View File

@ -1,17 +1,8 @@
name: ChestShop
main: com.Acrobot.ChestShop.ChestShop
version: ${project.version}
#for CButD
dev-url: http://dev.bukkit.org/server-mods/chestshop/
author: Acrobot
description: >
A chest shop for economy plugins.
author: [Acrobot, dmulloy2, L4BORG]
description: A chest shop for economy plugins.
depend: [Vault]
softdepend: [LWC, Lockette, Deadbolt, OddItem, WorldGuard, Heroes, SimpleChestLock, Residence]