Initial commit
Dieser Commit ist enthalten in:
Ursprung
ddb96fbbef
Commit
776c3acff2
7
Diamant-ix_Corre/.classpath
Normale Datei
7
Diamant-ix_Corre/.classpath
Normale Datei
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="C:/Users/hunjy/Desktop/Programmieren/Versionen/1.12.2.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
17
Diamant-ix_Corre/.project
Normale Datei
17
Diamant-ix_Corre/.project
Normale Datei
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Diamant-ix_Corre</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
2
Diamant-ix_Corre/.settings/org.eclipse.core.resources.prefs
Normale Datei
2
Diamant-ix_Corre/.settings/org.eclipse.core.resources.prefs
Normale Datei
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/de/diamant/hunjy/PlayerManager/events/PlayerJoin.java=UTF-8
|
11
Diamant-ix_Corre/.settings/org.eclipse.jdt.core.prefs
Normale Datei
11
Diamant-ix_Corre/.settings/org.eclipse.jdt.core.prefs
Normale Datei
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
BIN
Diamant-ix_Corre/bin/de/diamant/hunjy/CoinSystem/CoinSystem.class
Normale Datei
BIN
Diamant-ix_Corre/bin/de/diamant/hunjy/CoinSystem/CoinSystem.class
Normale Datei
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
BIN
Diamant-ix_Corre/bin/de/diamant/hunjy/Core.class
Normale Datei
BIN
Diamant-ix_Corre/bin/de/diamant/hunjy/Core.class
Normale Datei
Binäre Datei nicht angezeigt.
BIN
Diamant-ix_Corre/bin/de/diamant/hunjy/MySQL/MySQL.class
Normale Datei
BIN
Diamant-ix_Corre/bin/de/diamant/hunjy/MySQL/MySQL.class
Normale Datei
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
BIN
Diamant-ix_Corre/bin/de/diamant/hunjy/PlayerManager/PlayerManager.class
Normale Datei
BIN
Diamant-ix_Corre/bin/de/diamant/hunjy/PlayerManager/PlayerManager.class
Normale Datei
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
BIN
Diamant-ix_Corre/bin/de/diamant/hunjy/manager/CacheManager.class
Normale Datei
BIN
Diamant-ix_Corre/bin/de/diamant/hunjy/manager/CacheManager.class
Normale Datei
Binäre Datei nicht angezeigt.
BIN
Diamant-ix_Corre/bin/de/diamant/hunjy/manager/FileManager.class
Normale Datei
BIN
Diamant-ix_Corre/bin/de/diamant/hunjy/manager/FileManager.class
Normale Datei
Binäre Datei nicht angezeigt.
15
Diamant-ix_Corre/bin/plugin.yml
Normale Datei
15
Diamant-ix_Corre/bin/plugin.yml
Normale Datei
@ -0,0 +1,15 @@
|
||||
name: CoreSystem
|
||||
version: 1.0
|
||||
|
||||
author: hunjy
|
||||
|
||||
main: de.diamant.hunjy.Core
|
||||
|
||||
commands:
|
||||
coins:
|
||||
pay:
|
||||
addcoins:
|
||||
removecoins:
|
||||
setcoins:
|
||||
perms:
|
||||
dperms:
|
18
Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/CoinSystem.java
Normale Datei
18
Diamant-ix_Corre/src/de/diamant/hunjy/CoinSystem/CoinSystem.java
Normale Datei
@ -0,0 +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);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,180 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +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() + "'");
|
||||
}
|
||||
|
||||
}
|
||||
|
90
Diamant-ix_Corre/src/de/diamant/hunjy/Core.java
Normale Datei
90
Diamant-ix_Corre/src/de/diamant/hunjy/Core.java
Normale Datei
@ -0,0 +1,90 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
95
Diamant-ix_Corre/src/de/diamant/hunjy/MySQL/MySQL.java
Normale Datei
95
Diamant-ix_Corre/src/de/diamant/hunjy/MySQL/MySQL.java
Normale Datei
@ -0,0 +1,95 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,158 @@
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,205 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
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() + "'");
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
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");
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
37
Diamant-ix_Corre/src/de/diamant/hunjy/manager/CacheManager.java
Normale Datei
37
Diamant-ix_Corre/src/de/diamant/hunjy/manager/CacheManager.java
Normale Datei
@ -0,0 +1,37 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
49
Diamant-ix_Corre/src/de/diamant/hunjy/manager/FileManager.java
Normale Datei
49
Diamant-ix_Corre/src/de/diamant/hunjy/manager/FileManager.java
Normale Datei
@ -0,0 +1,49 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
15
Diamant-ix_Corre/src/plugin.yml
Normale Datei
15
Diamant-ix_Corre/src/plugin.yml
Normale Datei
@ -0,0 +1,15 @@
|
||||
name: CoreSystem
|
||||
version: 1.0
|
||||
|
||||
author: hunjy
|
||||
|
||||
main: de.diamant.hunjy.Core
|
||||
|
||||
commands:
|
||||
coins:
|
||||
pay:
|
||||
addcoins:
|
||||
removecoins:
|
||||
setcoins:
|
||||
perms:
|
||||
dperms:
|
In neuem Issue referenzieren
Einen Benutzer sperren