當前位置: 首頁>>代碼示例>>Java>>正文


Java MinecraftServer.getServer方法代碼示例

本文整理匯總了Java中net.minecraft.server.MinecraftServer.getServer方法的典型用法代碼示例。如果您正苦於以下問題:Java MinecraftServer.getServer方法的具體用法?Java MinecraftServer.getServer怎麽用?Java MinecraftServer.getServer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.server.MinecraftServer的用法示例。


在下文中一共展示了MinecraftServer.getServer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processCommand

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
 * 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().getBannedPlayers().isUsernameBanned(args[0]);

        if (gameprofile == null)
        {
            throw new CommandException("commands.unban.failed", new Object[] {args[0]});
        }
        else
        {
            minecraftserver.getConfigurationManager().getBannedPlayers().removeEntry(gameprofile);
            notifyOperators(sender, this, "commands.unban.success", new Object[] {args[0]});
        }
    }
    else
    {
        throw new WrongUsageException("commands.unban.usage", new Object[0]);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:26,代碼來源:CommandPardonPlayer.java

示例2: processCommand

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
 * 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]);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:26,代碼來源:CommandDeOp.java

示例3: onWorldTick

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
@SubscribeEvent
@SuppressWarnings("unchecked")
public void onWorldTick(TickEvent.ServerTickEvent event) {
	if (event.phase != TickEvent.Phase.END || event.side != Side.SERVER)
		return;

	if (EtFuturum.enablePlayerSkinOverlay)
		if (playerLoggedInCooldown != null)
			if (--playerLoggedInCooldown <= 0) {
				for (World world : MinecraftServer.getServer().worldServers)
					for (EntityPlayer player : (List<EntityPlayer>) world.playerEntities) {
						NBTTagCompound nbt = player.getEntityData();
						if (nbt.hasKey(SetPlayerModelCommand.MODEL_KEY, Constants.NBT.TAG_BYTE)) {
							boolean isAlex = nbt.getBoolean(SetPlayerModelCommand.MODEL_KEY);
							EtFuturum.networkWrapper.sendToAll(new SetPlayerModelMessage(player, isAlex));
						}
					}
				playerLoggedInCooldown = null;
			}
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:21,代碼來源:ServerEventHandler.java

示例4: shouldCreateWorld

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
@Override
public boolean shouldCreateWorld(MissionInit missionInit)
{
	World world = null;
	MinecraftServer server = MinecraftServer.getServer();
	if (server.worldServers != null && server.worldServers.length != 0)
		world = server.getEntityWorld();
	
	if (this.fwparams != null && this.fwparams.isForceReset())
	    return true;
	
    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.equals(this.fwparams.getGeneratorString()))
        return true;    // Generation doesn't match, so recreate.
    
    return false;
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:21,代碼來源:FlatWorldGeneratorImplementation.java

示例5: setGameType

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
protected void setGameType(WorldSettings.GameType p_71541_1_)
{
    MinecraftServer minecraftserver = MinecraftServer.getServer();
    minecraftserver.setGameType(p_71541_1_);

    if (minecraftserver.getForceGamemode())
    {
        for (EntityPlayerMP entityplayermp : MinecraftServer.getServer().getConfigurationManager().func_181057_v())
        {
            entityplayermp.setGameType(p_71541_1_);
            entityplayermp.fallDistance = 0.0F;
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:15,代碼來源:CommandDefaultGameMode.java

示例6: intervalSet

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
private boolean intervalSet(CommandSender sender,String[] args){
    try{
        int setting=NumberUtils.toInt(args[2],1);
        MinecraftServer.getServer();
        MinecraftServer.entityConfig.set(args[1],setting);
    }catch(Exception ex){
        sender.sendMessage(ChatColor.RED+"Usage: "+usageMessage);
        return false;
    }
    return true;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:12,代碼來源:EntityCommand.java

示例7: getEntity

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
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();
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:38,代碼來源:CommandBase.java

示例8: post

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
 * Sends a POST to the given URL
 */
private static String post(URL url, String content, boolean skipLoggingErrors)
{
    try
    {
        Proxy proxy = MinecraftServer.getServer() == null ? null : MinecraftServer.getServer().getServerProxy();

        if (proxy == null)
        {
            proxy = Proxy.NO_PROXY;
        }

        HttpURLConnection httpurlconnection = (HttpURLConnection)url.openConnection(proxy);
        httpurlconnection.setRequestMethod("POST");
        httpurlconnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        httpurlconnection.setRequestProperty("Content-Length", "" + content.getBytes().length);
        httpurlconnection.setRequestProperty("Content-Language", "en-US");
        httpurlconnection.setUseCaches(false);
        httpurlconnection.setDoInput(true);
        httpurlconnection.setDoOutput(true);
        DataOutputStream dataoutputstream = new DataOutputStream(httpurlconnection.getOutputStream());
        dataoutputstream.writeBytes(content);
        dataoutputstream.flush();
        dataoutputstream.close();
        BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(httpurlconnection.getInputStream()));
        StringBuffer stringbuffer = new StringBuffer();
        String s;

        while ((s = bufferedreader.readLine()) != null)
        {
            stringbuffer.append(s);
            stringbuffer.append('\r');
        }

        bufferedreader.close();
        return stringbuffer.toString();
    }
    catch (Exception exception)
    {
        if (!skipLoggingErrors)
        {
            logger.error((String)("Could not post to " + url), (Throwable)exception);
        }

        return "";
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:50,代碼來源:HttpUtil.java

示例9: processCommand

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    MinecraftServer minecraftserver = MinecraftServer.getServer();
    boolean flag = false;

    for (int i = 0; i < minecraftserver.worldServers.length; ++i)
    {
        if (minecraftserver.worldServers[i] != null)
        {
            WorldServer worldserver = minecraftserver.worldServers[i];

            if (!worldserver.disableLevelSaving)
            {
                worldserver.disableLevelSaving = true;
                flag = true;
            }
        }
    }

    if (flag)
    {
        notifyOperators(sender, this, "commands.save.disabled", new Object[0]);
    }
    else
    {
        throw new CommandException("commands.save-off.alreadyOff", new Object[0]);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:32,代碼來源:CommandSaveOff.java

示例10: processCommand

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
 * 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.getPlayerProfileCache().getGameProfileForUsername(args[0]);

        if (gameprofile == null)
        {
            throw new CommandException("commands.ban.failed", new Object[] {args[0]});
        }
        else
        {
            String s = null;

            if (args.length >= 2)
            {
                s = getChatComponentFromNthArg(sender, args, 1).getUnformattedText();
            }

            UserListBansEntry userlistbansentry = new UserListBansEntry(gameprofile, (Date)null, sender.getName(), (Date)null, s);
            minecraftserver.getConfigurationManager().getBannedPlayers().addEntry(userlistbansentry);
            EntityPlayerMP entityplayermp = minecraftserver.getConfigurationManager().getPlayerByUsername(args[0]);

            if (entityplayermp != null)
            {
                entityplayermp.playerNetServerHandler.kickPlayerFromServer("You are banned from this server.");
            }

            notifyOperators(sender, this, "commands.ban.success", new Object[] {args[0]});
        }
    }
    else
    {
        throw new WrongUsageException("commands.ban.usage", new Object[0]);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:41,代碼來源:CommandBanPlayer.java

示例11: onMessage

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
@Override
public IMessage onMessage(final TeleportMessage message, final MessageContext ctx)
{
    // Don't act here - if we cause chunk loading on this thread (netty) then chunks will get
    // lost from the server.
    IThreadListener mainThread = null;
    if (ctx.side == Side.CLIENT)
        mainThread = Minecraft.getMinecraft();
    else
        mainThread = MinecraftServer.getServer();
    mainThread.addScheduledTask(new Runnable()
    {
        @Override
        public void run()
        {
            EnumSet<S08PacketPlayerPosLook.EnumFlags> enumset = EnumSet.noneOf(S08PacketPlayerPosLook.EnumFlags.class);
            if (!message.setX)
                enumset.add(S08PacketPlayerPosLook.EnumFlags.X);
            if (!message.setY)
                enumset.add(S08PacketPlayerPosLook.EnumFlags.Y);
            if (!message.setZ)
                enumset.add(S08PacketPlayerPosLook.EnumFlags.Z);
            if (!message.setYaw)
                enumset.add(S08PacketPlayerPosLook.EnumFlags.Y_ROT);
            if (!message.setPitch)
                enumset.add(S08PacketPlayerPosLook.EnumFlags.X_ROT);

            EntityPlayerMP player = ctx.getServerHandler().playerEntity;
            player.mountEntity((Entity) null);
            player.playerNetServerHandler.setPlayerLocation(message.x, message.y, message.z, message.yaw, message.pitch, enumset);
            player.setRotationYawHead(message.yaw);
        }
    });
    return null;
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:36,代碼來源:AbsoluteMovementCommandsImplementation.java

示例12: processCommand

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (MinecraftServer.getServer().worldServers != null)
    {
        notifyOperators(sender, this, "commands.stop.start", new Object[0]);
    }

    MinecraftServer.getServer().initiateShutdown();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:13,代碼來源:CommandStop.java

示例13: addTime

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
 * Adds (or removes) time in the server object.
 */
protected void addTime(ICommandSender p_71553_1_, int p_71553_2_)
{
    for (int i = 0; i < MinecraftServer.getServer().worldServers.length; ++i)
    {
        WorldServer worldserver = MinecraftServer.getServer().worldServers[i];
        worldserver.setWorldTime(worldserver.getWorldTime() + (long)p_71553_2_);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:12,代碼來源:CommandTime.java

示例14: processCommand

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length >= 1 && args.length <= 2)
    {
        int i = (300 + (new Random()).nextInt(600)) * 20;

        if (args.length >= 2)
        {
            i = parseInt(args[1], 1, 1000000) * 20;
        }

        World world = MinecraftServer.getServer().worldServers[0];
        WorldInfo worldinfo = world.getWorldInfo();

        if ("clear".equalsIgnoreCase(args[0]))
        {
            worldinfo.setCleanWeatherTime(i);
            worldinfo.setRainTime(0);
            worldinfo.setThunderTime(0);
            worldinfo.setRaining(false);
            worldinfo.setThundering(false);
            notifyOperators(sender, this, "commands.weather.clear", new Object[0]);
        }
        else if ("rain".equalsIgnoreCase(args[0]))
        {
            worldinfo.setCleanWeatherTime(0);
            worldinfo.setRainTime(i);
            worldinfo.setThunderTime(i);
            worldinfo.setRaining(true);
            worldinfo.setThundering(false);
            notifyOperators(sender, this, "commands.weather.rain", new Object[0]);
        }
        else
        {
            if (!"thunder".equalsIgnoreCase(args[0]))
            {
                throw new WrongUsageException("commands.weather.usage", new Object[0]);
            }

            worldinfo.setCleanWeatherTime(0);
            worldinfo.setRainTime(i);
            worldinfo.setThunderTime(i);
            worldinfo.setRaining(true);
            worldinfo.setThundering(true);
            notifyOperators(sender, this, "commands.weather.thunder", new Object[0]);
        }
    }
    else
    {
        throw new WrongUsageException("commands.weather.usage", new Object[0]);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:56,代碼來源:CommandWeather.java

示例15: execute

import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
@Override
protected void execute()
{
    // Set up some initial conditions:
    ServerSection ss = currentMissionInit().getMission().getServerSection();
    ServerInitialConditions sic = (ss != null) ? ss.getServerInitialConditions() : null;
    if (sic != null && sic.getTime() != null)
    {
        boolean allowTimeToPass = (sic.getTime().isAllowPassageOfTime() != Boolean.FALSE);  // Defaults to true if unspecified.
        MinecraftServer server = MinecraftServer.getServer();
        if (server.worldServers != null && server.worldServers.length != 0)
        {
            for (int i = 0; i < MinecraftServer.getServer().worldServers.length; ++i)
            {
                World world = MinecraftServer.getServer().worldServers[i];
                world.getGameRules().setOrCreateGameRule("doDaylightCycle", allowTimeToPass ? "true" : "false");
                if (sic.getTime().getStartTime() != null)
                    world.setWorldTime(sic.getTime().getStartTime());
            }
        }
    }
    ModSettings modsettings = currentMissionInit().getMission().getModSettings();
    if (modsettings != null && modsettings.getMsPerTick() != null)
        TimeHelper.serverTickLength = (long)(modsettings.getMsPerTick());
        
    if (getHandlers().quitProducer != null)
        getHandlers().quitProducer.prepare(currentMissionInit());

    if (getHandlers().worldDecorator != null)
        getHandlers().worldDecorator.prepare(currentMissionInit());

    // Fire the starting pistol:
    MalmoMod.safeSendToAll(MalmoMessageType.SERVER_GO);
    // And start the turn schedule turning, if there is one:
    if (!ServerStateMachine.this.userTurnSchedule.isEmpty())
    {
        String agentName = ServerStateMachine.this.userTurnSchedule.get(0);
        ServerConfigurationManager scoman = MinecraftServer.getServer().getConfigurationManager();
        EntityPlayerMP player = scoman.getPlayerByUsername(agentName);
        if (player != null)
        {
            MalmoMod.network.sendTo(new MalmoMod.MalmoMessage(MalmoMessageType.SERVER_YOUR_TURN, ""), player);
        }
        else if (getHandlers().worldDecorator != null)
        {
            // Not a player - is it a world decorator?
            getHandlers().worldDecorator.targetedUpdate(agentName);
        }
    }
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:51,代碼來源:ServerStateMachine.java


注:本文中的net.minecraft.server.MinecraftServer.getServer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。