mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-11-23 02:35:25 +01:00
Added island banks.
This commit is contained in:
parent
d7efe4bdda
commit
6381e7b138
4
pom.xml
4
pom.xml
@ -20,7 +20,7 @@
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>private</id>
|
||||
<url>http://repo.songoda.com/repository/private</url>
|
||||
<url>http://repo.songoda.com/artifactory/private/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
@ -41,7 +41,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.nifheim.beelzebu</groupId>
|
||||
<artifactId>coins</artifactId>
|
||||
<artifactId>Coins</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -253,6 +253,7 @@ public class SkyBlock extends JavaPlugin {
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
configLoad.set("Stackables", null);
|
||||
|
||||
if (stackableManager.getStacks() == null) return;
|
||||
for (Stackable stackable : stackableManager.getStacks().values()) {
|
||||
if (island != stackable.getIsland()) continue;
|
||||
ConfigurationSection section = configLoad.createSection("Stackables." + stackable.getUuid().toString());
|
||||
|
@ -108,6 +108,8 @@ public class CommandManager implements CommandExecutor, TabCompleter {
|
||||
configLoad.getString("Command.Island.Weather.Info.Message"))));
|
||||
subCommands.add(new UnlockCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Command.Island.Unlock.Info.Message"))));
|
||||
subCommands.add(new BankCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&',
|
||||
configLoad.getString("Command.Island.Bank.Info.Message"))));
|
||||
// subCommands.add(new
|
||||
// RollbackCommand(skyblock).setInfo(ChatColor.translateAlternateColorCodes('&',
|
||||
// configLoad.getString("Command.Island.Rollback.Info.Message"))));
|
||||
|
@ -0,0 +1,143 @@
|
||||
package me.goodandevil.skyblock.command.commands;
|
||||
|
||||
import me.goodandevil.skyblock.SkyBlock;
|
||||
import me.goodandevil.skyblock.command.CommandManager.Type;
|
||||
import me.goodandevil.skyblock.command.SubCommand;
|
||||
import me.goodandevil.skyblock.config.FileManager;
|
||||
import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.economy.EconomyManager;
|
||||
import me.goodandevil.skyblock.island.Island;
|
||||
import me.goodandevil.skyblock.island.IslandManager;
|
||||
import me.goodandevil.skyblock.island.IslandRole;
|
||||
import me.goodandevil.skyblock.message.MessageManager;
|
||||
import me.goodandevil.skyblock.sound.SoundManager;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BankCommand extends SubCommand {
|
||||
|
||||
private final SkyBlock skyblock;
|
||||
private String info;
|
||||
|
||||
public BankCommand(SkyBlock skyblock) {
|
||||
this.skyblock = skyblock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByPlayer(Player player, String[] args) {
|
||||
MessageManager messageManager = skyblock.getMessageManager();
|
||||
EconomyManager economyManager = skyblock.getEconomyManager();
|
||||
IslandManager islandManager = skyblock.getIslandManager();
|
||||
SoundManager soundManager = skyblock.getSoundManager();
|
||||
FileManager fileManager = skyblock.getFileManager();
|
||||
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
|
||||
if (args.length == 0) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
String action = WordUtils.capitalize(args[0].toLowerCase());
|
||||
|
||||
Island island = islandManager.getIslandAtLocation(player.getLocation());
|
||||
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Unknown.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!island.hasRole(IslandRole.Operator, player.getUniqueId())
|
||||
&& !island.hasRole(IslandRole.Owner, player.getUniqueId())
|
||||
&& !island.hasRole(IslandRole.Member, player.getUniqueId())) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Perm.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
double balance = island.getBankBalance();
|
||||
|
||||
switch (action) {
|
||||
case "Balance":
|
||||
case "Bal":
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Balance.Message").replace(
|
||||
"%balance%", String.valueOf(balance)));
|
||||
return;
|
||||
case "Deposit": {
|
||||
double amt = Long.parseLong(args[1]);
|
||||
|
||||
if (!economyManager.hasBalance(player, amt)) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
economyManager.withdraw(player, amt);
|
||||
island.addToBank(amt);
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Deposit.Message").replace(
|
||||
"%amount%", String.valueOf(amt)));
|
||||
return;
|
||||
}
|
||||
case "Withdraw": {
|
||||
double amt = Long.parseLong(args[1]);
|
||||
|
||||
if (amt > balance) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short2.Message"));
|
||||
return;
|
||||
}
|
||||
economyManager.deposit(player, amt);
|
||||
island.removeFromBank(amt);
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Withdraw.Message").replace(
|
||||
"%amount%", String.valueOf(amt)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Invalid.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandByConsole(ConsoleCommandSender sender, String[] args) {
|
||||
sender.sendMessage("SkyBlock | Error: You must be a player to perform that command.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "bank";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubCommand setInfo(String info) {
|
||||
this.info = info;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAliases() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return Type.Default;
|
||||
}
|
||||
}
|
@ -58,6 +58,7 @@ public class UnlockCommand extends SubCommand {
|
||||
if (island == null) {
|
||||
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Owner.Message"));
|
||||
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
Config islandData = fileManager
|
||||
|
@ -60,6 +60,16 @@ public class EconomyManager {
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
|
||||
}
|
||||
|
||||
public void deposit(Player player, double money) {
|
||||
if (economy != null) {
|
||||
economy.depositPlayer(player, money);
|
||||
} else if (economyPlugin == EconomyPlugin.Coins) {
|
||||
CoinsAPI.addCoins(player.getUniqueId(), money);
|
||||
}
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
|
||||
}
|
||||
|
||||
public boolean isEconomy() {
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null
|
||||
&& Bukkit.getServer().getPluginManager().getPlugin("Coins") == null) {
|
||||
|
@ -5,7 +5,6 @@ import me.goodandevil.skyblock.config.FileManager.Config;
|
||||
import me.goodandevil.skyblock.utils.version.Materials;
|
||||
import me.goodandevil.skyblock.utils.version.NMSUtil;
|
||||
import me.goodandevil.skyblock.utils.version.Sounds;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@ -233,31 +232,27 @@ public class GeneratorManager {
|
||||
public void generateBlock(Generator generator, Block block) {
|
||||
block.setType(Material.AIR);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> {
|
||||
|
||||
Materials materials = getRandomMaterials(generator);
|
||||
Materials materials = getRandomMaterials(generator);
|
||||
|
||||
if (materials == null) return;
|
||||
Bukkit.getScheduler().runTask(skyblock, () -> {
|
||||
skyblock.getSoundManager().playSound(block.getLocation(), Sounds.FIZZ.bukkitSound(),
|
||||
1.0F, 10.0F);
|
||||
if (materials == null) return;
|
||||
skyblock.getSoundManager().playSound(block.getLocation(), Sounds.FIZZ.bukkitSound(),
|
||||
1.0F, 10.0F);
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 12) {
|
||||
block.setType(materials.parseMaterial());
|
||||
} else {
|
||||
ItemStack is = materials.parseItem();
|
||||
block.setType(is.getType());
|
||||
if (NMSUtil.getVersionNumber() > 12) {
|
||||
block.setType(materials.parseMaterial());
|
||||
} else {
|
||||
ItemStack is = materials.parseItem();
|
||||
block.setType(is.getType());
|
||||
|
||||
try {
|
||||
block.getClass().getMethod("setData", byte.class).invoke(block,
|
||||
(byte) is.getDurability());
|
||||
} catch (IllegalAccessException | IllegalArgumentException
|
||||
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
try {
|
||||
block.getClass().getMethod("setData", byte.class).invoke(block,
|
||||
(byte) is.getDurability());
|
||||
} catch (IllegalAccessException | IllegalArgumentException
|
||||
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Materials getRandomMaterials(Generator generator) {
|
||||
|
@ -3,6 +3,7 @@ package me.goodandevil.skyblock.hologram;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import me.goodandevil.skyblock.utils.version.NMSUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
@ -27,7 +28,10 @@ public class Hologram {
|
||||
public void addLine(String text) {
|
||||
ArmorStand as = (ArmorStand) location.getWorld().spawnEntity(
|
||||
location.clone().add(0.0D, getHeight() + getHeightIncrement(), 0.0D), EntityType.ARMOR_STAND);
|
||||
int NMSVersion = NMSUtil.getVersionNumber();
|
||||
as.setVisible(false);
|
||||
if (NMSVersion > 8)
|
||||
as.setMarker(false);
|
||||
as.setGravity(false);
|
||||
as.setCustomName(ChatColor.translateAlternateColorCodes('&', text));
|
||||
as.setCustomNameVisible(true);
|
||||
|
@ -609,6 +609,32 @@ public class Island {
|
||||
return null;
|
||||
}
|
||||
|
||||
public double getBankBalance() {
|
||||
return skyblock.getFileManager().getConfig(
|
||||
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml"))
|
||||
.getFileConfiguration().getDouble("Bank.Balance");
|
||||
}
|
||||
|
||||
public void addToBank(double value) {
|
||||
value = value + getBankBalance();
|
||||
skyblock.getFileManager().getConfig(
|
||||
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml"))
|
||||
.getFileConfiguration().set("Bank.Balance", value);
|
||||
}
|
||||
|
||||
public void removeFromBank(double value) {
|
||||
value = getBankBalance() - value;
|
||||
skyblock.getFileManager().getConfig(
|
||||
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml"))
|
||||
.getFileConfiguration().set("Bank.Balance", value);
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return skyblock.getFileManager().getConfig(
|
||||
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml"))
|
||||
.getFileConfiguration().getBoolean("Visitor.Open");
|
||||
}
|
||||
|
||||
public void setOpen(boolean open) {
|
||||
IslandOpenEvent islandOpenEvent = new IslandOpenEvent(getAPIWrapper(), open);
|
||||
Bukkit.getServer().getPluginManager().callEvent(islandOpenEvent);
|
||||
@ -621,12 +647,6 @@ public class Island {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return skyblock.getFileManager().getConfig(
|
||||
new File(new File(skyblock.getDataFolder().toString() + "/island-data"), uuid.toString() + ".yml"))
|
||||
.getFileConfiguration().getBoolean("Visitor.Open");
|
||||
}
|
||||
|
||||
public List<String> getMessage(IslandMessage message) {
|
||||
List<String> islandMessage = new ArrayList<>();
|
||||
|
||||
|
@ -1148,27 +1148,19 @@ public class IslandManager {
|
||||
|| island.hasRole(IslandRole.Operator, player.getUniqueId())) {
|
||||
if (player.hasPermission("fabledskyblock.fly") || player.hasPermission("fabledskyblock.fly")
|
||||
|| player.hasPermission("fabledskyblock.*")) {
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (player.hasPermission("fabledskyblock.fly") || player.hasPermission("fabledskyblock.*")) {
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
}
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (player.hasPermission("fabledskyblock.fly") || player.hasPermission("fabledskyblock.*")) {
|
||||
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void removeUpgrades(Player player, boolean bypassIsland) {
|
||||
|
@ -293,9 +293,12 @@ public class Block implements Listener {
|
||||
if (!LocationUtil.isLocationAtLocationRadius(block.getLocation(),
|
||||
island.getLocation(world, IslandEnvironment.Island), island.getRadius() - 2.0D)) {
|
||||
event.setCancelled(true);
|
||||
} else if (skyblock.getStackableManager() != null
|
||||
&& skyblock.getStackableManager().isStacked(block.getLocation())) {
|
||||
event.setCancelled(true);
|
||||
} else if (skyblock.getStackableManager() != null) {
|
||||
if (skyblock.getStackableManager().isStacked(block.getLocation())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (LocationUtil.isLocationLocation(block.getLocation(),
|
||||
island.getLocation(world, IslandEnvironment.Main)
|
||||
.clone()
|
||||
@ -341,6 +344,8 @@ public class Block implements Listener {
|
||||
Material material = event.getBlock().getType();
|
||||
if (material != Material.WATER && material != Material.LAVA) return;
|
||||
|
||||
if (event.getNewState().getType() != Material.COBBLESTONE) return;
|
||||
|
||||
if (generatorManager != null && generatorManager.getGenerators().size() > 0) {
|
||||
Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation());
|
||||
IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld());
|
||||
@ -360,6 +365,7 @@ public class Block implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
generatorManager.generateBlock(generator, block);
|
||||
return;
|
||||
}
|
||||
|
@ -102,6 +102,7 @@ public class Move implements Listener {
|
||||
|
||||
|
||||
if (island != null) {
|
||||
islandManager.removeUpgrades(player, false);
|
||||
if (islandManager.isLocationAtIsland(island, to)) {
|
||||
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||
FileConfiguration configLoad = config.getFileConfiguration();
|
||||
@ -122,6 +123,7 @@ public class Move implements Listener {
|
||||
|
||||
if (configLoad.getBoolean("Island.World." + world.name() + ".Liquid.Enable")) {
|
||||
if (to.getY() <= configLoad.getInt("Island.World." + world.name() + ".Liquid.Height")) {
|
||||
if (!configLoad.getBoolean("Island.Liquid.Teleport.Enable")) return;
|
||||
if (keepItemsOnDeath) {
|
||||
player.setFallDistance(0.0F);
|
||||
|
||||
|
@ -16,6 +16,25 @@ Command:
|
||||
Message: "&bSkyBlock &8| &cError&8: &ePlease provide a numerical value."
|
||||
Page:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eThere are not that many pages."
|
||||
Bank:
|
||||
Info:
|
||||
Message: "&f&oAllows you to access your islands bank."
|
||||
Unknown:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eYou are not currently on an island."
|
||||
Perm:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eYou do not have permission to access this islands bank."
|
||||
Balance:
|
||||
Message: "&bSkyBlock &8| &aInfo&8: &eYour islands balance is '&7$%balance%&e'."
|
||||
Deposit:
|
||||
Message: "&bSkyBlock &8| &aInfo&8: &eYou successfully deposited '&7$%amount%&e'."
|
||||
Withdraw:
|
||||
Message: "&bSkyBlock &8| &aInfo&8: &eYou successfully withdrew '&7$%amount%&e'."
|
||||
Short:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eYou don't have enough money to do that."
|
||||
Short2:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eThere is not enough money to withdraw."
|
||||
Invalid:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eInvalid: /island bank [<Deposit|Withdraw|Balance>]"
|
||||
Unlock:
|
||||
Owner:
|
||||
Message: "&bSkyBlock &8| &cError&8: &eYou are not an Island owner."
|
||||
|
Loading…
Reference in New Issue
Block a user