Adding sessions
Dieser Commit ist enthalten in:
Ursprung
53d44cb628
Commit
439ef96bac
@ -5,14 +5,6 @@ import net.md_5.bungee.config.Configuration;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ArenaMode {
|
public class ArenaMode {
|
||||||
/*AirShip,
|
|
||||||
WarShip,
|
|
||||||
WarGear,
|
|
||||||
MiniWarGear,
|
|
||||||
WarGear7,
|
|
||||||
GearUp,
|
|
||||||
EisZeit,
|
|
||||||
UNKNOWN;*/
|
|
||||||
|
|
||||||
private static Map<String, ArenaMode> byChat = new HashMap<>();
|
private static Map<String, ArenaMode> byChat = new HashMap<>();
|
||||||
private static Map<String, ArenaMode> byInternal = new HashMap<>();
|
private static Map<String, ArenaMode> byInternal = new HashMap<>();
|
||||||
|
@ -11,7 +11,8 @@ class Broadcaster {
|
|||||||
|
|
||||||
Broadcaster(){
|
Broadcaster(){
|
||||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||||
BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + broadCastMsgs[lastBroadCast]);
|
if(!ProxyServer.getInstance().getPlayers().isEmpty())
|
||||||
|
BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + broadCastMsgs[lastBroadCast]);
|
||||||
lastBroadCast++;
|
lastBroadCast++;
|
||||||
if(lastBroadCast == broadCastMsgs.length){
|
if(lastBroadCast == broadCastMsgs.length){
|
||||||
lastBroadCast = 0;
|
lastBroadCast = 0;
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.commands.*;
|
import de.steamwar.bungeecore.commands.*;
|
||||||
import de.steamwar.bungeecore.listeners.BanListener;
|
import de.steamwar.bungeecore.listeners.*;
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
|
||||||
import de.steamwar.bungeecore.listeners.PollSystem;
|
|
||||||
import de.steamwar.bungeecore.listeners.mods.Forge;
|
import de.steamwar.bungeecore.listeners.mods.Forge;
|
||||||
import de.steamwar.bungeecore.listeners.mods.LabyMod;
|
import de.steamwar.bungeecore.listeners.mods.LabyMod;
|
||||||
import de.steamwar.bungeecore.sql.SQL;
|
import de.steamwar.bungeecore.sql.SQL;
|
||||||
@ -86,6 +83,7 @@ public class BungeeCore extends Plugin {
|
|||||||
|
|
||||||
new EventStarter();
|
new EventStarter();
|
||||||
new Broadcaster();
|
new Broadcaster();
|
||||||
|
new SessionManager();
|
||||||
|
|
||||||
getProxy().getScheduler().schedule(this, () -> {
|
getProxy().getScheduler().schedule(this, () -> {
|
||||||
SteamwarUser.clearCache();
|
SteamwarUser.clearCache();
|
||||||
|
28
src/de/steamwar/bungeecore/listeners/SessionManager.java
Normale Datei
28
src/de/steamwar/bungeecore/listeners/SessionManager.java
Normale Datei
@ -0,0 +1,28 @@
|
|||||||
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.sql.Session;
|
||||||
|
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.event.EventHandler;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SessionManager extends BasicListener {
|
||||||
|
|
||||||
|
private Map<ProxiedPlayer, Session> sessions = new HashMap<>();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPostLogin(PostLoginEvent event){
|
||||||
|
sessions.put(event.getPlayer(), new Session(SteamwarUser.get(event.getPlayer()).getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDisconnect(PlayerDisconnectEvent e){
|
||||||
|
Session session = sessions.remove(e.getPlayer());
|
||||||
|
if(session != null)
|
||||||
|
session.stopSession();
|
||||||
|
}
|
||||||
|
}
|
19
src/de/steamwar/bungeecore/sql/Session.java
Normale Datei
19
src/de/steamwar/bungeecore/sql/Session.java
Normale Datei
@ -0,0 +1,19 @@
|
|||||||
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
|
public class Session {
|
||||||
|
|
||||||
|
private final int userID;
|
||||||
|
private Timestamp startTime;
|
||||||
|
|
||||||
|
public Session(int userID){
|
||||||
|
this.userID = userID;
|
||||||
|
startTime = Timestamp.from(Instant.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopSession(){
|
||||||
|
SQL.update("INSERT INTO Session (UserID, StartTime, EndTime) VALUES ("+ userID + ", '" + startTime.toString() + "', NOW())");
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren