Various things + Core Schematic API
Dieser Commit ist enthalten in:
Ursprung
443b7bdd38
Commit
95ebca1681
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,4 +3,5 @@
|
||||
.project
|
||||
.settings
|
||||
target
|
||||
bin
|
||||
bin
|
||||
*.iml
|
@ -1,5 +0,0 @@
|
||||
package de.diamant.hunjy.BanSystem;
|
||||
|
||||
public class BanManager {
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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");
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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
56
pom.xml
Normale Datei
@ -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>
|
@ -1,18 +1,18 @@
|
||||
package de.diamant.hunjy.CoinSystem;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.diamant.hunjy.CoinSystem.manager.CoinsManager;
|
||||
|
||||
public class CoinSystem {
|
||||
|
||||
public static String prefix = "§6Bank §8» ";
|
||||
|
||||
public CoinSystem() {
|
||||
}
|
||||
|
||||
public static CoinsManager getCoinsManager(Player player) {
|
||||
return new CoinsManager(player);
|
||||
}
|
||||
|
||||
}
|
||||
package de.warking.hunjy.CoinSystem;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.warking.hunjy.CoinSystem.manager.CoinsManager;
|
||||
|
||||
public class CoinSystem {
|
||||
|
||||
public static String prefix = "<EFBFBD>6Bank <20>8<EFBFBD> ";
|
||||
|
||||
public CoinSystem() {
|
||||
}
|
||||
|
||||
public static CoinsManager getCoinsManager(Player player) {
|
||||
return new CoinsManager(player);
|
||||
}
|
||||
|
||||
}
|
@ -1,180 +1,179 @@
|
||||
package de.diamant.hunjy.CoinSystem.command;
|
||||
|
||||
/**
|
||||
* @author hunjy
|
||||
*
|
||||
*/
|
||||
|
||||
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.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CoinCommand implements CommandExecutor{
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player))
|
||||
return false;
|
||||
|
||||
Player player = (Player)sender;
|
||||
|
||||
if(command.getName().equals("coins")) {
|
||||
if(args.length == 0) {
|
||||
int coins = CoinSystem.getCoinsManager(player).getCoins();
|
||||
player.sendMessage(CoinSystem.prefix + "§aDu hast §6" + coins + " Münzen§a.");
|
||||
}else if(args.length == 1) {
|
||||
|
||||
if(player.hasPermission("admin.coins.seecoins")) {
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(target == null) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cDer Spieler ist nicht Online!");
|
||||
return false;
|
||||
}
|
||||
int coins = CoinSystem.getCoinsManager(target).getCoins();
|
||||
player.sendMessage(CoinSystem.prefix + "§7" + target.getName() + " §ahat §6" + coins + " Münzen§a.");
|
||||
}
|
||||
}
|
||||
}else if(command.getName().equals("addcoins")) {
|
||||
if(player.hasPermission("admin.coins.addcoins")) {
|
||||
if(args.length == 2) {
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(target == null) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cDer Spieler ist nicht Online!");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
int coins = Integer.valueOf(args[1]);
|
||||
|
||||
if(coins == 0) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
CoinSystem.getCoinsManager(target).addCoins(coins);
|
||||
|
||||
target.sendMessage(CoinSystem.prefix + "§aDu hast §6"+ coins + " Münzen §avon §7" + player.getDisplayName() + " §aerhalten");
|
||||
player.sendMessage(CoinSystem.prefix + "§aDu hast dem Spieler §7" + target.getDisplayName() + " §aerfolgreich §6" + coins + " Münzen §agegeben.");
|
||||
Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "add",coins));
|
||||
}catch (NumberFormatException e) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(CoinSystem.prefix + "§cBenutze: /addcoins [Spieler] [Anzahl]");
|
||||
}
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}else if(command.getName().equals("removecoins")) {
|
||||
if(player.hasPermission("admin.coins.removecoins")) {
|
||||
if(args.length == 2) {
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(target == null) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cDer Spieler ist nicht Online!");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
int coins = Integer.valueOf(args[1]);
|
||||
|
||||
if(coins == 0) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
if(CoinSystem.getCoinsManager(target).getCoins() < coins) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cDer Spieler hat nicht so viele §6Münzen§c.");
|
||||
return false;
|
||||
}
|
||||
CoinSystem.getCoinsManager(target).removeCoins(coins);
|
||||
|
||||
player.sendMessage(CoinSystem.prefix + "§aDu hast dem Spieler §7" + target.getDisplayName() + " §aerfolgreich §6" + coins + " Münzen §aweggenommen.");
|
||||
Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "remove",coins));
|
||||
}catch (NumberFormatException e) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(CoinSystem.prefix + "§cBenutze: /removecoins [Spieler] [Anzahl]");
|
||||
}
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}else if(command.getName().equals("setcoins")) {
|
||||
if(player.hasPermission("admin.coins.setcoins")) {
|
||||
if(args.length == 2) {
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(target == null) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cDer Spieler ist nicht Online!");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
int coins = Integer.valueOf(args[1]);
|
||||
if(coins < 0) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
CoinSystem.getCoinsManager(target).setCoins(coins);
|
||||
|
||||
|
||||
player.sendMessage(CoinSystem.prefix + "§aDu hast den Kontostand von §7" + target.getDisplayName() + " §aauf §6" + coins + " Münzen §agesetzt.");
|
||||
Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "set",coins));
|
||||
}catch (NumberFormatException e) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(CoinSystem.prefix + "§cBenutze: /setcoins [Spieler] [Anzahl]");
|
||||
}
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}else if(command.getName().equals("pay")) {
|
||||
if(args.length != 2) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cBenutze: /pay [Spieler] [Anzahl]");
|
||||
}else {
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(target == null) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cDer Spieler ist nicht Online!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(target == player || target.getAddress().getHostName() == player.getAddress().getHostName()){
|
||||
player.sendMessage(CoinSystem.prefix + "§cDu kannst dir kein Geld überweisen!");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
int coins = Integer.valueOf(args[1]);
|
||||
|
||||
if(CoinSystem.getCoinsManager(player).getCoins() < coins) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cDu hast nicht genügend §6Münzen§c.");
|
||||
return false;
|
||||
}
|
||||
if(coins == 0) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
CoinSystem.getCoinsManager(player).removeCoins(coins);
|
||||
CoinSystem.getCoinsManager(target).addCoins(coins);
|
||||
|
||||
target.sendMessage(CoinSystem.prefix + "§aDu hast §6"+ coins + " Münzen §avon §7" + player.getDisplayName() + " §aerhalten");
|
||||
player.sendMessage(CoinSystem.prefix + "§aDu hast dem Spieler §7" + target.getDisplayName() + " §aerfolgreich §6" + coins + " Münzen §agegeben");
|
||||
Bukkit.getPluginManager().callEvent(new PlayerPayPlayerEvent(player, target, coins));
|
||||
}catch (NumberFormatException e) {
|
||||
player.sendMessage(CoinSystem.prefix + "§cBitte gebe einen gültigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
package de.warking.hunjy.CoinSystem.command;
|
||||
|
||||
/**
|
||||
* @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.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CoinCommand implements CommandExecutor{
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player))
|
||||
return false;
|
||||
|
||||
Player player = (Player)sender;
|
||||
|
||||
if(command.getName().equals("coins")) {
|
||||
if(args.length == 0) {
|
||||
int coins = CoinSystem.getCoinsManager(player).getCoins();
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast <20>6" + coins + " M<>nzen<65>a.");
|
||||
}else if(args.length == 1) {
|
||||
|
||||
if(player.hasPermission("admin.coins.seecoins")) {
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(target == null) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDer Spieler ist nicht Online!");
|
||||
return false;
|
||||
}
|
||||
int coins = CoinSystem.getCoinsManager(target).getCoins();
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>7" + target.getName() + " <20>ahat <20>6" + coins + " M<>nzen<65>a.");
|
||||
}
|
||||
}
|
||||
}else if(command.getName().equals("addcoins")) {
|
||||
if(player.hasPermission("admin.coins.addcoins")) {
|
||||
if(args.length == 2) {
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(target == null) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDer Spieler ist nicht Online!");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
int coins = Integer.valueOf(args[1]);
|
||||
|
||||
if(coins == 0) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
CoinSystem.getCoinsManager(target).addCoins(coins);
|
||||
|
||||
target.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast <20>6"+ coins + " M<>nzen <20>avon <20>7" + player.getDisplayName() + " <20>aerhalten");
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast dem Spieler <20>7" + target.getDisplayName() + " <20>aerfolgreich <20>6" + coins + " M<>nzen <20>agegeben.");
|
||||
Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "add",coins));
|
||||
}catch (NumberFormatException e) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBenutze: /addcoins [Spieler] [Anzahl]");
|
||||
}
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}else if(command.getName().equals("removecoins")) {
|
||||
if(player.hasPermission("admin.coins.removecoins")) {
|
||||
if(args.length == 2) {
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(target == null) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDer Spieler ist nicht Online!");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
int coins = Integer.valueOf(args[1]);
|
||||
|
||||
if(coins == 0) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
if(CoinSystem.getCoinsManager(target).getCoins() < coins) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDer Spieler hat nicht so viele <20>6M<36>nzen<65>c.");
|
||||
return false;
|
||||
}
|
||||
CoinSystem.getCoinsManager(target).removeCoins(coins);
|
||||
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast dem Spieler <20>7" + target.getDisplayName() + " <20>aerfolgreich <20>6" + coins + " M<>nzen <20>aweggenommen.");
|
||||
Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "remove",coins));
|
||||
}catch (NumberFormatException e) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBenutze: /removecoins [Spieler] [Anzahl]");
|
||||
}
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}else if(command.getName().equals("setcoins")) {
|
||||
if(player.hasPermission("admin.coins.setcoins")) {
|
||||
if(args.length == 2) {
|
||||
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(target == null) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDer Spieler ist nicht Online!");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
int coins = Integer.valueOf(args[1]);
|
||||
if(coins < 0) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
CoinSystem.getCoinsManager(target).setCoins(coins);
|
||||
|
||||
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast den Kontostand von <20>7" + target.getDisplayName() + " <20>aauf <20>6" + coins + " M<>nzen <20>agesetzt.");
|
||||
Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "set",coins));
|
||||
}catch (NumberFormatException e) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBenutze: /setcoins [Spieler] [Anzahl]");
|
||||
}
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}else if(command.getName().equals("pay")) {
|
||||
if(args.length != 2) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBenutze: /pay [Spieler] [Anzahl]");
|
||||
}else {
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if(target == null) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDer Spieler ist nicht Online!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(target == player || target.getAddress().getHostName() == player.getAddress().getHostName()){
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDu kannst dir kein Geld <20>berweisen!");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
int coins = Integer.valueOf(args[1]);
|
||||
|
||||
if(CoinSystem.getCoinsManager(player).getCoins() < coins) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cDu hast nicht gen<65>gend <20>6M<36>nzen<65>c.");
|
||||
return false;
|
||||
}
|
||||
if(coins == 0) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
CoinSystem.getCoinsManager(player).removeCoins(coins);
|
||||
CoinSystem.getCoinsManager(target).addCoins(coins);
|
||||
|
||||
target.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast <20>6"+ coins + " M<>nzen <20>avon <20>7" + player.getDisplayName() + " <20>aerhalten");
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>aDu hast dem Spieler <20>7" + target.getDisplayName() + " <20>aerfolgreich <20>6" + coins + " M<>nzen <20>agegeben");
|
||||
Bukkit.getPluginManager().callEvent(new PlayerPayPlayerEvent(player, target, coins));
|
||||
}catch (NumberFormatException e) {
|
||||
player.sendMessage(CoinSystem.prefix + "<EFBFBD>cBitte gebe einen g<>ltigen Wert ein!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,68 +1,67 @@
|
||||
package de.diamant.hunjy.CoinSystem.events;
|
||||
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import de.diamant.hunjy.Core;
|
||||
|
||||
|
||||
public class PlayerCoinsChangeEvent extends Event implements Cancellable{
|
||||
|
||||
public static HandlerList handlers = new HandlerList();
|
||||
public boolean cancelled = false;
|
||||
|
||||
Player player;
|
||||
String msg;
|
||||
|
||||
public PlayerCoinsChangeEvent(Player player, Player target, String option, int Coins) {
|
||||
this.player = player;
|
||||
switch (option) {
|
||||
case "add":
|
||||
this.msg = "§8[§c"+ player.getName() + "§8] §7Gibt " + target.getName() + " §6" + Coins + "§6 Münze/n" ;
|
||||
break;
|
||||
case "set":
|
||||
this.msg = "§8[§c"+ player.getName() + "§8] §7Setzt den Kontostand von " + target.getName() + " §7auf §6" + Coins + "§6 Münze/n" ;
|
||||
break;
|
||||
case "remove":
|
||||
this.msg = "§8[§c"+ player.getName() + "§8] §7Entfernt " + target.getName() + " §6" + Coins + "§6 Münze/n" ;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Core.getInstance().getCacheManager().addCache(this.msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getLog() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
package de.warking.hunjy.CoinSystem.events;
|
||||
|
||||
|
||||
import de.warking.hunjy.Core;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
|
||||
public class PlayerCoinsChangeEvent extends Event implements Cancellable{
|
||||
|
||||
public static HandlerList handlers = new HandlerList();
|
||||
public boolean cancelled = false;
|
||||
|
||||
Player player;
|
||||
String msg;
|
||||
|
||||
public PlayerCoinsChangeEvent(Player player, Player target, String option, int Coins) {
|
||||
this.player = player;
|
||||
switch (option) {
|
||||
case "add":
|
||||
this.msg = "<EFBFBD>8[<5B>c"+ player.getName() + "<EFBFBD>8] <20>7Gibt " + target.getName() + " <20>6" + Coins + "<EFBFBD>6 M<>nze/n" ;
|
||||
break;
|
||||
case "set":
|
||||
this.msg = "<EFBFBD>8[<5B>c"+ player.getName() + "<EFBFBD>8] <20>7Setzt den Kontostand von " + target.getName() + " <20>7auf <20>6" + Coins + "<EFBFBD>6 M<>nze/n" ;
|
||||
break;
|
||||
case "remove":
|
||||
this.msg = "<EFBFBD>8[<5B>c"+ player.getName() + "<EFBFBD>8] <20>7Entfernt " + target.getName() + " <20>6" + Coins + "<EFBFBD>6 M<>nze/n" ;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Core.getInstance().getCacheManager().addCache(this.msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getLog() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +1,52 @@
|
||||
package de.diamant.hunjy.CoinSystem.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import de.diamant.hunjy.Core;
|
||||
|
||||
public class PlayerPayPlayerEvent extends Event implements Cancellable{
|
||||
|
||||
public static HandlerList handlers = new HandlerList();
|
||||
public boolean cancelled = false;
|
||||
|
||||
Player player;
|
||||
String msg;
|
||||
|
||||
public PlayerPayPlayerEvent(Player player, Player target, int coins) {
|
||||
this.player = player;
|
||||
this.msg = "§7" + player.getName() + " §8-> §7" + target.getName() + " §8[§6" + coins + " Münzen§8]";
|
||||
|
||||
Core.getInstance().getCacheManager().addCache(this.msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
package de.warking.hunjy.CoinSystem.events;
|
||||
|
||||
import de.warking.hunjy.Core;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerPayPlayerEvent extends Event implements Cancellable{
|
||||
|
||||
public static HandlerList handlers = new HandlerList();
|
||||
public boolean cancelled = false;
|
||||
|
||||
Player player;
|
||||
String msg;
|
||||
|
||||
public PlayerPayPlayerEvent(Player player, Player target, int coins) {
|
||||
this.player = player;
|
||||
this.msg = "<EFBFBD>7" + player.getName() + " <20>8-> <20>7" + target.getName() + " <20>8[<5B>6" + coins + " M<>nzen<65>8]";
|
||||
|
||||
Core.getInstance().getCacheManager().addCache(this.msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
@ -1,82 +1,82 @@
|
||||
package de.diamant.hunjy.CoinSystem.manager;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.diamant.hunjy.Core;
|
||||
import de.diamant.hunjy.MySQL.MySQL;
|
||||
/**
|
||||
* @author hunjy
|
||||
*
|
||||
*/
|
||||
public class CoinsManager {
|
||||
|
||||
private MySQL mySQL;
|
||||
Player player;
|
||||
|
||||
public CoinsManager(Player player) {
|
||||
mySQL = Core.getInstance().getMySQL();
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public boolean playerExist() {
|
||||
try {
|
||||
PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM Coins WHERE UUID=?");
|
||||
st.setString(1, player.getUniqueId().toString());
|
||||
ResultSet rs = st.executeQuery();
|
||||
return rs.next();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void createPlayer() {
|
||||
mySQL.update("INSERT INTO Coins(UUID, Coins) VALUES ('"+ player.getUniqueId().toString() +"','0')");
|
||||
}
|
||||
|
||||
public int getCoins() {
|
||||
if(!playerExist())
|
||||
createPlayer();
|
||||
int coins = 0;
|
||||
|
||||
ResultSet rs = mySQL.getResultSet("SELECT * FROM Coins WHERE UUID='"+ player.getUniqueId().toString() +"'");
|
||||
try {
|
||||
if(rs.next() && Integer.valueOf(rs.getInt("Coins")) != null) {
|
||||
coins = rs.getInt("Coins");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return coins;
|
||||
}
|
||||
|
||||
public void setCoins(int amount) {
|
||||
if(!playerExist())
|
||||
createPlayer();
|
||||
mySQL.update("UPDATE Coins Set Coins='" + amount + "' WHERE UUID='" + player.getUniqueId().toString() + "'");
|
||||
}
|
||||
|
||||
public void addCoins( int amount) {
|
||||
if(!playerExist())
|
||||
createPlayer();
|
||||
int coins = getCoins();
|
||||
coins += amount;
|
||||
mySQL.update("UPDATE Coins Set Coins='" + coins + "' WHERE UUID='" + player.getUniqueId().toString() + "'");
|
||||
}
|
||||
|
||||
public void removeCoins( int amount) {
|
||||
if(!playerExist())
|
||||
createPlayer();
|
||||
int coins = getCoins();
|
||||
coins -= amount;
|
||||
if(coins >= 0)
|
||||
mySQL.update("UPDATE Coins Set Coins='" + coins + "' WHERE UUID='" + player.getUniqueId().toString() + "'");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package de.warking.hunjy.CoinSystem.manager;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import de.warking.hunjy.Core;
|
||||
import de.warking.hunjy.MySQL.MySQL;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author hunjy
|
||||
*
|
||||
*/
|
||||
public class CoinsManager {
|
||||
|
||||
private MySQL mySQL;
|
||||
Player player;
|
||||
|
||||
public CoinsManager(Player player) {
|
||||
mySQL = Core.getInstance().getMySQL();
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public boolean playerExist() {
|
||||
try {
|
||||
PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM Coins WHERE UUID=?");
|
||||
st.setString(1, player.getUniqueId().toString());
|
||||
ResultSet rs = st.executeQuery();
|
||||
return rs.next();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void createPlayer() {
|
||||
mySQL.update("INSERT INTO Coins(UUID, Coins) VALUES ('"+ player.getUniqueId().toString() +"','0')");
|
||||
}
|
||||
|
||||
public int getCoins() {
|
||||
if(!playerExist())
|
||||
createPlayer();
|
||||
int coins = 0;
|
||||
|
||||
ResultSet rs = mySQL.select("SELECT * FROM Coins WHERE UUID='"+ player.getUniqueId().toString() +"'");
|
||||
try {
|
||||
if(rs.next() && Integer.valueOf(rs.getInt("Coins")) != null) {
|
||||
coins = rs.getInt("Coins");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return coins;
|
||||
}
|
||||
|
||||
public void setCoins(int amount) {
|
||||
if(!playerExist())
|
||||
createPlayer();
|
||||
mySQL.update("UPDATE Coins Set Coins='" + amount + "' WHERE UUID='" + player.getUniqueId().toString() + "'");
|
||||
}
|
||||
|
||||
public void addCoins( int amount) {
|
||||
if(!playerExist())
|
||||
createPlayer();
|
||||
int coins = getCoins();
|
||||
coins += amount;
|
||||
mySQL.update("UPDATE Coins Set Coins='" + coins + "' WHERE UUID='" + player.getUniqueId().toString() + "'");
|
||||
}
|
||||
|
||||
public void removeCoins( int amount) {
|
||||
if(!playerExist())
|
||||
createPlayer();
|
||||
int coins = getCoins();
|
||||
coins -= amount;
|
||||
if(coins >= 0)
|
||||
mySQL.update("UPDATE Coins Set Coins='" + coins + "' WHERE UUID='" + player.getUniqueId().toString() + "'");
|
||||
}
|
||||
|
||||
}
|
||||
|
83
src/de/warking/hunjy/Core.java
Normale Datei
83
src/de/warking/hunjy/Core.java
Normale Datei
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -1,95 +1,98 @@
|
||||
package de.diamant.hunjy.MySQL;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import de.diamant.hunjy.Core;
|
||||
|
||||
|
||||
public class MySQL {
|
||||
private String HOST = "";
|
||||
private String PORT = "";
|
||||
private String DATABASE = "";
|
||||
private String USER = "";
|
||||
private String PASSWORD = "";
|
||||
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() {
|
||||
this.HOST = Core.getInstance().getFileManager().getConfig().getString("HOST");
|
||||
this.PORT = Core.getInstance().getFileManager().getConfig().getString("PORT");
|
||||
this.DATABASE = Core.getInstance().getFileManager().getConfig().getString("DATABASE");
|
||||
this.USER = Core.getInstance().getFileManager().getConfig().getString("USER");
|
||||
|
||||
if(!Core.getInstance().getFileManager().getConfig().getString("PASSWORD").equals("")) {
|
||||
this.PASSWORD = Core.getInstance().getFileManager().getConfig().getString("PASSWORD");
|
||||
}
|
||||
|
||||
connect();
|
||||
}
|
||||
|
||||
public void connect() {
|
||||
try {
|
||||
con = DriverManager.getConnection("jdbc:mysql://" + HOST + ":" + PORT + "/" + DATABASE + "?autoreconnect=true", USER, PASSWORD);
|
||||
if(con != null)
|
||||
System.out.println(Core.getInstance().getDescription().getFullName() + " >> MySQL: Verbunden");
|
||||
}catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void closeConnection() {
|
||||
try {
|
||||
if(con != null)
|
||||
con.close();
|
||||
}catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(String qry) {
|
||||
try {
|
||||
PreparedStatement st = con.prepareStatement(qry);
|
||||
st.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public ResultSet getResultSet(String qry) {
|
||||
|
||||
try {
|
||||
PreparedStatement st = con.prepareStatement(qry);
|
||||
return st.executeQuery();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Connection getCon() {
|
||||
return con;
|
||||
}
|
||||
}
|
||||
package de.warking.hunjy.MySQL;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import de.warking.hunjy.Core;
|
||||
|
||||
|
||||
public class MySQL {
|
||||
private String HOST;
|
||||
private String PORT;
|
||||
private String DATABASE;
|
||||
private String USER;
|
||||
private String PASSWORD = "";
|
||||
private Connection con;
|
||||
|
||||
public MySQL() {
|
||||
this.HOST = Core.getInstance().getFileManager().getConfig().getString("HOST");
|
||||
this.PORT = Core.getInstance().getFileManager().getConfig().getString("PORT");
|
||||
this.DATABASE = Core.getInstance().getFileManager().getConfig().getString("DATABASE");
|
||||
this.USER = Core.getInstance().getFileManager().getConfig().getString("USER");
|
||||
|
||||
if(!Core.getInstance().getFileManager().getConfig().getString("PASSWORD").equals("")) {
|
||||
this.PASSWORD = Core.getInstance().getFileManager().getConfig().getString("PASSWORD");
|
||||
}
|
||||
|
||||
connect();
|
||||
}
|
||||
|
||||
public void connect() {
|
||||
try {
|
||||
con = DriverManager.getConnection("jdbc:mysql://" + HOST + ":" + PORT + "/" + DATABASE + "?autoreconnect=true", USER, PASSWORD);
|
||||
if(con == null)
|
||||
System.err.println("Fatal ERROR: Could not connect to database!");
|
||||
}catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void reconnect(){
|
||||
closeConnection();
|
||||
connect();
|
||||
}
|
||||
|
||||
public void closeConnection() {
|
||||
try {
|
||||
if(con != null)
|
||||
con.close();
|
||||
}catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(String qry) {
|
||||
if(con == null){
|
||||
return;
|
||||
}
|
||||
try {
|
||||
PreparedStatement st = con.prepareStatement(qry);
|
||||
st.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
reconnect();
|
||||
try {
|
||||
PreparedStatement st = con.prepareStatement(qry);
|
||||
st.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ResultSet select(String qry) {
|
||||
if(con == null){
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
PreparedStatement st = con.prepareStatement(qry);
|
||||
return st.executeQuery();
|
||||
} catch (SQLException e) {
|
||||
reconnect();
|
||||
try {
|
||||
PreparedStatement st = con.prepareStatement(qry);
|
||||
return st.executeQuery();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Connection getCon() {
|
||||
return con;
|
||||
}
|
||||
}
|
140
src/de/warking/hunjy/MySQL/Schematic.java
Normale Datei
140
src/de/warking/hunjy/MySQL/Schematic.java
Normale Datei
@ -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();
|
||||
}
|
||||
}
|
7
src/de/warking/hunjy/MySQL/SchematicMember.java
Normale Datei
7
src/de/warking/hunjy/MySQL/SchematicMember.java
Normale Datei
@ -0,0 +1,7 @@
|
||||
package de.warking.hunjy.MySQL;
|
||||
|
||||
public class SchematicMember {
|
||||
private int SchemOwner;
|
||||
private String SchemName;
|
||||
private int Member;
|
||||
}
|
9
src/de/warking/hunjy/MySQL/SchematicType.java
Normale Datei
9
src/de/warking/hunjy/MySQL/SchematicType.java
Normale Datei
@ -0,0 +1,9 @@
|
||||
package de.warking.hunjy.MySQL;
|
||||
|
||||
public enum SchematicType {
|
||||
normal,
|
||||
airship,
|
||||
wargear,
|
||||
warship,
|
||||
miniwargear
|
||||
}
|
80
src/de/warking/hunjy/MySQL/WarkingUser.java
Normale Datei
80
src/de/warking/hunjy/MySQL/WarkingUser.java
Normale Datei
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,75 +1,57 @@
|
||||
package de.diamant.hunjy.PlayerManager;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.diamant.hunjy.Core;
|
||||
import de.diamant.hunjy.MySQL.MySQL;
|
||||
import de.diamant.hunjy.Permissions.PermissionsManager;
|
||||
|
||||
public class PlayerManager {
|
||||
|
||||
UUID uuid;
|
||||
private MySQL mySQL;
|
||||
|
||||
public PlayerManager(Player player) {
|
||||
mySQL = Core.getInstance().getMySQL();
|
||||
this.uuid = player.getUniqueId();
|
||||
}
|
||||
|
||||
public PlayerManager(UUID uuid) {
|
||||
mySQL = Core.getInstance().getMySQL();
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public boolean playerExist() {
|
||||
try {
|
||||
PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM UserData WHERE UUID=?");
|
||||
st.setString(1, uuid.toString());
|
||||
ResultSet rs = st.executeQuery();
|
||||
return rs.next();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
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() {
|
||||
try {
|
||||
PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM UserData WHERE UUID=?");
|
||||
st.setString(1, uuid.toString());
|
||||
ResultSet rs = st.executeQuery();
|
||||
while(rs.next()) {
|
||||
return rs.getString("UserGroup");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public int getGroupID() {
|
||||
return PermissionsManager.getGroupManager().getSortIDFromGroup(getGroupName());
|
||||
}
|
||||
|
||||
public String getGroupDisplay() {
|
||||
return PermissionsManager.getGroupManager().getDisplayFromGroup(getGroupName());
|
||||
}
|
||||
|
||||
public void setGroup(String group) {
|
||||
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() + "'");
|
||||
}
|
||||
}
|
||||
package de.warking.hunjy.PlayerManager;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.warking.hunjy.Core;
|
||||
import de.warking.hunjy.MySQL.MySQL;
|
||||
|
||||
public class PlayerManager {
|
||||
|
||||
UUID uuid;
|
||||
private MySQL mySQL;
|
||||
|
||||
public PlayerManager(Player player) {
|
||||
mySQL = Core.getInstance().getMySQL();
|
||||
this.uuid = player.getUniqueId();
|
||||
}
|
||||
|
||||
public PlayerManager(UUID uuid) {
|
||||
mySQL = Core.getInstance().getMySQL();
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public boolean playerExist() {
|
||||
try {
|
||||
PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM UserData WHERE UUID=?");
|
||||
st.setString(1, uuid.toString());
|
||||
ResultSet rs = st.executeQuery();
|
||||
return rs.next();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
try {
|
||||
PreparedStatement st = mySQL.getCon().prepareStatement("SELECT * FROM UserData WHERE UUID=?");
|
||||
st.setString(1, uuid.toString());
|
||||
ResultSet rs = st.executeQuery();
|
||||
while(rs.next()) {
|
||||
return rs.getString("UserGroup");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setGroup(String group) {
|
||||
mySQL.update("UPDATE UserData Set UserGroup='" + group + "' WHERE UUID='" + uuid.toString() + "'");
|
||||
}
|
||||
}
|
26
src/de/warking/hunjy/PlayerManager/events/ChattingEvent.java
Normale Datei
26
src/de/warking/hunjy/PlayerManager/events/ChattingEvent.java
Normale Datei
@ -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");
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +1,56 @@
|
||||
package de.diamant.hunjy.PlayerManager.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerChengeTeamEvent extends Event implements Cancellable{
|
||||
|
||||
public static HandlerList handlers = new HandlerList();
|
||||
public boolean cancelled = false;
|
||||
|
||||
Player player;
|
||||
String oldGroup;
|
||||
String newGroup;
|
||||
|
||||
|
||||
public PlayerChengeTeamEvent(Player player, String oldGroup, String newGroup) {
|
||||
this.player = player;
|
||||
this.oldGroup = oldGroup;
|
||||
this.newGroup = newGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getOldGroup() {
|
||||
return oldGroup;
|
||||
}
|
||||
|
||||
public String getNewGroup() {
|
||||
return newGroup;
|
||||
}
|
||||
|
||||
}
|
||||
package de.warking.hunjy.PlayerManager.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerChangeTeamEvent extends Event implements Cancellable{
|
||||
|
||||
public static HandlerList handlers = new HandlerList();
|
||||
public boolean cancelled = false;
|
||||
|
||||
Player player;
|
||||
String oldGroup;
|
||||
String newGroup;
|
||||
|
||||
|
||||
public PlayerChangeTeamEvent(Player player, String oldGroup, String newGroup) {
|
||||
this.player = player;
|
||||
this.oldGroup = oldGroup;
|
||||
this.newGroup = newGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getOldGroup() {
|
||||
return oldGroup;
|
||||
}
|
||||
|
||||
public String getNewGroup() {
|
||||
return newGroup;
|
||||
}
|
||||
|
||||
}
|
57
src/de/warking/hunjy/PlayerManager/events/PlayerJoin.java
Normale Datei
57
src/de/warking/hunjy/PlayerManager/events/PlayerJoin.java
Normale Datei
@ -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());
|
||||
}
|
||||
|
||||
}
|
@ -1,37 +1,36 @@
|
||||
package de.diamant.hunjy.manager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Time;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import de.diamant.hunjy.Core;
|
||||
|
||||
|
||||
public class CacheManager {
|
||||
|
||||
private File file;
|
||||
private YamlConfiguration config;
|
||||
|
||||
public CacheManager() {
|
||||
file = new File(Core.getInstance().getDataFolder(), "cache.yml");
|
||||
config = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void addCache(String qry) {
|
||||
|
||||
long millis = System.currentTimeMillis();
|
||||
Time time = new Time(millis);
|
||||
|
||||
config.set(time.toLocaleString(), qry);
|
||||
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package de.warking.hunjy.manager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Time;
|
||||
|
||||
import de.warking.hunjy.Core;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
|
||||
public class CacheManager {
|
||||
|
||||
private File file;
|
||||
private YamlConfiguration config;
|
||||
|
||||
public CacheManager() {
|
||||
file = new File(Core.getInstance().getDataFolder(), "cache.yml");
|
||||
config = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void addCache(String qry) {
|
||||
|
||||
long millis = System.currentTimeMillis();
|
||||
Time time = new Time(millis);
|
||||
|
||||
config.set(time.toLocaleString(), qry);
|
||||
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,49 +1,48 @@
|
||||
package de.diamant.hunjy.manager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import de.diamant.hunjy.Core;
|
||||
|
||||
|
||||
public class FileManager {
|
||||
|
||||
private File file;
|
||||
private YamlConfiguration config;
|
||||
|
||||
public FileManager() {
|
||||
file = new File(Core.getInstance().getDataFolder(), "MySQL.yml");
|
||||
config = YamlConfiguration.loadConfiguration(file);
|
||||
setDefaults();
|
||||
}
|
||||
|
||||
private void setDefaults() {
|
||||
if(!file.exists()) {
|
||||
config.set("HOST", "localhost");
|
||||
config.set("PORT", "3306");
|
||||
config.set("DATABASE", "coinsystem");
|
||||
config.set("USER", "root");
|
||||
config.set("PASSWORD", "");
|
||||
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public YamlConfiguration getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
package de.warking.hunjy.manager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import de.warking.hunjy.Core;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
|
||||
public class FileManager {
|
||||
|
||||
private File file;
|
||||
private YamlConfiguration config;
|
||||
|
||||
public FileManager() {
|
||||
file = new File(Core.getInstance().getDataFolder(), "MySQL.yml");
|
||||
config = YamlConfiguration.loadConfiguration(file);
|
||||
setDefaults();
|
||||
}
|
||||
|
||||
private void setDefaults() {
|
||||
if(!file.exists()) {
|
||||
config.set("HOST", "localhost");
|
||||
config.set("PORT", "3306");
|
||||
config.set("DATABASE", "coinsystem");
|
||||
config.set("USER", "root");
|
||||
config.set("PASSWORD", "");
|
||||
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public YamlConfiguration getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,15 +1,13 @@
|
||||
name: CoreSystem
|
||||
version: 1.0
|
||||
|
||||
author: hunjy
|
||||
author: hunjy, Lixfel
|
||||
|
||||
main: de.diamant.hunjy.Core
|
||||
main: de.warking.hunjy.Core
|
||||
|
||||
commands:
|
||||
coins:
|
||||
pay:
|
||||
addcoins:
|
||||
removecoins:
|
||||
setcoins:
|
||||
perms:
|
||||
dperms:
|
||||
setcoins:
|
In neuem Issue referenzieren
Einen Benutzer sperren