From bf72b1560340b48fc0958b3b2038ba13d49b7190 Mon Sep 17 00:00:00 2001 From: Luck Date: Tue, 29 May 2018 01:01:30 +0100 Subject: Multiple fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed an issue which prevented links from being “clickable” * Added a /spark alias * Added a max stack depth limit to fix issues with rendering --- .../me/lucko/spark/bukkit/SparkBukkitPlugin.java | 5 +++++ bukkit/src/main/resources/plugin.yml | 7 ++++--- .../spark/bungeecord/SparkBungeeCordPlugin.java | 11 +++++++++- bungeecord/src/main/resources/bungee.yml | 2 +- .../main/java/com/sk89q/warmroast/StackNode.java | 6 ++++++ .../java/me/lucko/spark/common/CommandHandler.java | 4 +++- .../me/lucko/spark/sponge/SparkSpongePlugin.java | 22 ++++++++++++++++++-- universal/pom.xml | 24 ++++++++++++++++++++++ 8 files changed, 73 insertions(+), 8 deletions(-) diff --git a/bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java b/bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java index 0ddbce0..cc774a3 100644 --- a/bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java +++ b/bukkit/src/main/java/me/lucko/spark/bukkit/SparkBukkitPlugin.java @@ -15,6 +15,11 @@ public class SparkBukkitPlugin extends JavaPlugin { sender.sendMessage(ChatColor.translateAlternateColorCodes('&', message)); } + @Override + protected void sendLink(CommandSender sender, String url) { + sendMessage(sender, "&7" + url); + } + @Override protected void runAsync(Runnable r) { getServer().getScheduler().runTaskAsynchronously(SparkBukkitPlugin.this, r); diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index a1e473e..1914e04 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -1,9 +1,10 @@ name: spark -version: ${project.version} +version: 1.0.2 description: ${project.description} authors: [Luck, sk89q] main: me.lucko.spark.bukkit.SparkBukkitPlugin commands: - profiler: - description: Main plugin command \ No newline at end of file + spark: + description: Main plugin command + aliases: [profiler] \ No newline at end of file diff --git a/bungeecord/src/main/java/me/lucko/spark/bungeecord/SparkBungeeCordPlugin.java b/bungeecord/src/main/java/me/lucko/spark/bungeecord/SparkBungeeCordPlugin.java index 2f43744..c23e303 100644 --- a/bungeecord/src/main/java/me/lucko/spark/bungeecord/SparkBungeeCordPlugin.java +++ b/bungeecord/src/main/java/me/lucko/spark/bungeecord/SparkBungeeCordPlugin.java @@ -4,6 +4,7 @@ import me.lucko.spark.common.CommandHandler; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.api.plugin.Plugin; @@ -16,6 +17,14 @@ public class SparkBungeeCordPlugin extends Plugin { sender.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', message))); } + @Override + protected void sendLink(CommandSender sender, String url) { + TextComponent component = new TextComponent(url); + component.setColor(ChatColor.GRAY); + component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)); + sender.sendMessage(component); + } + @Override protected void runAsync(Runnable r) { getProxy().getScheduler().runAsync(SparkBungeeCordPlugin.this, r); @@ -24,7 +33,7 @@ public class SparkBungeeCordPlugin extends Plugin { @Override public void onEnable() { - getProxy().getPluginManager().registerCommand(this, new Command("profiler", null) { + getProxy().getPluginManager().registerCommand(this, new Command("spark", null, "profiler") { @Override public void execute(CommandSender sender, String[] args) { if (!sender.hasPermission("spark.profiler")) { diff --git a/bungeecord/src/main/resources/bungee.yml b/bungeecord/src/main/resources/bungee.yml index d5aede0..cfcac19 100644 --- a/bungeecord/src/main/resources/bungee.yml +++ b/bungeecord/src/main/resources/bungee.yml @@ -1,5 +1,5 @@ name: spark -version: ${project.version} +version: 1.0.2 description: ${project.description} author: Luck, sk89q main: me.lucko.spark.bungeecord.SparkBungeeCordPlugin diff --git a/common/src/main/java/com/sk89q/warmroast/StackNode.java b/common/src/main/java/com/sk89q/warmroast/StackNode.java index f077309..8fd0661 100644 --- a/common/src/main/java/com/sk89q/warmroast/StackNode.java +++ b/common/src/main/java/com/sk89q/warmroast/StackNode.java @@ -36,6 +36,8 @@ import java.util.Map; */ public class StackNode implements Comparable { + private static final int MAX_STACK_DEPTH = 300; + /** * The name of this node */ @@ -87,6 +89,10 @@ public class StackNode implements Comparable { private void log(StackTraceElement[] elements, int skip, long time) { accumulateTime(time); + + if (skip >= MAX_STACK_DEPTH) { + return; + } if (elements.length - skip == 0) { return; diff --git a/common/src/main/java/me/lucko/spark/common/CommandHandler.java b/common/src/main/java/me/lucko/spark/common/CommandHandler.java index c015cb3..52cdbe1 100644 --- a/common/src/main/java/me/lucko/spark/common/CommandHandler.java +++ b/common/src/main/java/me/lucko/spark/common/CommandHandler.java @@ -51,6 +51,7 @@ public abstract class CommandHandler { // abstract methods implemented by each platform protected abstract void sendMessage(T sender, String message); + protected abstract void sendLink(T sender, String url); protected abstract void runAsync(Runnable r); private void sendPrefixedMessage(T sender, String message) { @@ -231,7 +232,8 @@ public abstract class CommandHandler { JsonObject output = sampler.formOutput(); try { String pasteId = Bytebin.postContent(output); - sendPrefixedMessage(sender, "&bSampling results: &7" + VIEWER_URL + pasteId); + sendPrefixedMessage(sender, "&bSampling results:"); + sendLink(sender, VIEWER_URL + pasteId); } catch (IOException e) { sendPrefixedMessage(sender, "&cAn error occurred whilst uploading the results."); e.printStackTrace(); diff --git a/sponge/src/main/java/me/lucko/spark/sponge/SparkSpongePlugin.java b/sponge/src/main/java/me/lucko/spark/sponge/SparkSpongePlugin.java index b763549..92ecc43 100644 --- a/sponge/src/main/java/me/lucko/spark/sponge/SparkSpongePlugin.java +++ b/sponge/src/main/java/me/lucko/spark/sponge/SparkSpongePlugin.java @@ -14,12 +14,16 @@ import org.spongepowered.api.event.game.state.GameStartedServerEvent; import org.spongepowered.api.plugin.Plugin; import org.spongepowered.api.scheduler.AsynchronousExecutor; import org.spongepowered.api.scheduler.SpongeExecutorService; +import org.spongepowered.api.text.LiteralText; import org.spongepowered.api.text.Text; +import org.spongepowered.api.text.action.TextActions; import org.spongepowered.api.text.format.TextColors; import org.spongepowered.api.text.serializer.TextSerializers; import org.spongepowered.api.world.Location; import org.spongepowered.api.world.World; +import java.net.MalformedURLException; +import java.net.URL; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -29,7 +33,7 @@ import javax.annotation.Nullable; @Plugin( id = "spark", name = "spark", - version = PomData.VERSION, + version = "1.0.2", description = PomData.DESCRIPTION, authors = {"Luck", "sk89q"} ) @@ -41,6 +45,20 @@ public class SparkSpongePlugin implements CommandCallable { sender.sendMessage(TextSerializers.FORMATTING_CODE.deserialize(message)); } + @Override + protected void sendLink(CommandSource sender, String url) { + try { + LiteralText text = Text.builder(url) + .color(TextColors.GRAY) + .onClick(TextActions.openUrl(new URL(url))) + .build(); + + sender.sendMessage(text); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } + @Override protected void runAsync(Runnable r) { asyncExecutor.execute(r); @@ -56,7 +74,7 @@ public class SparkSpongePlugin implements CommandCallable { @Listener public void onServerStart(GameStartedServerEvent event) { - game.getCommandManager().register(this, this, "profiler"); + game.getCommandManager().register(this, this, "spark", "profiler"); } @Override diff --git a/universal/pom.xml b/universal/pom.xml index ad6fb74..507df7b 100644 --- a/universal/pom.xml +++ b/universal/pom.xml @@ -47,6 +47,30 @@ + + + sign + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + + + + + + + me.lucko -- cgit