Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
Upload files and build the release v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mustafa ÖNCEL committed Jun 28, 2018
1 parent f71c6b8 commit d2bdfaf
Show file tree
Hide file tree
Showing 12 changed files with 652 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="LifeMC-API/src|main/" kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="LifeMC-API/src|main/" kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>LifeMC-API</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions .settings/org.eclipse.core.runtime.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\r\n
5 changes: 5 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
3 changes: 3 additions & 0 deletions .settings/org.eclipse.mylyn.tasks.ui.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
project.repository.kind=local
project.repository.url=local
28 changes: 28 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>LifeMC-API</groupId>
<artifactId>LifeMC-API</artifactId>
<version>1.0</version>
<name>LifeMC-API</name>
<description>High performance &amp; feature rich APIs for LifeMC Minecraft Server.</description>
<url>https://www.lifemcserver.com/</url>
<inceptionYear>LifeMC-API</inceptionYear>
<organization>
<name>LifeMC, Inc.</name>
<url>https://www.lifemcserver.com/</url>
</organization>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>25.1-jre</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
106 changes: 106 additions & 0 deletions src/main/java/com/lifemcserver/api/LifeAPI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package com.lifemcserver.api;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.annotation.Nullable;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

public class LifeAPI {

protected static ExecutorService apiThread = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("LifeAPI - API Thread").build());
protected static LifeAPI Instance = null;

protected ConcurrentHashMap<String, User> userMap = new ConcurrentHashMap<String, User>();

public LifeAPI() {

Instance = this;

}

@Nullable
public Object getUser(String name, String password) {

if(userMap.containsKey(name)) {

return userMap.get(name);

} else {

String jsonResponse = "";

try {

jsonResponse = User.connectTo("https://www.lifemcserver.com/loginAPI.php?" + name + "&password=" + password);

} catch(Exception ex) {

ex.printStackTrace();

} catch(Throwable tw) {

tw.printStackTrace();

}

ResponseType response = null;

if(jsonResponse.equalsIgnoreCase("NO_USER")) {
response = ResponseType.NO_USER;
return response;
}

else if(jsonResponse.equalsIgnoreCase("WRONG_PASSWORD")) {
response = ResponseType.WRONG_PASSWORD;
return response;
}

else if(jsonResponse.equalsIgnoreCase("MAX_TRIES")) {
response = ResponseType.MAX_TRIES;
return response;
}

else if(jsonResponse.equalsIgnoreCase("ERROR")) {
response = ResponseType.ERROR;
return response;
}

else if(jsonResponse.equalsIgnoreCase("SUCCESS")) {
response = ResponseType.SUCCESS;
}

else {

response = ResponseType.ERROR;
return response;

}

User u = new User(name, password);
userMap.put(name, u);

return u;

}

}

@Nullable
public User getUser(String name) {

if(userMap.containsKey(name)) {

return userMap.get(name);

} else {

return null;

}

}

}
7 changes: 7 additions & 0 deletions src/main/java/com/lifemcserver/api/ResponseType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.lifemcserver.api;

public enum ResponseType {

NO_USER, WRONG_PASSWORD, MAX_TRIES, ERROR, SUCCESS;

}
Loading

0 comments on commit d2bdfaf

Please sign in to comment.