Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.esinia.server;
- import java.io.File;
- import java.io.IOException;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import org.slf4j.Logger;
- import org.spongepowered.api.CatalogTypes;
- import org.spongepowered.api.Game;
- import org.spongepowered.api.Sponge;
- import org.spongepowered.api.command.args.GenericArguments;
- import org.spongepowered.api.command.spec.CommandSpec;
- import org.spongepowered.api.config.ConfigDir;
- import org.spongepowered.api.config.DefaultConfig;
- import org.spongepowered.api.event.Listener;
- import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
- import org.spongepowered.api.event.game.state.GameStartedServerEvent;
- import org.spongepowered.api.plugin.Plugin;
- import org.spongepowered.api.text.Text;
- import com.esinia.server.anvils.AnvilStone;
- import com.esinia.server.commands.EsiniaCoreExecutor;
- import com.esinia.server.commands.EsiniaCoreItemNamer;
- import com.esinia.server.commands.EsiniaCoreItemTyper;
- import com.esinia.server.commands.EsiniaCoreLoreNamer;
- import com.esinia.server.craftingtables.CraftingTablesRudimentary;
- import com.esinia.server.events.EventBlockBreak;
- import com.esinia.server.events.EventBlockPlace;
- import com.esinia.server.events.EventDecay;
- import com.esinia.server.events.EventInventoryClick;
- import com.esinia.server.events.EventInventoryOpen;
- import com.esinia.server.events.EventItemDrop;
- import com.esinia.server.events.EventRightClick;
- import com.esinia.server.events.EventSpawnEntity;
- import com.esinia.server.invintories.anvils.AnvilStoneInventory;
- import com.esinia.server.invintories.craftingtables.CraftingTablesRudimentaryInventory;
- import com.google.common.collect.Lists;
- import com.google.inject.Inject;
- import ninja.leaping.configurate.ConfigurationNode;
- import ninja.leaping.configurate.commented.CommentedConfigurationNode;
- import ninja.leaping.configurate.loader.ConfigurationLoader;
- @Plugin(id = "esiniacore", name = "Esinia Core", version = "1.0")
- public class Esinia {
- @Inject
- @DefaultConfig(sharedRoot = true)
- private Path path;
- @Inject
- @DefaultConfig(sharedRoot = true)
- ConfigurationLoader<CommentedConfigurationNode> configManager;
- @Inject
- @ConfigDir(sharedRoot = false)
- private Path privateConfigDir;
- @Inject
- Game game;
- @Inject
- private Logger logger;
- public Logger getLogger(){
- return logger;
- }
- @Listener
- public void onServerStart(GameStartedServerEvent event) {
- if (!Files.exists(path)) {
- try {
- Files.createFile(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- this.getLogger().info("Loading...");
- CommandSpec esiniaCommandSpec = CommandSpec.builder()
- .description(Text.of("Says different things based on the source"))
- .executor(new EsiniaCoreExecutor())
- .build();
- CommandSpec esiniaItemTyperCommandSpec = CommandSpec.builder()
- .description(Text.of("Says the item type of held item"))
- .executor(new EsiniaCoreItemTyper())
- .build();
- CommandSpec esiniaitemnamerCommandSpec = CommandSpec.builder()
- .description(Text.of("Changes the name of player's held item."))
- .arguments(
- GenericArguments.catalogedElement(Text.of("color"), CatalogTypes.TEXT_COLOR),
- GenericArguments.remainingJoinedStrings(Text.of("name")))
- .executor(new EsiniaCoreItemNamer())
- .build();
- CommandSpec esinialorenamerCommandSpec = CommandSpec.builder()
- .description(Text.of("Changes the lore of player's held item."))
- .arguments(
- GenericArguments.allOf(GenericArguments.string(Text.of("lore"))))
- .executor(new EsiniaCoreLoreNamer())
- .build();
- Sponge.getCommandManager().register(this, esiniaCommandSpec, Lists.newArrayList("Esinia"));
- Sponge.getCommandManager().register(this, esiniaItemTyperCommandSpec, Lists.newArrayList("ItemTyper"));
- Sponge.getCommandManager().register(this, esiniaitemnamerCommandSpec, Lists.newArrayList("ItemNamer"));
- Sponge.getCommandManager().register(this, esinialorenamerCommandSpec, Lists.newArrayList("LoreNamer"));
- //Events
- game.getEventManager().registerListeners(this, new EventBlockBreak());
- game.getEventManager().registerListeners(this, new EventBlockPlace());
- game.getEventManager().registerListeners(this, new EventDecay());
- game.getEventManager().registerListeners(this, new EventItemDrop());
- game.getEventManager().registerListeners(this, new EventSpawnEntity());
- game.getEventManager().registerListeners(this, new EventRightClick());
- game.getEventManager().registerListeners(this, new EventInventoryClick());
- game.getEventManager().registerListeners(this, new EventInventoryOpen());
- //Anvils
- game.getEventManager().registerListeners(this, new AnvilStone());
- //Anvil Inventories
- game.getEventManager().registerListeners(this, new AnvilStoneInventory());
- //Crafting Tables
- game.getEventManager().registerListeners(this, new CraftingTablesRudimentary());
- //Crafting Table Inventories
- game.getEventManager().registerListeners(this, new CraftingTablesRudimentaryInventory());
- this.getLogger().info("Hello World");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment