mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-28 00:55:29 +01:00
Improved comments
This commit is contained in:
parent
92e6c17c8d
commit
72d2bef1a6
@ -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
|
||||
* often except if the player is in a really NARROW zone
|
||||
*/
|
||||
@ -148,8 +148,8 @@ public class LootChestRegion {
|
||||
public Location tryRandomDirection(Location center) {
|
||||
|
||||
/*
|
||||
* chooses a random direction and get the block in that direction which
|
||||
* has the same height as the player
|
||||
* Chooses a random direction and get the block in
|
||||
* that direction which has the same height as the player
|
||||
*/
|
||||
double a = random.nextDouble() * 2 * Math.PI;
|
||||
Vector dir = new Vector(Math.cos(a), 0, Math.sin(a))
|
||||
@ -157,8 +157,8 @@ public class LootChestRegion {
|
||||
Location random = center.add(dir);
|
||||
|
||||
/*
|
||||
* go up and down at the same time till it finds a non-solid block with
|
||||
* a solid block underneath
|
||||
* Go up and down at the same time till it finds
|
||||
* a non-solid block with a solid block underneath
|
||||
*/
|
||||
for (int h = 0; h <= algOptions.height * 2; h++) {
|
||||
int z = h % 2 == 0 ? h / 2 : -(h + 1) / 2; // bijective from N to Z
|
||||
|
@ -1,10 +1,6 @@
|
||||
package net.Indyuce.mmocore.manager;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@ -14,22 +10,32 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigFile;
|
||||
import net.Indyuce.mmocore.loot.chest.LootChest;
|
||||
import net.Indyuce.mmocore.loot.chest.LootChestRegion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
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<>();
|
||||
|
||||
/**
|
||||
* Registered loot chest regions
|
||||
*/
|
||||
private final Map<String, LootChestRegion> regions = new HashMap<>();
|
||||
|
||||
public boolean hasRegion(String id) {
|
||||
return regions.containsKey(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Region with specific identifier
|
||||
* @throws NullPointerException if not found
|
||||
*/
|
||||
@NotNull
|
||||
public LootChestRegion getRegion(String id) {
|
||||
return regions.get(id);
|
||||
return Objects.requireNonNull(regions.get(id), "Could not find region with ID '" + id + "'");
|
||||
}
|
||||
|
||||
public Collection<LootChestRegion> getRegions() {
|
||||
@ -48,6 +54,7 @@ public class LootChestManager implements MMOCoreManager {
|
||||
active.remove(chest);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public LootChest getChest(Location loc) {
|
||||
|
||||
for (LootChest chest : active)
|
||||
|
Loading…
Reference in New Issue
Block a user