Archiviert
1
0

Implementing check listings

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2020-05-01 12:32:13 +02:00
Ursprung c3faa9163f
Commit de0bd02d18
2 geänderte Dateien mit 37 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -1,13 +1,36 @@
package de.steamwar.bungeecore.listeners;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.commands.CheckCommand;
import de.steamwar.bungeecore.sql.Schematic;
import de.steamwar.bungeecore.sql.SchematicType;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.event.EventHandler;
import java.util.LinkedList;
import java.util.List;
public class CheckListener extends BasicListener {
@EventHandler
public void onPlayerJoin(PostLoginEvent e){
ProxiedPlayer player = e.getPlayer();
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
List<Schematic> uncheckedSchematics = new LinkedList<>();
for(SchematicType type : SchematicType.values()){
if(type.check())
uncheckedSchematics.addAll(Schematic.getSchemsOfType(user.getId(), type));
}
if(!uncheckedSchematics.isEmpty())
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Du hast noch §e" + uncheckedSchematics.size() + " §7ungeprüfte Schematic§8(§7s§8)!");
}
@EventHandler
public void onServerSwitch(ServerSwitchEvent e){
ProxiedPlayer player = e.getPlayer();

Datei anzeigen

@ -48,7 +48,7 @@ public class Schematic {
public static List<Schematic> getAllSchemsOfType(SchematicType schemType){
try{
ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, Item, SchemType, SchemFormat FROM Schematic WHERE SchemType = ?", schemType.toDB());
ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType FROM Schematic WHERE SchemType = ?", schemType.toDB());
List<Schematic> schematics = new ArrayList<>();
while(schematic.next()){
schematics.add(new Schematic(schematic));
@ -59,6 +59,19 @@ public class Schematic {
}
}
public static List<Schematic> getSchemsOfType(int userId, SchematicType schemType){
try{
ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType FROM Schematic WHERE SchemType = ? AND SchemOwner = ?", schemType.toDB(), userId);
List<Schematic> schematics = new ArrayList<>();
while(schematic.next()){
schematics.add(new Schematic(schematic));
}
return schematics;
}catch(SQLException e){
throw new SecurityException("Failed loading schems of type", e);
}
}
public int getSchemID() {
return schemID;
}