geforkt von SteamWar/BungeeCore
Merge pull request 'Move first storage to persistency' (#107) from moveStorageToPersistency into master
Reviewed-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Commit
efa6398248
@ -28,14 +28,14 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|||||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static de.steamwar.bungeecore.Storage.eventServer;
|
||||||
|
|
||||||
public class EventStarter implements Runnable {
|
public class EventStarter implements Runnable {
|
||||||
|
|
||||||
private static final Map<Team, Subserver> eventServer = new HashMap<>();
|
|
||||||
private static ScheduledTask task = null;
|
private static ScheduledTask task = null;
|
||||||
|
|
||||||
EventStarter(){
|
EventStarter(){
|
||||||
@ -47,7 +47,7 @@ public class EventStarter implements Runnable {
|
|||||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this, 1, 10, TimeUnit.SECONDS);
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this, 1, 10, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Team, Subserver> getEventServer() {
|
public static Map<Integer, Subserver> getEventServer() {
|
||||||
return eventServer;
|
return eventServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +67,8 @@ public class EventStarter implements Runnable {
|
|||||||
if(leiter != null)
|
if(leiter != null)
|
||||||
subserver.sendPlayer(leiter);
|
subserver.sendPlayer(leiter);
|
||||||
|
|
||||||
eventServer.put(blue, subserver);
|
eventServer.put(blue.getTeamId(), subserver);
|
||||||
eventServer.put(red, subserver);
|
eventServer.put(red.getTeamId(), subserver);
|
||||||
BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + "§7Hier §eklicken §7für den Kampf §e" + blue.getTeamName() + " §8vs §e" + red.getTeamName(),
|
BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + "§7Hier §eklicken §7für den Kampf §e" + blue.getTeamName() + " §8vs §e" + red.getTeamName(),
|
||||||
"§eEvent beitreten",
|
"§eEvent beitreten",
|
||||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/event " + blue.getTeamKuerzel()));
|
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/event " + blue.getTeamKuerzel()));
|
||||||
|
@ -28,9 +28,9 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ChallengeCommand extends BasicCommand {
|
import static de.steamwar.bungeecore.Storage.challenges;
|
||||||
|
|
||||||
private static final Map<ProxiedPlayer, List<ProxiedPlayer>> challenges = new HashMap<>();
|
public class ChallengeCommand extends BasicCommand {
|
||||||
|
|
||||||
public ChallengeCommand() {
|
public ChallengeCommand() {
|
||||||
super("challenge", "");
|
super("challenge", "");
|
||||||
|
@ -68,7 +68,7 @@ public class EventCommand extends BasicCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Subserver eventArena = EventStarter.getEventServer().get(team);
|
Subserver eventArena = EventStarter.getEventServer().get(team.getTeamId());
|
||||||
if(eventArena == null || !Subserver.getServerList().contains(eventArena)){
|
if(eventArena == null || !Subserver.getServerList().contains(eventArena)){
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDas Team kämpft derzeit nicht");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDas Team kämpft derzeit nicht");
|
||||||
return;
|
return;
|
||||||
|
@ -27,12 +27,11 @@ import net.md_5.bungee.api.ProxyServer;
|
|||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
|
import static de.steamwar.bungeecore.Storage.lastChats;
|
||||||
|
|
||||||
public class MsgCommand extends BasicCommand {
|
public class MsgCommand extends BasicCommand {
|
||||||
|
|
||||||
static final HashMap<String, ProxiedPlayer> lastChats = new HashMap<>();
|
|
||||||
|
|
||||||
public MsgCommand() {
|
public MsgCommand() {
|
||||||
super("msg", "", "w", "tell");
|
super("msg", "", "w", "tell");
|
||||||
}
|
}
|
||||||
@ -78,8 +77,8 @@ public class MsgCommand extends BasicCommand {
|
|||||||
BungeeCore.send(target, msg);
|
BungeeCore.send(target, msg);
|
||||||
BungeeCore.log(msg);
|
BungeeCore.log(msg);
|
||||||
|
|
||||||
lastChats.put(player.getName().toLowerCase(), target);
|
lastChats.put(player, target);
|
||||||
lastChats.put(target.getName().toLowerCase(), player);
|
lastChats.put(target, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,4 +89,8 @@ public class MsgCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void remove(ProxiedPlayer player){
|
||||||
|
lastChats.remove(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ import de.steamwar.bungeecore.sql.SteamwarUser;
|
|||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import static de.steamwar.bungeecore.Storage.lastChats;
|
||||||
|
|
||||||
public class RCommand extends BasicCommand {
|
public class RCommand extends BasicCommand {
|
||||||
|
|
||||||
public RCommand() {
|
public RCommand() {
|
||||||
@ -46,12 +48,13 @@ public class RCommand extends BasicCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxiedPlayer target = MsgCommand.lastChats.get(player.getName().toLowerCase());
|
ProxiedPlayer target = lastChats.get(player);
|
||||||
if(target == null){
|
if(target == null){
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDu hast bisher mit niemandem geschrieben!");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDu hast bisher mit niemandem geschrieben!");
|
||||||
return;
|
return;
|
||||||
}else if(!target.isConnected()){
|
}else if(!target.isConnected()){
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler ist derzeit nicht online!");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler ist derzeit nicht online!");
|
||||||
|
lastChats.remove(player);
|
||||||
return;
|
return;
|
||||||
}else if (IgnoreSystem.isIgnored(target, player)) {
|
}else if (IgnoreSystem.isIgnored(target, player)) {
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler hat dich geblockt!");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler hat dich geblockt!");
|
||||||
@ -71,7 +74,7 @@ public class RCommand extends BasicCommand {
|
|||||||
BungeeCore.send(target, msg);
|
BungeeCore.send(target, msg);
|
||||||
BungeeCore.log(msg);
|
BungeeCore.log(msg);
|
||||||
|
|
||||||
MsgCommand.lastChats.put(target.getName().toLowerCase(), player);
|
lastChats.put(target, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,14 +36,14 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static de.steamwar.bungeecore.Storage.teamInvitations;
|
||||||
|
|
||||||
public class TeamCommand extends BasicCommand {
|
public class TeamCommand extends BasicCommand {
|
||||||
|
|
||||||
public TeamCommand() {
|
public TeamCommand() {
|
||||||
super("team", "");
|
super("team", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<SteamwarUser, List<Team>> invitations = new HashMap<>();
|
|
||||||
|
|
||||||
private void help(CommandSender sender){
|
private void help(CommandSender sender){
|
||||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§7Mit §e/team §7verwaltest du dein Team");
|
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§7Mit §e/team §7verwaltest du dein Team");
|
||||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§eteam list §8- §7Liste alle Teams auf");
|
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§eteam list §8- §7Liste alle Teams auf");
|
||||||
@ -152,13 +152,13 @@ public class TeamCommand extends BasicCommand {
|
|||||||
if(notDuringEvent(player))
|
if(notDuringEvent(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!invitations.containsKey(user)){
|
if(!teamInvitations.containsKey(user.getId())){
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Du hast keine Einladungen erhalten.");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Du hast keine Einladungen erhalten.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Team> invs = invitations.get(user);
|
List<Integer> invs = teamInvitations.get(user.getId());
|
||||||
Team t = null;
|
Integer t = null;
|
||||||
|
|
||||||
if(invs.size() == 1){
|
if(invs.size() == 1){
|
||||||
t = invs.get(0);
|
t = invs.get(0);
|
||||||
@ -166,15 +166,17 @@ public class TeamCommand extends BasicCommand {
|
|||||||
if(args.length != 2){
|
if(args.length != 2){
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§8/§eteam join §8[§eTeam§8]");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§8/§eteam join §8[§eTeam§8]");
|
||||||
StringBuilder sb = new StringBuilder().append("§7Du wurdest von diesen Teams eingeladen§8: §e");
|
StringBuilder sb = new StringBuilder().append("§7Du wurdest von diesen Teams eingeladen§8: §e");
|
||||||
for(Team inv : invs){
|
for(int inv : invs){
|
||||||
sb.append(inv.getTeamName()).append(" ");
|
Team team = Team.get(inv);
|
||||||
|
sb.append(team.getTeamName()).append(" ");
|
||||||
}
|
}
|
||||||
BungeeCore.send(player, sb.toString());
|
BungeeCore.send(player, sb.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Team inv : invs){
|
for(int inv : invs){
|
||||||
if(inv.getTeamName().equals(args[1])){
|
Team team = Team.get(inv);
|
||||||
|
if(team.getTeamName().equals(args[1])){
|
||||||
t = inv;
|
t = inv;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -186,9 +188,9 @@ public class TeamCommand extends BasicCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
user.setTeam(t.getTeamId());
|
user.setTeam(t);
|
||||||
invitations.remove(user);
|
teamInvitations.remove(user.getId());
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Du bist dem Team §e" + t.getTeamName() + " §7beigetreten!");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Du bist dem Team §e" + Team.get(t).getTeamName() + " §7beigetreten!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void leave(ProxiedPlayer player, SteamwarUser user, Team team){
|
private void leave(ProxiedPlayer player, SteamwarUser user, Team team){
|
||||||
@ -231,15 +233,15 @@ public class TeamCommand extends BasicCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!invitations.containsKey(target))
|
if(!teamInvitations.containsKey(target.getId()))
|
||||||
invitations.put(target, new LinkedList<>());
|
teamInvitations.put(target.getId(), new LinkedList<>());
|
||||||
|
|
||||||
if(invitations.get(target).contains(team)){
|
if(teamInvitations.get(target.getId()).contains(team.getTeamId())){
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDu hast diesen Spieler bereits eingeladen");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDu hast diesen Spieler bereits eingeladen");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
invitations.get(target).add(team);
|
teamInvitations.get(target.getId()).add(team.getTeamId());
|
||||||
|
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Du hast §e" + args[1] + " §7in das Team eingeladen!");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Du hast §e" + args[1] + " §7in das Team eingeladen!");
|
||||||
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid());
|
ProxiedPlayer p = ProxyServer.getInstance().getPlayer(target.getUuid());
|
||||||
@ -262,11 +264,11 @@ public class TeamCommand extends BasicCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(invitations.containsKey(target)){
|
if(teamInvitations.containsKey(target.getId())){
|
||||||
if(invitations.get(target).remove(team)){
|
if(teamInvitations.get(target.getId()).remove((Integer) team.getTeamId())){
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Die Einladung wurde zurückgezogen");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Die Einladung wurde zurückgezogen");
|
||||||
if(invitations.get(target).isEmpty())
|
if(teamInvitations.get(target.getId()).isEmpty())
|
||||||
invitations.remove(target);
|
teamInvitations.remove(target.getId());
|
||||||
}else{
|
}else{
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler hat keine Einladung erhalten");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler hat keine Einladung erhalten");
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class TpCommand extends BasicCommand {
|
|||||||
if(server == null){
|
if(server == null){
|
||||||
Team team = Team.get(args[0]);
|
Team team = Team.get(args[0]);
|
||||||
if(team != null){
|
if(team != null){
|
||||||
Subserver eventArena = EventStarter.getEventServer().get(team);
|
Subserver eventArena = EventStarter.getEventServer().get(team.getTeamId());
|
||||||
if(eventArena != null && Subserver.getServerList().contains(eventArena))
|
if(eventArena != null && Subserver.getServerList().contains(eventArena))
|
||||||
server = eventArena.getServer();
|
server = eventArena.getServer();
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import de.steamwar.bungeecore.BungeeCore;
|
|||||||
import de.steamwar.bungeecore.Servertype;
|
import de.steamwar.bungeecore.Servertype;
|
||||||
import de.steamwar.bungeecore.Subserver;
|
import de.steamwar.bungeecore.Subserver;
|
||||||
import de.steamwar.bungeecore.commands.ChallengeCommand;
|
import de.steamwar.bungeecore.commands.ChallengeCommand;
|
||||||
|
import de.steamwar.bungeecore.commands.MsgCommand;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.AbstractReconnectHandler;
|
import net.md_5.bungee.api.AbstractReconnectHandler;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -153,6 +154,7 @@ public class ConnectionListener extends BasicListener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDisconnect(PlayerDisconnectEvent e){
|
public void onDisconnect(PlayerDisconnectEvent e){
|
||||||
ChallengeCommand.remove(e.getPlayer());
|
ChallengeCommand.remove(e.getPlayer());
|
||||||
|
MsgCommand.remove(e.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -21,27 +21,26 @@ package de.steamwar.bungeecore.listeners;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.sql.Session;
|
import de.steamwar.bungeecore.sql.Session;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
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.PlayerDisconnectEvent;
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.sql.Timestamp;
|
||||||
import java.util.Map;
|
import java.time.Instant;
|
||||||
|
|
||||||
|
import static de.steamwar.bungeecore.Storage.sessions;
|
||||||
|
|
||||||
public class SessionManager extends BasicListener {
|
public class SessionManager extends BasicListener {
|
||||||
|
|
||||||
private Map<ProxiedPlayer, Session> sessions = new HashMap<>();
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPostLogin(PostLoginEvent event){
|
public void onPostLogin(PostLoginEvent event){
|
||||||
sessions.put(event.getPlayer(), new Session(SteamwarUser.get(event.getPlayer()).getId()));
|
sessions.put(event.getPlayer(), Timestamp.from(Instant.now()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDisconnect(PlayerDisconnectEvent e){
|
public void onDisconnect(PlayerDisconnectEvent e){
|
||||||
Session session = sessions.remove(e.getPlayer());
|
Timestamp timestamp = sessions.remove(e.getPlayer());
|
||||||
if(session != null)
|
if(timestamp != null)
|
||||||
session.stopSession();
|
Session.insertSession(SteamwarUser.get(e.getPlayer()).getId(), timestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,19 +20,11 @@
|
|||||||
package de.steamwar.bungeecore.sql;
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
public class Session {
|
public class Session {
|
||||||
|
private Session(){}
|
||||||
|
|
||||||
private final int userID;
|
public static void insertSession(int userID, Timestamp startTime){
|
||||||
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 (?, ?, NOW())", userID, startTime);
|
SQL.update("INSERT INTO Session (UserID, StartTime, EndTime) VALUES (?, ?, NOW())", userID, startTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren