Advertisement
Guest User

Untitled

a guest
Jan 9th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.54 KB | None | 0 0
  1. package fr.flashback083.gtm;
  2.  
  3. import java.io.IOException;
  4. import java.sql.SQLException;
  5. import java.util.Calendar;
  6. import java.util.GregorianCalendar;
  7.  
  8. import com.pixelmonmod.pixelmon.Pixelmon;
  9.  
  10. import fr.flashback083.commands.GTM;
  11. import fr.flashback083.config.SQL;
  12. import fr.flashback083.proxy.CommonProxy;
  13. import net.minecraftforge.common.MinecraftForge;
  14. import net.minecraftforge.common.config.Configuration;
  15. import net.minecraftforge.fml.common.Mod;
  16. import net.minecraftforge.fml.common.SidedProxy;
  17. import net.minecraftforge.fml.common.event.FMLInitializationEvent;
  18. import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
  19. import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
  20. import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
  21. import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
  22.  
  23.  
  24. @Mod(modid = Main.MODID, name = Main.MODNAME, version = Main.VERSION, acceptableRemoteVersions="*", acceptedMinecraftVersions="[1.10.2]", dependencies = "required-after:pixelmon", serverSideOnly = true)
  25. public class Main {
  26.  
  27.     public static final String MODID = "globaltrademarket";
  28.     public static final String MODNAME = "GTM";
  29.     public static final String VERSION = "1.0.0";
  30.     public SQL sql;
  31.  
  32.    
  33.     public static org.apache.logging.log4j.Logger logger;
  34.  
  35.     @SidedProxy(clientSide = "fr.flashback083.proxy.ClientProxy" ,serverSide = "fr.flashback083.proxy.ServerProxy")
  36.     public static CommonProxy proxy;
  37.  
  38.    
  39.  
  40.     @Mod.EventHandler
  41.     public void preInit(FMLPreInitializationEvent event) throws IOException {
  42.         logger = event.getModLog();
  43.         proxy.preInit(event);
  44.         Configuration cfg = CommonProxy.configbdd;
  45.         boolean sql = cfg.get("Base de donnees","BDDSQL", false).getBoolean();
  46.         if (sql == true) {
  47.             this.sql = new SQL("jdbc:mysql://",cfg.getCategory("Base de donnees").get("Host").getString(),cfg.getCategory("Base de donnees").get("Database").getString(),cfg.getCategory("Base de donnees").get("User").getString(),cfg.getCategory("Base de donnees").get("MDP").getString());
  48.             this.sql.connection();
  49.         }
  50.        
  51.  
  52.  
  53.     }
  54.    
  55.  
  56.    
  57.     @Mod.EventHandler
  58.     public void init(FMLInitializationEvent e) {
  59.         proxy.init(e);
  60.         MinecraftForge.EVENT_BUS.register(new EventHandler());
  61.         Pixelmon.EVENT_BUS.register(new EventHandlerPixelmon());
  62.     }
  63.  
  64.     @Mod.EventHandler
  65.     public void postInit(FMLPostInitializationEvent e) {
  66.         proxy.postInit(e);
  67.     }
  68.    
  69.     @SuppressWarnings("deprecation")
  70.     @Mod.EventHandler
  71.     public void onServerStart(FMLServerStartingEvent e) throws SQLException {
  72.         Configuration cfg = CommonProxy.configbdd;
  73.         boolean sql = cfg.get("Base de donnees","BDDSQL", false).getBoolean();
  74.         if (sql == true) {
  75.         e.registerServerCommand(new GTM());
  76.          Calendar c=new GregorianCalendar();
  77.          int d =c.getTime().getDate();
  78.          this.sql = new SQL("jdbc:mysql://",cfg.getCategory("Base de donnees").get("Host").getString(),cfg.getCategory("Base de donnees").get("Database").getString(),cfg.getCategory("Base de donnees").get("User").getString(),cfg.getCategory("Base de donnees").get("MDP").getString());
  79.           this.sql.connection();
  80.            String sqlReset = "UPDATE GTM SET Etat=1 WHERE Date='"+d+"'";                 
  81.            java.sql.Statement stmt = this.sql.connection.createStatement();
  82.            stmt.execute(sqlReset);
  83.            
  84.         }
  85.     }
  86.    
  87.     @Mod.EventHandler
  88.     public void onServerStop(FMLServerStoppingEvent e) {
  89.        
  90.     }
  91.    
  92.    
  93.    
  94.  
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement