SteamWar/SpigotCore
Archiviert
13
0

Various things + Core Schematic API

Dieser Commit ist enthalten in:
Lixfel 2019-03-16 20:03:24 +01:00
Ursprung 443b7bdd38
Commit 95ebca1681
27 geänderte Dateien mit 1155 neuen und 1285 gelöschten Zeilen

1
.gitignore vendored
Datei anzeigen

@ -4,3 +4,4 @@
.settings .settings
target target
bin bin
*.iml

Datei anzeigen

@ -1,5 +0,0 @@
package de.diamant.hunjy.BanSystem;
public class BanManager {
}

Datei anzeigen

@ -1,90 +0,0 @@
package de.diamant.hunjy;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import de.diamant.hunjy.CoinSystem.CoinSystem;
import de.diamant.hunjy.CoinSystem.command.CoinCommand;
import de.diamant.hunjy.MySQL.MySQL;
import de.diamant.hunjy.Permissions.PermissionsManager;
import de.diamant.hunjy.Permissions.commands.PermsCommand;
import de.diamant.hunjy.PlayerManager.PlayerManager;
import de.diamant.hunjy.PlayerManager.events.ChatingEvent;
import de.diamant.hunjy.PlayerManager.events.PlayerJoin;
import de.diamant.hunjy.manager.CacheManager;
import de.diamant.hunjy.manager.FileManager;
public class Core extends JavaPlugin{
private MySQL mySQL;
public static String prefix = "§eCore §8» ";
private static Core instance;
private CacheManager cacheManager;
private FileManager fileManager;
@Override
public void onLoad() {
instance = this;
cacheManager = new CacheManager();
}
@Override
public void onEnable() {
fileManager = new FileManager();
mySQL = new MySQL("localhost", "3306", "core", "core", "150965Ingo");
mySQL.update("CREATE TABLE IF NOT EXISTS Coins(ID INT(16) PRIMARY KEY NOT NULL, Coins INT(16));");
mySQL.update("CREATE TABLE IF NOT EXISTS Permisson(GroupSortID VARCHAR(64), GroupName VARCHAR(64), GroupDisplay VARCHAR(64), Permissons LONGTEXT);");
mySQL.update("CREATE TABLE IF NOT EXISTS UserData(ID INT(16) PRIMARY KEY AUTO_INCREMENT NOT NULL,UUID VARCHAR(64), UserName VARCHAR(64) NOT NULL, UserGroup VARCHAR(64));");
new CoinSystem();
new PermissionsManager();
instance.getCommand("coins").setExecutor(new CoinCommand());
instance.getCommand("pay").setExecutor(new CoinCommand());
instance.getCommand("addcoins").setExecutor(new CoinCommand());
instance.getCommand("setcoins").setExecutor(new CoinCommand());
instance.getCommand("removecoins").setExecutor(new CoinCommand());
instance.getCommand("perms").setExecutor(new PermsCommand());
instance.getCommand("dperms").setExecutor(new PermsCommand());
Bukkit.getPluginManager().registerEvents(new PlayerJoin(), this);
Bukkit.getPluginManager().registerEvents(new ChatingEvent(), this);
}
public static Core getInstance() {
return instance;
}
public MySQL getMySQL() {
return mySQL;
}
public CacheManager getCacheManager() {
return cacheManager;
}
public PlayerManager getPlayerManager(Player player) {
return new PlayerManager(player);
}
public PlayerManager getPlayerManager(UUID uuid) {
return new PlayerManager(uuid);
}
public FileManager getFileManager() {
return fileManager;
}
}

Datei anzeigen

@ -1,158 +0,0 @@
package de.diamant.hunjy.Permissions.Manager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import de.diamant.hunjy.Core;
import de.diamant.hunjy.MySQL.MySQL;
public class GroupManager {
private MySQL mySQL;
public GroupManager() {
mySQL = Core.getInstance().getMySQL();
}
public boolean existGroup(String groupName) {
try {
PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM Permisson WHERE GroupName=?");
st.setString(1, groupName);
ResultSet rs = st.executeQuery();
return rs.next();
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
public boolean createGroup(int groupPower, String groupName, String display) {
if(!existGroup(groupName)) {
mySQL.update("INSERT INTO Permisson(GroupSortID, GroupName, GroupDisplay, Permissons) VALUES ('"+ groupPower +"', '" + groupName + "', '" + display + "', '')");
return true;
}
return false;
}
public void setPerms(String groupName, ArrayList<String> perms) {
mySQL.update("UPDATE Permisson SET Permissons='" + perms.toString() + "' WHERE GroupName='" + groupName + "'");
}
public void setDisplay(String groupName, String display) {
mySQL.update("UPDATE Permisson SET GroupDisplay='" + display + "' WHERE GroupName='" + groupName + "'");
}
public boolean deleteGroup(String groupName) {
if(existGroup(groupName)) {
try {
PreparedStatement st = mySQL.getCon().prepareStatement("DELETE FROM Permisson WHERE GroupName=?");
st.setString(1, groupName);
st.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
return true;
}
return false;
}
public String getDisplayFromGroup(String groupName) {
if(existGroup(groupName)) {
String display = "";
try {
PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM Permisson WHERE GroupName=?");
st.setString(1, groupName);
ResultSet rs = st.executeQuery();
while(rs.next()) {
display = rs.getString("GroupDisplay").replaceAll("&", "§");
}
} catch (SQLException e) {
e.printStackTrace();
}
return display;
}else {
return null;
}
}
public int getSortIDFromGroup(String groupName) {
if(existGroup(groupName)) {
int sortID = 0;
try {
PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM Permisson WHERE GroupName=?");
st.setString(1, groupName);
ResultSet rs = st.executeQuery();
while(rs.next()) {
sortID = rs.getInt("GroupSortID");
}
} catch (SQLException e) {
e.printStackTrace();
}
return sortID;
}else {
return 0;
}
}
public String getGroupFromSortID(int sortID) {
String group = "";
try {
PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM Permisson WHERE GroupSortID=?");
st.setInt(1, sortID);
ResultSet rs = st.executeQuery();
while(rs.next()) {
group = rs.getString("GroupName");
}
} catch (SQLException e) {
e.printStackTrace();
}
return group;
}
public List<String> getGroups() {
List<String> list = new ArrayList<>();
try {
PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM Permisson");
ResultSet rs = st.executeQuery();
while(rs.next()) {
list.add(rs.getString("GroupName"));
}
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
public ArrayList<String> getGroupPermissions(String groupName) {
ArrayList<String> list;
String perms = "";
try {
PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM Permisson WHERE GroupName=?");
st.setString(1, groupName);
ResultSet rs = st.executeQuery();
while(rs.next()) {
perms = rs.getString("Permissons");
}
} catch (SQLException e) {
e.printStackTrace();
}
if(perms.length() > 0) {
perms = perms.substring(1, perms.length()-1);
}else {
return new ArrayList<String>();
}
String[] array = perms.split(", ");
list = new ArrayList<String>(Arrays.asList(array));
return list;
}
}

Datei anzeigen

@ -1,49 +0,0 @@
package de.diamant.hunjy.Permissions;
import java.util.ArrayList;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;
import de.diamant.hunjy.Core;
import de.diamant.hunjy.Permissions.Manager.GroupManager;
public class PermissionsManager {
public static String prefix = "§3Perms §8» §7";
public static GroupManager groupManager;
public PermissionsManager() {
groupManager = new GroupManager();
}
public static GroupManager getGroupManager() {
return groupManager;
}
public static void unssetPermission(Player player) {
player.setOp(false);
for(String group : PermissionsManager.getGroupManager().getGroups()) {
ArrayList<String> perms = getGroupManager().getGroupPermissions(group);
for(String perm : perms) {
PermissionAttachment attachment = player.addAttachment(Core.getInstance());
attachment.setPermission(perm, false);
}
}
}
public static void setPermission(Player player) {
player.setOp(false);
String group = Core.getInstance().getPlayerManager(player).getGroupName();
ArrayList<String> perms = getGroupManager().getGroupPermissions(group);
for(String perm : perms) {
PermissionAttachment attachment = player.addAttachment(Core.getInstance());
attachment.setPermission(perm, true);
if(perm.equals("*")) {
player.setOp(true);
}
}
}
}

Datei anzeigen

@ -1,205 +0,0 @@
package de.diamant.hunjy.Permissions.commands;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import de.diamant.hunjy.Core;
import de.diamant.hunjy.Permissions.PermissionsManager;
import de.diamant.hunjy.PlayerManager.events.PlayerChengeTeamEvent;
public class PermsCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String lable, String[] args) {
if(!(sender instanceof Player))return false;
Player player = (Player)sender;
if(player.isOp() || player.hasPermission("core.admin,premission")) {
if(args.length == 0) {
player.sendMessage("§7§m--------------------[§3 Permissions §7§m]--------------------");
player.sendMessage(" " + PermissionsManager.prefix + "/perms list");
player.sendMessage(" " + PermissionsManager.prefix + "/perms user <Spieler>");
player.sendMessage(" " + PermissionsManager.prefix + "/perms createGroup <GroupID> <GroupName> <Display>");
player.sendMessage(" " + PermissionsManager.prefix + "/perms removeGroup <GroupName>");
player.sendMessage(" " + PermissionsManager.prefix + "/perms addPermission <GroupName> <Permission>");
player.sendMessage(" " + PermissionsManager.prefix + "/perms removePermission <GroupName> <Permission>");
player.sendMessage(" " + PermissionsManager.prefix + "/perms changeDisplay <GroupName> <Display>");
player.sendMessage(" " + PermissionsManager.prefix + "/perms player <Player> set group <GroupName>");
player.sendMessage(" " + PermissionsManager.prefix + "/perms player <Player> remove group");
player.sendMessage("§7§m--------------------[§3 Permissions §7§m]--------------------");
}else if(args.length >= 1) {
if(args[0].equalsIgnoreCase("list")) {
player.sendMessage("");
List<Integer> idList = new ArrayList<Integer>();
for(String current : PermissionsManager.getGroupManager().getGroups()) {
idList.add(PermissionsManager.getGroupManager().getSortIDFromGroup(current));
}
Collections.reverse(idList);;
for(int id : idList) {
String group = PermissionsManager.getGroupManager().getGroupFromSortID(id);
String display = PermissionsManager.getGroupManager().getDisplayFromGroup(group);
player.sendMessage("§8[§7" + id + "§8] §7" + group + " §8» §7" + display);
}
}else if(args[0].equalsIgnoreCase("user")) {
if(args.length == 2) {
Player target = Bukkit.getPlayer(args[1]);
if(target == null) {
player.sendMessage("§cDer Spieler ist nicht Online!");
return false;
}
player.sendMessage("§aDer Spieler §e" + target.getName() + " §aist in der Gruppe §8[§7" + Core.getInstance().getPlayerManager(target).getGroupName() + "§8]");
}else{
}
}else if(args[0].equalsIgnoreCase("createGroup")) {
if(args.length == 4) {
try {
int groupPower = Integer.valueOf(args[1]);
String groupName = args[2];
String display = "";
display = args[3];
if(PermissionsManager.getGroupManager().createGroup(groupPower, groupName, display)) {
player.sendMessage("§aDie Gruppe §8[§7"+ display.replaceAll("&", "§") + "§8] §awurde erstellt!");
}else {
player.sendMessage("§cDie Gruppe §8[§7"+ groupName + "§8] §cgibt es bereits!");
}
}catch (NumberFormatException e) {
player.sendMessage(PermissionsManager.prefix + "§cBitte gebe einen Richtigen Wert ein!");
}
}else {
player.sendMessage(PermissionsManager.prefix + "/perms createGroup <GroupID> <GroupName> <Display>");
return false;
}
}else if(args[0].equalsIgnoreCase("removeGroup")) {
if(args.length == 2) {
String groupName = args[1];
if(PermissionsManager.getGroupManager().deleteGroup(groupName)){
player.sendMessage("§aDie Gruppe wurde erfolgreich gelöscht!");
}else {
player.sendMessage("§cDiese Gruppe gibt es nicht!");
}
}else {
player.sendMessage(" " + PermissionsManager.prefix + "/perms removeGroup <GroupName>");
return false;
}
}else if(args[0].equalsIgnoreCase("addPermission")) {
if(args.length == 3) {
String groupName = args[1];
if(!PermissionsManager.getGroupManager().existGroup(groupName)) {
player.sendMessage("§cDiese Gruppe gibt es nicht!");
return false;
}
String newPerm = args[2];
ArrayList<String> perms = PermissionsManager.getGroupManager().getGroupPermissions(groupName);
if(perms.contains(newPerm)) {
player.sendMessage("§cDie Gruppe hat diese Berechtigung bereits!");
return false;
}
perms.add(newPerm);
PermissionsManager.getGroupManager().setPerms(groupName, perms);
player.sendMessage("§aDie Permission §8[§7" + newPerm + "§8] §awurde der Gruppe " + PermissionsManager.getGroupManager().getDisplayFromGroup(groupName) + " §ahinzugefügt");
}else {
player.sendMessage(" " + PermissionsManager.prefix + "/perms addPermission <GroupName> <Permission>");
}
}else if(args[0].equalsIgnoreCase("removePermission")) {
if(args.length == 3) {
String groupName = args[1];
if(!PermissionsManager.getGroupManager().existGroup(groupName)) {
player.sendMessage("§cDiese Gruppe gibt es nicht!");
return false;
}
String newPerm = args[2];
ArrayList<String> perms = PermissionsManager.getGroupManager().getGroupPermissions(groupName);
if(!perms.contains(newPerm)) {
player.sendMessage("§cDie Gruppe hat diese Berechtigung nicht!");
return false;
}
perms.remove(newPerm);
PermissionsManager.getGroupManager().setPerms(groupName, perms);
player.sendMessage("§aDie Permission §8[§7" + newPerm + "§8] §awurde der Gruppe " + PermissionsManager.getGroupManager().getDisplayFromGroup(groupName) + " §aentfernt");
}else {
player.sendMessage(" " + PermissionsManager.prefix + "/perms removePermission <GroupName> <Permission>");
}
}else if(args[0].equalsIgnoreCase("changeDisplay")) {
if(args.length == 3) {
String group = args[1];
if(!PermissionsManager.getGroupManager().existGroup(group)) {
player.sendMessage("§cDiese Guppe gibt es nicht!");
return false;
}
String display = args[2];
PermissionsManager.getGroupManager().setDisplay(group, display);
player.sendMessage("§aDie Gruppe §8[§7" + group + "§8] §ahat jetzt den Display §r" + display.replaceAll("&", "§"));
}else {
}
}else if(args[0].equalsIgnoreCase("player")) {
if(args.length >= 3) {
if((args[2].equalsIgnoreCase("set") || args[2].equalsIgnoreCase("add")) && args[3].equalsIgnoreCase("group")) {
Player target = Bukkit.getPlayer(args[1]);
if(target == null) {
player.sendMessage("§cDer Spieler ist nicht Online!");
return false;
}
String group = args[4];
if(!PermissionsManager.getGroupManager().existGroup(group)) {
player.sendMessage("§cDiese Guppe gibt es nicht!");
return false;
}
if(Core.getInstance().getPlayerManager(target).getGroupName().equalsIgnoreCase(group)) {
player.sendMessage("§cDer Spieler ist bereits in deiser Gruppe");
return false;
}
Bukkit.getPluginManager().callEvent(new PlayerChengeTeamEvent(target, Core.getInstance().getPlayerManager(target).getGroupDisplay(), PermissionsManager.getGroupManager().getDisplayFromGroup(group)));
Core.getInstance().getPlayerManager(target).setGroup(group);
player.sendMessage("§aDer Spieler §e" + target.getName() + " §aist jetzt in der Gruppe §8[§7" + group + "§8]");
}else if(args[2].equalsIgnoreCase("remove") && args[3].equalsIgnoreCase("group")){
Player target = Bukkit.getPlayer(args[1]);
if(target == null) {
player.sendMessage("§cDer Spieler ist nicht Online!");
return false;
}
Bukkit.getPluginManager().callEvent(new PlayerChengeTeamEvent(target, Core.getInstance().getPlayerManager(target).getGroupDisplay(), PermissionsManager.getGroupManager().getDisplayFromGroup(PermissionsManager.getGroupManager().getGroupFromSortID(0))));
Core.getInstance().getPlayerManager(target).setGroup(PermissionsManager.getGroupManager().getGroupFromSortID(0));
player.sendMessage("§aDer Spieler §e" + target.getName() + " §aist jetzt in der Gruppe §8[§7" + PermissionsManager.getGroupManager().getGroupFromSortID(0) + "§8]");
return true;
}
}else {
player.sendMessage(PermissionsManager.prefix + "/perms setGroup <Player> <GroupName>");
}
}
}
}
return false;
}
}

Datei anzeigen

@ -1,26 +0,0 @@
package de.diamant.hunjy.PlayerManager.events;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class ChatingEvent implements Listener {
@EventHandler
private void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
event.setFormat(player.getDisplayName() + "§8» §7" + event.getMessage());
}
@EventHandler
private void onGroupChange(PlayerChengeTeamEvent event) {
Player player = event.getPlayer();
player.kickPlayer("§7Du hast einen neuen Rang erhalten\n\n" + event.getOldGroup() + " §8» " + event.getNewGroup() + "\n\n§7Bitte Joine neu auf §9Diamant-ix.de");
}
}

Datei anzeigen

@ -1,34 +0,0 @@
package de.diamant.hunjy.PlayerManager.events;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import de.diamant.hunjy.Core;
import de.diamant.hunjy.Permissions.PermissionsManager;
import de.diamant.hunjy.PlayerManager.PlayerManager;
public class PlayerJoin implements Listener{
@EventHandler
private void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
PlayerManager pm = Core.getInstance().getPlayerManager(player);
if(!pm.playerExist())
pm.createPlayer();
player.setDisplayName(Core.getInstance().getPlayerManager(player).getGroupDisplay() + " §8● §7" + Core.getInstance().getPlayerManager(player).getGroupDisplay().substring(0, 2) + player.getName() + " §r");
PermissionsManager.setPermission(player);
}
@EventHandler
private void onQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
PermissionsManager.setPermission(player);
}
}

56
pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,56 @@
<?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>de.warking</groupId>
<artifactId>SpigotCore</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<url>https://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -1,12 +1,12 @@
package de.diamant.hunjy.CoinSystem; package de.warking.hunjy.CoinSystem;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import de.diamant.hunjy.CoinSystem.manager.CoinsManager; import de.warking.hunjy.CoinSystem.manager.CoinsManager;
public class CoinSystem { public class CoinSystem {
public static String prefix = "§6Bank §8» "; public static String prefix = "<EFBFBD>6Bank <20>8<EFBFBD> ";
public CoinSystem() { public CoinSystem() {
} }

Datei anzeigen

@ -1,16 +1,15 @@
package de.diamant.hunjy.CoinSystem.command; package de.warking.hunjy.CoinSystem.command;
/** /**
* @author hunjy * @author hunjy
* *
*/ */
import de.warking.hunjy.CoinSystem.CoinSystem;
import de.warking.hunjy.CoinSystem.events.PlayerCoinsChangeEvent;
import de.warking.hunjy.CoinSystem.events.PlayerPayPlayerEvent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import de.diamant.hunjy.CoinSystem.CoinSystem;
import de.diamant.hunjy.CoinSystem.events.PlayerCoinsChangeEvent;
import de.diamant.hunjy.CoinSystem.events.PlayerPayPlayerEvent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -28,17 +27,17 @@ public class CoinCommand implements CommandExecutor{
if(command.getName().equals("coins")) { if(command.getName().equals("coins")) {
if(args.length == 0) { if(args.length == 0) {
int coins = CoinSystem.getCoinsManager(player).getCoins(); int coins = CoinSystem.getCoinsManager(player).getCoins();
player.sendMessage(CoinSystem.prefix + "§aDu hast §6" + coins + " Münzen§a."); player.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast <20>6" + coins + " M<EFBFBD>nzen<EFBFBD>a.");
}else if(args.length == 1) { }else if(args.length == 1) {
if(player.hasPermission("admin.coins.seecoins")) { if(player.hasPermission("admin.coins.seecoins")) {
Player target = Bukkit.getPlayer(args[0]); Player target = Bukkit.getPlayer(args[0]);
if(target == null) { if(target == null) {
player.sendMessage(CoinSystem.prefix + "§cDer Spieler ist nicht Online!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDer Spieler ist nicht Online!");
return false; return false;
} }
int coins = CoinSystem.getCoinsManager(target).getCoins(); int coins = CoinSystem.getCoinsManager(target).getCoins();
player.sendMessage(CoinSystem.prefix + "§7" + target.getName() + " §ahat §6" + coins + " Münzen§a."); player.sendMessage(CoinSystem.prefix + "<EFBFBD>7" + target.getName() + " <EFBFBD>ahat <20>6" + coins + " M<EFBFBD>nzen<EFBFBD>a.");
} }
} }
}else if(command.getName().equals("addcoins")) { }else if(command.getName().equals("addcoins")) {
@ -47,27 +46,27 @@ public class CoinCommand implements CommandExecutor{
Player target = Bukkit.getPlayer(args[0]); Player target = Bukkit.getPlayer(args[0]);
if(target == null) { if(target == null) {
player.sendMessage(CoinSystem.prefix + "§cDer Spieler ist nicht Online!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDer Spieler ist nicht Online!");
return false; return false;
} }
try { try {
int coins = Integer.valueOf(args[1]); int coins = Integer.valueOf(args[1]);
if(coins == 0) { if(coins == 0) {
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
return false; return false;
} }
CoinSystem.getCoinsManager(target).addCoins(coins); CoinSystem.getCoinsManager(target).addCoins(coins);
target.sendMessage(CoinSystem.prefix + "§aDu hast §6"+ coins + " Münzen §avon §7" + player.getDisplayName() + " §aerhalten"); target.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast <20>6"+ coins + " M<>nzen <20>avon <20>7" + player.getDisplayName() + " <EFBFBD>aerhalten");
player.sendMessage(CoinSystem.prefix + "§aDu hast dem Spieler §7" + target.getDisplayName() + " §aerfolgreich §6" + coins + " Münzen §agegeben."); player.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast dem Spieler <20>7" + target.getDisplayName() + " <EFBFBD>aerfolgreich <20>6" + coins + " M<EFBFBD>nzen <20>agegeben.");
Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "add",coins)); Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "add",coins));
}catch (NumberFormatException e) { }catch (NumberFormatException e) {
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
return false; return false;
} }
}else { }else {
player.sendMessage(CoinSystem.prefix + "§cBenutze: /addcoins [Spieler] [Anzahl]"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBenutze: /addcoins [Spieler] [Anzahl]");
} }
}else { }else {
return false; return false;
@ -78,30 +77,30 @@ public class CoinCommand implements CommandExecutor{
Player target = Bukkit.getPlayer(args[0]); Player target = Bukkit.getPlayer(args[0]);
if(target == null) { if(target == null) {
player.sendMessage(CoinSystem.prefix + "§cDer Spieler ist nicht Online!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDer Spieler ist nicht Online!");
return false; return false;
} }
try { try {
int coins = Integer.valueOf(args[1]); int coins = Integer.valueOf(args[1]);
if(coins == 0) { if(coins == 0) {
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
return false; return false;
} }
if(CoinSystem.getCoinsManager(target).getCoins() < coins) { if(CoinSystem.getCoinsManager(target).getCoins() < coins) {
player.sendMessage(CoinSystem.prefix + "§cDer Spieler hat nicht so viele §6Münzen§c."); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDer Spieler hat nicht so viele <20>6M<36>nzen<65>c.");
return false; return false;
} }
CoinSystem.getCoinsManager(target).removeCoins(coins); CoinSystem.getCoinsManager(target).removeCoins(coins);
player.sendMessage(CoinSystem.prefix + "§aDu hast dem Spieler §7" + target.getDisplayName() + " §aerfolgreich §6" + coins + " Münzen §aweggenommen."); player.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast dem Spieler <20>7" + target.getDisplayName() + " <EFBFBD>aerfolgreich <20>6" + coins + " M<EFBFBD>nzen <20>aweggenommen.");
Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "remove",coins)); Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "remove",coins));
}catch (NumberFormatException e) { }catch (NumberFormatException e) {
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
return false; return false;
} }
}else { }else {
player.sendMessage(CoinSystem.prefix + "§cBenutze: /removecoins [Spieler] [Anzahl]"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBenutze: /removecoins [Spieler] [Anzahl]");
} }
}else { }else {
return false; return false;
@ -112,42 +111,42 @@ public class CoinCommand implements CommandExecutor{
Player target = Bukkit.getPlayer(args[0]); Player target = Bukkit.getPlayer(args[0]);
if(target == null) { if(target == null) {
player.sendMessage(CoinSystem.prefix + "§cDer Spieler ist nicht Online!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDer Spieler ist nicht Online!");
return false; return false;
} }
try { try {
int coins = Integer.valueOf(args[1]); int coins = Integer.valueOf(args[1]);
if(coins < 0) { if(coins < 0) {
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
return false; return false;
} }
CoinSystem.getCoinsManager(target).setCoins(coins); CoinSystem.getCoinsManager(target).setCoins(coins);
player.sendMessage(CoinSystem.prefix + "§aDu hast den Kontostand von §7" + target.getDisplayName() + " §aauf §6" + coins + " Münzen §agesetzt."); player.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast den Kontostand von <20>7" + target.getDisplayName() + " <EFBFBD>aauf <20>6" + coins + " M<EFBFBD>nzen <20>agesetzt.");
Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "set",coins)); Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "set",coins));
}catch (NumberFormatException e) { }catch (NumberFormatException e) {
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
return false; return false;
} }
}else { }else {
player.sendMessage(CoinSystem.prefix + "§cBenutze: /setcoins [Spieler] [Anzahl]"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBenutze: /setcoins [Spieler] [Anzahl]");
} }
}else { }else {
return false; return false;
} }
}else if(command.getName().equals("pay")) { }else if(command.getName().equals("pay")) {
if(args.length != 2) { if(args.length != 2) {
player.sendMessage(CoinSystem.prefix + "§cBenutze: /pay [Spieler] [Anzahl]"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBenutze: /pay [Spieler] [Anzahl]");
}else { }else {
Player target = Bukkit.getPlayer(args[0]); Player target = Bukkit.getPlayer(args[0]);
if(target == null) { if(target == null) {
player.sendMessage(CoinSystem.prefix + "§cDer Spieler ist nicht Online!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDer Spieler ist nicht Online!");
return false; return false;
} }
if(target == player || target.getAddress().getHostName() == player.getAddress().getHostName()){ if(target == player || target.getAddress().getHostName() == player.getAddress().getHostName()){
player.sendMessage(CoinSystem.prefix + "§cDu kannst dir kein Geld überweisen!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDu kannst dir kein Geld <20>berweisen!");
return false; return false;
} }
@ -155,21 +154,21 @@ public class CoinCommand implements CommandExecutor{
int coins = Integer.valueOf(args[1]); int coins = Integer.valueOf(args[1]);
if(CoinSystem.getCoinsManager(player).getCoins() < coins) { if(CoinSystem.getCoinsManager(player).getCoins() < coins) {
player.sendMessage(CoinSystem.prefix + "§cDu hast nicht genügend §6Münzen§c."); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDu hast nicht gen<65>gend <20>6M<36>nzen<65>c.");
return false; return false;
} }
if(coins == 0) { if(coins == 0) {
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
return false; return false;
} }
CoinSystem.getCoinsManager(player).removeCoins(coins); CoinSystem.getCoinsManager(player).removeCoins(coins);
CoinSystem.getCoinsManager(target).addCoins(coins); CoinSystem.getCoinsManager(target).addCoins(coins);
target.sendMessage(CoinSystem.prefix + "§aDu hast §6"+ coins + " Münzen §avon §7" + player.getDisplayName() + " §aerhalten"); target.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast <20>6"+ coins + " M<>nzen <20>avon <20>7" + player.getDisplayName() + " <EFBFBD>aerhalten");
player.sendMessage(CoinSystem.prefix + "§aDu hast dem Spieler §7" + target.getDisplayName() + " §aerfolgreich §6" + coins + " Münzen §agegeben"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast dem Spieler <20>7" + target.getDisplayName() + " <EFBFBD>aerfolgreich <20>6" + coins + " M<EFBFBD>nzen <20>agegeben");
Bukkit.getPluginManager().callEvent(new PlayerPayPlayerEvent(player, target, coins)); Bukkit.getPluginManager().callEvent(new PlayerPayPlayerEvent(player, target, coins));
}catch (NumberFormatException e) { }catch (NumberFormatException e) {
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!"); player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
return false; return false;
} }
} }

Datei anzeigen

@ -1,13 +1,12 @@
package de.diamant.hunjy.CoinSystem.events; package de.warking.hunjy.CoinSystem.events;
import de.warking.hunjy.Core;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import de.diamant.hunjy.Core;
public class PlayerCoinsChangeEvent extends Event implements Cancellable{ public class PlayerCoinsChangeEvent extends Event implements Cancellable{
@ -21,13 +20,13 @@ public class PlayerCoinsChangeEvent extends Event implements Cancellable{
this.player = player; this.player = player;
switch (option) { switch (option) {
case "add": case "add":
this.msg = "§8[§c"+ player.getName() + "§8] §7Gibt " + target.getName() + " §6" + Coins + "§6 Münze/n" ; this.msg = "<EFBFBD>8[<5B>c"+ player.getName() + "<EFBFBD>8] <20>7Gibt " + target.getName() + " <EFBFBD>6" + Coins + "<EFBFBD>6 M<>nze/n" ;
break; break;
case "set": case "set":
this.msg = "§8[§c"+ player.getName() + "§8] §7Setzt den Kontostand von " + target.getName() + " §7auf §6" + Coins + "§6 Münze/n" ; this.msg = "<EFBFBD>8[<5B>c"+ player.getName() + "<EFBFBD>8] <20>7Setzt den Kontostand von " + target.getName() + " <EFBFBD>7auf <20>6" + Coins + "<EFBFBD>6 M<>nze/n" ;
break; break;
case "remove": case "remove":
this.msg = "§8[§c"+ player.getName() + "§8] §7Entfernt " + target.getName() + " §6" + Coins + "§6 Münze/n" ; this.msg = "<EFBFBD>8[<5B>c"+ player.getName() + "<EFBFBD>8] <20>7Entfernt " + target.getName() + " <EFBFBD>6" + Coins + "<EFBFBD>6 M<>nze/n" ;
break; break;
default: default:

Datei anzeigen

@ -1,12 +1,11 @@
package de.diamant.hunjy.CoinSystem.events; package de.warking.hunjy.CoinSystem.events;
import de.warking.hunjy.Core;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import de.diamant.hunjy.Core;
public class PlayerPayPlayerEvent extends Event implements Cancellable{ public class PlayerPayPlayerEvent extends Event implements Cancellable{
public static HandlerList handlers = new HandlerList(); public static HandlerList handlers = new HandlerList();
@ -17,7 +16,7 @@ public class PlayerPayPlayerEvent extends Event implements Cancellable{
public PlayerPayPlayerEvent(Player player, Player target, int coins) { public PlayerPayPlayerEvent(Player player, Player target, int coins) {
this.player = player; this.player = player;
this.msg = "§7" + player.getName() + " §8-> §7" + target.getName() + " §8[§6" + coins + " Münzen§8]"; this.msg = "<EFBFBD>7" + player.getName() + " <EFBFBD>8-> <20>7" + target.getName() + " <EFBFBD>8[<5B>6" + coins + " M<EFBFBD>nzen<EFBFBD>8]";
Core.getInstance().getCacheManager().addCache(this.msg); Core.getInstance().getCacheManager().addCache(this.msg);
} }

Datei anzeigen

@ -1,13 +1,13 @@
package de.diamant.hunjy.CoinSystem.manager; package de.warking.hunjy.CoinSystem.manager;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import de.warking.hunjy.Core;
import de.warking.hunjy.MySQL.MySQL;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import de.diamant.hunjy.Core;
import de.diamant.hunjy.MySQL.MySQL;
/** /**
* @author hunjy * @author hunjy
* *
@ -44,7 +44,7 @@ public class CoinsManager {
createPlayer(); createPlayer();
int coins = 0; int coins = 0;
ResultSet rs = mySQL.getResultSet("SELECT * FROM Coins WHERE UUID='"+ player.getUniqueId().toString() +"'"); ResultSet rs = mySQL.select("SELECT * FROM Coins WHERE UUID='"+ player.getUniqueId().toString() +"'");
try { try {
if(rs.next() && Integer.valueOf(rs.getInt("Coins")) != null) { if(rs.next() && Integer.valueOf(rs.getInt("Coins")) != null) {
coins = rs.getInt("Coins"); coins = rs.getInt("Coins");

Datei anzeigen

@ -0,0 +1,83 @@
package de.warking.hunjy;
import java.util.UUID;
import de.warking.hunjy.PlayerManager.PlayerManager;
import de.warking.hunjy.PlayerManager.events.ChattingEvent;
import de.warking.hunjy.PlayerManager.events.PlayerJoin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import de.warking.hunjy.CoinSystem.CoinSystem;
import de.warking.hunjy.CoinSystem.command.CoinCommand;
import de.warking.hunjy.MySQL.MySQL;
import de.warking.hunjy.manager.CacheManager;
import de.warking.hunjy.manager.FileManager;
public class Core extends JavaPlugin{
public static MySQL sql;
public static String chatPrefix = "§6War§7King» §r";
private static Core instance;
private CacheManager cacheManager;
private FileManager fileManager;
@Override
public void onLoad() {
instance = this;
cacheManager = new CacheManager();
}
@Override
public void onEnable() {
fileManager = new FileManager();
sql = new MySQL();
sql.update("CREATE TABLE IF NOT EXISTS Coins(ID INT(16) PRIMARY KEY NOT NULL, Coins INT(16));");
sql.update("CREATE TABLE IF NOT EXISTS Permisson(GroupSortID VARCHAR(64), GroupName VARCHAR(64), GroupDisplay VARCHAR(64), Permissons LONGTEXT);");
sql.update("CREATE TABLE IF NOT EXISTS UserData(ID INT(16) PRIMARY KEY AUTO_INCREMENT NOT NULL,UUID VARCHAR(64), UserName VARCHAR(64) NOT NULL, UserGroup VARCHAR(64));");
new CoinSystem();
instance.getCommand("coins").setExecutor(new CoinCommand());
instance.getCommand("pay").setExecutor(new CoinCommand());
instance.getCommand("addcoins").setExecutor(new CoinCommand());
instance.getCommand("setcoins").setExecutor(new CoinCommand());
instance.getCommand("removecoins").setExecutor(new CoinCommand());
Bukkit.getPluginManager().registerEvents(new PlayerJoin(), this);
Bukkit.getPluginManager().registerEvents(new ChattingEvent(), this);
}
public static Core getInstance() {
return instance;
}
public MySQL getMySQL() {
return sql;
}
public CacheManager getCacheManager() {
return cacheManager;
}
public PlayerManager getPlayerManager(Player player) {
return new PlayerManager(player);
}
public PlayerManager getPlayerManager(UUID uuid) {
return new PlayerManager(uuid);
}
public FileManager getFileManager() {
return fileManager;
}
}

Datei anzeigen

@ -1,4 +1,4 @@
package de.diamant.hunjy.MySQL; package de.warking.hunjy.MySQL;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
@ -6,36 +6,17 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import de.diamant.hunjy.Core; import de.warking.hunjy.Core;
public class MySQL { public class MySQL {
private String HOST = ""; private String HOST;
private String PORT = ""; private String PORT;
private String DATABASE = ""; private String DATABASE;
private String USER = ""; private String USER;
private String PASSWORD = ""; private String PASSWORD = "";
private Connection con; private Connection con;
public MySQL(String HOST, String PORT, String DATABASE, String USER, String PASSWORD) {
this.HOST = HOST;
this.PORT = PORT;
this.DATABASE = DATABASE;
this.USER = USER;
this.PASSWORD = PASSWORD;
connect();
}
public MySQL(String HOST, String PORT, String DATABASE, String USER) {
this.HOST = HOST;
this.PORT = PORT;
this.DATABASE = DATABASE;
this.USER = USER;
connect();
}
public MySQL() { public MySQL() {
this.HOST = Core.getInstance().getFileManager().getConfig().getString("HOST"); this.HOST = Core.getInstance().getFileManager().getConfig().getString("HOST");
this.PORT = Core.getInstance().getFileManager().getConfig().getString("PORT"); this.PORT = Core.getInstance().getFileManager().getConfig().getString("PORT");
@ -52,13 +33,18 @@ public class MySQL {
public void connect() { public void connect() {
try { try {
con = DriverManager.getConnection("jdbc:mysql://" + HOST + ":" + PORT + "/" + DATABASE + "?autoreconnect=true", USER, PASSWORD); con = DriverManager.getConnection("jdbc:mysql://" + HOST + ":" + PORT + "/" + DATABASE + "?autoreconnect=true", USER, PASSWORD);
if(con != null) if(con == null)
System.out.println(Core.getInstance().getDescription().getFullName() + " >> MySQL: Verbunden"); System.err.println("Fatal ERROR: Could not connect to database!");
}catch (SQLException e) { }catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private void reconnect(){
closeConnection();
connect();
}
public void closeConnection() { public void closeConnection() {
try { try {
if(con != null) if(con != null)
@ -69,21 +55,38 @@ public class MySQL {
} }
public void update(String qry) { public void update(String qry) {
if(con == null){
return;
}
try { try {
PreparedStatement st = con.prepareStatement(qry); PreparedStatement st = con.prepareStatement(qry);
st.executeUpdate(); st.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); reconnect();
try {
PreparedStatement st = con.prepareStatement(qry);
st.executeUpdate();
} catch (SQLException ex) {
ex.printStackTrace();
}
} }
} }
public ResultSet getResultSet(String qry) { public ResultSet select(String qry) {
if(con == null){
return null;
}
try { try {
PreparedStatement st = con.prepareStatement(qry); PreparedStatement st = con.prepareStatement(qry);
return st.executeQuery(); return st.executeQuery();
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); reconnect();
try {
PreparedStatement st = con.prepareStatement(qry);
return st.executeQuery();
} catch (SQLException ex) {
ex.printStackTrace();
}
} }
return null; return null;

Datei anzeigen

@ -0,0 +1,140 @@
package de.warking.hunjy.MySQL;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static de.warking.hunjy.Core.sql;
public class Schematic {
private String SchemName;
private int SchemOwner;
private String Item;
private SchematicType SchemType;
private Schematic(String schemName, int schemOwner, String item, SchematicType schemType, boolean updateDB){
SchemName = schemName;
SchemOwner = schemOwner;
Item = item;
SchemType = schemType;
if(updateDB)
updateDB();
}
public Schematic(String schemName, int schemOwner, String item, SchematicType schemType){
this(schemName, schemOwner, item, schemType, true);
}
public Schematic(String schemName, UUID schemOwner, String item, SchematicType schemType){
this(schemName, WarkingUser.get(schemOwner).getId(), item, schemType, true);
}
private void updateDB(){
sql.update("INSERT INTO Schematic" +
" (SchemName, SchemOwner, Item, SchemType)" +
" VALUES" +
" ('" + SchemName + "', '" + SchemOwner + "', '" + Item + "', '" + SchemType.name() + "')" +
" ON DUPLICATE KEY UPDATE" +
" Item = VALUES(Item), SchemType = VALUES(SchemType)");
}
public static Schematic getSchemFromDB(String schemName, UUID schemOwner){
return getSchemFromDB(schemName, WarkingUser.get(schemOwner).getId());
}
public static Schematic getSchemFromDB(String schemName, int schemOwner){
ResultSet schematic = sql.select("SELECT * FROM Schematic WHERE SchemName = '" + schemName + "', SchemOwner = '" + schemOwner + "'");
try {
if(schematic == null || !schematic.next()){
System.err.println("Fatal ERROR: Could not load schematic!");
return null;
}
String item = schematic.getString("Item");;
SchematicType schemType = SchematicType.valueOf(schematic.getString("SchemType"));
return new Schematic(schemName, schemOwner, item, schemType, false);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
public static List<Schematic> getSchemsAccessibleByUser(UUID schemOwner){
return getSchemsAccessibleByUser(WarkingUser.get(schemOwner).getId());
}
public static List<Schematic> getSchemsAccessibleByUser(int schemOwner){
try{
ResultSet schematic = sql.select("SELECT * FROM Schematic WHERE SchemOwner = '" + schemOwner + "'");
List<Schematic> schematics = new ArrayList<>();
while(schematic.next()){
String schemName = schematic.getString("SchemName");
String item = schematic.getString("Item");
SchematicType schemType = SchematicType.valueOf(schematic.getString("SchemType"));
schematics.add(new Schematic(schemName, schemOwner, item, schemType, false));
}
return schematics;
}catch(SQLException e){
e.printStackTrace();
}
return null;
}
public static List<Schematic> getSchemsOfType(UUID schemOwner, SchematicType schemType){
return getSchemsOfType(WarkingUser.get(schemOwner).getId(), schemType);
}
public static List<Schematic> getSchemsOfType(int schemOwner, SchematicType schemType){
try{
ResultSet schematic = sql.select("SELECT * FROM Schematic WHERE SchemOwner = '" + schemOwner + "' AND SchemType = '" + schemType.name() + "'");
List<Schematic> schematics = new ArrayList<>();
while(schematic.next()){
String schemName = schematic.getString("SchemName");
String item = schematic.getString("Item");
schematics.add(new Schematic(schemName, schemOwner, item, schemType, false));
}
return schematics;
}catch(SQLException e){
e.printStackTrace();
}
return null;
}
public String getSchemName() {
return SchemName;
}
public void setSchemName(String schemName) {
SchemName = schemName;
updateDB();
}
public int getSchemOwner() {
return SchemOwner;
}
public void setSchemOwner(int schemOwner) {
SchemOwner = schemOwner;
updateDB();
}
public String getItem() {
return Item;
}
public void setItem(String item) {
Item = item;
updateDB();
}
public SchematicType getSchemType() {
return SchemType;
}
public void setSchemType(SchematicType schemType) {
SchemType = schemType;
updateDB();
}
}

Datei anzeigen

@ -0,0 +1,7 @@
package de.warking.hunjy.MySQL;
public class SchematicMember {
private int SchemOwner;
private String SchemName;
private int Member;
}

Datei anzeigen

@ -0,0 +1,9 @@
package de.warking.hunjy.MySQL;
public enum SchematicType {
normal,
airship,
wargear,
warship,
miniwargear
}

Datei anzeigen

@ -0,0 +1,80 @@
package de.warking.hunjy.MySQL;
import org.bukkit.entity.Player;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static de.warking.hunjy.Core.sql;
public class WarkingUser {
private static final List<WarkingUser> allUsers = new ArrayList<>();
private int id;
private UUID UUID;
private String UserName;
private String UserGroup;
public WarkingUser(Player player){
ResultSet dbplayer = sql.select("SELECT * FROM UserData WHERE UUID = '" + player.getUniqueId().toString() + "'");
init(dbplayer);
}
private void init(ResultSet dbplayer){
try {
if(dbplayer == null || !dbplayer.next()){
System.err.println("Fatal ERROR: Could not load player!");
return;
}
id = dbplayer.getInt("id");
this.UUID = java.util.UUID.fromString(dbplayer.getString("UUID"));
UserName = dbplayer.getString("UserName");
UserGroup = dbplayer.getString("UserGroup");
allUsers.add(this);
} catch (SQLException e) {
e.printStackTrace();
}
}
public int getId() {
return id;
}
public java.util.UUID getUUID() {
return UUID;
}
public String getUserName() {
return UserName;
}
public String getUserGroup() {
return UserGroup;
}
public static WarkingUser get(String userName){
for(WarkingUser user : allUsers)
if(user.getUserName().equals(userName))
return user;
return null;
}
public static WarkingUser get(UUID uuid){
for(WarkingUser user : allUsers)
if(user.getUserName().equals(uuid))
return user;
return null;
}
public static void remove(Player player){
for(int i = 0; i < allUsers.size(); i++)
if(allUsers.get(i).getUUID().equals(player.getUniqueId())){
allUsers.remove(i);
return;
}
}
}

Datei anzeigen

@ -1,16 +1,14 @@
package de.diamant.hunjy.PlayerManager; package de.warking.hunjy.PlayerManager;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import de.diamant.hunjy.Core; import de.warking.hunjy.Core;
import de.diamant.hunjy.MySQL.MySQL; import de.warking.hunjy.MySQL.MySQL;
import de.diamant.hunjy.Permissions.PermissionsManager;
public class PlayerManager { public class PlayerManager {
@ -39,11 +37,6 @@ public class PlayerManager {
return false; return false;
} }
public void createPlayer() {
mySQL.update("INSERT INTO UserData(UUID, UserName, UserGroup) VALUES ('"+ uuid.toString() +"','" + Bukkit.getPlayer(uuid).getName() + "', '" + PermissionsManager.getGroupManager().getGroupFromSortID(0) + "')");
}
public String getGroupName() { public String getGroupName() {
try { try {
PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM UserData WHERE UUID=?"); PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM UserData WHERE UUID=?");
@ -57,19 +50,8 @@ public class PlayerManager {
} }
return null; return null;
} }
public int getGroupID() {
return PermissionsManager.getGroupManager().getSortIDFromGroup(getGroupName());
}
public String getGroupDisplay() {
return PermissionsManager.getGroupManager().getDisplayFromGroup(getGroupName());
}
public void setGroup(String group) { public void setGroup(String group) {
mySQL.update("UPDATE UserData Set UserGroup='" + group + "' WHERE UUID='" + uuid.toString() + "'"); mySQL.update("UPDATE UserData Set UserGroup='" + group + "' WHERE UUID='" + uuid.toString() + "'");
} }
public void removeGroup() {
mySQL.update("UPDATE UserData Set UserGroup='" + PermissionsManager.getGroupManager().getGroupFromSortID(0) + "' WHERE UUID='" + uuid.toString() + "'");
}
} }

Datei anzeigen

@ -0,0 +1,26 @@
package de.warking.hunjy.PlayerManager.events;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class ChattingEvent implements Listener {
@EventHandler
private void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
event.setFormat(player.getDisplayName() + "<EFBFBD>8<EFBFBD> <20>7" + event.getMessage());
}
@EventHandler
private void onGroupChange(PlayerChangeTeamEvent event) {
Player player = event.getPlayer();
player.kickPlayer("<EFBFBD>7Du hast einen neuen Rang erhalten\n\n" + event.getOldGroup() + " <20>8<EFBFBD> " + event.getNewGroup() + "\n\n<EFBFBD>7Bitte Joine neu auf <20>9Diamant-ix.de");
}
}

Datei anzeigen

@ -1,11 +1,11 @@
package de.diamant.hunjy.PlayerManager.events; package de.warking.hunjy.PlayerManager.events;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
public class PlayerChengeTeamEvent extends Event implements Cancellable{ public class PlayerChangeTeamEvent extends Event implements Cancellable{
public static HandlerList handlers = new HandlerList(); public static HandlerList handlers = new HandlerList();
public boolean cancelled = false; public boolean cancelled = false;
@ -15,7 +15,7 @@ public class PlayerChengeTeamEvent extends Event implements Cancellable{
String newGroup; String newGroup;
public PlayerChengeTeamEvent(Player player, String oldGroup, String newGroup) { public PlayerChangeTeamEvent(Player player, String oldGroup, String newGroup) {
this.player = player; this.player = player;
this.oldGroup = oldGroup; this.oldGroup = oldGroup;
this.newGroup = newGroup; this.newGroup = newGroup;

Datei anzeigen

@ -0,0 +1,57 @@
package de.warking.hunjy.PlayerManager.events;
import de.warking.hunjy.MySQL.WarkingUser;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerJoin implements Listener{
@EventHandler
private void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
WarkingUser user = new WarkingUser(player);
switch(user.getUserGroup()){
case "Admin":
player.setDisplayName("§4Admin " + player.getName() + "§r");
break;
case "Developer":
player.setDisplayName("§3Developer " + player.getName() + "§r");
break;
case "Moderator":
player.setDisplayName("§bModerator " + player.getName() + "§r");
break;
case "Supporter":
player.setDisplayName("§1Supporter " + player.getName() + "§r");
break;
case "Builder":
player.setDisplayName("§2Architekt " + player.getName() + "§r");
break;
case "Youtuber":
player.setDisplayName("§5Youtuber " + player.getName() + "§r");
break;
case "Premium":
player.setDisplayName("§6Premium " + player.getName() + "§r");
break;
case "Member":
default:
player.setDisplayName("§7" + player.getName() + "§r");
break;
}
event.setJoinMessage("§a§l» §r" + player.getDisplayName());
}
@EventHandler
private void onQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
WarkingUser.remove(player);
event.setQuitMessage("§c§l« §r" + player.getDisplayName());
}
}

Datei anzeigen

@ -1,13 +1,12 @@
package de.diamant.hunjy.manager; package de.warking.hunjy.manager;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.sql.Time; import java.sql.Time;
import de.warking.hunjy.Core;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import de.diamant.hunjy.Core;
public class CacheManager { public class CacheManager {

Datei anzeigen

@ -1,12 +1,11 @@
package de.diamant.hunjy.manager; package de.warking.hunjy.manager;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import de.warking.hunjy.Core;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import de.diamant.hunjy.Core;
public class FileManager { public class FileManager {

Datei anzeigen

@ -1,9 +1,9 @@
name: CoreSystem name: CoreSystem
version: 1.0 version: 1.0
author: hunjy author: hunjy, Lixfel
main: de.diamant.hunjy.Core main: de.warking.hunjy.Core
commands: commands:
coins: coins:
@ -11,5 +11,3 @@ commands:
addcoins: addcoins:
removecoins: removecoins:
setcoins: setcoins:
perms:
dperms: