This repository has been archived by the owner on Jan 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upload files and build the release v1.0
- Loading branch information
Mustafa ÖNCEL
committed
Jun 28, 2018
1 parent
f71c6b8
commit d2bdfaf
Showing
12 changed files
with
652 additions
and
0 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 |
---|---|---|
@@ -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> |
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 @@ | ||
/target/ |
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 @@ | ||
<?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> |
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,2 @@ | ||
eclipse.preferences.version=1 | ||
line.separator=\r\n |
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,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 |
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,4 @@ | ||
activeProfiles= | ||
eclipse.preferences.version=1 | ||
resolveWorkspaceProjects=true | ||
version=1 |
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,3 @@ | ||
eclipse.preferences.version=1 | ||
project.repository.kind=local | ||
project.repository.url=local |
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,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 & 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> |
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,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; | ||
|
||
} | ||
|
||
} | ||
|
||
} |
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,7 @@ | ||
package com.lifemcserver.api; | ||
|
||
public enum ResponseType { | ||
|
||
NO_USER, WRONG_PASSWORD, MAX_TRIES, ERROR, SUCCESS; | ||
|
||
} |
Oops, something went wrong.