本文整理汇总了Java中org.spongepowered.api.event.game.state.GameInitializationEvent类的典型用法代码示例。如果您正苦于以下问题:Java GameInitializationEvent类的具体用法?Java GameInitializationEvent怎么用?Java GameInitializationEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GameInitializationEvent类属于org.spongepowered.api.event.game.state包,在下文中一共展示了GameInitializationEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onServerInitialization
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的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,"=========================================="));
}
示例2: init
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener(order=Order.FIRST)
public void init(GameInitializationEvent event) { instance = this; //myL=L.createLang(this);
reload();
Sponge.getServiceManager().setProvider(this, LanguageService.class, new LanguageServiceProvider());
l("The LanguageService is now available!");
Map<String, String> listMap = new HashMap<>();
for (String al : available) listMap.put(al, al);
Sponge.getCommandManager().register(this, CommandSpec.builder().arguments(GenericArguments.onlyOne(GenericArguments.choices(Text.of("Language"), listMap))).executor(new CommandExecutor() {
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
if (!(src instanceof Player)) { src.sendMessage(Text.of("Only available for players")); return CommandResult.success(); }
Optional<String> la = args.<String>getOne("Language");
if (!la.isPresent()) {
src.sendMessage(Text.of(playerLang.get(((Player)src).getUniqueId()).toString()));
} else {
String lang = la.get();
lang = lang.replace('_', '-'); //Locales toString used a underscore but the language tag requires a dash
Locale locale = Locale.forLanguageTag(lang);
playerChangedLang(((Player)src).getProfile(), locale);
}
return CommandResult.success();
}
}).build(), "language");
}
示例3: onInit
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener
public void onInit(GameInitializationEvent event) {
File configDirFile = configDir.toFile();
File configFile = new File(configDirFile, "rpchat.cfg");
if (!configDirFile.exists() && !configDirFile.mkdirs()) {
logger.severe("Failed to create config directory!!");
return;
}
config = new Config(configFile);
DefaultMessageVars.init(this);
Sponge.getCommandManager().register(this, MuteCommand.MUTE_SPEC, "mute");
Sponge.getCommandManager().register(this, MuteCommand.UNMUTE_SPEC, "unmute");
}
示例4: onInitCore
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener
public void onInitCore(GameInitializationEvent event) {
SpongeDataManager manager = SpongeDataManager.getInstance();
manager.registerDataProcessorAndImpl(AuraNodeData.class, ThaumicAuraNodeData.class, ImmutableAuraNodeData.class,
ImmutableThaumicAuraNodeData.class, new AuraNodeDataProcessor());
manager.registerDataProcessorAndImpl(WarpData.class, ThaumicWarpData.class, ImmutableWarpData.class, ImmutableThaumicWarpData.class,
new PlayerWarpDataProcessor());
CommandManager commandManager = Sponge.getCommandManager();
CommandSpec discoAuraCmd = CommandSpec.builder()
.arguments(GenericArguments.none())
.description(Text.of("Creates a new Aura node and turns it into a disco ball!"))
.executor((executor, args) -> {
if (executor instanceof Player) {
Entity auraNode = ((Player) executor).getLocation().getExtent().createEntity(ThaumicEntityTypes.AURA_NODE, ((Player) executor).getLocation().getPosition()).get();
AuraNodeData nodeData = new ThaumicAuraNodeData(50, Aspects.AER, false, AuraNodeTypes.NORMAL);
auraNode.offer(nodeData);
auraNode.getWorld().spawnEntity(auraNode, Cause.of(NamedCause.source(this)));
this.auraMap.put(auraNode.getWorld().getUniqueId(), auraNode.getUniqueId());
return CommandResult.success();
}
return CommandResult.empty();
})
.build();
commandManager.register(this, discoAuraCmd, "disco");
}
示例5: onInitialization
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener
public void onInitialization(GameInitializationEvent event)
{
Sponge.getEventManager().registerListener(this, ClientPingServerEvent.class, e ->
{
Optional<ClientPingServerEvent.Response.Players> optional = e.getResponse().getPlayers();
if (optional.isPresent())
{
ClientPingServerEvent.Response.Players players = optional.get();
if (this.fixed)
{
players.setOnline(Math.min(this.value - 1, players.getOnline()));
players.setMax(this.value);
}
else
{
players.setMax(players.getOnline() + this.value);
}
}
});
}
示例6: enable
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener
public void enable(GameInitializationEvent event) {
this.taskBuilder = Sponge.getScheduler().createTaskBuilder();
try {
if ( ! Files.exists(privateConfigDir)) {
Files.createDirectories(privateConfigDir);
}
Config.get().load().save().update();
} catch (Exception e) {
e.printStackTrace();
}
Sponge.getEventManager().registerListeners(this, SilkTouchListener.get());
// Add our adapter for backpack
Backpack.addAsAdapter();
}
示例7: onServerInit
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener
public void onServerInit(GameInitializationEvent event) {
instance = this;
customSerializer.registerType(TypeToken.of(StockItem.class), new StockItemSerializer());
customSerializer.registerType(TypeToken.of(NPCguard.class), new NPCguardSerializer());
Sponge.getEventManager().registerListeners(this, new EventListeners());
try {
//trick here:
// if we can't get the class for name an exception is thrown preventing the real depending code from even being looked at.
// this requires the entry point to not be obfuscated, but for an API that's normally not the case anyways.
Class<?> webAPIAPI = Class.forName("valandur.webapi.api.WebAPIAPI");
if (webAPIAPI != null) WebAPI.init();
} catch(Exception e) {
l("WebAPI not found, skipping");
}
}
示例8: hookChannels
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener
public void hookChannels(GameInitializationEvent event) {
Game game = event.getGame();
Server server = game.getServer();
Method getNetworkSystem = null;
for (Method m : server.getClass().getMethods()) {
if ("net.minecraft.network.NetworkSystem".equals(m.getReturnType().getName())) {
getNetworkSystem = m;
}
}
if (getNetworkSystem == null) {
throw new RuntimeException("Could not find getNetworkSystem in " + server);
}
try {
Object networkSystem = getNetworkSystem.invoke(server);
SpongeChannelInitializer channelInitializer = new SpongeChannelInitializer(game);
@SuppressWarnings("unchecked")
List<ChannelFuture> endpoints = (List) Reflection.getField(networkSystem.getClass(), "field_151274_e", networkSystem);
for (ChannelFuture endpoint : endpoints) {
endpoint.channel().pipeline().addFirst(channelInitializer);
}
} catch (IllegalAccessException | NoSuchFieldException | InvocationTargetException e) {
e.printStackTrace();
}
}
示例9: onGameInitialization
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener
public void onGameInitialization(GameInitializationEvent e) {
final WeatherBuilder builder = e.getGame().getRegistry().createBuilder(WeatherBuilder.class);
// Register some test weathers
builder.reset().plugin(this).name("mizzle")
.darkness(0.1f).rainStrength(0.2f).buildAndRegister();
builder.reset().plugin(this).name("drizzle")
.darkness(0.13f).rainStrength(0.3f).buildAndRegister();
builder.reset().plugin(this).name("light_rain")
.darkness(0.2f).rainStrength(0.6f).buildAndRegister();
builder.reset().plugin(this).name("medium_rain")
.darkness(0.4f).rainStrength(1.0f).buildAndRegister();
builder.reset().plugin(this).name("heavy_rain")
.darkness(0.5f).rainStrength(1.3f).buildAndRegister();
builder.reset().plugin(this).name("storm")
.darkness(1.0f).rainStrength(1.0f).lightningRate(0.00003f).buildAndRegister();
builder.reset().plugin(this).name("heavy_storm")
.darkness(1.3f).rainStrength(1.3f).lightningRate(0.0001f).buildAndRegister();
}
示例10: onStart
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener
public void onStart(GameInitializationEvent event) {
this.logger.info("Test Recipes plugin enabled!");
final GameRegistry gameRegistry = Sponge.getGame().getRegistry();
gameRegistry.getCraftingRecipeRegistry().register(CraftingRecipe.shapedBuilder()
.aisle("xy", "yx")
.where('x', Ingredient.of(ItemTypes.APPLE))
.where('y', Ingredient.of(ItemTypes.GOLD_NUGGET))
.result(ItemStack.of(ItemTypes.GOLDEN_APPLE, 2))
.build("golden_apples", this));
gameRegistry.getSmeltingRecipeRegistry().register(SmeltingRecipe.builder()
.ingredient(ItemTypes.GOLDEN_APPLE)
.result(ItemStack.of(ItemTypes.GOLD_NUGGET, 1))
.build());
}
示例11: onStart
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener
public void onStart(GameInitializationEvent event) {
this.logger.info("TestCommand plugin enabled!");
Sponge.getCommandManager().register(this, CommandSpec.builder()
.executor((src, args) -> {
final Text message = Text.of(TextColors.GREEN, TextStyles.UNDERLINE, "Test", TextStyles.RESET, " 1234");
if (src instanceof Player) {
((Player) src).sendTitle(Title.builder().subtitle(message).build());
} else {
src.sendMessage(message);
}
return CommandResult.success();
})
.build(), "test-command", "tc");
}
示例12: onServerInitialize
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener
public void onServerInitialize(GameInitializationEvent event) {
logger.info("JobsLite " + version + " by Flibio initializing!");
initializeFiles();
// Initialize the player and job managers
boolean flatfile = true;
if (optionEnabled("mysql.enabled")) {
// Load the remote managers
RemotePlayerManager tempPlayerManager =
new RemotePlayerManager(getOption("mysql.hostname"), getOption("mysql.port"), getOption("mysql.database"),
getOption("mysql.username"), getOption("mysql.password"));
RemoteJobManager tempJobManager =
new RemoteJobManager(getOption("mysql.hostname"), getOption("mysql.port"), getOption("mysql.database"),
getOption("mysql.username"), getOption("mysql.password"));
if (tempPlayerManager.isWorking() && tempJobManager.isWorking()) {
playerManager = tempPlayerManager;
jobManager = tempJobManager;
flatfile = false;
}
}
if (flatfile) {
// Load the local managers
playerManager = new LocalPlayerManager();
jobManager = new LocalJobManager();
}
}
示例13: onInit
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener
public void onInit(GameInitializationEvent initEvent) {
//register events
Sponge.getEventManager().registerListeners(this, new ConnectionListener(this));
Sponge.getEventManager().registerListeners(this, new PlayerListener(this));
//register commands
CommandManager commandDispatcher = Sponge.getCommandManager();
CommandSpec statsCommand = CommandSpec.builder()
.executor(injector.getInstance(StatsCommand.class))
.permission(PomData.ARTIFACT_ID + ".command.stats")
.arguments(GenericArguments
.onlyOne(GenericArguments
.playerOrSource(Text.of("target"))))
.build();
commandDispatcher.register(this, statsCommand, PomData.ARTIFACT_ID, "stats", "pvpstats");
CommandSpec topCommand = CommandSpec.builder()
.executor(injector.getInstance(TopCommand.class))
.permission(PomData.ARTIFACT_ID + ".command.top")
.arguments(GenericArguments
.optional(GenericArguments
.integer(Text.of("page")), 1))
.build();
commandDispatcher.register(this, topCommand, "top", "topstats");
}
示例14: onEnable
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener
public void onEnable(GameInitializationEvent event)
{
i18n.getCompositor().registerFormatter(new RoleFormatter());
cm.getProviders().register(this, new RoleParser(service), FileSubject.class);
cm.getProviders().register(this, new DefaultPermissionValueProvider(), Tristate.class);
cm.getProviders().register(this, new PermissionCompleter(service));
RoleCommands cmdRoles = new RoleCommands(cm);
cm.addCommand(cmdRoles);
RoleManagementCommands cmdRole = new RoleManagementCommands(cm, service, i18n);
cmdRoles.addCommand(cmdRole);
cm.addCommands(cmdRole, this, new RoleInformationCommands(cm, service, i18n));
UserManagementCommands cmdUsers = new UserManagementCommands(cm, service, i18n);
cmdRoles.addCommand(cmdUsers);
cm.addCommands(cmdUsers, this, new UserInformationCommands(cm, i18n, service));
cmdRoles.addCommand(new ManagementCommands(cm, this, service, i18n, plugin));
}
示例15: onEnable
import org.spongepowered.api.event.game.state.GameInitializationEvent; //导入依赖的package包/类
@Listener
public void onEnable(GameInitializationEvent event)
{
this.tf = mm.getThreadFactory(Vigil.class);
ReportManager reportManager = new ReportManager(this, em, i18n);
qm = new QueryManager(tf, bd.getDatabase().getCollection("vigil"), reportManager, i18n, plugin);
this.cm.getProviders().register(this, new LookupDataParser(i18n), LookupData.class);;
VigilCommands vc = new VigilCommands(sm, i18n, cm);
cm.addCommand(vc);
vc.addCommand(new VigilAdminCommands(cm, i18n, this));
cm.addCommands(vc, this, new VigilLookupCommands(cm, i18n, qm));
em.registerListener(Vigil.class, new ToolListener(pm, qm));
DataRegistration<LookupData, ImmutableLookupData> dr =
DataRegistration.<LookupData, ImmutableLookupData>builder()
.dataClass(LookupData.class).immutableClass(ImmutableLookupData.class)
.builder(new LookupDataBuilder()).manipulatorId("vigil-lookup")
.dataName("CubeEngine vigil Lookup Data")
.buildAndRegister(plugin);
}