Merge branch 'development'

This commit is contained in:
Brianna 2020-06-06 15:27:51 -05:00
commit 6a1e43fa34
12 changed files with 39 additions and 291 deletions

2
.gitignore vendored
View File

@ -36,3 +36,5 @@ hs_err_pid*
# JDT-specific (Eclipse Java Development Tools)
.classpath
/target/
*.iml

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId>
<artifactId>skyblock</artifactId>
<version>2.2.13</version>
<version>2.2.14</version>
<packaging>jar</packaging>
<build>
<defaultGoal>clean install</defaultGoal>
@ -138,12 +138,6 @@
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.OmerBenGera</groupId>
<artifactId>WildStackerAPI</artifactId>
<version>b15</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>ultimatestacker</artifactId>

View File

@ -186,7 +186,6 @@ public class SkyBlock extends SongodaPlugin {
pluginManager.registerEvents(new FallBreak(this), this);
if (pluginManager.isPluginEnabled("EpicSpawners")) pluginManager.registerEvents(new EpicSpawners(this), this);
if (pluginManager.isPluginEnabled("WildStacker")) pluginManager.registerEvents(new WildStacker(this), this);
if (pluginManager.isPluginEnabled("UltimateStacker"))
pluginManager.registerEvents(new UltimateStacker(this), this);

View File

@ -19,7 +19,7 @@ public class BankManager {
public static BankManager getInstance() {return instance == null ? instance = new BankManager() : instance;}
public HashMap<UUID, List<Transaction>> log;
private HashMap<UUID, List<Transaction>> log;
public FileConfiguration lang;
@ -35,12 +35,10 @@ public class BankManager {
if (log.containsKey(player.getUniqueId())&&log.get(player.getUniqueId())!=null&&!log.get(player.getUniqueId()).isEmpty()) {
List<String> lore = new ArrayList<>();
List<Transaction> transactions = log.get(player.getUniqueId());
int count = 1;
while (count <= 10) {
if (transactions.size()-count < 0) { break; }
Transaction t = transactions.get(transactions.size()-count);
lore.add("#" + count + " " + t.timestamp.toString() +" " + t.player.getPlayer().getDisplayName() + " " + t.action.name().toLowerCase() + " " + EconomyManager.formatEconomy(t.ammount));
count++;
int size = transactions.size()>10 ? 10 : transactions.size();
for (int i = 0;i<size;i++) {
Transaction t = transactions.get((transactions.size()-1)-i);
lore.add("#" + (i+1) + " " + t.timestamp.toString() +" " + t.player.getPlayer().getDisplayName() + " " + t.action.name().toLowerCase() + " " + EconomyManager.formatEconomy(t.ammount));
}
return lore;
}else {
@ -53,13 +51,11 @@ public class BankManager {
public void addTransaction(Player p, Transaction transaction) {
if (log.containsKey(p.getUniqueId())) {
log.get(p.getUniqueId()).add(transaction);
}else {
}else {
List<Transaction> t = new ArrayList<>();
t.add(transaction);
log.put(p.getUniqueId(),t);
}
SkyBlock.getInstance().getPlayerDataManager().getPlayerData().get(p.getUniqueId()).getTransactions().add(transaction);
}
private void loadTransactions() {
@ -70,8 +66,9 @@ public class BankManager {
public List<String> getBalanceLore(Player player) {
List<String> result = new ArrayList<>();
result.add("Some error occured while loading your balance");
result.add("Some error occurred while loading your balance!");
Island island = SkyBlock.getInstance().getIslandManager().getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));
result.add("If this is null then its a easy to fix bug: "+island.toString());
if (island != null) {
result.clear();
result.add(player.getDisplayName()+"'s balance is "+EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId()))));

View File

@ -121,7 +121,7 @@ public class AdminBank extends SubCommand {
@Override
public String getName() {
return "adminbank";
return "bank";
}
@Override

View File

@ -532,6 +532,7 @@ public class IslandManager {
if ((amt = data.getIslandDeletionCount()) >= highest) return false;
data.setIslandDeletionCount(amt + 1);
data.deleteTransactions();
}
}
}

View File

@ -3,21 +3,16 @@ package com.songoda.skyblock.levelling.rework;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.skyblock.utils.version.CompatibleSpawners;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
@ -31,7 +26,6 @@ import com.songoda.skyblock.levelling.rework.calculator.Calculator;
import com.songoda.skyblock.levelling.rework.calculator.CalculatorRegistry;
import com.songoda.skyblock.levelling.rework.calculator.impl.EpicSpawnerCalculator;
import com.songoda.skyblock.levelling.rework.calculator.impl.UltimateStackerCalculator;
import com.songoda.skyblock.levelling.rework.calculator.impl.WildStackerCalculator;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.stackable.StackableManager;
@ -152,7 +146,6 @@ public final class IslandLevelManager {
if (pm.isPluginEnabled("EpicSpawners")) CalculatorRegistry.registerCalculator(new EpicSpawnerCalculator(), spawner);
if (pm.isPluginEnabled("UltimateStacker")) CalculatorRegistry.registerCalculator(new UltimateStackerCalculator(), spawner);
if (pm.isPluginEnabled("WildStacker")) CalculatorRegistry.registerCalculator(new WildStackerCalculator(), spawner);
}
private static final AmountMaterialPair EMPTY = new AmountMaterialPair(null, 0);

View File

@ -1,17 +0,0 @@
package com.songoda.skyblock.levelling.rework.calculator.impl;
import org.bukkit.block.CreatureSpawner;
import com.bgsoftware.wildstacker.api.WildStackerAPI;
import com.bgsoftware.wildstacker.api.objects.StackedSpawner;
import com.songoda.skyblock.levelling.rework.calculator.SpawnerCalculator;
public class WildStackerCalculator implements SpawnerCalculator {
@Override
public long getSpawnerAmount(CreatureSpawner spawner) {
final StackedSpawner stacked = WildStackerAPI.getStackedSpawner(spawner);
return stacked == null ? 0 : stacked.getStackAmount();
}
}

View File

@ -1,236 +0,0 @@
package com.songoda.skyblock.listeners;
import com.bgsoftware.wildstacker.api.events.*;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandLevel;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.utils.version.CompatibleSpawners;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.world.WorldManager;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import java.io.File;
public class WildStacker implements Listener {
private final SkyBlock skyblock;
public WildStacker(SkyBlock skyblock) {
this.skyblock = skyblock;
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBarrelPlace(BarrelPlaceEvent event) {
IslandManager islandManager = skyblock.getIslandManager();
WorldManager worldManager = skyblock.getWorldManager();
Location location = event.getBarrel().getLocation();
if (!worldManager.isIslandWorld(location.getWorld())) return;
Island island = islandManager.getIslandAtLocation(location);
Material material = event.getBarrel().getType();
if (NMSUtil.getVersionNumber() > 12 && material.name().startsWith("LEGACY_")) {
material = Material.matchMaterial(material.name().replace("LEGACY_", ""));
}
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
CompatibleMaterial materials = CompatibleMaterial.getBlockMaterial(material);
if (materials != null) {
IslandLevel level = island.getLevel();
long materialAmount = 0;
if (level.hasMaterial(materials.name())) {
materialAmount = level.getMaterialAmount(materials.name());
}
level.setMaterialAmount(materials.name(), materialAmount + event.getBarrel().getStackAmount() - 1); // -1 because the Interact handler will always add +1
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBarrelStack(BarrelStackEvent event) {
IslandManager islandManager = skyblock.getIslandManager();
WorldManager worldManager = skyblock.getWorldManager();
Location location = event.getBarrel().getLocation();
if (!worldManager.isIslandWorld(location.getWorld())) return;
Island island = islandManager.getIslandAtLocation(location);
Material material = event.getBarrel().getType();
if (NMSUtil.getVersionNumber() > 12 && material.name().startsWith("LEGACY_")) {
material = Material.matchMaterial(material.name().replace("LEGACY_", ""));
}
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
CompatibleMaterial materials = CompatibleMaterial.getBlockMaterial(material);
if (materials != null) {
IslandLevel level = island.getLevel();
long materialAmount = 0;
if (level.hasMaterial(materials.name())) {
materialAmount = level.getMaterialAmount(materials.name());
}
level.setMaterialAmount(materials.name(), materialAmount + event.getTarget().getStackAmount() - 1); // -1 because the Interact handler will always add +1
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBarrelUnstack(BarrelUnstackEvent event) {
IslandManager islandManager = skyblock.getIslandManager();
WorldManager worldManager = skyblock.getWorldManager();
Location location = event.getBarrel().getLocation();
if (!worldManager.isIslandWorld(location.getWorld())) return;
Island island = islandManager.getIslandAtLocation(location);
Material material = event.getBarrel().getType();
if (NMSUtil.getVersionNumber() > 12 && material.name().startsWith("LEGACY_")) {
material = Material.matchMaterial(material.name().replace("LEGACY_", ""));
}
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
CompatibleMaterial materials = CompatibleMaterial.getBlockMaterial(material);
if (materials != null) {
IslandLevel level = island.getLevel();
if (level.hasMaterial(materials.name())) {
long materialAmount = level.getMaterialAmount(materials.name());
if (materialAmount - event.getAmount() <= 0) {
level.removeMaterial(materials.name());
} else {
level.setMaterialAmount(materials.name(), materialAmount - event.getAmount());
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSpawnerPlace(SpawnerPlaceEvent event) {
IslandManager islandManager = skyblock.getIslandManager();
WorldManager worldManager = skyblock.getWorldManager();
Location location = event.getSpawner().getLocation();
if (!worldManager.isIslandWorld(location.getWorld())) return;
Island island = islandManager.getIslandAtLocation(location);
EntityType spawnerType = event.getSpawner().getSpawnedType();
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
CompatibleSpawners materials = CompatibleSpawners.getSpawner(spawnerType);
if (materials != null) {
IslandLevel level = island.getLevel();
long materialAmount = 0;
if (level.hasMaterial(materials.name())) {
materialAmount = level.getMaterialAmount(materials.name());
}
level.setMaterialAmount(materials.name(), materialAmount + event.getSpawner().getStackAmount());
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSpawnerStack(SpawnerStackEvent event) {
IslandManager islandManager = skyblock.getIslandManager();
WorldManager worldManager = skyblock.getWorldManager();
Location location = event.getSpawner().getLocation();
if (!worldManager.isIslandWorld(location.getWorld())) return;
Island island = islandManager.getIslandAtLocation(location);
EntityType spawnerType = event.getSpawner().getSpawnedType();
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
CompatibleSpawners materials = CompatibleSpawners.getSpawner(spawnerType);
if (materials != null) {
IslandLevel level = island.getLevel();
long materialAmount = 0;
if (level.hasMaterial(materials.name())) {
materialAmount = level.getMaterialAmount(materials.name());
}
level.setMaterialAmount(materials.name(), materialAmount + event.getTarget().getStackAmount());
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSpawnerUnstack(SpawnerUnstackEvent event) {
IslandManager islandManager = skyblock.getIslandManager();
WorldManager worldManager = skyblock.getWorldManager();
Location location = event.getSpawner().getLocation();
if (!worldManager.isIslandWorld(location.getWorld())) return;
Island island = islandManager.getIslandAtLocation(location);
EntityType spawnerType = event.getSpawner().getSpawnedType();
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
CompatibleSpawners materials = CompatibleSpawners.getSpawner(spawnerType);
if (materials != null) {
IslandLevel level = island.getLevel();
if (level.hasMaterial(materials.name())) {
long materialAmount = level.getMaterialAmount(materials.name());
if (materialAmount - event.getAmount() <= 0) {
level.removeMaterial(materials.name());
} else {
level.setMaterialAmount(materials.name(), materialAmount - event.getAmount());
}
}
}
}
}
}

View File

@ -146,7 +146,7 @@ public class Bank {
}
public void open(Player player) {
Island island = null;
Island island;
island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));

View File

@ -229,18 +229,34 @@ public class PlayerData {
this.viewer = viewer;
}
public void deleteTransactions() {
Config config = getConfig();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Bank.Transactions",null);
configLoad.set("Bank.Transactions.Size",0);
try {
configLoad.save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
}
public void save() {
transactions = BankManager.getInstance().getTransactionList(getPlayer());
Config config = getConfig();
FileConfiguration configLoad = config.getFileConfiguration();
configLoad.set("Statistics.Island.Playtime", getPlaytime());
configLoad.set("Bank.Transactions.Size",transactions.size());
for (int i = 0;i<transactions.size();i++) {
Transaction t = transactions.get(i);
configLoad.set("Bank.Transactions."+i+".Action",t.action.name());
configLoad.set("Bank.Transactions."+i+".Amount",t.ammount);
configLoad.set("Bank.Transactions."+i+".Player",t.player.getUniqueId().toString());
configLoad.set("Bank.Transactions."+i+".Date",t.timestamp.getTime());
if (transactions != null) {
configLoad.set("Bank.Transactions.Size", transactions.size());
for (int i = 0; i < transactions.size(); i++) {
Transaction t = transactions.get(i);
configLoad.set("Bank.Transactions." + i + ".Action", t.action.name());
configLoad.set("Bank.Transactions." + i + ".Amount", t.ammount);
configLoad.set("Bank.Transactions." + i + ".Player", t.player.getUniqueId().toString());
configLoad.set("Bank.Transactions." + i + ".Date", t.timestamp.getTime());
}
}else {
configLoad.set("Bank.Transactions.Size", 0);
}
try {
configLoad.save(config.getFile());
@ -251,7 +267,6 @@ public class PlayerData {
private Config getConfig() {
SkyBlock skyblock = SkyBlock.getInstance();
return skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/player-data"), uuid.toString() + ".yml"));
}

View File

@ -152,7 +152,7 @@ Command:
Short01:
Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin bank [<Deposit|Withdraw|Balance>]'
Short02:
Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin bank [Player] [<Deposit|Withdraw|Balance>]'
Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin bank [<Deposit|Withdraw|Balance>] [Player]'
NullIsland:
Message: '&bSkyBlock &8| &cError&8: &eYou are not on an island, please specify a Player or move to an island. Or maybe you are on nullisland?'
ByConsole:
@ -160,7 +160,7 @@ Command:
Balance:
Message: ' %player% have %bal%.'
Info:
Message: '&bSkyBlock &8| &cError&8: /island admin bank [Player] [<Deposit|Withdraw|Balance>]'
Message: '&bSkyBlock &8| &cError&8: /island admin bank [<Deposit|Withdraw|Balance>] [Player]'
SuccesWithdraw:
Message: 'Succesfully removed %ammount% from %player%''s island'
SuccesDeposit: