memoryleak-fix
Dieser Commit ist enthalten in:
Ursprung
1b1b7b7648
Commit
dbaf226e2b
@ -40,14 +40,15 @@ public class Countingwand {
|
||||
ColorConfig.HIGHLIGHT + "Rechtsklick" + ColorConfig.OTHER + " - " + ColorConfig.BASE + "Setzt die 2. Position"),
|
||||
false, clickType -> {
|
||||
}).getItemStack();
|
||||
|
||||
private final Map<String, Pair<Point, Point>> selections = new HashMap<>();
|
||||
|
||||
public boolean isCountingwand(final ItemStack item) {
|
||||
return Countingwand.WAND_ITEM.isSimilar(item);
|
||||
return WAND_ITEM.isSimilar(item);
|
||||
}
|
||||
|
||||
public void checkSelection(final Point point, final boolean pos1, final Player p) {
|
||||
Pair<Point, Point> selection = Countingwand.selections.get(p.getUniqueId().toString());
|
||||
Pair<Point, Point> selection = selections.get(p.getUniqueId().toString());
|
||||
final boolean newPos;
|
||||
if (selection != null) {
|
||||
if (pos1) {
|
||||
@ -61,7 +62,7 @@ public class Countingwand {
|
||||
} else {
|
||||
selection = new Pair<>(null, point);
|
||||
}
|
||||
Countingwand.selections.put(p.getUniqueId().toString(), selection);
|
||||
selections.put(p.getUniqueId().toString(), selection);
|
||||
newPos = true;
|
||||
}
|
||||
|
||||
@ -89,6 +90,10 @@ public class Countingwand {
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayer(Player p) {
|
||||
selections.remove(p);
|
||||
}
|
||||
|
||||
public int getAmount(final Point point1, final Point point2) {
|
||||
if (point1 == null || point2 == null) {
|
||||
return 0;
|
||||
|
@ -28,6 +28,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
|
||||
@Linked(LinkageType.LISTENER)
|
||||
@ -56,4 +57,9 @@ public class CountingwandListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
Countingwand.checkSelection(Point.fromLocation(Objects.requireNonNull(event.getClickedBlock()).getLocation()), false, event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeave(PlayerQuitEvent event) {
|
||||
Countingwand.removePlayer(event.getPlayer());
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren