inital commit
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
# To contribute improvements to CI/CD templates, please follow the Development guide at:
|
||||||
|
# https://docs.gitlab.com/ee/development/cicd/templates.html
|
||||||
|
# This specific template is located at:
|
||||||
|
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Maven.gitlab-ci.yml
|
||||||
|
|
||||||
|
# Build JAVA applications using Apache Maven (http://maven.apache.org)
|
||||||
|
# For docker image tags see https://hub.docker.com/_/maven/
|
||||||
|
#
|
||||||
|
# For general lifecycle information see https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
|
||||||
|
|
||||||
|
# This template will build and test your projects
|
||||||
|
# * Caches downloaded dependencies and plugins between invocation.
|
||||||
|
# * Verify but don't deploy merge requests.
|
||||||
|
# * Deploy built artifacts from master branch only.
|
||||||
|
|
||||||
|
variables:
|
||||||
|
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
|
||||||
|
MAVEN_OPTS: >-
|
||||||
|
-Dhttps.protocols=TLSv1.2
|
||||||
|
-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository
|
||||||
|
-Dorg.slf4j.simpleLogger.showDateTime=true
|
||||||
|
-Djava.awt.headless=true
|
||||||
|
|
||||||
|
# As of Maven 3.3.0 instead of this you MAY define these options in `.mvn/maven.config` so the same config is used
|
||||||
|
# when running from the command line.
|
||||||
|
# As of Maven 3.6.1, the use of `--no-tranfer-progress` (or `-ntp`) suppresses download and upload messages. The use
|
||||||
|
# of the `Slf4jMavenTransferListener` is no longer necessary.
|
||||||
|
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
|
||||||
|
MAVEN_CLI_OPTS: >-
|
||||||
|
--batch-mode
|
||||||
|
--errors
|
||||||
|
--fail-at-end
|
||||||
|
--show-version
|
||||||
|
--no-transfer-progress
|
||||||
|
-DinstallAtEnd=true
|
||||||
|
-DdeployAtEnd=true
|
||||||
|
|
||||||
|
# This template uses the latest Maven 3 release, e.g., 3.8.6, and OpenJDK 8 (LTS)
|
||||||
|
# for verifying and deploying images
|
||||||
|
# Maven 3.8.x REQUIRES HTTPS repositories.
|
||||||
|
# See https://maven.apache.org/docs/3.8.1/release-notes.html#how-to-fix-when-i-get-a-http-repository-blocked for more.
|
||||||
|
image: maven:3-openjdk-20
|
||||||
|
|
||||||
|
# Cache downloaded dependencies and plugins between builds.
|
||||||
|
# To keep cache across branches add 'key: "$CI_JOB_NAME"'
|
||||||
|
# Be aware that `mvn deploy` will install the built jar into this repository. If you notice your cache size
|
||||||
|
# increasing, consider adding `-Dmaven.install.skip=true` to `MAVEN_OPTS` or in `.mvn/maven.config`
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .m2/repository
|
||||||
|
|
||||||
|
# For merge requests do not `deploy` but only run `verify`.
|
||||||
|
# See https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
|
||||||
|
.verify:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- 'mvn $MAVEN_CLI_OPTS verify'
|
||||||
|
except:
|
||||||
|
variables:
|
||||||
|
- $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
|
|
||||||
|
# Verify merge requests using JDK8
|
||||||
|
verify:jdk20:
|
||||||
|
extends:
|
||||||
|
- .verify
|
||||||
|
|
||||||
|
# To deploy packages from CI, create a `ci_settings.xml` file
|
||||||
|
# For deploying packages to GitLab's Maven Repository: See https://docs.gitlab.com/ee/user/packages/maven_repository/index.html#create-maven-packages-with-gitlab-cicd for more details.
|
||||||
|
# Please note: The GitLab Maven Repository is currently only available in GitLab Premium / Ultimate.
|
||||||
|
# For `master` or `main` branch run `mvn deploy` automatically.
|
||||||
|
deploy:jdk20:
|
||||||
|
stage: deploy
|
||||||
|
script:
|
||||||
|
- if [ ! -f ci_settings.xml ]; then
|
||||||
|
echo "CI settings missing\! If deploying to GitLab Maven Repository, please see https://docs.gitlab.com/ee/user/packages/maven_repository/index.html#create-maven-packages-with-gitlab-cicd for instructions.";
|
||||||
|
fi
|
||||||
|
- 'mvn $MAVEN_CLI_OPTS deploy --settings ci_settings.xml'
|
||||||
|
only:
|
||||||
|
variables:
|
||||||
|
- $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
||||||
Generated
+7
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,com.softwarerat.SQL.AsyncSQLHandler,executeQuery" />
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
Generated
+13
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="corretto-18" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+97
@@ -0,0 +1,97 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AutoImportSettings">
|
||||||
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
|
</component>
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="dac31118-6e03-4b37-bd82-a241dbd68d95" name="Changes" comment="initial Commit">
|
||||||
|
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
|
||||||
|
</list>
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="FileTemplateManagerImpl">
|
||||||
|
<option name="RECENT_TEMPLATES">
|
||||||
|
<list>
|
||||||
|
<option value="Class" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="MarkdownSettingsMigration">
|
||||||
|
<option name="stateVersion" value="1" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
||||||
|
<ConfirmationsSetting value="2" id="Add" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectViewState">
|
||||||
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
|
<option name="showLibraryContents" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
|
"keyToString": {
|
||||||
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
|
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
|
"git-widget-placeholder": "main",
|
||||||
|
"last_opened_file_path": "C:/Users/Fraus/IdeaProjects/HomesAPI"
|
||||||
|
}
|
||||||
|
}]]></component>
|
||||||
|
<component name="RecentsManager">
|
||||||
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
|
<recent name="C:\Users\Fraus\IdeaProjects\HomesAPI" />
|
||||||
|
</key>
|
||||||
|
</component>
|
||||||
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
|
<component name="TaskManager">
|
||||||
|
<task active="true" id="Default" summary="Default task">
|
||||||
|
<changelist id="dac31118-6e03-4b37-bd82-a241dbd68d95" name="Changes" comment="" />
|
||||||
|
<created>1699031531702</created>
|
||||||
|
<option name="number" value="Default" />
|
||||||
|
<option name="presentableId" value="Default" />
|
||||||
|
<updated>1699031531702</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00001" summary="initial Commit">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1699032959323</created>
|
||||||
|
<option name="number" value="00001" />
|
||||||
|
<option name="presentableId" value="LOCAL-00001" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1699032959323</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00002" summary="initial Commit">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1699032974795</created>
|
||||||
|
<option name="number" value="00002" />
|
||||||
|
<option name="presentableId" value="LOCAL-00002" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1699032974795</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00003" summary="initial Commit">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1699033030069</created>
|
||||||
|
<option name="number" value="00003" />
|
||||||
|
<option name="presentableId" value="LOCAL-00003" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1699033030069</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00004" summary="initial Commit">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1699036089856</created>
|
||||||
|
<option name="number" value="00004" />
|
||||||
|
<option name="presentableId" value="LOCAL-00004" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1699036089856</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="5" />
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
<component name="VcsManagerConfiguration">
|
||||||
|
<MESSAGE value="initial Commit" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="initial Commit" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# HomesAPI
|
||||||
|
### initialisierung des Basis API Codes
|
||||||
|
|
||||||
|
```java
|
||||||
|
public void onEnable(){
|
||||||
|
Bansystem bansystem = new Bansystem();
|
||||||
|
bansystem.enableAPI("Benutzer","Passwort","Host","Datenbank");
|
||||||
|
ban = bansystem.getBan();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Verwendung des Home Systems:
|
||||||
|
### erstellen eines Homes
|
||||||
|
````java
|
||||||
|
Homes home;
|
||||||
|
public void addHome(PlayerHome p){
|
||||||
|
//erstellt anhand der PlayerHome informationen ein Home
|
||||||
|
home.createNewHome(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
````
|
||||||
|
|
||||||
|
### alle Homes eines Spielers holen
|
||||||
|
|
||||||
|
````java
|
||||||
|
Homes home;
|
||||||
|
public ArrayList<String> getHomes{
|
||||||
|
ArrayList<String> homes = new ArrayList<>();
|
||||||
|
//erstellt eine ArrayList mit den HomeNames
|
||||||
|
home.getPlayerHome.forEach(h -> {homes.add(h.getName)});
|
||||||
|
return homes;
|
||||||
|
}
|
||||||
|
````
|
||||||
|
|
||||||
|
### ein Home eines Spielers anhand des Namens holen
|
||||||
|
|
||||||
|
````java
|
||||||
|
Homes home;
|
||||||
|
public String getHomeWorld(String name){
|
||||||
|
home.getHomeByName(name);
|
||||||
|
return home.getWorld;
|
||||||
|
}
|
||||||
|
````
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<settings>
|
||||||
|
<servers>
|
||||||
|
<server>
|
||||||
|
<id>gitlab-maven</id>
|
||||||
|
<configuration>
|
||||||
|
<httpHeaders>
|
||||||
|
<property>
|
||||||
|
<name>Job-Token</name>
|
||||||
|
<value>${CI_JOB_TOKEN}</value>
|
||||||
|
</property>
|
||||||
|
</httpHeaders>
|
||||||
|
</configuration>
|
||||||
|
</server>
|
||||||
|
</servers>
|
||||||
|
</settings>
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<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>com.softwarerat</groupId>
|
||||||
|
<artifactId>HomesAPI</artifactId>
|
||||||
|
<version>1.1-SNAPSHOT</version>
|
||||||
|
<distributionManagement>
|
||||||
|
<repository>
|
||||||
|
<id>gitlab-maven</id>
|
||||||
|
<url>https://gitlab.softwarerat.com/api/v4/projects/14/packages/maven</url>
|
||||||
|
</repository>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>gitlab-maven</id>
|
||||||
|
<url>https://gitlab.softwarerat.com/api/v4/projects/14/packages/maven</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
</distributionManagement>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>18</maven.compiler.source>
|
||||||
|
<maven.compiler.target>18</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.28</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.mint</groupId>
|
||||||
|
<artifactId>AsyncMySQLPoolHandler</artifactId>
|
||||||
|
<version>1.0.5</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>gitlab-zyonic</id>
|
||||||
|
<url>https://gitlab.zyonicsoftware.com/api/v4/projects/119/packages/maven</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<settings>
|
||||||
|
<servers>
|
||||||
|
<server>
|
||||||
|
<id>gitlab-maven</id>
|
||||||
|
<configuration>
|
||||||
|
<httpHeaders>
|
||||||
|
<property>
|
||||||
|
<name>Job-Token</name>
|
||||||
|
<value>${CI_JOB_TOKEN}</value>
|
||||||
|
</property>
|
||||||
|
</httpHeaders>
|
||||||
|
</configuration>
|
||||||
|
</server>
|
||||||
|
</servers>
|
||||||
|
</settings>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.softwarerat;
|
||||||
|
|
||||||
|
import com.softwarerat.SQL.AsyncSQLHandler;
|
||||||
|
import com.softwarerat.SQL.Homes;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class Main {
|
||||||
|
AsyncSQLHandler asyncSQLHandler;
|
||||||
|
Homes homes;
|
||||||
|
public void enableAPI(String user, String pw, String Database, String host){
|
||||||
|
asyncSQLHandler = new AsyncSQLHandler(host,user,pw,Database);
|
||||||
|
homes = new Homes(asyncSQLHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.softwarerat.SQL;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
|
||||||
|
import de.mint.asyncmysqlpoolhandler.configservice.ConfigBuilder;
|
||||||
|
import de.mint.asyncmysqlpoolhandler.configservice.ConfigPoolFramework;
|
||||||
|
import de.mint.asyncmysqlpoolhandler.enumservice.EnumPoolFramework;
|
||||||
|
import de.mint.asyncmysqlpoolhandler.mainservice.AsyncMySQLPoolHandler;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
public class AsyncSQLHandler {
|
||||||
|
|
||||||
|
private final AsyncMySQLPoolHandler MySQLPoolHandler;
|
||||||
|
private final ConfigPoolFramework configPoolFramework = ConfigBuilder.getConfigBuilder().build();
|
||||||
|
|
||||||
|
public AsyncSQLHandler(String hostname, String user, String pw, String DB) {
|
||||||
|
this.MySQLPoolHandler = new AsyncMySQLPoolHandler(hostname, user, pw, DB, EnumPoolFramework.HIKARICP, configPoolFramework);
|
||||||
|
this.openConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openConnection() {
|
||||||
|
this.MySQLPoolHandler.openPool();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Basic SQL Things
|
||||||
|
protected ResultSet executeQuery(String sql) throws ExecutionException, InterruptedException {
|
||||||
|
return this.MySQLPoolHandler.executeQueryAsync(sql).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void executeUpdate(String sql) throws ExecutionException, InterruptedException {
|
||||||
|
this.MySQLPoolHandler.executeUpdateAsync(sql).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package com.softwarerat.SQL;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
public class Homes {
|
||||||
|
AsyncSQLHandler sqlHandler;
|
||||||
|
|
||||||
|
public Homes(AsyncSQLHandler sqlHandler) {
|
||||||
|
this.sqlHandler = sqlHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerHome getHomeByName(String name){
|
||||||
|
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
try {
|
||||||
|
resultSet = sqlHandler.executeQuery("SELECT * FROM homes WHERE Name = '" + name + "';");
|
||||||
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
if (resultSet != null) {
|
||||||
|
try {
|
||||||
|
resultSet.next();
|
||||||
|
return new PlayerHome(resultSet.getString("Name"),resultSet.getString("UUID"),resultSet.getString("World"),resultSet.getInt("x"),resultSet.getInt("y"), resultSet.getInt("z"));
|
||||||
|
} catch (SQLException e) {
|
||||||
|
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("Loaded home");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createNewHome(PlayerHome playerHome){
|
||||||
|
try {
|
||||||
|
sqlHandler.executeUpdate("INSERT INTO homes (Name, UUID, World, x, y, z) VALUES ('"+playerHome.getName()+"','"+playerHome.getUUID()+"','"+playerHome.getWorld()+"','"+playerHome.getX()+"','"+playerHome.getY()+"','"+playerHome.getZ()+"');");
|
||||||
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//ToDo: DeleteHome method
|
||||||
|
public ArrayList<PlayerHome> getPlayerHomes(String UUID) {
|
||||||
|
ArrayList<PlayerHome> homes = new ArrayList<>();
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
try {
|
||||||
|
resultSet = sqlHandler.executeQuery("SELECT * FROM homes WHERE uuid = '" + UUID + "';");
|
||||||
|
} catch (ExecutionException | InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
if (resultSet != null) {
|
||||||
|
try {
|
||||||
|
while (true){
|
||||||
|
resultSet.next();
|
||||||
|
homes.add(new PlayerHome(resultSet.getString("Name"),resultSet.getString("UUID"),resultSet.getString("World"),resultSet.getInt("x"),resultSet.getInt("y"), resultSet.getInt("z")));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("Loaded Homes from player ");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.softwarerat.SQL;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
|
||||||
|
public class PlayerHome {
|
||||||
|
String Name;
|
||||||
|
String UUID;
|
||||||
|
String World;
|
||||||
|
private double x;
|
||||||
|
private double y;
|
||||||
|
private double z;
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user