Archiviert
1
0

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.sql.SQL;
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.CommandSender;
import net.md_5.bungee.api.ProxyServer;
@ -86,7 +87,10 @@ public class BungeeCore extends Plugin {
new EventStarter();
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

Datei anzeigen

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

Datei anzeigen

@ -41,7 +41,7 @@ public class ChatListener extends BasicListener {
ProxiedPlayer sender = (ProxiedPlayer) e.getSender();
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);
}else if(command[0].equalsIgnoreCase("/bc") || command[0].equalsIgnoreCase("/bauchat") || command[0].equalsIgnoreCase("/local")){
localChat(e, command);

Datei anzeigen

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