Lots of fixes
This commit is contained in:
parent
1d4d56e792
commit
7df87a7d7e
@ -14,6 +14,7 @@ import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.gemhunters.economy.command.CashOutItemCommand;
|
||||
import mineplex.gemhunters.economy.command.ResetCooldownCommand;
|
||||
import mineplex.gemhunters.economy.event.PlayerCashOutCompleteEvent;
|
||||
import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent;
|
||||
import org.bukkit.Material;
|
||||
@ -61,6 +62,7 @@ public class CashOutModule extends MiniPlugin
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new CashOutItemCommand(this));
|
||||
addCommand(new ResetCooldownCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -0,0 +1,23 @@
|
||||
package mineplex.gemhunters.economy.command;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.gemhunters.economy.CashOutModule;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ResetCooldownCommand extends CommandBase<CashOutModule>
|
||||
{
|
||||
|
||||
public ResetCooldownCommand(CashOutModule plugin)
|
||||
{
|
||||
super(plugin, Rank.DEVELOPER, "resetcashout");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Recharge.Instance.useForce(caller, "Cash Out", 0);
|
||||
}
|
||||
|
||||
}
|
@ -4,12 +4,13 @@ import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.gemhunters.death.quitnpc.QuitNPC;
|
||||
import mineplex.gemhunters.death.quitnpc.QuitNPCModule;
|
||||
import mineplex.gemhunters.economy.EconomyModule;
|
||||
import mineplex.gemhunters.loot.InventoryModule;
|
||||
import mineplex.gemhunters.map.ItemMapModule;
|
||||
import mineplex.gemhunters.loot.LootModule;
|
||||
import mineplex.gemhunters.persistence.PersistenceData;
|
||||
import mineplex.gemhunters.persistence.PersistenceModule;
|
||||
import mineplex.gemhunters.persistence.PersistenceRepository;
|
||||
@ -20,7 +21,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -28,8 +28,11 @@ import java.util.function.Consumer;
|
||||
public class JoinModule extends MiniPlugin
|
||||
{
|
||||
|
||||
private static final double MAXIMUM_DURABILITY_LOSS = 0.85;
|
||||
|
||||
private final CoreClientManager _client;
|
||||
private final EconomyModule _economy;
|
||||
private final LootModule _loot;
|
||||
private final QuestModule _quest;
|
||||
private final PersistenceModule _persistence;
|
||||
private final QuitNPCModule _npc;
|
||||
@ -42,6 +45,7 @@ public class JoinModule extends MiniPlugin
|
||||
|
||||
_client = require(CoreClientManager.class);
|
||||
_economy = require(EconomyModule.class);
|
||||
_loot = require(LootModule.class);
|
||||
_quest = require(QuestModule.class);
|
||||
_persistence = require(PersistenceModule.class);
|
||||
_npc = require(QuitNPCModule.class);
|
||||
@ -63,10 +67,16 @@ public class JoinModule extends MiniPlugin
|
||||
player.setHealth(data.getHealth());
|
||||
player.setMaxHealth(data.getMaxHealth());
|
||||
player.setFoodLevel(data.getHunger());
|
||||
loseDurability(data.getItems(), data.getSaveTime());
|
||||
for (ItemStack itemStack : data.getItems())
|
||||
{
|
||||
_loot.handleRewardItem(player, itemStack);
|
||||
}
|
||||
player.getInventory().addItem(data.getItems());
|
||||
loseDurability(data.getArmour(), data.getSaveTime());
|
||||
player.getInventory().setArmorContents(data.getArmour());
|
||||
_inventory.unlockSlots(player, data.getSlots(), false);
|
||||
Recharge.Instance.useForce(player, "Cash Out", data.getCashOutTime());
|
||||
});
|
||||
|
||||
player.getInventory().clear();
|
||||
@ -93,19 +103,25 @@ public class JoinModule extends MiniPlugin
|
||||
private void loseDurability(ItemStack[] items, long time)
|
||||
{
|
||||
long diff = System.currentTimeMillis() - time;
|
||||
long hours = TimeUnit.MILLISECONDS.toHours(diff);
|
||||
long hours = TimeUnit.MILLISECONDS.toSeconds(diff);
|
||||
|
||||
for (ItemStack item : items)
|
||||
{
|
||||
short max = item.getType().getMaxDurability();
|
||||
short change = (short) ((max / 100D) * hours);
|
||||
|
||||
if (item.getDurability() + change > max * 0.15)
|
||||
if (!UtilItem.isSword(item) && !UtilItem.isArmor(item))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
item.setDurability((short) (item.getDurability() + change));
|
||||
short max = item.getType().getMaxDurability();
|
||||
short change = (short) (((double) max / 100D) * hours);
|
||||
short apply = (short) (item.getDurability() + change);
|
||||
|
||||
if (apply > max * MAXIMUM_DURABILITY_LOSS)
|
||||
{
|
||||
apply = (short) (max * MAXIMUM_DURABILITY_LOSS);
|
||||
}
|
||||
|
||||
item.setDurability(apply);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,23 @@
|
||||
package mineplex.gemhunters.loot;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.google.GoogleSheetsManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.gemhunters.economy.EconomyModule;
|
||||
import mineplex.gemhunters.economy.event.PlayerCashOutCompleteEvent;
|
||||
import mineplex.gemhunters.loot.command.SpawnChestCommand;
|
||||
import mineplex.gemhunters.loot.command.UpdateLootCommand;
|
||||
import mineplex.gemhunters.loot.deserialisers.ChestPropertiesDeserialiser;
|
||||
import mineplex.gemhunters.loot.deserialisers.LootItemDeserialiser;
|
||||
import mineplex.gemhunters.loot.event.PlayerChestOpenEvent;
|
||||
import mineplex.gemhunters.loot.rewards.*;
|
||||
import mineplex.gemhunters.safezone.SafezoneModule;
|
||||
import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent;
|
||||
import mineplex.gemhunters.world.WorldDataModule;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
@ -25,35 +34,8 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.google.GoogleSheetsManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.gemhunters.economy.EconomyModule;
|
||||
import mineplex.gemhunters.economy.event.PlayerCashOutCompleteEvent;
|
||||
import mineplex.gemhunters.loot.command.SpawnChestCommand;
|
||||
import mineplex.gemhunters.loot.command.UpdateLootCommand;
|
||||
import mineplex.gemhunters.loot.deserialisers.ChestPropertiesDeserialiser;
|
||||
import mineplex.gemhunters.loot.deserialisers.LootItemDeserialiser;
|
||||
import mineplex.gemhunters.loot.event.PlayerChestOpenEvent;
|
||||
import mineplex.gemhunters.loot.rewards.LootChestReward;
|
||||
import mineplex.gemhunters.loot.rewards.LootGadgetReward;
|
||||
import mineplex.gemhunters.loot.rewards.LootItemReward;
|
||||
import mineplex.gemhunters.loot.rewards.LootRankReward;
|
||||
import mineplex.gemhunters.loot.rewards.LootShardReward;
|
||||
import mineplex.gemhunters.safezone.SafezoneModule;
|
||||
import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent;
|
||||
import mineplex.gemhunters.util.SlackSheetsBot;
|
||||
import mineplex.gemhunters.world.WorldDataModule;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class LootModule extends MiniPlugin
|
||||
@ -200,12 +182,6 @@ public class LootModule extends MiniPlugin
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (row != 1)
|
||||
{
|
||||
SlackSheetsBot.reportParsingError(e, "Chest Loot", key, row);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,12 +200,6 @@ public class LootModule extends MiniPlugin
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (row != 1)
|
||||
{
|
||||
SlackSheetsBot.reportParsingError(e, "Chest Loot", key, row);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -659,7 +629,7 @@ public class LootModule extends MiniPlugin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public final Set<UUID> getShownPlayers()
|
||||
{
|
||||
return _shownPlayers;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.gemhunters.loot.rewards;
|
||||
|
||||
import mineplex.gemhunters.util.SlackRewardBot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
@ -10,14 +11,14 @@ public class LootChestReward extends LootItemReward
|
||||
{
|
||||
|
||||
private final InventoryManager _inventory;
|
||||
|
||||
|
||||
private final String _chestName;
|
||||
private final int _amount;
|
||||
|
||||
|
||||
public LootChestReward(long cashOutDelay, ItemStack itemStack, String chestName, int amount)
|
||||
{
|
||||
super(chestName + " Chest", cashOutDelay, itemStack);
|
||||
|
||||
|
||||
_inventory = Managers.require(InventoryManager.class);
|
||||
_chestName = chestName;
|
||||
_amount = amount;
|
||||
@ -26,27 +27,19 @@ public class LootChestReward extends LootItemReward
|
||||
@Override
|
||||
public void onCollectItem()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccessful()
|
||||
{
|
||||
_inventory.addItemToInventory(new Callback<Boolean>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void run(Boolean success)
|
||||
{
|
||||
//DebugModule.getInstance().d("Success= " + success);
|
||||
}
|
||||
}, _player, _chestName + " Chest", _amount);
|
||||
_inventory.addItemToInventory(success -> SlackRewardBot.logReward(_player, this, success ? "Success" : "Failure"), _player, _chestName + " Chest", _amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package mineplex.gemhunters.loot.rewards;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.server.util.TransactionResponse;
|
||||
import mineplex.gemhunters.util.SlackRewardBot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
@ -35,13 +39,11 @@ public class LootGadgetReward extends LootItemReward
|
||||
|
||||
if (donor.ownsUnknownSalesPackage(_gadget))
|
||||
{
|
||||
//DebugModule.getInstance().d("Shard duplicate");
|
||||
_donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, _player, "Earned", (int) (500 + 1000 * Math.random()));
|
||||
_donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, _player, "Earned", (int) (500 + 1000 * Math.random()), success -> SlackRewardBot.logReward(_player, this, (success ? "Success" : "Failure") + " (Shard Dupe)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
//DebugModule.getInstance().d("Adding gadget");
|
||||
_donation.purchaseUnknownSalesPackage(_player, _gadget, GlobalCurrency.TREASURE_SHARD, 0, true, null);
|
||||
_donation.purchaseUnknownSalesPackage(_player, _gadget, GlobalCurrency.TREASURE_SHARD, 0, true, transaction -> SlackRewardBot.logReward(_player, this, transaction == TransactionResponse.Success ? "Success" : "Failure"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package mineplex.gemhunters.loot.rewards;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.gemhunters.util.SlackRewardBot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
@ -70,11 +71,11 @@ public class LootRankReward extends LootItemReward
|
||||
if (newRank == null)
|
||||
{
|
||||
_player.sendMessage(F.main("Loot", "Since you already have eternal ( You are lucky :) ). So instead you can have " + CONSOLATION_PRICE + " shards."));
|
||||
_donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, _player, "Earned", CONSOLATION_PRICE);
|
||||
_donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, _player, "Earned", CONSOLATION_PRICE, success -> SlackRewardBot.logReward(_player, this, (success ? "Success" : "Failure") + " (Shard Dupe)"));
|
||||
return;
|
||||
}
|
||||
|
||||
_clientManager.SaveRank(_player.getName(), _player.getUniqueId(), newRank, true);
|
||||
_clientManager.SaveRank(callback -> SlackRewardBot.logReward(_player, this, callback.Name), _player.getName(), _player.getUniqueId(), newRank, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.gemhunters.loot.rewards;
|
||||
|
||||
import mineplex.gemhunters.util.SlackRewardBot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
@ -30,7 +31,7 @@ public class LootShardReward extends LootItemReward
|
||||
@Override
|
||||
public void onSuccessful()
|
||||
{
|
||||
_donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, _player, "Earned", _amount);
|
||||
_donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, _player, "Earned", _amount, success -> SlackRewardBot.logReward(_player, this, success ? "Success" : "Failure"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -279,8 +279,8 @@ public class ItemMapRenderer extends MapRenderer
|
||||
continue;
|
||||
}
|
||||
|
||||
byte b0 = (byte) (int) Math.min(127, (double) (mapX * 2.0F) + 0.5D);
|
||||
byte b1 = (byte) (int) Math.max(-127, (double) (mapZ * 2.0F) + 0.5D);
|
||||
byte b0 = (byte) (int) Math.min(127, (mapX * 2.0F) + 0.5D);
|
||||
byte b1 = (byte) (int) Math.max(-127, (mapZ * 2.0F) + 0.5D);
|
||||
|
||||
byte rotation = (byte) (int) ((l.getYaw() * 16D) / 360D);
|
||||
|
||||
|
@ -17,8 +17,9 @@ public class PersistenceData
|
||||
private final ItemStack[] _items;
|
||||
private final ItemStack[] _armour;
|
||||
private final long _saveTime;
|
||||
private final int _cashOutTime;
|
||||
|
||||
public PersistenceData(int gems, Location location, QuestPlayerData questData, int health, int maxHealth, int hunger, int slots, ItemStack[] items, ItemStack[] armour, long saveTime)
|
||||
public PersistenceData(int gems, Location location, QuestPlayerData questData, int health, int maxHealth, int hunger, int slots, ItemStack[] items, ItemStack[] armour, long saveTime, int cashOutTime)
|
||||
{
|
||||
_gems = gems;
|
||||
_location = location;
|
||||
@ -30,6 +31,7 @@ public class PersistenceData
|
||||
_slots = slots;
|
||||
_armour = armour;
|
||||
_saveTime = saveTime;
|
||||
_cashOutTime = cashOutTime;
|
||||
}
|
||||
|
||||
public int getGems()
|
||||
@ -81,4 +83,9 @@ public class PersistenceData
|
||||
{
|
||||
return _saveTime;
|
||||
}
|
||||
|
||||
public int getCashOutTime()
|
||||
{
|
||||
return _cashOutTime;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.portal.events.ServerTransferEvent;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.recharge.RechargeData;
|
||||
import mineplex.gemhunters.death.event.QuitNPCDespawnEvent;
|
||||
import mineplex.gemhunters.economy.CashOutModule;
|
||||
import mineplex.gemhunters.economy.EconomyModule;
|
||||
@ -98,8 +100,19 @@ public class PersistenceModule extends MiniPlugin
|
||||
ItemStack[] items = player.getInventory().getContents();
|
||||
ItemStack[] armour = player.getInventory().getArmorContents();
|
||||
long saveTime = System.currentTimeMillis();
|
||||
int cashOutTime;
|
||||
RechargeData rechargeData = Recharge.Instance.Get(player).get("Cash Out");
|
||||
|
||||
PersistenceData data = new PersistenceData(gems, location, quest, health, maxHealth, hunger, slots, items, armour, saveTime);
|
||||
if (rechargeData == null)
|
||||
{
|
||||
cashOutTime = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cashOutTime = (int) rechargeData.GetRemaining();
|
||||
}
|
||||
|
||||
PersistenceData data = new PersistenceData(gems, location, quest, health, maxHealth, hunger, slots, items, armour, saveTime, cashOutTime);
|
||||
|
||||
runAsync(() ->
|
||||
{
|
||||
|
@ -8,17 +8,14 @@ import mineplex.serverdata.database.RepositoryBase;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnTimestamp;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
import net.minecraft.server.v1_8_R3.ItemMapEmpty;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jooq.util.derby.sys.Sys;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.sql.Time;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -29,8 +26,8 @@ public class PersistenceRepository extends RepositoryBase
|
||||
{
|
||||
|
||||
private static final String GET_DATA = "SELECT * FROM gemHunters WHERE accountId=?;";
|
||||
private static final String INSERT_DATA = "INSERT INTO gemHunters VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
|
||||
private static final String UPDATE_DATA = "UPDATE gemHunters SET gems=?,health=?,maxHealth=?,hunger=?,x=?,y=?,z=?,yaw=?,pitch=?,quests=?,slots=?,items=?,armour=?,saveTime=? WHERE accountId=?;";
|
||||
private static final String INSERT_DATA = "INSERT INTO gemHunters VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
|
||||
private static final String UPDATE_DATA = "UPDATE gemHunters SET gems=?,health=?,maxHealth=?,hunger=?,x=?,y=?,z=?,yaw=?,pitch=?,quests=?,slots=?,items=?,armour=?,saveTime=?,cashOutTime=? WHERE accountId=?;";
|
||||
private static final String DELETE_DATA = "DELETE FROM gemHunters WHERE accountId=?;";
|
||||
private static final Gson GSON;
|
||||
private static final ItemStack AIR = new ItemStack(Material.AIR);
|
||||
@ -109,10 +106,12 @@ public class PersistenceRepository extends RepositoryBase
|
||||
saveTime = new Timestamp(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
int cashOutTime = resultSet.getInt("cashOutTime");
|
||||
|
||||
_exists.add(accountId);
|
||||
Location location = new Location(Bukkit.getWorlds().get(0), x, y, z, yaw, pitch);
|
||||
|
||||
PersistenceData data = new PersistenceData(gems, location, questData, health, maxHealth, hunger, slots, itemsList.toArray(new ItemStack[0]), armourList.toArray(new ItemStack[0]), saveTime.getTime());
|
||||
PersistenceData data = new PersistenceData(gems, location, questData, health, maxHealth, hunger, slots, itemsList.toArray(new ItemStack[0]), armourList.toArray(new ItemStack[0]), saveTime.getTime(), cashOutTime);
|
||||
response.accept(data);
|
||||
}
|
||||
}, new ColumnInt("accountId", accountId));
|
||||
@ -137,6 +136,7 @@ public class PersistenceRepository extends RepositoryBase
|
||||
List<Map<String, Object>> itemsMap = new ArrayList<>(items.length);
|
||||
List<Map<String, Object>> armourMap = new ArrayList<>(armour.length);
|
||||
Timestamp saveTime = new Timestamp(data.getSaveTime());
|
||||
int cashOutTime = data.getCashOutTime();
|
||||
|
||||
for (ItemStack itemStack : items)
|
||||
{
|
||||
@ -175,6 +175,7 @@ public class PersistenceRepository extends RepositoryBase
|
||||
new ColumnVarChar("items", 10000, GSON.toJson(itemsMap)),
|
||||
new ColumnVarChar("armour", 1000, GSON.toJson(armourMap)),
|
||||
new ColumnTimestamp("saveTime", saveTime),
|
||||
new ColumnInt("cashOutTime", cashOutTime),
|
||||
new ColumnInt("accountId", accountId)
|
||||
);
|
||||
}
|
||||
@ -195,7 +196,8 @@ public class PersistenceRepository extends RepositoryBase
|
||||
new ColumnInt("slots", slots),
|
||||
new ColumnVarChar("items", 10000, GSON.toJson(itemsMap)),
|
||||
new ColumnVarChar("armour", 1000, GSON.toJson(armourMap)),
|
||||
new ColumnTimestamp("saveTime", saveTime)
|
||||
new ColumnTimestamp("saveTime", saveTime),
|
||||
new ColumnInt("cashOutTime", cashOutTime)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
package mineplex.gemhunters.quest;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.menu.Menu;
|
||||
import mineplex.gemhunters.util.SimpleNPC;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.Villager.Profession;
|
||||
@ -8,10 +11,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.menu.Menu;
|
||||
import mineplex.gemhunters.util.SimpleNPC;
|
||||
|
||||
public class QuestNPC extends SimpleNPC
|
||||
{
|
||||
|
||||
@ -19,7 +18,7 @@ public class QuestNPC extends SimpleNPC
|
||||
|
||||
public QuestNPC(QuestModule quest, Location spawn, Menu<?> menu)
|
||||
{
|
||||
super(quest.getPlugin(), spawn, Villager.class, C.cGreenB + "NEW - " + C.cYellowB + "Quest Master" + C.cGreenB + " - NEW", null);
|
||||
super(quest.getPlugin(), spawn, Villager.class, C.cYellowB + "Quest Master", null);
|
||||
|
||||
_questMenu = menu;
|
||||
_entity.setMetadata("quest_npc", new FixedMetadataValue(quest.getPlugin(), true));
|
||||
@ -40,7 +39,6 @@ public class QuestNPC extends SimpleNPC
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
//event.getPlayer().sendMessage(F.main("Quest", "The Quest Master is currently disabled but will be available to all players shortly."));
|
||||
_questMenu.open(event.getPlayer());
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,223 @@
|
||||
package mineplex.gemhunters.shop;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.gemhunters.economy.EconomyModule;
|
||||
import mineplex.gemhunters.util.SimpleNPC;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class SellingNPC extends SimpleNPC
|
||||
{
|
||||
|
||||
private static final ItemStack CANCEL = new ItemBuilder(Material.REDSTONE_BLOCK)
|
||||
.setTitle(C.cRedB + "Cancel")
|
||||
.addLore("", "Click to cancel and return your items.")
|
||||
.build();
|
||||
private static final ItemStack BUFFER = new ItemBuilder(Material.STAINED_GLASS_PANE, (byte) 15)
|
||||
.setTitle(" ")
|
||||
.build();
|
||||
|
||||
private final EconomyModule _economy;
|
||||
|
||||
private final Set<TradeableItem> _selling;
|
||||
private final Map<Player, Inventory> _inv;
|
||||
|
||||
private int _total;
|
||||
|
||||
public SellingNPC(JavaPlugin plugin, Location spawn, Class<? extends LivingEntity> type, String name, boolean vegetated, Set<TradeableItem> selling)
|
||||
{
|
||||
super(plugin, spawn, type, name, null, vegetated);
|
||||
|
||||
_economy = Managers.require(EconomyModule.class);
|
||||
|
||||
_selling = selling;
|
||||
_inv = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler
|
||||
public void npcClick(PlayerInteractEntityEvent event)
|
||||
{
|
||||
super.npcClick(event);
|
||||
|
||||
if (event.getRightClicked().equals(_entity))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Inventory inv = UtilServer.getServer().createInventory(null, 54, _entity.getCustomName());
|
||||
|
||||
inv.setItem(0, CANCEL);
|
||||
inv.setItem(8, getConfirm());
|
||||
|
||||
for (int i = 9; i < 18; i++)
|
||||
{
|
||||
inv.setItem(i, BUFFER);
|
||||
}
|
||||
|
||||
_inv.put(player, inv);
|
||||
player.openInventory(inv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void inventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
if (event.getInventory() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
Inventory inv = _inv.get(player);
|
||||
|
||||
if (inv == null | !event.getInventory().equals(inv))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack itemStack = event.getCurrentItem();
|
||||
ItemStack cursor = event.getCursor();
|
||||
|
||||
if (itemStack == null || cursor == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Material type = itemStack.getType();
|
||||
|
||||
if (type == Material.EMERALD_BLOCK || type == Material.REDSTONE_BLOCK || type == Material.STAINED_GLASS_PANE)
|
||||
{
|
||||
if (type == Material.EMERALD_BLOCK)
|
||||
{
|
||||
finalise(player);
|
||||
}
|
||||
else if (type == Material.REDSTONE_BLOCK)
|
||||
{
|
||||
cancel(player);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
TradeableItem currentItem = fromItemStack(itemStack);
|
||||
TradeableItem cursorItem = fromItemStack(cursor);
|
||||
|
||||
if (currentItem == null && cursorItem == null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
player.playSound(player.getLocation(), Sound.VILLAGER_NO, 1, 0.7F);
|
||||
player.sendMessage(F.main("Shop", "You cannot sell that item."));
|
||||
return;
|
||||
}
|
||||
|
||||
UtilServer.runSyncLater(() -> recalculatePrice(inv), 1);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void inventoryClose(InventoryCloseEvent event)
|
||||
{
|
||||
Player player = (Player) event.getPlayer();
|
||||
|
||||
if (_inv.containsKey(player))
|
||||
{
|
||||
cancel(player);
|
||||
}
|
||||
}
|
||||
|
||||
private void recalculatePrice(Inventory inv)
|
||||
{
|
||||
int price = 0;
|
||||
|
||||
for (ItemStack itemStack : inv.getContents())
|
||||
{
|
||||
TradeableItem tradeableItem = fromItemStack(itemStack);
|
||||
|
||||
if (tradeableItem == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
price += tradeableItem.getCost() * itemStack.getAmount();
|
||||
}
|
||||
|
||||
_total = price;
|
||||
inv.setItem(8, getConfirm());
|
||||
}
|
||||
|
||||
private void finalise(Player player)
|
||||
{
|
||||
recalculatePrice(_inv.remove(player));
|
||||
player.closeInventory();
|
||||
player.playSound(player.getLocation(), Sound.VILLAGER_YES, 1, 0.7F);
|
||||
_economy.addToStore(player, "Sold Items", _total);
|
||||
}
|
||||
|
||||
private void cancel(Player player)
|
||||
{
|
||||
Inventory inv = _inv.remove(player);
|
||||
|
||||
for (ItemStack itemStack : inv.getContents())
|
||||
{
|
||||
TradeableItem tradeableItem = fromItemStack(itemStack);
|
||||
|
||||
if (tradeableItem == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.getInventory().addItem(itemStack);
|
||||
}
|
||||
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
private TradeableItem fromItemStack(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for (TradeableItem item : _selling)
|
||||
{
|
||||
ItemStack itemStack2 = item.getLootItem().getItemStack();
|
||||
|
||||
if (itemStack.getType() == itemStack2.getType())
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private ItemStack getConfirm()
|
||||
{
|
||||
return new ItemBuilder(Material.EMERALD_BLOCK)
|
||||
.setTitle(C.cGreenB + "Confirm")
|
||||
.addLore("", "Click to sell these current items", "at a price of " + F.currency(GlobalCurrency.GEM, _total) + ".")
|
||||
.build();
|
||||
}
|
||||
}
|
@ -1,19 +1,8 @@
|
||||
package mineplex.gemhunters.shop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
@ -24,8 +13,13 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.gemhunters.loot.deserialisers.LootItemDeserialiser;
|
||||
import mineplex.gemhunters.safezone.SafezoneModule;
|
||||
import mineplex.gemhunters.shop.deserialisers.VillagerPropertiesDeserialiser;
|
||||
import mineplex.gemhunters.util.SlackSheetsBot;
|
||||
import mineplex.gemhunters.util.SlackRewardBot;
|
||||
import mineplex.gemhunters.world.WorldDataModule;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class ShopModule extends MiniPlugin
|
||||
@ -35,16 +29,7 @@ public class ShopModule extends MiniPlugin
|
||||
private static final String VILLAGER_MASTER_SHEET_NAME = "VILLAGER_MASTER";
|
||||
private static final VillagerPropertiesDeserialiser VILLAGER_PROPERTIES_DESERIALISER = new VillagerPropertiesDeserialiser();
|
||||
private static final LootItemDeserialiser DESERIALISER = new LootItemDeserialiser();
|
||||
private static final SheetObjectDeserialiser<Integer> COST_DESERIALISER = new SheetObjectDeserialiser<Integer>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public Integer deserialise(String[] values) throws ArrayIndexOutOfBoundsException, NumberFormatException
|
||||
{
|
||||
return Integer.parseInt(values[10]);
|
||||
}
|
||||
|
||||
};
|
||||
private static final SheetObjectDeserialiser<Integer> COST_DESERIALISER = values -> Integer.parseInt(values[10]);
|
||||
|
||||
private static final int MINIMUM_ITEMS = 1;
|
||||
private static final int MAXIMUM_ITEMS = 5;
|
||||
@ -107,10 +92,6 @@ public class ShopModule extends MiniPlugin
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (row != 1)
|
||||
{
|
||||
SlackSheetsBot.reportParsingError(e, "Villager Trades", key, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
@ -129,10 +110,6 @@ public class ShopModule extends MiniPlugin
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (row != 1)
|
||||
{
|
||||
SlackSheetsBot.reportParsingError(e, "Villager Trades", key, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,20 +185,31 @@ public class ShopModule extends MiniPlugin
|
||||
}
|
||||
|
||||
int index = getFreeIndex(locations.size(), usedIndexes);
|
||||
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Location randomLocation = locations.get(index);
|
||||
|
||||
randomLocation.setYaw(UtilMath.r(360));
|
||||
|
||||
|
||||
usedIndexes.add(index);
|
||||
|
||||
String name = NAMES[UtilMath.r(NAMES.length)];
|
||||
|
||||
name = (properties.isSelling() ? C.cGold + "Buying" : C.cGreen + "Selling") + C.cGray + " - " + C.cWhite + name;
|
||||
|
||||
//DebugModule.getInstance().d("Trader at " + UtilWorld.locToStrClean(randomLocation) + " with key=" + key + " and index=" + index + " and max=" + spawned + "/" + max);
|
||||
_npcs.add(new TraderNPC(_plugin, randomLocation, Villager.class, NAMES[UtilMath.r(NAMES.length)], _safezone.isInSafeZone(randomLocation), properties, getRandomItemSet(_trades.get(key))));
|
||||
if (properties.isSelling())
|
||||
{
|
||||
_npcs.add(new TraderNPC(_plugin, randomLocation, Villager.class, name, _safezone.isInSafeZone(randomLocation), properties, getRandomItemSet(_trades.get(key))));
|
||||
}
|
||||
else
|
||||
{
|
||||
new SellingNPC(_plugin, randomLocation, Villager.class, name, _safezone.isInSafeZone(randomLocation), _trades.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,7 +240,7 @@ public class ShopModule extends MiniPlugin
|
||||
return items2;
|
||||
}
|
||||
|
||||
private final String capitalise(String s)
|
||||
private String capitalise(String s)
|
||||
{
|
||||
String right = s.toLowerCase().substring(1);
|
||||
char left = Character.toUpperCase(s.charAt(0));
|
||||
|
@ -100,14 +100,14 @@ public class TraderNPC extends SimpleNPC
|
||||
|
||||
if (cost > gems)
|
||||
{
|
||||
player.sendMessage(F.main(_entity.getCustomName(), "I'm sorry you don't have enough gems to purchase this."));
|
||||
player.sendMessage(F.main("Shop", "I'm sorry you don't have enough gems to purchase this."));
|
||||
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0.6F);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UtilInv.HasSpace(player, itemStack.getType(), itemStack.getAmount()))
|
||||
{
|
||||
player.sendMessage(F.main(_entity.getCustomName(), "I'm sorry you don't have enough space to hold that."));
|
||||
player.sendMessage(F.main("Shop", "I'm sorry you don't have enough space to hold that."));
|
||||
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, 0.6F);
|
||||
return;
|
||||
}
|
||||
@ -125,7 +125,7 @@ public class TraderNPC extends SimpleNPC
|
||||
|
||||
String itemName = ItemStackFactory.Instance.GetName(itemStack, true);
|
||||
|
||||
player.sendMessage(F.main(_entity.getCustomName(), "Purchased " + F.elem(itemName) + "!"));
|
||||
player.sendMessage(F.main("Shop", "Purchased " + F.elem(itemName) + "!"));
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 1.2F);
|
||||
player.getInventory().addItem(itemStack);
|
||||
}
|
||||
|
@ -5,16 +5,18 @@ public class VillagerProperties
|
||||
|
||||
private final String _name;
|
||||
private final String _dataKey;
|
||||
private final boolean _selling;
|
||||
private final int _spawnRate;
|
||||
private final int _expireRate;
|
||||
private final int _max;
|
||||
|
||||
private long _lastSpawn;
|
||||
|
||||
public VillagerProperties(String name, String dataKey, int spawnRate, int expireRate, int max)
|
||||
public VillagerProperties(String name, String dataKey, boolean selling, int spawnRate, int expireRate, int max)
|
||||
{
|
||||
_name = name;
|
||||
_dataKey = dataKey;
|
||||
_selling = selling;
|
||||
_spawnRate = spawnRate;
|
||||
_expireRate = expireRate;
|
||||
_max = max;
|
||||
@ -32,6 +34,11 @@ public class VillagerProperties
|
||||
return _dataKey;
|
||||
}
|
||||
|
||||
public boolean isSelling()
|
||||
{
|
||||
return _selling;
|
||||
}
|
||||
|
||||
public final int getSpawnRate()
|
||||
{
|
||||
return _spawnRate;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.gemhunters.shop.deserialisers;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
import mineplex.core.google.SheetObjectDeserialiser;
|
||||
import mineplex.gemhunters.shop.VillagerProperties;
|
||||
|
||||
@ -11,13 +12,15 @@ public class VillagerPropertiesDeserialiser implements SheetObjectDeserialiser<V
|
||||
{
|
||||
String name = values[0];
|
||||
String dataKey = values[1];
|
||||
|
||||
|
||||
boolean selling = values[2].equalsIgnoreCase("Selling");
|
||||
|
||||
int spawnRate = Integer.parseInt(values[4]);
|
||||
int expireRate = Integer.parseInt(values[5]);
|
||||
|
||||
int max = Integer.parseInt(values[7]);
|
||||
|
||||
return new VillagerProperties(name, dataKey, spawnRate, expireRate, max);
|
||||
return new VillagerProperties(name, dataKey, selling, spawnRate, expireRate, max);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,10 @@
|
||||
package mineplex.gemhunters.spawn;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.gemhunters.playerstatus.PlayerStatus;
|
||||
import mineplex.gemhunters.playerstatus.PlayerStatusModule;
|
||||
import mineplex.gemhunters.playerstatus.PlayerStatusType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -17,12 +22,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.portal.GenericServer;
|
||||
import mineplex.core.portal.Intent;
|
||||
import mineplex.core.portal.Portal;
|
||||
@ -44,7 +43,7 @@ public class SpawnModule extends MiniPlugin
|
||||
private static final int MAX_SPAWNING_Y = 73;
|
||||
private static final int MIN_PLAYER_DISTANCE_SQUARED = 6400;
|
||||
|
||||
private final QuitNPCModule _npc;
|
||||
private final PlayerStatusModule _status;
|
||||
private final SafezoneModule _safezone;
|
||||
private final WorldDataModule _worldData;
|
||||
|
||||
@ -56,7 +55,7 @@ public class SpawnModule extends MiniPlugin
|
||||
{
|
||||
super("Spawn");
|
||||
|
||||
_npc = require(QuitNPCModule.class);
|
||||
_status = require(PlayerStatusModule.class);
|
||||
_safezone = require(SafezoneModule.class);
|
||||
_worldData = require(WorldDataModule.class);
|
||||
}
|
||||
@ -158,6 +157,12 @@ public class SpawnModule extends MiniPlugin
|
||||
new SimpleNPC(_plugin, location, Villager.class, C.cYellowB + "Random Teleport", clicker ->
|
||||
{
|
||||
|
||||
if (_status.Get(clicker).getStatusType() == PlayerStatusType.COMBAT || !Recharge.Instance.usable(clicker, "Cash Out"))
|
||||
{
|
||||
clicker.sendMessage(F.main(_moduleName, "You can not do this right now."));
|
||||
return;
|
||||
}
|
||||
|
||||
Location toTeleport = getRandomLocation();
|
||||
|
||||
if (toTeleport == null)
|
||||
|
@ -0,0 +1,49 @@
|
||||
package mineplex.gemhunters.util;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.monitor.LagMeter;
|
||||
import mineplex.core.slack.SlackAPI;
|
||||
import mineplex.core.slack.SlackMessage;
|
||||
import mineplex.core.slack.SlackTeam;
|
||||
import mineplex.gemhunters.loot.rewards.LootItemReward;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class SlackRewardBot
|
||||
{
|
||||
|
||||
private static final DecimalFormat FORMAT = new DecimalFormat("0.0");
|
||||
private static final String SLACK_CHANNEL_NAME = "#gem-hunters-logging";
|
||||
private static final String SLACK_USERNAME = "Gem Hunters";
|
||||
private static final String SLACK_ICON = "http://moppletop.github.io/mineplex/chest-image.png";
|
||||
|
||||
private static LagMeter _lag;
|
||||
|
||||
public static void logReward(Player player, LootItemReward reward, String status)
|
||||
{
|
||||
if (_lag == null)
|
||||
{
|
||||
_lag = Managers.get(LagMeter.class);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, SLACK_CHANNEL_NAME, new SlackMessage(SLACK_USERNAME, new URL(SLACK_ICON),
|
||||
"Rewarding a " + reward.getClass().getSimpleName() +
|
||||
"\nName: " + reward.getItemStack().getItemMeta().getDisplayName() +
|
||||
"\nPlayer: " + player.getName() +
|
||||
"\nStatus: *" + status + "*" +
|
||||
"\nServer: " + UtilServer.getServerName() +
|
||||
"\nTPS: " + FORMAT.format(_lag.getTicksPerSecond())),
|
||||
true);
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package mineplex.gemhunters.util;
|
||||
|
||||
public class SlackSheetsBot
|
||||
{
|
||||
|
||||
private static final String SLACK_CHANNEL_NAME = "#google-sheet-errors";
|
||||
private static final String SLACK_USERNAME = "Google Sheets";
|
||||
private static final String SLACK_ICON = "http://moppletop.github.io/mineplex/google-sheets-image.png";
|
||||
|
||||
public static final void reportParsingError(Exception exception, String spreadsheetName, String sheetName, int row)
|
||||
{
|
||||
String message = "A parsing error has occured on spreadsheet *" + spreadsheetName + "* sheet *" + sheetName + "* at row *" + row + "*.\n Details: " + exception.getMessage();
|
||||
|
||||
System.out.println(message);
|
||||
// try
|
||||
// {
|
||||
// SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, SLACK_CHANNEL_NAME, new SlackMessage(SLACK_USERNAME, new URL(SLACK_ICON), message), true);
|
||||
// }
|
||||
// catch (MalformedURLException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user