set revives command (in case of skill issue)
This commit is contained in:
parent
871c10bba3
commit
1160637cf0
@ -31,6 +31,7 @@ import net.minecraft.world.GameMode;
|
|||||||
import net.touhoudiscord.block.BuyStation;
|
import net.touhoudiscord.block.BuyStation;
|
||||||
import net.touhoudiscord.block.BuyStationEntity;
|
import net.touhoudiscord.block.BuyStationEntity;
|
||||||
import net.touhoudiscord.commands.RedeployPlayerCommand;
|
import net.touhoudiscord.commands.RedeployPlayerCommand;
|
||||||
|
import net.touhoudiscord.commands.SetRevivesCommand;
|
||||||
import net.touhoudiscord.item.BuyStationItem;
|
import net.touhoudiscord.item.BuyStationItem;
|
||||||
import net.touhoudiscord.status.RedeployingStatusEffect;
|
import net.touhoudiscord.status.RedeployingStatusEffect;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -116,6 +117,7 @@ public class HardcoreRedeploy implements ModInitializer {
|
|||||||
HardcoreRedeploy.BUY_STATION).build());
|
HardcoreRedeploy.BUY_STATION).build());
|
||||||
Registry.register(Registries.STATUS_EFFECT, new Identifier(HardcoreRedeploy.MOD_ID, "redeploying"), REDEPLOYING);
|
Registry.register(Registries.STATUS_EFFECT, new Identifier(HardcoreRedeploy.MOD_ID, "redeploying"), REDEPLOYING);
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> RedeployPlayerCommand.register(dispatcher));
|
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> RedeployPlayerCommand.register(dispatcher));
|
||||||
|
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> SetRevivesCommand.register(dispatcher));
|
||||||
Registry.register(Registries.SOUND_EVENT, BUY_STATION_SOUND_ID, BUY_STATION_SOUND_EVENT);
|
Registry.register(Registries.SOUND_EVENT, BUY_STATION_SOUND_ID, BUY_STATION_SOUND_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public class RedeployPlayerCommand {
|
|||||||
|
|
||||||
ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "player");
|
ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "player");
|
||||||
RedeployPlayer.redeploy(player, context.getSource().getPlayer());
|
RedeployPlayer.redeploy(player, context.getSource().getPlayer());
|
||||||
context.getSource().sendFeedback(() -> Text.literal("Redeployed ").append(player.getName()), false);
|
context.getSource().sendFeedback(() -> Text.literal("Redeployed ").append(player.getName()), true);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
})));
|
})));
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package net.touhoudiscord.commands;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||||
|
import net.minecraft.command.argument.EntityArgumentType;
|
||||||
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.touhoudiscord.HardcoreRedeploy;
|
||||||
|
import net.touhoudiscord.RedeployStateSaver;
|
||||||
|
|
||||||
|
import static net.minecraft.server.command.CommandManager.argument;
|
||||||
|
import static net.minecraft.server.command.CommandManager.literal;
|
||||||
|
|
||||||
|
public class SetRevivesCommand {
|
||||||
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
|
dispatcher.register(literal("setrevives")
|
||||||
|
.requires(source -> source.hasPermissionLevel(4))
|
||||||
|
.then(argument("player", EntityArgumentType.player())
|
||||||
|
.then(argument("revives", IntegerArgumentType.integer(0))
|
||||||
|
.executes(context -> {
|
||||||
|
if (context.getSource().getPlayer() == null) return 0;
|
||||||
|
|
||||||
|
ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "player");
|
||||||
|
|
||||||
|
RedeployStateSaver.getPlayerState(player).timesRevived = IntegerArgumentType.getInteger(context, "revives");
|
||||||
|
|
||||||
|
context.getSource().getServer().getPlayerManager().getPlayerList().forEach(player1 -> {
|
||||||
|
HardcoreRedeploy.syncRevives(context.getSource().getServer(), player1, player.getUuid());
|
||||||
|
});
|
||||||
|
context.getSource().sendFeedback(() -> Text.literal("Set revives for ").append(player.getName()), true);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}))));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user