Dieser Commit ist enthalten in:
Ursprung
17c03f629a
Commit
19bb7cc733
@ -58,10 +58,7 @@ import org.bukkit.event.player.*;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -77,6 +74,7 @@ public class SimulatorCursor implements Listener {
|
|||||||
|
|
||||||
private Map<Player, CursorType> cursorType = Collections.synchronizedMap(new HashMap<>());
|
private Map<Player, CursorType> cursorType = Collections.synchronizedMap(new HashMap<>());
|
||||||
private Map<Player, REntityServer> cursors = Collections.synchronizedMap(new HashMap<>());
|
private Map<Player, REntityServer> cursors = Collections.synchronizedMap(new HashMap<>());
|
||||||
|
private final Set<Player> calculating = new HashSet<>();
|
||||||
|
|
||||||
public static boolean isSimulatorItem(ItemStack itemStack) {
|
public static boolean isSimulatorItem(ItemStack itemStack) {
|
||||||
return ItemUtils.isItem(itemStack, "simulator");
|
return ItemUtils.isItem(itemStack, "simulator");
|
||||||
@ -115,6 +113,9 @@ public class SimulatorCursor implements Listener {
|
|||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
cursorType.remove(event.getPlayer());
|
cursorType.remove(event.getPlayer());
|
||||||
cursors.remove(event.getPlayer());
|
cursors.remove(event.getPlayer());
|
||||||
|
synchronized (calculating) {
|
||||||
|
calculating.remove(event.getPlayer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<Player, Long> LAST_SNEAKS = new HashMap<>();
|
private static final Map<Player, Long> LAST_SNEAKS = new HashMap<>();
|
||||||
@ -141,11 +142,18 @@ public class SimulatorCursor implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void calcCursor(Player player) {
|
public void calcCursor(Player player) {
|
||||||
|
synchronized (calculating) {
|
||||||
|
if (calculating.contains(player)) return;
|
||||||
|
calculating.add(player);
|
||||||
|
}
|
||||||
if (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand())) {
|
if (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand())) {
|
||||||
if (removeCursor(player) || SimulatorWatcher.show(null, player)) {
|
if (removeCursor(player) || SimulatorWatcher.show(null, player)) {
|
||||||
SWUtils.sendToActionbar(player, "");
|
SWUtils.sendToActionbar(player, "");
|
||||||
}
|
}
|
||||||
|
synchronized (calculating) {
|
||||||
|
calculating.remove(player);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Simulator simulator = SimulatorStorage.getSimulator(player);
|
Simulator simulator = SimulatorStorage.getSimulator(player);
|
||||||
@ -160,10 +168,16 @@ public class SimulatorCursor implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
SWUtils.sendToActionbar(player, "§eOpen Simulator");
|
SWUtils.sendToActionbar(player, "§eOpen Simulator");
|
||||||
}
|
}
|
||||||
|
synchronized (calculating) {
|
||||||
|
calculating.remove(player);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
showCursor(player, rayTraceResult, simulator != null);
|
showCursor(player, rayTraceResult, simulator != null);
|
||||||
|
synchronized (calculating) {
|
||||||
|
calculating.remove(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized boolean removeCursor(Player player) {
|
private synchronized boolean removeCursor(Player player) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren