mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-12-17 23:48:00 +01:00
Fixed the gravity command
This commit is contained in:
parent
9e6da2f64a
commit
ece5f378dc
2 changed files with 24 additions and 24 deletions
|
@ -4,6 +4,7 @@ import com.minelittlepony.unicopia.entity.player.Pony;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.FloatArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import net.minecraft.command.arguments.EntityArgumentType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
@ -14,37 +15,36 @@ import net.minecraft.text.TranslatableText;
|
|||
class GravityCommand {
|
||||
|
||||
static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||
LiteralArgumentBuilder<ServerCommandSource> builder = CommandManager.literal("gravity").requires(s -> s.hasPermissionLevel(4));
|
||||
LiteralArgumentBuilder<ServerCommandSource> builder = CommandManager
|
||||
.literal("gravity")
|
||||
.requires(s -> s.hasPermissionLevel(4));
|
||||
|
||||
builder.then(CommandManager
|
||||
.literal("get")
|
||||
.executes(context -> get(context.getSource(), context.getSource().getPlayer(), true))
|
||||
).then(CommandManager.argument("target", EntityArgumentType.player())
|
||||
.executes(context -> get(context.getSource(), EntityArgumentType.getPlayer(context, "target"), false))
|
||||
);
|
||||
builder.then(CommandManager
|
||||
.literal("set")
|
||||
.then(CommandManager.argument("gravity", FloatArgumentType.floatArg(-99, 99))
|
||||
.executes(context -> set(context.getSource(), context.getSource().getPlayer(), FloatArgumentType.getFloat(context, "gravity"), true))
|
||||
.then(CommandManager.argument("target", EntityArgumentType.player())
|
||||
.executes(context -> set(context.getSource(), EntityArgumentType.getPlayer(context, "target"), FloatArgumentType.getFloat(context, "gravity"), false))
|
||||
)));
|
||||
builder.then(CommandManager.literal("get")
|
||||
.executes(context -> get(context.getSource(), context.getSource().getPlayer(), true))
|
||||
.then(CommandManager.argument("target", EntityArgumentType.player())
|
||||
.executes(context -> get(context.getSource(), EntityArgumentType.getPlayer(context, "target"), false))
|
||||
));
|
||||
builder.then(CommandManager.literal("set")
|
||||
.then(CommandManager.argument("gravity", FloatArgumentType.floatArg(-99, 99))
|
||||
.executes(context -> set(context.getSource(), context.getSource().getPlayer(), FloatArgumentType.getFloat(context, "gravity"), true))
|
||||
.then(CommandManager.argument("target", EntityArgumentType.player())
|
||||
.executes(context -> set(context.getSource(), EntityArgumentType.getPlayer(context, "target"), FloatArgumentType.getFloat(context, "gravity"), false))
|
||||
)));
|
||||
|
||||
dispatcher.register(builder);
|
||||
}
|
||||
|
||||
static int get(ServerCommandSource source, PlayerEntity player, boolean isSelf) {
|
||||
static int get(ServerCommandSource source, PlayerEntity player, boolean isSelf) throws CommandSyntaxException {
|
||||
String translationKey = "commands.gravity.get";
|
||||
|
||||
Pony iplayer = Pony.of(player);
|
||||
|
||||
float gravity = iplayer.getGravity().getGravitationConstant();
|
||||
|
||||
if (isSelf) {
|
||||
player.sendMessage(new TranslatableText(translationKey, gravity));
|
||||
if (source.getPlayer() != player) {
|
||||
translationKey += ".other";
|
||||
}
|
||||
|
||||
source.sendFeedback(new TranslatableText(translationKey + ".other", player.getName(), gravity), true);
|
||||
player.sendMessage(new TranslatableText(translationKey, player.getName(), gravity));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@
|
|||
"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.race.success.other": "%1$s was added to the whitelist by %2$s.",
|
||||
"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.",
|
||||
|
@ -241,10 +241,10 @@
|
|||
"commands.disguise.success.otherself": "%1$s changed their disguise to %2$s",
|
||||
|
||||
"commands.gravity.usage": "/gravity <get|set> <player> <gravity>",
|
||||
"commands.gravity.get": "Your gravity is %f",
|
||||
"commands.gravity.get.other": "%1$s has a gravity of %f",
|
||||
"commands.gravity.set": "Your gravity was set to %f",
|
||||
"commands.gravity.set.other": "Set %1$s's gravity to %f",
|
||||
"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",
|
||||
|
||||
"unicopia.race.human": "Human",
|
||||
"unicopia.race.human.alt": "Humans",
|
||||
|
|
Loading…
Reference in a new issue