Possible fix to memory leak

This commit is contained in:
Unknown 2018-07-12 13:49:20 +01:00
parent 4f516a7eb2
commit e3b660dcae
5 changed files with 15 additions and 7 deletions

View File

@ -1,6 +1,6 @@
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.0.40
version: 0.0.41
author: sekwah41
description: An advanced portals plugin for bukkit.
commands:

View File

@ -16,7 +16,7 @@
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<version>0.0.40-snapshot</version>
<version>0.0.41-snapshot</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>

View File

@ -61,7 +61,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
for (AdvancedPortal portal: Portal.portals){
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);
plugin.getServer().getPluginManager().callEvent(warpEvent);

View File

@ -23,6 +23,8 @@ import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import java.util.UUID;
public class Listeners implements Listener {
// 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...
@ -95,6 +97,11 @@ public class Listeners implements Listener {
@EventHandler
public void onLeaveEvent(PlayerQuitEvent event) {
Portal.cooldown.remove(event.getPlayer().getName());
UUID uuid = event.getPlayer().getUniqueId();
for (AdvancedPortal portal : Portal.portals) {
portal.inPortal.remove(uuid);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -119,14 +126,14 @@ public class Listeners implements Listener {
player.setMetadata("lavaWarped", new FixedMetadataValue(plugin, true));
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);
plugin.getServer().getPluginManager().callEvent(warpEvent);
if (!warpEvent.isCancelled()) Portal.activate(player, portal);
portal.inPortal.add(player);
} else portal.inPortal.remove(player);
portal.inPortal.add(player.getUniqueId());
} else portal.inPortal.remove(player.getUniqueId());
}
}

View File

@ -6,6 +6,7 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.HashSet;
import java.util.UUID;
public class AdvancedPortal {
@ -28,7 +29,7 @@ public class AdvancedPortal {
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.
public AdvancedPortal(String portalName, Material trigger, String destination, Location pos1, Location pos2, PortalArg... portalArgs) {