mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-11-23 18:45:17 +01:00
feat: add island total points + placeholder (#264)
* feat: add island total points + placeholder * Update IslandLevels.java
This commit is contained in:
parent
ac6bead52e
commit
fba73948c6
@ -36,6 +36,7 @@ import world.bentobox.level.config.BlockConfig;
|
|||||||
import world.bentobox.level.config.ConfigSettings;
|
import world.bentobox.level.config.ConfigSettings;
|
||||||
import world.bentobox.level.listeners.IslandActivitiesListeners;
|
import world.bentobox.level.listeners.IslandActivitiesListeners;
|
||||||
import world.bentobox.level.listeners.JoinLeaveListener;
|
import world.bentobox.level.listeners.JoinLeaveListener;
|
||||||
|
import world.bentobox.level.objects.IslandLevels;
|
||||||
import world.bentobox.level.listeners.MigrationListener;
|
import world.bentobox.level.listeners.MigrationListener;
|
||||||
import world.bentobox.level.objects.LevelsData;
|
import world.bentobox.level.objects.LevelsData;
|
||||||
import world.bentobox.level.objects.TopTenData;
|
import world.bentobox.level.objects.TopTenData;
|
||||||
@ -226,6 +227,13 @@ public class Level extends Addon {
|
|||||||
getPlugin().getPlaceholdersManager().registerPlaceholder(this,
|
getPlugin().getPlaceholdersManager().registerPlaceholder(this,
|
||||||
gm.getDescription().getName().toLowerCase() + "_island_level_raw",
|
gm.getDescription().getName().toLowerCase() + "_island_level_raw",
|
||||||
user -> String.valueOf(getManager().getIslandLevel(gm.getOverWorld(), user.getUniqueId())));
|
user -> String.valueOf(getManager().getIslandLevel(gm.getOverWorld(), user.getUniqueId())));
|
||||||
|
getPlugin().getPlaceholdersManager().registerPlaceholder(this,
|
||||||
|
gm.getDescription().getName().toLowerCase() + "_island_total_points",
|
||||||
|
user -> {
|
||||||
|
IslandLevels data = getManager().getLevelsData(this.getIslands().getIsland(gm.getOverWorld(), user));
|
||||||
|
return data.getTotalPoints()+"";
|
||||||
|
});
|
||||||
|
|
||||||
getPlugin().getPlaceholdersManager().registerPlaceholder(this,
|
getPlugin().getPlaceholdersManager().registerPlaceholder(this,
|
||||||
gm.getDescription().getName().toLowerCase() + "_points_to_next_level",
|
gm.getDescription().getName().toLowerCase() + "_points_to_next_level",
|
||||||
user -> getManager().getPointsToNextString(gm.getOverWorld(), user.getUniqueId()));
|
user -> getManager().getPointsToNextString(gm.getOverWorld(), user.getUniqueId()));
|
||||||
|
@ -181,6 +181,7 @@ public class LevelsManager {
|
|||||||
results.setInitialLevel((Long)ilce.getKeyValues().getOrDefault("initialLevel", results.getInitialLevel()));
|
results.setInitialLevel((Long)ilce.getKeyValues().getOrDefault("initialLevel", results.getInitialLevel()));
|
||||||
results.setDeathHandicap((int)ilce.getKeyValues().getOrDefault("deathHandicap", results.getDeathHandicap()));
|
results.setDeathHandicap((int)ilce.getKeyValues().getOrDefault("deathHandicap", results.getDeathHandicap()));
|
||||||
results.setPointsToNextLevel((Long)ilce.getKeyValues().getOrDefault("pointsToNextLevel", results.getPointsToNextLevel()));
|
results.setPointsToNextLevel((Long)ilce.getKeyValues().getOrDefault("pointsToNextLevel", results.getPointsToNextLevel()));
|
||||||
|
results.setTotalPoints((Long)ilce.getKeyValues().getOrDefault("totalPoints", results.getTotalPoints()));
|
||||||
return ((Boolean)ilce.getKeyValues().getOrDefault("isCancelled", false));
|
return ((Boolean)ilce.getKeyValues().getOrDefault("isCancelled", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,6 +433,7 @@ public class LevelsManager {
|
|||||||
ld.setUwCount(Maps.asMap(r.getUwCount().elementSet(), elem -> r.getUwCount().count(elem)));
|
ld.setUwCount(Maps.asMap(r.getUwCount().elementSet(), elem -> r.getUwCount().count(elem)));
|
||||||
ld.setMdCount(Maps.asMap(r.getMdCount().elementSet(), elem -> r.getMdCount().count(elem)));
|
ld.setMdCount(Maps.asMap(r.getMdCount().elementSet(), elem -> r.getMdCount().count(elem)));
|
||||||
ld.setPointsToNextLevel(r.getPointsToNextLevel());
|
ld.setPointsToNextLevel(r.getPointsToNextLevel());
|
||||||
|
ld.setTotalPoints(r.getTotalPoints());
|
||||||
levelsCache.put(island.getUniqueId(), ld);
|
levelsCache.put(island.getUniqueId(), ld);
|
||||||
handler.saveObjectAsync(ld);
|
handler.saveObjectAsync(ld);
|
||||||
// Update TopTen
|
// Update TopTen
|
||||||
|
@ -52,7 +52,7 @@ import world.bentobox.level.calculators.Results.Result;
|
|||||||
|
|
||||||
public class IslandLevelCalculator {
|
public class IslandLevelCalculator {
|
||||||
private static final String LINE_BREAK = "==================================";
|
private static final String LINE_BREAK = "==================================";
|
||||||
public static final long MAX_AMOUNT = 10000;
|
public static final long MAX_AMOUNT = 10000000;
|
||||||
private static final List<Material> CHESTS = Arrays.asList(Material.CHEST, Material.CHEST_MINECART, Material.TRAPPED_CHEST,
|
private static final List<Material> CHESTS = Arrays.asList(Material.CHEST, Material.CHEST_MINECART, Material.TRAPPED_CHEST,
|
||||||
Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX,
|
Material.SHULKER_BOX, Material.BLACK_SHULKER_BOX, Material.BLUE_SHULKER_BOX, Material.BROWN_SHULKER_BOX,
|
||||||
Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX,
|
Material.CYAN_SHULKER_BOX, Material.GRAY_SHULKER_BOX, Material.GREEN_SHULKER_BOX, Material.LIGHT_BLUE_SHULKER_BOX,
|
||||||
@ -601,6 +601,7 @@ public class IslandLevelCalculator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long blockAndDeathPoints = this.results.rawBlockCount.get();
|
long blockAndDeathPoints = this.results.rawBlockCount.get();
|
||||||
|
this.results.totalPoints.set(blockAndDeathPoints);
|
||||||
|
|
||||||
if (this.addon.getSettings().getDeathPenalty() > 0)
|
if (this.addon.getSettings().getDeathPenalty() > 0)
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,7 @@ public class Results {
|
|||||||
AtomicInteger deathHandicap = new AtomicInteger(0);
|
AtomicInteger deathHandicap = new AtomicInteger(0);
|
||||||
AtomicLong pointsToNextLevel = new AtomicLong(0);
|
AtomicLong pointsToNextLevel = new AtomicLong(0);
|
||||||
AtomicLong initialLevel = new AtomicLong(0);
|
AtomicLong initialLevel = new AtomicLong(0);
|
||||||
|
AtomicLong totalPoints = new AtomicLong(0);
|
||||||
final Result state;
|
final Result state;
|
||||||
|
|
||||||
public Results(Result state) {
|
public Results(Result state) {
|
||||||
@ -93,6 +94,21 @@ public class Results {
|
|||||||
pointsToNextLevel.set(points);
|
pointsToNextLevel.set(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the totalPoints
|
||||||
|
*/
|
||||||
|
public long getTotalPoints() {
|
||||||
|
return totalPoints.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the total points
|
||||||
|
* @param points
|
||||||
|
*/
|
||||||
|
public void setTotalPoints(long points) {
|
||||||
|
totalPoints.set(points);
|
||||||
|
}
|
||||||
|
|
||||||
public long getInitialLevel() {
|
public long getInitialLevel() {
|
||||||
return initialLevel.get();
|
return initialLevel.get();
|
||||||
}
|
}
|
||||||
@ -109,7 +125,7 @@ public class Results {
|
|||||||
return "Results [report=" + report + ", mdCount=" + mdCount + ", uwCount=" + uwCount + ", ncCount="
|
return "Results [report=" + report + ", mdCount=" + mdCount + ", uwCount=" + uwCount + ", ncCount="
|
||||||
+ ncCount + ", ofCount=" + ofCount + ", rawBlockCount=" + rawBlockCount + ", underWaterBlockCount="
|
+ ncCount + ", ofCount=" + ofCount + ", rawBlockCount=" + rawBlockCount + ", underWaterBlockCount="
|
||||||
+ underWaterBlockCount + ", level=" + level + ", deathHandicap=" + deathHandicap
|
+ underWaterBlockCount + ", level=" + level + ", deathHandicap=" + deathHandicap
|
||||||
+ ", pointsToNextLevel=" + pointsToNextLevel + ", initialLevel=" + initialLevel + "]";
|
+ ", pointsToNextLevel=" + pointsToNextLevel + ", totalPoints=" + totalPoints + ", initialLevel=" + initialLevel + "]";
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return the mdCount
|
* @return the mdCount
|
||||||
|
@ -110,7 +110,7 @@ public class IslandLevelCommand extends CompositeCommand {
|
|||||||
user.sendMessage("island.level.deaths", "[number]", String.valueOf(results.getDeathHandicap()));
|
user.sendMessage("island.level.deaths", "[number]", String.valueOf(results.getDeathHandicap()));
|
||||||
}
|
}
|
||||||
// Send player how many points are required to reach next island level
|
// Send player how many points are required to reach next island level
|
||||||
if (results.getPointsToNextLevel() >= 0 && results.getPointsToNextLevel() < 10000) {
|
if (results.getPointsToNextLevel() >= 0) {
|
||||||
user.sendMessage("island.level.required-points-to-next-level", "[points]", String.valueOf(results.getPointsToNextLevel()));
|
user.sendMessage("island.level.required-points-to-next-level", "[points]", String.valueOf(results.getPointsToNextLevel()));
|
||||||
}
|
}
|
||||||
// Tell other team members
|
// Tell other team members
|
||||||
|
@ -49,6 +49,12 @@ public class IslandLevels implements DataObject {
|
|||||||
@Expose
|
@Expose
|
||||||
private long maxLevel;
|
private long maxLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total points
|
||||||
|
*/
|
||||||
|
@Expose
|
||||||
|
private long totalPoints;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Underwater count
|
* Underwater count
|
||||||
*/
|
*/
|
||||||
@ -133,6 +139,20 @@ public class IslandLevels implements DataObject {
|
|||||||
this.pointsToNextLevel = pointsToNextLevel;
|
this.pointsToNextLevel = pointsToNextLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the pointsToNextLevel
|
||||||
|
*/
|
||||||
|
public long getTotalPoints() {
|
||||||
|
return totalPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param totalPoints the totalPoints to set
|
||||||
|
*/
|
||||||
|
public void setTotalPoints(long totalPoints) {
|
||||||
|
this.totalPoints = totalPoints;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the maximum level ever set using {@link #setLevel(long)}
|
* Get the maximum level ever set using {@link #setLevel(long)}
|
||||||
* @return the maxLevel
|
* @return the maxLevel
|
||||||
|
Loading…
Reference in New Issue
Block a user