Advertisement
Ghaz-ranka

Untitled

May 20th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. @Plugin(id = "esiniacore", name = "Esinia Core", version = "1.0")
  2. public class Esinia {
  3.  
  4. @Inject
  5. @DefaultConfig(sharedRoot = true)
  6. private ConfigurationNode root;
  7.  
  8. @Inject
  9. @DefaultConfig(sharedRoot = true)
  10. private Path defaultConfig;
  11.  
  12. @Inject
  13. @DefaultConfig(sharedRoot = true)
  14. ConfigurationLoader<CommentedConfigurationNode> configManager;
  15.  
  16. @Inject
  17. @ConfigDir(sharedRoot = false)
  18. private Path privateConfigDir;
  19.  
  20. @Inject
  21. Game game;
  22.  
  23. @Inject
  24. private Logger logger;
  25.  
  26. public Logger getLogger(){
  27. return logger;
  28.  
  29. }
  30.  
  31.  
  32. @Listener
  33.  
  34. public void onServerStart(GameStartedServerEvent event) {
  35.  
  36. if (!Files.exists(defaultConfig)) {
  37. try {
  38. Files.createFile(defaultConfig);
  39.  
  40. } catch (IOException e) {
  41. e.printStackTrace();
  42. }
  43. try {
  44. root = configManager.load();
  45. } catch (IOException e1) {
  46. // TODO Auto-generated catch block
  47. e1.printStackTrace();
  48. }
  49. }
  50.  
  51.  
  52. this.getLogger().info("Loading...");
  53.  
  54. CommandSpec esiniaCommandSpec = CommandSpec.builder()
  55. .description(Text.of("Says different things based on the source"))
  56. .executor(new EsiniaCoreExecutor())
  57. .build();
  58.  
  59. CommandSpec esiniaItemTyperCommandSpec = CommandSpec.builder()
  60. .description(Text.of("Says the item type of held item"))
  61. .executor(new EsiniaCoreItemTyper())
  62. .build();
  63.  
  64. CommandSpec esiniaitemnamerCommandSpec = CommandSpec.builder()
  65. .description(Text.of("Changes the name of player's held item."))
  66. .arguments(
  67. GenericArguments.catalogedElement(Text.of("color"), CatalogTypes.TEXT_COLOR),
  68. GenericArguments.remainingJoinedStrings(Text.of("name")))
  69. .executor(new EsiniaCoreItemNamer())
  70. .build();
  71.  
  72. CommandSpec esinialorenamerCommandSpec = CommandSpec.builder()
  73. .description(Text.of("Changes the lore of player's held item."))
  74. .arguments(
  75. GenericArguments.allOf(GenericArguments.string(Text.of("lore"))))
  76. .executor(new EsiniaCoreLoreNamer())
  77. .build();
  78. //Commands
  79. Sponge.getCommandManager().register(this, esiniaCommandSpec, Lists.newArrayList("Esinia"));
  80. Sponge.getCommandManager().register(this, esiniaItemTyperCommandSpec, Lists.newArrayList("ItemTyper"));
  81. Sponge.getCommandManager().register(this, esiniaitemnamerCommandSpec, Lists.newArrayList("ItemNamer"));
  82. Sponge.getCommandManager().register(this, esinialorenamerCommandSpec, Lists.newArrayList("LoreNamer"));
  83. //Events
  84. game.getEventManager().registerListeners(this, new EventBlockBreak());
  85. game.getEventManager().registerListeners(this, new EventBlockPlace());
  86. game.getEventManager().registerListeners(this, new EventDecay());
  87. game.getEventManager().registerListeners(this, new EventItemDrop());
  88. game.getEventManager().registerListeners(this, new EventSpawnEntity());
  89. game.getEventManager().registerListeners(this, new EventRightClick());
  90. game.getEventManager().registerListeners(this, new EventInventoryClick());
  91. game.getEventManager().registerListeners(this, new EventInventoryOpen());
  92. //Anvils
  93. game.getEventManager().registerListeners(this, new AnvilStone());
  94. //Anvil Inventories
  95. game.getEventManager().registerListeners(this, new AnvilStoneInventory());
  96.  
  97. //Crafting Tables
  98. game.getEventManager().registerListeners(this, new CraftingTablesRudimentary());
  99. //Crafting Table Inventories
  100. game.getEventManager().registerListeners(this, new CraftingTablesRudimentaryInventory());
  101.  
  102. this.getLogger().info("Hello World");
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement