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

Commit d2bdfaf

Browse files
author
Mustafa ÖNCEL
committed
Upload files and build the release v1.0
1 parent f71c6b8 commit d2bdfaf

12 files changed

Lines changed: 652 additions & 0 deletions

File tree

.classpath

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry excluding="LifeMC-API/src|main/" kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="LifeMC-API/src|main/" kind="src" output="target/test-classes" path="src/test/java">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
</attributes>
14+
</classpathentry>
15+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
16+
<attributes>
17+
<attribute name="maven.pomderived" value="true"/>
18+
</attributes>
19+
</classpathentry>
20+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
21+
<attributes>
22+
<attribute name="maven.pomderived" value="true"/>
23+
</attributes>
24+
</classpathentry>
25+
<classpathentry kind="output" path="target/classes"/>
26+
</classpath>

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/

.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>LifeMC-API</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
line.separator=\r\n
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
3+
org.eclipse.jdt.core.compiler.compliance=1.5
4+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5+
org.eclipse.jdt.core.compiler.source=1.5
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
eclipse.preferences.version=1
2+
project.repository.kind=local
3+
project.repository.url=local

pom.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>LifeMC-API</groupId>
4+
<artifactId>LifeMC-API</artifactId>
5+
<version>1.0</version>
6+
<name>LifeMC-API</name>
7+
<description>High performance &amp; feature rich APIs for LifeMC Minecraft Server.</description>
8+
<url>https://www.lifemcserver.com/</url>
9+
<inceptionYear>LifeMC-API</inceptionYear>
10+
<organization>
11+
<name>LifeMC, Inc.</name>
12+
<url>https://www.lifemcserver.com/</url>
13+
</organization>
14+
<dependencies>
15+
<dependency>
16+
<groupId>com.google.guava</groupId>
17+
<artifactId>guava</artifactId>
18+
<version>25.1-jre</version>
19+
<scope>provided</scope>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.json</groupId>
23+
<artifactId>json</artifactId>
24+
<version>20180130</version>
25+
<scope>provided</scope>
26+
</dependency>
27+
</dependencies>
28+
</project>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package com.lifemcserver.api;
2+
3+
import java.util.concurrent.ConcurrentHashMap;
4+
import java.util.concurrent.ExecutorService;
5+
import java.util.concurrent.Executors;
6+
7+
import javax.annotation.Nullable;
8+
9+
import com.google.common.util.concurrent.ThreadFactoryBuilder;
10+
11+
public class LifeAPI {
12+
13+
protected static ExecutorService apiThread = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("LifeAPI - API Thread").build());
14+
protected static LifeAPI Instance = null;
15+
16+
protected ConcurrentHashMap<String, User> userMap = new ConcurrentHashMap<String, User>();
17+
18+
public LifeAPI() {
19+
20+
Instance = this;
21+
22+
}
23+
24+
@Nullable
25+
public Object getUser(String name, String password) {
26+
27+
if(userMap.containsKey(name)) {
28+
29+
return userMap.get(name);
30+
31+
} else {
32+
33+
String jsonResponse = "";
34+
35+
try {
36+
37+
jsonResponse = User.connectTo("https://www.lifemcserver.com/loginAPI.php?" + name + "&password=" + password);
38+
39+
} catch(Exception ex) {
40+
41+
ex.printStackTrace();
42+
43+
} catch(Throwable tw) {
44+
45+
tw.printStackTrace();
46+
47+
}
48+
49+
ResponseType response = null;
50+
51+
if(jsonResponse.equalsIgnoreCase("NO_USER")) {
52+
response = ResponseType.NO_USER;
53+
return response;
54+
}
55+
56+
else if(jsonResponse.equalsIgnoreCase("WRONG_PASSWORD")) {
57+
response = ResponseType.WRONG_PASSWORD;
58+
return response;
59+
}
60+
61+
else if(jsonResponse.equalsIgnoreCase("MAX_TRIES")) {
62+
response = ResponseType.MAX_TRIES;
63+
return response;
64+
}
65+
66+
else if(jsonResponse.equalsIgnoreCase("ERROR")) {
67+
response = ResponseType.ERROR;
68+
return response;
69+
}
70+
71+
else if(jsonResponse.equalsIgnoreCase("SUCCESS")) {
72+
response = ResponseType.SUCCESS;
73+
}
74+
75+
else {
76+
77+
response = ResponseType.ERROR;
78+
return response;
79+
80+
}
81+
82+
User u = new User(name, password);
83+
userMap.put(name, u);
84+
85+
return u;
86+
87+
}
88+
89+
}
90+
91+
@Nullable
92+
public User getUser(String name) {
93+
94+
if(userMap.containsKey(name)) {
95+
96+
return userMap.get(name);
97+
98+
} else {
99+
100+
return null;
101+
102+
}
103+
104+
}
105+
106+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.lifemcserver.api;
2+
3+
public enum ResponseType {
4+
5+
NO_USER, WRONG_PASSWORD, MAX_TRIES, ERROR, SUCCESS;
6+
7+
}

0 commit comments

Comments
 (0)