This commit is contained in:
Indyuce 2021-08-25 13:34:04 +02:00
parent a574a67a3b
commit 408703b4f4
2 changed files with 41 additions and 42 deletions

View File

@ -5,24 +5,24 @@ import org.bukkit.configuration.ConfigurationSection;
public class ChestAlgorithmOptions { public class ChestAlgorithmOptions {
/* /**
* min and max range represents the range at which the chest can spawn * Min and max range represents the range at which the chest can spawn
* around the player. height is the Z delta in which the chest can spawn, * around the player. Height is the Z delta in which the chest can spawn,
* relative to the player's altitude * relative to the player's altitude
*/ */
public final double minRange, maxRange, height; public final double minRange, maxRange, height;
/* /**
* maximum amount of trials the algorithm will run in order to find a * Maximum amount of trials the algorithm will run in order to find a
* suitable location for a chest around the player. * suitable location for a chest around the player.
*/ */
public final int iterations; public final int iterations;
public static final ChestAlgorithmOptions DEFAULT = new ChestAlgorithmOptions(10, 30, 8, 15); public static final ChestAlgorithmOptions DEFAULT = new ChestAlgorithmOptions(10, 30, 8, 15);
/* /**
* this is purely to let server owners tweak the chest random location * This is purely to let server owners tweak the
* finder algorithm. * chest random location finder algorithm.
*/ */
public ChestAlgorithmOptions(ConfigurationSection config) { public ChestAlgorithmOptions(ConfigurationSection config) {
Validate.notNull(config, "Config cannot be null"); Validate.notNull(config, "Config cannot be null");
@ -37,9 +37,9 @@ public class ChestAlgorithmOptions {
Validate.isTrue(iterations > 0, "Iterations must be strictly positive"); Validate.isTrue(iterations > 0, "Iterations must be strictly positive");
} }
/* /**
* can be used to register loot chest regions with external plugins, and * Can be used to register loot chest regions with external
* used by the default alg options instance * plugins, and used by the default alg options instance
*/ */
public ChestAlgorithmOptions(double minRange, double maxRange, double height, int iterations) { public ChestAlgorithmOptions(double minRange, double maxRange, double height, int iterations) {
this.minRange = minRange; this.minRange = minRange;

View File

@ -56,8 +56,11 @@ public class LootChest {
} }
/** /**
* @param player If a player just the chest. It's set to false * @param player If a player triggered the unregistration of that chest by
* when a loot chest expires or when MMOCore disables. * opening and then closing it for the first time. It's set
* to false when a loot chest expires or when MMOCore disables.
* <p>
* When no player is closing the chest, its content should be lost
*/ */
public void unregister(boolean player) { public void unregister(boolean player) {
@ -91,10 +94,6 @@ public class LootChest {
this.loc = block.getLocation(); this.loc = block.getLocation();
} }
public Location getLocoation() {
return loc;
}
public boolean matches(Location loc) { public boolean matches(Location loc) {
return this.loc.getWorld().equals(loc.getWorld()) && this.loc.getBlockX() == loc.getBlockX() && this.loc.getBlockY() == loc.getBlockY() return this.loc.getWorld().equals(loc.getWorld()) && this.loc.getBlockX() == loc.getBlockX() && this.loc.getBlockY() == loc.getBlockY()
&& this.loc.getBlockZ() == loc.getBlockZ(); && this.loc.getBlockZ() == loc.getBlockZ();