本文整理汇总了Java中org.spongepowered.api.event.game.state.GameStartingServerEvent类的典型用法代码示例。如果您正苦于以下问题:Java GameStartingServerEvent类的具体用法?Java GameStartingServerEvent怎么用?Java GameStartingServerEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GameStartingServerEvent类属于org.spongepowered.api.event.game.state包,在下文中一共展示了GameStartingServerEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onServerStart
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Listener
public void onServerStart(GameStartingServerEvent event) {
Sponge.getCommandManager().register(this, CommandSpec.builder()
.description(Text.of("Gets info on the user."))
.arguments(flags()
.permissionFlag("whois.all", ALL, "-all")
.permissionFlag("whois.address", IP, "-ip")
.flag(FIRST, "-firstjoined")
.flag(LAST, "-lastjoined")
.flag(WORLD, "-world")
.flag(COORDINATES, "-coords")
.flag(GAMEMODE, "-gamemode")
.flag(BAN, "-ban")
.buildWith(optional(user(KEY_USER))))
.permission("whois.command")
.executor(this::whois)
.build(), "whois");
}
示例2: onServerStarted
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Subscribe
public void onServerStarted(GameStartingServerEvent event) throws IOException {
channel = game.getChannelRegistrar().createRawChannel(this, CHANNEL);
if (!defaultConfig.exists()) {
InputStream in = getClass().getResourceAsStream("/config.conf");
FileOutputStream out = new FileOutputStream(defaultConfig);
out.getChannel().transferFrom(Channels.newChannel(in), 0, Long.MAX_VALUE);
out.close();
in.close();
}
ConfigurationNode config = HoconConfigurationLoader.builder().setFile(defaultConfig).build().load();
global.putAll(loadRestrictions(config));
ConfigurationNode worlds = config.getNode("worlds");
if (!worlds.isVirtual()) {
for (ConfigurationNode world : worlds.getChildrenList()) {
Map<String, Object> worldRestrictions = new HashMap<>(global);
worldRestrictions.putAll(loadRestrictions(world));
this.worlds.put(world.getKey().toString(), worldRestrictions);
}
}
}
示例3: onServerInitialize
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Listener
public void onServerInitialize(GameStartingServerEvent event) {
logger.info("Ultimate Spleef is enabling!");
access = this;
minigame = Minigame.create("UltimateSpleef", this).get();
messageStorage = MessageStorage.createInstance(this);
messageStorage.defaultMessages("messages");
CommandLoader.registerCommands(this, TextSerializers.FORMATTING_CODE.serialize(messageStorage.getMessage("command.invalidsource")),
new SpleefCommand(),
new CreateCommand()
);
for (ArenaData arenaData : minigame.getArenaManager().loadArenaData()) {
Optional<UArena> uarena = UArena.createArena(arenaData.getName(), arenaData);
if (uarena.isPresent())
minigame.getArenaManager().addArena(uarena.get());
}
if (!minigame.getEconomyManager().foundEconomy()) {
logger.warn("Could not find an economy plugin! Players will not be rewarded!");
}
}
示例4: onServerStarting
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Listener
public void onServerStarting(GameStartingServerEvent event) {
// https://docs.spongepowered.org/stable/en/plugin/lifecycle.html
// "The server instance exists, and worlds are loaded"
webSocketServerThread = new WebSocketServerThread(settings);
/* TODO: factor out bukkit
webSocketServerThread.blockBridge = new BlockBridge(webSocketServerThread, settings);
webSocketServerThread.playersBridge = new PlayersBridge(webSocketServerThread, settings);
webSocketServerThread.webPlayerBridge = new WebPlayerBridge(webSocketServerThread, settings);
*/
/* TODO: write for sponge
// Register our events
PluginManager pm = getServer().getPluginManager();
pm.registerEvents(new BlockListener(webSocketServerThread.blockBridge), plugin);
pm.registerEvents(new PlayersListener(webSocketServerThread.playersBridge), plugin);
pm.registerEvents(new EntityListener(webSocketServerThread.webPlayerBridge), plugin);
// Register our commands
getCommand("websandbox").setExecutor(new WsCommand(webSocketServerThread, settings.usePermissions));
*/
// Run the websocket server
webSocketServerThread.start();
}
示例5: onStartingServer
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Listener
public void onStartingServer(GameStartingServerEvent event)
{
this.virtualChestCommandManager.init();
this.economyManager.init();
this.permissionManager.init();
this.virtualChestActions.init();
this.placeholderManager.init();
}
示例6: onServerStart
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Listener
public void onServerStart(GameStartingServerEvent event) {
this.abilityManager = new AbilityManager(this);
this.sequenceManager = new SequenceManager(this.abilityManager, this);
this.abilityService = new AbilityService(this, this.abilityManager);
this.sequenceService = new SequenceService(this, this.sequenceManager);
this.userService = new UserService(this);
this.services.add(this.abilityService);
this.services.add(this.sequenceService);
this.services.add(this.userService);
this.services.forEach(Service::start);
}
示例7: onServerStarting
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Listener
public void onServerStarting(GameStartingServerEvent event)
{
GlobalCommands globalCommands = new GlobalCommands(this);
CommandSpec map = CommandSpec.builder()
.description(Text.of("All commands related to the chunk protection"))
.executor(globalCommands::map)
.build();
CommandSpec claim = CommandSpec.builder()
.description(Text.of("Claims the chunk that you are standing"))
.executor(globalCommands::claim)
.build();
CommandSpec chunk = CommandSpec.builder()
.description(Text.of("Commands related to chunk protection"))
.child(map, "map")
.child(claim, "claim")
.build();
CommandSpec mychunk = CommandSpec.builder()
.description(Text.of("All mychunk commands"))
.child(chunk, "chunk", "c")
.build();
Sponge.getCommandManager().register(this, chunk, "chunk");
Sponge.getCommandManager().register(this, mychunk, "mychunk");
}
示例8: onPluginLoaded
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Listener
public void onPluginLoaded(GameStartingServerEvent event) {
logger.info("I'm loaded! ;)");
CommandSpec myCommandSpec = CommandSpec.builder()
.description(Text.of("Hello World Command"))
.executor(new HelloWorldCommand())
.build();
commandMapping = game.getCommandManager().register(plugin, myCommandSpec, "hello");
}
示例9: onServerStarting
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Listener
public void onServerStarting(GameStartingServerEvent event) {
logger.info("hello ServerStartingEvent from MyFirstSpongePlugIn!");
// https://docs.spongepowered.org/en/plugin/basics/commands/creating.html
// https://github.com/SpongePowered/Cookbook/blob/master/Plugin/WorldEditingTest/src/main/java/org/spongepowered/cookbook/plugin/WorldEditingTest.java
WorldTeleportCommand worldTeleportCommand = new WorldTeleportCommand();
CommandCallable tpwCommandSpec = worldTeleportCommand.getCommandSpec(game);
// TODO put this into a superclass / @Inject helper of WorldTeleportCommand..
commandMapping = game.getCommandManager().register(plugin, tpwCommandSpec , "tpw" ,"tpworld");
if (!commandMapping.isPresent()) {
logger.error("/tpw Command could not be registered!! :-(");
}
}
示例10: onServerStarting
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Listener
public void onServerStarting(GameStartingServerEvent event) {
this.commandService = game.getCommandManager();
commandRegistry.register(CommandSpec.builder().description(Text.of("repeat command N times")).arguments(
// GenericArguments.playerOrSource(Text.of("player"), game)
GenericArguments.integer(Text.of("n")),
GenericArguments.allOf(GenericArguments.string(Text.of("commandToRepeat")))
).executor(CommandExecutorAdapter.adapt((src, args) -> {
// Player player = (Player) src; // TODO if instanceof
Integer n = args.<Integer>getOne("n").get();
Collection<String> commandsToRepeat = args.<String>getAll("commandToRepeat");
this.x(src, n, commandsToRepeat.toArray(new String[0]));
})).build(), "x");
commandRegistry.register(CommandSpec.builder().description(Text.of("list all / register new / delete Alias command")).arguments(
// GenericArguments.playerOrSource(Text.of("player"), game)
GenericArguments.optional(GenericArguments.string(Text.of("cmd"))),
GenericArguments.optional(GenericArguments.remainingJoinedStrings(Text.of("commandsToAlias")))
).executor(CommandExecutorAdapter.adapt((src, args) -> {
// Player player = (Player) src; // TODO if instanceof
Optional<String> name = args.<String>getOne("cmd");
Optional<String> commandsToAlias = args.<String>getOne("commandsToAlias");
this.alias(src, name, commandsToAlias);
})).build(), "def", "alias");
}
示例11: onServerStarting
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Override
@Listener
public final void onServerStarting(GameStartingServerEvent event) {
super.onServerStarting(event);
commandManager.register(plugin, this);
onServerStarting();
}
示例12: onServerStarting
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Listener
public void onServerStarting(GameStartingServerEvent event) {
logger.info("hello ServerStartingEvent from MyFirstSpongePlugIn!");
CommandSpec commandSpec = CommandSpec.builder()
.arguments(optional(seq(player(Text.of("player")))))
.description(Text.of("Question!"))
// .permission("ch.vorburger.minecraft.learning.question")
.executor(new QuestionCommand())
.build();
commandMapping = Sponge.getCommandManager().register(plugin, commandSpec , "question");
if (!commandMapping.isPresent()) {
logger.error("Command could not be registered!! :-(");
}
}
示例13: onServerStarting
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
/**
* Runs when the server is starting.
*
* @param event The event
*/
@Listener
public void onServerStarting(GameStartingServerEvent event) {
if (isLoaded) {
// Once the server is starting, reset the text colour map.
HammerTextToTextColorCoverter.init();
}
}
示例14: onServerStarting
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Listener
public void onServerStarting(GameStartingServerEvent event) {
this.logger.info("Loading...");
this.cmdManager = new CommandManager(game, this);
this.logger.info("Loaded!");
}
示例15: init
import org.spongepowered.api.event.game.state.GameStartingServerEvent; //导入依赖的package包/类
@Listener
public void init(GameStartingServerEvent event) {
// Loads the config
BlockerManager.loadConfig(new File(configDir, "config.json"), new File(configDir, "doha-database.json"));
}