本文整理汇总了Java中net.minecraft.command.ICommandManager.executeCommand方法的典型用法代码示例。如果您正苦于以下问题:Java ICommandManager.executeCommand方法的具体用法?Java ICommandManager.executeCommand怎么用?Java ICommandManager.executeCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.command.ICommandManager
的用法示例。
在下文中一共展示了ICommandManager.executeCommand方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doAction
import net.minecraft.command.ICommandManager; //导入方法依赖的package包/类
@Override
public void doAction(World world, IStructure structure, Point3i worldPos) {
if(commands.isEmpty()) {
return;
}
MinecraftServer minecraftserver = MinecraftServer.getServer();
if(minecraftserver != null) {
Point3i wp = getWorldPosition(structure, worldPos);
InnerSender sender = new InnerSender(world, structure, wp);
ICommandManager icommandmanager = minecraftserver.getCommandManager();
boolean origValue = minecraftserver.worldServers[0].getGameRules().getGameRuleBooleanValue("commandBlockOutput");
minecraftserver.worldServers[0].getGameRules().setOrCreateGameRule("commandBlockOutput", "false");
for(String cmd : commands) {
icommandmanager.executeCommand(sender, cmd);
}
minecraftserver.worldServers[0].getGameRules().setOrCreateGameRule("commandBlockOutput", origValue + "");
}
}
示例2: func_145755_a
import net.minecraft.command.ICommandManager; //导入方法依赖的package包/类
public void func_145755_a(World p_145755_1_)
{
if (p_145755_1_.isClient)
{
this.field_145764_b = 0;
}
MinecraftServer var2 = MinecraftServer.getServer();
if (var2 != null && var2.isCommandBlockEnabled())
{
ICommandManager var3 = var2.getCommandManager();
this.field_145764_b = var3.executeCommand(this, this.field_145763_e);
}
else
{
this.field_145764_b = 0;
}
}
示例3: runCommand
import net.minecraft.command.ICommandManager; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public int runCommand(String... args) {
if (FMLCommonHandler.instance().getMinecraftServerInstance() != null &&
FMLCommonHandler.instance().getMinecraftServerInstance().isCallingFromMinecraftThread()) {
if (reduxEngine.globalObjectExists("entity") && reduxEngine.getJavaObject("entity", Entity.class) instanceof Entity) {
lastEntity = (Entity) reduxEngine.getJavaObject("entity", Entity.class);
} else {
lastEntity = null;
}
if (reduxEngine.globalObjectExists("world") && reduxEngine.getJavaObject("world", World.class) instanceof World) {
lastWorld = (World) reduxEngine.getJavaObject("world", World.class);
} else {
lastWorld = null;
}
if (reduxEngine.globalObjectExists("pos") && reduxEngine.getJavaObject("pos", BlockPos.class) instanceof BlockPos) {
lastBlockPos = (BlockPos) reduxEngine.getJavaObject("pos", BlockPos.class);
} else {
lastBlockPos = null;
}
ICommandManager manager = FMLCommonHandler.instance().getMinecraftServerInstance().getCommandManager();
manager.executeCommand(this, StringUtils.join(args));
}
return 0;
}
示例4: handleCommandExecution
import net.minecraft.command.ICommandManager; //导入方法依赖的package包/类
private int handleCommandExecution(ICommandManager commandManager, CommandBlockLogic commandBlockLogic, String commandStored) {
final String[] args = commandStored.split(" ");
String commandName = args[0];
if (commandName.startsWith("/")) {
commandName = commandName.substring(1);
}
CommandBlockCommandHook commandHook = (CommandBlockCommandHook) new CommandBlockCommandHook(
(net.canarymod.api.CommandBlockLogic) commandBlockLogic, args).call();
if (!commandHook.isCanceled()
&& (Configuration.getServerConfig().isCommandBlockOpped()
|| ((net.canarymod.api.CommandBlockLogic) commandBlockLogic).hasPermission("canary.command." + commandName))) {
int result = commandManager.executeCommand(commandBlockLogic, commandStored);
if (result == 0) {
// Minecraft found no command, now its our turn
Canary.getServer().consoleCommand(commandStored, (net.canarymod.api.CommandBlockLogic) commandBlockLogic);
}
return result;
}
return 0;
}
示例5: func_145755_a
import net.minecraft.command.ICommandManager; //导入方法依赖的package包/类
public void func_145755_a(World p_145755_1_)
{
if (p_145755_1_.isRemote)
{
this.field_145764_b = 0;
}
MinecraftServer minecraftserver = MinecraftServer.getServer();
if (minecraftserver != null && minecraftserver.isCommandBlockEnabled())
{
ICommandManager icommandmanager = minecraftserver.getCommandManager();
this.field_145764_b = icommandmanager.executeCommand(this, this.field_145763_e);
}
else
{
this.field_145764_b = 0;
}
}
示例6: executeCommandOnPowered
import net.minecraft.command.ICommandManager; //导入方法依赖的package包/类
/**
* Execute the command, called when the command block is powered.
*/
public int executeCommandOnPowered(World par1World)
{
if (par1World.isRemote)
{
return 0;
}
else
{
MinecraftServer minecraftserver = MinecraftServer.getServer();
if (minecraftserver != null && minecraftserver.isCommandBlockEnabled())
{
ICommandManager icommandmanager = minecraftserver.getCommandManager();
return icommandmanager.executeCommand(this, this.command);
}
else
{
return 0;
}
}
}
示例7: apply
import net.minecraft.command.ICommandManager; //导入方法依赖的package包/类
@Override
public void apply(EntityActor actor)
{
if (!this.command.isEmpty())
{
MinecraftServer server = actor.worldObj.getMinecraftServer();
if (server != null)
{
ICommandManager manager = server.commandManager;
manager.executeCommand(new CommandSender(actor), this.command);
}
}
}
示例8: execute
import net.minecraft.command.ICommandManager; //导入方法依赖的package包/类
public void execute(MinecraftServer minecraftserver) {
ICommandManager icommandmanager = minecraftserver.getCommandManager();
int value = icommandmanager.executeCommand(minecraftserver, "/schematicaGenerate " + schematic + " " + Integer.toString(x) + " " + Integer.toString(y) + " "+ Integer.toString(z));
if (value < 1) {
FMLLog.getLogger().error("Schematica failed to generate the cheat area- code "+value);
return;
}
}
示例9: SendJsonRaw
import net.minecraft.command.ICommandManager; //导入方法依赖的package包/类
/**
* Send variable number of JSON Objects to a player.
* Note: It is recommended to use SendJsonFormatted() if you want to format a text
* This function will just glue all elements together!
*
* @param pPlayer
* @param pChatObjects
*/
public static void SendJsonRaw( EntityPlayer pPlayer, JSONChatText... pChatObjects )
{
MinecraftServer tMCServer = MinecraftServer.getServer();
ICommandManager tCmdMngr = tMCServer.getCommandManager();
if( tMCServer != null )
{
String tConstructedJSON = "";
if( pChatObjects.length > 1 )
{
boolean tFirst = true;
tConstructedJSON = "[";
for( JSONChatText pChatObject : pChatObjects )
{
if( tFirst )
tFirst = false;
else
tConstructedJSON += ", ";
tConstructedJSON += pChatObject.getConstructed();
}
tConstructedJSON += "]";
}
else
tConstructedJSON = pChatObjects[0].getConstructed();
tCmdMngr.executeCommand( tMCServer, "tellraw " + pPlayer.getCommandSenderName() + " " + tConstructedJSON );
}
}
示例10: trigger
import net.minecraft.command.ICommandManager; //导入方法依赖的package包/类
public void trigger(World worldIn)
{
if (worldIn.isRemote)
{
this.successCount = 0;
}
MinecraftServer minecraftserver = MinecraftServer.getServer();
if (minecraftserver != null && minecraftserver.isAnvilFileSet() && minecraftserver.isCommandBlockEnabled())
{
ICommandManager icommandmanager = minecraftserver.getCommandManager();
try
{
this.lastOutput = null;
this.successCount = icommandmanager.executeCommand(this, this.commandStored);
}
catch (Throwable throwable)
{
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Executing command block");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Command to be executed");
crashreportcategory.addCrashSectionCallable("Command", new Callable<String>()
{
public String call() throws Exception
{
return CommandBlockLogic.this.getCommand();
}
});
crashreportcategory.addCrashSectionCallable("Name", new Callable<String>()
{
public String call() throws Exception
{
return CommandBlockLogic.this.getName();
}
});
throw new ReportedException(crashreport);
}
}
else
{
this.successCount = 0;
}
}
示例11: trigger
import net.minecraft.command.ICommandManager; //导入方法依赖的package包/类
public void trigger(World worldIn)
{
if (worldIn.isRemote)
{
this.successCount = 0;
}
else if ("Searge".equalsIgnoreCase(this.commandStored))
{
this.lastOutput = new TextComponentString("#itzlipofutzli");
this.successCount = 1;
}
else
{
MinecraftServer minecraftserver = this.getServer();
if (minecraftserver != null && minecraftserver.isAnvilFileSet() && minecraftserver.isCommandBlockEnabled())
{
ICommandManager icommandmanager = minecraftserver.getCommandManager();
try
{
this.lastOutput = null;
this.successCount = icommandmanager.executeCommand(this, this.commandStored);
}
catch (Throwable throwable)
{
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Executing command block");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Command to be executed");
crashreportcategory.setDetail("Command", new ICrashReportDetail<String>()
{
public String call() throws Exception
{
return CommandBlockBaseLogic.this.getCommand();
}
});
crashreportcategory.setDetail("Name", new ICrashReportDetail<String>()
{
public String call() throws Exception
{
return CommandBlockBaseLogic.this.getName();
}
});
throw new ReportedException(crashreport);
}
}
else
{
this.successCount = 0;
}
}
}
示例12: execute
import net.minecraft.command.ICommandManager; //导入方法依赖的package包/类
@Override
public String execute(CommandSender sender, String[] params) throws CommandException {
if (params.length > 1 && sender.getServer() instanceof IntegratedServer &&
((IntegratedServer) sender.getServer()).getPublic()) {
EntityPlayer player = null;
Object playerEntity;
Iterator players = sender.getServer().getPlayerList().getPlayers().iterator();
while (players.hasNext()) {
playerEntity = players.next();
if (playerEntity instanceof EntityPlayer) {
if (((EntityPlayer) playerEntity).getName().equalsIgnoreCase(params[0])) {
player = (EntityPlayer) playerEntity;
break;
}
}
}
if (player == null) throw new CommandException("command.sudo.playerNotFound", sender);
ICommandManager manager = sender.getServer().getCommandManager();
String command = params[1];
String parameters = "";
if (params.length > 2) {
int index = 0;
for (String param : params) {
if (index > 1) {parameters += " " + param;}
index++;
}
}
manager.executeCommand((new CommandSender(player)).getMinecraftISender(), command + parameters);
sender.sendLangfileMessage("command.sudo.executed", command + parameters, player.getName());
}
else if (!(sender.getServer() instanceof IntegratedServer)) throw new CommandException("command.sudo.notInLAN", sender);
else if (!((IntegratedServer) sender.getServer()).getPublic()) throw new CommandException("command.sudo.notInLAN", sender);
else throw new CommandException("command.sudo.invalidArgs", sender);
return null;
}