Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://git.lexteam.xyz/lex-game/Game
oh god noooooo! bloody merges :(
- Loading branch information
Showing
8 changed files
with
218 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* This file is part of lex-game, licensed All Rights Reserved. | ||
* | ||
* Copyright (c) 2015-2016, Lexteam <http://www.lexteam.xyz/> | ||
* All Rights Reserved. | ||
*/ | ||
package xyz.lexteam.ygd.core; | ||
|
||
import org.slf4j.Logger; | ||
import xyz.lexteam.ygd.core.service.ServiceManager; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* Static access to {@link Game}. | ||
* | ||
* @author Jamie Mansfield | ||
*/ | ||
public class LexGame { | ||
|
||
private static final Game GAME = null; | ||
|
||
public static Game getGame() { | ||
return GAME; | ||
} | ||
|
||
/** | ||
* @see Game#getServiceManager() | ||
*/ | ||
public static ServiceManager getServiceManager() { | ||
return GAME.getServiceManager(); | ||
} | ||
|
||
/** | ||
* @see Game#getSettings() | ||
*/ | ||
public static GameSettings getSettings() { | ||
return GAME.getSettings(); | ||
} | ||
|
||
/** | ||
* @see Game#getLogger() | ||
*/ | ||
public static Logger getLogger() { | ||
return GAME.getLogger(); | ||
} | ||
|
||
/** | ||
* @see Game#getDirectory() | ||
*/ | ||
public static File getDirectory() { | ||
return GAME.getDirectory(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Core/src/main/java/xyz/lexteam/ygd/core/event/module/ModulesEnableEvent.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,18 @@ | ||
/* | ||
* This file is part of lex-game, licensed All Rights Reserved. | ||
* | ||
* Copyright (c) 2015-2016, Lexteam <http://www.lexteam.xyz/> | ||
* All Rights Reserved. | ||
*/ | ||
package xyz.lexteam.ygd.core.event.module; | ||
|
||
import xyz.lexteam.ygd.core.event.Event; | ||
|
||
/** | ||
* The event that is called to enable modules. | ||
* | ||
* @author Jamie Mansfield | ||
*/ | ||
public class ModulesEnableEvent implements Event { | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
Core/src/main/java/xyz/lexteam/ygd/core/module/Module.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,21 @@ | ||
/* | ||
* This file is part of lex-game, licensed All Rights Reserved. | ||
* | ||
* Copyright (c) 2015-2016, Lexteam <http://www.lexteam.xyz/> | ||
* All Rights Reserved. | ||
*/ | ||
package xyz.lexteam.ygd.core.module; | ||
|
||
/** | ||
* This annotation will be used by modules. | ||
* | ||
* @author Jamie Mansfield | ||
*/ | ||
public @interface Module { | ||
|
||
String id(); | ||
|
||
String name(); | ||
|
||
String version(); | ||
} |
23 changes: 23 additions & 0 deletions
23
Core/src/main/java/xyz/lexteam/ygd/core/module/ModuleContainer.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,23 @@ | ||
/* | ||
* This file is part of lex-game, licensed All Rights Reserved. | ||
* | ||
* Copyright (c) 2015-2016, Lexteam <http://www.lexteam.xyz/> | ||
* All Rights Reserved. | ||
*/ | ||
package xyz.lexteam.ygd.core.module; | ||
|
||
/** | ||
* Wrapper around classes with the {@link Module} annotation. | ||
* | ||
* @author Jamie Mansfield | ||
*/ | ||
public interface ModuleContainer { | ||
|
||
String getId(); | ||
|
||
String getName(); | ||
|
||
String getVersion(); | ||
|
||
Object getInstance(); | ||
} |
39 changes: 39 additions & 0 deletions
39
Core/src/main/java/xyz/lexteam/ygd/core/service/module/ModuleService.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,39 @@ | ||
/* | ||
* This file is part of lex-game, licensed All Rights Reserved. | ||
* | ||
* Copyright (c) 2015-2016, Lexteam <http://www.lexteam.xyz/> | ||
* All Rights Reserved. | ||
*/ | ||
package xyz.lexteam.ygd.core.service.module; | ||
|
||
import xyz.lexteam.ygd.core.module.ModuleContainer; | ||
|
||
import java.io.File; | ||
import java.util.Set; | ||
|
||
/** | ||
* The module service. | ||
* | ||
* @author Jamie Mansfield | ||
*/ | ||
public interface ModuleService { | ||
|
||
/** | ||
* Loads all the modules from the given directory. | ||
* | ||
* @param directory The directory. | ||
*/ | ||
void loadModules(File directory); | ||
|
||
/** | ||
* Enables all the loaded modules. | ||
*/ | ||
void enableModules(); | ||
|
||
/** | ||
* Gets all the loaded modules. | ||
* | ||
* @return The loaded modules. | ||
*/ | ||
Set<ModuleContainer> getModules(); | ||
} |
46 changes: 46 additions & 0 deletions
46
Core/src/main/java/xyz/lexteam/ygd/core/service/module/SimpleModuleService.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,46 @@ | ||
/* | ||
* This file is part of lex-game, licensed All Rights Reserved. | ||
* | ||
* Copyright (c) 2015-2016, Lexteam <http://www.lexteam.xyz/> | ||
* All Rights Reserved. | ||
*/ | ||
package xyz.lexteam.ygd.core.service.module; | ||
|
||
import com.google.common.collect.Sets; | ||
import xyz.lexteam.ygd.core.event.module.ModulesEnableEvent; | ||
import xyz.lexteam.ygd.core.module.ModuleContainer; | ||
import xyz.lexteam.ygd.core.service.event.Events; | ||
|
||
import java.io.File; | ||
import java.io.FileFilter; | ||
import java.util.Set; | ||
import java.util.jar.JarFile; | ||
|
||
/** | ||
* A simple implementation of {@link ModuleService}. | ||
* | ||
* @author Jamie Mansfield | ||
*/ | ||
public class SimpleModuleService implements ModuleService { | ||
|
||
private Set<ModuleContainer> modules = Sets.newHashSet(); | ||
|
||
@Override | ||
public void loadModules(File directory) { | ||
for (File f : directory.listFiles(pathname -> { | ||
return pathname.getName().endsWith(".jar"); | ||
})) { | ||
// TODO: | ||
} | ||
} | ||
|
||
@Override | ||
public void enableModules() { | ||
Events.post(new ModulesEnableEvent()); | ||
} | ||
|
||
@Override | ||
public Set<ModuleContainer> getModules() { | ||
return this.modules; | ||
} | ||
} |
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