Advertisement
-Chicken-

MainPluginFile.java

Feb 3rd, 2016
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.15 KB | None | 0 0
  1. package com.gmail.eliterscripts;
  2. import org.spongepowered.api.config.DefaultConfig;
  3. import org.spongepowered.api.entity.living.player.Player;
  4. import org.spongepowered.api.event.Listener;
  5. import org.spongepowered.api.event.command.SendCommandEvent;
  6. import org.spongepowered.api.event.game.state.GameStartedServerEvent;
  7. import org.spongepowered.api.event.network.ClientConnectionEvent;
  8. import org.spongepowered.api.event.server.ClientPingServerEvent;
  9. import org.spongepowered.api.plugin.Plugin;
  10. import org.spongepowered.api.plugin.PluginContainer;
  11. import org.spongepowered.api.text.*;
  12.  
  13. import com.gmail.eliterscripts.command.CommandManager;
  14. import com.google.inject.Inject;
  15.  
  16. import java.nio.file.Path;
  17. import java.util.Optional;
  18.  
  19. import org.slf4j.Logger;
  20.  
  21.  
  22. @Plugin(id = "announcer_plus", name = "AnnouncerPlus", version = "A0.0")
  23. public class MainPluginFile {
  24.    
  25.     MainPluginFile(){
  26.        
  27.     }
  28.    
  29.     @Inject
  30.     private static PluginContainer container;
  31.    
  32.     public static PluginContainer getContainer(){
  33.         return container;
  34.     }
  35.    
  36.     @Inject
  37.     private Logger logger;
  38.    
  39.     @Inject
  40.     @DefaultConfig(sharedRoot = false)
  41.     private static Path defaultConfig;
  42.    
  43.     public static Path getConfigPath(){
  44.         return defaultConfig;
  45.        
  46.     }
  47.    
  48.     public Logger getLogger(){
  49.         return logger;
  50.     }
  51.    
  52.     @Listener
  53.     public void onServerStart(GameStartedServerEvent event){
  54.         logger.info(container.getName() + " v" + container.getVersion() + " by EliterScripts loaded.");
  55.        
  56.         //CommandManager.RegisterAll();
  57.     }
  58.    
  59.     @Listener
  60.     public void onJoin(ClientConnectionEvent.Join event) {
  61.        
  62.         Player person = event.getTargetEntity();
  63.        
  64.         String person_name = person.getName();
  65.        
  66.         event.getTargetEntity().sendMessage(
  67.                 Text.of("Welcome ", person_name, " to the server!")
  68.         );
  69.        
  70.     }
  71.    
  72.     @Listener
  73.     public void lie (ClientPingServerEvent event){
  74.         event.getResponse().setDescription(Text.of("Hey, does it work now?"));
  75.         Optional<ClientPingServerEvent.Response.Players> stuff = event.getResponse().getPlayers();
  76.        
  77.         if(stuff.isPresent()){
  78.             stuff.get().setMax((Math.round(stuff.get().getOnline()/100)*100) + 100);
  79.         }
  80.     }
  81.    
  82.     public void onCommand(SendCommandEvent event){
  83.        
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement