Cleaned up imports and unused code.
This commit is contained in:
parent
bd7f591f36
commit
93ea0d3153
@ -1,11 +1,9 @@
|
|||||||
package ca.recrown.islandsurvivalcraft.interaction.commands.runnables;
|
package ca.recrown.islandsurvivalcraft.interaction.commands.runnables;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
@ -17,7 +15,6 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import ca.recrown.islandsurvivalcraft.IslandSurvivalCraft;
|
import ca.recrown.islandsurvivalcraft.IslandSurvivalCraft;
|
||||||
import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2;
|
import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2;
|
||||||
import ca.recrown.islandsurvivalcraft.utilities.pathfinding.DepthFirstSearch;
|
|
||||||
import ca.recrown.islandsurvivalcraft.world.WorldInfo;
|
import ca.recrown.islandsurvivalcraft.world.WorldInfo;
|
||||||
import ca.recrown.islandsurvivalcraft.world.Information.IslandInformation;
|
import ca.recrown.islandsurvivalcraft.world.Information.IslandInformation;
|
||||||
|
|
||||||
@ -27,7 +24,7 @@ public class HighlightIslandCommand implements CommandRunnable {
|
|||||||
private final double OFFSET_X = 0.0d, OFFSET_Y = 6.0d, OFFSET_Z = 0.0d;
|
private final double OFFSET_X = 0.0d, OFFSET_Y = 6.0d, OFFSET_Z = 0.0d;
|
||||||
private final double EXTRA = 0d;
|
private final double EXTRA = 0d;
|
||||||
HashSet<Player> playersHighlighting = new HashSet<>();
|
HashSet<Player> playersHighlighting = new HashSet<>();
|
||||||
LinkedList<PlayerIslandHighlighter> waitingList = new LinkedList<>();
|
LinkedList<Player> waitingList = new LinkedList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
@ -46,7 +43,7 @@ public class HighlightIslandCommand implements CommandRunnable {
|
|||||||
}
|
}
|
||||||
if (args[0].toLowerCase().equals("start")) {
|
if (args[0].toLowerCase().equals("start")) {
|
||||||
if (playersHighlighting.add(player)) {
|
if (playersHighlighting.add(player)) {
|
||||||
waitingList.add(new PlayerIslandHighlighter(player));
|
waitingList.add(player);
|
||||||
sender.sendMessage("You are now highlighting islands.");
|
sender.sendMessage("You are now highlighting islands.");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("You are already highlighting islands.");
|
sender.sendMessage("You are already highlighting islands.");
|
||||||
@ -68,9 +65,7 @@ public class HighlightIslandCommand implements CommandRunnable {
|
|||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(islandsurvivalcraft, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(islandsurvivalcraft, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PlayerIslandHighlighter highlighter = waitingList.poll();
|
Player player = waitingList.poll();
|
||||||
if (highlighter == null) return;
|
|
||||||
Player player = highlighter.player;
|
|
||||||
if (player == null || !player.isOnline() || !playersHighlighting.contains(player)) {
|
if (player == null || !player.isOnline() || !playersHighlighting.contains(player)) {
|
||||||
playersHighlighting.remove(player);
|
playersHighlighting.remove(player);
|
||||||
return;
|
return;
|
||||||
@ -90,7 +85,7 @@ public class HighlightIslandCommand implements CommandRunnable {
|
|||||||
islandborderIterable.next();
|
islandborderIterable.next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
waitingList.add(highlighter);
|
waitingList.add(player);
|
||||||
}
|
}
|
||||||
}, 0, 10);
|
}, 0, 10);
|
||||||
|
|
||||||
@ -104,23 +99,4 @@ public class HighlightIslandCommand implements CommandRunnable {
|
|||||||
public String getDetailedDescription() {
|
public String getDetailedDescription() {
|
||||||
return "A helpful debugging command to analyze what the plugin considers an island by displaying particle effects around the player that is a part of the island. The <start | stop> argument is required to dicate whether or not to start the highlighting or stop it.";
|
return "A helpful debugging command to analyze what the plugin considers an island by displaying particle effects around the player that is a part of the island. The <start | stop> argument is required to dicate whether or not to start the highlighting or stop it.";
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PlayerIslandHighlighter {
|
|
||||||
private final int MAX_SEARCH = 0;
|
|
||||||
private IslandInformation lastIsland;
|
|
||||||
private final Player player;
|
|
||||||
private DepthFirstSearch dfs;
|
|
||||||
|
|
||||||
public PlayerIslandHighlighter(Player player) {
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasUpdated(IslandInformation islandInformation) {
|
|
||||||
if (lastIsland == null || !(lastIsland.hashCode() == islandInformation.hashCode() && lastIsland.equals(islandInformation))) {
|
|
||||||
lastIsland = islandInformation;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -36,6 +36,7 @@ public class WorldInfo {
|
|||||||
public void initialize(World world) {
|
public void initialize(World world) {
|
||||||
if (initialized)
|
if (initialized)
|
||||||
throw new IllegalStateException("This world information object has already been initialized.");
|
throw new IllegalStateException("This world information object has already been initialized.");
|
||||||
|
if (world == null) throw new NullPointerException("The world argument cannot be null.");
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
this.seed = world.getSeed();
|
this.seed = world.getSeed();
|
||||||
this.random = new Random(seed);
|
this.random = new Random(seed);
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package ca.recrown.islandsurvivalcraft.world;
|
package ca.recrown.islandsurvivalcraft.world;
|
||||||
|
|
||||||
import java.security.InvalidParameterException;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.apache.commons.lang.NullArgumentException;
|
import org.apache.commons.lang.NullArgumentException;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
Loading…
Reference in New Issue
Block a user