mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Add APF Notification prompt to Join Event Listener.
This commit is contained in:
parent
75d3e5fa20
commit
230eb7fc82
@ -1,14 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: com.destroystokyo.paper:paper-spigot:1.12">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/destroystokyo/paper/paper-spigot/1.12/paper-spigot-1.12.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/destroystokyo/paper/paper-spigot/1.12/paper-spigot-1.12-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://D:/Downloads/PaperSpigot-latest.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/destroystokyo/paper/paper-spigot/1.12/paper-spigot-1.12-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -1,13 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: com.djrapitops:abstract-plugin-framework:2.0.0">
|
||||
<library name="Maven: com.djrapitops:abstract-plugin-framework:2.0.1">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/abstract-plugin-framework/2.0.0/abstract-plugin-framework-2.0.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/abstract-plugin-framework/2.0.1/abstract-plugin-framework-2.0.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/abstract-plugin-framework/2.0.0/abstract-plugin-framework-2.0.0-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/abstract-plugin-framework/2.0.1/abstract-plugin-framework-2.0.1-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/abstract-plugin-framework/2.0.0/abstract-plugin-framework-2.0.0-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/djrapitops/abstract-plugin-framework/2.0.1/abstract-plugin-framework-2.0.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -1,8 +1,9 @@
|
||||
package main.java.com.djrapitops.plan.data.listeners;
|
||||
|
||||
import com.djrapitops.plugin.task.AbsRunnable;
|
||||
import com.djrapitops.plugin.utilities.player.Fetch;
|
||||
import com.djrapitops.plugin.utilities.player.Gamemode;
|
||||
import com.djrapitops.plugin.utilities.player.bukkit.BukkitPlayer;
|
||||
import com.djrapitops.plugin.utilities.player.IPlayer;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
@ -26,6 +27,7 @@ import java.util.UUID;
|
||||
* Event Listener for PlayerJoin, PlayerQuit and PlayerKickEvents.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class PlanPlayerListener implements Listener {
|
||||
|
||||
@ -35,8 +37,7 @@ public class PlanPlayerListener implements Listener {
|
||||
/**
|
||||
* Class Constructor.
|
||||
* <p>
|
||||
* Copies the references to multiple handlers from Current instance of
|
||||
* handler.
|
||||
* Copies the references to multiple handlers from Current instance of handler.
|
||||
*
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
@ -48,41 +49,49 @@ public class PlanPlayerListener implements Listener {
|
||||
/**
|
||||
* PlayerJoinEvent Listener.
|
||||
* <p>
|
||||
* If player is a new player, creates a new data in the database for the
|
||||
* player. Retrieves the UserData, updates and then saves it to the Cache.
|
||||
* If player is a new player, creates new data for the player.
|
||||
* <p>
|
||||
* Adds a LoginInfo to the processingQueue if the user is not new.
|
||||
*
|
||||
* @param event The Fired event.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLogin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
IPlayer iPlayer = Fetch.wrapBukkit(player);
|
||||
plugin.getNotificationCenter().checkNotifications(iPlayer);
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
handler.startSession(uuid);
|
||||
Log.debug(uuid + ": PlayerJoinEvent");
|
||||
|
||||
plugin.getRunnableFactory().createNew(new AbsRunnable("NewPlayerCheckTask") {
|
||||
@Override
|
||||
public void run() {
|
||||
LoginInfo loginInfo = new LoginInfo(uuid, MiscUtils.getTime(), player.getAddress().getAddress(), player.isBanned(), player.getDisplayName(), Gamemode.wrap(player.getGameMode()), 1);
|
||||
boolean isNewPlayer = !plugin.getDB().wasSeenBefore(uuid);
|
||||
|
||||
if (isNewPlayer) {
|
||||
UserData newUserData = NewPlayerCreator.createNewPlayer(BukkitPlayer.wrap(player));
|
||||
UserData newUserData = NewPlayerCreator.createNewPlayer(iPlayer);
|
||||
loginInfo.process(newUserData);
|
||||
handler.newPlayer(newUserData);
|
||||
} else {
|
||||
handler.addToPool(loginInfo);
|
||||
}
|
||||
|
||||
Log.debug(uuid + ": PlayerJoinEvent_AsyncTask_END, New:" + isNewPlayer);
|
||||
this.cancel();
|
||||
}
|
||||
}).runTaskAsynchronously();
|
||||
|
||||
Log.debug(uuid + ": PlayerJoinEvent_END");
|
||||
}
|
||||
|
||||
/**
|
||||
* PlayerQuitEvent Listener.
|
||||
* <p>
|
||||
* Retrieves the current UserData for the Player, updates it, saves the data
|
||||
* to Database and clears it from cache.
|
||||
* Adds a LogoutInfo to the processing Queue.
|
||||
*
|
||||
* @param event Fired event
|
||||
*/
|
||||
@ -100,7 +109,7 @@ public class PlanPlayerListener implements Listener {
|
||||
/**
|
||||
* PlayerKickEvent Listener.
|
||||
* <p>
|
||||
* Updates current playerdata and saves it to the Database.
|
||||
* Adds a KickInfo & LogoutInfo to the processing Queue.
|
||||
*
|
||||
* @param event Fired event
|
||||
*/
|
||||
|
@ -106,4 +106,5 @@ permissions:
|
||||
plan.*:
|
||||
children:
|
||||
plan.manage: true
|
||||
plan.staff: true
|
||||
plan.staff: true
|
||||
apf.notify: true
|
Loading…
Reference in New Issue
Block a user