From 95ebca1681e4a91a42011c2ec52e96d7a2c7f513 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 16 Mar 2019 20:03:24 +0100 Subject: [PATCH] Various things + Core Schematic API --- .gitignore | 3 +- .../diamant/hunjy/BanSystem/BanManager.java | 5 - .../src/de/diamant/hunjy/Core.java | 90 ----- .../Permissions/Manager/GroupManager.java | 158 -------- .../hunjy/Permissions/PermissionsManager.java | 49 --- .../Permissions/commands/PermsCommand.java | 205 ---------- .../PlayerManager/events/ChatingEvent.java | 26 -- .../PlayerManager/events/PlayerJoin.java | 34 -- pom.xml | 56 +++ .../warking}/hunjy/CoinSystem/CoinSystem.java | 36 +- .../hunjy/CoinSystem/command/CoinCommand.java | 357 +++++++++--------- .../events/PlayerCoinsChangeEvent.java | 135 ++++--- .../events/PlayerPayPlayerEvent.java | 105 +++--- .../CoinSystem/manager/CoinsManager.java | 164 ++++---- src/de/warking/hunjy/Core.java | 83 ++++ .../de/warking}/hunjy/MySQL/MySQL.java | 193 +++++----- src/de/warking/hunjy/MySQL/Schematic.java | 140 +++++++ .../warking/hunjy/MySQL/SchematicMember.java | 7 + src/de/warking/hunjy/MySQL/SchematicType.java | 9 + src/de/warking/hunjy/MySQL/WarkingUser.java | 80 ++++ .../hunjy/PlayerManager/PlayerManager.java | 132 +++---- .../PlayerManager/events/ChattingEvent.java | 26 ++ .../events/PlayerChangeTeamEvent.java | 112 +++--- .../PlayerManager/events/PlayerJoin.java | 57 +++ .../warking}/hunjy/manager/CacheManager.java | 73 ++-- .../warking}/hunjy/manager/FileManager.java | 97 +++-- {Diamant-ix_Corre/src => src}/plugin.yml | 8 +- 27 files changed, 1155 insertions(+), 1285 deletions(-) delete mode 100644 Diamant-ix_Corre/src/de/diamant/hunjy/BanSystem/BanManager.java delete mode 100644 Diamant-ix_Corre/src/de/diamant/hunjy/Core.java delete mode 100644 Diamant-ix_Corre/src/de/diamant/hunjy/Permissions/Manager/GroupManager.java delete mode 100644 Diamant-ix_Corre/src/de/diamant/hunjy/Permissions/PermissionsManager.java delete mode 100644 Diamant-ix_Corre/src/de/diamant/hunjy/Permissions/commands/PermsCommand.java delete mode 100644 Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/events/ChatingEvent.java delete mode 100644 Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/events/PlayerJoin.java create mode 100644 pom.xml rename {Diamant-ix_Corre/src/de/diamant => src/de/warking}/hunjy/CoinSystem/CoinSystem.java (55%) rename {Diamant-ix_Corre/src/de/diamant => src/de/warking}/hunjy/CoinSystem/command/CoinCommand.java (53%) rename {Diamant-ix_Corre/src/de/diamant => src/de/warking}/hunjy/CoinSystem/events/PlayerCoinsChangeEvent.java (67%) rename {Diamant-ix_Corre/src/de/diamant => src/de/warking}/hunjy/CoinSystem/events/PlayerPayPlayerEvent.java (79%) rename {Diamant-ix_Corre/src/de/diamant => src/de/warking}/hunjy/CoinSystem/manager/CoinsManager.java (85%) create mode 100644 src/de/warking/hunjy/Core.java rename {Diamant-ix_Corre/src/de/diamant => src/de/warking}/hunjy/MySQL/MySQL.java (62%) create mode 100644 src/de/warking/hunjy/MySQL/Schematic.java create mode 100644 src/de/warking/hunjy/MySQL/SchematicMember.java create mode 100644 src/de/warking/hunjy/MySQL/SchematicType.java create mode 100644 src/de/warking/hunjy/MySQL/WarkingUser.java rename {Diamant-ix_Corre/src/de/diamant => src/de/warking}/hunjy/PlayerManager/PlayerManager.java (57%) create mode 100644 src/de/warking/hunjy/PlayerManager/events/ChattingEvent.java rename Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/events/PlayerChengeTeamEvent.java => src/de/warking/hunjy/PlayerManager/events/PlayerChangeTeamEvent.java (78%) create mode 100644 src/de/warking/hunjy/PlayerManager/events/PlayerJoin.java rename {Diamant-ix_Corre/src/de/diamant => src/de/warking}/hunjy/manager/CacheManager.java (86%) rename {Diamant-ix_Corre/src/de/diamant => src/de/warking}/hunjy/manager/FileManager.java (87%) rename {Diamant-ix_Corre/src => src}/plugin.yml (50%) diff --git a/.gitignore b/.gitignore index c4c7126..7d6e08c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ .project .settings target -bin \ No newline at end of file +bin +*.iml \ No newline at end of file diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/BanSystem/BanManager.java b/Diamant-ix_Corre/src/de/diamant/hunjy/BanSystem/BanManager.java deleted file mode 100644 index 0922c47..0000000 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/BanSystem/BanManager.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.diamant.hunjy.BanSystem; - -public class BanManager { - -} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/Core.java b/Diamant-ix_Corre/src/de/diamant/hunjy/Core.java deleted file mode 100644 index 8fdb27f..0000000 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/Core.java +++ /dev/null @@ -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; - } - -} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/Permissions/Manager/GroupManager.java b/Diamant-ix_Corre/src/de/diamant/hunjy/Permissions/Manager/GroupManager.java deleted file mode 100644 index 9606817..0000000 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/Permissions/Manager/GroupManager.java +++ /dev/null @@ -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 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 getGroups() { - List 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 getGroupPermissions(String groupName) { - ArrayList 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[] array = perms.split(", "); - list = new ArrayList(Arrays.asList(array)); - return list; - - } -} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/Permissions/PermissionsManager.java b/Diamant-ix_Corre/src/de/diamant/hunjy/Permissions/PermissionsManager.java deleted file mode 100644 index 5966a0f..0000000 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/Permissions/PermissionsManager.java +++ /dev/null @@ -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 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 perms = getGroupManager().getGroupPermissions(group); - for(String perm : perms) { - PermissionAttachment attachment = player.addAttachment(Core.getInstance()); - attachment.setPermission(perm, true); - if(perm.equals("*")) { - player.setOp(true); - } - } - } -} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/Permissions/commands/PermsCommand.java b/Diamant-ix_Corre/src/de/diamant/hunjy/Permissions/commands/PermsCommand.java deleted file mode 100644 index ac70564..0000000 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/Permissions/commands/PermsCommand.java +++ /dev/null @@ -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("7m--------------------[3 Permissions 7m]--------------------"); - player.sendMessage(" " + PermissionsManager.prefix + "/perms list"); - player.sendMessage(" " + PermissionsManager.prefix + "/perms user "); - - player.sendMessage(" " + PermissionsManager.prefix + "/perms createGroup "); - player.sendMessage(" " + PermissionsManager.prefix + "/perms removeGroup "); - - - player.sendMessage(" " + PermissionsManager.prefix + "/perms addPermission "); - player.sendMessage(" " + PermissionsManager.prefix + "/perms removePermission "); - - player.sendMessage(" " + PermissionsManager.prefix + "/perms changeDisplay "); - - - player.sendMessage(" " + PermissionsManager.prefix + "/perms player set group "); - player.sendMessage(" " + PermissionsManager.prefix + "/perms player remove group"); - player.sendMessage("7m--------------------[3 Permissions 7m]--------------------"); - - }else if(args.length >= 1) { - if(args[0].equalsIgnoreCase("list")) { - player.sendMessage(""); - List idList = new ArrayList(); - 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 "); - 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 gelscht!"); - }else { - player.sendMessage("cDiese Gruppe gibt es nicht!"); - } - - }else { - player.sendMessage(" " + PermissionsManager.prefix + "/perms removeGroup "); - 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 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) + " ahinzugefgt"); - - }else { - player.sendMessage(" " + PermissionsManager.prefix + "/perms addPermission "); - } - }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 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 "); - } - }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 "); - } - } - } - } - - return false; - } - -} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/events/ChatingEvent.java b/Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/events/ChatingEvent.java deleted file mode 100644 index 1ca2c86..0000000 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/events/ChatingEvent.java +++ /dev/null @@ -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\n7Bitte Joine neu auf 9Diamant-ix.de"); - - } - -} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/events/PlayerJoin.java b/Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/events/PlayerJoin.java deleted file mode 100644 index e85a3cf..0000000 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/events/PlayerJoin.java +++ /dev/null @@ -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); - - } - -} diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..e912893 --- /dev/null +++ b/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + + de.warking + SpigotCore + 1.0 + jar + https://maven.apache.org + + + UTF-8 + + + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + + + src + + + src + + **/*.java + **/*.kt + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + 1.8 + 1.8 + + + + + + + + org.spigotmc + spigot-api + 1.12.2-R0.1-SNAPSHOT + provided + + + \ No newline at end of file diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/CoinSystem.java b/src/de/warking/hunjy/CoinSystem/CoinSystem.java similarity index 55% rename from Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/CoinSystem.java rename to src/de/warking/hunjy/CoinSystem/CoinSystem.java index 7777234..ff4341f 100644 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/CoinSystem.java +++ b/src/de/warking/hunjy/CoinSystem/CoinSystem.java @@ -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 = "�6Bank �8� "; + + public CoinSystem() { + } + + public static CoinsManager getCoinsManager(Player player) { + return new CoinsManager(player); + } + +} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/command/CoinCommand.java b/src/de/warking/hunjy/CoinSystem/command/CoinCommand.java similarity index 53% rename from Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/command/CoinCommand.java rename to src/de/warking/hunjy/CoinSystem/command/CoinCommand.java index 5e0a62e..f7f226b 100644 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/command/CoinCommand.java +++ b/src/de/warking/hunjy/CoinSystem/command/CoinCommand.java @@ -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 + " Mnzena."); - }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 + " Mnzena."); - } - } - }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 gltigen Wert ein!"); - return false; - } - CoinSystem.getCoinsManager(target).addCoins(coins); - - target.sendMessage(CoinSystem.prefix + "aDu hast 6"+ coins + " Mnzen avon 7" + player.getDisplayName() + " aerhalten"); - player.sendMessage(CoinSystem.prefix + "aDu hast dem Spieler 7" + target.getDisplayName() + " aerfolgreich 6" + coins + " Mnzen agegeben."); - Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "add",coins)); - }catch (NumberFormatException e) { - player.sendMessage(CoinSystem.prefix + "cBitte gebe einen gltigen 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 gltigen Wert ein!"); - return false; - } - if(CoinSystem.getCoinsManager(target).getCoins() < coins) { - player.sendMessage(CoinSystem.prefix + "cDer Spieler hat nicht so viele 6Mnzenc."); - return false; - } - CoinSystem.getCoinsManager(target).removeCoins(coins); - - player.sendMessage(CoinSystem.prefix + "aDu hast dem Spieler 7" + target.getDisplayName() + " aerfolgreich 6" + coins + " Mnzen aweggenommen."); - Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "remove",coins)); - }catch (NumberFormatException e) { - player.sendMessage(CoinSystem.prefix + "cBitte gebe einen gltigen 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 gltigen Wert ein!"); - return false; - } - CoinSystem.getCoinsManager(target).setCoins(coins); - - - player.sendMessage(CoinSystem.prefix + "aDu hast den Kontostand von 7" + target.getDisplayName() + " aauf 6" + coins + " Mnzen agesetzt."); - Bukkit.getPluginManager().callEvent(new PlayerCoinsChangeEvent(player, target, "set",coins)); - }catch (NumberFormatException e) { - player.sendMessage(CoinSystem.prefix + "cBitte gebe einen gltigen 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 gengend 6Mnzenc."); - return false; - } - if(coins == 0) { - player.sendMessage(CoinSystem.prefix + "cBitte gebe einen gltigen Wert ein!"); - return false; - } - CoinSystem.getCoinsManager(player).removeCoins(coins); - CoinSystem.getCoinsManager(target).addCoins(coins); - - target.sendMessage(CoinSystem.prefix + "aDu hast 6"+ coins + " Mnzen avon 7" + player.getDisplayName() + " aerhalten"); - player.sendMessage(CoinSystem.prefix + "aDu hast dem Spieler 7" + target.getDisplayName() + " aerfolgreich 6" + coins + " Mnzen agegeben"); - Bukkit.getPluginManager().callEvent(new PlayerPayPlayerEvent(player, target, coins)); - }catch (NumberFormatException e) { - player.sendMessage(CoinSystem.prefix + "cBitte gebe einen gltigen 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 + "�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; + } + } \ No newline at end of file diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/events/PlayerCoinsChangeEvent.java b/src/de/warking/hunjy/CoinSystem/events/PlayerCoinsChangeEvent.java similarity index 67% rename from Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/events/PlayerCoinsChangeEvent.java rename to src/de/warking/hunjy/CoinSystem/events/PlayerCoinsChangeEvent.java index 7132354..7dfa154 100644 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/events/PlayerCoinsChangeEvent.java +++ b/src/de/warking/hunjy/CoinSystem/events/PlayerCoinsChangeEvent.java @@ -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 Mnze/n" ; - break; - case "set": - this.msg = "8[c"+ player.getName() + "8] 7Setzt den Kontostand von " + target.getName() + " 7auf 6" + Coins + "6 Mnze/n" ; - break; - case "remove": - this.msg = "8[c"+ player.getName() + "8] 7Entfernt " + target.getName() + " 6" + Coins + "6 Mnze/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 = "�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; + } + +} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/events/PlayerPayPlayerEvent.java b/src/de/warking/hunjy/CoinSystem/events/PlayerPayPlayerEvent.java similarity index 79% rename from Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/events/PlayerPayPlayerEvent.java rename to src/de/warking/hunjy/CoinSystem/events/PlayerPayPlayerEvent.java index 8f41b4b..225b6cd 100644 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/events/PlayerPayPlayerEvent.java +++ b/src/de/warking/hunjy/CoinSystem/events/PlayerPayPlayerEvent.java @@ -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 + " Mnzen8]"; - - 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 = "�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; + } + +} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/manager/CoinsManager.java b/src/de/warking/hunjy/CoinSystem/manager/CoinsManager.java similarity index 85% rename from Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/manager/CoinsManager.java rename to src/de/warking/hunjy/CoinSystem/manager/CoinsManager.java index be6c668..1e6caa6 100644 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/manager/CoinsManager.java +++ b/src/de/warking/hunjy/CoinSystem/manager/CoinsManager.java @@ -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() + "'"); + } + +} + diff --git a/src/de/warking/hunjy/Core.java b/src/de/warking/hunjy/Core.java new file mode 100644 index 0000000..82773e3 --- /dev/null +++ b/src/de/warking/hunjy/Core.java @@ -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; + } + +} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/MySQL/MySQL.java b/src/de/warking/hunjy/MySQL/MySQL.java similarity index 62% rename from Diamant-ix_Corre/src/de/diamant/hunjy/MySQL/MySQL.java rename to src/de/warking/hunjy/MySQL/MySQL.java index bbe8569..a1a75bb 100644 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/MySQL/MySQL.java +++ b/src/de/warking/hunjy/MySQL/MySQL.java @@ -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; + } +} diff --git a/src/de/warking/hunjy/MySQL/Schematic.java b/src/de/warking/hunjy/MySQL/Schematic.java new file mode 100644 index 0000000..5d8fcde --- /dev/null +++ b/src/de/warking/hunjy/MySQL/Schematic.java @@ -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 getSchemsAccessibleByUser(UUID schemOwner){ + return getSchemsAccessibleByUser(WarkingUser.get(schemOwner).getId()); + } + + public static List getSchemsAccessibleByUser(int schemOwner){ + try{ + ResultSet schematic = sql.select("SELECT * FROM Schematic WHERE SchemOwner = '" + schemOwner + "'"); + List 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 getSchemsOfType(UUID schemOwner, SchematicType schemType){ + return getSchemsOfType(WarkingUser.get(schemOwner).getId(), schemType); + } + + public static List getSchemsOfType(int schemOwner, SchematicType schemType){ + try{ + ResultSet schematic = sql.select("SELECT * FROM Schematic WHERE SchemOwner = '" + schemOwner + "' AND SchemType = '" + schemType.name() + "'"); + List 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(); + } +} diff --git a/src/de/warking/hunjy/MySQL/SchematicMember.java b/src/de/warking/hunjy/MySQL/SchematicMember.java new file mode 100644 index 0000000..5d16331 --- /dev/null +++ b/src/de/warking/hunjy/MySQL/SchematicMember.java @@ -0,0 +1,7 @@ +package de.warking.hunjy.MySQL; + +public class SchematicMember { + private int SchemOwner; + private String SchemName; + private int Member; +} diff --git a/src/de/warking/hunjy/MySQL/SchematicType.java b/src/de/warking/hunjy/MySQL/SchematicType.java new file mode 100644 index 0000000..c0092e6 --- /dev/null +++ b/src/de/warking/hunjy/MySQL/SchematicType.java @@ -0,0 +1,9 @@ +package de.warking.hunjy.MySQL; + +public enum SchematicType { + normal, + airship, + wargear, + warship, + miniwargear +} diff --git a/src/de/warking/hunjy/MySQL/WarkingUser.java b/src/de/warking/hunjy/MySQL/WarkingUser.java new file mode 100644 index 0000000..05654eb --- /dev/null +++ b/src/de/warking/hunjy/MySQL/WarkingUser.java @@ -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 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; + } + } +} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/PlayerManager.java b/src/de/warking/hunjy/PlayerManager/PlayerManager.java similarity index 57% rename from Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/PlayerManager.java rename to src/de/warking/hunjy/PlayerManager/PlayerManager.java index 5bf0253..fcc21a9 100644 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/PlayerManager.java +++ b/src/de/warking/hunjy/PlayerManager/PlayerManager.java @@ -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() + "'"); + } +} diff --git a/src/de/warking/hunjy/PlayerManager/events/ChattingEvent.java b/src/de/warking/hunjy/PlayerManager/events/ChattingEvent.java new file mode 100644 index 0000000..e02f346 --- /dev/null +++ b/src/de/warking/hunjy/PlayerManager/events/ChattingEvent.java @@ -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() + "�8� �7" + event.getMessage()); + + } + + @EventHandler + private void onGroupChange(PlayerChangeTeamEvent 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"); + + } + +} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/events/PlayerChengeTeamEvent.java b/src/de/warking/hunjy/PlayerManager/events/PlayerChangeTeamEvent.java similarity index 78% rename from Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/events/PlayerChengeTeamEvent.java rename to src/de/warking/hunjy/PlayerManager/events/PlayerChangeTeamEvent.java index 5ba2a39..e2c6c36 100644 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/PlayerManager/events/PlayerChengeTeamEvent.java +++ b/src/de/warking/hunjy/PlayerManager/events/PlayerChangeTeamEvent.java @@ -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; + } + +} diff --git a/src/de/warking/hunjy/PlayerManager/events/PlayerJoin.java b/src/de/warking/hunjy/PlayerManager/events/PlayerJoin.java new file mode 100644 index 0000000..50b323f --- /dev/null +++ b/src/de/warking/hunjy/PlayerManager/events/PlayerJoin.java @@ -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()); + } + +} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/manager/CacheManager.java b/src/de/warking/hunjy/manager/CacheManager.java similarity index 86% rename from Diamant-ix_Corre/src/de/diamant/hunjy/manager/CacheManager.java rename to src/de/warking/hunjy/manager/CacheManager.java index 64568c3..72e1987 100644 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/manager/CacheManager.java +++ b/src/de/warking/hunjy/manager/CacheManager.java @@ -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(); + } + } + +} diff --git a/Diamant-ix_Corre/src/de/diamant/hunjy/manager/FileManager.java b/src/de/warking/hunjy/manager/FileManager.java similarity index 87% rename from Diamant-ix_Corre/src/de/diamant/hunjy/manager/FileManager.java rename to src/de/warking/hunjy/manager/FileManager.java index fa8966d..2f1598f 100644 --- a/Diamant-ix_Corre/src/de/diamant/hunjy/manager/FileManager.java +++ b/src/de/warking/hunjy/manager/FileManager.java @@ -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; + } + + + +} diff --git a/Diamant-ix_Corre/src/plugin.yml b/src/plugin.yml similarity index 50% rename from Diamant-ix_Corre/src/plugin.yml rename to src/plugin.yml index 65d0ad6..3fd6d06 100644 --- a/Diamant-ix_Corre/src/plugin.yml +++ b/src/plugin.yml @@ -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: \ No newline at end of file + setcoins: \ No newline at end of file