mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-04 22:41:41 +01:00
Fixed Death Processing and other sponge bugs
This commit is contained in:
parent
e6eac6fa5d
commit
f4c3f804cd
@ -39,7 +39,7 @@ public class SpongeSystem extends PlanSystem implements ServerSystem {
|
||||
configSystem = new BukkitConfigSystem();
|
||||
databaseSystem = new BukkitDBSystem();
|
||||
listenerSystem = new SpongeListenerSystem(plugin);
|
||||
taskSystem = new SpongeTaskSystem();
|
||||
taskSystem = new SpongeTaskSystem(plugin);
|
||||
|
||||
infoSystem = new BukkitInfoSystem();
|
||||
serverInfo = new SpongeServerInfo();
|
||||
|
@ -74,7 +74,14 @@ public class SpongeDeathListener {
|
||||
ItemStack inHand = inMainHand.orElse(killer.getItemInHand(HandTypes.OFF_HAND).orElse(ItemStack.empty()));
|
||||
ItemType type = inHand.isEmpty() ? ItemTypes.AIR : inHand.getType();
|
||||
|
||||
return new SpongeKillProcessor(killer.getUniqueId(), time, dead, normalizeItemName(type));
|
||||
return new SpongeKillProcessor(killer.getUniqueId(), time, getUUID(dead), normalizeItemName(type));
|
||||
}
|
||||
|
||||
private UUID getUUID(Living dead) {
|
||||
if (dead instanceof Player) {
|
||||
return dead.getUniqueId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private SpongeKillProcessor handleWolfKill(long time, Living dead, Wolf wolf) {
|
||||
@ -85,7 +92,7 @@ public class SpongeDeathListener {
|
||||
}
|
||||
|
||||
return owner.get().map(
|
||||
uuid -> new SpongeKillProcessor(uuid, time, dead, "Wolf")
|
||||
uuid -> new SpongeKillProcessor(uuid, time, getUUID(dead), "Wolf")
|
||||
).orElse(null);
|
||||
}
|
||||
|
||||
@ -97,7 +104,7 @@ public class SpongeDeathListener {
|
||||
|
||||
Player player = (Player) source;
|
||||
|
||||
return new SpongeKillProcessor(player.getUniqueId(), time, dead, "Bow");
|
||||
return new SpongeKillProcessor(player.getUniqueId(), time, getUUID(dead), "Bow");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,8 +4,6 @@ import com.djrapitops.plan.data.container.PlayerKill;
|
||||
import com.djrapitops.plan.data.container.Session;
|
||||
import com.djrapitops.plan.system.cache.SessionCache;
|
||||
import com.djrapitops.plan.system.processing.CriticalRunnable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.spongepowered.api.entity.living.Living;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@ -22,7 +20,7 @@ import java.util.UUID;
|
||||
public class SpongeKillProcessor implements CriticalRunnable {
|
||||
|
||||
private final UUID uuid;
|
||||
private final Living dead;
|
||||
private final UUID deadUUID;
|
||||
private final String weaponName;
|
||||
private final long time;
|
||||
|
||||
@ -31,29 +29,37 @@ public class SpongeKillProcessor implements CriticalRunnable {
|
||||
*
|
||||
* @param uuid UUID of the killer.
|
||||
* @param time Epoch ms the event occurred.
|
||||
* @param dead Dead entity (Mob or Player)
|
||||
* @param deadUUID Dead entity (Mob or Player)
|
||||
* @param weaponName Weapon used.
|
||||
*/
|
||||
public SpongeKillProcessor(UUID uuid, long time, Living dead, String weaponName) {
|
||||
public SpongeKillProcessor(UUID uuid, long time, UUID deadUUID, String weaponName) {
|
||||
this.uuid = uuid;
|
||||
this.time = time;
|
||||
this.dead = dead;
|
||||
this.deadUUID = deadUUID;
|
||||
this.weaponName = weaponName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Optional<Session> cachedSession = SessionCache.getCachedSession(uuid);
|
||||
System.out.println("*");
|
||||
if (!cachedSession.isPresent()) {
|
||||
System.out.println("No session");
|
||||
return;
|
||||
}
|
||||
System.out.println("**");
|
||||
Session session = cachedSession.get();
|
||||
System.out.println("***");
|
||||
|
||||
if (dead instanceof Player) {
|
||||
Player deadPlayer = (Player) dead;
|
||||
session.playerKilled(new PlayerKill(deadPlayer.getUniqueId(), weaponName, time));
|
||||
if (deadUUID != null) {
|
||||
System.out.println("Dead player");
|
||||
|
||||
session.playerKilled(new PlayerKill(deadUUID, weaponName, time));
|
||||
} else {
|
||||
System.out.println("Dead mob");
|
||||
|
||||
session.mobKilled();
|
||||
}
|
||||
System.out.println("****");
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class SpongeTPSCountTimer extends TPSCountTimer<PlanSponge> {
|
||||
double tps = Sponge.getGame().getServer().getTicksPerSecond();
|
||||
int playersOnline = ServerInfo.getServerProperties().getOnlinePlayers();
|
||||
latestPlayersOnline = playersOnline;
|
||||
int loadedChunks = getLoadedChunks();
|
||||
int loadedChunks = -1;
|
||||
int entityCount = getEntityCount();
|
||||
|
||||
return TPSBuilder.get()
|
||||
@ -82,6 +82,8 @@ public class SpongeTPSCountTimer extends TPSCountTimer<PlanSponge> {
|
||||
* @return amount of loaded chunks
|
||||
*/
|
||||
private int getLoadedChunks() {
|
||||
// DISABLED
|
||||
|
||||
int loaded = 0;
|
||||
for (World world : Sponge.getGame().getServer().getWorlds()) {
|
||||
Iterator<Chunk> iterator = world.getLoadedChunks().iterator();
|
||||
|
@ -16,7 +16,7 @@ import com.djrapitops.plan.system.processing.Processing;
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.locale.Locale;
|
||||
import com.djrapitops.plan.system.settings.locale.Msg;
|
||||
import com.djrapitops.plan.system.tasks.BukkitTaskSystem;
|
||||
import com.djrapitops.plan.system.tasks.ServerTaskSystem;
|
||||
import com.djrapitops.plan.system.tasks.TaskSystem;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
@ -79,7 +79,7 @@ public class Analysis implements Callable<AnalysisData> {
|
||||
}
|
||||
|
||||
private AnalysisData runAnalysis() throws Exception {
|
||||
((BukkitTaskSystem) TaskSystem.getInstance()).cancelBootAnalysis();
|
||||
((ServerTaskSystem) TaskSystem.getInstance()).cancelBootAnalysis();
|
||||
|
||||
Benchmark.start("Analysis: Total");
|
||||
log(Locale.get(Msg.ANALYSIS_START).toString());
|
||||
|
Loading…
Reference in New Issue
Block a user