Push
This commit is contained in:
commit
2e182d13a5
89
.gitignore
vendored
Normal file
89
.gitignore
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
### Java template
|
||||
*.class
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
### Eclipse template
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
# Eclipse Core
|
||||
.project
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
# PyDev specific (Python IDE for Eclipse)
|
||||
*.pydevproject
|
||||
# CDT-specific (C/C++ Development Tooling)
|
||||
.cproject
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
# Java annotation processor (APT)
|
||||
.factorypath
|
||||
# PDT-specific (PHP Development Tools)
|
||||
.buildpath
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
# Tern plugin
|
||||
.tern-project
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
# STS (Spring Tool Suite)
|
||||
.springBeans
|
||||
# Code Recommenders
|
||||
.recommenders/
|
||||
### NetBeans template
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
nbactions.xml
|
||||
.nb-gradle/
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
# User-specific stuff:
|
||||
.idea/*
|
||||
*.iml
|
||||
# Sensitive or high-churn files:
|
||||
.idea/dataSources.ids
|
||||
.idea/dataSources.xml
|
||||
.idea/dataSources.local.xml
|
||||
.idea/sqlDataSources.xml
|
||||
.idea/dynamic.xml
|
||||
.idea/uiDesigner.xml
|
||||
# Gradle:
|
||||
.idea/gradle.xml
|
||||
.idea/libraries
|
||||
# Mongo Explorer plugin:
|
||||
.idea/mongoSettings.xml
|
||||
## File-based project format:
|
||||
*.iws
|
||||
## Plugin-specific files:
|
||||
# IntelliJ
|
||||
/out/
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
43
pom.xml
Normal file
43
pom.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?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>cf.semikolon</groupId>
|
||||
<artifactId>teamspeak</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>TeamSpeak-3-Java-API-mvn-repo</id>
|
||||
<url>https://raw.githubusercontent.com/TheHolyWaffle/TeamSpeak-3-Java-API/mvn-repo/</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!--Spigot-API-->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.8-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.theholywaffle</groupId>
|
||||
<artifactId>teamspeak3-api</artifactId>
|
||||
<version>[1.0.0,2.0.0)</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
70
src/main/java/cf/semikolon/teamspeak/FileSystem.java
Normal file
70
src/main/java/cf/semikolon/teamspeak/FileSystem.java
Normal file
@ -0,0 +1,70 @@
|
||||
package cf.semikolon.teamspeak;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by jan on 25.07.16.
|
||||
*
|
||||
* @version 4.0
|
||||
*/
|
||||
public abstract class FileSystem {
|
||||
|
||||
File cfgFile = null;
|
||||
YamlConfiguration cfg = null;
|
||||
|
||||
public FileSystem(String pluginName, String fileName) {
|
||||
this.cfgFile = new File("plugins/" + pluginName, fileName + ".yml");
|
||||
this.cfg = YamlConfiguration.loadConfiguration(cfgFile);
|
||||
if (!this.cfgFile.exists()) {
|
||||
try {
|
||||
this.cfgFile.createNewFile();
|
||||
load();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Fehler beim erstellen!");
|
||||
}
|
||||
initConfig();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public File getCfgFile() {
|
||||
return cfgFile;
|
||||
}
|
||||
|
||||
public abstract void initConfig();
|
||||
|
||||
public void load() {
|
||||
|
||||
try {
|
||||
if (!this.cfgFile.exists()) {
|
||||
this.cfgFile.createNewFile();
|
||||
} else {
|
||||
cfg.load(this.cfgFile);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
save();
|
||||
load();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
|
||||
try {
|
||||
this.cfg.save(this.cfgFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public YamlConfiguration getCfg() {
|
||||
return cfg;
|
||||
}
|
||||
|
||||
}
|
47
src/main/java/cf/semikolon/teamspeak/MainClass.java
Normal file
47
src/main/java/cf/semikolon/teamspeak/MainClass.java
Normal file
@ -0,0 +1,47 @@
|
||||
package cf.semikolon.teamspeak;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Created by jan on 25.07.16.
|
||||
*/
|
||||
public class MainClass extends JavaPlugin {
|
||||
|
||||
private static MainClass INSTANCE;
|
||||
private ServerQuery serverQuery;
|
||||
|
||||
FileSystem cfg = new FileSystem("TeamspekAuth", "config") {
|
||||
@Override
|
||||
public void initConfig() {
|
||||
getCfg().set("tsHost", "127.0.0.1");
|
||||
getCfg().set("queryPort", 10011);
|
||||
getCfg().set("queryUser", "serveradmin");
|
||||
getCfg().set("queryPassword", "password");
|
||||
getCfg().set("tsPort", 9987);
|
||||
getCfg().set("botNickname", "TeamspeakAuth");
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
INSTANCE = this;
|
||||
System.out.println("Plugin TeamspeakAuth by Semikolon\nconnecting...");
|
||||
serverQuery = new ServerQuery(cfg.getCfg().getString("tsHost"),
|
||||
cfg.getCfg().getInt("queryPort"),
|
||||
cfg.getCfg().getInt("tsPort"),
|
||||
cfg.getCfg().getString("queryUser"),
|
||||
cfg.getCfg().getString("queryPassword"),
|
||||
cfg.getCfg().getString("botNickname"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
|
||||
public static MainClass getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
35
src/main/java/cf/semikolon/teamspeak/ServerQuery.java
Normal file
35
src/main/java/cf/semikolon/teamspeak/ServerQuery.java
Normal file
@ -0,0 +1,35 @@
|
||||
package cf.semikolon.teamspeak;
|
||||
|
||||
import com.github.theholywaffle.teamspeak3.TS3ApiAsync;
|
||||
import com.github.theholywaffle.teamspeak3.TS3Config;
|
||||
import com.github.theholywaffle.teamspeak3.TS3Query;
|
||||
import com.github.theholywaffle.teamspeak3.api.reconnect.ReconnectStrategy;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Created by jan on 25.07.16.
|
||||
*/
|
||||
public class ServerQuery {
|
||||
private TS3Config tsconfig = new TS3Config();
|
||||
private TS3Query query;
|
||||
private TS3ApiAsync api;
|
||||
|
||||
public ServerQuery(String host, int queryPort, int tsPort, String queryUser, String queryPassword, String nickname) {
|
||||
this.tsconfig.setHost(host);
|
||||
this.tsconfig.setQueryPort(queryPort);
|
||||
this.tsconfig.setDebugLevel(Level.ALL);
|
||||
this.query = new TS3Query(tsconfig);
|
||||
this.query.connect();
|
||||
System.out.println("Successfully connected to TeamSpeak!\n Logging in...");
|
||||
this.api = query.getAsyncApi();
|
||||
this.api.login(queryUser, queryPassword);
|
||||
System.out.println("Login successfully");
|
||||
this.api.selectVirtualServerByPort(tsPort);
|
||||
this.api.setNickname(nickname);
|
||||
}
|
||||
|
||||
public TS3ApiAsync getApi() {
|
||||
return api;
|
||||
}
|
||||
}
|
5
src/main/resources/plugin.yml
Normal file
5
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,5 @@
|
||||
name: TeamspeakAuth
|
||||
version: 1.0
|
||||
author: Semikolon
|
||||
main: cf.semikolon.teamspeak.MainClass
|
||||
commands:
|
Loading…
x
Reference in New Issue
Block a user