Fixed various bugs with the commands

This commit is contained in:
Sollace 2021-08-07 22:32:05 +02:00
parent 6d82ecc73b
commit 550db7ad97
4 changed files with 44 additions and 31 deletions

View file

@ -21,6 +21,7 @@ import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.world.GameRules;
public class DisguiseCommand {
@ -65,13 +66,14 @@ public class DisguiseCommand {
.orElseGet(() -> SpellType.DISGUISE.apply(iplayer))
.setDisguise(entity);
if (!isSelf) {
source.sendFeedback(new TranslatableText("commands.disguise.success.other", player.getName(), entity.getName()), true);
if (source.getEntity() == player) {
source.sendFeedback(new TranslatableText("commands.disguise.success.self", entity.getName()), true);
} else {
if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendMessage(new TranslatableText("commands.disguise.success.self", entity.getName()), false);
player.sendSystemMessage(new TranslatableText("commands.disguise.success", entity.getName()), Util.NIL_UUID);
}
source.sendFeedback(new TranslatableText("commands.disguise.success.otherself", player.getName(), entity.getName()), true);
source.sendFeedback(new TranslatableText("commands.disguise.success.other", player.getName(), entity.getName()), true);
}
return 0;
@ -81,8 +83,14 @@ public class DisguiseCommand {
Pony iplayer = Pony.of(player);
iplayer.getSpellSlot().get(SpellType.DISGUISE, true).ifPresent(Spell::setDead);
if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendMessage(new TranslatableText("commands.disguise.removed"), false);
if (source.getEntity() == player) {
source.sendFeedback(new TranslatableText("commands.disguise.removed.self"), true);
} else {
if (player.getEntityWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendSystemMessage(new TranslatableText("commands.disguise.removed"), Util.NIL_UUID);
}
source.sendFeedback(new TranslatableText("commands.disguise.removed.other", player.getName()), true);
}
return 0;

View file

@ -11,6 +11,8 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Util;
import net.minecraft.world.GameRules;
class GravityCommand {
@ -41,10 +43,11 @@ class GravityCommand {
float gravity = iplayer.getPhysics().getGravityModifier();
if (source.getPlayer() != player) {
translationKey += ".other";
if (source.getPlayer() == player) {
player.sendMessage(new TranslatableText(translationKey, gravity), false);
} else {
source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true);
}
player.sendMessage(new TranslatableText(translationKey, player.getName(), gravity), false);
return 0;
}
@ -57,11 +60,15 @@ class GravityCommand {
iplayer.getPhysics().setBaseGravityModifier(gravity);
iplayer.setDirty();
if (isSelf) {
player.sendMessage(new TranslatableText(translationKey, gravity), false);
}
if (source.getEntity() == player) {
source.sendFeedback(new TranslatableText("commands.gamemode.success.self", gravity), true);
} else {
if (source.getWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendSystemMessage(new TranslatableText(translationKey, gravity), Util.NIL_UUID);
}
source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true);
source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true);
}
return 0;
}

View file

@ -22,7 +22,7 @@ class RacelistCommand {
builder.then(CommandManager.literal("allow")
.then(CommandManager.argument("race", new RaceArgument())
.executes(context -> toggle(context.getSource(), context.getSource().getPlayer(), context.getArgument("race", Race.class), "allowed", race -> {
boolean result = Unicopia.getConfig().speciesWhiteList.get().remove(race);
boolean result = Unicopia.getConfig().speciesWhiteList.get().add(race);
Unicopia.getConfig().save();
@ -32,7 +32,7 @@ class RacelistCommand {
builder.then(CommandManager.literal("disallow")
.then(CommandManager.argument("race", new RaceArgument())
.executes(context -> toggle(context.getSource(), context.getSource().getPlayer(), context.getArgument("race", Race.class), "disallowed", race -> {
boolean result = Unicopia.getConfig().speciesWhiteList.get().add(race);
boolean result = Unicopia.getConfig().speciesWhiteList.get().remove(race);
Unicopia.getConfig().save();
@ -52,9 +52,7 @@ class RacelistCommand {
Text formattedName = new TranslatableText(race.name().toLowerCase()).styled(s -> s.withColor(Formatting.GOLD));
player.sendMessage(new TranslatableText(translationKey, formattedName).styled(s -> s.withColor(Formatting.GREEN)), false);
source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), formattedName), true);
source.sendFeedback(new TranslatableText(translationKey, formattedName).styled(s -> s.withColor(Formatting.GREEN)), false);
return 0;
}
}

View file

@ -295,27 +295,27 @@
"commands.racelist.usage": "/racelist <allow|disallow> <species>",
"commands.racelist.illegal": "The default race %s cannot be used with this command.",
"commands.racelist.allowed": "Added %1$s to the whitelist.",
"commands.racelist.allowed.failed": "%1$s is already whitelisted.",
"commands.racelist.success.other": "%1$s was added to the whitelist by %2$s.",
"commands.racelist.allowed.failed.other": "%2$s tried to whitelist %1$s but it was already whitelisted.",
"commands.racelist.disallowed": "Removed %1$s from the whitelist.",
"commands.racelist.disallowed.failed": "%1$s is not on the whitelist.",
"commands.racelist.disallowed.other": "%1$s was removed from the whitelist by %2$s.",
"commands.racelist.disallowed.failed.other": "%2$s tried to remove %1$s from the whitelist but it has not been added yet.",
"commands.disguise.usage": "/disguise <player> <entity> [nbt]",
"commands.disguise.notfound": "The entity id '%s' does not exist.",
"commands.disguise.removed": "Removed disguise.",
"commands.disguise.success.other": "%1$s is now disguised as %2$s",
"commands.disguise.success.self": "Updated disguise to %s",
"commands.disguise.success.otherself": "%1$s changed their disguise to %2$s",
"commands.disguise.removed": "Your disguise has been removed.",
"commands.disguise.removed.self": "Removed own disguise.",
"commands.disguise.removed.other": "Removed %s's disguise.",
"commands.disguise.success": "You are nod disguised as %s",
"commands.disguise.success.self": "Set own disguise to %s",
"commands.disguise.success.other": "%s changed their disguise to %s",
"commands.gravity.usage": "/gravity <get|set> <player> <gravity>",
"commands.gravity.get": "Your gravity is %2$f",
"commands.gravity.get.other": "%1$s has a gravity of %2$f",
"commands.gravity.set": "Your gravity was set to %2$f",
"commands.gravity.set.other": "Set %1$s's gravity to %2$f",
"commands.gravity.get": "Your gravity is %f",
"commands.gravity.get.other": "%s has a gravity of %f",
"commands.gravity.set": "Your gravity has been updated to %f",
"commands.gravity.set.self": "Set own gravity to %f",
"commands.gravity.set.other": "Set %s's gravity to %f",
"unicopia.options.title": "Unicopia Options",
"unicopia.options.ignore_mine_lp": "Ignore Mine Little Pony",