From 4271938c3af26bf10677c50fb1434a95c8dcc25d Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Fri, 11 Jun 2021 10:46:48 -0400 Subject: [PATCH] Add ice commmand #EasterEgg --- .../essentials/commands/Commandice.java | 59 +++++++++++++++++++ .../src/main/resources/messages.properties | 10 ++++ Essentials/src/main/resources/plugin.yml | 4 ++ 3 files changed, 73 insertions(+) create mode 100644 Essentials/src/main/java/com/earth2me/essentials/commands/Commandice.java diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandice.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandice.java new file mode 100644 index 000000000..dc0eaba9b --- /dev/null +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandice.java @@ -0,0 +1,59 @@ +package com.earth2me.essentials.commands; + +import com.earth2me.essentials.ChargeException; +import com.earth2me.essentials.CommandSource; +import com.earth2me.essentials.User; +import com.earth2me.essentials.utils.VersionUtil; +import net.ess3.api.IUser; +import net.ess3.api.MaxMoneyException; +import org.bukkit.Server; + +import java.util.Collections; +import java.util.List; + +import static com.earth2me.essentials.I18n.tl; + +public class Commandice extends EssentialsLoopCommand { + public Commandice() { + super("ice"); + } + + @Override + protected void run(Server server, CommandSource sender, String commandLabel, String[] args) throws Exception { + if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_17_R01)) { + sender.sendMessage(tl("unsupportedFeature")); + return; + } + + if (args.length == 0 && !sender.isPlayer()) { + throw new NotEnoughArgumentsException(); + } + + if (args.length > 0 && sender.isAuthorized("essentials.ice.others", ess)) { + loopOnlinePlayers(server, sender, false, true, args[0], null); + return; + } + //noinspection ConstantConditions + freezePlayer(sender.getUser(ess)); + } + + @Override + protected void updatePlayer(Server server, CommandSource sender, User user, String[] args) throws NotEnoughArgumentsException, PlayerExemptException, ChargeException, MaxMoneyException { + freezePlayer(user); + user.sendMessage(tl("iceOther")); + } + + private void freezePlayer(final IUser user) { + user.getBase().setFreezeTicks(user.getBase().getMaxFreezeTicks()); + user.sendMessage(tl("ice")); + } + + @Override + protected List getTabCompleteOptions(Server server, CommandSource sender, String commandLabel, String[] args) { + if (args.length == 1 && sender.isAuthorized("essentials.ice.others", ess)) { + return getPlayers(server, sender); + } else { + return Collections.emptyList(); + } + } +} diff --git a/Essentials/src/main/resources/messages.properties b/Essentials/src/main/resources/messages.properties index 408287cc7..36b94f3c3 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -438,6 +438,16 @@ homeConfirmation=\u00a76You already have a home named \u00a7c{0}\u00a76!\nTo ove homeSet=\u00a76Home set to current location. hour=hour hours=hours +ice=\u00a76You feel much colder... +iceCommandDescription=Cools a player off. +iceCommandUsage=/ [player] +iceCommandUsage1=/ +iceCommandUsage1Description=Cools you off +iceCommandUsage2=/ +iceCommandUsage2Description=Cools the given player off +iceCommandUsage3=/ * +iceCommandUsage3Description=Cools all online players off +iceOther=\u00a76Chilling\u00a7c {0}\u00a76. ignoreCommandDescription=Ignore or unignore other players. ignoreCommandUsage=/ ignoreCommandUsage1=/ diff --git a/Essentials/src/main/resources/plugin.yml b/Essentials/src/main/resources/plugin.yml index abe569bcd..e96ec4aff 100644 --- a/Essentials/src/main/resources/plugin.yml +++ b/Essentials/src/main/resources/plugin.yml @@ -208,6 +208,10 @@ commands: description: Teleport to your home. usage: / [player:][name] aliases: [ehome,homes,ehomes] + ice: + description: Cools a player off. + usage: / [player] + aliases: [eice, efreeze] ignore: description: Ignore or unignore other players. usage: /