mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-12-05 11:44:15 +01:00
Possible fix to memory leak
This commit is contained in:
parent
4f516a7eb2
commit
e3b660dcae
@ -1,6 +1,6 @@
|
|||||||
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
|
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
|
||||||
name: AdvancedPortals
|
name: AdvancedPortals
|
||||||
version: 0.0.40
|
version: 0.0.41
|
||||||
author: sekwah41
|
author: sekwah41
|
||||||
description: An advanced portals plugin for bukkit.
|
description: An advanced portals plugin for bukkit.
|
||||||
commands:
|
commands:
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@ -16,7 +16,7 @@
|
|||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<version>0.0.40-snapshot</version>
|
<version>0.0.41-snapshot</version>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>1.7</maven.compiler.source>
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
|
|||||||
@ -61,7 +61,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
for (AdvancedPortal portal: Portal.portals){
|
for (AdvancedPortal portal: Portal.portals){
|
||||||
if (args[1].equalsIgnoreCase(portal.getName())){
|
if (args[1].equalsIgnoreCase(portal.getName())){
|
||||||
|
|
||||||
if (portal.inPortal.contains(player)) return true;
|
if (portal.inPortal.contains(player.getUniqueId())) return true;
|
||||||
WarpEvent warpEvent = new WarpEvent(player, portal);
|
WarpEvent warpEvent = new WarpEvent(player, portal);
|
||||||
plugin.getServer().getPluginManager().callEvent(warpEvent);
|
plugin.getServer().getPluginManager().callEvent(warpEvent);
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,8 @@ import org.bukkit.event.player.*;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Listeners implements Listener {
|
public class Listeners implements Listener {
|
||||||
// The needed config values will be stored so they are easier to access later
|
// The needed config values will be stored so they are easier to access later
|
||||||
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("\u00A7eP...
|
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("\u00A7eP...
|
||||||
@ -95,6 +97,11 @@ public class Listeners implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLeaveEvent(PlayerQuitEvent event) {
|
public void onLeaveEvent(PlayerQuitEvent event) {
|
||||||
Portal.cooldown.remove(event.getPlayer().getName());
|
Portal.cooldown.remove(event.getPlayer().getName());
|
||||||
|
|
||||||
|
UUID uuid = event.getPlayer().getUniqueId();
|
||||||
|
for (AdvancedPortal portal : Portal.portals) {
|
||||||
|
portal.inPortal.remove(uuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
@ -119,14 +126,14 @@ public class Listeners implements Listener {
|
|||||||
player.setMetadata("lavaWarped", new FixedMetadataValue(plugin, true));
|
player.setMetadata("lavaWarped", new FixedMetadataValue(plugin, true));
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new RemoveLavaData(player), 10);
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new RemoveLavaData(player), 10);
|
||||||
}
|
}
|
||||||
if (portal.inPortal.contains(player)) return;
|
if (portal.inPortal.contains(player.getUniqueId())) return;
|
||||||
WarpEvent warpEvent = new WarpEvent(player, portal);
|
WarpEvent warpEvent = new WarpEvent(player, portal);
|
||||||
plugin.getServer().getPluginManager().callEvent(warpEvent);
|
plugin.getServer().getPluginManager().callEvent(warpEvent);
|
||||||
|
|
||||||
if (!warpEvent.isCancelled()) Portal.activate(player, portal);
|
if (!warpEvent.isCancelled()) Portal.activate(player, portal);
|
||||||
|
|
||||||
portal.inPortal.add(player);
|
portal.inPortal.add(player.getUniqueId());
|
||||||
} else portal.inPortal.remove(player);
|
} else portal.inPortal.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class AdvancedPortal {
|
public class AdvancedPortal {
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ public class AdvancedPortal {
|
|||||||
|
|
||||||
private PortalArg[] portalArgs = null;
|
private PortalArg[] portalArgs = null;
|
||||||
|
|
||||||
public HashSet<Player> inPortal = new HashSet<Player>();
|
public HashSet<UUID> inPortal = new HashSet<UUID>();
|
||||||
|
|
||||||
// TODO think of relaying out the data input to a more logical format.
|
// TODO think of relaying out the data input to a more logical format.
|
||||||
public AdvancedPortal(String portalName, Material trigger, String destination, Location pos1, Location pos2, PortalArg... portalArgs) {
|
public AdvancedPortal(String portalName, Material trigger, String destination, Location pos1, Location pos2, PortalArg... portalArgs) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user