Removing Bauwelt and BauweltMember from SpigotCore
Dieser Commit ist enthalten in:
Ursprung
30ea4e5dcf
Commit
0dc558eece
@ -1,23 +1,19 @@
|
|||||||
package de.warking.hunjy;
|
package de.warking.hunjy;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.sun.net.httpserver.BasicAuthenticator;
|
|
||||||
import de.warking.hunjy.MySQL.Bauwelt;
|
|
||||||
import de.warking.hunjy.MySQL.BauweltMember;
|
|
||||||
import de.warking.hunjy.MySQL.WarkingUser;
|
|
||||||
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.CoinSystem;
|
||||||
import de.warking.hunjy.CoinSystem.command.CoinCommand;
|
import de.warking.hunjy.CoinSystem.command.CoinCommand;
|
||||||
import de.warking.hunjy.MySQL.MySQL;
|
import de.warking.hunjy.MySQL.MySQL;
|
||||||
|
import de.warking.hunjy.MySQL.WarkingUser;
|
||||||
|
import de.warking.hunjy.PlayerManager.PlayerManager;
|
||||||
|
import de.warking.hunjy.PlayerManager.events.ChattingEvent;
|
||||||
|
import de.warking.hunjy.PlayerManager.events.PlayerJoin;
|
||||||
import de.warking.hunjy.manager.CacheManager;
|
import de.warking.hunjy.manager.CacheManager;
|
||||||
import de.warking.hunjy.manager.FileManager;
|
import de.warking.hunjy.manager.FileManager;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
public class Core extends JavaPlugin{
|
public class Core extends JavaPlugin{
|
||||||
@ -53,11 +49,7 @@ public class Core extends JavaPlugin{
|
|||||||
Bukkit.getPluginManager().registerEvents(new PlayerJoin(), this);
|
Bukkit.getPluginManager().registerEvents(new PlayerJoin(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new ChattingEvent(), this);
|
Bukkit.getPluginManager().registerEvents(new ChattingEvent(), this);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskTimer(this, () -> {
|
Bukkit.getScheduler().runTaskTimer(this, WarkingUser::clearCache, 72000, 72000);
|
||||||
WarkingUser.clearCache();
|
|
||||||
Bauwelt.clearCache();
|
|
||||||
BauweltMember.clearCache();
|
|
||||||
}, 72000, 72000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Core getInstance() {
|
public static Core getInstance() {
|
||||||
|
@ -1,95 +0,0 @@
|
|||||||
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 Bauwelt {
|
|
||||||
|
|
||||||
private final int UserID;
|
|
||||||
private boolean TNTDmg;
|
|
||||||
private boolean FireDmg;
|
|
||||||
private static final List<Bauwelt> bauweltCache = new ArrayList<>();
|
|
||||||
|
|
||||||
private Bauwelt(int userID, boolean tntDmg, boolean fireDmg, boolean updateDB){
|
|
||||||
UserID = userID;
|
|
||||||
TNTDmg = tntDmg;
|
|
||||||
FireDmg = fireDmg;
|
|
||||||
bauweltCache.add(this);
|
|
||||||
if(updateDB)
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bauwelt(int userID, boolean tntDmg, boolean fireDmg){
|
|
||||||
this(userID, tntDmg, fireDmg, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Bauwelt(UUID userID, boolean tntDmg, boolean fireDmg){
|
|
||||||
this(WarkingUser.get(userID).getId(), tntDmg, fireDmg, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateDB(){
|
|
||||||
sql.update("INSERT INTO Bauwelt" +
|
|
||||||
" (UserID, TNTDmg, FireDmg)" +
|
|
||||||
" VALUES" +
|
|
||||||
" ('" + UserID + "', '" + sql.booleanToInt(TNTDmg) + "', '" + sql.booleanToInt(FireDmg) + "')" +
|
|
||||||
" ON DUPLICATE KEY UPDATE" +
|
|
||||||
" TNTDmg = VALUES(TNTDmg), FireDmg = VALUES(FireDmg)");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Bauwelt getBauwelt(UUID user){
|
|
||||||
return getBauwelt(WarkingUser.get(user).getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Bauwelt getBauwelt(int userId){
|
|
||||||
for(Bauwelt b : bauweltCache)
|
|
||||||
if(b.UserID == userId)
|
|
||||||
return b;
|
|
||||||
ResultSet bauwelt = sql.select("SELECT * FROM Bauwelt WHERE UserID = '" + userId + "'");
|
|
||||||
try {
|
|
||||||
if(bauwelt == null || !bauwelt.next()){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
boolean tntDmg = bauwelt.getBoolean("TNTDmg");
|
|
||||||
boolean fireDmg = bauwelt.getBoolean("FireDmg");
|
|
||||||
return new Bauwelt(userId, tntDmg, fireDmg, false);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUserID() {
|
|
||||||
return UserID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getUUID(){
|
|
||||||
return WarkingUser.get(UserID).getUUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTNTDmg() {
|
|
||||||
return TNTDmg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTNTDmg(boolean TNTDmg) {
|
|
||||||
this.TNTDmg = TNTDmg;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFireDmg() {
|
|
||||||
return FireDmg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFireDmg(boolean fireDmg) {
|
|
||||||
FireDmg = fireDmg;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearCache(){
|
|
||||||
bauweltCache.clear();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,159 +0,0 @@
|
|||||||
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 BauweltMember{
|
|
||||||
private final int BauweltID;
|
|
||||||
private final int MemberID;
|
|
||||||
private boolean Build;
|
|
||||||
private boolean ChangeGM;
|
|
||||||
private boolean Teleport;
|
|
||||||
private boolean WorldEdit;
|
|
||||||
private boolean Testblock;
|
|
||||||
|
|
||||||
private static List<BauweltMember> memberCache = new ArrayList<>();
|
|
||||||
|
|
||||||
private BauweltMember(int bauweltID, int memberID, boolean build, boolean changeGM, boolean teleport, boolean worldEdit, boolean testblock, boolean updateDB){
|
|
||||||
BauweltID = bauweltID;
|
|
||||||
MemberID = memberID;
|
|
||||||
Build = build;
|
|
||||||
ChangeGM = changeGM;
|
|
||||||
Teleport = teleport;
|
|
||||||
WorldEdit = worldEdit;
|
|
||||||
Testblock = testblock;
|
|
||||||
memberCache.add(this);
|
|
||||||
if(updateDB)
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BauweltMember(int bauweltID, int memberID, boolean build, boolean changeGM, boolean teleport, boolean worldEdit, boolean testblock){
|
|
||||||
this(bauweltID, memberID, build, changeGM, teleport, worldEdit, testblock, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BauweltMember(UUID bauweltID, UUID memberID, boolean build, boolean changeGM, boolean teleport, boolean worldEdit, boolean testblock){
|
|
||||||
this(WarkingUser.get(bauweltID).getId(), WarkingUser.get(memberID).getId(), build, changeGM, teleport, worldEdit, testblock, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(){
|
|
||||||
sql.update("DELETE FROM BauweltMember WHERE BauweltID = " + BauweltID + " AND MemberID = " + MemberID);
|
|
||||||
memberCache.remove(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateDB(){
|
|
||||||
sql.update("INSERT INTO BauweltMember" +
|
|
||||||
" (BauweltID, MemberID, Build, ChangeGM, Teleport, WorldEdit, Testblock)" +
|
|
||||||
" VALUES" +
|
|
||||||
" ('" + BauweltID + "', '" + MemberID + "', '" + sql.booleanToInt(Build) + "', '" + sql.booleanToInt(ChangeGM) + "', '" + sql.booleanToInt(Teleport) + "', '" + sql.booleanToInt(WorldEdit) + "', '" + sql.booleanToInt(Testblock) + "')" +
|
|
||||||
" ON DUPLICATE KEY UPDATE" +
|
|
||||||
" Build = VALUES(Build), ChangeGM = VALUES(ChangeGM), Teleport = VALUES(Teleport), WorldEdit = VALUES(WorldEdit), Testblock = VALUES(Testblock)");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BauweltMember getBauMember(UUID bauweltID, UUID memberID){
|
|
||||||
return getBauMember(WarkingUser.get(bauweltID).getId(), WarkingUser.get(memberID).getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BauweltMember getBauMember(int bauweltID, int memberID){
|
|
||||||
ResultSet member = sql.select("SELECT * FROM BauweltMember WHERE BauweltID = '" + bauweltID + "' AND MemberID = '" + memberID + "'");
|
|
||||||
try {
|
|
||||||
if(member == null || !member.next()){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
boolean build = member.getBoolean("Build");
|
|
||||||
boolean changeGM = member.getBoolean("ChangeGM");
|
|
||||||
boolean teleport = member.getBoolean("Teleport");
|
|
||||||
boolean worldEdit = member.getBoolean("WorldEdit");
|
|
||||||
boolean testblock = member.getBoolean("Testblock");
|
|
||||||
return new BauweltMember(bauweltID, memberID, build, changeGM, teleport, worldEdit, testblock, false);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BauweltMember> getMembers(UUID bauweltID){
|
|
||||||
return getMembers(WarkingUser.get(bauweltID).getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<BauweltMember> getMembers(int bauweltID){
|
|
||||||
try{
|
|
||||||
ResultSet memberlist = sql.select("SELECT * FROM BauweltMember WHERE BauweltID = '" + bauweltID + "'");
|
|
||||||
List<BauweltMember> members = new ArrayList<>();
|
|
||||||
while(memberlist.next()){
|
|
||||||
int memberID = memberlist.getInt("MemberID");
|
|
||||||
boolean build = memberlist.getBoolean("Build");
|
|
||||||
boolean changeGM = memberlist.getBoolean("ChangeGM");
|
|
||||||
boolean teleport = memberlist.getBoolean("Teleport");
|
|
||||||
boolean worldEdit = memberlist.getBoolean("WorldEdit");
|
|
||||||
boolean testblock = memberlist.getBoolean("Testblock");
|
|
||||||
members.add(new BauweltMember(bauweltID, memberID, build, changeGM, teleport, worldEdit, testblock, false));
|
|
||||||
}
|
|
||||||
return members;
|
|
||||||
}catch(SQLException e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBauweltID() {
|
|
||||||
return BauweltID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMemberID() {
|
|
||||||
return MemberID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isBuild() {
|
|
||||||
return Build;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBuild(boolean build) {
|
|
||||||
Build = build;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isChangeGM() {
|
|
||||||
return ChangeGM;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChangeGM(boolean changeGM) {
|
|
||||||
ChangeGM = changeGM;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTeleport() {
|
|
||||||
return Teleport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTeleport(boolean teleport) {
|
|
||||||
Teleport = teleport;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWorldEdit() {
|
|
||||||
return WorldEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWorldEdit(boolean worldEdit) {
|
|
||||||
WorldEdit = worldEdit;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTestblock() {
|
|
||||||
return Testblock;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTestblock(boolean testblock) {
|
|
||||||
Testblock = testblock;
|
|
||||||
updateDB();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearCache(){
|
|
||||||
memberCache.clear();
|
|
||||||
}
|
|
||||||
}
|
|
In neuem Issue referenzieren
Einen Benutzer sperren