Implement /troll command

This commit is contained in:
JeremyStar™ 2024-10-08 14:14:06 +02:00
parent f147b2000e
commit d86f859b3a
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
4 changed files with 152 additions and 3 deletions

View file

@ -80,6 +80,16 @@ public enum LanguageString {
// Command /toggledownfall
TOGGLEDOWNFALL,
// Command /troll
TROLL_CRASH,
TROLL_CREDITS,
TROLL_CREEPER,
TROLL_DEMO,
TROLL_GUARDIAN,
TROLL_HACK,
TROLL_HACK_COMPLETE,
TROLL_HEAVENS,
// Event for chat messages
CHATMESSAGE_SERVER,

View file

@ -19,15 +19,30 @@
package de.jeremystartm.pickshadow.command.general;
import de.jeremystartm.pickshadow.Extension;
import de.jeremystartm.pickshadow.api.command.CommandBase;
import de.jeremystartm.pickshadow.api.command.completion.StaticTabCompletion;
import de.jeremystartm.pickshadow.api.command.TabCompletion;
import de.jeremystartm.pickshadow.api.command.completion.StubTabCompletion;
import de.jeremystartm.pickshadow.api.translation.LanguageString;
import de.jeremystartm.pickshadow.api.translation.TranslationManager;
import lombok.Getter;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.title.Title;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.time.Duration;
import static java.util.Map.entry;
/**
* Handles the {@code /troll} command.
*
@ -46,7 +61,15 @@ public final class TrollCommand extends CommandBase {
* @return tab completion
* @since v1-release0
*/
private final @NotNull TabCompletion completion = StubTabCompletion.completion();
private final @NotNull TabCompletion completion = new StaticTabCompletion()
.players("", 0)
.add("", 1, "crash", "pickshadow.command.troll.action.crash")
.add("", 1, "credits", "pickshadow.command.troll.action.credits")
.add("", 1, "creeper", "pickshadow.command.troll.action.creeper")
.add("", 1, "demo", "pickshadow.command.troll.action.demo")
.add("", 1, "guardian", "pickshadow.command.troll.action.guardian")
.add("", 1, "hack", "pickshadow.command.troll.action.hack")
.add("", 1, "heavens", "pickshadow.command.troll.action.heavens");
/**
* Creates and initializes an instance of
@ -60,5 +83,103 @@ public final class TrollCommand extends CommandBase {
/** {@inheritDoc} */
@Override
public void invoke(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] arguments) {}
public void invoke(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] arguments) {
if (checkPermission(sender, "pickshadow.command.troll"))
return;
if (arguments.length < 2) {
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_TOO_FEW_ARGUMENTS, sender, true));
return;
}
Player target = Bukkit.getPlayer(arguments[0]);
if (target == null) {
sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_PLAYER_NOT_FOUND, sender, true, entry("player", arguments[0])));
return;
}
switch (arguments[1]) {
case "crash" -> {
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_CRASH, sender, true, entry("target", target.getName())));
for (int i = 0; i < 10000; i++)
target.spawnParticle(Particle.EXPLOSION, target.getLocation(), 100000);
}
case "credits" -> {
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_CREDITS, sender, true, entry("target", target.getName())));
target.showWinScreen();
}
case "creeper" -> {
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_CREEPER, sender, true, entry("target", target.getName())));
target.playSound(Sound.sound(Key.key("minecraft:entity.creeper.primed"), Sound.Source.MASTER, 1f, 1f));
}
case "demo" -> {
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_DEMO, sender, true, entry("target", target.getName())));
target.showDemoScreen();
}
case "guardian" -> {
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_GUARDIAN, sender, true, entry("target", target.getName())));
target.showElderGuardian();
}
case "hack" -> {
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_HACK, sender, true, entry("target", target.getName())));
String format = "<dark_red><bold><obfuscated>";
// Ugly but it works
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
MiniMessage.miniMessage().deserialize(format + ":/45v.8r9(VU$R)w.9ruv"),
Component.empty(),
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
)), null, 20);
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
MiniMessage.miniMessage().deserialize(format + "tI=)$t0,ivAEr9+"),
Component.empty(),
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
)), null, 60);
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
MiniMessage.miniMessage().deserialize(format + "(U$T98vtiIÜ$)TU9i"),
Component.empty(),
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
)), null, 100);
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
MiniMessage.miniMessage().deserialize(format + "L.f-.3_F:_34-,ldMVams"),
Component.empty(),
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
)), null, 140);
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
MiniMessage.miniMessage().deserialize(format + ")$u095u921,EFJKDA"),
Component.empty(),
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
)), null, 180);
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
MiniMessage.miniMessage().deserialize(format + "joIV;;0p98v"),
Component.empty(),
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
)), null, 220);
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
MiniMessage.miniMessage().deserialize(format + "IV)=RI(VT=)l9re"),
Component.empty(),
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
)), null, 260);
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
MiniMessage.miniMessage().deserialize(format + "$KL%98vu9485u20k8lü="),
Component.empty(),
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(0))
)), null, 300);
target.getScheduler().execute(Extension.getInstance(), () -> target.showTitle(Title.title(
MiniMessage.miniMessage().deserialize("<dark_red><bold>" + TranslationManager.get(LanguageString.TROLL_HACK_COMPLETE, target, false)),
Component.empty(),
Title.Times.times(Duration.ofMillis(0), Duration.ofSeconds(5), Duration.ofMillis(500))
)), null, 340);
}
case "heavens" -> {
sender.sendRichMessage(TranslationManager.get(LanguageString.TROLL_HEAVENS, sender, true, entry("target", target.getName())));
Location location = target.getLocation();
location.setY(10000);
target.teleport(location);
}
default -> sender.sendRichMessage(TranslationManager.get(LanguageString.ERROR_INVALID_ARGUMENT, sender, true, entry("argument", arguments[1])));
}
}
}

View file

@ -31,5 +31,14 @@
"TOGGLEDOWNFALL": "Niederschlag umgestellt",
"TROLL_CRASH": "<generic><mention>%target%</mention>'s Minecraft Client sollte nun in der Zeit stehen bleiben...</generic>",
"TROLL_CREDITS": "<generic><mention>%target%</mention> hat's geschafft! Angeblich...</generic>",
"TROLL_CREEPER": "<generic><mention>%target%</mention> erlebt jetzt den Ton eines grünes Geschenks.</generic>",
"TROLL_DEMO": "<generic><mention>%target%</mention> wird nun dazu gezwungen das Spiel zu kaufen.</generic>",
"TROLL_GUARDIAN": "<generic><mention>%target%</mention> wurde von einem Elder Guardian gejumpscared.</generic>",
"TROLL_HACK": "<generic><mention>%target%</mention> wird nun gehackt. OoOoOoOo...</generic>",
"TROLL_HACK_COMPLETE": "Zugang gewährt.",
"TROLL_HEAVENS": "<generic><mention>%target%</mention> glaubt nun fliegen zu können.</generic>",
"CHATCOMMAND_ERROR_NAMESPACE": "<error>Namespaces zu verwenden ist nicht erlaubt, da es verwendet werden kann um Sicherheitsmaßnahmen zu umgehen.</error>"
}

View file

@ -44,6 +44,15 @@
"TOGGLEDOWNFALL": "Toggled downfall",
"TROLL_CRASH": "<generic><mention>%target%</mention>'s Minecraft Client should now be stuck in time...</generic>",
"TROLL_CREDITS": "<generic><mention>%target%</mention> made it! Supposedly...</generic>",
"TROLL_CREEPER": "<generic><mention>%target%</mention> now experiences the sound of a green gift.</generic>",
"TROLL_DEMO": "<generic><mention>%target%</mention> is now required to buy the game.</generic>",
"TROLL_GUARDIAN": "<generic><mention>%target%</mention> has been jumpscared by an Elder Guardian.</generic>",
"TROLL_HACK": "<generic><mention>%target%</mention> is now being hacked. OoOoOoOo...</generic>",
"TROLL_HACK_COMPLETE": "Access granted.",
"TROLL_HEAVENS": "<generic><mention>%target%</mention> believes that they can fly.</generic>",
"CHATMESSAGE_SERVER": "<mention>%sender%</mention> <#d60532>»</#d60532> ",
"CHATCOMMAND_ERROR_NAMESPACE": "<error>Using namespaces is not allowed, as it may be used to circumvent security measures.</error>"