52 lines
1.5 KiB
Java
52 lines
1.5 KiB
Java
package eu.univento.core.api.player;
|
|
|
|
import java.sql.ResultSet;
|
|
import java.sql.SQLException;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import eu.univento.core.Core;
|
|
import eu.univento.core.api.MySQL;
|
|
|
|
/**
|
|
* querys database for muted players
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
public class MuteSystem {
|
|
|
|
|
|
/**
|
|
* checks if player is muted
|
|
* @param p player
|
|
* @return true /false
|
|
* @throws SQLException SQL server not available or throwing error
|
|
* @throws ClassNotFoundException class couldn't be found
|
|
*/
|
|
public static boolean isMuted(Player p) throws SQLException, ClassNotFoundException {
|
|
MySQL sql = Core.returnSQL();
|
|
sql.openConnection();
|
|
String uuid = p.getUniqueId().toString();
|
|
ResultSet rs = sql.getConnection().createStatement().executeQuery("SELECT mute FROM PlayerData WHERE player_uuid='" + uuid + "';");
|
|
if (rs.next()) {
|
|
return rs.getInt("mute") == 1;
|
|
}
|
|
sql.closeConnection();
|
|
return false;
|
|
}
|
|
|
|
|
|
/**
|
|
* sets / unsets mute
|
|
* @param p player
|
|
* @param mute boolean
|
|
* @throws SQLException SQL server not available or throwing error
|
|
* @throws ClassNotFoundException class couldn't be found
|
|
*/
|
|
public static void setUser(Player p, boolean mute) throws SQLException, ClassNotFoundException {
|
|
MySQL sql = Core.returnSQL();
|
|
sql.openConnection();
|
|
String uuid = p.getUniqueId().toString();
|
|
sql.getConnection().createStatement().executeUpdate("UPDATE PlayerData SET mute = " + mute + " WHERE player_uuid='" + uuid + "';");
|
|
sql.closeConnection();
|
|
}
|
|
} |