当前位置: 首页>>代码示例>>Java>>正文


Java Sponge类代码示例

本文整理汇总了Java中org.spongepowered.api.Sponge的典型用法代码示例。如果您正苦于以下问题:Java Sponge类的具体用法?Java Sponge怎么用?Java Sponge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Sponge类属于org.spongepowered.api包,在下文中一共展示了Sponge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onServerStart

import org.spongepowered.api.Sponge; //导入依赖的package包/类
@Listener
public void onServerStart(GameStartedServerEvent event) {
	instance = this;
	
	ConfigBuilder.configPath = Paths.get(configDir.toString(), "config.json");
	
	RText.impl(new RTextSponge());
	RColour.impl(new RColourSponge());
	Travellers.impl(new SpongeTravellers());
	
	CommandSpec camCommandSpec = CommandSpec.builder()
			.arguments(GenericArguments.optional(GenericArguments.remainingJoinedStrings(Text.of("cmd"))))
			.executor(new SpongeCommandManager())
			.build();

	Sponge.getCommandManager().register(this, camCommandSpec, "cam", "camerastudio");
}
 
开发者ID:redstone,项目名称:RCameraStudio,代码行数:18,代码来源:RCameraStudioSponge.java

示例2: onServerInitialization

import org.spongepowered.api.Sponge; //导入依赖的package包/类
@Listener
public void onServerInitialization(GameInitializationEvent event)
{
    eagleFactions = this;

   //Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.AQUA, "EagleFactions is loading..."));
   Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.AQUA, "Preparing wings..."));

   SetupConfigs();

   Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.AQUA, "Configs loaded..."));

   InitializeCommands();

   Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.AQUA, "Commands loaded..."));

   RegisterListeners();

    //Display some info text in the console.
    Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.GREEN,"=========================================="));
    Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.AQUA, "EagleFactions", TextColors.WHITE, " is ready to use!"));
    Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.WHITE,"Thank you for choosing this plugin!"));
    Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.WHITE,"Current version: " + PluginInfo.Version));
    Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.WHITE,"Have a great time with EagleFactions! :D"));
    Sponge.getServer().getConsole().sendMessage(Text.of(TextColors.GREEN,"=========================================="));
}
 
开发者ID:Aquerr,项目名称:EagleFactions,代码行数:27,代码来源:EagleFactions.java

示例3: onAboutToStart

import org.spongepowered.api.Sponge; //导入依赖的package包/类
@Listener
public void onAboutToStart(GameAboutToStartServerEvent event) {
	if (!enabled)
		return;

	// Initialize configs
	config = new StickyChunkConfig();
	pluginConfigManager = new ConfigManager(configManager);
	pluginConfigManager.save();

	database = new SqliteDatabase();
	dataStore = new DataStore();
	ticketManager = new TicketManager();

	dataStore.addPlayerRegions(database.loadRegionData());
	dataStore.addUsers(database.loadUserData());

	logger.info("registering callback");

	// Register callbacks
	Sponge.getServer().getChunkTicketManager().registerCallback(this, new ChunkLoadCallback());

	// Register events
	Sponge.getGame().getEventManager().registerListeners(this, new PlayerConnectionListener());
	Sponge.getGame().getEventManager().registerListeners(this, new RegionAreaListener());
}
 
开发者ID:DevOnTheRocks,项目名称:StickyChunk,代码行数:27,代码来源:StickyChunk.java

示例4: validateSpongeVersion

import org.spongepowered.api.Sponge; //导入依赖的package包/类
private boolean validateSpongeVersion() {
	PluginContainer container = Sponge.getPlatform().getContainer(Platform.Component.IMPLEMENTATION);
	if (container.getName().equals("SpongeForge")) {
		try {
			String version = container.getVersion().orElseThrow(Exception::new);
			version = version.substring(Math.max(version.length() - 4, 0));
			int spongeVersion = Integer.parseInt(version);
			if (spongeVersion < 2132) {
				this.logger.error(String.format("Failed to initialize StickyChunk due to outdated SpongeForge (%s). StickyChunk requires SF 2132+", spongeVersion));
				return false;
			}
		} catch (Exception ignored) {
		}
	}
	return true;
}
 
