use of net.minecraft.server.MinecraftServer in project NewHorizonsCoreMod by GTNewHorizons.
the class CustomFuelsCommand method canCommandSenderUseCommand.
@Override
public boolean canCommandSenderUseCommand(ICommandSender pCommandSender) {
if (pCommandSender instanceof EntityPlayerMP) {
EntityPlayerMP tEP = (EntityPlayerMP) pCommandSender;
boolean tPlayerOpped = MinecraftServer.getServer().getConfigurationManager().func_152596_g(tEP.getGameProfile());
// && tIncreative;
return tPlayerOpped;
} else if (pCommandSender instanceof MinecraftServer)
return true;
else
return false;
}
use of net.minecraft.server.MinecraftServer in project Galacticraft by micdoodle8.
the class CommandGCHouston method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
EntityPlayerMP playerBase = null;
MinecraftServer server = MinecraftServer.getServer();
boolean isOp = false;
Entity entitySender = sender.getCommandSenderEntity();
if (entitySender == null) {
isOp = true;
} else if (entitySender instanceof EntityPlayer) {
GameProfile prof = ((EntityPlayer) entitySender).getGameProfile();
isOp = server.getConfigurationManager().canSendCommands(prof);
}
if (args.length < 2) {
try {
if (args.length == 0) {
playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), true);
if (!playerBase.capabilities.isCreativeMode) {
if (ConfigManagerCore.challengeMode || !(playerBase.worldObj.provider instanceof IGalacticraftWorldProvider)) {
CommandBase.notifyOperators(sender, this, "commands.gchouston.fail");
return;
}
}
if (timerList.contains(playerBase)) {
timerList.remove(playerBase);
} else {
timerList.add(playerBase);
TickHandlerServer.timerHoustonCommand = 250;
String msg = EnumColor.YELLOW + GCCoreUtil.translate("commands.gchouston.confirm.1") + " " + EnumColor.WHITE + GCCoreUtil.translate("commands.gchouston.confirm.2");
CommandBase.notifyOperators(sender, this, msg);
return;
}
} else {
if (!isOp) {
CommandBase.notifyOperators(sender, this, "commands.gchouston.noop");
return;
}
playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(args[0], true);
}
if (playerBase != null) {
int dimID = ConfigManagerCore.idDimensionOverworld;
WorldServer worldserver = server.worldServerForDimension(dimID);
if (worldserver == null) {
worldserver = server.worldServerForDimension(0);
if (worldserver == null) {
throw new Exception("/gchouston could not find Overworld.");
}
dimID = 0;
}
BlockPos spawnPoint = null;
BlockPos bedPos = playerBase.getBedLocation(dimID);
if (bedPos != null) {
spawnPoint = EntityPlayer.getBedSpawnLocation(worldserver, bedPos, false);
}
if (spawnPoint == null) {
spawnPoint = worldserver.getTopSolidOrLiquidBlock(worldserver.getSpawnPoint());
}
GCPlayerStats stats = GCPlayerStats.get(playerBase);
stats.setRocketStacks(new ItemStack[0]);
stats.setRocketType(IRocketType.EnumRocketType.DEFAULT.ordinal());
stats.setRocketItem(null);
stats.setFuelLevel(0);
stats.setCoordsTeleportedFromX(spawnPoint.getX());
stats.setCoordsTeleportedFromZ(spawnPoint.getZ());
stats.setUsingPlanetSelectionGui(false);
playerBase.closeScreen();
Vector3 spawnPos = new Vector3(spawnPoint.getX() + 0.5D, spawnPoint.getY() + 0.25D, spawnPoint.getZ() + 0.5D);
try {
WorldUtil.teleportEntitySimple(worldserver, dimID, playerBase, spawnPos);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
CommandBase.notifyOperators(sender, this, "commands.gchouston.success", new Object[] { String.valueOf(EnumColor.GREY + "" + playerBase.getName()) });
} else {
throw new Exception("Could not find player with name: " + args[0]);
}
} catch (final Exception var6) {
throw new CommandException(var6.getMessage(), new Object[0]);
}
} else {
throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.dimensiontp.too_many", this.getCommandUsage(sender)), new Object[0]);
}
}
use of net.minecraft.server.MinecraftServer in project Galacticraft by micdoodle8.
the class CommandPlanetTeleport method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
EntityPlayerMP playerBase = null;
if (args.length < 2) {
try {
if (args.length == 1) {
playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(args[0], true);
} else {
playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), true);
}
if (playerBase != null) {
MinecraftServer server = MinecraftServer.getServer();
WorldServer worldserver = server.worldServerForDimension(GCCoreUtil.getDimensionID(server.worldServers[0]));
BlockPos spawnPoint = worldserver.getSpawnPoint();
GCPlayerStats stats = GCPlayerStats.get(playerBase);
stats.setRocketStacks(new ItemStack[2]);
stats.setRocketType(IRocketType.EnumRocketType.DEFAULT.ordinal());
stats.setRocketItem(GCItems.rocketTier1);
stats.setFuelLevel(1000);
stats.setCoordsTeleportedFromX(spawnPoint.getX());
stats.setCoordsTeleportedFromZ(spawnPoint.getZ());
try {
WorldUtil.toCelestialSelection(playerBase, stats, Integer.MAX_VALUE);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
CommandBase.notifyOperators(sender, this, "commands.dimensionteleport", new Object[] { String.valueOf(EnumColor.GREY + "[" + playerBase.getName()), "]" });
} else {
throw new Exception("Could not find player with name: " + args[0]);
}
} catch (final Exception var6) {
throw new CommandException(var6.getMessage(), new Object[0]);
}
} else {
throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.dimensiontp.too_many", this.getCommandUsage(sender)), new Object[0]);
}
}
use of net.minecraft.server.MinecraftServer in project Galacticraft by micdoodle8.
the class CommandJoinSpaceRace method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
MinecraftServer server = MinecraftServer.getServer();
EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(server, sender.getName(), true);
if (args.length == 0) {
try {
if (playerBase != null) {
GCPlayerStats stats = GCPlayerStats.get(playerBase);
if (stats.getSpaceRaceInviteTeamID() > 0) {
SpaceRaceManager.sendSpaceRaceData(server, playerBase, SpaceRaceManager.getSpaceRaceFromID(stats.getSpaceRaceInviteTeamID()));
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_OPEN_JOIN_RACE_GUI, GCCoreUtil.getDimensionID(playerBase.worldObj), new Object[] { stats.getSpaceRaceInviteTeamID() }), playerBase);
} else {
throw new Exception("You haven't been invited to a space race team!");
}
} else {
throw new Exception("Could not find player with name: " + args[0]);
}
} catch (final Exception var6) {
throw new CommandException(var6.getMessage(), new Object[0]);
}
} else {
throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.joinrace.no_team", this.getCommandUsage(sender)), new Object[0]);
}
}
use of net.minecraft.server.MinecraftServer in project BuildCraft by BuildCraft.
the class SubCommandDeop method processSubCommand.
@Override
public void processSubCommand(ICommandSender sender, String[] args) throws CommandException {
MinecraftServer server = sender.getServer();
if (server == null) {
throw new CommandException("No server!");
} else {
server.getPlayerList().removeOp(BuildCraftCore.gameProfile);
CommandHelpers.sendLocalizedChatMessage(sender, "commands.deop.success", "[BuildCraft]");
}
}
Aggregations