Java Code Examples for net.minecraft.server.MinecraftServer

The following are top voted examples for showing how to use net.minecraft.server.MinecraftServer. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: DecompiledMinecraft   File: CommandDeOp.java   View source code 6 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length == 1 && args[0].length() > 0)
    {
        MinecraftServer minecraftserver = MinecraftServer.getServer();
        GameProfile gameprofile = minecraftserver.getConfigurationManager().getOppedPlayers().getGameProfileFromName(args[0]);

        if (gameprofile == null)
        {
            throw new CommandException("commands.deop.failed", new Object[] {args[0]});
        }
        else
        {
            minecraftserver.getConfigurationManager().removeOp(gameprofile);
            notifyOperators(sender, this, "commands.deop.success", new Object[] {args[0]});
        }
    }
    else
    {
        throw new WrongUsageException("commands.deop.usage", new Object[0]);
    }
}
 
Example 2
Project: FullwidthPunctuationFix   File: CommandDumpGlyphWidth.java   View source code 6 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    new Thread(() -> {
        try {
            byte[] dataToDump = FullwidthPunctuationFix.INSTANCE.getCharWidthData();
            File dest = new File(Minecraft.getMinecraft().getResourcePackRepository().getDirResourcepacks(), "autogen_glyph_width");
            if (!dest.exists() || !dest.isDirectory()) {
                dest.mkdir();
            }
            File dumpTargetDir = new File(dest, "assets/minecraft/font");
            if (!dumpTargetDir.exists() || !dumpTargetDir.isDirectory()) {
                dumpTargetDir.mkdirs();
            }
            File dumpTarget = new File(dumpTargetDir, "glyph_sizes.bin");
            FileUtils.writeByteArrayToFile(dumpTarget, dataToDump, false);
            File packMeta = new File(dest, "pack.mcmeta");
            FileUtils.writeStringToFile(packMeta, "{ \"pack\": { \"pack_format\": 2, \"description\": \"Auto-generated glyph width data\" } }", "UTF-8", false);
            sender.addChatMessage(new TextComponentTranslation("command.fwpf.dump.success"));
        } catch (Exception e) {
            sender.addChatMessage(new TextComponentTranslation("command.fwpf.dump.fail"));
        }
    }, "GlyphWidthDataExporter").start();
}
 
Example 3
Project: CustomWorldGen   File: CommandScoreboard.java   View source code 6 votes vote down vote up
protected void enablePlayerTrigger(ICommandSender sender, String[] p_184914_2_, int p_184914_3_, MinecraftServer server) throws CommandException
{
    Scoreboard scoreboard = this.getScoreboard(server);
    String s = getPlayerName(server, sender, p_184914_2_[p_184914_3_++]);

    if (s.length() > 40)
    {
        throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
    }
    else
    {
        ScoreObjective scoreobjective = this.convertToObjective(p_184914_2_[p_184914_3_], false, server);

        if (scoreobjective.getCriteria() != IScoreCriteria.TRIGGER)
        {
            throw new CommandException("commands.scoreboard.players.enable.noTrigger", new Object[] {scoreobjective.getName()});
        }
        else
        {
            Score score = scoreboard.getOrCreateScore(s, scoreobjective);
            score.setLocked(false);
            notifyCommandListener(sender, this, "commands.scoreboard.players.enable.success", new Object[] {scoreobjective.getName(), s});
        }
    }
}
 
Example 4
Project: BaseClient   File: ChatComponentScore.java   View source code 6 votes vote down vote up
/**
 * Gets the text of this component, without any special formatting codes added, for chat.  TODO: why is this two
 * different methods?
 */
public String getUnformattedTextForChat()
{
    MinecraftServer minecraftserver = MinecraftServer.getServer();

    if (minecraftserver != null && minecraftserver.isAnvilFileSet() && StringUtils.isNullOrEmpty(this.value))
    {
        Scoreboard scoreboard = minecraftserver.worldServerForDimension(0).getScoreboard();
        ScoreObjective scoreobjective = scoreboard.getObjective(this.objective);

        if (scoreboard.entityHasObjective(this.name, scoreobjective))
        {
            Score score = scoreboard.getValueFromObjective(this.name, scoreobjective);
            this.setValue(String.format("%d", new Object[] {Integer.valueOf(score.getScorePoints())}));
        }
        else
        {
            this.value = "";
        }
    }

    return this.value;
}
 
Example 5
Project: Halloween   File: CommandCurse.java   View source code 6 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
	World world = sender.getEntityWorld();
	if (!world.isRemote && args.length > 0)
	{
		EntityPlayer player = this.getCommandSenderAsPlayer(sender);
		EntityCurse curse = null;

		EnumCurseType curseType = EnumCurseType.byName(args[0]);
		switch(curseType)
		{
			case CREEPER: curse = new EntityCreeperCurse(world, player); break;
			case GHAST: curse = new EntityGhastCurse(world, player); break;
			case SKELETON: curse = new EntitySkeletonCurse(world, player); break;
			case SLIME: curse = new EntitySlimeCurse(world, player); break;
			case SPIDER: curse = new EntitySpiderCurse(world, player); break;
			case ZOMBIE: curse = new EntityZombieCurse(world, player); break;
		}
		world.spawnEntity(curse);
	}
}
 
Example 6
Project: BaseClient   File: CommandAchievement.java   View source code 6 votes vote down vote up
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
    if (args.length == 1)
    {
        return getListOfStringsMatchingLastWord(args, new String[] {"give", "take"});
    }
    else if (args.length != 2)
    {
        return args.length == 3 ? getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getAllUsernames()) : null;
    }
    else
    {
        List<String> list = Lists.<String>newArrayList();

        for (StatBase statbase : StatList.allStats)
        {
            list.add(statbase.statId);
        }

        return getListOfStringsMatchingLastWord(args, list);
    }
}
 
Example 7
Project: BaseClient   File: CommandWhitelist.java   View source code 6 votes vote down vote up
public List<String> addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos)
{
    if (args.length == 1)
    {
        return getListOfStringsMatchingLastWord(args, new String[] {"on", "off", "list", "add", "remove", "reload"});
    }
    else
    {
        if (args.length == 2)
        {
            if (args[0].equals("remove"))
            {
                return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getConfigurationManager().getWhitelistedPlayerNames());
            }

            if (args[0].equals("add"))
            {
                return getListOfStringsMatchingLastWord(args, MinecraftServer.getServer().getPlayerProfileCache().getUsernames());
            }
        }

        return null;
    }
}
 
Example 8
Project: Proyecto-DASI   File: FileWorldGeneratorImplementation.java   View source code 6 votes vote down vote up
@Override
public boolean shouldCreateWorld(MissionInit missionInit)
{
    if (this.fwparams != null && this.fwparams.isForceReset())
        return true;

    World world = null;
    MinecraftServer server = MinecraftServer.getServer();
    if (server.worldServers != null && server.worldServers.length != 0)
        world = server.getEntityWorld();

    if (world == null)
        return true;   // There is no world, so we definitely need to create one.

    String name = (world != null) ? world.getWorldInfo().getWorldName() : "";
    // Extract the name from the path (need to cope with backslashes or forward slashes.)
    String mapfile = (this.mapFilename == null) ? "" : this.mapFilename;    // Makes no sense to have an empty filename, but createWorld will deal with it graciously.
    String[] parts = mapfile.split("[\\\\/]");
    if (name.length() > 0 && parts[parts.length - 1].equalsIgnoreCase(name) && Minecraft.getMinecraft().theWorld != null)
        return false;	// We don't check whether the game modes match - it's up to the server state machine to sort that out.

    return true;	// There's no world, or the world is different to the basemap file, so create.
}
 
Example 9
Project: DecompiledMinecraft   File: RConThreadQuery.java   View source code 6 votes vote down vote up
/**
 * Removes all clients whose auth is no longer valid
 */
private void cleanQueryClientsMap()
{
    if (this.running)
    {
        long i = MinecraftServer.getCurrentTimeMillis();

        if (i >= this.lastAuthCheckTime + 30000L)
        {
            this.lastAuthCheckTime = i;
            Iterator<Entry<SocketAddress, RConThreadQuery.Auth>> iterator = this.queryClients.entrySet().iterator();

            while (iterator.hasNext())
            {
                Entry<SocketAddress, RConThreadQuery.Auth> entry = (Entry)iterator.next();

                if (((RConThreadQuery.Auth)entry.getValue()).hasExpired(i).booleanValue())
                {
                    iterator.remove();
                }
            }
        }
    }
}
 
Example 10
Project: DecompiledMinecraft   File: StatsComponent.java   View source code 6 votes vote down vote up
public StatsComponent(MinecraftServer p_i2367_1_)
{
    this.field_120037_e = p_i2367_1_;
    this.setPreferredSize(new Dimension(456, 246));
    this.setMinimumSize(new Dimension(456, 246));
    this.setMaximumSize(new Dimension(456, 246));
    (new Timer(500, new ActionListener()
    {
        public void actionPerformed(ActionEvent p_actionPerformed_1_)
        {
            StatsComponent.this.func_120034_a();
        }
    })).start();
    this.setBackground(Color.BLACK);
}
 
Example 11
Project: craftsman   File: AbstractCircle.java   View source code 6 votes vote down vote up
@Override
public void doCommand(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {        
    FstPlayer player = new FstPlayer(sender);
    
    player.runIfAirOrBlockHeld(() -> {
        Map<String, Integer> argsInt = argsToInteger(copyArgs(args, 1), 
                "ux", "uy", "uz", "radius");
        
        FstPos center = new FstPos(
                argsInt.get("ux"),
                argsInt.get("uy"),
                argsInt.get("uz")
            );
        
        if("vt".equals(args[0])) {
            buildVerticalCircle(player, center, argsInt.get("radius"));
        } else {
            buildHorizontalCircle(player, center, argsInt.get("radius"));
        }
    });
}
 
Example 12
Project: CreeperHostGui   File: CommandInvite.java   View source code 6 votes vote down vote up
@Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos)
{
    if (args.length == 1)
    {
        return getListOfStringsMatchingLastWord(args, new String[]{"list", "add", "remove", "reload"});
    }
    else
    {
        if (args.length == 2)
        {
            if ("remove".equals(args[0]))
            {
                return getListOfStringsMatchingLastWord(args, server.getPlayerList().getWhitelistedPlayerNames());
            }

            if ("add".equals(args[0]))
            {
                return getListOfStringsMatchingLastWord(args, server.getPlayerProfileCache().getUsernames());
            }
        }

        return Collections.emptyList();
    }
}
 
Example 13
Project: DecompiledMinecraft   File: PreYggdrasilConverter.java   View source code 6 votes vote down vote up
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
    String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
    {
        public boolean apply(String p_apply_1_)
        {
            return !StringUtils.isNullOrEmpty(p_apply_1_);
        }
    }), String.class);

    if (server.isServerInOnlineMode())
    {
        server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
    }
    else
    {
        for (String s : astring)
        {
            UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
            GameProfile gameprofile = new GameProfile(uuid, s);
            callback.onProfileLookupSucceeded(gameprofile);
        }
    }
}
 
Example 14
Project: DecompiledMinecraft   File: CommandSetDefaultSpawnpoint.java   View source code 6 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    BlockPos blockpos;

    if (args.length == 0)
    {
        blockpos = getCommandSenderAsPlayer(sender).getPosition();
    }
    else
    {
        if (args.length != 3 || sender.getEntityWorld() == null)
        {
            throw new WrongUsageException("commands.setworldspawn.usage", new Object[0]);
        }

        blockpos = parseBlockPos(sender, args, 0, true);
    }

    sender.getEntityWorld().setSpawnPoint(blockpos);
    MinecraftServer.getServer().getConfigurationManager().sendPacketToAllPlayers(new S05PacketSpawnPosition(blockpos));
    notifyOperators(sender, this, "commands.setworldspawn.success", new Object[] {Integer.valueOf(blockpos.getX()), Integer.valueOf(blockpos.getY()), Integer.valueOf(blockpos.getZ())});
}
 
Example 15
Project: DecompiledMinecraft   File: CommandDeOp.java   View source code 6 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length == 1 && args[0].length() > 0)
    {
        MinecraftServer minecraftserver = MinecraftServer.getServer();
        GameProfile gameprofile = minecraftserver.getConfigurationManager().getOppedPlayers().getGameProfileFromName(args[0]);

        if (gameprofile == null)
        {
            throw new CommandException("commands.deop.failed", new Object[] {args[0]});
        }
        else
        {
            minecraftserver.getConfigurationManager().removeOp(gameprofile);
            notifyOperators(sender, this, "commands.deop.success", new Object[] {args[0]});
        }
    }
    else
    {
        throw new WrongUsageException("commands.deop.usage", new Object[0]);
    }
}
 
Example 16
Project: World-Border   File: WBCommand.java   View source code 6 votes vote down vote up
@Override
public boolean checkPermission(MinecraftServer server, ICommandSender sender) {
    if (sender instanceof DedicatedServer)
        return true;

    EntityPlayerMP   player  = (EntityPlayerMP) sender;
    GameProfile      profile = player.getGameProfile();
    UserListOpsEntry opEntry = (UserListOpsEntry) WorldBorder.SERVER
        .getPlayerList()
        .getOppedPlayers()
        .getEntry(profile);

    // Level 2 (out of 4) have general access to game-changing commands
    // TODO: Make this a configuration option
    return opEntry != null && opEntry.getPermissionLevel() > 2;
}
 
Example 17
Project: Proyecto-DASI   File: DefaultWorldGeneratorImplementation.java   View source code 6 votes vote down vote up
@Override
public boolean shouldCreateWorld(MissionInit missionInit)
{
    if (this.dwparams != null && this.dwparams.isForceReset())
        return true;
    
	World world = null;
	MinecraftServer server = MinecraftServer.getServer();
	if (server.worldServers != null && server.worldServers.length != 0)
		world = server.getEntityWorld();

	if (Minecraft.getMinecraft().theWorld == null || world == null)
        return true;    // Definitely need to create a world if there isn't one in existence!

    String genOptions = world.getWorldInfo().getGeneratorOptions();
    if (genOptions != null && !genOptions.isEmpty())
    	return true;	// Default world has no generator options.

    return false;
}
 
Example 18
Project: CustomWorldGen   File: ItemMonsterPlacer.java   View source code 6 votes vote down vote up
/**
 * Applies the data in the EntityTag tag of the given ItemStack to the given Entity.
 */
public static void applyItemEntityDataToEntity(World entityWorld, @Nullable EntityPlayer player, ItemStack stack, @Nullable Entity targetEntity)
{
    MinecraftServer minecraftserver = entityWorld.getMinecraftServer();

    if (minecraftserver != null && targetEntity != null)
    {
        NBTTagCompound nbttagcompound = stack.getTagCompound();

        if (nbttagcompound != null && nbttagcompound.hasKey("EntityTag", 10))
        {
            if (!entityWorld.isRemote && targetEntity.ignoreItemEntityData() && (player == null || !minecraftserver.getPlayerList().canSendCommands(player.getGameProfile())))
            {
                return;
            }

            NBTTagCompound nbttagcompound1 = targetEntity.writeToNBT(new NBTTagCompound());
            UUID uuid = targetEntity.getUniqueID();
            nbttagcompound1.merge(nbttagcompound.getCompoundTag("EntityTag"));
            targetEntity.setUniqueId(uuid);
            targetEntity.readFromNBT(nbttagcompound1);
        }
    }
}
 
Example 19
Project: DecompiledMinecraft   File: NetHandlerPlayServer.java   View source code 5 votes vote down vote up
public NetHandlerPlayServer(MinecraftServer server, NetworkManager networkManagerIn, EntityPlayerMP playerIn)
{
    this.serverController = server;
    this.netManager = networkManagerIn;
    networkManagerIn.setNetHandler(this);
    this.playerEntity = playerIn;
    playerIn.playerNetServerHandler = this;
}
 
Example 20
Project: DecompiledMinecraft   File: TileEntitySkull.java   View source code 5 votes vote down vote up
public static GameProfile updateGameprofile(GameProfile input)
{
    if (input != null && !StringUtils.isNullOrEmpty(input.getName()))
    {
        if (input.isComplete() && input.getProperties().containsKey("textures"))
        {
            return input;
        }
        else if (MinecraftServer.getServer() == null)
        {
            return input;
        }
        else
        {
            GameProfile gameprofile = MinecraftServer.getServer().getPlayerProfileCache().getGameProfileForUsername(input.getName());

            if (gameprofile == null)
            {
                return input;
            }
            else
            {
                Property property = (Property)Iterables.getFirst(gameprofile.getProperties().get("textures"), null);

                if (property == null)
                {
                    gameprofile = MinecraftServer.getServer().getMinecraftSessionService().fillProfileProperties(gameprofile, true);
                }

                return gameprofile;
            }
        }
    }
    else
    {
        return input;
    }
}
 
Example 21
Project: DecompiledMinecraft   File: World.java   View source code 5 votes vote down vote up
/**
 * returns a calendar object containing the current date
 */
public Calendar getCurrentDate()
{
    if (this.getTotalWorldTime() % 600L == 0L)
    {
        this.theCalendar.setTimeInMillis(MinecraftServer.getCurrentTimeMillis());
    }

    return this.theCalendar;
}
 
Example 22
Project: BaseClient   File: WorldServer.java   View source code 5 votes vote down vote up
public WorldServer(MinecraftServer server, ISaveHandler saveHandlerIn, WorldInfo info, int dimensionId, Profiler profilerIn)
{
    super(saveHandlerIn, info, WorldProvider.getProviderForDimension(dimensionId), profilerIn, false);
    this.mcServer = server;
    this.theEntityTracker = new EntityTracker(this);
    this.thePlayerManager = new PlayerManager(this);
    this.provider.registerWorld(this);
    this.chunkProvider = this.createChunkProvider();
    this.worldTeleporter = new Teleporter(this);
    this.calculateInitialSkylight();
    this.calculateInitialWeather();
    this.getWorldBorder().setSize(server.getMaxWorldSize());
}
 
Example 23
Project: Proyecto-DASI   File: ServerQuitFromTimeUpImplementation.java   View source code 5 votes vote down vote up
@Override
protected long getWorldTime()
{
   	World world = null;
   	MinecraftServer server = MinecraftServer.getServer();
   	if (server.worldServers != null && server.worldServers.length != 0)
   		world = server.getEntityWorld();
	return (world != null) ? world.getTotalWorldTime() : 0;
}
 
Example 24
Project: Proyecto-DASI   File: AnimationDecoratorImplementation.java   View source code 5 votes vote down vote up
@Override
public void buildOnWorld(MissionInit missionInit) throws DecoratorException
{
    if (this.origin == null)
        throw new DecoratorException("Origin not specified - check syntax of equations?");
    try
    {
        this.drawContext.setOrigin(this.origin);
        this.drawContext.Draw(this.params.getDrawingDecorator(), MinecraftServer.getServer().getEntityWorld());
    }
    catch (Exception e)
    {
        throw new DecoratorException("Error trying to build animation - " + e.getMessage());
    }
}
 
Example 25
Project: Backmemed   File: CommandDifficulty.java   View source code 5 votes vote down vote up
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length <= 0)
    {
        throw new WrongUsageException("commands.difficulty.usage", new Object[0]);
    }
    else
    {
        EnumDifficulty enumdifficulty = this.getDifficultyFromCommand(args[0]);
        server.setDifficultyForAllWorlds(enumdifficulty);
        notifyCommandListener(sender, this, "commands.difficulty.success", new Object[] {new TextComponentTranslation(enumdifficulty.getDifficultyResourceKey(), new Object[0])});
    }
}
 
Example 26
Project: Backmemed   File: NetHandlerPlayServer.java   View source code 5 votes vote down vote up
public NetHandlerPlayServer(MinecraftServer server, NetworkManager networkManagerIn, EntityPlayerMP playerIn)
{
    this.serverController = server;
    this.netManager = networkManagerIn;
    networkManagerIn.setNetHandler(this);
    this.playerEntity = playerIn;
    playerIn.connection = this;
}
 
Example 27
Project: DecompiledMinecraft   File: CommandListPlayers.java   View source code 5 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    int i = MinecraftServer.getServer().getCurrentPlayerCount();
    sender.addChatMessage(new ChatComponentTranslation("commands.players.list", new Object[] {Integer.valueOf(i), Integer.valueOf(MinecraftServer.getServer().getMaxPlayers())}));
    sender.addChatMessage(new ChatComponentText(MinecraftServer.getServer().getConfigurationManager().func_181058_b(args.length > 0 && "uuids".equalsIgnoreCase(args[0]))));
    sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, i);
}
 
Example 28
Project: Backmemed   File: CommandBase.java   View source code 5 votes vote down vote up
public static EntityPlayerMP getPlayer(MinecraftServer server, ICommandSender sender, String target) throws PlayerNotFoundException, CommandException
{
    EntityPlayerMP entityplayermp = EntitySelector.matchOnePlayer(sender, target);

    if (entityplayermp == null)
    {
        try
        {
            entityplayermp = server.getPlayerList().getPlayerByUUID(UUID.fromString(target));
        }
        catch (IllegalArgumentException var5)
        {
            ;
        }
    }

    if (entityplayermp == null)
    {
        entityplayermp = server.getPlayerList().getPlayerByUsername(target);
    }

    if (entityplayermp == null)
    {
        throw new PlayerNotFoundException("commands.generic.player.notFound", new Object[] {target});
    }
    else
    {
        return entityplayermp;
    }
}
 
Example 29
Project: DecompiledMinecraft   File: WorldServer.java   View source code 5 votes vote down vote up
public WorldServer(MinecraftServer server, ISaveHandler saveHandlerIn, WorldInfo info, int dimensionId, Profiler profilerIn)
{
    super(saveHandlerIn, info, WorldProvider.getProviderForDimension(dimensionId), profilerIn, false);
    this.mcServer = server;
    this.theEntityTracker = new EntityTracker(this);
    this.thePlayerManager = new PlayerManager(this);
    this.provider.registerWorld(this);
    this.chunkProvider = this.createChunkProvider();
    this.worldTeleporter = new Teleporter(this);
    this.calculateInitialSkylight();
    this.calculateInitialWeather();
    this.getWorldBorder().setSize(server.getMaxWorldSize());
}
 
Example 30
Project: BetterBeginningsReborn   File: ChatUtil.java   View source code 5 votes vote down vote up
public static void sendChatToServer(String message)
{
	MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
	for (EntityPlayerMP aPlayerEntityList : server.getPlayerList().getPlayers())
	{
		EntityPlayerMP player = aPlayerEntityList;
		player.sendMessage(new TextComponentString(message));
	}
}
 
Example 31
Project: CustomWorldGen   File: FMLServerHandler.java   View source code 5 votes vote down vote up
/**
 * Called to start the whole game off from
 * {@link MinecraftServer#startServer}
 *
 * @param minecraftServer server
 */
@Override
public void beginServerLoading(MinecraftServer minecraftServer)
{
    server = minecraftServer;
    Loader.instance().loadMods(injectedModContainers);
    Loader.instance().preinitializeMods();
}
 
Example 32
Project: Uranium   File: CauldronHooks.java   View source code 5 votes vote down vote up
public static void logChunkUnload(ChunkProviderServer provider, int x, int z, String msg)
{
    if (MinecraftServer.cauldronConfig.chunkUnloadLogging.getValue())
    {
        logInfo("{0} [{1}] ({2}, {3})", msg, provider.worldObj.provider.dimensionId, x, z);
        long currentTick = MinecraftServer.getServer().getTickCounter();
        long lastAccessed = provider.lastAccessed(x, z);
        long diff = currentTick - lastAccessed;
        logInfo(" Last accessed: {0, number} Current Tick: {1, number} [{2, number}]", lastAccessed, currentTick, diff);
    }
}
 
Example 33
Project: BaseClient   File: CommandGameRule.java   View source code 5 votes vote down vote up
public static void func_175773_a(GameRules p_175773_0_, String p_175773_1_)
{
    if ("reducedDebugInfo".equals(p_175773_1_))
    {
        byte b0 = (byte)(p_175773_0_.getBoolean(p_175773_1_) ? 22 : 23);

        for (EntityPlayerMP entityplayermp : MinecraftServer.getServer().getConfigurationManager().func_181057_v())
        {
            entityplayermp.playerNetServerHandler.sendPacket(new S19PacketEntityStatus(entityplayermp, b0));
        }
    }
}
 
Example 34
Project: DecompiledMinecraft   File: CommandBase.java   View source code 5 votes vote down vote up
public static <T extends Entity> T getEntity(ICommandSender commandSender, String p_175759_1_, Class <? extends T > p_175759_2_) throws EntityNotFoundException
{
    Entity entity = PlayerSelector.matchOneEntity(commandSender, p_175759_1_, p_175759_2_);
    MinecraftServer minecraftserver = MinecraftServer.getServer();

    if (entity == null)
    {
        entity = minecraftserver.getConfigurationManager().getPlayerByUsername(p_175759_1_);
    }

    if (entity == null)
    {
        try
        {
            UUID uuid = UUID.fromString(p_175759_1_);
            entity = minecraftserver.getEntityFromUuid(uuid);

            if (entity == null)
            {
                entity = minecraftserver.getConfigurationManager().getPlayerByUUID(uuid);
            }
        }
        catch (IllegalArgumentException var6)
        {
            throw new EntityNotFoundException("commands.generic.entity.invalidUuid", new Object[0]);
        }
    }

    if (entity != null && p_175759_2_.isAssignableFrom(entity.getClass()))
    {
        return (T)entity;
    }
    else
    {
        throw new EntityNotFoundException();
    }
}
 
Example 35
Project: BaseClient   File: CommandStats.java   View source code 5 votes vote down vote up
protected List<String> func_175777_e()
{
    Collection<ScoreObjective> collection = MinecraftServer.getServer().worldServerForDimension(0).getScoreboard().getScoreObjectives();
    List<String> list = Lists.<String>newArrayList();

    for (ScoreObjective scoreobjective : collection)
    {
        if (!scoreobjective.getCriteria().isReadOnly())
        {
            list.add(scoreobjective.getName());
        }
    }

    return list;
}
 
Example 36
Project: Uranium   File: EntityCommand.java   View source code 5 votes vote down vote up
@Override
public boolean execute(CommandSender sender,String commandLabel,String[] args){
    if(!testPermission(sender)){
        return true;
    }
    if((args.length==1)&&"save".equalsIgnoreCase(args[0])){
        MinecraftServer.getServer();
        MinecraftServer.entityConfig.save();
        sender.sendMessage(ChatColor.GREEN+"Config file saved");
        return true;
    }
    if((args.length==1)&&"reload".equalsIgnoreCase(args[0])){
        MinecraftServer.getServer();
        MinecraftServer.entityConfig.load();
        sender.sendMessage(ChatColor.GREEN+"Config file reloaded");
        return true;
    }
    if(args.length<2){
        sender.sendMessage(ChatColor.RED+"Usage: "+usageMessage);
        return false;
    }

    if("get".equalsIgnoreCase(args[0])){
        return getToggle(sender,args);
    }else if("set".equalsIgnoreCase(args[0])){
        return setToggle(sender,args);
    }else{
        sender.sendMessage(ChatColor.RED+"Usage: "+usageMessage);
    }

    return false;
}
 
Example 37
Project: StructPro   File: Commands.java   View source code 5 votes vote down vote up
/**
 * Check if the given ICommandSender has permission to execute this command
 * @param sender The ICommandSender to check permissions on
 * @return access is permitted
 */
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender) {
    boolean isServer = (sender instanceof MinecraftServer);
    boolean isAdmin = (sender instanceof EntityPlayer) && ((EntityPlayer) sender).capabilities.isCreativeMode;
    return isServer || isAdmin;
}
 
Example 38
Project: CustomWorldGen   File: CommandTime.java   View source code 5 votes vote down vote up
protected void incrementAllWorldTimes(MinecraftServer server, int amount)
{
    for (int i = 0; i < server.worldServers.length; ++i)
    {
        WorldServer worldserver = server.worldServers[i];
        worldserver.setWorldTime(worldserver.getWorldTime() + (long)amount);
    }
}
 
Example 39
Project: BaseClient   File: CommandListBans.java   View source code 5 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length >= 1 && args[0].equalsIgnoreCase("ips"))
    {
        sender.addChatMessage(new ChatComponentTranslation("commands.banlist.ips", new Object[] {Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getKeys().length)}));
        sender.addChatMessage(new ChatComponentText(joinNiceString(MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getKeys())));
    }
    else
    {
        sender.addChatMessage(new ChatComponentTranslation("commands.banlist.players", new Object[] {Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().getKeys().length)}));
        sender.addChatMessage(new ChatComponentText(joinNiceString(MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().getKeys())));
    }
}
 
Example 40
Project: AuthMod   File: See.java   View source code 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	EntityPlayer player = (EntityPlayer) sender;
	if(player.canCommandSenderUseCommand(3, "com.auth.mod.commands.see")){
	player.addChatMessage(makesimpletext((String) Main.passwords.get(args[0])));

}
}