-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use UUID based map adapter and tweak logic (#6)
- Loading branch information
Showing
7 changed files
with
67 additions
and
37 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,5 @@ | |
|
||
public interface IdlyAPI { | ||
|
||
boolean isMatchRunning(Player player); | ||
|
||
boolean isPlaying(Player player); | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/tc/oc/occ/idly/utils/OnlinePlayerUUIDMapAdapter.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,33 @@ | ||
package tc.oc.occ.idly.utils; | ||
|
||
import java.util.Map; | ||
import java.util.UUID; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerQuitEvent; | ||
import org.bukkit.plugin.Plugin; | ||
import tc.oc.pgm.util.bukkit.ListeningMapAdapter; | ||
|
||
public class OnlinePlayerUUIDMapAdapter<V> extends ListeningMapAdapter<UUID, V> | ||
implements Listener { | ||
public OnlinePlayerUUIDMapAdapter(Plugin plugin) { | ||
super(plugin); | ||
} | ||
|
||
public OnlinePlayerUUIDMapAdapter(Map<UUID, V> map, Plugin plugin) { | ||
super(map, plugin); | ||
} | ||
|
||
public boolean isValid(UUID key) { | ||
Player player = Bukkit.getPlayer(key); | ||
return player != null && player.isOnline(); | ||
} | ||
|
||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) | ||
public void onPlayerQuit(PlayerQuitEvent event) { | ||
this.remove(event.getPlayer().getUniqueId()); | ||
} | ||
} |
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