BentoBox version

This commit is contained in:
tastybento 2018-07-28 21:42:29 -07:00
parent 5137efb7f0
commit e559c67dd3
15 changed files with 72 additions and 65 deletions

View File

@ -47,9 +47,10 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>us.tastybento</groupId>
<artifactId>bskyblock</artifactId>
<groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>bskyblock.addon</groupId>

View File

@ -13,11 +13,11 @@ import bskyblock.addon.level.commands.IslandTop;
import bskyblock.addon.level.config.Settings;
import bskyblock.addon.level.database.object.LevelsData;
import bskyblock.addon.level.listeners.NewIslandListener;
import us.tastybento.bskyblock.api.addons.Addon;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.BSBDatabase;
import us.tastybento.bskyblock.database.objects.Island;
import world.bentobox.bbox.api.addons.Addon;
import world.bentobox.bbox.api.commands.CompositeCommand;
import world.bentobox.bbox.api.user.User;
import world.bentobox.bbox.database.BSBDatabase;
import world.bentobox.bbox.database.objects.Island;
/**
@ -106,7 +106,7 @@ public class Level extends Addon {
// Initialize the cache
levelsCache = new HashMap<>();
// Load the calculator
levelCalc = new LevelPresenter(this, getBSkyBlock());
levelCalc = new LevelPresenter(this, this.getBSkyBlock());
// Start the top ten and register it for clicks
topTen = new TopTen(this);
registerListener(topTen);
@ -115,20 +115,27 @@ public class Level extends Addon {
getServer().getScheduler().runTask(getBSkyBlock(), () -> {
this.getBSkyBlock().getAddonsManager().getAddonByName("AcidIsland").ifPresent(a -> {
CompositeCommand acidIslandCmd = getBSkyBlock().getCommandsManager().getCommand("ai");
new IslandLevel(this, acidIslandCmd);
new IslandTop(this, acidIslandCmd);
CompositeCommand acidCmd = getBSkyBlock().getCommandsManager().getCommand("acid");
new AdminLevel(this, acidCmd);
new AdminTop(this, acidCmd);
if (acidIslandCmd != null) {
new IslandLevel(this, acidIslandCmd);
new IslandTop(this, acidIslandCmd);
CompositeCommand acidCmd = getBSkyBlock().getCommandsManager().getCommand("acid");
new AdminLevel(this, acidCmd);
new AdminTop(this, acidCmd);
}
});
// BSkyBlock hook in
this.getBSkyBlock().getAddonsManager().getAddonByName("BSkyBlock").ifPresent(a -> {
CompositeCommand bsbIslandCmd = getBSkyBlock().getCommandsManager().getCommand("island");
if (bsbIslandCmd != null) {
new IslandLevel(this, bsbIslandCmd);
new IslandTop(this, bsbIslandCmd);
CompositeCommand bsbAdminCmd = getBSkyBlock().getCommandsManager().getCommand("bsbadmin");
new AdminLevel(this, bsbAdminCmd);
new AdminTop(this, bsbAdminCmd);
}
});
});
// BSkyBlock hook in
CompositeCommand bsbIslandCmd = getBSkyBlock().getCommandsManager().getCommand("island");
new IslandLevel(this, bsbIslandCmd);
new IslandTop(this, bsbIslandCmd);
CompositeCommand bsbAdminCmd = getBSkyBlock().getCommandsManager().getCommand("bsbadmin");
new AdminLevel(this, bsbAdminCmd);
new AdminTop(this, bsbAdminCmd);
// Register new island listener
registerListener(new NewIslandListener(this));
// Done

View File

@ -7,21 +7,21 @@ import java.util.UUID;
import org.bukkit.World;
import bskyblock.addon.level.calculators.PlayerLevel;
import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.user.User;
import world.bentobox.bbox.BentoBox;
import world.bentobox.bbox.api.user.User;
public class LevelPresenter {
private int levelWait;
private final Level addon;
private final BSkyBlock bSkyBlock;
private final BentoBox plugin;
// Level calc cool down
private HashMap<UUID, Long> levelWaitTime = new HashMap<UUID, Long>();
public LevelPresenter(Level plugin, BSkyBlock bSkyBlock) {
this.addon = plugin;
this.bSkyBlock = bSkyBlock;
public LevelPresenter(Level addon, BentoBox plugin) {
this.addon = addon;
this.plugin = plugin;
}
/**
@ -33,13 +33,13 @@ public class LevelPresenter {
*/
public boolean calculateIslandLevel(World world, final User sender, UUID targetPlayer) {
// Get permission prefix for this world
String permPrefix = bSkyBlock.getIWM().getPermissionPrefix(world);
String permPrefix = plugin.getIWM().getPermissionPrefix(world);
// Check if target has island
boolean inTeam = false;
if (!bSkyBlock.getIslands().hasIsland(world, targetPlayer)) {
if (!plugin.getIslands().hasIsland(world, targetPlayer)) {
// Player may be in a team
if (bSkyBlock.getIslands().inTeam(world, targetPlayer)) {
targetPlayer = bSkyBlock.getIslands().getTeamLeader(world, targetPlayer);
if (plugin.getIslands().inTeam(world, targetPlayer)) {
targetPlayer = plugin.getIslands().getTeamLeader(world, targetPlayer);
inTeam = true;
} else {
sender.sendMessage("general.errors.player-has-no-island");
@ -52,7 +52,7 @@ public class LevelPresenter {
if (!onLevelWaitTime(sender) || levelWait <= 0 || sender.isOp() || sender.hasPermission(permPrefix + "mod.info")) {
sender.sendMessage("island.level.calculating");
setLevelWaitTime(sender);
new PlayerLevel(addon, bSkyBlock.getIslands().getIsland(world, targetPlayer), targetPlayer, sender);
new PlayerLevel(addon, plugin.getIslands().getIsland(world, targetPlayer), targetPlayer, sender);
} else {
// Cooldown
sender.sendMessage("island.level.cooldown", "[time]", String.valueOf(getLevelWaitTime(sender)));

View File

@ -13,16 +13,14 @@ import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import bskyblock.addon.level.database.object.LevelsData;
import bskyblock.addon.level.database.object.TopTenData;
import bskyblock.addon.warps.Warp;
import us.tastybento.bskyblock.api.panels.PanelItem;
import us.tastybento.bskyblock.api.panels.builders.PanelBuilder;
import us.tastybento.bskyblock.api.panels.builders.PanelItemBuilder;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.BSBDatabase;
import world.bentobox.bbox.api.panels.PanelItem;
import world.bentobox.bbox.api.panels.builders.PanelBuilder;
import world.bentobox.bbox.api.panels.builders.PanelItemBuilder;
import world.bentobox.bbox.api.user.User;
import world.bentobox.bbox.database.BSBDatabase;
/**
* Handles all Top Ten List functions
@ -172,6 +170,7 @@ public class TopTen implements Listener {
.description(description);
// If welcome warps is present then add warping
/*
addon.getAddonByName("BSkyBlock-WelcomeWarps").ifPresent(warp -> {
if (((Warp)warp).getWarpSignsManager().hasWarp(world, playerUUID)) {
@ -183,7 +182,7 @@ public class TopTen implements Listener {
return true;
});
}
});
});*/
return builder.build();
}

View File

@ -20,9 +20,9 @@ import com.google.common.collect.Multiset.Entry;
import com.google.common.collect.Multisets;
import bskyblock.addon.level.Level;
import us.tastybento.bskyblock.database.objects.Island;
import us.tastybento.bskyblock.util.Pair;
import us.tastybento.bskyblock.util.Util;
import world.bentobox.bbox.database.objects.Island;
import world.bentobox.bbox.util.Pair;
import world.bentobox.bbox.util.Util;
public class CalcIslandLevel {
@ -201,7 +201,7 @@ public class CalcIslandLevel {
// Finalize calculations
result.rawBlockCount += (long)(result.underWaterBlockCount * addon.getSettings().getUnderWaterMultiplier());
// Set the death penalty
result.deathHandicap = addon.getPlayers().getDeaths(island.getOwner());
result.deathHandicap = addon.getPlayers().getDeaths(world, island.getOwner());
// Set final score
result.level = (result.rawBlockCount / addon.getSettings().getLevelCost()) - result.deathHandicap - island.getLevelHandicap();
// Calculate how many points are required to get to the next level

View File

@ -8,8 +8,8 @@ import bskyblock.addon.level.Level;
import bskyblock.addon.level.calculators.CalcIslandLevel.Results;
import bskyblock.addon.level.event.IslandLevelCalculatedEvent;
import bskyblock.addon.level.event.IslandPreLevelEvent;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island;
import world.bentobox.bbox.api.user.User;
import world.bentobox.bbox.database.objects.Island;
/**

View File

@ -4,8 +4,8 @@ import java.util.List;
import java.util.UUID;
import bskyblock.addon.level.Level;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import world.bentobox.bbox.api.commands.CompositeCommand;
import world.bentobox.bbox.api.user.User;
public class AdminLevel extends CompositeCommand {

View File

@ -7,9 +7,9 @@ import java.util.UUID;
import org.bukkit.World;
import bskyblock.addon.level.Level;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.database.objects.Island;
import world.bentobox.bbox.api.commands.CompositeCommand;
import world.bentobox.bbox.api.user.User;
import world.bentobox.bbox.database.objects.Island;
public class AdminTop extends CompositeCommand {

View File

@ -4,8 +4,8 @@ import java.util.List;
import java.util.UUID;
import bskyblock.addon.level.Level;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import world.bentobox.bbox.api.commands.CompositeCommand;
import world.bentobox.bbox.api.user.User;
public class IslandLevel extends CompositeCommand {

View File

@ -3,8 +3,8 @@ package bskyblock.addon.level.commands;
import java.util.List;
import bskyblock.addon.level.Level;
import us.tastybento.bskyblock.api.commands.CompositeCommand;
import us.tastybento.bskyblock.api.user.User;
import world.bentobox.bbox.api.commands.CompositeCommand;
import world.bentobox.bbox.api.user.User;
public class IslandTop extends CompositeCommand {

View File

@ -8,7 +8,7 @@ import org.bukkit.World;
import com.google.gson.annotations.Expose;
import us.tastybento.bskyblock.database.objects.DataObject;
import world.bentobox.bbox.database.objects.DataObject;
public class LevelsData implements DataObject {
@ -36,7 +36,7 @@ public class LevelsData implements DataObject {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.database.objects.DataObject#getUniqueId()
* @see world.bentobox.bbox.database.objects.DataObject#getUniqueId()
*/
@Override
public String getUniqueId() {
@ -44,7 +44,7 @@ public class LevelsData implements DataObject {
}
/* (non-Javadoc)
* @see us.tastybento.bskyblock.database.objects.DataObject#setUniqueId(java.lang.String)
* @see world.bentobox.bbox.database.objects.DataObject#setUniqueId(java.lang.String)
*/
@Override
public void setUniqueId(String uniqueId) {

View File

@ -8,7 +8,7 @@ import java.util.stream.Collectors;
import com.google.gson.annotations.Expose;
import us.tastybento.bskyblock.database.objects.DataObject;
import world.bentobox.bbox.database.objects.DataObject;
/**
* This class stores and sorts the top ten.

View File

@ -3,8 +3,8 @@ package bskyblock.addon.level.event;
import java.util.UUID;
import bskyblock.addon.level.calculators.CalcIslandLevel.Results;
import us.tastybento.bskyblock.api.events.IslandBaseEvent;
import us.tastybento.bskyblock.database.objects.Island;
import world.bentobox.bbox.api.events.IslandBaseEvent;
import world.bentobox.bbox.database.objects.Island;
/**
* This event is fired after the island level is calculated and before the results are saved.

View File

@ -2,8 +2,8 @@ package bskyblock.addon.level.event;
import java.util.UUID;
import us.tastybento.bskyblock.api.events.IslandBaseEvent;
import us.tastybento.bskyblock.database.objects.Island;
import world.bentobox.bbox.api.events.IslandBaseEvent;
import world.bentobox.bbox.database.objects.Island;
/**
* Called when an island level is going to be calculated

View File

@ -9,9 +9,9 @@ import org.bukkit.event.Listener;
import bskyblock.addon.level.Level;
import bskyblock.addon.level.calculators.CalcIslandLevel;
import us.tastybento.bskyblock.api.events.island.IslandEvent.IslandCreatedEvent;
import us.tastybento.bskyblock.api.events.island.IslandEvent.IslandResettedEvent;
import us.tastybento.bskyblock.database.objects.Island;
import world.bentobox.bbox.api.events.island.IslandEvent.IslandCreatedEvent;
import world.bentobox.bbox.api.events.island.IslandEvent.IslandResettedEvent;
import world.bentobox.bbox.database.objects.Island;
/**
* Listens for new islands and sets the level to zero automatically