mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-24 06:06:45 +01:00
Add JFR events
This commit is contained in:
parent
bbf1e4fe61
commit
78c107f176
@ -35,6 +35,9 @@ import com.plotsquared.core.util.query.PlotQuery;
|
|||||||
import com.plotsquared.core.util.query.SortingStrategy;
|
import com.plotsquared.core.util.query.SortingStrategy;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
|
import jdk.jfr.Category;
|
||||||
|
import jdk.jfr.Event;
|
||||||
|
import jdk.jfr.Label;
|
||||||
import net.kyori.adventure.text.minimessage.Template;
|
import net.kyori.adventure.text.minimessage.Template;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
@ -59,13 +62,24 @@ public class HomeCommand extends Command {
|
|||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Label("Home Query")
|
||||||
|
@Category("PlotSquared")
|
||||||
|
static class HomeQueryEvent extends Event {
|
||||||
|
@Label("Result Size")
|
||||||
|
public int size;
|
||||||
|
}
|
||||||
|
|
||||||
private void home(
|
private void home(
|
||||||
final @NonNull PlotPlayer<?> player,
|
final @NonNull PlotPlayer<?> player,
|
||||||
final @NonNull PlotQuery query, final int page,
|
final @NonNull PlotQuery query, final int page,
|
||||||
final RunnableVal3<Command, Runnable, Runnable> confirm,
|
final RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||||
final RunnableVal2<Command, CommandResult> whenDone
|
final RunnableVal2<Command, CommandResult> whenDone
|
||||||
) {
|
) {
|
||||||
|
final HomeQueryEvent event = new HomeQueryEvent();
|
||||||
|
event.begin();
|
||||||
List<Plot> plots = query.asList();
|
List<Plot> plots = query.asList();
|
||||||
|
event.size = plots.size();
|
||||||
|
event.commit();
|
||||||
if (plots.isEmpty()) {
|
if (plots.isEmpty()) {
|
||||||
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
|
player.sendMessage(TranslatableCaption.of("invalid.found_no_plots"));
|
||||||
return;
|
return;
|
||||||
|
@ -68,6 +68,9 @@ import com.plotsquared.core.util.task.TaskTime;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import jdk.jfr.Category;
|
||||||
|
import jdk.jfr.Event;
|
||||||
|
import jdk.jfr.Label;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
@ -2288,6 +2291,25 @@ public class Plot {
|
|||||||
return this.area.getPlotAbs(this.id.getRelative(direction));
|
return this.area.getPlotAbs(this.id.getRelative(direction));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Label("Connected Plots Search")
|
||||||
|
@Category("PlotSquared")
|
||||||
|
static class ConnectedPlotsEvent extends Event {
|
||||||
|
|
||||||
|
public ConnectedPlotsEvent(final int x, final int y) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Label("Plot Id X")
|
||||||
|
public int x;
|
||||||
|
@Label("Plot Id Y")
|
||||||
|
public int y;
|
||||||
|
@Label("Merged Plots Count")
|
||||||
|
public int mergedSize;
|
||||||
|
@Label("Connected Plots Cache Miss")
|
||||||
|
public boolean cacheMiss;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a set of plots connected (and including) this plot<br>
|
* Gets a set of plots connected (and including) this plot<br>
|
||||||
* - This result is cached globally
|
* - This result is cached globally
|
||||||
@ -2295,13 +2317,19 @@ public class Plot {
|
|||||||
* @return a Set of Plots connected to this Plot
|
* @return a Set of Plots connected to this Plot
|
||||||
*/
|
*/
|
||||||
public Set<Plot> getConnectedPlots() {
|
public Set<Plot> getConnectedPlots() {
|
||||||
|
ConnectedPlotsEvent event = new ConnectedPlotsEvent(this.id.getX(), this.id.getY());
|
||||||
|
event.begin();
|
||||||
if (this.settings == null) {
|
if (this.settings == null) {
|
||||||
|
event.commit();
|
||||||
return Collections.singleton(this);
|
return Collections.singleton(this);
|
||||||
}
|
}
|
||||||
if (!this.isMerged()) {
|
if (!this.isMerged()) {
|
||||||
|
event.commit();
|
||||||
return Collections.singleton(this);
|
return Collections.singleton(this);
|
||||||
}
|
}
|
||||||
if (connected_cache != null && connected_cache.contains(this)) {
|
if (connected_cache != null && connected_cache.contains(this)) {
|
||||||
|
event.mergedSize = connected_cache.size();
|
||||||
|
event.commit();
|
||||||
return connected_cache;
|
return connected_cache;
|
||||||
}
|
}
|
||||||
regions_cache = null;
|
regions_cache = null;
|
||||||
@ -2410,6 +2438,9 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
connected_cache = tmpSet;
|
connected_cache = tmpSet;
|
||||||
|
event.mergedSize = tmpSet.size();
|
||||||
|
event.cacheMiss = true;
|
||||||
|
event.commit();
|
||||||
return tmpSet;
|
return tmpSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user