Merge branch 'development'

This commit is contained in:
Brianna 2021-02-25 14:22:05 -06:00
commit a79d5f7abb
10 changed files with 101 additions and 86 deletions

View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId>
<artifactId>skyblock</artifactId>
<version>2.3.26</version>
<version>2.3.27</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -17,7 +17,7 @@ public class IslandLevel {
/**
* @return Points of the Island from gathered materials
*/
public long getPoints() {
public double getPoints() {
return this.handle.getIsland().getLevel().getPoints();
}
@ -31,7 +31,7 @@ public class IslandLevel {
/**
* @return Last calculated points of the Island
*/
public long getLastCalculatedPoints() {
public double getLastCalculatedPoints() {
return this.handle.getIsland().getLevel().getLastCalculatedPoints();
}

View File

@ -24,7 +24,7 @@ public class IslandLevel {
private UUID ownerUUID;
private long lastCalculatedLevel = 0;
private long lastCalculatedPoints = 0;
private double lastCalculatedPoints = 0;
private Map<String, Long> materials;
@ -64,21 +64,21 @@ public class IslandLevel {
this.ownerUUID = ownerUUID;
}
public long getPoints() {
public double getPoints() {
FileConfiguration configLoad = this.plugin.getLevelling();
ConfigurationSection materialSection = configLoad.getConfigurationSection("Materials");
if (materialSection == null) return 0;
long pointsEarned = 0;
double pointsEarned = 0;
for (Entry<String, Long> entry : this.materials.entrySet()) {
ConfigurationSection current = materialSection.getConfigurationSection(entry.getKey());
if (current == null) continue;
long pointsRequired = current.getLong("Points", 0);
double pointsRequired = current.getDouble("Points", 0);
long blockAmount = entry.getValue();
long materialLimit = current.getLong("Limit", -1);
@ -135,7 +135,7 @@ public class IslandLevel {
division = 1;
}
long points = getPoints();
double points = getPoints();
long subtract = this.plugin.getConfiguration().getLong("Island.Levelling.Subtract");
if(points >= subtract){
points -= subtract;
@ -143,7 +143,7 @@ public class IslandLevel {
points = 0;
}
return points / division;
return Math.round(points) / division;
}
public void checkLevelUp() {
@ -267,11 +267,11 @@ public class IslandLevel {
this.materials = materials;
}
public long getLastCalculatedPoints() {
public double getLastCalculatedPoints() {
return this.lastCalculatedPoints;
}
public void setLastCalculatedPoints(long lastCalculatedPoints) {
public void setLastCalculatedPoints(double lastCalculatedPoints) {
this.lastCalculatedPoints = lastCalculatedPoints;
}

View File

@ -595,19 +595,22 @@ public class IslandManager {
player.getEnderChest().clear();
}
if (cooldownCreationEnabled) {
if (!player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*") && !player.hasPermission("fabledskyblock.*")) {
plugin.getCooldownManager().createPlayer(CooldownType.Creation, player);
if (!playerData.isPreview()) {
if (cooldownCreationEnabled) {
if (!player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*") && !player.hasPermission("fabledskyblock.*")) {
plugin.getCooldownManager().createPlayer(CooldownType.Creation, player);
}
}
}
if (cooldownDeletionEnabled) {
if (!player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*") && !player.hasPermission("fabledskyblock.*")) {
plugin.getCooldownManager().createPlayer(CooldownType.Deletion, player);
if (cooldownDeletionEnabled) {
if (!player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*") && !player.hasPermission("fabledskyblock.*")) {
plugin.getCooldownManager().createPlayer(CooldownType.Deletion, player);
}
}
}
if (cooldownPreviewEnabled) {
if (!player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*") && !player.hasPermission("fabledskyblock.*")) {
plugin.getCooldownManager().createPlayer(CooldownType.Preview, player);
}else{
if (cooldownPreviewEnabled) {
if (!player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*") && !player.hasPermission("fabledskyblock.*")) {
plugin.getCooldownManager().createPlayer(CooldownType.Preview, player);
}
}
}
}

View File

@ -34,8 +34,6 @@ public final class IslandScan extends BukkitRunnable {
private final Island island;
private final IslandWorld world;
private final Map<CompatibleMaterial, BlockAmount> amounts;
private final Configuration language;
private final int runEveryX;
private final SkyBlock plugin;
private int totalScanned;
@ -48,31 +46,16 @@ public final class IslandScan extends BukkitRunnable {
this.island = island;
this.world = world;
this.amounts = new EnumMap<>(CompatibleMaterial.class);
this.language = this.plugin.getLanguage();
this.runEveryX = language.getInt("Command.Island.Level.Scanning.Progress.Display-Every-X-Scan");
this.doubleBlocks = new HashSet<>();
}
public IslandScan start() {
final SkyBlock plugin = SkyBlock.getInstance();
final FileConfiguration config = this.plugin.getConfiguration();
final FileConfiguration islandData = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), this.island.getOwnerUUID().toString() + ".yml")).getFileConfiguration();
final boolean hasNether = config.getBoolean("Island.World.Nether.Enable") && islandData.getBoolean("Unlocked.Nether", false);
final boolean hasEnd = config.getBoolean("Island.World.End.Enable") && islandData.getBoolean("Unlocked.End", false);
final Map<World, List<ChunkSnapshot>> snapshots = new HashMap<>(3);
if (plugin.isPaperAsync()) {
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
initScan(plugin);
});
} else {
if (plugin.isPaperAsync())
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> initScan(plugin));
else
initScan(plugin);
}
return this;
}

View File

@ -46,7 +46,14 @@ public class QueuedIslandScan {
this.executions += currentScan.getExecutions();
this.totalScanned += currentScan.getTotalScanned();
this.blocksSize += currentScan.getBlocksSize();
this.amounts.putAll(currentScan.getAmounts());
for (Map.Entry<CompatibleMaterial, BlockAmount> entry : currentScan.getAmounts().entrySet()) {
if (amounts.containsKey(entry.getKey())) {
amounts.get(entry.getKey()).increaseAmount(entry.getValue().getAmount());
} else {
amounts.put(entry.getKey(), entry.getValue());
}
}
}
public boolean scan() {

View File

@ -9,21 +9,11 @@ import java.util.Map;
public final class CalculatorRegistry {
private CalculatorRegistry() {
}
private static final Map<CompatibleMaterial, List<Calculator>> calculators = new HashMap<>();
public static void registerCalculator(Calculator calculator, CompatibleMaterial to) {
List<Calculator> list = calculators.get(to);
if (list == null) {
list = new ArrayList<>();
calculators.put(to, list);
}
List<Calculator> list = calculators.computeIfAbsent(to, k -> new ArrayList<>());
list.add(calculator);
}

View File

@ -157,46 +157,78 @@ public class Creator {
event.setWillClose(false);
event.setWillDestroy(false);
return;
} else if (plugin.getConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable")
&& cooldownManager.hasPlayer(CooldownType.Creation, player)) {
CooldownPlayer cooldownPlayer = cooldownManager
.getCooldownPlayer(CooldownType.Creation, player);
Cooldown cooldown = cooldownPlayer.getCooldown();
if (cooldown.getTime() < 60) {
messageManager.sendMessage(player, configLoad
.getString("Island.Creator.Selector.Cooldown.Message")
.replace("%time", cooldown.getTime() + " "
+ configLoad.getString(
"Island.Creator.Selector.Cooldown.Word.Second")));
} else {
long[] durationTime = NumberUtil.getDuration(cooldown.getTime());
messageManager.sendMessage(player, configLoad
.getString("Island.Creator.Selector.Cooldown.Message")
.replace("%time", durationTime[2] + " "
+ configLoad.getString(
"Island.Creator.Selector.Cooldown.Word.Minute")
+ " " + durationTime[3] + " "
+ configLoad.getString(
"Island.Creator.Selector.Cooldown.Word.Second")));
}
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
return;
}
if(event.getClick().isLeftClick()) {
if (plugin.getConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable")
&& cooldownManager.hasPlayer(CooldownType.Creation, player)) {
CooldownPlayer cooldownPlayer = cooldownManager
.getCooldownPlayer(CooldownType.Creation, player);
Cooldown cooldown = cooldownPlayer.getCooldown();
if (cooldown.getTime() < 60) {
messageManager.sendMessage(player, configLoad
.getString("Island.Creator.Selector.Cooldown.Message")
.replace("%time", cooldown.getTime() + " "
+ configLoad.getString(
"Island.Creator.Selector.Cooldown.Word.Second")));
} else {
long[] durationTime = NumberUtil.getDuration(cooldown.getTime());
messageManager.sendMessage(player, configLoad
.getString("Island.Creator.Selector.Cooldown.Message")
.replace("%time", durationTime[2] + " "
+ configLoad.getString(
"Island.Creator.Selector.Cooldown.Word.Minute")
+ " " + durationTime[3] + " "
+ configLoad.getString(
"Island.Creator.Selector.Cooldown.Word.Second")));
}
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
return;
}
if (islandManager.createIsland(player, structureList)) {
messageManager.sendMessage(player,
configLoad.getString("Island.Creator.Selector.Created.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
}
} else if(event.getClick().isRightClick()) {
if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
.getFileConfiguration().getBoolean("Island.Preview.Cooldown.Enable")
&& cooldownManager.hasPlayer(CooldownType.Preview, player)) {
CooldownPlayer cooldownPlayer = cooldownManager.getCooldownPlayer(CooldownType.Preview, player);
Cooldown cooldown = cooldownPlayer.getCooldown();
if (cooldown.getTime() < 60) {
messageManager.sendMessage(player, configLoad
.getString("Island.Preview.Cooldown.Message")
.replace("%time", cooldown.getTime() + " "
+ configLoad.getString(
"Island.Preview.Cooldown.Word.Second")));
} else {
long[] durationTime = NumberUtil.getDuration(cooldown.getTime());
messageManager.sendMessage(player, configLoad
.getString("Island.Preview.Cooldown.Message")
.replace("%time", durationTime[2] + " "
+ configLoad.getString(
"Island.Preview.Cooldown.Word.Minute")
+ " " + durationTime[3] + " "
+ configLoad.getString(
"Island.Preview.Cooldown.Word.Second")));
}
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
return;
}
if (islandManager.previewIsland(player, structureList)) {
messageManager.sendMessage(player,
configLoad.getString("Island.Creator.Selector.Preview.Message"));

View File

@ -127,7 +127,7 @@ public class PlaceholderProcessor {
}
break;
case "fabledskyblock_island_points":
returnValue = island == null ? "0" : Long.toString(island.getLevel().getPoints());
returnValue = island == null ? "0" : Double.toString(island.getLevel().getPoints());
break;
case "fabledskyblock_island_votes":
if (island == null) {

View File

@ -3326,7 +3326,7 @@ Menu:
- '%description'
- ''
- '&eClick to create Island!'
- '&eRight-Click to create Island!'
- '&eRight-Click to preview Island!'
Bank:
Title: 'Bank'
Item: