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