Add ice commmand #EasterEgg

This commit is contained in:
Josh Roy 2021-06-11 10:46:48 -04:00 committed by MD
parent e1441c1d33
commit 4271938c3a
3 changed files with 73 additions and 0 deletions

View File

@ -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<String> 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();
}
}
}

View File

@ -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=/<command> [player]
iceCommandUsage1=/<command>
iceCommandUsage1Description=Cools you off
iceCommandUsage2=/<command> <player>
iceCommandUsage2Description=Cools the given player off
iceCommandUsage3=/<command> *
iceCommandUsage3Description=Cools all online players off
iceOther=\u00a76Chilling\u00a7c {0}\u00a76.
ignoreCommandDescription=Ignore or unignore other players.
ignoreCommandUsage=/<command> <player>
ignoreCommandUsage1=/<command> <player>

View File

@ -208,6 +208,10 @@ commands:
description: Teleport to your home.
usage: /<command> [player:][name]
aliases: [ehome,homes,ehomes]
ice:
description: Cools a player off.
usage: /<command> [player]
aliases: [eice, efreeze]
ignore:
description: Ignore or unignore other players.
usage: /<command> <player>