Update code for new DiamondBank-OG API
This commit is contained in:
1 parent
df7422213f
commit
05593b6b2d
5 files changed
+214
-171
No files matched your search
@@ -54,7 +54,6 @@ repositories {
|
||||
dependencies {
|
||||
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT") // Declare Purpur API version to be packaged.
|
||||
compileOnly("io.github.miniplaceholders:miniplaceholders-api:2.2.3") // Import MiniPlaceholders API.
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7") // Import Vault API.
|
||||
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.3.0-SNAPSHOT") // Import WorldEdit API.
|
||||
implementation("net.essentialsx:EssentialsX:2.20.1") // Import EssentialsX API.
|
||||
compileOnlyApi(project(":libs:Utilities-OG")) // Import TrueOG Network Utilities-OG Java API (from source).
|
||||
|
||||
+135
-106
@@ -19,66 +19,84 @@ import com.destroystokyo.paper.event.player.PlayerAdvancementCriterionGrantEvent
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import main.SpleggOG;
|
||||
import managers.Game;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.trueog.diamondbankog.DiamondBankException.EconomyDisabledException;
|
||||
import net.trueog.diamondbankog.DiamondBankException.InsufficientFundsException;
|
||||
import net.trueog.diamondbankog.DiamondBankException.InvalidPlayerException;
|
||||
import net.trueog.diamondbankog.DiamondBankException.PlayerNotOnlineException;
|
||||
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import utils.UtilPlayer;
|
||||
import utils.Utils;
|
||||
|
||||
public class Listeners implements Listener {
|
||||
|
||||
public static ArrayList<String> manager = new ArrayList<String>();
|
||||
public static ArrayList<String> moneymanager = new ArrayList<String>();
|
||||
public static ArrayList<String> shopmanager = new ArrayList<String>();
|
||||
public static ArrayList<String> diamondspade = new ArrayList<String>();
|
||||
public static ArrayList<String> goldspade = new ArrayList<String>();
|
||||
public static ArrayList<String> launchEggs = new ArrayList<String>();
|
||||
public static ArrayList<String> manager = new ArrayList<>();
|
||||
public static ArrayList<String> moneymanager = new ArrayList<>();
|
||||
public static ArrayList<String> shopmanager = new ArrayList<>();
|
||||
public static ArrayList<String> diamondspade = new ArrayList<>();
|
||||
public static ArrayList<String> goldspade = new ArrayList<>();
|
||||
public static ArrayList<String> launchEggs = new ArrayList<>();
|
||||
|
||||
private final DiamondBankAPIJava diamondBankAPI;
|
||||
|
||||
public Listeners(DiamondBankAPIJava diamondBankAPI) {
|
||||
|
||||
this.diamondBankAPI = diamondBankAPI;
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
final UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
|
||||
|
||||
if (shopmanager.contains(player.getName())) {
|
||||
|
||||
EconomyResponse r;
|
||||
|
||||
if (event.getCurrentItem().getType() == Material.GOLDEN_SHOVEL) {
|
||||
|
||||
player.getInventory().close();
|
||||
|
||||
if (SpleggOG.getPlugin().econ.getBalance(
|
||||
player) >= (double) SpleggOG.getPlugin().getConfig().getInt("GUI.Shop.GoldShovel.Price"))
|
||||
{
|
||||
final int priceInDiamonds = SpleggOG.getPlugin().getConfig().getInt("GUI.Shop.GoldShovel.Price");
|
||||
final long priceInShards = diamondBankAPI.diamondsToShards((float) priceInDiamonds);
|
||||
|
||||
r = SpleggOG.getPlugin().econ.withdrawPlayer(player,
|
||||
(double) SpleggOG.getPlugin().getConfig().getInt("GUI.Shop.GoldShovel.Price"));
|
||||
if (r.transactionSuccess()) {
|
||||
try {
|
||||
|
||||
goldspade.add(player.getName());
|
||||
diamondspade.remove(player.getName());
|
||||
shopmanager.remove(player.getName());
|
||||
manager.remove(player.getName());
|
||||
diamondBankAPI.consumeFromPlayer(player.getUniqueId(), priceInShards,
|
||||
"Player " + player.getName() + " purchased a Gold Shovel in Splegg.", "Plugin: Splegg-OG");
|
||||
|
||||
Utils.spleggOGMessage(player,
|
||||
SpleggOG.getPlugin().getConfig().getString("Messages.BuyGoldShovel"));
|
||||
goldspade.add(player.getName());
|
||||
diamondspade.remove(player.getName());
|
||||
shopmanager.remove(player.getName());
|
||||
manager.remove(player.getName());
|
||||
|
||||
} else {
|
||||
Utils.spleggOGMessage(player, SpleggOG.getPlugin().getConfig().getString("Messages.BuyGoldShovel"));
|
||||
|
||||
player.sendMessage(String.format("An error occured: %s", r.errorMessage));
|
||||
|
||||
shopmanager.add(player.getName());
|
||||
manager.add(player.getName());
|
||||
goldspade.remove(player.getName());
|
||||
diamondspade.remove(player.getName());
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
} catch (InsufficientFundsException insufficientFundsException) {
|
||||
|
||||
player.getInventory().close();
|
||||
|
||||
Utils.spleggOGMessage(player, SpleggOG.getPlugin().getConfig().getString("Messages.NoEnoughMoney"));
|
||||
|
||||
} catch (EconomyDisabledException economyDisabledException) {
|
||||
|
||||
UtilitiesOG.trueogMessage(player, "&cERROR: The Diamond economy is currently unavailable.");
|
||||
|
||||
shopmanager.add(player.getName());
|
||||
manager.add(player.getName());
|
||||
goldspade.remove(player.getName());
|
||||
diamondspade.remove(player.getName());
|
||||
|
||||
} catch (InvalidPlayerException | PlayerNotOnlineException playerException) {
|
||||
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"&cERROR: Your player account could not be found. Contact an administrator.");
|
||||
|
||||
shopmanager.add(player.getName());
|
||||
manager.add(player.getName());
|
||||
goldspade.remove(player.getName());
|
||||
diamondspade.remove(player.getName());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -87,39 +105,48 @@ public class Listeners implements Listener {
|
||||
|
||||
player.getInventory().close();
|
||||
|
||||
if (SpleggOG.getPlugin().econ.getBalance(
|
||||
player) >= (double) SpleggOG.getPlugin().getConfig().getInt("GUI.Shop.DiamondShovel.Price"))
|
||||
{
|
||||
final int priceInDiamonds = SpleggOG.getPlugin().getConfig().getInt("GUI.Shop.DiamondShovel.Price");
|
||||
final long priceInShards = diamondBankAPI.diamondsToShards((float) priceInDiamonds);
|
||||
|
||||
r = SpleggOG.getPlugin().econ.withdrawPlayer(player,
|
||||
(double) SpleggOG.getPlugin().getConfig().getInt("GUI.Shop.DiamondShovel.Price"));
|
||||
if (r.transactionSuccess()) {
|
||||
try {
|
||||
|
||||
goldspade.remove(player.getName());
|
||||
diamondspade.add(player.getName());
|
||||
shopmanager.remove(player.getName());
|
||||
manager.remove(player.getName());
|
||||
diamondBankAPI.consumeFromPlayer(player.getUniqueId(), priceInShards,
|
||||
"Player " + player.getName() + " purchased a Diamond Shovel in Splegg.",
|
||||
"Plugin: Splegg-OG");
|
||||
|
||||
Utils.spleggOGMessage(player,
|
||||
SpleggOG.getPlugin().getConfig().getString("Messages.BuyDiamondShovel"));
|
||||
goldspade.remove(player.getName());
|
||||
diamondspade.add(player.getName());
|
||||
shopmanager.remove(player.getName());
|
||||
manager.remove(player.getName());
|
||||
|
||||
} else {
|
||||
Utils.spleggOGMessage(player,
|
||||
SpleggOG.getPlugin().getConfig().getString("Messages.BuyDiamondShovel"));
|
||||
|
||||
player.sendMessage(String.format("An error occured: %s", r.errorMessage));
|
||||
|
||||
shopmanager.add(player.getName());
|
||||
manager.add(player.getName());
|
||||
goldspade.remove(player.getName());
|
||||
diamondspade.remove(player.getName());
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
} catch (InsufficientFundsException insufficientFundsException) {
|
||||
|
||||
player.getInventory().close();
|
||||
|
||||
Utils.spleggOGMessage(player, SpleggOG.getPlugin().getConfig().getString("Messages.NoEnoughMoney"));
|
||||
|
||||
} catch (EconomyDisabledException economyDisabledException) {
|
||||
|
||||
UtilitiesOG.trueogMessage(player, "&cERROR: The Diamond economy is currently unavailable.");
|
||||
|
||||
shopmanager.add(player.getName());
|
||||
manager.add(player.getName());
|
||||
goldspade.remove(player.getName());
|
||||
diamondspade.remove(player.getName());
|
||||
|
||||
} catch (InvalidPlayerException | PlayerNotOnlineException playerException) {
|
||||
|
||||
UtilitiesOG.trueogMessage(player,
|
||||
"&cERROR: Your player account could not be found. Contact an administrator.");
|
||||
|
||||
shopmanager.add(player.getName());
|
||||
manager.add(player.getName());
|
||||
goldspade.remove(player.getName());
|
||||
diamondspade.remove(player.getName());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -141,11 +168,11 @@ public class Listeners implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
public void onPlayerQuit(PlayerQuitEvent playerQuitEvent) {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
|
||||
Game game = u.getGame();
|
||||
final Player player = playerQuitEvent.getPlayer();
|
||||
final UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
|
||||
final Game game = u.getGame();
|
||||
|
||||
if (game != null) {
|
||||
|
||||
@@ -156,78 +183,80 @@ public class Listeners implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPickupItem(EntityPickupItemEvent event) {
|
||||
public void onPlayerPickupItem(EntityPickupItemEvent entityPickupItemEvent) {
|
||||
|
||||
if (event.getEntityType() == EntityType.PLAYER) {
|
||||
if (entityPickupItemEvent.getEntityType() != EntityType.PLAYER) {
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
|
||||
if (u.getGame() != null && u.isAlive()) {
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerAdvancement(PlayerAdvancementCriterionGrantEvent event) {
|
||||
|
||||
Player player = event.getPlayer();
|
||||
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
|
||||
final Player player = (Player) entityPickupItemEvent.getEntity();
|
||||
final UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
|
||||
if (u.getGame() != null && u.isAlive()) {
|
||||
|
||||
event.setCancelled(true);
|
||||
entityPickupItemEvent.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
public void onPlayerAdvancement(PlayerAdvancementCriterionGrantEvent playerAdvancementCriterionGrantEvent) {
|
||||
|
||||
Player player = (Player) event.getPlayer();
|
||||
UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
|
||||
Game game = u.getGame();
|
||||
if (game != null && Listeners.launchEggs.contains(u.getName())) {
|
||||
final Player player = playerAdvancementCriterionGrantEvent.getPlayer();
|
||||
final UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
|
||||
if (u.getGame() != null && u.isAlive()) {
|
||||
|
||||
EquipmentSlot playerHand = null;
|
||||
try {
|
||||
playerAdvancementCriterionGrantEvent.setCancelled(true);
|
||||
|
||||
playerHand = event.getHand();
|
||||
}
|
||||
|
||||
} catch (NullPointerException error) {
|
||||
}
|
||||
|
||||
SpleggOG.getPlugin().getLogger().severe("ERROR: Player's hand returned null.");
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent playerInteractEvent) {
|
||||
|
||||
}
|
||||
final Player player = playerInteractEvent.getPlayer();
|
||||
final UtilPlayer u = SpleggOG.getPlugin().pm.getPlayer(player);
|
||||
final Game game = u.getGame();
|
||||
if (!(game != null && Listeners.launchEggs.contains(u.getName()))) {
|
||||
|
||||
if (playerHand.equals(EquipmentSlot.HAND)) {
|
||||
return;
|
||||
|
||||
ItemStack itemInHand = player.getInventory().getItemInMainHand();
|
||||
switch (itemInHand.getType()) {
|
||||
}
|
||||
|
||||
case WOODEN_SHOVEL, STONE_SHOVEL, IRON_SHOVEL, GOLDEN_SHOVEL, DIAMOND_SHOVEL, NETHERITE_SHOVEL:
|
||||
Utils.fireEgg(event, u, player, itemInHand);
|
||||
break;
|
||||
case SLIME_BALL:
|
||||
EquipmentSlot playerHand = null;
|
||||
try {
|
||||
|
||||
game.leaveGame(u);
|
||||
playerHand = playerInteractEvent.getHand();
|
||||
|
||||
break;
|
||||
default:
|
||||
} catch (NullPointerException nullPointerException) {
|
||||
|
||||
if (itemInHand.getType() == Material
|
||||
.getMaterial(SpleggOG.getPlugin().getConfig().getString("Shop.Item")))
|
||||
{
|
||||
SpleggOG.getPlugin().getLogger().severe("ERROR: Player's hand returned null.");
|
||||
nullPointerException.printStackTrace();
|
||||
|
||||
player.openInventory(Utils.getShopInventory());
|
||||
}
|
||||
|
||||
}
|
||||
if (playerHand != EquipmentSlot.HAND) {
|
||||
|
||||
break;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final ItemStack itemInHand = player.getInventory().getItemInMainHand();
|
||||
switch (itemInHand.getType()) {
|
||||
|
||||
case WOODEN_SHOVEL, STONE_SHOVEL, IRON_SHOVEL, GOLDEN_SHOVEL, DIAMOND_SHOVEL, NETHERITE_SHOVEL ->
|
||||
Utils.fireEgg(playerInteractEvent, u, player, itemInHand);
|
||||
case SLIME_BALL -> game.leaveGame(u);
|
||||
default -> {
|
||||
|
||||
if (itemInHand.getType() == Material
|
||||
.getMaterial(SpleggOG.getPlugin().getConfig().getString("Shop.Item")))
|
||||
{
|
||||
|
||||
player.openInventory(Utils.getShopInventory());
|
||||
|
||||
}
|
||||
|
||||
@@ -238,7 +267,7 @@ public class Listeners implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAsyncPlayerChat(AsyncChatEvent event) {
|
||||
public void onAsyncPlayerChat(AsyncChatEvent asyncChatEvent) {
|
||||
|
||||
// TODO: Direct chat to world-specific channel here.
|
||||
|
||||
|
||||
@@ -22,17 +22,13 @@ import managers.Game;
|
||||
import managers.GameManager;
|
||||
import managers.GameUtilities;
|
||||
import managers.Status;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.trueog.diamondbankog.DiamondBankAPIJava;
|
||||
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
|
||||
import utils.UtilPlayer;
|
||||
import utils.Utils;
|
||||
|
||||
public class SpleggOG extends JavaPlugin {
|
||||
|
||||
DiamondBankAPIJava dbog;
|
||||
|
||||
private static SpleggOG plugin;
|
||||
public Economy econ = null;
|
||||
public Utils chat;
|
||||
public MapUtilities maps;
|
||||
public GameUtilities games;
|
||||
@@ -44,51 +40,76 @@ public class SpleggOG extends JavaPlugin {
|
||||
public String newVer = "";
|
||||
public boolean disabling = false;
|
||||
boolean economy = true;
|
||||
private DiamondBankAPIJava diamondBankAPI;
|
||||
|
||||
// TODO: If a shovel in the Splegg shop is too expensive, close the inventory
|
||||
// and tell the user about it.
|
||||
private boolean setupEconomy() {
|
||||
|
||||
if (this.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
|
||||
// ondBankAPI dbog;
|
||||
final RegisteredServiceProvider<DiamondBankAPIJava> diamondBankAPIProvider = getServer().getServicesManager()
|
||||
.getRegistration(DiamondBankAPIJava.class);
|
||||
if (diamondBankAPIProvider == null) {
|
||||
|
||||
getLogger().severe("DiamondBank-OG API is null");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return false;
|
||||
|
||||
} else {
|
||||
|
||||
RegisteredServiceProvider<Economy> rsp = this.getServer().getServicesManager()
|
||||
.getRegistration(Economy.class);
|
||||
if (rsp == null) {
|
||||
|
||||
return false;
|
||||
|
||||
} else {
|
||||
|
||||
this.econ = (Economy) rsp.getProvider();
|
||||
|
||||
return this.econ != null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.diamondBankAPI = diamondBankAPIProvider.getProvider();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
plugin = this;
|
||||
this.chat = new Utils();
|
||||
if (this.getServer().getPluginManager().getPlugin("WorldEdit") == null) {
|
||||
|
||||
String noWorldEditError = "\"ERROR: WorldEdit not found! Without WorldEdit, Splegg-OG will not function. Please download it from http://dev.bukkit.org/bukkit-plugins/worldedit\"";
|
||||
final String noWorldEditError = "\"ERROR: WorldEdit not found! Without WorldEdit, Splegg-OG will not function. Please download it from http://dev.bukkit.org/bukkit-plugins/worldedit\"";
|
||||
this.getLogger().severe(noWorldEditError);
|
||||
this.getLogger().info(noWorldEditError);
|
||||
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
|
||||
} else if (this.getServer().getPluginManager().getPlugin("DiamondBank-OG") == null) {
|
||||
|
||||
final String noDiamondBankOGError = "\"ERROR: DiamondBank-OG not found! Without WorldEdit, Splegg-OG will not function. Please download it from http://dev.bukkit.org/bukkit-plugins/worldedit\"";
|
||||
this.getLogger().severe(noDiamondBankOGError);
|
||||
this.getLogger().info(noDiamondBankOGError);
|
||||
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
|
||||
} else {
|
||||
|
||||
if (!this.setupEconomy()) {
|
||||
|
||||
// Inform the user that the plugin will not work due to a missing
|
||||
// DiamondBank-OG.
|
||||
// dependency.
|
||||
this.getLogger().severe("[%s] - Disabled due to no DiamomdBank-OG dependency found!"
|
||||
.formatted(this.getPluginMeta().getName()));
|
||||
|
||||
// Disable Splegg-OG for this instance because DiamondBank-OG (a crucial
|
||||
// dependency) was
|
||||
// not found.
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
|
||||
} else {
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach((Player p) -> {
|
||||
|
||||
final UtilPlayer u = new UtilPlayer(p);
|
||||
|
||||
this.pm.PLAYERS.put(p.getName(), u);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
this.maps = new MapUtilities();
|
||||
this.games = new GameUtilities();
|
||||
this.game = new GameManager();
|
||||
@@ -106,37 +127,14 @@ public class SpleggOG extends JavaPlugin {
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new SpleggEvents(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new SignListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new Listeners(), this);
|
||||
|
||||
getServer().getPluginManager().registerEvents(new Listeners(diamondBankAPI), this);
|
||||
this.getCommand("splegg").setExecutor(new SpleggCommand());
|
||||
|
||||
if (!this.setupEconomy()) {
|
||||
|
||||
// Inform the user that the plugin will not work due to a missing vault
|
||||
// dependency.
|
||||
this.getLogger().severe(String.format("[%s] - Disabled due to no Vault dependency found!",
|
||||
this.getPluginMeta().getName()));
|
||||
|
||||
// Disable Splegg-OG for this instance because Vault (a crucial dependency) was
|
||||
// not found.
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
|
||||
} else {
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
|
||||
UtilPlayer u = new UtilPlayer(p);
|
||||
|
||||
this.pm.PLAYERS.put(p.getName(), u);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
this.disabling = true;
|
||||
@@ -145,15 +143,15 @@ public class SpleggOG extends JavaPlugin {
|
||||
HandlerList.unregisterAll(new PlayerListener());
|
||||
HandlerList.unregisterAll(new SpleggEvents());
|
||||
HandlerList.unregisterAll(new SignListener());
|
||||
HandlerList.unregisterAll(new Listeners());
|
||||
HandlerList.unregisterAll(new Listeners(diamondBankAPI));
|
||||
|
||||
int gameCounter = 0;
|
||||
try {
|
||||
|
||||
Iterator<?> gameIterator = this.games.GAMES.values().iterator();
|
||||
final Iterator<?> gameIterator = this.games.GAMES.values().iterator();
|
||||
while (gameIterator.hasNext()) {
|
||||
|
||||
Game game = (Game) gameIterator.next();
|
||||
final Game game = (Game) gameIterator.next();
|
||||
if (game.getStatus() == Status.INGAME) {
|
||||
|
||||
gameCounter++;
|
||||
@@ -166,9 +164,10 @@ public class SpleggOG extends JavaPlugin {
|
||||
|
||||
this.getLogger().info("Splegg-OG Shut Down with " + gameCounter + " games running.");
|
||||
|
||||
} catch (NullPointerException error) {
|
||||
} catch (NullPointerException nullPointerException) {
|
||||
|
||||
this.getLogger().info("Splegg-OG Shut Down with 0 games running.");
|
||||
nullPointerException.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
@@ -176,7 +175,7 @@ public class SpleggOG extends JavaPlugin {
|
||||
|
||||
public WorldEditPlugin getWorldEdit() {
|
||||
|
||||
Plugin worldEdit = this.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
final Plugin worldEdit = this.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
|
||||
return worldEdit instanceof WorldEditPlugin ? (WorldEditPlugin) worldEdit : null;
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import config.Map;
|
||||
import events.Listeners;
|
||||
import main.SpleggOG;
|
||||
import net.trueog.diamondbankog.DiamondBankException.EconomyDisabledException;
|
||||
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
import runnables.GameTime;
|
||||
import runnables.LobbyCountdown;
|
||||
import signs.LobbySign;
|
||||
@@ -53,6 +56,7 @@ public class Game {
|
||||
int timer;
|
||||
boolean starting;
|
||||
LobbySign sign;
|
||||
DiamondBankAPIJava diamondBankAPI;
|
||||
|
||||
// Enable the conversion of text from config.yml to objects.
|
||||
public FileConfiguration config = SpleggOG.getPlugin().getConfig();
|
||||
@@ -380,10 +384,10 @@ public class Game {
|
||||
|
||||
private void saveInv(Player player) {
|
||||
|
||||
Essentials ess = (Essentials) SpleggOG.getPlugin().getServer().getPluginManager().getPlugin("Essentials");
|
||||
Kits preGameKit = new Kits(ess);
|
||||
final Essentials ess = (Essentials) SpleggOG.getPlugin().getServer().getPluginManager().getPlugin("Essentials");
|
||||
final Kits preGameKit = new Kits(ess);
|
||||
|
||||
ArrayList<String> itemsAsListOfStrings = new ArrayList<String>(player.getInventory().getSize());
|
||||
final ArrayList<String> itemsAsListOfStrings = new ArrayList<String>(player.getInventory().getSize());
|
||||
for (ItemStack item : player.getInventory().getContents()) {
|
||||
|
||||
if (item != null) {
|
||||
@@ -560,11 +564,23 @@ public class Game {
|
||||
|
||||
if (Listeners.moneymanager.contains(p.getName())) {
|
||||
|
||||
p.sendMessage(Utils
|
||||
.legacySerializerAnyCase(
|
||||
"&BYou received " + splegg.getConfig().getInt("Money.KillPlayer") + " &BDiamonds!")
|
||||
.content());
|
||||
splegg.econ.depositPlayer(p, splegg.getConfig().getInt("Money.KillPlayer"));
|
||||
final int rewardInDiamonds = splegg.getConfig().getInt("Money.KillPlayer");
|
||||
final long rewardInShards = diamondBankAPI.diamondsToShards((float) rewardInDiamonds);
|
||||
|
||||
try {
|
||||
|
||||
diamondBankAPI.addToPlayerBankShards(p.getUniqueId(), rewardInShards,
|
||||
"Player " + p.getName() + " earned Diamonds for a kill in Splegg.", "Plugin: Splegg-OG");
|
||||
|
||||
p.sendMessage(Utils.legacySerializerAnyCase("&BYou received " + rewardInDiamonds + " &BDiamonds!")
|
||||
.content());
|
||||
|
||||
} catch (EconomyDisabledException economyDisabledException) {
|
||||
|
||||
UtilitiesOG.trueogMessage(p,
|
||||
"&cERROR: The Diamond economy is currently unavailable. Your kill reward could not be paid out.");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ main: main.SpleggOG
|
||||
version: '${version}'
|
||||
authors: [Hraponssi, MrLuangamer, Theluangamer9416, NotAlexNoyle]
|
||||
api-version: '${apiVersion}'
|
||||
depend: [Vault, WorldEdit]
|
||||
depend: [DiamondBank-OG, WorldEdit]
|
||||
|
||||
commands:
|
||||
splegg:
|
||||
|
||||
Reference in new issue
Block a user