Archiviert
1
0

Removing caches from Bauwelt and BauweltMember

Dieser Commit ist enthalten in:
Travis CI 2019-06-13 22:09:30 +02:00
Ursprung be9478ad7a
Commit ac4a2ab78b
5 geänderte Dateien mit 11 neuen und 30 gelöschten Zeilen

3
.gitignore vendored
Datei anzeigen

@ -1,2 +1,3 @@
.idea .idea
target target
dependency-reduced-pom.xml

Datei anzeigen

@ -44,6 +44,14 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>

Datei anzeigen

@ -4,8 +4,6 @@ import de.steamwar.bungeecore.arenasystem.ArenaMode;
import de.steamwar.bungeecore.arenasystem.ArenaSystem; import de.steamwar.bungeecore.arenasystem.ArenaSystem;
import de.steamwar.bungeecore.bausystem.BauSystem; import de.steamwar.bungeecore.bausystem.BauSystem;
import de.steamwar.bungeecore.commands.*; import de.steamwar.bungeecore.commands.*;
import de.steamwar.bungeecore.sql.Bauwelt;
import de.steamwar.bungeecore.sql.BauweltMember;
import de.steamwar.bungeecore.sql.WarkingUser; import de.steamwar.bungeecore.sql.WarkingUser;
import de.steamwar.bungeecore.sql.sql; import de.steamwar.bungeecore.sql.sql;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
@ -125,11 +123,7 @@ public class BungeeCore extends Plugin {
} }
}, 10, 10, TimeUnit.MINUTES); }, 10, 10, TimeUnit.MINUTES);
getProxy().getScheduler().schedule(this, () -> { getProxy().getScheduler().schedule(this, WarkingUser::clearCache, 1, 1, TimeUnit.HOURS);
WarkingUser.clearCache();
Bauwelt.clearCache();
BauweltMember.clearCache();
}, 1, 1, TimeUnit.HOURS);
} }
@Override @Override

Datei anzeigen

@ -3,8 +3,6 @@ package de.steamwar.bungeecore.sql;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
public class Bauwelt { public class Bauwelt {
@ -13,15 +11,12 @@ public class Bauwelt {
private boolean TNTDmg; private boolean TNTDmg;
private boolean FireDmg; private boolean FireDmg;
private static List<Bauwelt> welten = new ArrayList<>();
private Bauwelt(int userID, boolean tntDmg, boolean fireDmg, boolean updateDB){ private Bauwelt(int userID, boolean tntDmg, boolean fireDmg, boolean updateDB){
UserID = userID; UserID = userID;
TNTDmg = tntDmg; TNTDmg = tntDmg;
FireDmg = fireDmg; FireDmg = fireDmg;
if(updateDB) if(updateDB)
updateDB(); updateDB();
welten.add(this);
} }
public Bauwelt(int userID, boolean tntDmg, boolean fireDmg){ public Bauwelt(int userID, boolean tntDmg, boolean fireDmg){
@ -46,9 +41,6 @@ public class Bauwelt {
} }
public static Bauwelt getBauwelt(int userId){ public static Bauwelt getBauwelt(int userId){
for(Bauwelt welt : welten)
if(welt.UserID == userId)
return welt;
ResultSet bauwelt = sql.select("SELECT * FROM Bauwelt WHERE UserID = '" + userId + "'"); ResultSet bauwelt = sql.select("SELECT * FROM Bauwelt WHERE UserID = '" + userId + "'");
try { try {
if(bauwelt == null || !bauwelt.next()){ if(bauwelt == null || !bauwelt.next()){
@ -63,10 +55,6 @@ public class Bauwelt {
return null; return null;
} }
public static void clearCache(){
welten.clear();
}
public int getUserID() { public int getUserID() {
return UserID; return UserID;
} }

Datei anzeigen

@ -13,7 +13,6 @@ public class BauweltMember{
private boolean WorldEdit; private boolean WorldEdit;
private boolean World; private boolean World;
private static final List<BauweltMember> members = new ArrayList<>();
private BauweltMember(int ownerID, int memberID, boolean build, boolean worldEdit, boolean world, boolean updateDB){ private BauweltMember(int ownerID, int memberID, boolean build, boolean worldEdit, boolean world, boolean updateDB){
BauweltID = ownerID; BauweltID = ownerID;
@ -23,7 +22,6 @@ public class BauweltMember{
World = world; World = world;
if(updateDB) if(updateDB)
updateDB(); updateDB();
members.add(this);
} }
public BauweltMember(int ownerID, int memberID, boolean build, boolean worldEdit, boolean world){ public BauweltMember(int ownerID, int memberID, boolean build, boolean worldEdit, boolean world){
@ -36,7 +34,6 @@ public class BauweltMember{
public void remove(){ public void remove(){
sql.update("DELETE FROM BauweltMember WHERE BauweltID = " + BauweltID + " AND MemberID = " + MemberID); sql.update("DELETE FROM BauweltMember WHERE BauweltID = " + BauweltID + " AND MemberID = " + MemberID);
members.remove(this);
} }
private void updateDB(){ private void updateDB(){
@ -53,9 +50,6 @@ public class BauweltMember{
} }
public static BauweltMember getBauMember(int ownerID, int memberID){ public static BauweltMember getBauMember(int ownerID, int memberID){
for(BauweltMember member : members)
if(member.BauweltID == ownerID && member.MemberID == memberID)
return member;
ResultSet member = sql.select("SELECT * FROM BauweltMember WHERE BauweltID = '" + ownerID + "' AND MemberID = '" + memberID + "'"); ResultSet member = sql.select("SELECT * FROM BauweltMember WHERE BauweltID = '" + ownerID + "' AND MemberID = '" + memberID + "'");
try { try {
if(member == null || !member.next()){ if(member == null || !member.next()){
@ -71,10 +65,6 @@ public class BauweltMember{
return null; return null;
} }
public static void clearCache(){
members.clear();
}
public static List<BauweltMember> getMembers(UUID bauweltID){ public static List<BauweltMember> getMembers(UUID bauweltID){
return getMembers(WarkingUser.get(bauweltID).getId()); return getMembers(WarkingUser.get(bauweltID).getId());
} }