mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-19 03:49:24 +00:00
54 lines
1.7 KiB
Java
54 lines
1.7 KiB
Java
package mcp.mobius.opis.commands;
|
|
|
|
import cpw.mods.fml.common.network.PacketDispatcher;
|
|
import cpw.mods.fml.common.network.Player;
|
|
import mcp.mobius.opis.modOpis;
|
|
import net.minecraft.command.CommandBase;
|
|
import net.minecraft.command.ICommandSender;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
import net.minecraft.network.MemoryConnection;
|
|
import net.minecraft.network.packet.Packet3Chat;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.server.dedicated.DedicatedServer;
|
|
import net.minecraft.util.ChatMessageComponent;
|
|
|
|
public class CommandFrequency extends CommandBase {
|
|
|
|
@Override
|
|
public String getCommandName() {
|
|
return "opis_delay";
|
|
}
|
|
|
|
@Override
|
|
public String getCommandUsage(ICommandSender icommandsender) {
|
|
return "";
|
|
}
|
|
|
|
@Override
|
|
public void processCommand(ICommandSender icommandsender, String[] astring) {
|
|
if (astring.length < 1) return;
|
|
try{
|
|
modOpis.profilerDelay = Integer.valueOf(astring[0]);
|
|
if (icommandsender instanceof EntityPlayer)
|
|
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis delay set to %s ticks.", astring[0]))), (Player)icommandsender);
|
|
|
|
} catch (Exception e){}
|
|
}
|
|
|
|
@Override
|
|
public int getRequiredPermissionLevel()
|
|
{
|
|
return 3;
|
|
}
|
|
|
|
@Override
|
|
public boolean canCommandSenderUseCommand(ICommandSender sender)
|
|
{
|
|
if (sender instanceof DedicatedServer) return true;
|
|
if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true;
|
|
return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username);
|
|
}
|
|
|
|
}
|