forked from Upstream/mmocore
Improved comments
This commit is contained in:
parent
92e6c17c8d
commit
72d2bef1a6
src/main/java/net/Indyuce/mmocore
@ -138,7 +138,7 @@ public class LootChestRegion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* no location has been found after the X iterations, return null and
|
* No location has been found after the X iterations, return null and
|
||||||
* cancel chest spawning. worst case scenario, should not happen too
|
* cancel chest spawning. worst case scenario, should not happen too
|
||||||
* often except if the player is in a really NARROW zone
|
* often except if the player is in a really NARROW zone
|
||||||
*/
|
*/
|
||||||
@ -148,8 +148,8 @@ public class LootChestRegion {
|
|||||||
public Location tryRandomDirection(Location center) {
|
public Location tryRandomDirection(Location center) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* chooses a random direction and get the block in that direction which
|
* Chooses a random direction and get the block in
|
||||||
* has the same height as the player
|
* that direction which has the same height as the player
|
||||||
*/
|
*/
|
||||||
double a = random.nextDouble() * 2 * Math.PI;
|
double a = random.nextDouble() * 2 * Math.PI;
|
||||||
Vector dir = new Vector(Math.cos(a), 0, Math.sin(a))
|
Vector dir = new Vector(Math.cos(a), 0, Math.sin(a))
|
||||||
@ -157,8 +157,8 @@ public class LootChestRegion {
|
|||||||
Location random = center.add(dir);
|
Location random = center.add(dir);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* go up and down at the same time till it finds a non-solid block with
|
* Go up and down at the same time till it finds
|
||||||
* a solid block underneath
|
* a non-solid block with a solid block underneath
|
||||||
*/
|
*/
|
||||||
for (int h = 0; h <= algOptions.height * 2; h++) {
|
for (int h = 0; h <= algOptions.height * 2; h++) {
|
||||||
int z = h % 2 == 0 ? h / 2 : -(h + 1) / 2; // bijective from N to Z
|
int z = h % 2 == 0 ? h / 2 : -(h + 1) / 2; // bijective from N to Z
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package net.Indyuce.mmocore.manager;
|
package net.Indyuce.mmocore.manager;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -14,23 +10,33 @@ import net.Indyuce.mmocore.MMOCore;
|
|||||||
import net.Indyuce.mmocore.api.ConfigFile;
|
import net.Indyuce.mmocore.api.ConfigFile;
|
||||||
import net.Indyuce.mmocore.loot.chest.LootChest;
|
import net.Indyuce.mmocore.loot.chest.LootChest;
|
||||||
import net.Indyuce.mmocore.loot.chest.LootChestRegion;
|
import net.Indyuce.mmocore.loot.chest.LootChestRegion;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class LootChestManager implements MMOCoreManager {
|
public class LootChestManager implements MMOCoreManager {
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* all active loot chests in the server
|
* Active loot chests in the server
|
||||||
*/
|
*/
|
||||||
private final Set<LootChest> active = new HashSet<>();
|
private final Set<LootChest> active = new HashSet<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registered loot chest regions
|
||||||
|
*/
|
||||||
private final Map<String, LootChestRegion> regions = new HashMap<>();
|
private final Map<String, LootChestRegion> regions = new HashMap<>();
|
||||||
|
|
||||||
public boolean hasRegion(String id) {
|
public boolean hasRegion(String id) {
|
||||||
return regions.containsKey(id);
|
return regions.containsKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LootChestRegion getRegion(String id) {
|
/**
|
||||||
return regions.get(id);
|
* @return Region with specific identifier
|
||||||
}
|
* @throws NullPointerException if not found
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public LootChestRegion getRegion(String id) {
|
||||||
|
return Objects.requireNonNull(regions.get(id), "Could not find region with ID '" + id + "'");
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<LootChestRegion> getRegions() {
|
public Collection<LootChestRegion> getRegions() {
|
||||||
return regions.values();
|
return regions.values();
|
||||||
@ -48,6 +54,7 @@ public class LootChestManager implements MMOCoreManager {
|
|||||||
active.remove(chest);
|
active.remove(chest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public LootChest getChest(Location loc) {
|
public LootChest getChest(Location loc) {
|
||||||
|
|
||||||
for (LootChest chest : active)
|
for (LootChest chest : active)
|
||||||
|
Loading…
Reference in New Issue
Block a user