Ghaz-ranka

Untitled

May 19th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. package com.esinia.server;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.nio.file.Files;
  6. import java.nio.file.Path;
  7. import org.slf4j.Logger;
  8. import org.spongepowered.api.CatalogTypes;
  9. import org.spongepowered.api.Game;
  10. import org.spongepowered.api.Sponge;
  11. import org.spongepowered.api.command.args.GenericArguments;
  12. import org.spongepowered.api.command.spec.CommandSpec;
  13. import org.spongepowered.api.config.ConfigDir;
  14. import org.spongepowered.api.config.DefaultConfig;
  15. import org.spongepowered.api.event.Listener;
  16. import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
  17. import org.spongepowered.api.event.game.state.GameStartedServerEvent;
  18. import org.spongepowered.api.plugin.Plugin;
  19. import org.spongepowered.api.text.Text;
  20.  
  21. import com.esinia.server.anvils.AnvilStone;
  22. import com.esinia.server.commands.EsiniaCoreExecutor;
  23. import com.esinia.server.commands.EsiniaCoreItemNamer;
  24. import com.esinia.server.commands.EsiniaCoreItemTyper;
  25. import com.esinia.server.commands.EsiniaCoreLoreNamer;
  26. import com.esinia.server.craftingtables.CraftingTablesRudimentary;
  27. import com.esinia.server.events.EventBlockBreak;
  28. import com.esinia.server.events.EventBlockPlace;
  29. import com.esinia.server.events.EventDecay;
  30. import com.esinia.server.events.EventInventoryClick;
  31. import com.esinia.server.events.EventInventoryOpen;
  32. import com.esinia.server.events.EventItemDrop;
  33. import com.esinia.server.events.EventRightClick;
  34. import com.esinia.server.events.EventSpawnEntity;
  35. import com.esinia.server.invintories.anvils.AnvilStoneInventory;
  36. import com.esinia.server.invintories.craftingtables.CraftingTablesRudimentaryInventory;
  37. import com.google.common.collect.Lists;
  38. import com.google.inject.Inject;
  39.  
  40. import ninja.leaping.configurate.ConfigurationNode;
  41. import ninja.leaping.configurate.commented.CommentedConfigurationNode;
  42. import ninja.leaping.configurate.loader.ConfigurationLoader;
  43.  
  44.  
  45.  
  46. @Plugin(id = "esiniacore", name = "Esinia Core", version = "1.0")
  47. public class Esinia {
  48.  
  49. @Inject
  50. @DefaultConfig(sharedRoot = true)
  51. private Path path;
  52.  
  53. @Inject
  54. @DefaultConfig(sharedRoot = true)
  55. ConfigurationLoader<CommentedConfigurationNode> configManager;
  56.  
  57. @Inject
  58. @ConfigDir(sharedRoot = false)
  59. private Path privateConfigDir;
  60.  
  61. @Inject
  62. Game game;
  63.  
  64. @Inject
  65. private Logger logger;
  66.  
  67. public Logger getLogger(){
  68. return logger;
  69.  
  70. }
  71.  
  72.  
  73. @Listener
  74. public void onServerStart(GameStartedServerEvent event) {
  75. if (!Files.exists(path)) {
  76. try {
  77. Files.createFile(path);
  78. } catch (IOException e) {
  79. e.printStackTrace();
  80. }
  81. }
  82.  
  83. this.getLogger().info("Loading...");
  84.  
  85. CommandSpec esiniaCommandSpec = CommandSpec.builder()
  86. .description(Text.of("Says different things based on the source"))
  87. .executor(new EsiniaCoreExecutor())
  88. .build();
  89.  
  90. CommandSpec esiniaItemTyperCommandSpec = CommandSpec.builder()
  91. .description(Text.of("Says the item type of held item"))
  92. .executor(new EsiniaCoreItemTyper())
  93. .build();
  94.  
  95. CommandSpec esiniaitemnamerCommandSpec = CommandSpec.builder()
  96. .description(Text.of("Changes the name of player's held item."))
  97. .arguments(
  98. GenericArguments.catalogedElement(Text.of("color"), CatalogTypes.TEXT_COLOR),
  99. GenericArguments.remainingJoinedStrings(Text.of("name")))
  100. .executor(new EsiniaCoreItemNamer())
  101. .build();
  102.  
  103. CommandSpec esinialorenamerCommandSpec = CommandSpec.builder()
  104. .description(Text.of("Changes the lore of player's held item."))
  105. .arguments(
  106. GenericArguments.allOf(GenericArguments.string(Text.of("lore"))))
  107. .executor(new EsiniaCoreLoreNamer())
  108. .build();
  109.  
  110. Sponge.getCommandManager().register(this, esiniaCommandSpec, Lists.newArrayList("Esinia"));
  111. Sponge.getCommandManager().register(this, esiniaItemTyperCommandSpec, Lists.newArrayList("ItemTyper"));
  112. Sponge.getCommandManager().register(this, esiniaitemnamerCommandSpec, Lists.newArrayList("ItemNamer"));
  113. Sponge.getCommandManager().register(this, esinialorenamerCommandSpec, Lists.newArrayList("LoreNamer"));
  114. //Events
  115. game.getEventManager().registerListeners(this, new EventBlockBreak());
  116. game.getEventManager().registerListeners(this, new EventBlockPlace());
  117. game.getEventManager().registerListeners(this, new EventDecay());
  118. game.getEventManager().registerListeners(this, new EventItemDrop());
  119. game.getEventManager().registerListeners(this, new EventSpawnEntity());
  120. game.getEventManager().registerListeners(this, new EventRightClick());
  121. game.getEventManager().registerListeners(this, new EventInventoryClick());
  122. game.getEventManager().registerListeners(this, new EventInventoryOpen());
  123. //Anvils
  124. game.getEventManager().registerListeners(this, new AnvilStone());
  125. //Anvil Inventories
  126. game.getEventManager().registerListeners(this, new AnvilStoneInventory());
  127. //Crafting Tables
  128. game.getEventManager().registerListeners(this, new CraftingTablesRudimentary());
  129. //Crafting Table Inventories
  130. game.getEventManager().registerListeners(this, new CraftingTablesRudimentaryInventory());
  131.  
  132. this.getLogger().info("Hello World");
  133. }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment