Add in a console command handler so you can access the command console
This commit is contained in:
parent
8fa4c1645c
commit
07437b95ae
7 changed files with 115 additions and 1 deletions
|
@ -261,4 +261,24 @@ public class FMLModContainer implements ModContainer
|
|||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#wantsConsoleCommands()
|
||||
*/
|
||||
@Override
|
||||
public boolean wantsConsoleCommands()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see cpw.mods.fml.common.ModContainer#getConsoleHandler()
|
||||
*/
|
||||
@Override
|
||||
public IConsoleHandler getConsoleHandler()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
24
fml/common/cpw/mods/fml/common/IConsoleHandler.java
Normal file
24
fml/common/cpw/mods/fml/common/IConsoleHandler.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* The FML Forge Mod Loader suite.
|
||||
* Copyright (C) 2012 cpw
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 2.1 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package cpw.mods.fml.common;
|
||||
|
||||
/**
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
public interface IConsoleHandler
|
||||
{
|
||||
public boolean handleCommand(String command);
|
||||
}
|
|
@ -156,4 +156,12 @@ public interface ModContainer
|
|||
* @return
|
||||
*/
|
||||
boolean ownsNetworkChannel(String channel);
|
||||
|
||||
/**
|
||||
* Does this mod want commands from the console?
|
||||
* @return
|
||||
*/
|
||||
boolean wantsConsoleCommands();
|
||||
|
||||
IConsoleHandler getConsoleHandler();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
--- ../src-base/minecraft_server/net/minecraft/src/ConsoleCommandHandler.java 0000-00-00 00:00:00.000000000 -0000
|
||||
+++ ../src-work/minecraft_server/net/minecraft/src/ConsoleCommandHandler.java 0000-00-00 00:00:00.000000000 -0000
|
||||
@@ -3,6 +3,8 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
+
|
||||
+import cpw.mods.fml.server.FMLServerHandler;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class ConsoleCommandHandler
|
||||
@@ -397,7 +399,7 @@
|
||||
var6.func_2_b("Ban list:" + this.func_40648_a(this.field_22116_b.func_40025_r(), ", "));
|
||||
}
|
||||
}
|
||||
- else
|
||||
+ else if (!FMLServerHandler.instance().handleServerCommand(var2))
|
||||
{
|
||||
field_22117_a.info("Unknown console command. Type \"help\" for help.");
|
||||
}
|
|
@ -440,4 +440,18 @@ public class FMLServerHandler implements IFMLSidedHandler
|
|||
return new File(".");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param var2
|
||||
* @return
|
||||
*/
|
||||
public boolean handleServerCommand(String command)
|
||||
{
|
||||
for (ModContainer mod : Loader.getModList()) {
|
||||
if (mod.wantsConsoleCommands() && mod.getConsoleHandler().handleCommand(command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.StringTokenizer;
|
|||
import net.minecraft.src.BaseMod;
|
||||
import net.minecraft.src.MLProp;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.IConsoleHandler;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.IDispenseHandler;
|
||||
import cpw.mods.fml.common.INetworkHandler;
|
||||
|
@ -492,4 +493,16 @@ public class ModLoaderModContainer implements ModContainer
|
|||
{
|
||||
return FMLCommonHandler.instance().getChannelListFor(this).contains(channel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wantsConsoleCommands()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConsoleHandler getConsoleHandler()
|
||||
{
|
||||
return mod;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,13 +15,14 @@ package net.minecraft.src;
|
|||
import java.util.Random;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import cpw.mods.fml.common.IConsoleHandler;
|
||||
import cpw.mods.fml.common.ICraftingHandler;
|
||||
import cpw.mods.fml.common.IDispenseHandler;
|
||||
import cpw.mods.fml.common.INetworkHandler;
|
||||
import cpw.mods.fml.common.IPickupNotifier;
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
|
||||
public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDispenseHandler, ICraftingHandler, INetworkHandler
|
||||
public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDispenseHandler, ICraftingHandler, INetworkHandler, IConsoleHandler
|
||||
{
|
||||
// CALLBACK MECHANISMS
|
||||
@Override
|
||||
|
@ -82,6 +83,20 @@ public abstract class BaseMod implements IWorldGenerator, IPickupNotifier, IDisp
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean handleCommand(String command)
|
||||
{
|
||||
return onServerCommand(command);
|
||||
}
|
||||
/**
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
private boolean onServerCommand(String command)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// BASEMOD API
|
||||
/**
|
||||
* Override if you wish to provide a fuel item for the furnace and return the fuel value of the item
|
||||
|
|
Loading…
Reference in a new issue