Added more APIs for levels

This commit is contained in:
Fabrizio La Rosa 2020-07-03 14:47:03 +02:00
parent 1f508a7225
commit 9a3b800f5f
2 changed files with 26 additions and 1 deletions

View File

@ -1,8 +1,9 @@
package com.songoda.skyblock.api.island;
import com.google.common.base.Preconditions;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.skyblock.SkyBlock;
import org.bukkit.Location;
import org.bukkit.Material;
public class IslandLevel {
@ -116,4 +117,13 @@ public class IslandLevel {
public Island getIsland() {
return handle;
}
/**
* Update the island level for a determined location
* @param location
*/
public void updateLevel(Location location){
Preconditions.checkArgument(location != null, "Cannot update level of a null island");
SkyBlock.getInstance().getLevellingManager().updateLevel(this.handle.getIsland(), location);
}
}

View File

@ -1,8 +1,12 @@
package com.songoda.skyblock.api.levelling;
import com.google.common.base.Preconditions;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.skyblock.api.island.Island;
import com.songoda.skyblock.levelling.IslandLevelManager;
import com.songoda.skyblock.levelling.calculator.Calculator;
import com.songoda.skyblock.levelling.calculator.CalculatorRegistry;
import org.bukkit.Material;
public class LevellingManager {
@ -19,4 +23,15 @@ public class LevellingManager {
Preconditions.checkArgument(island != null, "Cannot calculate points to null island");
this.levellingManager.startScan(null, island.getIsland());
}
/**
* Register a new material calculator for a determined material
* @param calculator
* @param material
*/
public void registerCalculator(Calculator calculator, Material material){
Preconditions.checkArgument(calculator != null, "Cannot use a null calculator");
Preconditions.checkArgument(material != null, "Cannot use a null material");
CalculatorRegistry.registerCalculator(calculator, CompatibleMaterial.getMaterial(material));
}
}