-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.4 - Properly use sided proxies to fix the server crash + ad…
…ded docstrings
- Loading branch information
1 parent
60e3cdd
commit 7782a3e
Showing
3 changed files
with
86 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,61 @@ | ||
package com.brittank88.clipshot; | ||
|
||
import java.awt.HeadlessException; | ||
import java.awt.Toolkit; | ||
|
||
import com.brittank88.clipshot.config.ConfigurationHandler; | ||
|
||
import cpw.mods.fml.common.FMLCommonHandler; | ||
import cpw.mods.fml.common.event.FMLInitializationEvent; | ||
import cpw.mods.fml.common.event.FMLPreInitializationEvent; | ||
|
||
/** | ||
* Override CommonProxy methods here, if you want a different behaviour on the client (e.g. registering renders). | ||
* <p> | ||
* Don't forget to call the super methods as well. | ||
* | ||
* @see CommonProxy | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class ClientProxy extends CommonProxy { | ||
|
||
// Override CommonProxy methods here, if you want a different behaviour on the client (e.g. registering renders). | ||
// Don't forget to call the super methods as well. | ||
/** | ||
* {@inheritDoc} | ||
* | ||
* @param event The pre-initialisation event. | ||
*/ | ||
@Override | ||
public void preInit(FMLPreInitializationEvent event) { | ||
super.preInit(event); | ||
|
||
// Initialise the configuration file. | ||
ConfigurationHandler.init(event.getSuggestedConfigurationFile()); | ||
FMLCommonHandler.instance() | ||
.bus() | ||
.register(new ConfigurationHandler()); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @param event The initialisation event. | ||
*/ | ||
@Override | ||
public void init(FMLInitializationEvent event) { | ||
super.init(event); | ||
|
||
ClipShot.LOG.info("Getting system clipboard via AWT..."); | ||
|
||
try { | ||
Toolkit.getDefaultToolkit() | ||
.getSystemClipboard(); | ||
} catch (HeadlessException e) { | ||
throw ClipShot.LOG.throwing( | ||
new RuntimeException( | ||
"Failed to get system clipboard; java.awt.headless property was not set properly: ", | ||
e)); | ||
} | ||
|
||
ClipShot.LOG.info("ClipShot " + Tags.VERSION + " loaded!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,31 @@ | ||
package com.brittank88.clipshot; | ||
|
||
import java.awt.HeadlessException; | ||
import java.awt.Toolkit; | ||
|
||
import com.brittank88.clipshot.config.ConfigurationHandler; | ||
|
||
import cpw.mods.fml.common.FMLCommonHandler; | ||
import cpw.mods.fml.common.event.FMLInitializationEvent; | ||
import cpw.mods.fml.common.event.FMLPreInitializationEvent; | ||
|
||
public class CommonProxy { | ||
|
||
private boolean isClient = false; | ||
|
||
// preInit "Run before anything else. Read your config, create blocks, items, etc., and register them with the | ||
// GameRegistry." (Remove if not needed) | ||
/** | ||
* Run before anything else. | ||
* <p> | ||
* Read your config, create blocks, items, etc., and register them with the GameRegistry. | ||
* | ||
* @param event The pre-initialisation event. | ||
*/ | ||
public void preInit(FMLPreInitializationEvent event) { | ||
|
||
// Skip initialisation on dedicated servers. | ||
isClient = event.getSide() | ||
.isClient(); | ||
if (!isClient) { | ||
// Warn about being useless on a dedicated server. | ||
if (event.getSide() | ||
.isServer()) | ||
ClipShot.LOG.warn("ClipShot will do nothing on a dedicated server as it is a client-only mod!"); | ||
return; | ||
} | ||
|
||
// Initialise the configuration file. | ||
ConfigurationHandler.init(event.getSuggestedConfigurationFile()); | ||
FMLCommonHandler.instance() | ||
.bus() | ||
.register(new ConfigurationHandler()); | ||
} | ||
|
||
// load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed) | ||
public void init(@SuppressWarnings("unused") FMLInitializationEvent event) { | ||
|
||
// Skip initialisation on dedicated servers. | ||
if (isClient) return; | ||
|
||
ClipShot.LOG.info("Getting system clipboard via AWT..."); | ||
|
||
try { | ||
Toolkit.getDefaultToolkit() | ||
.getSystemClipboard(); | ||
} catch (HeadlessException e) { | ||
throw ClipShot.LOG.throwing( | ||
new RuntimeException( | ||
"Failed to get system clipboard via AWT. The java.awt.headless property was not set properly: ", | ||
e)); | ||
} | ||
|
||
ClipShot.LOG.info("ClipShot " + Tags.VERSION + " loaded!"); | ||
} | ||
/** | ||
* Do your mod setup. | ||
* <p> | ||
* Build whatever data structures you care about. Register recipes. | ||
* | ||
* @param event The initialisation event. | ||
*/ | ||
public void init(@SuppressWarnings("unused") FMLInitializationEvent event) {} | ||
} |