use of net.minecraft.server.MinecraftServer in project NewHorizonsCoreMod by GTNewHorizons.
the class CustomToolTipsCommand 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 NewHorizonsCoreMod by GTNewHorizons.
the class HazardousItemsCommand method canCommandSenderUseCommand.
/*
private void ProcessRemoveItemCommand(EntityPlayer pPlayer, ItemStack pInHand, String[] pArgs)
{
boolean bFlag = false;
if (pArgs.length == 2)
{
String pSecondArg = pArgs[1];
if (pSecondArg.equalsIgnoreCase("all")) bFlag = true;
}
if (!MainRegistry.Module_HazardousItems.RemoveItemFromList(pInHand,bFlag))
{
PlayerChatHelper.SendWarn(pPlayer, "Nothing removed. Either there was no such item,");
PlayerChatHelper.SendWarn(pPlayer, "or an error occurred");
} else
PlayerChatHelper.SendInfo(pPlayer, "Item(s) removed. Don't forget to save");
}
private void ProcessAddDamageEffectCommand(EntityPlayer pPlayer, ItemStack pInHand, String[] pArgs)
{
try
{
String tDmgSource = pArgs[1];
float tDmgAmount = Float.parseFloat(pArgs[2]);
if (!DamageTypeHelper.IsValidDamageSource(tDmgSource))
PlayerChatHelper.SendError(pPlayer, "This damagesource is invalid");
else
{
if (MainRegistry.Module_HazardousItems.AddDamageEffectToItem(pInHand, tDmgSource, tDmgAmount))
PlayerChatHelper.SendInfo(pPlayer, "Effect added to item. Don't forget to save");
else
PlayerChatHelper.SendError(pPlayer, "Unable to add item. Please check your logfile");
}
} catch (Exception e)
{
PlayerChatHelper.SendError(pPlayer,
"Error in your command. Check your syntax");
}
}
private void ProcessAddPotionEffectCommand(EntityPlayer pPlayer, ItemStack pInHand, String[] pArgs)
{
try
{
int tPotionID = Integer.parseInt(pArgs[1]);
int tTickDuration = Integer.parseInt(pArgs[2]);
int tLevel = Integer.parseInt(pArgs[3]);
if (!PotionHelper.IsValidPotionID(tPotionID)) PlayerChatHelper
.SendError(pPlayer, "This potion ID is invalid");
else
{
if (MainRegistry.Module_HazardousItems.AddPotionEffectToItem(pInHand, tPotionID, tTickDuration, tLevel))
PlayerChatHelper.SendInfo(pPlayer, "Effect added to item. Don't forget to save");
else
PlayerChatHelper.SendError(pPlayer, "Unable to add item. Please check your logfile");
}
} catch (Exception e)
{
PlayerChatHelper.SendError(pPlayer, "Error in your command. Check your syntax");
}
}
*/
/*
* Make sure only an op/admin can execute this command
*/
@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 RecurrentComplex by Ivorforce.
the class CommandSanity method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
RCParameters parameters = RCParameters.of(args, "silent", "short");
boolean sane = true;
if (StructureRegistry.INSTANCE.ids().isEmpty()) {
commandSender.sendMessage(new TextComponentString("No registered structures!"));
sane = false;
}
if (!Files.isReadable(ResourceDirectory.getCustomDirectory().toPath())) {
commandSender.sendMessage(new TextComponentString("Can't read files from custom directory"));
sane = false;
}
for (ModContainer mod : Loader.instance().getModList()) {
String domain = mod.getModId();
Path path = null;
try {
path = RCFiles.pathFromResourceLocation(new ResourceLocation(domain.toLowerCase(), ""));
} catch (RCFiles.ResourceLocationLoadException e) {
RecurrentComplex.logger.error(e);
commandSender.sendMessage(new TextComponentString("Error reading files from mod " + mod.getModId() + ": "));
commandSender.sendMessage(new TextComponentString(RCCommands.reason(e)));
sane = false;
}
if (path != null && !Files.isReadable(path)) {
commandSender.sendMessage(new TextComponentString("Can't read files from mod: " + mod.getModId()));
sane = false;
}
}
if (!Files.isReadable(ResourceDirectory.getServerDirectory().toPath())) {
commandSender.sendMessage(new TextComponentString("Can't read files from server directory"));
sane = false;
}
if (!parameters.has("short")) {
sane &= addStructureLog(commandSender, (s, structure) -> !structure.generationTypes(GenerationType.class).isEmpty(), "Missing generation type");
sane &= addGenerationLog(commandSender, NaturalGeneration.class, (structure, gen) -> values(Biome.REGISTRY).anyMatch(b -> StructureSelector.generationWeightInBiome(gen.biomeWeights, b) > 0), "Natural generation type won't accept any known biomes");
sane &= addGenerationLog(commandSender, NaturalGeneration.class, (structure, gen) -> dimensions(server).anyMatch(d -> StructureSelector.generationWeightInDimension(gen.dimensionWeights, d.provider) > 0), "Natural generation type won't accept any known dimensions");
sane &= addGenerationLog(commandSender, NaturalGeneration.class, (structure, gen) -> gen.getActiveGenerationWeight() > 0, "Natural generation type has no weight");
sane &= addGenerationLog(commandSender, VanillaGeneration.class, (structure, gen) -> values(Biome.REGISTRY).anyMatch(b -> gen.biomeExpression.test(b)), "Vanilla structure generation type won't accept any known biomes");
sane &= addGenerationLog(commandSender, VanillaGeneration.class, (structure, gen) -> gen.getActiveWeight() > 0, "Vanilla structure generation type has no weight");
sane &= addGenerationLog(commandSender, VanillaGeneration.class, (structure, gen) -> gen.minBaseLimit > 0 || gen.maxBaseLimit > 0 || gen.maxScaledLimit > 0 || gen.minScaledLimit > 0, "Vanilla structure is always limited to zero instances");
sane &= addGenerationLog(commandSender, VanillaDecorationGeneration.class, (structure, gen) -> values(Biome.REGISTRY).anyMatch(b -> StructureSelector.generationWeightInBiome(gen.biomeWeights, b) > 0), "Vanilla structure generation type won't accept any known biomes");
sane &= addGenerationLog(commandSender, VanillaDecorationGeneration.class, (structure, gen) -> dimensions(server).anyMatch(d -> StructureSelector.generationWeightInDimension(gen.dimensionWeights, d.provider) > 0), "Natural generation type won't accept any dimensions");
sane &= addGenerationLog(commandSender, MazeGeneration.class, (structure, gen) -> gen.getWeight() > 0, "Maze generation type has no weight");
sane &= addGenerationLog(commandSender, MazeGeneration.class, (structure, gen) -> !gen.getMazeID().trim().isEmpty(), "Maze generation type has maze id");
sane &= addGenerationLog(commandSender, MazeGeneration.class, (structure, gen) -> !gen.mazeComponent.rooms.isEmpty(), "Maze generation type has no rooms");
sane &= addGenerationLog(commandSender, MazeGeneration.class, (structure, gen) -> !gen.mazeComponent.exitPaths.isEmpty() || !gen.mazeComponent.defaultConnector.id.equals(ConnectorStrategy.DEFAULT_WALL), "Maze generation type has no walkable exits");
sane &= addGenerationLog(commandSender, ListGeneration.class, (structure, gen) -> !gen.listID.trim().isEmpty(), "List generation has no list id");
sane &= addGenerationLog(commandSender, ListGeneration.class, (structure, gen) -> gen.getWeight() > 0, "List generation has no weight");
sane &= addGenerationLog(commandSender, SaplingGeneration.class, (structure, gen) -> gen.getActiveWeight() > 0, "Sapling generation has no weight");
sane &= addGenerationLog(commandSender, StaticGeneration.class, (structure, gen) -> dimensions(server).anyMatch(d -> gen.dimensionExpression.test(d.provider)), "Static generation won't accept any known dimensions");
}
if (sane && !parameters.has("silent"))
commandSender.sendMessage(new TextComponentString("No specific problems found!"));
}
use of net.minecraft.server.MinecraftServer in project RecurrentComplex by Ivorforce.
the class SpawnCommandLogic method trigger.
public void trigger(World worldIn) {
if (!worldIn.isRemote) {
MinecraftServer minecraftserver = this.getServer();
if (minecraftserver != null && minecraftserver.isAnvilFileSet() && minecraftserver.isCommandBlockEnabled()) {
ICommandManager icommandmanager = minecraftserver.getCommandManager();
ICommandListener cachedAdmin = null;
if (!RCConfig.notifyAdminOnBlockCommands) {
cachedAdmin = RCAccessorCommandBase.getCommandAdmin();
CommandBase.setCommandListener(null);
}
try {
icommandmanager.executeCommand(this, this.commandStored);
} catch (Exception ex) {
CrashReport crashreport = CrashReport.makeCrashReport(ex, "Executing command block");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Command to be executed");
crashreportcategory.addDetail("Command", this::getCommand);
crashreportcategory.addDetail("Name", this::getName);
throw new ReportedException(crashreport);
}
if (!RCConfig.notifyAdminOnBlockCommands)
CommandBase.setCommandListener(cachedAdmin);
}
}
}
use of net.minecraft.server.MinecraftServer in project VanillaTeleporter by dyeo.
the class TeleporterUtility method transferEntityToDimension.
/**
* Transfers an entity to a different dimension and location, as if it was being teleported by a dimension portal
*/
private static boolean transferEntityToDimension(Entity entity, double x, double y, double z, float yaw, float pitch, int dimension) {
MinecraftServer minecraftServer = FMLCommonHandler.instance().getMinecraftServerInstance();
WorldServer srcWorld = minecraftServer.worldServerForDimension(entity.dimension);
WorldServer dstWorld = minecraftServer.worldServerForDimension(dimension);
if (dstWorld != null) {
NBTTagCompound nbttagcompound = entity.writeToNBT(new NBTTagCompound());
nbttagcompound.removeTag("Dimension");
srcWorld.removeEntity(entity);
Entity newEntity = EntityList.newEntity(entity.getClass(), dstWorld);
newEntity.readFromNBT(nbttagcompound);
setEntityPosition(newEntity, x, y, z, yaw, pitch);
dstWorld.spawnEntity(newEntity);
dstWorld.updateEntityWithOptionalForce(newEntity, false);
return true;
} else {
return false;
}
}
Aggregations