Abstracted ListenerSystem, moved Processors to new package

This commit is contained in:
Rsl1122 2018-01-13 13:46:32 +02:00
parent 193cccc650
commit d9e9843069
49 changed files with 695 additions and 114 deletions

View File

@ -27,10 +27,13 @@ import com.djrapitops.plan.settings.locale.Locale;
import com.djrapitops.plan.settings.locale.Msg;
import com.djrapitops.plan.settings.theme.PlanColorScheme;
import com.djrapitops.plan.settings.theme.Theme;
import com.djrapitops.plan.system.BukkitSystem;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.file.FileSystem;
import com.djrapitops.plan.system.processing.ProcessingQueue;
import com.djrapitops.plan.system.processing.processors.Processor;
import com.djrapitops.plan.system.processing.processors.importing.importers.OfflinePlayerImporter;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.settings.config.ConfigSystem;
import com.djrapitops.plan.system.update.VersionCheckSystem;
@ -44,9 +47,6 @@ import com.djrapitops.plan.systems.info.BukkitInformationManager;
import com.djrapitops.plan.systems.info.ImporterManager;
import com.djrapitops.plan.systems.info.InformationManager;
import com.djrapitops.plan.systems.info.server.BukkitServerInfoManager;
import com.djrapitops.plan.systems.listeners.*;
import com.djrapitops.plan.systems.processing.Processor;
import com.djrapitops.plan.systems.processing.importing.importers.OfflinePlayerImporter;
import com.djrapitops.plan.systems.tasks.TaskSystem;
import com.djrapitops.plan.utilities.file.export.HtmlExport;
import com.djrapitops.plan.utilities.metrics.BStats;
@ -180,11 +180,6 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
Benchmark.stop("Enable", "WebServer Initialization");
if (!reloading) {
registerListeners();
}
PlanPlayerListener.setCountKicks(true);
TaskSystem.getInstance().enable();
this.api = new API(this);
@ -273,18 +268,7 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
@Override
public void onReload() {
ConfigSystem.reload();
}
private void registerListeners() {
Benchmark.start("Register Listeners");
registerListener(new PlanPlayerListener(this));
registerListener(new PlanChatListener(this));
registerListener(new PlanGamemodeChangeListener(this));
registerListener(new PlanWorldChangeListener(this));
registerListener(new PlanCommandPreprocessListener(this));
registerListener(new PlanDeathEventListener(this));
Benchmark.stop("Enable", "Register Listeners");
}
/**
@ -434,4 +418,8 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
public Systems getSystems() {
return systems;
}
public BukkitSystem getSystem() {
return system;
}
}

View File

@ -9,10 +9,12 @@ import com.djrapitops.plan.settings.locale.Locale;
import com.djrapitops.plan.settings.locale.Msg;
import com.djrapitops.plan.settings.theme.PlanColorScheme;
import com.djrapitops.plan.settings.theme.Theme;
import com.djrapitops.plan.system.BungeeSystem;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.file.FileSystem;
import com.djrapitops.plan.system.processing.ProcessingQueue;
import com.djrapitops.plan.system.processing.processors.Processor;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.settings.config.ConfigSystem;
import com.djrapitops.plan.system.update.VersionCheckSystem;
@ -22,8 +24,6 @@ import com.djrapitops.plan.systems.Systems;
import com.djrapitops.plan.systems.info.BungeeInformationManager;
import com.djrapitops.plan.systems.info.InformationManager;
import com.djrapitops.plan.systems.info.server.BungeeServerInfoManager;
import com.djrapitops.plan.systems.listeners.BungeePlayerListener;
import com.djrapitops.plan.systems.processing.Processor;
import com.djrapitops.plan.systems.tasks.TaskSystem;
import com.djrapitops.plan.utilities.file.export.HtmlExport;
import com.djrapitops.plugin.BungeePlugin;
@ -55,6 +55,7 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
private ProcessingQueue processingQueue;
private boolean setupAllowed = false;
private BungeeSystem system;
@Override
public void onEnable() {
@ -94,8 +95,6 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
processingQueue = new ProcessingQueue();
registerListener(new BungeePlayerListener(this));
Log.logDebug("Enable", "WebServer Initialization");
Log.info(Locale.get(Msg.ENABLED).toString());
if (Settings.ANALYSIS_EXPORT.isTrue()) {
@ -211,4 +210,8 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
public void setSetupAllowed(boolean setupAllowed) {
this.setupAllowed = setupAllowed;
}
public BungeeSystem getSystem() {
return system;
}
}

View File

@ -6,10 +6,10 @@ package com.djrapitops.plan;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.processing.ProcessingQueue;
import com.djrapitops.plan.system.processing.processors.Processor;
import com.djrapitops.plan.system.webserver.WebServer;
import com.djrapitops.plan.systems.Systems;
import com.djrapitops.plan.systems.info.InformationManager;
import com.djrapitops.plan.systems.processing.Processor;
import com.djrapitops.plugin.IPlugin;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.config.Config;

View File

@ -4,8 +4,8 @@ import com.djrapitops.plan.Plan;
import com.djrapitops.plan.command.ConditionUtils;
import com.djrapitops.plan.settings.locale.Locale;
import com.djrapitops.plan.settings.locale.Msg;
import com.djrapitops.plan.system.processing.processors.info.InspectCacheRequestProcessor;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.systems.processing.info.InspectCacheRequestProcessor;
import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plan.utilities.uuid.UUIDUtility;

View File

@ -2,8 +2,8 @@ package com.djrapitops.plan.command.commands.manage;
import com.djrapitops.plan.settings.locale.Locale;
import com.djrapitops.plan.settings.locale.Msg;
import com.djrapitops.plan.system.listeners.bukkit.PlayerOnlineListener;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.systems.listeners.PlanPlayerListener;
import com.djrapitops.plan.utilities.Condition;
import com.djrapitops.plugin.command.CommandType;
import com.djrapitops.plugin.command.ISender;
@ -34,7 +34,7 @@ public class ManageDisableCommand extends SubCommand {
}
switch (args[0].toLowerCase()) {
case "kickcount":
PlanPlayerListener.setCountKicks(false);
PlayerOnlineListener.setCountKicks(false);
sender.sendMessage("§aDisabled Kick Counting temporarily until next plugin reload.");
break;
default:

View File

@ -23,4 +23,8 @@ public class BukkitSystem extends PlanSystem {
configSystem = new BukkitConfigSystem();
databaseSystem = new BukkitDBSystem();
}
public static BukkitSystem getInstance() {
return Plan.getInstance().getSystem();
}
}

View File

@ -23,4 +23,8 @@ public class BungeeSystem extends PlanSystem {
configSystem = new BungeeConfigSystem();
databaseSystem = new BungeeDBSystem();
}
public static BungeeSystem getInstance() {
return PlanBungee.getInstance().getSystem();
}
}

View File

@ -7,6 +7,7 @@ package com.djrapitops.plan.system;
import com.djrapitops.plan.api.exceptions.EnableException;
import com.djrapitops.plan.system.database.DBSystem;
import com.djrapitops.plan.system.file.FileSystem;
import com.djrapitops.plan.system.listeners.ListenerSystem;
import com.djrapitops.plan.system.processing.ProcessingQueue;
import com.djrapitops.plan.system.settings.config.ConfigSystem;
import com.djrapitops.plan.system.update.VersionCheckSystem;
@ -31,6 +32,8 @@ public abstract class PlanSystem implements SubSystem {
protected ConfigSystem configSystem;
protected DBSystem databaseSystem;
protected ListenerSystem listenerSystem;
public PlanSystem() {
processingQueue = new ProcessingQueue();
}
@ -40,14 +43,19 @@ public abstract class PlanSystem implements SubSystem {
checkSubSystemInitialization();
versionCheckSystem.enable();
fileSystem.enable();
configSystem.enable();
databaseSystem.enable();
processingQueue.enable();
listenerSystem.enable();
}
@Override
public void disable() {
processingQueue.disable();
databaseSystem.disable();
configSystem.disable();
fileSystem.disable();
versionCheckSystem.disable();
}
@ -62,6 +70,7 @@ public abstract class PlanSystem implements SubSystem {
NullCheck.check(fileSystem, new IllegalStateException("File system was not initialized."));
NullCheck.check(configSystem, new IllegalStateException("Config system was not initialized."));
NullCheck.check(databaseSystem, new IllegalStateException("Database system was not initialized."));
NullCheck.check(listenerSystem, new IllegalStateException("Listener system was not initialized."));
} catch (Exception e) {
throw new EnableException("One of the subsystems is not initialized on enable for " + this.getClass().getSimpleName() + ".", e);
}
@ -73,9 +82,9 @@ public abstract class PlanSystem implements SubSystem {
if (bukkitAvailable && bungeeAvailable) {
// TODO test system.
} else if (bungeeAvailable) {
// todo bungee
return BungeeSystem.getInstance();
} else {
// Todo bukkit
return BukkitSystem.getInstance();
}
throw new IllegalAccessError("PlanSystem is not available on this platform.");
}
@ -101,4 +110,8 @@ public abstract class PlanSystem implements SubSystem {
public DBSystem getDatabaseSystem() {
return databaseSystem;
}
public ListenerSystem getListenerSystem() {
return listenerSystem;
}
}

View File

@ -0,0 +1,32 @@
package com.djrapitops.plan.system.listeners;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.system.listeners.bukkit.*;
import org.bukkit.event.HandlerList;
public class BukkitListenerSystem extends ListenerSystem {
private final Plan plugin;
public BukkitListenerSystem(Plan plugin) {
this.plugin = plugin;
}
@Override
protected void registerListeners() {
plugin.registerListener(
new PlayerOnlineListener(plugin),
new ChatListener(plugin),
new GamemodeChangeListener(plugin),
new WorldChangeListener(plugin),
new CommandPreprocessListener(plugin),
new DeathEventListener(plugin)
);
PlayerOnlineListener.setCountKicks(true);
}
@Override
protected void unregisterListeners() {
HandlerList.unregisterAll(plugin);
}
}

View File

@ -0,0 +1,23 @@
package com.djrapitops.plan.system.listeners;
import com.djrapitops.plan.PlanBungee;
import com.djrapitops.plan.system.listeners.bungee.PlayerOnlineListener;
public class BungeeListenerSystem extends ListenerSystem {
private final PlanBungee plugin;
public BungeeListenerSystem(PlanBungee plugin) {
this.plugin = plugin;
}
@Override
protected void registerListeners() {
plugin.registerListener(new PlayerOnlineListener(plugin));
}
@Override
protected void unregisterListeners() {
plugin.getProxy().getPluginManager().unregisterListeners(plugin);
}
}

View File

@ -0,0 +1,25 @@
package com.djrapitops.plan.system.listeners;
import com.djrapitops.plan.system.SubSystem;
import com.djrapitops.plugin.api.Benchmark;
public abstract class ListenerSystem implements SubSystem {
@Override
public void enable() {
Benchmark.start("Register Listeners");
registerListeners();
Benchmark.stop("Enable", "Register Listeners");
}
@Override
public void disable() {
unregisterListeners();
}
protected abstract void registerListeners();
protected abstract void unregisterListeners();
}

View File

@ -0,0 +1,61 @@
package com.djrapitops.plan.system.listeners.bukkit;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.system.processing.processors.player.NameProcessor;
import com.djrapitops.plan.systems.cache.DataCache;
import com.djrapitops.plugin.api.utility.log.Log;
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.AsyncPlayerChatEvent;
import java.util.UUID;
/**
* Event Listener for AsyncPlayerChatEvents.
*
* @author Rsl1122
*/
public class ChatListener implements Listener {
private final Plan plugin;
private final DataCache dataCache;
/**
* Class Constructor.
*
* @param plugin Current instance of Plan
*/
public ChatListener(Plan plugin) {
this.plugin = plugin;
dataCache = plugin.getDataCache();
}
/**
* ChatEvent listener.
*
* @param event Fired Event
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onChat(AsyncPlayerChatEvent event) {
if (event.isCancelled()) {
return;
}
try {
Player p = event.getPlayer();
UUID uuid = p.getUniqueId();
String name = p.getName();
String displayName = p.getDisplayName();
if (dataCache.isFirstSession(uuid)) {
dataCache.firstSessionMessageSent(uuid);
}
plugin.addToProcessQueue(new NameProcessor(uuid, name, displayName));
} catch (Exception e) {
Log.toLog(this.getClass(), e);
}
}
}

View File

@ -0,0 +1,77 @@
package com.djrapitops.plan.system.listeners.bukkit;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.system.processing.processors.CommandProcessor;
import com.djrapitops.plan.system.settings.Permissions;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plugin.api.utility.log.Log;
import org.bukkit.command.Command;
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.PlayerCommandPreprocessEvent;
/**
* Event Listener for PlayerCommandPreprocessEvents.
*
* @author Rsl1122
*/
public class CommandPreprocessListener implements Listener {
private final Plan plugin;
/**
* Class Constructor.
*
* @param plugin Current instance of Plan
*/
public CommandPreprocessListener(Plan plugin) {
this.plugin = plugin;
}
/**
* Command use listener.
*
* @param event Fired event.
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
if (event.isCancelled()) {
return;
}
Player player = event.getPlayer();
try {
if (player.hasPermission(Permissions.IGNORE_COMMANDUSE.getPermission())) {
return;
}
String commandName = event.getMessage().substring(1).split(" ")[0].toLowerCase();
boolean logUnknownCommands = Settings.LOG_UNKNOWN_COMMANDS.isTrue();
boolean combineCommandAliases = Settings.COMBINE_COMMAND_ALIASES.isTrue();
if (!logUnknownCommands || combineCommandAliases) {
Command command = plugin.getServer().getPluginCommand(commandName);
if (command == null) {
try {
command = plugin.getServer().getCommandMap().getCommand(commandName);
} catch (NoSuchMethodError ignored) {
/* Ignored, Bukkit 1.8 has no such method */
}
}
if (command == null) {
if (!logUnknownCommands) {
return;
}
} else if (combineCommandAliases) {
commandName = command.getName();
}
}
plugin.addToProcessQueue(new CommandProcessor(commandName));
} catch (Exception e) {
Log.toLog(this.getClass(), e);
}
}
}

View File

@ -0,0 +1,133 @@
package com.djrapitops.plan.system.listeners.bukkit;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.system.processing.processors.player.DeathProcessor;
import com.djrapitops.plan.system.processing.processors.player.KillProcessor;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.api.utility.log.Log;
import com.djrapitops.plugin.utilities.Format;
import org.bukkit.Material;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.projectiles.ProjectileSource;
/**
* Event Listener for EntityDeathEvents.
*
* @author Rsl1122
*/
public class DeathEventListener implements Listener {
private final Plan plugin;
/**
* Class Constructor.
*
* @param plugin Current instance of Plan
*/
public DeathEventListener(Plan plugin) {
this.plugin = plugin;
}
/**
* Command use listener.
*
* @param event Fired event.
*/
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR)
public void onDeath(EntityDeathEvent event) {
long time = MiscUtils.getTime();
LivingEntity dead = event.getEntity();
if (dead instanceof Player) {
plugin.addToProcessQueue(new DeathProcessor(dead.getUniqueId()));
}
try {
EntityDamageEvent entityDamageEvent = dead.getLastDamageCause();
if (!(entityDamageEvent instanceof EntityDamageByEntityEvent)) {
return;
}
EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) entityDamageEvent;
Entity killerEntity = entityDamageByEntityEvent.getDamager();
if (killerEntity instanceof Player) {
handlePlayerKill(time, dead, (Player) killerEntity);
} else if (killerEntity instanceof Wolf) {
handleWolfKill(time, dead, (Wolf) killerEntity);
} else if (killerEntity instanceof Arrow) {
handleArrowKill(time, dead, (Arrow) killerEntity);
}
} catch (Exception e) {
Log.toLog(this.getClass(), e);
}
}
private void handlePlayerKill(long time, LivingEntity dead, Player killer) {
Material itemInHand;
try {
itemInHand = killer.getInventory().getItemInMainHand().getType();
} catch (NoSuchMethodError e) {
try {
itemInHand = killer.getInventory().getItemInHand().getType(); // Support for non dual wielding versions.
} catch (Exception | NoSuchMethodError | NoSuchFieldError e2) {
itemInHand = Material.AIR;
}
}
plugin.addToProcessQueue(new KillProcessor(killer.getUniqueId(), time, dead, normalizeMaterialName(itemInHand)));
}
private void handleWolfKill(long time, LivingEntity dead, Wolf wolf) {
if (!wolf.isTamed()) {
return;
}
AnimalTamer owner = wolf.getOwner();
if (!(owner instanceof Player)) {
return;
}
plugin.addToProcessQueue(new KillProcessor(owner.getUniqueId(), time, dead, "Wolf"));
}
private void handleArrowKill(long time, LivingEntity dead, Arrow arrow) {
ProjectileSource source = arrow.getShooter();
if (!(source instanceof Player)) {
return;
}
Player player = (Player) source;
plugin.addToProcessQueue(new KillProcessor(player.getUniqueId(), time, dead, "Bow"));
}
/**
* Normalizes a material name
*
* @param material The material
* @return The normalized material name
*/
private String normalizeMaterialName(Material material) {
String[] parts = material.name().split("_");
StringBuilder builder = new StringBuilder();
for (int i = 0; i < parts.length; i++) {
String part = new Format(parts[i]).capitalize().toString();
builder.append(part);
if (i < parts.length - 1) {
builder.append(" ");
}
}
return builder.toString();
}
}

