mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 01:49:49 -05:00
Code cleanup
Former-commit-id: 42b801b371bbadc235e5517bc27d20a4cb5abe15 Former-commit-id: c179d5721b60d4a87f6258d8962f139cc93201ad
This commit is contained in:
1 parent
7ea44312c3
commit
1b565feff4
25 files changed
+116
-117
No files matched your search
@@ -30,7 +30,7 @@ public class SubCommand_CleanGhost implements CommandProcesser {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!cmdArg[0].equalsIgnoreCase("confirm")){
|
||||
if(!"confirm".equalsIgnoreCase(cmdArg[0])){
|
||||
sender.sendMessage(ChatColor.YELLOW+"This command will purge all data damaged shop, create in disallow world shop, create disallow sell items shop and IN NOT LOADED WORLD SHOPS, make sure you have backup your shops data, and use /qs cleanghost confirm to continue.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Database {
|
||||
@@ -76,7 +77,7 @@ public class Database {
|
||||
return; // go way!
|
||||
}
|
||||
String finalTable;
|
||||
if (table.startsWith(prefix)) {
|
||||
if (table.startsWith(Objects.requireNonNull(prefix))) {
|
||||
finalTable = table;
|
||||
} else {
|
||||
finalTable = prefix + table;
|
||||
|
||||
@@ -9,17 +9,13 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Queue;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
/**
|
||||
* A Util to execute all SQLs.
|
||||
*/
|
||||
public class DatabaseHelper {
|
||||
|
||||
private final Queue<PreparedStatement> sqlQueue = new LinkedBlockingQueue<>();
|
||||
|
||||
@NotNull
|
||||
private final Database db;
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ public class DatabaseManager {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
Util.debugLog("Executing the SQL task: " + statement.toString());
|
||||
Util.debugLog("Executing the SQL task: " + statement);
|
||||
statement.execute();
|
||||
} catch (SQLException sqle) {
|
||||
plugin.getSentryErrorReporter().ignoreThrow();
|
||||
|
||||
@@ -87,6 +87,7 @@ public class MySQLCore implements DatabaseCore {
|
||||
// Else, it is invalid, so we return another connection.
|
||||
}
|
||||
connection = DriverManager.getConnection(this.url, info);
|
||||
|
||||
POOL.set(i, connection);
|
||||
return connection;
|
||||
} catch (SQLException e) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -67,7 +68,7 @@ public class Economy_Reserve implements EconomyCore {
|
||||
@Override
|
||||
public String format(double balance) {
|
||||
try {
|
||||
return reserve.format(new BigDecimal(balance));
|
||||
return Objects.requireNonNull(reserve).format(new BigDecimal(balance));
|
||||
} catch (Throwable throwable) {
|
||||
plugin.getSentryErrorReporter().ignoreThrow();
|
||||
throwable.printStackTrace();
|
||||
@@ -86,7 +87,7 @@ public class Economy_Reserve implements EconomyCore {
|
||||
@Override
|
||||
public boolean deposit(UUID name, double amount) {
|
||||
try {
|
||||
return reserve.addHoldings(name, new BigDecimal(amount));
|
||||
return Objects.requireNonNull(reserve).addHoldings(name, new BigDecimal(amount));
|
||||
} catch (Throwable throwable) {
|
||||
plugin.getSentryErrorReporter().ignoreThrow();
|
||||
throwable.printStackTrace();
|
||||
@@ -110,7 +111,7 @@ public class Economy_Reserve implements EconomyCore {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return reserve.removeHoldings(name, new BigDecimal(amount));
|
||||
return Objects.requireNonNull(reserve).removeHoldings(name, new BigDecimal(amount));
|
||||
} catch (Throwable throwable) {
|
||||
plugin.getSentryErrorReporter().ignoreThrow();
|
||||
throwable.printStackTrace();
|
||||
@@ -130,7 +131,7 @@ public class Economy_Reserve implements EconomyCore {
|
||||
@Override
|
||||
public boolean transfer(UUID from, UUID to, double amount) {
|
||||
try {
|
||||
return reserve.transferHoldings(from, to, new BigDecimal(amount));
|
||||
return Objects.requireNonNull(reserve).transferHoldings(from, to, new BigDecimal(amount));
|
||||
} catch (Throwable throwable) {
|
||||
plugin.getSentryErrorReporter().ignoreThrow();
|
||||
throwable.printStackTrace();
|
||||
@@ -148,7 +149,7 @@ public class Economy_Reserve implements EconomyCore {
|
||||
@Override
|
||||
public double getBalance(UUID name) {
|
||||
try {
|
||||
return reserve.getHoldings(name).doubleValue();
|
||||
return Objects.requireNonNull(reserve).getHoldings(name).doubleValue();
|
||||
} catch (Throwable throwable) {
|
||||
plugin.getSentryErrorReporter().ignoreThrow();
|
||||
throwable.printStackTrace();
|
||||
|
||||
@@ -33,8 +33,7 @@ public class InternalListener implements Listener {
|
||||
if (ListenerHelper.isDisabled(event.getClass())) {
|
||||
return;
|
||||
}
|
||||
plugin.log("Shop at location " + event.getShop().getLocation() + " moderator was changed to " + event.getModerator()
|
||||
.toString());
|
||||
plugin.log("Shop at location " + event.getShop().getLocation() + " moderator was changed to " + event.getModerator());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
|
||||
@@ -59,8 +59,7 @@ public class DisplayProtectionListener implements Listener {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
sendAlert("[DisplayGuard] Liuqid " + targetBlock.getLocation()
|
||||
.toString() + " trying flow to top of shop, QuickShop already cancel it.");
|
||||
sendAlert("[DisplayGuard] Liuqid " + targetBlock.getLocation() + " trying flow to top of shop, QuickShop already cancel it.");
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
@@ -91,8 +90,7 @@ public class DisplayProtectionListener implements Listener {
|
||||
Shop shop = plugin.getShopManager().getShopIncludeAttached(block.getLocation());
|
||||
if (shop != null) {
|
||||
event.setCancelled(true);
|
||||
sendAlert("[DisplayGuard] Piston " + event.getBlock().getLocation()
|
||||
.toString() + " trying push somethings on the shop top, QuickShop already cancel it.");
|
||||
sendAlert("[DisplayGuard] Piston " + event.getBlock().getLocation() + " trying push somethings on the shop top, QuickShop already cancel it.");
|
||||
return;
|
||||
}
|
||||
for (Block oBlock : event.getBlocks()) {
|
||||
@@ -101,8 +99,7 @@ public class DisplayProtectionListener implements Listener {
|
||||
shop = plugin.getShopManager().getShopIncludeAttached(otherBlock.getLocation());
|
||||
if (shop != null) {
|
||||
event.setCancelled(true);
|
||||
sendAlert("[DisplayGuard] Piston " + event.getBlock().getLocation()
|
||||
.toString() + " trying push somethings on the shop top, QuickShop already cancel it.");
|
||||
sendAlert("[DisplayGuard] Piston " + event.getBlock().getLocation() + " trying push somethings on the shop top, QuickShop already cancel it.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -121,8 +118,7 @@ public class DisplayProtectionListener implements Listener {
|
||||
Shop shop = plugin.getShopManager().getShopIncludeAttached(block.getLocation());
|
||||
if (shop != null) {
|
||||
event.setCancelled(true);
|
||||
sendAlert("[DisplayGuard] Piston " + event.getBlock().getLocation()
|
||||
.toString() + " trying pull somethings on the shop top, QuickShop already cancel it.");
|
||||
sendAlert("[DisplayGuard] Piston " + event.getBlock().getLocation() + " trying pull somethings on the shop top, QuickShop already cancel it.");
|
||||
return;
|
||||
}
|
||||
for (Block oBlock : event.getBlocks()) {
|
||||
@@ -131,8 +127,7 @@ public class DisplayProtectionListener implements Listener {
|
||||
shop = plugin.getShopManager().getShopIncludeAttached(otherBlock.getLocation());
|
||||
if (shop != null) {
|
||||
event.setCancelled(true);
|
||||
sendAlert("[DisplayGuard] Piston " + event.getBlock().getLocation()
|
||||
.toString() + " trying push somethings on the shop top, QuickShop already cancel it.");
|
||||
sendAlert("[DisplayGuard] Piston " + event.getBlock().getLocation() + " trying push somethings on the shop top, QuickShop already cancel it.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -150,7 +145,7 @@ public class DisplayProtectionListener implements Listener {
|
||||
ItemStack itemStack = event.getFuel();
|
||||
if (DisplayItem.checkIsGuardItemStack(itemStack)) {
|
||||
event.setCancelled(true);
|
||||
sendAlert("[DisplayGuard] Block " + event.getBlock().getLocation().toString()
|
||||
sendAlert("[DisplayGuard] Block " + event.getBlock().getLocation()
|
||||
+ " trying fuel the BrewingStand with DisplayItem.");
|
||||
}
|
||||
}
|
||||
@@ -169,7 +164,7 @@ public class DisplayProtectionListener implements Listener {
|
||||
Block furnace = event.getBlock();
|
||||
if (furnace.getState() instanceof Furnace) {
|
||||
Furnace furnace1 = (Furnace) furnace.getState();
|
||||
sendAlert("[DisplayGuard] Block " + event.getBlock().getLocation().toString()
|
||||
sendAlert("[DisplayGuard] Block " + event.getBlock().getLocation()
|
||||
+ " trying burn with DisplayItem.");
|
||||
Util.inventoryCheck(furnace1.getInventory());
|
||||
}
|
||||
@@ -190,7 +185,7 @@ public class DisplayProtectionListener implements Listener {
|
||||
Block furnace = event.getBlock();
|
||||
if (furnace.getState() instanceof Furnace) {
|
||||
Furnace furnace1 = (Furnace) furnace.getState();
|
||||
sendAlert("[DisplayGuard] Block " + event.getBlock().getLocation().toString()
|
||||
sendAlert("[DisplayGuard] Block " + event.getBlock().getLocation()
|
||||
+ " trying smelt with DisplayItem.");
|
||||
Util.inventoryCheck(furnace1.getInventory());
|
||||
}
|
||||
@@ -202,7 +197,7 @@ public class DisplayProtectionListener implements Listener {
|
||||
Block furnace = event.getBlock();
|
||||
if (furnace.getState() instanceof Furnace) {
|
||||
Furnace furnace1 = (Furnace) furnace.getState();
|
||||
sendAlert("[DisplayGuard] Block " + event.getBlock().getLocation().toString()
|
||||
sendAlert("[DisplayGuard] Block " + event.getBlock().getLocation()
|
||||
+ " trying smelt with DisplayItem.");
|
||||
Util.inventoryCheck(furnace1.getInventory());
|
||||
}
|
||||
@@ -225,8 +220,7 @@ public class DisplayProtectionListener implements Listener {
|
||||
// You shouldn't be able to pick up that...
|
||||
e.getItem().remove();
|
||||
sendAlert("[DisplayGuard] Entity " + e
|
||||
.getEntity().getName() + " # " + e.getEntity().getLocation()
|
||||
.toString() + " pickedup the displayItem, QuickShop already removed it.");
|
||||
.getEntity().getName() + " # " + e.getEntity().getLocation() + " pickedup the displayItem, QuickShop already removed it.");
|
||||
|
||||
Entity entity = e.getEntity();
|
||||
if (entity instanceof InventoryHolder) {
|
||||
@@ -286,7 +280,7 @@ public class DisplayProtectionListener implements Listener {
|
||||
Util.inventoryCheck(((InventoryHolder) entity).getInventory());
|
||||
}
|
||||
sendAlert("[DisplayGuard] Entity " + event.getEntityType()
|
||||
.name() + " # " + event.getEntity().getLocation().toString() + " trying interact the hold displayItem's entity.");
|
||||
.name() + " # " + event.getEntity().getLocation() + " trying interact the hold displayItem's entity.");
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
@@ -316,8 +310,7 @@ public class DisplayProtectionListener implements Listener {
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
||||
sendAlert("[DisplayGuard] Inventory " + event.getClickedInventory().getHolder() + " at" + event.getClickedInventory().getLocation()
|
||||
.toString() + " was clicked the displayItem, QuickShop already removed it.");
|
||||
sendAlert("[DisplayGuard] Inventory " + event.getClickedInventory().getHolder() + " at" + event.getClickedInventory().getLocation() + " was clicked the displayItem, QuickShop already removed it.");
|
||||
event.getCurrentItem().setAmount(0);
|
||||
event.getCurrentItem().setType(Material.AIR);
|
||||
event.setResult(Result.DENY);
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ public class HttpRequest implements Closeable {
|
||||
* @return this object
|
||||
*/
|
||||
public HttpRequest header(String key, String value) {
|
||||
if (key.equalsIgnoreCase("Content-Type")) {
|
||||
if ("Content-Type".equalsIgnoreCase(key)) {
|
||||
contentType = value;
|
||||
} else {
|
||||
headers.put(key, value);
|
||||
|
||||
@@ -88,7 +88,7 @@ public class GroupManagerProvider implements PermissionProvider {
|
||||
}
|
||||
StringBuilder permissionBuilder = new StringBuilder();
|
||||
handler.getAllPlayersPermissions(sender.getName(), true).forEach((node) -> permissionBuilder.append(node).append("\n"));
|
||||
return new PermissionInfomationContainer(sender, permission, handler.getPrimaryGroup(sender.getName()), "This player have permissions: \n" + permissionBuilder.toString() + "\nWARNING: GroupManager doesn't have support, don't report to us if you got any troubles.");
|
||||
return new PermissionInfomationContainer(sender, permission, handler.getPrimaryGroup(sender.getName()), "This player have permissions: \n" + permissionBuilder + "\nWARNING: GroupManager doesn't have support, don't report to us if you got any troubles.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,6 @@ public class LuckPermsProvider implements PermissionProvider {
|
||||
}
|
||||
StringBuilder permissionsBuilder = new StringBuilder();
|
||||
user.getPermissions().forEach((pnode) -> permissionsBuilder.append(pnode.getPermission()).append("\n"));
|
||||
return new PermissionInfomationContainer(sender, permission, user.getPrimaryGroup(), "This player all permissions: \n" + permissionsBuilder.toString());
|
||||
return new PermissionInfomationContainer(sender, permission, user.getPrimaryGroup(), "This player all permissions: \n" + permissionsBuilder);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import org.bukkit.plugin.RegisteredListener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.Command.CommandManager;
|
||||
import org.maxgamer.quickshop.Database.*;
|
||||
import org.maxgamer.quickshop.Database.Database.ConnectionException;
|
||||
@@ -45,6 +46,7 @@ public class QuickShop extends JavaPlugin {
|
||||
/**
|
||||
* The BootError, if it not NULL, plugin will stop loading and show setted errors when use /qs
|
||||
**/
|
||||
@Nullable
|
||||
private BootError bootError;
|
||||
// Listeners - We decide which one to use at runtime
|
||||
private ChatListener chatListener;
|
||||
@@ -98,6 +100,7 @@ public class QuickShop extends JavaPlugin {
|
||||
private HashMap<String, Integer> limits = new HashMap<>();
|
||||
private LockListener lockListener;
|
||||
//private BukkitTask itemWatcherTask;
|
||||
@Nullable
|
||||
private LogWatcher logWatcher;
|
||||
/**
|
||||
* bStats, good helper for metrics.
|
||||
@@ -1055,7 +1058,7 @@ public class QuickShop extends JavaPlugin {
|
||||
selectedVersion = 68;
|
||||
}
|
||||
if (selectedVersion == 68){
|
||||
ArrayList<String> temp = new ArrayList<>();;
|
||||
ArrayList<String> temp = new ArrayList<>();
|
||||
temp.add("SoulBound");
|
||||
getConfig().set("shop.blacklist-lores", temp);
|
||||
getConfig().set("config-version", 69);
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.Event.ShopDisplayItemDespawnEvent;
|
||||
import org.maxgamer.quickshop.Event.ShopDisplayItemSpawnEvent;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
@@ -26,7 +27,9 @@ public class ArmorStandDisplayItem implements DisplayItem {
|
||||
return nlc.contains("sword") || nlc.contains("shovel") || nlc.contains("axe");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private ArmorStand armorStand;
|
||||
@Nullable
|
||||
private ItemStack guardedIstack;
|
||||
private ItemStack originalItemStack;
|
||||
private QuickShop plugin = QuickShop.instance;
|
||||
@@ -87,7 +90,7 @@ public class ArmorStandDisplayItem implements DisplayItem {
|
||||
safeGuard(this.armorStand);
|
||||
//Set pose
|
||||
setPoseForArmorStand();
|
||||
Util.debugLog("Spawned a new ArmorStand DisplayItem for a shop " + shop.getLocation().toString());
|
||||
Util.debugLog("Spawned a new ArmorStand DisplayItem for a shop " + shop.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -105,8 +108,8 @@ public class ArmorStandDisplayItem implements DisplayItem {
|
||||
|
||||
if (!eArmorStand.getUniqueId().equals(this.armorStand.getUniqueId())) {
|
||||
if (DisplayItem.checkIsTargetShopDisplay(eArmorStand.getItemInHand(), this.shop)) {
|
||||
Util.debugLog("Removing dupes ArmorEntity " + eArmorStand.getUniqueId().toString() + " at " + eArmorStand
|
||||
.getLocation().toString());
|
||||
Util.debugLog("Removing dupes ArmorEntity " + eArmorStand.getUniqueId() + " at " + eArmorStand
|
||||
.getLocation());
|
||||
entity.remove();
|
||||
removed = true;
|
||||
}
|
||||
@@ -118,7 +121,7 @@ public class ArmorStandDisplayItem implements DisplayItem {
|
||||
@Override
|
||||
public void safeGuard(@NotNull Entity entity) {
|
||||
if (!(entity instanceof ArmorStand)) {
|
||||
Util.debugLog("Failed to safeGuard " + entity.getLocation().toString() + ", cause target not a ArmorStand");
|
||||
Util.debugLog("Failed to safeGuard " + entity.getLocation() + ", cause target not a ArmorStand");
|
||||
return;
|
||||
}
|
||||
ArmorStand armorStand = (ArmorStand) entity;
|
||||
@@ -126,7 +129,7 @@ public class ArmorStandDisplayItem implements DisplayItem {
|
||||
this.guardedIstack = DisplayItem.createGuardItemStack(this.originalItemStack, this.shop);
|
||||
armorStand.setItemInHand(guardedIstack);
|
||||
armorStand.getPersistentDataContainer().set(new NamespacedKey(plugin,"displayMark"),DisplayItemPersistentDataType.INSTANCE,DisplayItem.createShopProtectionFlag(this.originalItemStack,shop));
|
||||
Util.debugLog("Successfully safeGuard ArmorStand: " + armorStand.getLocation().toString());
|
||||
Util.debugLog("Successfully safeGuard ArmorStand: " + armorStand.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -246,8 +249,8 @@ public class ArmorStandDisplayItem implements DisplayItem {
|
||||
}
|
||||
ArmorStand eArmorStand = (ArmorStand) entity;
|
||||
if (eArmorStand.getUniqueId().equals(this.armorStand.getUniqueId())) {
|
||||
Util.debugLog("Fixing moved ArmorStand displayItem " + eArmorStand.getUniqueId().toString() + " at " + eArmorStand
|
||||
.getLocation().toString());
|
||||
Util.debugLog("Fixing moved ArmorStand displayItem " + eArmorStand.getUniqueId() + " at " + eArmorStand
|
||||
.getLocation());
|
||||
eArmorStand.teleport(getDisplayLocation());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class ContainerShop implements Shop {
|
||||
int stackSize = Math.min(remains, item.getMaxStackSize());
|
||||
item.setAmount(stackSize);
|
||||
inv.addItem(item);
|
||||
remains = remains - stackSize;
|
||||
remains -= stackSize;
|
||||
}
|
||||
this.setSignText();
|
||||
}
|
||||
@@ -268,41 +268,42 @@ public class ContainerShop implements Shop {
|
||||
*/
|
||||
@Override
|
||||
public void buy(@NotNull Player p, int amount) {
|
||||
if (amount < 0) {
|
||||
this.sell(p, -amount);
|
||||
int amount1 = amount;
|
||||
if (amount1 < 0) {
|
||||
this.sell(p, -amount1);
|
||||
}
|
||||
if (this.isUnlimited()) {
|
||||
ItemStack[] contents = p.getInventory().getContents();
|
||||
for (int i = 0; amount > 0 && i < contents.length; i++) {
|
||||
for (int i = 0; amount1 > 0 && i < contents.length; i++) {
|
||||
ItemStack stack = contents[i];
|
||||
if (stack == null) {
|
||||
continue; // No item
|
||||
}
|
||||
if (matches(stack)) {
|
||||
int stackSize = Math.min(amount, stack.getAmount());
|
||||
int stackSize = Math.min(amount1, stack.getAmount());
|
||||
stack.setAmount(stack.getAmount() - stackSize);
|
||||
amount -= stackSize;
|
||||
amount1 -= stackSize;
|
||||
}
|
||||
}
|
||||
// Send the players new inventory to them
|
||||
p.getInventory().setContents(contents);
|
||||
this.setSignText();
|
||||
// This should not happen.
|
||||
if (amount > 0) {
|
||||
if (amount1 > 0) {
|
||||
plugin.getLogger().log(Level.WARNING, "Could not take all items from a players inventory on purchase! " + p
|
||||
.getName() + ", missing: " + amount + ", item: " + Util.getItemStackName(this.getItem()) + "!");
|
||||
.getName() + ", missing: " + amount1 + ", item: " + Util.getItemStackName(this.getItem()) + "!");
|
||||
}
|
||||
} else {
|
||||
ItemStack[] playerContents = p.getInventory().getContents();
|
||||
Inventory chestInv = this.getInventory();
|
||||
for (int i = 0; amount > 0 && i < playerContents.length; i++) {
|
||||
for (int i = 0; amount1 > 0 && i < playerContents.length; i++) {
|
||||
ItemStack item = playerContents[i];
|
||||
if (item != null && this.matches(item)) {
|
||||
// Copy it, we don't want to interfere
|
||||
item = item.clone();
|
||||
// Amount = total, item.getAmount() = how many items in the
|
||||
// stack
|
||||
int stackSize = Math.min(amount, item.getAmount());
|
||||
int stackSize = Math.min(amount1, item.getAmount());
|
||||
// If Amount is item.getAmount(), then this sets the amount
|
||||
// to 0
|
||||
// Else it sets it to the remainder
|
||||
@@ -311,7 +312,7 @@ public class ContainerShop implements Shop {
|
||||
item.setAmount(stackSize);
|
||||
// Add the items to the players inventory
|
||||
chestInv.addItem(item);
|
||||
amount -= stackSize;
|
||||
amount1 -= stackSize;
|
||||
}
|
||||
}
|
||||
// Now update the players inventory.
|
||||
@@ -440,7 +441,7 @@ public class ContainerShop implements Shop {
|
||||
int stackSize = Math.min(remains, item.getMaxStackSize());
|
||||
item.setAmount(stackSize);
|
||||
inv.removeItem(item);
|
||||
remains = remains - stackSize;
|
||||
remains -= stackSize;
|
||||
}
|
||||
this.setSignText();
|
||||
}
|
||||
@@ -692,12 +693,12 @@ public class ContainerShop implements Shop {
|
||||
StringBuilder sb = new StringBuilder("Shop " + (location.getWorld() == null ?
|
||||
"unloaded world" :
|
||||
location.getWorld().getName()) + "(" + location.getBlockX() + ", " + location.getBlockY() + ", " + location.getBlockZ() + ")");
|
||||
sb.append(" Owner: ").append(this.ownerName()).append(" - ").append(getOwner().toString());
|
||||
sb.append(" Owner: ").append(this.ownerName()).append(" - ").append(getOwner());
|
||||
if (isUnlimited()) {
|
||||
sb.append(" Unlimited: true");
|
||||
}
|
||||
sb.append(" Price: ").append(getPrice());
|
||||
sb.append(" Item: ").append(getItem().toString());
|
||||
sb.append(" Item: ").append(getItem());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -824,7 +825,7 @@ public class ContainerShop implements Shop {
|
||||
*/
|
||||
public void checkContainer() {
|
||||
if (!Util.canBeShop(this.getLocation().getBlock())) {
|
||||
Util.debugLog("Shop at " + this.getLocation().toString() + " container was missing, remove...");
|
||||
Util.debugLog("Shop at " + this.getLocation() + " container was missing, remove...");
|
||||
this.onUnload();
|
||||
this.delete();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public class InventoryPreview implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Inventory inventory;
|
||||
private ItemStack itemStack;
|
||||
private Player player;
|
||||
|
||||
@@ -18,7 +18,9 @@ import org.maxgamer.quickshop.Util.Util;
|
||||
public class RealDisplayItem implements DisplayItem {
|
||||
|
||||
private static QuickShop plugin = QuickShop.instance;
|
||||
@Nullable
|
||||
private ItemStack guardedIstack;
|
||||
@Nullable
|
||||
private Item item;
|
||||
private ItemStack originalItemStack;
|
||||
private Shop shop;
|
||||
@@ -73,8 +75,8 @@ public class RealDisplayItem implements DisplayItem {
|
||||
}
|
||||
Item eItem = (Item) entity;
|
||||
if (eItem.getUniqueId().equals(this.item.getUniqueId())) {
|
||||
Util.debugLog("Fixing moved Item displayItem " + eItem.getUniqueId().toString() + " at " + eItem
|
||||
.getLocation().toString());
|
||||
Util.debugLog("Fixing moved Item displayItem " + eItem.getUniqueId() + " at " + eItem
|
||||
.getLocation());
|
||||
eItem.teleport(getDisplayLocation());
|
||||
return;
|
||||
}
|
||||
@@ -119,8 +121,8 @@ public class RealDisplayItem implements DisplayItem {
|
||||
}
|
||||
if (!eItem.getUniqueId().equals(this.item.getUniqueId())) {
|
||||
if (DisplayItem.checkIsTargetShopDisplay(eItem.getItemStack(), this.shop)) {
|
||||
Util.debugLog("Removing a duped ItemEntity " + eItem.getUniqueId().toString() + " at " + eItem
|
||||
.getLocation().toString());
|
||||
Util.debugLog("Removing a duped ItemEntity " + eItem.getUniqueId() + " at " + eItem
|
||||
.getLocation());
|
||||
entity.remove();
|
||||
removed = true;
|
||||
} else {
|
||||
@@ -141,7 +143,7 @@ public class RealDisplayItem implements DisplayItem {
|
||||
@Override
|
||||
public void safeGuard(@NotNull Entity entity) {
|
||||
if (!(entity instanceof Item)) {
|
||||
Util.debugLog("Failed to safeGuard " + entity.getLocation().toString() + ", cause target not a Item");
|
||||
Util.debugLog("Failed to safeGuard " + entity.getLocation() + ", cause target not a Item");
|
||||
return;
|
||||
}
|
||||
Item item = (Item) entity;
|
||||
@@ -152,7 +154,7 @@ public class RealDisplayItem implements DisplayItem {
|
||||
item.setCustomName(Util.getItemStackName(this.guardedIstack));
|
||||
item.setCustomNameVisible(true);
|
||||
}
|
||||
Util.debugLog("Successfully safeGuard Item: " + item.getLocation().toString());
|
||||
Util.debugLog("Successfully safeGuard Item: " + item.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,7 +194,7 @@ public class RealDisplayItem implements DisplayItem {
|
||||
this.item.setVelocity(new Vector(0, 0.1, 0));
|
||||
this.item.setCustomNameVisible(false);
|
||||
safeGuard(this.item);
|
||||
Util.debugLog("Spawned new DisplayItem for shop " + shop.getLocation().toString());
|
||||
Util.debugLog("Spawned new DisplayItem for shop " + shop.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ShopLoader {
|
||||
}
|
||||
|
||||
try {
|
||||
logger.warning("ClientInfo: " + plugin.getDatabase().getConnection().getClientInfo().toString());
|
||||
logger.warning("ClientInfo: " + plugin.getDatabase().getConnection().getClientInfo());
|
||||
} catch (SQLException | NullPointerException e) {
|
||||
logger.warning("ClientInfo: " + "FALSE - Failed to load status.");
|
||||
}
|
||||
|
||||
@@ -529,9 +529,8 @@ public class ShopManager {
|
||||
actionSell(p, eco, actions, info, message, shop, amount);
|
||||
} else {
|
||||
p.sendMessage(MsgUtil.getMessage("shop-purchase-cancelled", p));
|
||||
plugin.getLogger().warning("Shop data broken? Loc:" + shop.getLocation().toString());
|
||||
plugin.getLogger().warning("Shop data broken? Loc:" + shop.getLocation());
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -123,6 +123,7 @@ public class MsgUtil {
|
||||
} catch (ArrayIndexOutOfBoundsException e2) {
|
||||
p.getPlayer().sendMessage(msg);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A util to generate a paste report and upload it to Ubuntu Paste
|
||||
@@ -38,26 +39,22 @@ public class Paste {
|
||||
finalReport.append("QuickShop:\n");
|
||||
finalReport.append("\tVersion: ").append(QuickShop.getVersion()).append("\n");
|
||||
finalReport.append("\tFork: ").append(plugin.getFork()).append("\n");
|
||||
finalReport.append("\tServer ID: ").append(plugin.getServerUniqueID().toString()).append("\n");
|
||||
finalReport.append("\tServer ID: ").append(plugin.getServerUniqueID()).append("\n");
|
||||
finalReport.append("\tOpenInv Hook: ").append(plugin.getOpenInvPlugin() == null ? "Disabled" : "Enabled").append("\n");
|
||||
finalReport.append("\tEconomy System: ");
|
||||
EconomyCore economyCore = plugin.getEconomy().getCore();
|
||||
if (economyCore != null) {
|
||||
switch (Economy.getNowUsing()) {
|
||||
case VAULT:
|
||||
finalReport.append("Vault").append("%").append(((Economy_Vault) economyCore).getProviderName());
|
||||
break;
|
||||
case RESERVE:
|
||||
finalReport.append("Reserve").append("%").append("No details");
|
||||
break;
|
||||
case UNKNOWN:
|
||||
finalReport.append("Unknown").append("%").append("Unknown error");
|
||||
break;
|
||||
}
|
||||
finalReport.append("\n");
|
||||
} else {
|
||||
finalReport.append("null");
|
||||
switch (Economy.getNowUsing()) {
|
||||
case VAULT:
|
||||
finalReport.append("Vault").append("%").append(((Economy_Vault) economyCore).getProviderName());
|
||||
break;
|
||||
case RESERVE:
|
||||
finalReport.append("Reserve").append("%").append("No details");
|
||||
break;
|
||||
case UNKNOWN:
|
||||
finalReport.append("Unknown").append("%").append("Unknown error");
|
||||
break;
|
||||
}
|
||||
finalReport.append("\n");
|
||||
finalReport.append("================================================\n");
|
||||
finalReport.append("System:\n");
|
||||
finalReport.append("\tOS: ").append(System.getProperty("os.name")).append("\n");
|
||||
@@ -70,13 +67,14 @@ public class Paste {
|
||||
finalReport.append("\tServer Name: ").append(Bukkit.getServer().getName()).append("\n");
|
||||
finalReport.append("\tBuild: ").append(Bukkit.getServer().getVersion()).append("\n");
|
||||
finalReport.append("\tNMSV: ").append(Util.getNMSVersion()).append("\n");
|
||||
//noinspection deprecation
|
||||
finalReport.append("\tData Version: ").append(Bukkit.getUnsafe().getDataVersion()).append("\n");
|
||||
finalReport.append("\tJava: ").append(System.getProperty("java.version")).append("\n");
|
||||
finalReport.append("\tPlayers: ").append(Bukkit.getOnlinePlayers().size()).append("/").append(Bukkit.getMaxPlayers())
|
||||
.append("\n");
|
||||
finalReport.append("\tOnlineMode: ").append(Bukkit.getOnlineMode()).append("\n");
|
||||
finalReport.append("\tBukkitVersion: ").append(Bukkit.getVersion()).append("\n");
|
||||
finalReport.append("\tWorldContainer: ").append(Bukkit.getWorldContainer().toString()).append("\n");
|
||||
finalReport.append("\tWorldContainer: ").append(Bukkit.getWorldContainer()).append("\n");
|
||||
finalReport.append("================================================\n");
|
||||
finalReport.append("Worlds:\n");
|
||||
finalReport.append("\tTotal: ").append(Bukkit.getWorlds().size()).append("\n");
|
||||
@@ -101,27 +99,27 @@ public class Paste {
|
||||
try {
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\tconfig.yml:\n");
|
||||
finalReport.append("\t\t\n").append(new String(Util
|
||||
.inputStream2ByteArray(plugin.getDataFolder().toString() + "/config.yml"))).append("\n");
|
||||
finalReport.append("\t\t\n").append(new String(Objects.requireNonNull(Util
|
||||
.inputStream2ByteArray(plugin.getDataFolder() + "/config.yml")))).append("\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\tmessages.yml:\n");
|
||||
finalReport.append("\t\t\n").append(new String(Util
|
||||
.inputStream2ByteArray(plugin.getDataFolder().toString() + "/messages.yml"))).append("\n");
|
||||
finalReport.append("\t\t\n").append(new String(Objects.requireNonNull(Util
|
||||
.inputStream2ByteArray(plugin.getDataFolder() + "/messages.yml")))).append("\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\titemi18n.yml:\n");
|
||||
finalReport.append("\t\t\n").append(new String(Util
|
||||
.inputStream2ByteArray(new File(new File(".", "logs"), "latest.log").getPath()))).append("\n");
|
||||
finalReport.append("\t\t\n").append(new String(Objects.requireNonNull(Util
|
||||
.inputStream2ByteArray(new File(new File(".", "logs"), "latest.log").getPath())))).append("\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\tenchi18n.yml:\n");
|
||||
finalReport.append("\t\t\n").append(new String(Util
|
||||
.inputStream2ByteArray(new File(new File(".", "logs"), "latest.log").getPath()))).append("\n");
|
||||
finalReport.append("\t\t\n").append(new String(Objects.requireNonNull(Util
|
||||
.inputStream2ByteArray(new File(new File(".", "logs"), "latest.log").getPath())))).append("\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\tpotioni18n.yml:\n");
|
||||
finalReport.append("\t\t\n").append(new String(Util
|
||||
.inputStream2ByteArray(new File(new File(".", "logs"), "latest.log").getPath()))).append("\n");
|
||||
finalReport.append("\t\t\n").append(new String(Objects.requireNonNull(Util
|
||||
.inputStream2ByteArray(new File(new File(".", "logs"), "latest.log").getPath())))).append("\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\tInternal Debug Log:\n");
|
||||
@@ -130,8 +128,8 @@ public class Paste {
|
||||
try {
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\tlatest.log:\n");
|
||||
finalReport.append("\t\t\n").append(new String(Util
|
||||
.inputStream2ByteArray(new File(new File(".", "logs"), "latest.log").getPath()))).append("\n");
|
||||
finalReport.append("\t\t\n").append(new String(Objects.requireNonNull(Util
|
||||
.inputStream2ByteArray(new File(new File(".", "logs"), "latest.log").getPath())))).append("\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
} catch (Throwable th) {
|
||||
finalReport.append("\t*********************************\n");
|
||||
@@ -142,8 +140,8 @@ public class Paste {
|
||||
try {
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\tbukkit.yml:\n");
|
||||
finalReport.append("\t\t\n").append(new String(Util
|
||||
.inputStream2ByteArray(new File(new File("."), "bukkit.yml").getPath()))).append("\n");
|
||||
finalReport.append("\t\t\n").append(new String(Objects.requireNonNull(Util
|
||||
.inputStream2ByteArray(new File(new File("."), "bukkit.yml").getPath())))).append("\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
} catch (Throwable th) {
|
||||
finalReport.append("\t*********************************\n");
|
||||
@@ -154,8 +152,8 @@ public class Paste {
|
||||
try {
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\tspigot.yml:\n");
|
||||
finalReport.append("\t\t\n").append(new String(Util
|
||||
.inputStream2ByteArray(new File(new File("."), "spigot.yml").getPath()))).append("\n");
|
||||
finalReport.append("\t\t\n").append(new String(Objects.requireNonNull(Util
|
||||
.inputStream2ByteArray(new File(new File("."), "spigot.yml").getPath())))).append("\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
} catch (Throwable th) {
|
||||
finalReport.append("\t*********************************\n");
|
||||
@@ -166,8 +164,8 @@ public class Paste {
|
||||
try {
|
||||
finalReport.append("\t*********************************\n");
|
||||
finalReport.append("\tpaper.yml:\n");
|
||||
finalReport.append("\t\t\n").append(new String(Util
|
||||
.inputStream2ByteArray(new File(new File("."), "paper.yml").getPath()))).append("\n");
|
||||
finalReport.append("\t\t\n").append(new String(Objects.requireNonNull(Util
|
||||
.inputStream2ByteArray(new File(new File("."), "paper.yml").getPath())))).append("\n");
|
||||
finalReport.append("\t*********************************\n");
|
||||
} catch (Throwable th) {
|
||||
finalReport.append("\t*********************************\n");
|
||||
@@ -180,11 +178,11 @@ public class Paste {
|
||||
}
|
||||
finalReport.append("================================================\n");
|
||||
finalReport.append("Shops in DB:\n");
|
||||
plugin.getShopLoader().getOriginShopsInDatabase().forEach((shopDatabaseInfoOrigin -> finalReport.append("\t").append(shopDatabaseInfoOrigin.toString()).append("\n")));
|
||||
plugin.getShopLoader().getOriginShopsInDatabase().forEach((shopDatabaseInfoOrigin -> finalReport.append("\t").append(shopDatabaseInfoOrigin).append("\n")));
|
||||
finalReport.append("Total: ").append(plugin.getShopLoader().getOriginShopsInDatabase().size()).append("\n");
|
||||
finalReport.append("================================================\n");
|
||||
finalReport.append("Shops in Mem:\n");
|
||||
plugin.getShopLoader().getShopsInDatabase().forEach((shop -> finalReport.append("\t").append(shop.toString()).append("\n")));
|
||||
plugin.getShopLoader().getShopsInDatabase().forEach((shop -> finalReport.append("\t").append(shop).append("\n")));
|
||||
finalReport.append("Total: ").append(plugin.getShopLoader().getShopsInDatabase().size()).append("\n");
|
||||
finalReport.append("================================================\n");
|
||||
|
||||
@@ -192,11 +190,11 @@ public class Paste {
|
||||
String report = finalReport.toString();
|
||||
try {
|
||||
ConfigurationSection configurationSection = plugin.getConfig().getConfigurationSection("database");
|
||||
report = report.replaceAll(configurationSection.getString("user"), "[PROTECTED]");
|
||||
report = report.replaceAll(configurationSection.getString("password"), "[PROTECTED]");
|
||||
report = report.replaceAll(configurationSection.getString("host"), "[PROTECTED]");
|
||||
report = report.replaceAll(configurationSection.getString("port"), "[PROTECTED]");
|
||||
report = report.replaceAll(configurationSection.getString("database"), "[PROTECTED]");
|
||||
report = report.replaceAll(Objects.requireNonNull(Objects.requireNonNull(configurationSection).getString("user")), "[PROTECTED]");
|
||||
report = report.replaceAll(Objects.requireNonNull(configurationSection.getString("password")), "[PROTECTED]");
|
||||
report = report.replaceAll(Objects.requireNonNull(configurationSection.getString("host")), "[PROTECTED]");
|
||||
report = report.replaceAll(Objects.requireNonNull(configurationSection.getString("port")), "[PROTECTED]");
|
||||
report = report.replaceAll(Objects.requireNonNull(configurationSection.getString("database")), "[PROTECTED]");
|
||||
} catch (Throwable tg) {
|
||||
//Ignore
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class UbuntuPaster implements PasteInterface{
|
||||
out.print(builder);
|
||||
out.flush();//Drop
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
Util.debugLog("Request Completed: " + conn.getURL().toString());
|
||||
Util.debugLog("Request Completed: " + conn.getURL());
|
||||
String link = conn.getURL().toString();
|
||||
in.close();
|
||||
out.close();
|
||||
|
||||
@@ -208,7 +208,7 @@ public class SentryErrorReporter {
|
||||
plugin.getLogger().warning("====QuickShop Error Report BEGIN===");
|
||||
plugin.getLogger().warning("Description: " + throwable.getMessage());
|
||||
plugin.getLogger().warning("Event ID: " + this.context.getLastEventId());
|
||||
plugin.getLogger().warning("Server ID: " + plugin.getServerUniqueID().toString());
|
||||
plugin.getLogger().warning("Server ID: " + plugin.getServerUniqueID());
|
||||
plugin.getLogger().warning("====QuickShop Error Report E N D===");
|
||||
return this.context.getLastEventId();
|
||||
} catch (Throwable th) {
|
||||
|
||||
@@ -31,12 +31,12 @@ public class DisplayAutoDespawnWatcher extends BukkitRunnable {
|
||||
}
|
||||
if (anyPlayerInRegion) {
|
||||
if (!shop.getDisplay().isSpawned()) {
|
||||
Util.debugLog("Respawning the shop " + shop.toString() + " the display, cause it was despawned and a player close it");
|
||||
Util.debugLog("Respawning the shop " + shop + " the display, cause it was despawned and a player close it");
|
||||
shop.checkDisplay();
|
||||
}
|
||||
} else {
|
||||
if (shop.getDisplay().isSpawned()) {
|
||||
Util.debugLog("Removing the shop " + shop.toString() + " the display, cause nobody can see it");
|
||||
Util.debugLog("Removing the shop " + shop + " the display, cause nobody can see it");
|
||||
shop.getDisplay().remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class LogWatcher extends BukkitRunnable {
|
||||
public void log(@NonNull String log) {
|
||||
Date date = Calendar.getInstance().getTime();
|
||||
Timestamp time = new Timestamp(date.getTime());
|
||||
this.add("[" + time.toString() + "] " + log);
|
||||
this.add("[" + time + "] " + log);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,7 +51,7 @@ public class OngoingFeeWatcher extends BukkitRunnable {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} else {
|
||||
Util.debugLog("Shop was ignored for ongoing fee cause it is unlimited and ignoreUnlimited = true : " + shop.toString());
|
||||
Util.debugLog("Shop was ignored for ongoing fee cause it is unlimited and ignoreUnlimited = true : " + shop);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user