Add RTP timings.
*/
package io.github.nucleuspowered.nucleus.modules.rtp.commands;
+import co.aikar.timings.Timing;
+import co.aikar.timings.Timings;
import io.github.nucleuspowered.nucleus.Nucleus;
import io.github.nucleuspowered.nucleus.api.rtp.RTPKernel;
import io.github.nucleuspowered.nucleus.api.service.NucleusRTPService;
@@ -50,6 +52,7 @@ public class RandomTeleportCommand extends AbstractCommand.SimpleTargetOtherPlay
private RTPConfig rc = new RTPConfig();
private final String WORLD_KEY = "world";
+ private final Timing TIMINGS = Timings.of(Nucleus.getNucleus(), "RTP task");
@Override protected Map<String, PermissionInformation> permissionSuffixesToRegister() {
return new HashMap<String, PermissionInformation>() {{
@@ -145,13 +148,16 @@ public class RandomTeleportCommand extends AbstractCommand.SimpleTargetOtherPlay
return;
}
+ try (Timing dummy = TIMINGS.startTiming()) {
Nucleus.getNucleus()
- .getLogger().debug(String.format("RTP of %s, attempt %s of %s", this.target.getName(), this.maxCount - this.count, this.maxCount));
+ .getLogger()
+ .debug(String.format("RTP of %s, attempt %s of %s", this.target.getName(), this.maxCount - this.count, this.maxCount));
int counter = 0;
while (++counter <= 10) {
try {
- Optional<Location<World>> optionalLocation = this.kernel.getLocation(this.target.getLocation(), this.targetWorld, this.options);
+ Optional<Location<World>> optionalLocation =
+ this.kernel.getLocation(this.target.getLocation(), this.targetWorld, this.options);
if (optionalLocation.isPresent()) {
Location<World> targetLocation = optionalLocation.get();
if (Sponge.getEventManager().post(new RTPSelectedLocationEvent(
@@ -194,6 +200,7 @@ public class RandomTeleportCommand extends AbstractCommand.SimpleTargetOtherPlay
onUnsuccesfulAttempt();
}
+ }
private void onUnsuccesfulAttempt() {
if (this.count <= 0) {