View File

@ -0,0 +1,60 @@
package com.djrapitops.plan.system.listeners.bukkit;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.settings.WorldAliasSettings;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.api.utility.log.Log;
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.PlayerGameModeChangeEvent;
import java.util.Optional;
import java.util.UUID;
/**
* Event Listener for PlayerGameModeChangeEvents.
*
* @author Rsl1122
*/
public class GamemodeChangeListener implements Listener {
private final Plan plugin;
/**
* Class Constructor.
*
* @param plugin Current instance of Plan
*/
public GamemodeChangeListener(Plan plugin) {
this.plugin = plugin;
}
/**
* GM Change Event Listener.
*
* @param event Fired Event.
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onGamemodeChange(PlayerGameModeChangeEvent event) {
if (event.isCancelled()) {
return;
}
try {
Player p = event.getPlayer();
UUID uuid = p.getUniqueId();
long time = MiscUtils.getTime();
String gameMode = event.getNewGameMode().name();
String worldName = p.getWorld().getName();
new WorldAliasSettings().addWorld(worldName);
Optional<Session> cachedSession = plugin.getDataCache().getCachedSession(uuid);
cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time));
} catch (Exception e) {
Log.toLog(this.getClass(), e);
}
}
}

View File

@ -0,0 +1,154 @@
package com.djrapitops.plan.system.listeners.bukkit;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.system.processing.processors.info.NetworkPageUpdateProcessor;
import com.djrapitops.plan.system.processing.processors.player.*;
import com.djrapitops.plan.systems.cache.DataCache;
import com.djrapitops.plan.systems.tasks.TaskSystem;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.api.systems.NotificationCenter;
import com.djrapitops.plugin.api.utility.log.Log;
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.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.UUID;
/**
* Event Listener for PlayerJoin, PlayerQuit and PlayerKickEvents.
*
* @author Rsl1122
* @since 2.0.0
*/
public class PlayerOnlineListener implements Listener {
private static boolean countKicks = true;
private final Plan plugin;
private final DataCache cache;
/**
* Class Constructor.
*
* @param plugin Current instance of Plan
*/
public PlayerOnlineListener(Plan plugin) {
this.plugin = plugin;
cache = plugin.getDataCache();
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerLogin(PlayerLoginEvent event) {
try {
PlayerLoginEvent.Result result = event.getResult();
UUID uuid = event.getPlayer().getUniqueId();
boolean op = event.getPlayer().isOp();
if (result == PlayerLoginEvent.Result.KICK_BANNED) {
plugin.addToProcessQueue(new BanAndOpProcessor(uuid, true, op));
} else {
plugin.addToProcessQueue(new BanAndOpProcessor(uuid, false, op));
}
} catch (Exception e) {
Log.toLog(this.getClass(), e);
}
}
/**
* PlayerKickEvent Listener.
* <p>
* Adds processing information to the ProcessingQueue.
* After KickEvent, the QuitEvent is automatically called.
*
* @param event Fired event
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event) {
try {
if (!countKicks || event.isCancelled()) {
return;
}
UUID uuid = event.getPlayer().getUniqueId();
plugin.addToProcessQueue(new KickProcessor(uuid));
} catch (Exception e) {
Log.toLog(this.getClass(), e);
}
}
/**
* PlayerJoinEvent Listener.
* <p>
* Adds processing information to the ProcessingQueue.
*
* @param event The Fired event.
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
try {
Player player = event.getPlayer();
NotificationCenter.checkNotifications(player);
UUID uuid = player.getUniqueId();
long time = MiscUtils.getTime();
String world = player.getWorld().getName();
String gm = player.getGameMode().name();
String ip = player.getAddress().getAddress().getHostAddress();
String playerName = player.getName();
String displayName = player.getDisplayName();
int playersOnline = TaskSystem.getInstance().getTpsCountTimer().getLatestPlayersOnline();
cache.cacheSession(uuid, Session.start(time, world, gm));
plugin.addToProcessQueue(
new RegisterProcessor(uuid, player.getFirstPlayed(), time, playerName, playersOnline,
new IPUpdateProcessor(uuid, ip, time),
new NameProcessor(uuid, playerName, displayName)
),
new NetworkPageUpdateProcessor(plugin.getInfoManager())
);
} catch (Exception e) {
Log.toLog(this.getClass(), e);
}
}
/**
* PlayerQuitEvent Listener.
* <p>
* Adds processing information to the ProcessingQueue.
*
* @param event Fired event
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) {
try {
long time = MiscUtils.getTime();
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
plugin.addToProcessQueue(
new BanAndOpProcessor(uuid, player.isBanned(), player.isOp()),
new EndSessionProcessor(uuid, time),
new NetworkPageUpdateProcessor(plugin.getInfoManager())
);
if (cache.isFirstSession(uuid)) {
int messagesSent = plugin.getDataCache().getFirstSessionMsgCount(uuid);
plugin.addToProcessQueue(new FirstLeaveProcessor(uuid, time, messagesSent));
}
} catch (Exception e) {
Log.toLog(this.getClass(), e);
}
}
public static void setCountKicks(boolean value) {
countKicks = value;
}
}

View File

@ -0,0 +1,42 @@
package com.djrapitops.plan.system.listeners.bukkit;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.settings.WorldAliasSettings;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.api.utility.log.Log;
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.PlayerChangedWorldEvent;
import java.util.Optional;
import java.util.UUID;
public class WorldChangeListener implements Listener {
private final Plan plugin;
public WorldChangeListener(Plan plugin) {
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onWorldChange(PlayerChangedWorldEvent event) {
try {
Player p = event.getPlayer();
String worldName = p.getWorld().getName();
UUID uuid = p.getUniqueId();
String gameMode = p.getGameMode().name();
long time = MiscUtils.getTime();
new WorldAliasSettings().addWorld(worldName);
Optional<Session> cachedSession = plugin.getDataCache().getCachedSession(uuid);
cachedSession.ifPresent(session -> session.changeState(worldName, gameMode, time));
} catch (Exception e) {
Log.toLog(this.getClass(), e);
}
}
}

View File

@ -2,10 +2,10 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.listeners;
package com.djrapitops.plan.system.listeners.bungee;
import com.djrapitops.plan.PlanBungee;
import com.djrapitops.plan.systems.processing.player.BungeePlayerRegisterProcessor;
import com.djrapitops.plan.system.processing.processors.player.BungeePlayerRegisterProcessor;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.api.utility.log.Log;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -20,11 +20,11 @@ import java.util.UUID;
*
* @author Rsl1122
*/
public class BungeePlayerListener implements Listener {
public class PlayerOnlineListener implements Listener {
private final PlanBungee plugin;
public BungeePlayerListener(PlanBungee plugin) {
public PlayerOnlineListener(PlanBungee plugin) {
this.plugin = plugin;
}

View File

@ -3,7 +3,7 @@ package com.djrapitops.plan.system.processing;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.system.PlanSystem;
import com.djrapitops.plan.system.SubSystem;
import com.djrapitops.plan.systems.processing.Processor;
import com.djrapitops.plan.system.processing.processors.Processor;
import com.djrapitops.plan.systems.queue.Consumer;
import com.djrapitops.plan.systems.queue.Queue;
import com.djrapitops.plan.systems.queue.Setup;

View File

@ -2,7 +2,7 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing;
package com.djrapitops.plan.system.processing.processors;
import com.djrapitops.plan.Plan;
import com.djrapitops.plugin.api.utility.log.Log;

View File

@ -2,12 +2,12 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing;
package com.djrapitops.plan.system.processing.processors;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.Action;
import com.djrapitops.plan.system.database.tables.Actions;
import com.djrapitops.plan.systems.processing.player.PlayerProcessor;
import com.djrapitops.plan.system.processing.processors.player.PlayerProcessor;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plan.utilities.html.HtmlUtils;
import com.djrapitops.plugin.api.utility.log.Log;

View File

@ -2,7 +2,7 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing;
package com.djrapitops.plan.system.processing.processors;
import com.djrapitops.plan.system.processing.ProcessingQueue;

View File

@ -2,8 +2,9 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing;
package com.djrapitops.plan.system.processing.processors;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.data.container.TPS;
import com.djrapitops.plan.utilities.analysis.MathUtils;
import com.djrapitops.plugin.api.utility.log.Log;

View File

@ -2,7 +2,7 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.importing;
package com.djrapitops.plan.system.processing.processors.importing;
import com.djrapitops.plan.data.container.TPS;

View File

@ -2,7 +2,7 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.importing;
package com.djrapitops.plan.system.processing.processors.importing;
import com.djrapitops.plan.data.container.PlayerKill;
import com.djrapitops.plan.data.time.GMTimes;

View File

@ -2,7 +2,7 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.importing;
package com.djrapitops.plan.system.processing.processors.importing;
import com.djrapitops.plan.Plan;
import com.djrapitops.plugin.api.Benchmark;

View File

@ -2,7 +2,7 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.importing.importers;
package com.djrapitops.plan.system.processing.processors.importing.importers;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.GeoInfo;
@ -10,10 +10,10 @@ import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.container.UserInfo;
import com.djrapitops.plan.data.time.WorldTimes;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.processing.processors.importing.ServerImportData;
import com.djrapitops.plan.system.processing.processors.importing.UserImportData;
import com.djrapitops.plan.system.processing.processors.importing.UserImportRefiner;
import com.djrapitops.plan.systems.cache.GeolocationCache;
import com.djrapitops.plan.systems.processing.importing.ServerImportData;
import com.djrapitops.plan.systems.processing.importing.UserImportData;
import com.djrapitops.plan.systems.processing.importing.UserImportRefiner;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.utility.log.Log;

View File

@ -2,10 +2,10 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.importing.importers;
package com.djrapitops.plan.system.processing.processors.importing.importers;
import com.djrapitops.plan.systems.processing.importing.ServerImportData;
import com.djrapitops.plan.systems.processing.importing.UserImportData;
import com.djrapitops.plan.system.processing.processors.importing.ServerImportData;
import com.djrapitops.plan.system.processing.processors.importing.UserImportData;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;

View File

@ -2,14 +2,14 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.info;
package com.djrapitops.plan.system.processing.processors.info;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.settings.locale.Locale;
import com.djrapitops.plan.settings.locale.Msg;
import com.djrapitops.plan.system.processing.processors.player.PlayerProcessor;
import com.djrapitops.plan.systems.cache.DataCache;
import com.djrapitops.plan.systems.processing.player.PlayerProcessor;
import com.djrapitops.plugin.command.CommandUtils;
import com.djrapitops.plugin.command.ISender;

View File

@ -2,10 +2,10 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.info;
package com.djrapitops.plan.system.processing.processors.info;
import com.djrapitops.plan.system.processing.processors.Processor;
import com.djrapitops.plan.systems.info.InformationManager;
import com.djrapitops.plan.systems.processing.Processor;
/**
* //TODO Class Javadoc Comment

View File

@ -2,7 +2,7 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.player;
package com.djrapitops.plan.system.processing.processors.player;
import com.djrapitops.plan.Plan;
import com.djrapitops.plugin.api.utility.log.Log;

View File

@ -2,7 +2,7 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.player;
package com.djrapitops.plan.system.processing.processors.player;
import com.djrapitops.plan.PlanBungee;
import com.djrapitops.plan.system.database.tables.UsersTable;

View File

@ -1,4 +1,4 @@
package com.djrapitops.plan.systems.processing.player;
package com.djrapitops.plan.system.processing.processors.player;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.Session;

View File

@ -2,7 +2,7 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.player;
package com.djrapitops.plan.system.processing.processors.player;
import com.djrapitops.plan.Plan;

View File

@ -2,7 +2,7 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.player;
package com.djrapitops.plan.system.processing.processors.player;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.Action;

View File

@ -2,7 +2,7 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.player;
package com.djrapitops.plan.system.processing.processors.player;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.GeoInfo;

View File

@ -2,7 +2,7 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.player;
package com.djrapitops.plan.system.processing.processors.player;
import com.djrapitops.plan.Plan;
import com.djrapitops.plugin.api.utility.log.Log;

View File

@ -1,4 +1,4 @@
package com.djrapitops.plan.systems.processing.player;
package com.djrapitops.plan.system.processing.processors.player;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.PlayerKill;

View File

@ -2,13 +2,13 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.player;
package com.djrapitops.plan.system.processing.processors.player;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.database.tables.NicknamesTable;
import com.djrapitops.plan.system.processing.processors.NewNickActionProcessor;
import com.djrapitops.plan.systems.cache.DataCache;
import com.djrapitops.plan.systems.processing.NewNickActionProcessor;
import com.djrapitops.plugin.api.utility.log.Log;
import java.sql.SQLException;

View File

@ -2,9 +2,9 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.player;
package com.djrapitops.plan.system.processing.processors.player;
import com.djrapitops.plan.systems.processing.Processor;
import com.djrapitops.plan.system.processing.processors.Processor;
import java.util.UUID;

View File

@ -2,7 +2,7 @@
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.player;
package com.djrapitops.plan.system.processing.processors.player;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.Action;
@ -10,7 +10,7 @@ import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.database.tables.Actions;
import com.djrapitops.plan.system.database.tables.UserInfoTable;
import com.djrapitops.plan.system.database.tables.UsersTable;
import com.djrapitops.plan.systems.processing.Processor;
import com.djrapitops.plan.system.processing.processors.Processor;
import com.djrapitops.plugin.api.utility.log.Log;
import java.sql.SQLException;

View File

@ -7,11 +7,11 @@ package com.djrapitops.plan.system.webserver.webapi.bungee;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.api.exceptions.WebAPIException;
import com.djrapitops.plan.system.processing.processors.Processor;
import com.djrapitops.plan.system.webserver.response.Response;
import com.djrapitops.plan.system.webserver.webapi.WebAPI;
import com.djrapitops.plan.system.webserver.webapi.bukkit.RequestInspectPluginsTabBukkitWebAPI;
import com.djrapitops.plan.systems.info.server.ServerInfo;
import com.djrapitops.plan.systems.processing.Processor;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.utility.log.Log;

View File

@ -2,7 +2,7 @@ package com.djrapitops.plan.systems.cache;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.systems.processing.Processor;
import com.djrapitops.plan.system.processing.processors.Processor;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plugin.api.utility.log.Log;

View File

@ -12,6 +12,7 @@ import com.djrapitops.plan.data.element.InspectContainer;
import com.djrapitops.plan.data.plugin.HookHandler;
import com.djrapitops.plan.data.plugin.PluginData;
import com.djrapitops.plan.settings.theme.Theme;
import com.djrapitops.plan.system.processing.processors.Processor;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.webserver.WebServer;
import com.djrapitops.plan.system.webserver.WebServerSystem;
@ -32,7 +33,6 @@ import com.djrapitops.plan.system.webserver.webapi.universal.PingWebAPI;
import com.djrapitops.plan.systems.cache.DataCache;
import com.djrapitops.plan.systems.info.parsing.AnalysisPageParser;
import com.djrapitops.plan.systems.info.parsing.InspectPageParser;
import com.djrapitops.plan.systems.processing.Processor;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plan.utilities.analysis.Analysis;
import com.djrapitops.plan.utilities.file.export.HtmlExport;

View File

@ -4,7 +4,7 @@
*/
package com.djrapitops.plan.systems.info;
import com.djrapitops.plan.systems.processing.importing.importers.Importer;
import com.djrapitops.plan.system.processing.processors.importing.importers.Importer;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,39 +0,0 @@
/*
* Licence is provided in the jar as license.yml also here:
* https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml
*/
package com.djrapitops.plan.systems.processing.info;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.systems.processing.Processor;
import com.djrapitops.plugin.api.utility.log.Log;
import org.bukkit.entity.Player;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
/**
* //TODO Class Javadoc Comment
*
* @author Rsl1122
*/
public class BungeePluginChannelSenderProcessor extends Processor<Player> {
public BungeePluginChannelSenderProcessor(Player object) {
super(object);
}
@Override
public void process() {
Log.debug("Sending a Bungee Address get Request through plugin channel");
try (ByteArrayOutputStream b = new ByteArrayOutputStream()) {
try (DataOutputStream out = new DataOutputStream(b)) {
out.writeUTF("bungee_address_get");
object.sendPluginMessage(Plan.getInstance(), "BungeeCord", b.toByteArray());
}
} catch (IOException e) {
Log.toLog(this.getClass().getName(), e);
}
}
}

View File

@ -4,7 +4,7 @@ import com.djrapitops.plan.Plan;
import com.djrapitops.plan.PlanBungee;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.data.container.TPS;
import com.djrapitops.plan.systems.processing.TPSInsertProcessor;
import com.djrapitops.plan.system.processing.processors.TPSInsertProcessor;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plan.utilities.analysis.MathUtils;
import com.djrapitops.plugin.api.Check;

View File

@ -7,8 +7,8 @@ package com.djrapitops.plan.data.additional.importer;
import com.djrapitops.plan.data.container.PlayerKill;
import com.djrapitops.plan.data.container.TPS;
import com.djrapitops.plan.data.time.GMTimes;
import com.djrapitops.plan.systems.processing.importing.ServerImportData;
import com.djrapitops.plan.systems.processing.importing.UserImportData;
import com.djrapitops.plan.system.processing.processors.importing.ServerImportData;
import com.djrapitops.plan.system.processing.processors.importing.UserImportData;
import com.google.common.collect.ImmutableMap;
import org.junit.Test;
import test.utilities.RandomData;

View File

@ -16,9 +16,9 @@ import com.djrapitops.plan.system.database.databases.MySQLDB;
import com.djrapitops.plan.system.database.databases.SQLDB;
import com.djrapitops.plan.system.database.databases.SQLiteDB;
import com.djrapitops.plan.system.database.tables.*;
import com.djrapitops.plan.system.processing.processors.player.RegisterProcessor;
import com.djrapitops.plan.systems.cache.DataCache;
import com.djrapitops.plan.systems.info.server.ServerInfo;
import com.djrapitops.plan.systems.processing.player.RegisterProcessor;
import com.djrapitops.plan.utilities.ManageUtils;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plan.utilities.analysis.MathUtils;