diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..61f3bb9 --- /dev/null +++ b/.classpath @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore index 32858aa..fc51a24 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +/target/ +/Console.log diff --git a/.project b/.project new file mode 100644 index 0000000..8a695f0 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + unknown + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..4c28b1a --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..1ab2bb5 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..14b697b --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a663bfb --- /dev/null +++ b/pom.xml @@ -0,0 +1,67 @@ + + 4.0.0 + + galaxyoyo + unknown + 0.1-alpha + jar + + unknown + http://maven.apache.org + + + UTF-8 + 1.8 + 1.8 + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + galaxyoyo.unknown.client.main.Main + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + + + + junit + junit + 3.8.1 + test + + + net.sf.jopt-simple + jopt-simple + 4.8 + + + com.google.code.gson + gson + 2.3.1 + + + org.apache.logging.log4j + log4j-core + 2.1 + + + diff --git a/src/main/java/galaxyoyo/unknown/client/main/Main.java b/src/main/java/galaxyoyo/unknown/client/main/Main.java new file mode 100644 index 0000000..252cdf5 --- /dev/null +++ b/src/main/java/galaxyoyo/unknown/client/main/Main.java @@ -0,0 +1,99 @@ +/** + * + */ +package galaxyoyo.unknown.client.main; + +import java.io.IOException; + +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.Logger; +import org.apache.logging.log4j.core.appender.ConsoleAppender; +import org.apache.logging.log4j.core.appender.FileAppender; +import org.apache.logging.log4j.core.layout.PatternLayout; + +/** + * @author galaxyoyo + * Class principale qui lance le jeu + */ +public class Main +{ + private static boolean DEBUG; + private static boolean DEV; + + /** + * @param args arguments du jeu. Possibilit\u00e9s :
    --edit lancera un \u00e9diteur
    --help lance l'aide affichant toutes les options possibles + */ + public static void main(String ... args) + { + DEV = Main.class.getResource("/META-INF/MANIFEST.MF") == null; + + Logger LOGGER = (Logger) LogManager.getRootLogger(); + ConsoleAppender console = ConsoleAppender.newBuilder().setLayout(PatternLayout.newBuilder().withPattern("[%d{dd/MM/yyyy}] [%d{HH:mm:ss}] [%t] [%c] [%p] %m%n").build()).setName("Console").build(); + FileAppender file = FileAppender.createAppender("Console.log", "false", "false", "File", "true", "true", "true", "8192", console.getLayout(), null, "false", "false", null); + LOGGER.addAppender(console); + LOGGER.addAppender(file); + LOGGER.setLevel(Level.INFO); + + + + OptionParser parser = new OptionParser(); + + OptionSpec edit = parser.accepts("edit", "Lancer l'\u00e9diteur de monde").withOptionalArg(); + OptionSpec debug = parser.accepts("debug").withOptionalArg().ofType(Boolean.class).defaultsTo(true); + OptionSpec help = parser.accepts("help", "Affiche ce menu d'aide").withOptionalArg().forHelp(); + + OptionSet set = parser.parse(args); + + if (set.has(help)) + { + try + { + parser.printHelpOn(System.out); + } + catch (IOException e) + { + e.printStackTrace(); + } + finally + { + System.exit(0); + } + } + + if (set.has(debug)) + { + DEBUG = set.valueOf(debug); + + if (DEBUG) + { + LOGGER.setLevel(Level.DEBUG); + } + } + + if (set.has(edit)) + { + launchEditMode(); + return; + } + } + + private static void launchEditMode() + { + System.out.println("Lancement de l'\u00e9diteurde monde ..."); + } + + public static boolean isDebugMode() + { + return DEBUG; + } + + public static boolean isInDevelopmentMode() + { + return DEV; + } +} diff --git a/src/main/java/galaxyoyo/unknown/client/main/package-info.java b/src/main/java/galaxyoyo/unknown/client/main/package-info.java new file mode 100644 index 0000000..4de6196 --- /dev/null +++ b/src/main/java/galaxyoyo/unknown/client/main/package-info.java @@ -0,0 +1,7 @@ +/** + * Ce package comprend uniquement la classe Main, qui lance l'application. + */ +/** + * @author galaxyoyo + */ +package galaxyoyo.unknown.client.main; \ No newline at end of file diff --git a/src/test/java/galaxyoyo/unknown/AppTest.java b/src/test/java/galaxyoyo/unknown/AppTest.java new file mode 100644 index 0000000..5709616 --- /dev/null +++ b/src/test/java/galaxyoyo/unknown/AppTest.java @@ -0,0 +1,37 @@ +package galaxyoyo.unknown; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest(String testName) + { + super (testName); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite(AppTest.class); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue(true); + } +}