// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.builtin.portals.commands;

import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.builtin.portals.resources.PortalWorld;
import com.hypixel.hytale.server.core.universe.world.World;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgumentType;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;

public class TimerFragmentCommand extends PortalWorldCommandBase
{
    private final RequiredArg<Integer> remainingSecondsArg;
    
    public TimerFragmentCommand() {
        super("timer", "server.commands.fragment.timer.desc");
        this.remainingSecondsArg = this.withRequiredArg("seconds", "server.commands.fragment.timer.arg.seconds.desc", ArgTypes.INTEGER);
    }
    
    @Override
    protected void execute(@Nonnull final CommandContext context, @Nonnull final World world, @Nonnull final PortalWorld portalWorld, @Nonnull final Store<EntityStore> store) {
        final int before = (int)portalWorld.getRemainingSeconds(world);
        final int desired = this.remainingSecondsArg.get(context);
        portalWorld.setRemainingSeconds(world, desired);
        context.sendMessage(Message.translation("server.commands.fragment.timer.success").param("before", before).param("after", desired));
    }
}
