net.minecraft.server.management.PlayerList Java Examples
The following examples show how to use
net.minecraft.server.management.PlayerList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockTofuPortal.java From TofuCraftReload with MIT License | 5 votes |
/** * Called When an Entity Collided with the Block */ @Override public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { if (!entityIn.isRiding() && !entityIn.isBeingRidden() && entityIn.isNonBoss()) { MinecraftServer server = worldIn.getMinecraftServer(); if (server != null && entityIn.timeUntilPortal <= 0) { PlayerList playerList = server.getPlayerList(); int i = entityIn.dimension == DimensionType.OVERWORLD.getId() ? TofuMain.TOFU_DIMENSION.getId() : DimensionType.OVERWORLD.getId(); TofuTeleporter teleporter = new TofuTeleporter(server.getWorld(i)); entityIn.timeUntilPortal = 100; if (entityIn instanceof EntityPlayerMP) { playerList.transferPlayerToDimension((EntityPlayerMP) entityIn, i, teleporter); } else { int origin = entityIn.dimension; entityIn.dimension = i; worldIn.removeEntityDangerously(entityIn); entityIn.isDead = false; playerList.transferEntityToWorld(entityIn, origin, server.getWorld(origin), server.getWorld(i), teleporter); } } else entityIn.timeUntilPortal = Math.max(entityIn.getPortalCooldown(), 100); } }
Example #2
Source File: TickHandler.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private void teleportPlayers() { PlayerList list = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList(); if (this.portalFlags.isEmpty() == false) { for (UUID uuid : this.portalFlags) { EntityPlayer player = list.getPlayerByUUID(uuid); if (player != null) { World world = player.getEntityWorld(); BlockPos pos = player.getPosition(); // The exact intersection is checked here, because the players get added // to the set when they enter the block space, even if they don't intersect with the portal yet. for (int i = 0; i < 3; i++) { IBlockState state = world.getBlockState(pos); if (state.getBlock() == EnderUtilitiesBlocks.PORTAL && player.getEntityBoundingBox().intersects(state.getBoundingBox(world, pos).offset(pos))) { ((BlockEnderUtilitiesPortal) state.getBlock()).teleportEntity(world, pos, state, player); break; } pos = pos.up(); } } } this.portalFlags.clear(); } }
Example #3
Source File: CraftServer.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CraftServer(MinecraftServer console, PlayerList playerList) { this.console = console; this.playerList = (DedicatedPlayerList) playerList; this.playerView = Collections.unmodifiableList(Lists.transform(playerList.getPlayers(), EntityPlayerMP::getBukkitEntity)); this.serverVersion = CraftServer.class.getPackage().getImplementationVersion(); online.value = console.getPropertyManager().getBooleanProperty("online-mode", true); Bukkit.setServer(this); // Register all the Enchantments and PotionTypes now so we can stop new registration immediately after Enchantments.SHARPNESS.getClass(); Potion.setPotionBrewer(new CraftPotionBrewer()); MobEffects.BLINDNESS.getClass(); // Ugly hack :( if (!Main.useConsole) { getLogger().info("Console input is disabled due to --noconsole command argument"); } configuration = YamlConfiguration.loadConfiguration(getConfigFile()); configuration.options().copyDefaults(true); configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader( getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"), Charsets.UTF_8))); ConfigurationSection legacyAlias = null; if (!configuration.isString("aliases")) { legacyAlias = configuration.getConfigurationSection("aliases"); configuration.set("aliases", "now-in-commands.yml"); } saveConfig(); if (getCommandsConfigFile().isFile()) { legacyAlias = null; } commandsConfiguration = YamlConfiguration.loadConfiguration(getCommandsConfigFile()); commandsConfiguration.options().copyDefaults(true); commandsConfiguration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader( getClass().getClassLoader().getResourceAsStream("configurations/commands.yml"), Charsets.UTF_8))); saveCommandsConfig(); // Migrate aliases from old file and add previously implicit $1- to pass all arguments if (legacyAlias != null) { ConfigurationSection aliases = commandsConfiguration.createSection("aliases"); for (String key : legacyAlias.getKeys(false)) { ArrayList<String> commands = new ArrayList<String>(); if (legacyAlias.isList(key)) { for (String command : legacyAlias.getStringList(key)) { commands.add(command + " $1-"); } } else { commands.add(legacyAlias.getString(key) + " $1-"); } aliases.set(key, commands); } } saveCommandsConfig(); overrideAllCommandBlockCommands = commandsConfiguration.getStringList("command-block-overrides").contains("*"); unrestrictedAdvancements = commandsConfiguration.getBoolean("unrestricted-advancements"); pluginManager.useTimings(configuration.getBoolean("settings.plugin-profiling")); monsterSpawn = configuration.getInt("spawn-limits.monsters"); animalSpawn = configuration.getInt("spawn-limits.animals"); waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals"); ambientSpawn = configuration.getInt("spawn-limits.ambient"); console.autosavePeriod = configuration.getInt("ticks-per.autosave"); warningState = WarningState.value(configuration.getString("settings.deprecated-verbose")); loadIcon(); // Fixed server ping stalling. chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks"); chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold"); loadIcon(); }
Example #4
Source File: ServerStateMachine.java From malmo with MIT License | 4 votes |
private EntityPlayerMP getPlayerFromUsername(String username) { PlayerList scoman = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList(); EntityPlayerMP player = scoman.getPlayerByUsername(username); return player; }
Example #5
Source File: ServerStateMachine.java From malmo with MIT License | 4 votes |
@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 = FMLCommonHandler.instance().getMinecraftServerInstance(); if (server.worlds != null && server.worlds.length != 0) { for (int i = 0; i < server.worlds.length; ++i) { World world = server.worlds[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); PlayerList scoman = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList(); 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); } } }
Example #6
Source File: BlockTofuPortal.java From TofuCraftReload with MIT License | 2 votes |
@SuppressWarnings("unused") private boolean changeDim(EntityPlayer playerIn) { MinecraftServer server = playerIn.world.getMinecraftServer(); if (server != null) { PlayerList playerList = server.getPlayerList(); int i = playerIn.dimension == DimensionType.OVERWORLD.getId() ? TofuMain.TOFU_DIMENSION.getId() : DimensionType.OVERWORLD.getId(); Teleporter teleporter = new TofuTeleporter(server.getWorld(i)); if (playerIn instanceof EntityPlayerMP) { playerList.transferPlayerToDimension((EntityPlayerMP) playerIn, i, teleporter); } else { int origin = playerIn.dimension; playerIn.dimension = i; playerIn.world.removeEntityDangerously(playerIn); playerIn.isDead = false; playerList.transferEntityToWorld(playerIn, origin, server.getWorld(origin), server.getWorld(i), teleporter); } } return true; }