开发者ID:DevOnTheRocks,项目名称:StickyChunk,代码行数:17,代码来源:StickyChunk.java

示例5: performRemoval

import org.spongepowered.api.Sponge; //导入依赖的package包/类
private void performRemoval(LookupLine line) {
	World w = Sponge.getServer().getWorld(line.getWorld()).orElse(null);
	if (w == null) return;
	
	if (line.getTarget() instanceof ItemType) {
		
		Optional<TileEntity> te = w.getTileEntity(line.getPos());
		if (te.isPresent() && te.get() instanceof TileEntityCarrier) {
			TileEntityCarrier c = (TileEntityCarrier) te.get();
			Inventory i = c.getInventory();
			
			Inventory slot = i.query(new SlotIndex(line.getSlot()));
			slot.set(ItemStack.of(ItemTypes.NONE, 0));
		}
		
	} else if (line.getTarget() instanceof BlockType) {
		
		BlockState block = BlockState.builder().blockType(BlockTypes.AIR).build();
		w.setBlock(line.getPos(), block, Cause.source(container).build());
		
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:23,代码来源:RollbackManager.java

示例6: getDefaultGameMode

import org.spongepowered.api.Sponge; //导入依赖的package包/类
@Override
public GameMode getDefaultGameMode() {
    if (!Sponge.isServerAvailable()) {
        return GameMode.SURVIVAL;
    }
    Optional<WorldProperties>properties = Sponge.getServer().getDefaultWorld();
    if (!properties.isPresent()) {
        return GameMode.SURVIVAL;
    }
    org.spongepowered.api.entity.living.player.gamemode.GameMode gameMode = properties.get().getGameMode();

    if (gameMode == GameModes.SURVIVAL) {
        return GameMode.SURVIVAL;
    } else if (gameMode == GameModes.ADVENTURE) {
        return GameMode.ADVENTURE;
    } else if (gameMode == GameModes.CREATIVE) {
        return GameMode.CREATIVE;
    } else if (gameMode == GameModes.SPECTATOR) {
        return GameMode.SPECTATOR;
    }

    return GameMode.SURVIVAL; // Unimplemented gamemode's and NOT_SET
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:24,代码来源:FakeServer.java

示例7: releaseExample

import org.spongepowered.api.Sponge; //导入依赖的package包/类
public List<String> releaseExample()
{
    String defaultMenuDir = "menu/";
    File menuDir = this.plugin.getConfigDir().resolve(defaultMenuDir).toFile();
    if (menuDir.isDirectory() || menuDir.mkdirs())
    {
        try
        {
            AssetManager assetManager = Sponge.getAssetManager();
            Optional<Asset> example = assetManager.getAsset(this.plugin, "examples/example.conf");
            Optional<Asset> example2 = assetManager.getAsset(this.plugin, "examples/example2.conf");
            example.orElseThrow(IOException::new).copyToDirectory(menuDir.toPath());
            example2.orElseThrow(IOException::new).copyToDirectory(menuDir.toPath());
        }
        catch (IOException e)
        {
            this.logger.warn("Cannot extract default chest GUI configurations", e);
        }
    }
    return Collections.singletonList(defaultMenuDir);
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:22,代码来源:VirtualChestInventoryDispatcher.java

示例8: clanCoordsCommand

import org.spongepowered.api.Sponge; //导入依赖的package包/类
@Command(name = "coords", description = "Посмотреть координаты ваших соклановцев", isPlayerOnly = true, isClanOnly = true, clanPermission = "coords", spongePermission = "mcclans.user.coords")
public void clanCoordsCommand(CommandSource commandSource, ClanPlayerImpl clanPlayer, @PageParameter int page) {
    ClanImpl clan = clanPlayer.getClan();
    List<Player> onlineMembers = new ArrayList<Player>();
    List<ClanPlayerImpl> members = clan.getMembersImpl();
    for (ClanPlayerImpl member : members) {
        Optional<Player> playerOpt = Sponge.getServer().getPlayer(member.getUUID());
        if (playerOpt.isPresent() && playerOpt.get().isOnline()) {
            onlineMembers.add(playerOpt.get());
        }
    }
    java.util.Collections.sort(members, new MemberComparator());

    HorizontalTable<Player> table = new HorizontalTable<Player>("Clan coordinates " + clan.getName(), 10, (row, player, index) -> {
        if (player.isOnline()) {
            Location<World> location = player.getLocation();
            row.setValue("Player", Text.of(player.getName()));
            row.setValue("Location", Utils.formatLocation(location));

        }
    });
    table.defineColumn("Player", 30);
    table.defineColumn("Location", 30);

    table.draw(onlineMembers, page, commandSource);
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:27,代码来源:ClanCommands.java

示例9: loadedClan

import org.spongepowered.api.Sponge; //导入依赖的package包/类
protected void loadedClan(int clanID, String clanTag, String clanName, int ownerID, String tagColorId, boolean allowAllyInvites,
                          boolean ffProtection, long creationTime, String homeWorld, double homeX, double homeY, double homeZ, float homeYaw, float homePitch,
                          int homeSetTimes, long homeLastSetTimeStamp, String bankId) {
    ClanImpl clan = new ClanImpl.Builder(clanID, clanTag, clanName).tagColor(Utils.getTextColorById(tagColorId, Config.getColor(Config.CLAN_TAG_DEFAULT_COLOR))).acceptAllyInvites(allowAllyInvites)
            .ffProtection(ffProtection).creationTime(creationTime).homeSetTimes(homeSetTimes).homeLastSetTimeStamp(homeLastSetTimeStamp).bankId(bankId).build();
    if (homeWorld != null && Sponge.getServer().getWorld(UUID.fromString(homeWorld)).isPresent()) {
        // TODO SPONGE homeYaw, homePitch
        clan.setHomeInternal(new Location<>(Sponge.getServer().getWorld(UUID.fromString(homeWorld)).get(), homeX, homeY, homeZ));
    }

    clan.addRank(RankFactory.getInstance().createOwner());
    clan.addRank(RankFactory.getInstance().createRecruit());

    clanOwners.put(clanID, ownerID);
    clans.put(clanID, clan);

    checkHighestUsedClanID(clanID);
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:19,代码来源:DataLoader.java

示例10: SpongeStats

import org.spongepowered.api.Sponge; //导入依赖的package包/类
public SpongeStats(MCMarketApi marketApi, PluginContainer plugin) {
    super(marketApi);

    Sponge.getEventManager().registerListeners(plugin, this);

    Timer timer = new Timer(true);
    timer.scheduleAtFixedRate(new TimerTask() {

        @Override
        public void run() {
            if (!Sponge.getPluginManager().isLoaded(plugin.getId())) {
                timer.cancel();
                return;
            }

            Sponge.getScheduler().createTaskBuilder().execute(() -> runEventsSender()).submit(plugin);
        }
    }, 1000 * 10, 1000 * 60);
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:20,代码来源:SpongeStats.java

示例11: onReload

import org.spongepowered.api.Sponge; //导入依赖的package包/类
@Listener
public void onReload(GameReloadEvent event)
{
    try
    {
        MessageReceiver src = event.getCause().first(CommandSource.class).orElse(Sponge.getServer().getConsole());
        src.sendMessage(this.translation.take("virtualchest.reload.start"));
        this.loadConfig();
        this.saveConfig();
        src.sendMessage(this.translation.take("virtualchest.reload.finish"));
    }
    catch (IOException e)
    {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:17,代码来源:VirtualChestPlugin.java

示例12: registerDatabasePollingTask

import org.spongepowered.api.Sponge; //导入依赖的package包/类
private void registerDatabasePollingTask() {
    int delayInSeconds = 3600;
    int delayInTicks = delayInSeconds * 20;

    Task.Builder taskBuilder = Sponge.getScheduler().createTaskBuilder();
    taskBuilder.execute(new Runnable() {
        @Override
        public void run() {
            if (!DatabaseConnectionOwner.getInstance().isValid()) {
                DatabaseConnectionOwner.getInstance().setupConnection();
            }
        }
    });
    taskBuilder.delayTicks(delayInTicks).intervalTicks(delayInTicks).submit(MCClans.getPlugin());

    getLogger().info("Registered database polling task to run every " + delayInSeconds + "s (" + delayInSeconds / 3600 + "h)", false);
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:18,代码来源:MCClans.java

示例13: initEconomyService

import org.spongepowered.api.Sponge; //导入依赖的package包/类
private boolean initEconomyService() {
    Optional<ProviderRegistration<EconomyService>> economyServiceOpt = Sponge.getServiceManager().getRegistration(EconomyService.class);
    if (economyServiceOpt.isPresent()) {
        economyService = economyServiceOpt.get().getProvider();
        String currencyName = Config.getString(Config.CURRENCY);
        if (currencyName.equalsIgnoreCase("default")) {
            currency = economyService.getDefaultCurrency();
        } else {
            for (Currency checkCurrency : economyService.getCurrencies()) {
                if (currencyName.equalsIgnoreCase(checkCurrency.getDisplayName().toPlain())) {
                    currency = checkCurrency;
                    break;
                }
            }
            if (currency == null) {
                currency = economyService.getDefaultCurrency();
                getPlugin().getLogger().warn("Currency " + currencyName + " not found, falling back to default currency", false);
            }
        }
        return true;
    } else {
        return false;
    }
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:25,代码来源:MCClans.java

示例14: complete

import org.spongepowered.api.Sponge; //导入依赖的package包/类
@Override
public List<String> complete(CommandSource src, CommandArgs args, CommandContext context) {
    try {
        String arg = args.peek().toLowerCase();
        return Sponge.getRegistry().getAllOf(this.type).stream()
            .filter(x ->
                x.getId().startsWith(arg)
                || x.getId().startsWith("happytrails:" + arg)
            )
            .filter(x -> {
                final String trimmedId = x.getId().contains(":") ? x.getId().split(":")[1] : x.getId();
                return src.hasPermission(this.permissionPrefix + trimmedId);
            })
            .map(CatalogType::getId)
            .collect(Collectors.toList());
    } catch (Exception e) {
        return Sponge.getRegistry().getAllOf(this.type).stream().map(CatalogType::getId).collect(Collectors.toList());
    }
}
 
开发者ID:gabizou,项目名称:HappyTrails,代码行数:20,代码来源:TrailCommands.java

示例15: startSubmitting

import org.spongepowered.api.Sponge; //导入依赖的package包/类
private void startSubmitting() {
    // We use a timer cause want to be independent from the server tps
    final Timer timer = new Timer(true);
    timer.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            // Plugin was disabled, e.g. because of a reload (is this even possible in Sponge?)
            if (!Sponge.getPluginManager().isLoaded(plugin.getId())) {
                timer.cancel();
                return;
            }
            // The data collection (e.g. for custom graphs) is done sync
            // Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
            Scheduler scheduler = Sponge.getScheduler();
            Task.Builder taskBuilder = scheduler.createTaskBuilder();
            taskBuilder.execute(() -> submitData()).submit(plugin);
        }
    }, 1000*60*5, 1000*60*30);
    // Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
    // WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
    // WARNING: Just don't do it!
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:23,代码来源:Metrics.java


注:本文中的org.spongepowered.api.Sponge类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。