Initial commit
This commit is contained in:
113
Plugins/Old/BanSystem-Marc/.gitignore
vendored
Normal file
113
Plugins/Old/BanSystem-Marc/.gitignore
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
target/
|
||||
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
.flattened-pom.xml
|
||||
|
||||
# Common working directory
|
||||
run/
|
||||
71
Plugins/Old/BanSystem-Marc/pom.xml
Normal file
71
Plugins/Old/BanSystem-Marc/pom.xml
Normal file
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>de.craftix</groupId>
|
||||
<artifactId>BanSystem</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BanSystem</name>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.16-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,76 @@
|
||||
package de.craftix.bansystem;
|
||||
|
||||
import de.craftix.bansystem.commands.BanCmd;
|
||||
import de.craftix.bansystem.commands.BantypesCmd;
|
||||
import de.craftix.bansystem.commands.KickCmd;
|
||||
import de.craftix.bansystem.commands.MuteCmd;
|
||||
import de.craftix.bansystem.utils.Ban;
|
||||
import de.craftix.bansystem.utils.Reason;
|
||||
import de.craftix.bansystem.utils.Messages;
|
||||
import de.craftix.bansystem.utils.Mute;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.ChatEvent;
|
||||
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.api.plugin.PluginManager;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public final class BanSystem extends Plugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
MySQL.connect();
|
||||
manageSqlTables();
|
||||
PluginManager pm = getProxy().getPluginManager();
|
||||
pm.registerCommand(this, new BanCmd("ban", "princep.ban", "pban"));
|
||||
pm.registerCommand(this, new BantypesCmd("bantypes", "princep.list", "blist"));
|
||||
pm.registerCommand(this, new MuteCmd("mute", "princep.mute", "pmute"));
|
||||
pm.registerCommand(this, new KickCmd("kick", "princep.kick"));
|
||||
pm.registerListener(this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
MySQL.disconnect();
|
||||
}
|
||||
|
||||
private void manageSqlTables() {
|
||||
if (!MySQL.isConnected()) return;
|
||||
MySQL.insert("CREATE TABLE IF NOT EXISTS Ban (UUID VARCHAR(100), Type INT(10), Time INT(255))");
|
||||
MySQL.insert("CREATE TABLE IF NOT EXISTS BanHistory (UUID VARCHAR(100), Type INT(10))");
|
||||
MySQL.insert("CREATE TABLE IF NOT EXISTS Mute (UUID VARCHAR(100), Type INT(10), Time INT(255))");
|
||||
MySQL.insert("CREATE TABLE IF NOT EXISTS MuteHistory (UUID VARCHAR(100), Type INT(10))");
|
||||
}
|
||||
|
||||
public static void kickPlayer(ProxiedPlayer t, Reason reason) {
|
||||
t.disconnect(new TextComponent("§cDu wurdest gebannt!\n§aReason: §6" + reason.getMessage()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(ServerSwitchEvent e) {
|
||||
ProxiedPlayer p = e.getPlayer();
|
||||
if (p == null) System.out.println("Player not found");
|
||||
if (Ban.hasBanAccount(p.getUniqueId())) kickPlayer(p, Ban.getPlayerBan(p.getUniqueId()).reason);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChat(ChatEvent e) {
|
||||
ProxiedPlayer p = (ProxiedPlayer) e.getSender();
|
||||
if (p == null) System.out.println("Player not found");
|
||||
if (Mute.hasMuteAccount(p.getUniqueId())) {
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(new TextComponent(Messages.prefix + "§cDu bist gemutet, du kannst in " + convertTimeToString(Mute.getPlayerMute(p.getUniqueId()).time) + " wieder schreiben"));
|
||||
}
|
||||
}
|
||||
|
||||
public String convertTimeToString(long time) {
|
||||
Timestamp ts = new Timestamp(time);
|
||||
Date date = new Date(ts.getTime());
|
||||
return date.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package de.craftix.bansystem;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class MySQL {
|
||||
|
||||
public static final String server = "localhost";
|
||||
public static final Integer port = 3306;
|
||||
public static final String db = "Ban";
|
||||
public static final String user = "Ban";
|
||||
public static final String pass = "Ban";
|
||||
private static Connection con = null;
|
||||
|
||||
public static boolean connect(){
|
||||
String conString = "jdbc:mysql://" + server + ":" + port + "/" + db;
|
||||
try {
|
||||
con = DriverManager.getConnection(conString, user, pass);
|
||||
System.out.println("[Ban] MySQL connected successfully");
|
||||
return true;
|
||||
}catch (SQLException e){
|
||||
System.out.println("[Ban] MySQL connection failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean disconnect(){
|
||||
if (!isConnected()) return true;
|
||||
try {
|
||||
con.close();
|
||||
con = null;
|
||||
System.out.println("[Ban] MySQL disconnected");
|
||||
return true;
|
||||
}catch (SQLException e){
|
||||
System.out.println("[Ban] MySQL disconnecting failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isConnected(){
|
||||
return con != null;
|
||||
}
|
||||
|
||||
public static void insert(String qry){
|
||||
try {
|
||||
con.prepareStatement(qry).executeUpdate();
|
||||
}catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static ResultSet getData(String qry){
|
||||
try {
|
||||
return con.prepareStatement(qry).executeQuery();
|
||||
}catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package de.craftix.bansystem.commands;
|
||||
|
||||
import de.craftix.bansystem.BanSystem;
|
||||
import de.craftix.bansystem.utils.Ban;
|
||||
import de.craftix.bansystem.utils.Reason;
|
||||
import de.craftix.bansystem.utils.Messages;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
public class BanCmd extends Command {
|
||||
public BanCmd(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof ProxiedPlayer)) return;
|
||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||
if (args.length != 2) {
|
||||
p.sendMessage(Messages.syntaxErr);
|
||||
return;
|
||||
}
|
||||
int typeID = Integer.parseInt(args[1]);
|
||||
Reason type = null;
|
||||
for (Reason all : Reason.values()) if (all.getTypeID() == typeID) type = all;
|
||||
if (type == null) {
|
||||
p.sendMessage(Messages.syntaxErr);
|
||||
p.sendMessage(Messages.types);
|
||||
return;
|
||||
}
|
||||
ProxiedPlayer t = BungeeCord.getInstance().getPlayer(args[0]);
|
||||
if (Ban.hasBanAccount(t.getUniqueId())) {
|
||||
p.sendMessage(new TextComponent(Messages.prefix + "§cDieser Spieler ist bereits gebannt!"));
|
||||
return;
|
||||
}
|
||||
if (t.equals(p)) {
|
||||
p.sendMessage(new TextComponent(Messages.prefix + "§cDu kannst dich nicht selber bannen!"));
|
||||
return;
|
||||
}
|
||||
Ban.createBan(t, type);
|
||||
p.sendMessage(Messages.prefix + "§aDer Spieler §6" + t.getName() + " §awurde gebannt");
|
||||
BanSystem.kickPlayer(t, type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package de.craftix.bansystem.commands;
|
||||
|
||||
import de.craftix.bansystem.utils.Messages;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
public class BantypesCmd extends Command {
|
||||
public BantypesCmd(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sender.sendMessage(new TextComponent(Messages.types));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package de.craftix.bansystem.commands;
|
||||
|
||||
|
||||
import de.craftix.bansystem.utils.Messages;
|
||||
import de.craftix.bansystem.utils.Reason;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
public class KickCmd extends Command {
|
||||
public KickCmd(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||
if (args.length < 1) return;
|
||||
ProxiedPlayer t = BungeeCord.getInstance().getPlayer(args[0]);
|
||||
if (t == null) {
|
||||
p.sendMessage(new TextComponent("§cDieser Spieler existiert nicht!"));
|
||||
return;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
p.sendMessage(new TextComponent(Messages.types));
|
||||
return;
|
||||
}
|
||||
int typeID = Integer.parseInt(args[1]);
|
||||
Reason type = null;
|
||||
for (Reason all : Reason.values()) if (all.getTypeID() == typeID) type = all;
|
||||
if (type == null) {
|
||||
p.sendMessage(new TextComponent(Messages.syntaxErr));
|
||||
p.sendMessage(new TextComponent(Messages.types));
|
||||
return;
|
||||
}
|
||||
t.disconnect(new TextComponent("§cDu wurdest wegen " + type.getMessage() + " §cgekickt!"));
|
||||
p.sendMessage(new TextComponent("§aDu hast §7" + t.getName() + " §agekickt"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package de.craftix.bansystem.commands;
|
||||
|
||||
import de.craftix.bansystem.utils.Reason;
|
||||
import de.craftix.bansystem.utils.Messages;
|
||||
import de.craftix.bansystem.utils.Mute;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
public class MuteCmd extends Command {
|
||||
public MuteCmd(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof ProxiedPlayer)) return;
|
||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||
if (args.length != 2) {
|
||||
p.sendMessage(new TextComponent(Messages.syntaxErr));
|
||||
return;
|
||||
}
|
||||
int typeID = Integer.parseInt(args[1]);
|
||||
Reason type = null;
|
||||
for (Reason all : Reason.values()) if (all.getTypeID() == typeID) type = all;
|
||||
if (type == null) {
|
||||
p.sendMessage(new TextComponent(Messages.syntaxErr));
|
||||
p.sendMessage(new TextComponent(Messages.types));
|
||||
return;
|
||||
}
|
||||
ProxiedPlayer t = BungeeCord.getInstance().getPlayer(args[0]);
|
||||
if (t == null) {
|
||||
p.sendMessage(new TextComponent(Messages.prefix + "§cDieser Spieler exisitiert nicht"));
|
||||
return;
|
||||
}
|
||||
if (Mute.hasMuteAccount(t.getUniqueId())) {
|
||||
p.sendMessage(new TextComponent(Messages.prefix + "§cDieser Spieler ist bereits gemuted!"));
|
||||
return;
|
||||
}
|
||||
if (t.equals(p)) {
|
||||
p.sendMessage(new TextComponent(Messages.prefix + "§cDu kannst dich nicht selber gemuted!"));
|
||||
return;
|
||||
}
|
||||
Mute.createMute(t, type);
|
||||
p.sendMessage(new TextComponent(Messages.prefix + "§aDer Spieler §6" + t.getName() + " §awurde gemuted"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package de.craftix.bansystem.commands;
|
||||
|
||||
public class TempBanCmd {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package de.craftix.bansystem.commands;
|
||||
|
||||
public class TempMuteCmd {
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package de.craftix.bansystem.utils;
|
||||
|
||||
import de.craftix.bansystem.MySQL;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Ban {
|
||||
|
||||
public static Ban getPlayerBan(UUID uuid) {
|
||||
if (hasBanAccount(uuid)) return new Ban(uuid);
|
||||
return new Ban(uuid, null, 0);
|
||||
}
|
||||
|
||||
public static void createBan(ProxiedPlayer p, Reason type) {
|
||||
Ban ban = new Ban(p.getUniqueId(), type, type.getTime());
|
||||
ban.save();
|
||||
}
|
||||
|
||||
public static boolean hasBanAccount(UUID uuid) {
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM Ban WHERE UUID = \"" + uuid + "\"");
|
||||
if (rs == null) return false;
|
||||
if (!rs.next()) return false;
|
||||
return rs.getString("UUID") != null;
|
||||
}catch (Exception ignored) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Reason getType(int typeID) {
|
||||
for (Reason type : Reason.values()) if (type.getTypeID() == typeID) return type;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ArrayList<Ban> getAllBans() {
|
||||
ArrayList<Ban> bans = new ArrayList<>();
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM Ban");
|
||||
while (rs.next()) {
|
||||
bans.add(new Ban(UUID.fromString(rs.getString("UUID"))));
|
||||
}
|
||||
}catch (Exception ignored) {}
|
||||
return bans;
|
||||
}
|
||||
|
||||
//nonStatic
|
||||
public ProxiedPlayer player;
|
||||
public Reason reason;
|
||||
public long time;
|
||||
|
||||
public Ban(UUID uuid) {
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM Ban WHERE UUID = \"" + uuid + "\"");
|
||||
rs.next();
|
||||
player = BungeeCord.getInstance().getPlayer(uuid);
|
||||
reason = getType(rs.getInt("Type"));
|
||||
time = rs.getInt("Time");
|
||||
}catch (Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
|
||||
private Ban(UUID uuid, Reason reason, long time) {
|
||||
this.player = BungeeCord.getInstance().getPlayer(uuid);
|
||||
this.reason = reason;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
UUID uuid = player.getUniqueId();
|
||||
MySQL.insert("DELETE FROM Ban WHERE UUID = \"" + uuid + "\"");
|
||||
MySQL.insert("INSERT INTO Ban (UUID, Type, Time) VALUES (\"" + uuid + "\", " + reason.getTypeID() + ", " + time + ")");
|
||||
MySQL.insert("INSERT INTO BanHistory (UUID, Type) VALUES (\"" + uuid + "\", " + reason.getTypeID() + ")");
|
||||
}
|
||||
|
||||
public ArrayList<Ban> getBanHistory() {
|
||||
UUID uuid = player.getUniqueId();
|
||||
ArrayList<Ban> history = new ArrayList<>();
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM BanHistory WHERE UUID = \"" + uuid + "\"");
|
||||
if (rs == null) return history;
|
||||
while (rs.next()) {
|
||||
history.add(new Ban(uuid, getType(rs.getInt("Type")), 0L));
|
||||
}
|
||||
}catch (Exception e) { e.printStackTrace(); }
|
||||
return history;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package de.craftix.bansystem.utils;
|
||||
|
||||
public class Messages {
|
||||
|
||||
public static final String prefix = "§c§lPrincepDE §8» §r";
|
||||
public static final String syntaxErr = prefix + "§cFalscher Syntax";
|
||||
public static final String types = "§60: §eHacking\n" +
|
||||
"§61: §e...";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package de.craftix.bansystem.utils;
|
||||
|
||||
import de.craftix.bansystem.MySQL;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Mute {
|
||||
|
||||
public static Mute getPlayerMute(UUID uuid) {
|
||||
if (hasMuteAccount(uuid)) return new Mute(uuid);
|
||||
return new Mute(uuid, null, 0);
|
||||
}
|
||||
|
||||
public static void createMute(ProxiedPlayer p, Reason type) {
|
||||
Mute mute = new Mute(p.getUniqueId(), type, type.getTime());
|
||||
mute.save();
|
||||
}
|
||||
|
||||
public static boolean hasMuteAccount(UUID uuid) {
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM Mute WHERE UUID = \"" + uuid + "\"");
|
||||
if (rs == null) return false;
|
||||
if (!rs.next()) return false;
|
||||
return rs.getString("UUID") != null;
|
||||
}catch (Exception ignored) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ArrayList<Mute> getAllMute() {
|
||||
ArrayList<Mute> mutes = new ArrayList<>();
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM Mute");
|
||||
while (rs.next()) {
|
||||
mutes.add(new Mute(UUID.fromString(rs.getString("UUID"))));
|
||||
}
|
||||
}catch (Exception ignored) {}
|
||||
return mutes;
|
||||
}
|
||||
|
||||
//nonStatic
|
||||
public ProxiedPlayer player;
|
||||
public Reason reason;
|
||||
public long time;
|
||||
|
||||
public Mute(UUID uuid) {
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM Mute WHERE UUID = \"" + uuid + "\"");
|
||||
if (rs == null) return;
|
||||
if (!rs.next()) return;
|
||||
player = BungeeCord.getInstance().getPlayer(uuid);
|
||||
reason = Ban.getType(rs.getInt("Type"));
|
||||
time = rs.getInt("Time");
|
||||
}catch (Exception e) { e.printStackTrace(); }
|
||||
}
|
||||
|
||||
private Mute(UUID uuid, Reason reason, long time) {
|
||||
this.player = BungeeCord.getInstance().getPlayer(uuid);
|
||||
this.reason = reason;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
UUID uuid = player.getUniqueId();
|
||||
MySQL.insert("DELETE FROM Mute WHERE UUID = \"" + uuid + "\"");
|
||||
MySQL.insert("INSERT INTO Mute (UUID, Type, Time) VALUES (\"" + uuid + "\", " + reason.getTypeID() + ", " + time + ")");
|
||||
MySQL.insert("INSERT INTO MuteHistory (UUID, Type) VALUES (\"" + uuid + "\", " + reason.getTypeID() + ")");
|
||||
}
|
||||
|
||||
public ArrayList<Mute> getBanHistory() {
|
||||
UUID uuid = player.getUniqueId();
|
||||
ArrayList<Mute> history = new ArrayList<>();
|
||||
try {
|
||||
ResultSet rs = MySQL.getData("SELECT * FROM MuteHistory WHERE UUID = \"" + uuid + "\"");
|
||||
if (rs == null) return history;
|
||||
while (rs.next()) {
|
||||
history.add(new Mute(uuid, Ban.getType(rs.getInt("Type")), 0L));
|
||||
}
|
||||
}catch (Exception e) { e.printStackTrace(); }
|
||||
return history;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package de.craftix.bansystem.utils;
|
||||
|
||||
public enum Reason {
|
||||
|
||||
HACKING(0, 1, "§4Hacking");
|
||||
|
||||
private int typeID;
|
||||
private long time;
|
||||
private String message;
|
||||
|
||||
Reason(int typeID, long time, String message) {
|
||||
this.typeID = typeID;
|
||||
this.time = time;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getTypeID() {
|
||||
return typeID;
|
||||
}
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
3
Plugins/Old/BanSystem-Marc/src/main/resources/bungee.yml
Normal file
3
Plugins/Old/BanSystem-Marc/src/main/resources/bungee.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
name: BanSystem
|
||||
version: ${project.version}
|
||||
main: de.craftix.bansystem.BanSystem
|
||||
Reference in New Issue
Block a user