-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc909f0
commit 071e91c
Showing
5 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/com/owen1212055/customname/listener/PlayerQuitListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.owen1212055.customname.listener; | ||
|
||
import com.owen1212055.customname.CustomNameStorage; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerQuitEvent; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
|
||
public class PlayerQuitListener implements Listener { | ||
|
||
private final JavaPlugin plugin; | ||
private final CustomNameStorage nameStorage; | ||
|
||
public PlayerQuitListener(JavaPlugin plugin, CustomNameStorage nameStorage) { | ||
this.plugin = plugin; | ||
this.nameStorage = nameStorage; | ||
} | ||
|
||
@EventHandler | ||
public void playerQuit(PlayerQuitEvent event) { | ||
new BukkitRunnable() { | ||
|
||
@Override | ||
public void run() { | ||
nameStorage.remove(event.getPlayer().getUniqueId()); // Be safe, remove long enough so the entity is removed | ||
} | ||
}.runTaskLater(this.plugin, 5); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters