SteamWar/BungeeCore
Archiviert
13
2

Public and unknown Team + Challenge tab completion

Dieser Commit ist enthalten in:
Lixfel 2019-11-16 08:42:41 +01:00
Ursprung 3044544724
Commit 78ea4ed6e4
4 geänderte Dateien mit 28 neuen und 32 gelöschten Zeilen

Datei anzeigen

@ -9,6 +9,7 @@ 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;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Team;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
@ -86,7 +87,10 @@ public class BungeeCore extends Plugin {
new EventStarter(); new EventStarter();
new Broadcaster(); new Broadcaster();
getProxy().getScheduler().schedule(this, SteamwarUser::clearCache, 1, 1, TimeUnit.HOURS); getProxy().getScheduler().schedule(this, () -> {
SteamwarUser.clearCache();
Team.clearCache();
}, 1, 1, TimeUnit.HOURS);
} }
@Override @Override

Datei anzeigen

@ -88,17 +88,8 @@ public class ChallengeCommand extends BasicCommand {
@Override @Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) { public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
List<String> gamemodes = new ArrayList<>(); if(args.length == 2)
if(args.length == 2){ return ArenaMode.getAllChatNames();
gamemodes.add("AirShip"); return new ArrayList<>();
gamemodes.add("AS");
gamemodes.add("WarShip");
gamemodes.add("WS");
gamemodes.add("WarGear");
gamemodes.add("WG");
gamemodes.add("MiniWarGear");
gamemodes.add("MWG");
}
return gamemodes;
} }
} }

Datei anzeigen

@ -41,7 +41,7 @@ public class ChatListener extends BasicListener {
ProxiedPlayer sender = (ProxiedPlayer) e.getSender(); ProxiedPlayer sender = (ProxiedPlayer) e.getSender();
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cUnbekannter Befehl."); BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cUnbekannter Befehl.");
} }
}else if((command[0].equalsIgnoreCase("/bau") || command[0].equalsIgnoreCase("/b")) && e.getSender() instanceof ProxiedPlayer){ }else if((command[0].equalsIgnoreCase("/bau") || command[0].equalsIgnoreCase("/b") || command[0].equalsIgnoreCase("/gs")) && e.getSender() instanceof ProxiedPlayer){
BauCommand.onBau(e, command); BauCommand.onBau(e, command);
}else if(command[0].equalsIgnoreCase("/bc") || command[0].equalsIgnoreCase("/bauchat") || command[0].equalsIgnoreCase("/local")){ }else if(command[0].equalsIgnoreCase("/bc") || command[0].equalsIgnoreCase("/bauchat") || command[0].equalsIgnoreCase("/local")){
localChat(e, command); localChat(e, command);

Datei anzeigen

@ -16,13 +16,19 @@ public class Team {
private String teamName; private String teamName;
private int teamLeader; private int teamLeader;
private static final List<Team> teamCache = new ArrayList<>(); private static final List<Team> teamCache = new LinkedList<>();
private static final Team pub = new Team(0, "PUB", "Öffentlich", 0);
private Team(int id, String kuerzel, String name, int leader){ private Team(int id, String kuerzel, String name, int leader){
teamId = id; teamId = id;
teamKuerzel = kuerzel; teamKuerzel = kuerzel;
teamName = name; teamName = name;
teamLeader = leader; teamLeader = leader;
teamCache.add(this);
}
private Team(ResultSet rs) throws SQLException {
this(rs.getInt("TeamID"), rs.getString("TeamKuerzel"), rs.getString("TeamName"), rs.getInt("TeamLeader"));
} }
public static void create(String kuerzel, String name, int leader){ public static void create(String kuerzel, String name, int leader){
@ -33,6 +39,10 @@ public class Team {
} }
public static Team get(int id){ public static Team get(int id){
if(id == -1)
return new Team(-1, "?", "?", 0);
if(id == 0)
return pub;
for(Team team : teamCache) for(Team team : teamCache)
if(team.teamId == id) if(team.teamId == id)
return team; return team;
@ -50,20 +60,18 @@ public class Team {
} }
public static List<Team> getAll(){ public static List<Team> getAll(){
teamCache.clear(); clearCache();
List<Team> allTeams = new LinkedList<>();
try{ try{
ResultSet rs = select("SELECT * FROM Team"); ResultSet rs = select("SELECT * FROM Team WHERE TeamID > 0");
if(rs == null) if(rs == null)
return allTeams; return teamCache;
while(!rs.isLast()){ while(rs.next())
allTeams.add(load(rs)); new Team(rs);
}
} catch (SQLException e) { } catch (SQLException e) {
BungeeCore.log("Could not get all Teams", e); BungeeCore.log("Could not get all Teams", e);
} }
return allTeams; return teamCache;
} }
public static void clearCache(){ public static void clearCache(){
@ -72,16 +80,9 @@ public class Team {
private static Team load(ResultSet dbteam){ private static Team load(ResultSet dbteam){
try { try {
if(!dbteam.next()){ if(!dbteam.next())
return null; return null;
} return new Team(dbteam);
int id = dbteam.getInt("TeamID");
String kuerzel = dbteam.getString("TeamKuerzel");
String name = dbteam.getString("TeamName");
int leader = dbteam.getInt("TeamLeader");
Team team = new Team(id, kuerzel, name, leader);
teamCache.add(team);
return team;
} catch (SQLException e) { } catch (SQLException e) {
BungeeCore.log("Could not load Team", e); BungeeCore.log("Could not load Team", e);
return null; return null;