-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new hook manager
- Loading branch information
Showing
18 changed files
with
308 additions
and
89 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
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
16 changes: 16 additions & 0 deletions
16
src/main/java/eu/horyzon/premiumconnector/exceptions/InitHookException.java
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package eu.horyzon.premiumconnector.exceptions; | ||
|
||
import eu.horyzon.premiumconnector.hooks.Hook; | ||
|
||
public class InitHookException extends Exception { | ||
private final Hook hook; | ||
|
||
public InitHookException(Hook hook, String message) { | ||
super(message); | ||
this.hook = hook; | ||
} | ||
|
||
public Hook getHook() { | ||
return hook; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package eu.horyzon.premiumconnector.hooks; | ||
|
||
import eu.horyzon.premiumconnector.PremiumConnector; | ||
|
||
public abstract class Hook { | ||
protected final PremiumConnector plugin; | ||
protected final HookType type; | ||
protected boolean enabled = false; | ||
|
||
protected Hook(HookType type, PremiumConnector plugin) { | ||
this.type = type; | ||
this.plugin = plugin; | ||
|
||
if (! (enabled = ! (plugin.getProxy().getPluginManager().getPlugin(getName()) == null))) | ||
return; | ||
|
||
init(); | ||
|
||
if (isEnabled()) | ||
plugin.getLogger().info("Hook with " + getName() + " correctly loaded !"); | ||
else | ||
plugin.getLogger().warning("Hook with " + getName() + " detected but not properly loaded !"); | ||
} | ||
|
||
public String getName() { | ||
return type.getPluginName(); | ||
} | ||
|
||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
public void setEnabled(boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
protected void init() {} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/eu/horyzon/premiumconnector/hooks/HookType.java
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package eu.horyzon.premiumconnector.hooks; | ||
|
||
public enum HookType { | ||
MULTI_LOBBY("MultiLobby"); | ||
|
||
private final String pluginName; | ||
|
||
HookType(String hookName) { | ||
this.pluginName = hookName; | ||
} | ||
|
||
public String getPluginName() { | ||
return pluginName; | ||
} | ||
} |
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
Oops, something went wrong.