net.minecraft.server.MinecraftServer Java Examples
The following examples show how to use
net.minecraft.server.MinecraftServer.
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: TickSpeed.java From fabric-carpet with MIT License | 6 votes |
public static void tick(MinecraftServer server) { process_entities = true; if (player_active_timeout > 0) { player_active_timeout--; } if (is_paused) { if (player_active_timeout < PLAYER_GRACE) { process_entities = false; } } else if (is_superHot) { if (player_active_timeout <= 0) { process_entities = false; } } }
Example #2
Source File: CmdReport.java From I18nUpdateMod with MIT License | 6 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) { ItemStack stack = Minecraft.getMinecraft().player.inventory.getCurrentItem(); if (!stack.isEmpty()) { String text = String.format("模组ID:%s\n非本地化名称:%s\n显示名称:%s", stack.getItem().getCreatorModId(stack), stack.getItem().getUnlocalizedName(), stack.getDisplayName()); String url = I18nConfig.key.reportURL; try { GuiScreen.setClipboardString(text); Desktop.getDesktop().browse(new URI(url)); } catch (Exception urlException) { urlException.printStackTrace(); } } else { Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("message.i18nmod.cmd_report.empty")); } }
Example #3
Source File: SoulNetworkHandler.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
public static void setCurrentEssence(String ownerName, int essence) { if (MinecraftServer.getServer() == null) { return; } World world = MinecraftServer.getServer().worldServers[0]; LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName); if (data == null) { data = new LifeEssenceNetwork(ownerName); world.setItemData(ownerName, data); } data.currentEssence = essence; data.markDirty(); }
Example #4
Source File: CmdGetLangpack.java From I18nUpdateMod with MIT License | 6 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) { // 参数为空,警告 if (args.length == 0) { Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("message.i18nmod.cmd_get_langpack.empty")); return; } // 参数存在,进行下一步判定 if (Minecraft.getMinecraft().getResourceManager().getResourceDomains().contains(args[0])) { Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("message.i18nmod.cmd_get_langpack.right_start", args[0])); // 同名资源包存在,直接返回 if (!cerateTempLangpack(args[0])) { Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("message.i18nmod.cmd_get_langpack.error_create_folder")); return; } // 主下载功能 langFileDownloader(args[0]); } // 参数不存在,警告 else { Minecraft.getMinecraft().player.sendMessage(new TextComponentTranslation("message.i18nmod.cmd_get_langpack.not_found", args[0])); } }
Example #5
Source File: ProtectionManager.java From MyTown2 with The Unlicense | 6 votes |
public static void checkBlockInteraction(Resident res, BlockPos bp, PlayerInteractEvent.Action action, Event ev) { if(!ev.isCancelable()) { return; } World world = MinecraftServer.getServer().worldServerForDimension(bp.getDim()); Block block = world.getBlock(bp.getX(), bp.getY(), bp.getZ()); // Bypass for SellSign if (block instanceof BlockSign) { TileEntity te = world.getTileEntity(bp.getX(), bp.getY(), bp.getZ()); if(te instanceof TileEntitySign && SellSign.SellSignType.instance.isTileValid((TileEntitySign) te)) { return; } } for(SegmentBlock segment : segmentsBlock.get(block.getClass())) { if(!segment.shouldInteract(res, bp, action)) { ev.setCanceled(true); } } }
Example #6
Source File: CraftBlock.java From Thermos with GNU General Public License v3.0 | 6 votes |
public static void dumpMaterials() { if (MinecraftServer.getServer().cauldronConfig.dumpMaterials.getValue()) { FMLLog.info("Cauldron Dump Materials is ENABLED. Starting dump..."); for (int i = 0; i < 32000; i++) { Material material = Material.getMaterial(i); if (material != null) { FMLLog.info("Found material " + material + " with ID " + i); } } FMLLog.info("Cauldron Dump Materials complete."); FMLLog.info("To disable these dumps, set cauldron.dump-materials to false in bukkit.yml."); } }
Example #7
Source File: CauldronCommand.java From Thermos with GNU General Public License v3.0 | 6 votes |
@Override public List<String> tabComplete(CommandSender sender, String alias, String[] args) { Validate.notNull(sender, "Sender cannot be null"); Validate.notNull(args, "Arguments cannot be null"); Validate.notNull(alias, "Alias cannot be null"); if (args.length == 1) { return StringUtil.copyPartialMatches(args[0], COMMANDS, new ArrayList<String>(COMMANDS.size())); } if (((args.length == 2) && "get".equalsIgnoreCase(args[0])) || "set".equalsIgnoreCase(args[0])) { return StringUtil.copyPartialMatches(args[1], MinecraftServer.getServer().cauldronConfig.getSettings().keySet(), new ArrayList<String>(MinecraftServer.getServer().cauldronConfig.getSettings().size())); } else if ((args.length == 2) && "chunks".equalsIgnoreCase(args[0])) { return StringUtil.copyPartialMatches(args[1], CHUNK_COMMANDS, new ArrayList<String>(CHUNK_COMMANDS.size())); } return ImmutableList.of(); }
Example #8
Source File: ServerEventHandler.java From Et-Futurum with The Unlicense | 6 votes |
@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; } }
Example #9
Source File: SoulNetworkHandler.java From Framez with GNU General Public License v3.0 | 6 votes |
public static boolean canSyphonFromOnlyNetwork(String ownerName, int damageToBeDone) { if (MinecraftServer.getServer() == null) { return false; } World world = MinecraftServer.getServer().worldServers[0]; LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName); if (data == null) { data = new LifeEssenceNetwork(ownerName); world.setItemData(ownerName, data); } return data.currentEssence >= damageToBeDone; }
Example #10
Source File: CraftSkull.java From Kettle with GNU General Public License v3.0 | 6 votes |
@Override public boolean setOwner(String name) { if (name == null || name.length() > MAX_OWNER_LENGTH) { return false; } GameProfile profile = MinecraftServer.getServerCB().getPlayerProfileCache().getGameProfileForUsername(name); if (profile == null) { return false; } if (skullType != SkullType.PLAYER) { skullType = SkullType.PLAYER; } this.profile = profile; return true; }
Example #11
Source File: SpigotCommand.java From Kettle with GNU General Public License v3.0 | 6 votes |
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { if (!testPermission(sender)) return true; if (args.length != 1) { sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); return false; } if (args[0].equals("reload")) { Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues."); Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server."); MinecraftServer console = MinecraftServer.getServerCB(); org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); for (WorldServer world : console.worlds) { world.spigotConfig.init(); } console.server.reloadCount++; Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Reload complete."); } return true; }
Example #12
Source File: CommandConfig.java From OpenModsLib with MIT License | 6 votes |
@Override public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos blockPos) { String command = args[0]; if (args.length == 1) return filterPrefixes(command, SUBCOMMANDS); String modId = args[1]; if (args.length == 2) return filterPrefixes(modId, ConfigProcessing.getConfigsIds()); if (COMMAND_SAVE.equals(command)) return Collections.emptyList(); final ModConfig config = ConfigProcessing.getConfig(modId); if (config == null) return Collections.emptyList(); String category = args[2]; if (args.length == 3) return filterPrefixes(category, config.getCategories()); String name = args[3]; if (args.length == 4) return filterPrefixes(name, config.getValues(category)); return Collections.emptyList(); }
Example #13
Source File: DebugCommand.java From TFC2 with GNU General Public License v3.0 | 6 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] params) { EntityPlayerMP player; try { player = getCommandSenderAsPlayer(sender); } catch (PlayerNotFoundException e) { return; } WorldServer world = server.worldServerForDimension(player.getEntityWorld().provider.getDimension()); if(params.length == 1 && params[0].equalsIgnoreCase("report")) { int xM =player.getPosition().getX() >> 12; int zM =player.getPosition().getZ() >> 12; String out = "World Seed: [" + world.getSeed() + "] | IslandMap: [" +xM + "," + zM + "] | PlayerPos: [" + player.getPosition().toString() + "]"; StringSelection selection = new StringSelection(out); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); if(clipboard != null) clipboard.setContents(selection, selection); } }
Example #14
Source File: TargetData.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
public boolean isTargetBlockUnchanged() { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); if (server == null) { return false; } World world = server.getWorld(this.dimension); if (world == null) { return false; } IBlockState iBlockState = world.getBlockState(this.pos); Block block = iBlockState.getBlock(); ResourceLocation rl = ForgeRegistries.BLOCKS.getKey(block); int meta = block.getMetaFromState(iBlockState); // The target block unique name and metadata matches what we have stored return this.blockMeta == meta && rl != null && this.blockName.equals(rl.toString()); }
Example #15
Source File: ProtectionHandlers.java From MyTown2 with The Unlicense | 5 votes |
@SubscribeEvent public void serverTick(TickEvent.ServerTickEvent ev) { // TODO: Add a command to clean up the block whitelist table periodically if (MinecraftServer.getServer().getTickCounter() % 600 == 0) { for (Town town : MyTownUniverse.instance.towns) for (int i = 0; i < town.blockWhitelistsContainer.size(); i++) { BlockWhitelist bw = town.blockWhitelistsContainer.get(i); if (!ProtectionManager.isBlockWhitelistValid(bw)) { MyTown.instance.datasource.deleteBlockWhitelist(bw, town); } } } }
Example #16
Source File: CarpetServer.java From fabric-carpet with MIT License | 5 votes |
public static void onServerLoaded(MinecraftServer server) { CarpetServer.minecraft_server = server; settingsManager.attachServer(server); extensions.forEach(e -> { SettingsManager sm = e.customSettingsManager(); if (sm != null) sm.attachServer(server); e.onServerLoaded(server); }); scriptServer = new CarpetScriptServer(server); MobAI.resetTrackers(); LoggerRegistry.initLoggers(); //TickSpeed.reset(); }
Example #17
Source File: MinecraftServer_coreMixin.java From fabric-carpet with MIT License | 5 votes |
@Inject( method = "tick", at = @At( value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;tickWorlds(Ljava/util/function/BooleanSupplier;)V", shift = At.Shift.BEFORE, ordinal = 0 ) ) private void onTick(BooleanSupplier booleanSupplier_1, CallbackInfo ci) { CarpetServer.tick((MinecraftServer) (Object) this); }
Example #18
Source File: NEIServerUtils.java From NotEnoughItems with MIT License | 5 votes |
public static void sendNotice(ICommandSender sender, IChatComponent msg, String permission) { ChatComponentTranslation notice = new ChatComponentTranslation("chat.type.admin", sender.getCommandSenderName(), msg.createCopy()); notice.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(true); if (NEIServerConfig.canPlayerPerformAction("CONSOLE", permission)) MinecraftServer.getServer().addChatMessage(notice); for (EntityPlayer p : ServerUtils.getPlayers()) if(p == sender) p.addChatComponentMessage(msg); else if (NEIServerConfig.canPlayerPerformAction(p.getCommandSenderName(), permission)) p.addChatComponentMessage(notice); }
Example #19
Source File: ServerStateMachine.java From malmo with MIT License | 5 votes |
@Override protected void execute() { MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); World world = server.getEntityWorld(); MissionBehaviour handlers = this.ssmachine.getHandlers(); // Assume the world has been created correctly - now do the necessary building. boolean builtOkay = true; if (handlers != null && handlers.worldDecorator != null) { try { handlers.worldDecorator.buildOnWorld(this.ssmachine.currentMissionInit(), world); } catch (DecoratorException e) { // Error attempting to decorate the world - abandon the mission. builtOkay = false; if (e.getMessage() != null) saveErrorDetails(e.getMessage()); // Tell all the clients to abort: Map<String, String>data = new HashMap<String, String>(); data.put("message", getErrorDetails()); MalmoMod.safeSendToAll(MalmoMessageType.SERVER_ABORT, data); // And abort ourselves: episodeHasCompleted(ServerState.ERROR); } } if (builtOkay) { // Now set up other attributes of the environment (eg weather) EnvironmentHelper.setMissionWeather(currentMissionInit(), server.getEntityWorld().getWorldInfo()); episodeHasCompleted(ServerState.WAITING_FOR_AGENTS_TO_ASSEMBLE); } }
Example #20
Source File: TileAdditionalEldritchPortal.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
public static void informSessionStart(EntityPlayer player) { if(trackedPortalActivity.containsKey(player)) { ExtendedChunkCoordinates tileCoords = trackedPortalActivity.get(player); trackedPortalActivity.remove(player); if(tileCoords != null) { ChunkCoordinates cc = tileCoords.coordinates; WorldServer ws = MinecraftServer.getServer().worldServerForDimension(tileCoords.dimId); ws.removeTileEntity(cc.posX, cc.posY, cc.posZ); ws.setBlockToAir(cc.posX, cc.posY, cc.posZ); ws.markBlockForUpdate(cc.posX, cc.posY, cc.posZ); } } }
Example #21
Source File: WorldConfig.java From Thermos with GNU General Public License v3.0 | 5 votes |
private void log(String s) { if ( verbose ) { MinecraftServer.getServer().logInfo( s ); } }
Example #22
Source File: WorldTicktimeSensor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public int getRedstoneValue(World world, int x, int y, int z, int sensorRange, String textBoxText){ MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); double worldTickTime = mean(server.worldTickTimes.get(world.provider.dimensionId)) * 1.0E-6D; try { int redstoneStrength = (int)(worldTickTime * Double.parseDouble(textBoxText)); return Math.min(15, redstoneStrength); } catch(Exception e) { return 0; } }
Example #23
Source File: SushchestvoCommand.java From Thermos with GNU General Public License v3.0 | 5 votes |
@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().sushchestvoConfig.save(); sender.sendMessage(ChatColor.GREEN + "Config file saved"); return true; } if ((args.length == 1) && "reload".equalsIgnoreCase(args[0])) { MinecraftServer.getServer().sushchestvoConfig.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 #24
Source File: NewSpawnPlatformCommand.java From YUNoMakeGoodMap with Apache License 2.0 | 5 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length != 2) throw new WrongUsageException(getUsage(sender)); EntityPlayer player = getPlayer(server, sender, args[1]); if (player != null) { PlacementSettings settings = new PlacementSettings(); WorldServer world = (WorldServer) sender.getEntityWorld(); int platformNumber = SpawnPlatformSavedData.get(world).addAndGetPlatformNumber(); BlockPos pos = getPositionOfPlatform(world, platformNumber); Template temp = StructureUtil.loadTemplate(new ResourceLocation(args[0]), world, true); BlockPos spawn = StructureUtil.findSpawn(temp, settings); spawn = spawn == null ? pos : spawn.add(pos); sender.sendMessage(new TextComponentString("Building \"" + args[0] + "\" at " + pos.toString())); temp.addBlocksToWorld(world, pos, settings, 2); //Push to world, with no neighbor notifications! world.getPendingBlockUpdates(new StructureBoundingBox(pos, pos.add(temp.getSize())), true); //Remove block updates, so that sand doesn't fall! if (player instanceof EntityPlayerMP) { ((EntityPlayerMP) player).setPositionAndUpdate(spawn.getX() + 0.5, spawn.getY() + 1.6, spawn.getZ() + 0.5); } player.setSpawnChunk(spawn, true, world.provider.getDimension()); } else { throw new WrongUsageException(getUsage(sender)); } }
Example #25
Source File: ToroQuestCommand.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (!(sender instanceof EntityPlayer)) { return; } EntityPlayer player = (EntityPlayer) sender; if (args.length < 1) { throw new WrongUsageException("commands.tq.usage", new Object[0]); } String command = args[0]; System.out.println("command " + command); if ("rep".equals(command)) { adjustRep(server, player, args); } else if ("list".equals(command)) { listCommand(player, args); } else if ("gen".equals(command)) { genCommand(player, args); } else if ("gui".equals(command)) { guiCommand(player, args); } else if ("quest".equals(command)) { questCommand(player, args); } else if ("book".equals(command)) { bookCommand(player, args); } else { throw new WrongUsageException("commands.tq.usage", new Object[0]); } }
Example #26
Source File: ForgeCommand.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void execute(MinecraftServer minecraftServer, ICommandSender sender, String[] args) throws CommandException { if ((sender instanceof EntityPlayerMP)) { EntityPlayerMP player = (EntityPlayerMP) sender; if (player.worldObj.isRemote) { return; } FawePlayer<Object> fp = FawePlayer.wrap(player); cmd.executeSafe(fp, args); } }
Example #27
Source File: CustomFuelsCommand.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 5 votes |
@Override public boolean canCommandSenderUseCommand(ICommandSender pCommandSender) { if (pCommandSender instanceof EntityPlayerMP) { EntityPlayerMP tEP = (EntityPlayerMP) pCommandSender; boolean tPlayerOpped = MinecraftServer.getServer().getConfigurationManager().func_152596_g(tEP.getGameProfile()); //boolean tIncreative = tEP.capabilities.isCreativeMode; return tPlayerOpped; // && tIncreative; } else { return pCommandSender instanceof MinecraftServer; } }
Example #28
Source File: WorldUtil.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
public static void teleportToFakeOuter(EntityPlayerMP player) { MinecraftServer mServer = FMLCommonHandler.instance().getMinecraftServerInstance(); if(player.worldObj.provider.dimensionId != 0) { mServer.getConfigurationManager().transferPlayerToDimension(player, 0, new TeleporterNothing(mServer.worldServerForDimension(0))); } mServer.getConfigurationManager().transferPlayerToDimension(player, ModConfig.dimOuterId, new TeleporterNothing(mServer.worldServerForDimension(ModConfig.dimOuterId))); }
Example #29
Source File: ForgeCommand.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void execute(MinecraftServer minecraftServer, ICommandSender sender, String[] args) throws CommandException { if ((sender instanceof EntityPlayerMP)) { EntityPlayerMP player = (EntityPlayerMP) sender; if (player.world.isRemote) { return; } FawePlayer<Object> fp = FawePlayer.wrap(player); cmd.executeSafe(fp, args); } }
Example #30
Source File: CauldronHooks.java From Thermos with GNU General Public License v3.0 | 5 votes |
public static void logEntityDeath(Entity entity) { if (MinecraftServer.cauldronConfig.entityDeathLogging.getValue()) { logInfo("Dim: {0} setDead(): {1}", entity.worldObj.provider.dimensionId, entity); logStack(); } }