changed package name, fixed bugs

This commit is contained in:
Johannes Theiner 2015-12-06 11:04:47 +01:00
parent 1bc996652f
commit 63944b2aac
64 changed files with 676 additions and 338 deletions

View File

@ -3,5 +3,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="F:/DevServer/Spigot/spigot.jar"/>
<classpathentry kind="lib" path="F:/Sources/Jars/teamspeak3-api-1.0.12.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,161 +0,0 @@
package de.joethei.core.api;
import de.joethei.core.Core;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
/**
* some permission management
* @author joethei
* @version 1.0
*/
public class Perms{
private static HashMap<CustomPlayer, Ranks> ranks = new HashMap<CustomPlayer, Ranks>();
public static HashMap<CustomPlayer, Ranks> getRanks() {
return ranks;
}
/**
* gets the prefix of a player
* @param p player
* @return String
*/
public static String getPrefix(CustomPlayer p) {
switch(p.getRank()) {
case Admin: return "§7[§4Admin§7]§4 ";
case Developer: return "§7[§3Developer§7]§3 ";
case HeadBuilder: return "§7[§aHead-Builder§7]§a ";
case Builder: return "§7[§2Builder§7]§2 ";
case Moderator: return "§7[§cModerator§7]§c ";
case Supporter: return "§7[§bSupporter§7]§b ";
case Youtuber: return "§5";
case Premium: return "§6";
case Spieler: return "§7";
default: return "§cFehler ";
}
}
/**
* gets the suffix of a player
* @param p Player
* @return String
*/
public static String getSuffix(CustomPlayer p) {
switch(p.getRank()) {
case Admin: return " §8» §f§l";
case Developer: return " §8» §f§l";
case HeadBuilder: return " §8» §f§l";
case Builder: return " §8» §f§l";
case Moderator: return " §8» §f§l";
case Supporter: return " §8» §f§l";
case Youtuber: return " §8» §f§l";
case Premium: return " §8» §f";
case Spieler: return " §8» §f";
default: return "§cFehler";
}
}
/**
* gets color of a player
* @param p Player
* @return String
*/
public static String getColor(CustomPlayer p) {
switch(p.getRank()) {
case Admin: return "§4";
case Developer: return "§3";
case HeadBuilder: return "§a";
case Builder: return "§2";
case Moderator: return "§c";
case Supporter: return "§b";
case Youtuber: return "§5";
case Premium: return "§6";
case Spieler: return "§7";
default: return "§cFehler";
}
}
/**
* gets Rank of player
* @param p Player
* @return Ranks
*/
public static Ranks getRank(CustomPlayer p) {
return getRanks().get(p);
}
/**
* gets Rank of player fresh from database
* @param p Player
* @return Ranks
* @throws ClassNotFoundException Class couldn't be found
* @throws SQLException SQL server not available or throwing error
*/
public static Ranks getRankFresh(CustomPlayer p) throws SQLException, ClassNotFoundException {
MySQL sql = Core.returnSQL();
sql.openConnection();
ResultSet rs = sql.getConnection().createStatement().executeQuery("SELECT * FROM PlayerData WHERE player_uuid='" + p.getUniqueId() + "'");
rs.next();
if (rs.getString("player_uuid") != null) {
String rank = rs.getString("Rank");
Ranks Rank = Ranks.valueOf(rank);
sql.closeConnection();
return Rank;
}
sql.closeConnection();
return null;
}
/**
* sets rank for player
* @param p Player
* @param r Ranks
* @throws ClassNotFoundException Class couldn't be found
* @throws SQLException SQL server not available or throwing error
*/
public static void setRank(CustomPlayer p, Ranks r) throws ClassNotFoundException, SQLException {
MySQL sql = Core.returnSQL();
sql.openConnection();
sql.getConnection().createStatement().execute("UPDATE PlayerData SET Rank='" + r.toString() + "' WHERE player_uuid='" + p.getUniqueId() + "';");
sql.closeConnection();
}
/**
* if player is allowed to do
* @param p Player
* @param r Ranks
* @return true / false
* @throws ClassNotFoundException Class couldn't be found
* @throws SQLException SQL server not available or throwing error
*/
public static boolean isAllowed(CustomPlayer p, Ranks r) throws ClassNotFoundException, SQLException{
Ranks rank;
if(getRank(p) == null) {
rank = getRankFresh(p);
}else {
rank = getRank(p);
}
return rank.value >= r.value;
}
public static enum Ranks{
Admin(9),
Developer(8),
HeadBuilder(7),
Builder(6),
Moderator(5),
Supporter(4),
Youtuber(3),
Premium(2),
Spieler(1);
public final int value;
private Ranks(int n) {
this.value = n;
}
}
}

View File

@ -1,4 +1,4 @@
package de.joethei.core;
package eu.univento.core;
import java.io.IOException;
import java.sql.SQLException;
@ -10,25 +10,27 @@ import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import de.joethei.core.api.Messages;
import de.joethei.core.api.Config;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.MySQL;
import de.joethei.core.api.Settings;
import de.joethei.core.commands.Ban;
import de.joethei.core.commands.Build;
import de.joethei.core.commands.Fix;
import de.joethei.core.commands.GameMode;
import de.joethei.core.commands.GlobalMute;
import de.joethei.core.commands.RunAs;
import de.joethei.core.commands.SetRank;
import de.joethei.core.commands.SystemInfo;
import de.joethei.core.commands.Vanish;
import de.joethei.core.commands.Youtuber;
import de.joethei.core.listeners.Blocks;
import de.joethei.core.listeners.Chat;
import de.joethei.core.listeners.Commands;
import de.joethei.core.listeners.JoinQuit;
import eu.univento.core.api.Config;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
import eu.univento.core.api.MySQL;
import eu.univento.core.api.Perms;
import eu.univento.core.api.Settings;
import eu.univento.core.commands.Ban;
import eu.univento.core.commands.Build;
import eu.univento.core.commands.Fix;
import eu.univento.core.commands.GameMode;
import eu.univento.core.commands.GlobalMute;
import eu.univento.core.commands.RunAs;
import eu.univento.core.commands.SetRank;
import eu.univento.core.commands.SystemInfo;
import eu.univento.core.commands.TS;
import eu.univento.core.commands.Vanish;
import eu.univento.core.commands.Youtuber;
import eu.univento.core.listeners.Blocks;
import eu.univento.core.listeners.Chat;
import eu.univento.core.listeners.Commands;
import eu.univento.core.listeners.JoinQuit;
/**
* main class
@ -51,7 +53,7 @@ public class Core extends JavaPlugin{
/**
* mysql stuff
*/
private static MySQL sql = new MySQL(getInstance(), Config.readString("MySQL.Host"), Config.readString("MySQL.Port"), Config.readString("MySQL.DB"), Config.readString("MySQL.User"), Config.readString("MySQL.Pass") + "?autoReconnect=true");
private static MySQL sql = new MySQL(getInstance(), Config.readString("MySQL.Host"), Config.readString("MySQL.Port"), Config.readString("MySQL.DB"), Config.readString("MySQL.User"), Config.readString("MySQL.Pass"));
/**
* @return sql
*/
@ -83,12 +85,12 @@ public class Core extends JavaPlugin{
Settings.setBuild(true);
try {
Config.writeDefault();
} catch (ClassNotFoundException | SQLException | IOException e1) {
e1.printStackTrace();
} catch (ClassNotFoundException | SQLException | IOException e) {
e.printStackTrace();
}
instance = this;
if(Settings.isDebug()) log(Level.INFO, "Debug Modus aktiviert");
Perms.initScoreboard();
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new Commands(), this);
pm.registerEvents(new JoinQuit(), this);
@ -121,6 +123,9 @@ public class Core extends JavaPlugin{
String[] youtuber = {""};
new Youtuber(this, "youtuber", "setzt Spieler in den Youtuber Rang", youtuber);
String[] ts = {""};
new TS(this, "ts", "verifiziert Spieler auf dem TS", ts);
String[] ban = {""};
new Ban(this, "ban", "Bannt Spieler", ban);
@ -137,7 +142,7 @@ public class Core extends JavaPlugin{
MySQL tempSQL = sql;
tempSQL.openConnection();
tempSQL.getConnection().createStatement().execute("CREATE TABLE IF NOT EXISTS PlayerData(ID bigint PRIMARY KEY auto_increment, player_uuid varchar(50), FirstJoin TIMESTAMP default now(), Coins bigint, mute boolean, Rank varchar(15), nick boolean, FastMenu boolean, teleport boolean);");
tempSQL.getConnection().createStatement().execute("CREATE TABLE IF NOT EXISTS PlayerData(ID bigint PRIMARY KEY auto_increment, player_uuid varchar(50), FirstJoin TIMESTAMP default now(), Coins bigint, mute boolean, Rank varchar(15),TS-ID bigint, Friends varchar(2500), nick boolean, FastMenu boolean, teleport boolean);");
if(Settings.isDebug()) log(Level.INFO, "MySQL PlayerData ausgeführt");
tempSQL.getConnection().createStatement().execute("CREATE TABLE IF NOT EXISTS bans(ID bigint PRIMARY KEY auto_increment, player_uuid varchar(50), Reason varchar(50), who varchar(50));");
@ -157,6 +162,12 @@ public class Core extends JavaPlugin{
e.printStackTrace();
}
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
try {
Messages.writeDefault();
Messages.readStrings();
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
log(Level.INFO, "Plugin ver. " + getDescription().getVersion() + " gestartet");
}

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.lang.reflect.Field;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.lang.reflect.Field;
import java.util.ArrayList;

View File

@ -1,7 +1,7 @@
package de.joethei.core.api;
package eu.univento.core.api;
import de.joethei.core.Core;
import de.joethei.core.api.utils.NameFetcher;
import eu.univento.core.Core;
import eu.univento.core.api.utils.NameFetcher;
import java.sql.ResultSet;
import java.sql.SQLException;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

View File

@ -1,11 +1,12 @@
package de.joethei.core.api;
package eu.univento.core.api;
import de.joethei.core.api.utils.FakeDragon;
import de.joethei.core.api.utils.FakeWither;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.entity.Player;
import eu.univento.core.api.utils.FakeDragon;
import eu.univento.core.api.utils.FakeWither;
public class BossBar
{
public static Map<Player, String> playerdragonbartask = new HashMap<Player, String>();

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.io.File;
import java.io.IOException;
@ -29,11 +29,15 @@ public class Config {
//editable messages will be set here, but do not edit this messages.
//seting the default MySQL config.
cfg.set("MySQL.Host", "192.168.0.101");
cfg.set("MySQL.Port", "3306");
cfg.set("MySQL.DB", "core");
cfg.set("MySQL.User", "root");//best user name
cfg.set("MySQL.Pass", "");//best password
cfg.addDefault("MySQL.Host", "192.168.0.101");
cfg.addDefault("MySQL.Port", "3306");
cfg.addDefault("MySQL.DB", "core");
cfg.addDefault("MySQL.User", "root");//best user name
cfg.addDefault("MySQL.Pass", "");//best password
cfg.addDefault("TS.IP", "ts.univento.eu");
cfg.addDefault("TS.QueryPort", 0);
cfg.addDefault("TS.QueryUser", "ServerQuery");
cfg.addDefault("TS.QueryPass", "password");
cfg.options().copyDefaults(true);
cfg.save(file);

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.sql.SQLException;
import java.util.HashMap;
@ -7,8 +7,11 @@ import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Team;
import de.joethei.core.api.Perms.Ranks;
import com.github.theholywaffle.teamspeak3.api.wrapper.ClientInfo;
import eu.univento.core.api.Perms.Ranks;
/**
* custom player implementation
@ -132,7 +135,7 @@ public class CustomPlayer extends CraftPlayer {
if(customPrefix != null) {
return customPrefix;
}else {
return Perms.getPrefix(this);
return Perms.getPrefix(getRank());
}
}
@ -144,7 +147,7 @@ public class CustomPlayer extends CraftPlayer {
if(customSuffix != null) {
return customSuffix;
}
return Perms.getSuffix(this);
return Perms.getSuffix(getRank());
}
/**
@ -155,7 +158,7 @@ public class CustomPlayer extends CraftPlayer {
if(customColor != null) {
return customColor;
}
return Perms.getColor(this);
return Perms.getColor(getRank());
}
/**
@ -182,6 +185,14 @@ public class CustomPlayer extends CraftPlayer {
customColor = color;
}
/**
* gets scoreboard team for player
* @return Team
*/
public Team getTeam() {
return Perms.getTeam(getRank());
}
/**
* if player is muted
* @return true/false
@ -292,4 +303,31 @@ public class CustomPlayer extends CraftPlayer {
}
}
/**
* gets Client Info from TeamSpeak
* @return ClientInfo
*/
public ClientInfo getTSClientInfo() {
TeamSpeak ts = new TeamSpeak();
try {
return ts.getClientInfo(ts.getTsId(this));
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
return null;
}
}
/**
* verifys player account on teamspeak
*/
public void verifyTs() {
TeamSpeak ts = new TeamSpeak();
try {
ts.setRank(this);
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
}
}

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.sql.Connection;
import java.sql.ResultSet;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.lang.reflect.Field;
import net.minecraft.server.v1_8_R3.EntityLiving;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;

View File

@ -1,12 +1,13 @@
package de.joethei.core.api;
package eu.univento.core.api;
import de.joethei.core.api.utils.Direction;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import eu.univento.core.api.utils.Direction;
public enum Letters
{
LETTER_A('a',

View File

@ -1,9 +1,9 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.sql.ResultSet;
import java.sql.SQLException;
import de.joethei.core.Core;
import eu.univento.core.Core;
/**
* messages from database

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.io.BufferedReader;
import java.io.IOException;

View File

@ -1,10 +1,10 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import eu.univento.core.Core;
/**
* querys database for muted players

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.sql.Connection;
import java.sql.DriverManager;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -6,7 +6,7 @@ import java.util.ArrayList;
import java.util.Random;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import eu.univento.core.Core;
/**
* gets nick settings for players

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.util.ArrayList;
import java.util.List;

View File

@ -0,0 +1,237 @@
package eu.univento.core.api;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import eu.univento.core.Core;
/**
* some permission management
* @author joethei
* @version 1.0
*/
public class Perms{
private static HashMap<CustomPlayer, Ranks> ranks = new HashMap<CustomPlayer, Ranks>();
public static HashMap<CustomPlayer, Ranks> getRanks() {
return ranks;
}
/**
* gets the prefix of a player
* @param r Ranks
* @return String
*/
public static String getPrefix(Ranks r) {
switch(r) {
case Admin: return "§7[§4Admin§7]§4 ";
case Developer: return "§7[§aDeveloper§7]§3 ";
case Moderator: return "§7[§cModerator§7]§c ";
case HeadBuilder: return "§7[§2Head-Builder§7]§a ";
case Builder: return "§7[§2Builder§7]§2 ";
case Supporter: return "§7[§bSupporter§7]§b ";
case Youtuber: return "§5";
case Premium: return "§6";
case Spieler: return "§7";
default: return "§cFehler ";
}
}
/**
* gets the suffix of a player
* @param r Ranks
* @return String
*/
public static String getSuffix(Ranks r) {
switch(r) {
case Admin: return " §8» §6";
case Developer: return " §8» §f";
case Moderator: return " §8» §f";
case HeadBuilder: return " §8» §f";
case Builder: return " §8» §f";
case Supporter: return " §8» §f";
case Youtuber: return " §8» §f";
case Premium: return " §8» §f";
case Spieler: return " §8» §f";
default: return "§cFehler";
}
}
/**
* gets color of a player
* @param r Ranks
* @return String
*/
public static String getColor(Ranks r) {
switch(r) {
case Admin: return "§4";
case Developer: return "§3";
case Moderator: return "§c";
case HeadBuilder: return "§a";
case Builder: return "§2";
case Supporter: return "§b";
case Youtuber: return "§5";
case Premium: return "§6";
case Spieler: return "§7";
default: return "§cFehler";
}
}
public static Team getTeam(Ranks r) {
switch(r) {
case Admin: return Teams.Admin;
case Developer: return Teams.Developer;
case Moderator: return Teams.Moderator;
case HeadBuilder: return Teams.HeadBuilder;
case Builder: return Teams.Builder;
case Supporter: return Teams.Supporter;
case Youtuber: return Teams.Youtuber;
case Premium: return Teams.Premium;
case Spieler: return Teams.Spieler;
default: return null;
}
}
public static class Teams {
private static Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard();
public static Team Admin = board.getTeam("a");
public static Team Developer = board.getTeam("b");
public static Team Moderator = board.getTeam("c");
public static Team HeadBuilder = board.getTeam("d");
public static Team Builder = board.getTeam("e");
public static Team Supporter = board.getTeam("f");
public static Team Youtuber = board.getTeam("g");
public static Team Premium = board.getTeam("h");
public static Team Spieler = board.getTeam("i");
}
public static void initScoreboard() {
Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard();
Teams.Admin.unregister();
Teams.Developer.unregister();
Teams.Moderator.unregister();
Teams.HeadBuilder.unregister();
Teams.Builder.unregister();
Teams.Supporter.unregister();
Teams.Youtuber.unregister();
Teams.Premium.unregister();
Teams.Spieler.unregister();
Team Admin = board.registerNewTeam("a");
Team Developer = board.registerNewTeam("b");
Team Moderator = board.registerNewTeam("c");
Team HeadBuilder = board.registerNewTeam("d");
Team Builder = board.registerNewTeam("e");
Team Supporter = board.registerNewTeam("f");
Team Youtuber = board.registerNewTeam("g");
Team Premium = board.registerNewTeam("h");
Team Spieler = board.registerNewTeam("i");
Teams.Admin.setPrefix(getColor(Ranks.Admin));
Teams.Developer.setPrefix(getColor(Ranks.Developer));
Teams.Moderator.setPrefix(getColor(Ranks.Moderator));
Teams.HeadBuilder.setPrefix(getColor(Ranks.HeadBuilder));
Teams.Builder.setPrefix(getColor(Ranks.Builder));
Teams.Supporter.setPrefix(getColor(Ranks.Supporter));
Teams.Youtuber.setPrefix(getColor(Ranks.Youtuber));
Teams.Premium.setPrefix(getColor(Ranks.Premium));
Teams.Spieler.setPrefix(getColor(Ranks.Spieler));
Teams.Admin.setNameTagVisibility(NameTagVisibility.ALWAYS);
Teams.Developer.setNameTagVisibility(NameTagVisibility.ALWAYS);
Teams.Moderator.setNameTagVisibility(NameTagVisibility.ALWAYS);
Teams.HeadBuilder.setNameTagVisibility(NameTagVisibility.ALWAYS);
Teams.Builder.setNameTagVisibility(NameTagVisibility.ALWAYS);
Teams.Supporter.setNameTagVisibility(NameTagVisibility.ALWAYS);
Teams.Youtuber.setNameTagVisibility(NameTagVisibility.ALWAYS);
Teams.Premium.setNameTagVisibility(NameTagVisibility.ALWAYS);
Teams.Spieler.setNameTagVisibility(NameTagVisibility.ALWAYS);
}
/**
* gets Rank of player
* @param p Player
* @return Ranks
*/
public static Ranks getRank(CustomPlayer p) {
return getRanks().get(p);
}
/**
* gets Rank of player fresh from database
* @param p Player
* @return Ranks
* @throws ClassNotFoundException Class couldn't be found
* @throws SQLException SQL server not available or throwing error
*/
public static Ranks getRankFresh(CustomPlayer p) throws SQLException, ClassNotFoundException {
MySQL sql = Core.returnSQL();
sql.openConnection();
ResultSet rs = sql.getConnection().createStatement().executeQuery("SELECT * FROM PlayerData WHERE player_uuid='" + p.getUniqueId() + "'");
rs.next();
if (rs.getString("player_uuid") != null) {
String rank = rs.getString("Rank");
Ranks Rank = Ranks.valueOf(rank);
sql.closeConnection();
return Rank;
}
sql.closeConnection();
return null;
}
/**
* sets rank for player
* @param p Player
* @param r Ranks
* @throws ClassNotFoundException Class couldn't be found
* @throws SQLException SQL server not available or throwing error
*/
public static void setRank(CustomPlayer p, Ranks r) throws ClassNotFoundException, SQLException {
MySQL sql = Core.returnSQL();
sql.openConnection();
sql.getConnection().createStatement().execute("UPDATE PlayerData SET Rank='" + r.toString() + "' WHERE player_uuid='" + p.getUniqueId() + "';");
sql.closeConnection();
}
/**
* if player is allowed to do
* @param p Player
* @param r Ranks
* @return true / false
* @throws ClassNotFoundException Class couldn't be found
* @throws SQLException SQL server not available or throwing error
*/
public static boolean isAllowed(CustomPlayer p, Ranks r) throws ClassNotFoundException, SQLException{
Ranks rank;
if(getRank(p) == null) {
rank = getRankFresh(p);
}else {
rank = getRank(p);
}
return rank.value >= r.value;
}
public static enum Ranks{
Admin(9),
Developer(8),
Moderator(7),
HeadBuilder(6),
Builder(5),
Supporter(4),
Youtuber(3),
Premium(2),
Spieler(1);
public final int value;
private Ranks(int n) {
this.value = n;
}
}
}

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.io.File;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.io.DataOutputStream;
import java.io.InputStream;

View File

@ -1,9 +1,10 @@
package de.joethei.core.api;
package eu.univento.core.api;
import com.google.common.collect.Iterables;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import de.joethei.core.Core;
import eu.univento.core.Core;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
/**
* server-wide settings

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.util.ArrayList;

View File

@ -0,0 +1,146 @@
package eu.univento.core.api;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import com.github.theholywaffle.teamspeak3.TS3Api;
import com.github.theholywaffle.teamspeak3.TS3Config;
import com.github.theholywaffle.teamspeak3.TS3Query;
import com.github.theholywaffle.teamspeak3.api.wrapper.Client;
import com.github.theholywaffle.teamspeak3.api.wrapper.ClientInfo;
import eu.univento.core.Core;
import eu.univento.core.api.Perms.Ranks;
/**
* basic functions for teamspeak communication
* @author joethei
* @version 1.0
*/
public class TeamSpeak {
private TS3Api api;
private static int verified = 11;
public static int getVerifiedId() {
return verified;
}
/**
* inits class
*/
public TeamSpeak() {
final TS3Config config = new TS3Config();
config.setHost(Config.readString("TS.IP"));
config.setQueryPort(Config.readInt("TS.QueryPort"));
config.setDebugLevel(Level.ALL);
config.setLoginCredentials(Config.readString("TS.QueryUser"), Config.readString("TS.Query.Pass"));
final TS3Query query = new TS3Query(config);
query.connect();
final TS3Api api = query.getApi();
api.selectVirtualServerById(1);
api.setNickname("Rechteverteiler");
this.api = api;
}
/**
* gets teamspeak api
* @return TS3Api
*/
public TS3Api getAPI() {
return api;
}
/**
* gets client info for id
* @param id database id
* @return ClientInfo
*/
public ClientInfo getClientInfo(int id) {
return api.getClientInfo(id);
}
/**
* gets database id from teamspeak for player
* @param p CustomPlayer
* @return Integer
* @throws SQLException SQL server not available or throwing error
* @throws ClassNotFoundException class couldn't be found
*/
public int getTsId(CustomPlayer p) throws ClassNotFoundException, SQLException {
MySQL sql = Core.returnSQL();
sql.openConnection();
ResultSet rs = sql.getConnection().createStatement().executeQuery("SELECT * FROM PlayerData WHERE player_uuid='" + p.getUniqueId() + "'");
rs.next();
if (rs.getInt("TS-ID") != 0) {
int id = rs.getInt("TS-ID");
sql.closeConnection();
return id;
}
sql.closeConnection();
return 0;
}
/**
* writes id of player to database
* @param p CustomPlayer
* @param id database id
* @throws SQLException SQL server not available or throwing error
* @throws ClassNotFoundException class couldn't be found
*/
private void setTsId(CustomPlayer p, int id) throws ClassNotFoundException, SQLException {
MySQL sql = Core.returnSQL();
sql.openConnection();
sql.getConnection().createStatement().execute("UPDATE PlayerData SET TS-ID='" + id + "' WHERE player_uuid='" + p.getUniqueId() + "';");
sql.closeConnection();
}
/**
* sets rank on teamspeak
* @param p CustomPlayer
* @throws SQLException SQL server not available or throwing error
* @throws ClassNotFoundException class couldn't be found
*/
public void setRank(CustomPlayer p) throws ClassNotFoundException, SQLException {
TS3Api api = getAPI();
for(int i = 0; i >= api.getClients().size(); i++) {
String player_ip = p.getAddress().getHostName();
Client client = api.getClients().get(i);
ClientInfo info = api.getClientInfo(client.getId());
String ts_ip = info.getIp();
if(player_ip == ts_ip) {
int db_id = getTsId(p);
if(db_id == 0) {
api.removeClientFromServerGroup(getIdForRank(p.getRank()), db_id);
api.removeClientFromServerGroup(getVerifiedId(), db_id);
}
api.addClientToServerGroup(getIdForRank(p.getRank()), client.getDatabaseId());
api.addClientToServerGroup(getVerifiedId(), client.getDatabaseId());
setTsId(p, client.getDatabaseId());
}
}
}
/**
* gets group id for rank
* @param r Ranks
* @return Integer
*/
public int getIdForRank(Ranks r) {
switch(r) {
case Admin: return 10;
case Developer: return 13;
case Moderator: return 12;
case HeadBuilder: return 19;
case Builder: return 20;
case Supporter: return 14;
case Youtuber: return 21;
case Premium: return 22;
case Spieler: return 42;
default: return 0;
}
}
}

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.lang.reflect.Field;
import net.minecraft.server.v1_8_R3.IChatBaseComponent;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api;
package eu.univento.core.api;
import java.io.File;
import java.util.List;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.twitch;
package eu.univento.core.api.twitch;
import java.io.BufferedReader;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.twitch;
package eu.univento.core.api.twitch;
import com.google.gson.Gson;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.twitch;
package eu.univento.core.api.twitch;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.utils;
package eu.univento.core.api.utils;
public enum Direction
{

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.utils;
package eu.univento.core.api.utils;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.utils;
package eu.univento.core.api.utils;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.utils;
package eu.univento.core.api.utils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.utils;
package eu.univento.core.api.utils;
import java.util.Calendar;
import java.util.GregorianCalendar;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.utils;
package eu.univento.core.api.utils;
import com.google.common.collect.ImmutableList;
import java.io.InputStreamReader;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.utils;
package eu.univento.core.api.utils;
import java.util.NavigableMap;
import java.util.Random;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.utils;
package eu.univento.core.api.utils;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.utils;
package eu.univento.core.api.utils;
import org.bukkit.util.Vector;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.youtube;
package eu.univento.core.api.youtube;
import java.io.BufferedReader;
import java.io.InputStreamReader;

View File

@ -1,4 +1,4 @@
package de.joethei.core.api.youtube;
package eu.univento.core.api.youtube;
import java.beans.ConstructorProperties;

View File

@ -1,4 +1,4 @@
package de.joethei.core.commands;
package eu.univento.core.commands;
import java.util.ArrayList;
import java.util.HashMap;
@ -8,11 +8,11 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import de.joethei.core.api.AutoCommand;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Messages;
import de.joethei.core.api.Perms.Ranks;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
import eu.univento.core.api.Perms.Ranks;
/**
* command to ban players

View File

@ -1,4 +1,4 @@
package de.joethei.core.commands;
package eu.univento.core.commands;
import java.util.ArrayList;
import java.util.List;
@ -6,11 +6,11 @@ import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import de.joethei.core.api.AutoCommand;
import de.joethei.core.api.Messages;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Perms.Ranks;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
import eu.univento.core.api.Perms.Ranks;
/**
* lets player build

View File

@ -1,4 +1,4 @@
package de.joethei.core.commands;
package eu.univento.core.commands;
import java.util.ArrayList;
import java.util.List;
@ -7,10 +7,10 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import de.joethei.core.api.AutoCommand;
import de.joethei.core.api.Messages;
import de.joethei.core.api.CustomPlayer;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
/**
* fixes players

View File

@ -1,4 +1,4 @@
package de.joethei.core.commands;
package eu.univento.core.commands;
import java.util.ArrayList;
import java.util.List;
@ -6,11 +6,11 @@ import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import de.joethei.core.api.AutoCommand;
import de.joethei.core.api.Messages;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Perms.Ranks;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
import eu.univento.core.api.Perms.Ranks;
/**
* changes game modes

View File

@ -1,16 +1,16 @@
package de.joethei.core.commands;
package eu.univento.core.commands;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import de.joethei.core.api.AutoCommand;
import de.joethei.core.api.Messages;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Perms.Ranks;
import de.joethei.core.api.Settings;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
import eu.univento.core.api.Settings;
import eu.univento.core.api.Perms.Ranks;
/**
* mutes the whole server

View File

@ -1,4 +1,4 @@
package de.joethei.core.commands;
package eu.univento.core.commands;
import java.util.ArrayList;
import java.util.List;
@ -7,11 +7,11 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import de.joethei.core.api.AutoCommand;
import de.joethei.core.api.Messages;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Perms.Ranks;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
import eu.univento.core.api.Perms.Ranks;
/**
* lets other player run commands

View File

@ -1,4 +1,4 @@
package de.joethei.core.commands;
package eu.univento.core.commands;
import java.sql.SQLException;
import java.util.ArrayList;
@ -8,12 +8,12 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import de.joethei.core.api.AutoCommand;
import de.joethei.core.api.Messages;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Perms;
import de.joethei.core.api.Perms.Ranks;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
import eu.univento.core.api.Perms;
import eu.univento.core.api.Perms.Ranks;
/**
* sets ranks for players

View File

@ -1,4 +1,4 @@
package de.joethei.core.commands;
package eu.univento.core.commands;
import java.util.List;
@ -6,11 +6,11 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import de.joethei.core.api.AutoCommand;
import de.joethei.core.api.Messages;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Perms.Ranks;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
import eu.univento.core.api.Perms.Ranks;
/**
* prints infos about the server

View File

@ -0,0 +1,57 @@
package eu.univento.core.commands;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
import eu.univento.core.api.TeamSpeak;
/**
* sets ts groups according to player rank
* @author joethei
* @version 1.0
*/
public class TS extends AutoCommand<Core>{
/**
* @param plugin main class
* @param command command to execute
* @param description describes the command
* @param aliases aliases of command
*/
public TS(Core plugin, String command, String description, String[] aliases) {
super(plugin, command, description, aliases);
}
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if(sender instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer(sender.getName());
if(p.getTSClientInfo() != null) {
for(int i = 0; i >= p.getTSClientInfo().getServerGroups().length; i++) {
int[] groups = p.getTSClientInfo().getServerGroups();
if(groups[i] == TeamSpeak.getVerifiedId()) {
p.sendMessage(Messages.PREFIX + "§cDu hast schon einen verknüpften TS Account !");
}else {
p.verifyTs();
p.sendMessage(Messages.PREFIX + "§aDu bist nun verifiziert");
}
}
}
}else {
sender.sendMessage(Messages.NOT_A_PLAYER);
}
return true;
}
@Override
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
return null;
}
}

View File

@ -1,16 +1,16 @@
package de.joethei.core.commands;
package eu.univento.core.commands;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import de.joethei.core.api.AutoCommand;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Messages;
import de.joethei.core.api.twitch.Twitch_API;
import de.joethei.core.api.twitch.Twitch_Stream;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
import eu.univento.core.api.twitch.Twitch_API;
import eu.univento.core.api.twitch.Twitch_Stream;
/**
* send info about twitch streams

View File

@ -1,4 +1,4 @@
package de.joethei.core.commands;
package eu.univento.core.commands;
import java.util.ArrayList;
import java.util.List;
@ -7,11 +7,11 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import de.joethei.core.api.AutoCommand;
import de.joethei.core.api.Messages;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Perms.Ranks;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
import eu.univento.core.api.Perms.Ranks;
/**
* vanish players

View File

@ -1,16 +1,16 @@
package de.joethei.core.commands;
package eu.univento.core.commands;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.joethei.core.Core;
import de.joethei.core.api.AutoCommand;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Messages;
import de.joethei.core.api.youtube.YTAPI;
import de.joethei.core.api.youtube.YoutubeChannel;
import eu.univento.core.Core;
import eu.univento.core.api.AutoCommand;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
import eu.univento.core.api.youtube.YTAPI;
import eu.univento.core.api.youtube.YoutubeChannel;
/**
* sets player to youtube rank

View File

@ -1,13 +1,13 @@
package de.joethei.core.listeners;
package eu.univento.core.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Settings;
import de.joethei.core.commands.Build;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Settings;
import eu.univento.core.commands.Build;
/**
* cancels building

View File

@ -1,13 +1,13 @@
package de.joethei.core.listeners;
package eu.univento.core.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Settings;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Settings;
import eu.univento.core.api.Perms.Ranks;
import net.md_5.bungee.api.ChatColor;
import de.joethei.core.api.Perms.Ranks;
/**
* manages chat

View File

@ -1,4 +1,4 @@
package de.joethei.core.listeners;
package eu.univento.core.listeners;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -8,10 +8,10 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.help.HelpTopic;
import de.joethei.core.Core;
import de.joethei.core.api.Messages;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.Perms.Ranks;
import eu.univento.core.Core;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.Messages;
import eu.univento.core.api.Perms.Ranks;
/**
* commands

View File

@ -1,4 +1,4 @@
package de.joethei.core.listeners;
package eu.univento.core.listeners;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -14,13 +14,13 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import de.joethei.core.Core;
import de.joethei.core.api.CustomPlayer;
import de.joethei.core.api.MySQL;
import de.joethei.core.api.NickName;
import de.joethei.core.api.Perms;
import de.joethei.core.api.Perms.Ranks;
import de.joethei.core.commands.Vanish;
import eu.univento.core.Core;
import eu.univento.core.api.CustomPlayer;
import eu.univento.core.api.MySQL;
import eu.univento.core.api.NickName;
import eu.univento.core.api.Perms;
import eu.univento.core.api.Perms.Ranks;
import eu.univento.core.commands.Vanish;
/**
* @author joethei
@ -32,12 +32,14 @@ public class JoinQuit implements Listener{
* Handles JoinMessage and vanished players
* @param e event
*/
@SuppressWarnings("deprecation")
@EventHandler
public void onJoin(PlayerJoinEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
e.setJoinMessage(null);
createPlayer(p);
Perms.getRanks().put(p, p.getRankFresh());
p.getTeam().addPlayer(p);
try {
setup(p, p.getRank());
} catch (SQLException e1) {

View File

@ -1,6 +1,6 @@
main: de.joethei.core.Core
main: eu.univento.core.Core
name: Core
description: univento Core
author: joethei
version: 0.1
version: 0.5
website: http://univento.eu