geforkt von SteamWar/BungeeCore
Implementing check listings
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
c3faa9163f
Commit
de0bd02d18
@ -1,13 +1,36 @@
|
|||||||
package de.steamwar.bungeecore.listeners;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
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.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
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.api.event.ServerSwitchEvent;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class CheckListener extends BasicListener {
|
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
|
@EventHandler
|
||||||
public void onServerSwitch(ServerSwitchEvent e){
|
public void onServerSwitch(ServerSwitchEvent e){
|
||||||
ProxiedPlayer player = e.getPlayer();
|
ProxiedPlayer player = e.getPlayer();
|
||||||
|
@ -48,7 +48,7 @@ public class Schematic {
|
|||||||
|
|
||||||
public static List<Schematic> getAllSchemsOfType(SchematicType schemType){
|
public static List<Schematic> getAllSchemsOfType(SchematicType schemType){
|
||||||
try{
|
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<>();
|
List<Schematic> schematics = new ArrayList<>();
|
||||||
while(schematic.next()){
|
while(schematic.next()){
|
||||||
schematics.add(new Schematic(schematic));
|
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() {
|
public int getSchemID() {
|
||||||
return schemID;
|
return schemID;
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren