Updated commands
This commit is contained in:
parent
29216ee9c2
commit
d8b98c433c
4 changed files with 167 additions and 172 deletions
|
@ -3,7 +3,11 @@ package cr0s.warpdrive.command;
|
|||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import com.sun.media.jfxmedia.logging.Logger;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.WarpDriveConfig;
|
||||
|
@ -12,89 +16,82 @@ import cr0s.warpdrive.world.WorldGenSmallShip;
|
|||
import cr0s.warpdrive.world.WorldGenStation;
|
||||
|
||||
/*
|
||||
* /generate <structure>
|
||||
* Possible structures:
|
||||
* moon, ship, asteroid, astfield, gascloud, star
|
||||
*/
|
||||
* /generate <structure>
|
||||
* Possible structures:
|
||||
* moon, ship, asteroid, astfield, gascloud, star
|
||||
*/
|
||||
|
||||
public class GenerateCommand extends CommandBase
|
||||
{
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "generate";
|
||||
}
|
||||
public class GenerateCommand extends CommandBase {
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "generate";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
@Override
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender par1ICommandSender)
|
||||
{
|
||||
return "/" + getCommandName() + " <structure>\nPossible structures: moon, ship, asteroid, astfield, gascloud, star <class>, jumpgate <name>";
|
||||
}
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender par1ICommandSender) {
|
||||
return "/" + getCommandName() + " <structure>\nPossible structures: moon, ship, asteroid, astfield, gascloud, star <class>, jumpgate <name>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender icommandsender, String[] params)
|
||||
{
|
||||
EntityPlayerMP player = (EntityPlayerMP)icommandsender;
|
||||
if(params.length > 0)
|
||||
{
|
||||
String struct = params[0];
|
||||
|
||||
// Reject command, if player is not in space
|
||||
if (player.dimension != WarpDriveConfig.G_SPACE_DIMENSION_ID && (!"ship".equals(struct)))
|
||||
{
|
||||
player.addChatMessage("* generate: this structure is only allowed in space!");
|
||||
return;
|
||||
}
|
||||
|
||||
int x = MathHelper.floor_double(player.posX);
|
||||
int y = MathHelper.floor_double(player.posY);
|
||||
int z = MathHelper.floor_double(player.posZ);
|
||||
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
|
||||
if (struct.equals("moon")) {
|
||||
notifyAdmins(icommandsender, "/generate: generating moon at " + x + ", " + (y - 16) + ", " + z, new Object[0]);
|
||||
WarpDrive.instance.spaceWorldGenerator.generateMoon(player.worldObj, x, y - 16, z);
|
||||
} else if (struct.equals("ship")) {
|
||||
notifyAdmins(icommandsender, "/generate: generating NPC ship at " + x + ", " + y + ", " + z, new Object[0]);
|
||||
new WorldGenSmallShip(false).generate(player.worldObj, player.worldObj.rand, x, y, z);
|
||||
} else if (struct.equals("station")) {
|
||||
notifyAdmins(icommandsender, "/generate: generating station at " + x + ", " + y + ", " + z, new Object[0]);
|
||||
new WorldGenStation(false).generate(player.worldObj, player.worldObj.rand, x, y, z);
|
||||
} else if (struct.equals("asteroid")) {
|
||||
notifyAdmins(icommandsender, "/generate: generating asteroid at " + x + ", " + (y - 10) + ", " + z, new Object[0]);
|
||||
WarpDrive.instance.spaceWorldGenerator.generateRandomAsteroid(player.worldObj, x, y - 10, z, 6, 11);
|
||||
} else if (struct.equals("astfield")) {
|
||||
notifyAdmins(icommandsender, "/generate: generating asteroid field at " + x + ", " + y + ", " + z, new Object[0]);
|
||||
WarpDrive.instance.spaceWorldGenerator.generateAsteroidField(player.worldObj, x, y, z);
|
||||
} else if (struct.equals("gascloud")) {
|
||||
notifyAdmins(icommandsender, "/generate: generating gas cloud at " + x + ", " + y + ", " + z, new Object[0]);
|
||||
WarpDrive.instance.spaceWorldGenerator.generateGasCloudOfColor(player.worldObj, x, y, z, 15, 20, player.worldObj.rand.nextInt(12));
|
||||
} else if (struct.equals("star")) {
|
||||
notifyAdmins(icommandsender, "/generate: generating star at " + x + ", " + y + ", " + z, new Object[0]);
|
||||
Integer type = (params.length > 1) ? Integer.parseInt(params[1]) : -1; // Lem
|
||||
WarpDrive.instance.spaceWorldGenerator.generateStar(player.worldObj, x, y, z, type); // Lem
|
||||
} else if (struct.equals("jumpgate")) {
|
||||
if (params.length == 2) {
|
||||
notifyAdmins(icommandsender, "/generate: creating jumpgate at " + x + ", " + y + ", " + z, new Object[0]);
|
||||
|
||||
if (WarpDrive.jumpgates.addGate(params[1], x, y, z)) {
|
||||
JumpgateGenerator.generate(player.worldObj, x, Math.min(y,255-JumpgateGenerator.GATE_SIZE_HALF - 1), z);
|
||||
} else {
|
||||
notifyAdmins(icommandsender, "/generate: jumpgate '" + params[1] + "' already exists.", new Object[0]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.addChatMessage(getCommandUsage(icommandsender));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.addChatMessage(getCommandUsage(icommandsender));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void processCommand(ICommandSender icommandsender, String[] params) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) icommandsender;
|
||||
if (params.length > 0) {
|
||||
String struct = params[0];
|
||||
|
||||
// Reject command, if player is not in space
|
||||
if (player.dimension != WarpDriveConfig.G_SPACE_DIMENSION_ID && (!"ship".equals(struct))) {
|
||||
player.addChatMessage(new ChatComponentText("* generate: this structure is only allowed in space!"));
|
||||
return;
|
||||
}
|
||||
|
||||
int x = MathHelper.floor_double(player.posX);
|
||||
int y = MathHelper.floor_double(player.posY);
|
||||
int z = MathHelper.floor_double(player.posZ);
|
||||
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
|
||||
if (struct.equals("moon")) {
|
||||
Logger.logMsg(Logger.INFO, "/generate: generating moon at " + x + ", " + (y - 16) + ", " + z);
|
||||
WarpDrive.instance.spaceWorldGenerator.generateMoon(player.worldObj, x, y - 16, z);
|
||||
} else if (struct.equals("ship")) {
|
||||
Logger.logMsg(Logger.INFO, "/generate: generating NPC ship at " + x + ", " + y + ", " + z);
|
||||
new WorldGenSmallShip(false).generate(player.worldObj, player.worldObj.rand, x, y, z);
|
||||
} else if (struct.equals("station")) {
|
||||
Logger.logMsg(Logger.INFO, "/generate: generating station at " + x + ", " + y + ", " + z);
|
||||
new WorldGenStation(false).generate(player.worldObj, player.worldObj.rand, x, y, z);
|
||||
} else if (struct.equals("asteroid")) {
|
||||
Logger.logMsg(Logger.INFO, "/generate: generating asteroid at " + x + ", " + (y - 10) + ", " + z);
|
||||
WarpDrive.instance.spaceWorldGenerator.generateRandomAsteroid(player.worldObj, x, y - 10, z, 6, 11);
|
||||
} else if (struct.equals("astfield")) {
|
||||
Logger.logMsg(Logger.INFO, "/generate: generating asteroid field at " + x + ", " + y + ", " + z);
|
||||
WarpDrive.instance.spaceWorldGenerator.generateAsteroidField(player.worldObj, x, y, z);
|
||||
} else if (struct.equals("gascloud")) {
|
||||
Logger.logMsg(Logger.INFO, "/generate: generating gas cloud at " + x + ", " + y + ", " + z);
|
||||
WarpDrive.instance.spaceWorldGenerator.generateGasCloudOfColor(player.worldObj, x, y, z, 15, 20, player.worldObj.rand.nextInt(12));
|
||||
} else if (struct.equals("star")) {
|
||||
Logger.logMsg(Logger.INFO, "/generate: generating star at " + x + ", " + y + ", " + z);
|
||||
Integer type = (params.length > 1) ? Integer.parseInt(params[1]) : -1; // Lem
|
||||
WarpDrive.instance.spaceWorldGenerator.generateStar(player.worldObj, x, y, z, type); // Lem
|
||||
} else if (struct.equals("jumpgate")) {
|
||||
if (params.length == 2) {
|
||||
Logger.logMsg(Logger.INFO, "/generate: creating jumpgate at " + x + ", " + y + ", " + z);
|
||||
|
||||
if (WarpDrive.jumpgates.addGate(params[1], x, y, z)) {
|
||||
JumpgateGenerator.generate(player.worldObj, x, Math.min(y, 255 - JumpgateGenerator.GATE_SIZE_HALF - 1), z);
|
||||
} else {
|
||||
Logger.logMsg(Logger.INFO, "/generate: jumpgate '" + params[1] + "' already exists.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.addChatMessage(new ChatComponentText(getCommandUsage(icommandsender)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
player.addChatMessage(new ChatComponentText(getCommandUsage(icommandsender)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,45 +3,41 @@ package cr0s.warpdrive.command;
|
|||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class InvisibleCommand extends CommandBase
|
||||
{
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
import com.sun.media.jfxmedia.logging.Logger;
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "invisible";
|
||||
}
|
||||
public class InvisibleCommand extends CommandBase {
|
||||
@Override
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender icommandsender, String[] astring)
|
||||
{
|
||||
EntityPlayerMP player = (EntityPlayerMP)icommandsender;
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "invisible";
|
||||
}
|
||||
|
||||
if (astring.length >= 1)
|
||||
{
|
||||
notifyAdmins(icommandsender, "/invisible: setting invisible to " + astring[0], new Object[0]);
|
||||
player = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(astring[0]);
|
||||
}
|
||||
@Override
|
||||
public void processCommand(ICommandSender icommandsender, String[] astring) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) icommandsender;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (astring.length >= 1) {
|
||||
Logger.logMsg(Logger.INFO, "/invisible: setting invisible to " + astring[0]);
|
||||
// player =
|
||||
// MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(astring[0]);
|
||||
// TODO: Fix
|
||||
}
|
||||
|
||||
// Toggle invisibility
|
||||
player.setInvisible(!player.isInvisible());
|
||||
}
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender)
|
||||
{
|
||||
return "/invisible [player]";
|
||||
}
|
||||
// Toggle invisibility
|
||||
player.setInvisible(!player.isInvisible());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender) {
|
||||
return "/invisible [player]";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,32 +3,28 @@ package cr0s.warpdrive.command;
|
|||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import cr0s.warpdrive.WarpDrive;
|
||||
|
||||
public class JumpgateCommand extends CommandBase
|
||||
{
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "jumpgates";
|
||||
}
|
||||
public class JumpgateCommand extends CommandBase {
|
||||
@Override
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender)
|
||||
{
|
||||
public String getCommandName() {
|
||||
return "jumpgates";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender) {
|
||||
return "Lists jumpgates";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender icommandsender, String[] astring)
|
||||
{
|
||||
EntityPlayerMP player = (EntityPlayerMP)icommandsender;
|
||||
player.addChatMessage(WarpDrive.jumpgates.commaList());
|
||||
public void processCommand(ICommandSender icommandsender, String[] astring) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) icommandsender;
|
||||
player.addChatMessage(new ChatComponentText(WarpDrive.jumpgates.commaList()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,52 +6,58 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
|||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import com.sun.media.jfxmedia.logging.Logger;
|
||||
|
||||
import cr0s.warpdrive.WarpDriveConfig;
|
||||
import cr0s.warpdrive.world.SpaceTeleporter;
|
||||
|
||||
public class SpaceTpCommand extends CommandBase {
|
||||
@Override
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
@Override
|
||||
public int getRequiredPermissionLevel() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "space";
|
||||
}
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "space";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender icommandsender, String[] astring) {
|
||||
EntityPlayerMP player = null;
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
int targetDim = WarpDriveConfig.G_SPACE_DIMENSION_ID;
|
||||
@Override
|
||||
public void processCommand(ICommandSender icommandsender, String[] astring) {
|
||||
EntityPlayerMP player = null;
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
int targetDim = WarpDriveConfig.G_SPACE_DIMENSION_ID;
|
||||
|
||||
if (icommandsender != null && icommandsender instanceof EntityPlayerMP) {
|
||||
player = (EntityPlayerMP)icommandsender;
|
||||
}
|
||||
if (astring.length >= 1) {
|
||||
if ("hyper".equals(astring[0])) {
|
||||
targetDim = WarpDriveConfig.G_HYPERSPACE_DIMENSION_ID;
|
||||
} else if ("overworld".equals(astring[0])) {
|
||||
targetDim = 0;
|
||||
} else {
|
||||
player = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(astring[0]);
|
||||
}
|
||||
}
|
||||
if (icommandsender != null && icommandsender instanceof EntityPlayerMP) {
|
||||
player = (EntityPlayerMP) icommandsender;
|
||||
}
|
||||
if (astring.length >= 1) {
|
||||
if ("hyper".equals(astring[0])) {
|
||||
targetDim = WarpDriveConfig.G_HYPERSPACE_DIMENSION_ID;
|
||||
} else if ("overworld".equals(astring[0])) {
|
||||
targetDim = 0;
|
||||
} else { // TODO: Fix
|
||||
// player =
|
||||
// MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(astring[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (player == null) {
|
||||
notifyAdmins(icommandsender, "/space: undefined player");
|
||||
return;
|
||||
}
|
||||
if (player == null) {
|
||||
Logger.logMsg(Logger.INFO, "/space: undefined player");
|
||||
return;
|
||||
}
|
||||
|
||||
WorldServer targetWorld = server.worldServerForDimension(targetDim);
|
||||
notifyAdmins(icommandsender, "/space: teleporting player " + player.getDisplayName() + " to " + targetDim + ":" + targetWorld.getWorldInfo().getWorldName(), new Object[0]);
|
||||
SpaceTeleporter teleporter = new SpaceTeleporter(targetWorld, 0, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ));
|
||||
server.getConfigurationManager().transferPlayerToDimension(player, targetDim, teleporter);
|
||||
}
|
||||
WorldServer targetWorld = server.worldServerForDimension(targetDim);
|
||||
Logger.logMsg(Logger.INFO, "/space: teleporting player " + player.getDisplayName() + " to " + targetDim + ":"
|
||||
+ targetWorld.getWorldInfo().getWorldName());
|
||||
SpaceTeleporter teleporter = new SpaceTeleporter(targetWorld, 0, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY),
|
||||
MathHelper.floor_double(player.posZ));
|
||||
server.getConfigurationManager().transferPlayerToDimension(player, targetDim, teleporter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender) {
|
||||
return "/space [hyper|overworld|<player>]";
|
||||
}
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender) {
|
||||
return "/space [hyper|overworld|<player>]";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue