SteamWar/FightSystem
Archiviert
13
1

Schematic now nullable #185

Manuell gemergt
Lixfel hat 1 Commits von fix_statistics_issue nach master 2020-09-06 20:06:17 +02:00 zusammengeführt
3 geänderte Dateien mit 45 neuen und 18 gelöschten Zeilen
Nur Änderungen aus Commit e4cd7755b2 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SchematicType; import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup; import de.steamwar.sql.UserGroup;
@ -59,7 +60,7 @@ public class LockschemCommand implements CommandExecutor {
player.sendMessage(FightSystem.PREFIX + "§cDieses Team existiert nicht!"); player.sendMessage(FightSystem.PREFIX + "§cDieses Team existiert nicht!");
return false; return false;
} }
fightTeam.getSchematic().setSchemType(SchematicType.Normal); Schematic.getSchemFromDB(fightTeam.getSchematic()).setSchemType(SchematicType.Normal);
player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + " §cgesperrt!"); player.sendMessage(FightSystem.PREFIX + "Schematic von " + fightTeam.getColoredName() + " §cgesperrt!");
return false; return false;
} }

Datei anzeigen

@ -61,7 +61,7 @@ public class FightTeam implements IFightTeam{
private final String name; private final String name;
private final String prefix; private final String prefix;
private final ChatColor color; private final ChatColor color;
private Schematic schematic; private int schematic = 0;
private final Team team; private final Team team;
private final boolean blue; private final boolean blue;
@ -257,31 +257,40 @@ public class FightTeam implements IFightTeam{
public void pasteSchematic(){ public void pasteSchematic(){
FreezeWorld freezer = new FreezeWorld(); FreezeWorld freezer = new FreezeWorld();
DyeColor c = ColorConverter.chat2dye(color); DyeColor c = ColorConverter.chat2dye(color);
Schematic schem;
try{
schem = Schematic.getSchemFromDB(this.schematic);
}catch(SecurityException e){
pasteDummy();
return;
}
EditSession e; EditSession e;
try { try {
switch(Core.getVersion()){ switch(Core.getVersion()){
case 15: case 15:
e = FightTeam_15.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); e = FightTeam_15.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
FightTeam_15.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); FightTeam_15.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break; break;
case 14: case 14:
e = FightTeam_14.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); e = FightTeam_14.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break; break;
case 10: case 10:
e = FightTeam_10.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); e = FightTeam_10.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
FightTeam_10.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); FightTeam_10.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break; break;
case 9: case 9:
e = FightTeam_9.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); e = FightTeam_9.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
FightTeam_9.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); FightTeam_9.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break; break;
case 8: case 8:
e = FightTeam_8.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); e = FightTeam_8.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break; break;
default: default:
e = FightTeam_12.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); e = FightTeam_12.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate);
FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
} }
} catch (Schematic.WrongVersionException ex) { } catch (Schematic.WrongVersionException ex) {
@ -301,7 +310,7 @@ public class FightTeam implements IFightTeam{
if(publics.isEmpty()) if(publics.isEmpty())
return; return;
schematic = publics.get(new Random().nextInt(publics.size())); schematic = publics.get(new Random().nextInt(publics.size())).getSchemID();
pasteSchematic(); pasteSchematic();
if(!Config.test() && leader != null) if(!Config.test() && leader != null)
@ -309,7 +318,7 @@ public class FightTeam implements IFightTeam{
} }
public void setSchematic(Schematic schematic){ public void setSchematic(Schematic schematic){
this.schematic = schematic; this.schematic = schematic.getSchemID();
broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!"); broadcast(FightSystem.PREFIX + "§7Das §e" + Config.GameName + " " + schematic.getSchemName() + " §7wird für den Kampf verwendet!");
if(!Config.test()) if(!Config.test())
@ -323,13 +332,13 @@ public class FightTeam implements IFightTeam{
} }
public boolean hasSchematic(){ public boolean hasSchematic(){
return schematic != null; return schematic != 0;
} }
public void setReady(boolean ready) { public void setReady(boolean ready) {
Player l = leader.getPlayer(); Player l = leader.getPlayer();
if(schematic == null){ if(schematic == 0){
l.sendMessage(FightSystem.PREFIX + "§cZuerst muss eine Schematic gewählt sein!"); l.sendMessage(FightSystem.PREFIX + "§cZuerst muss eine Schematic gewählt sein!");
return; return;
} }
@ -362,7 +371,7 @@ public class FightTeam implements IFightTeam{
return prefix; return prefix;
} }
public Schematic getSchematic() { public int getSchematic() {
return schematic; return schematic;
} }

Datei anzeigen

@ -25,11 +25,13 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.sql.Elo; import de.steamwar.sql.Elo;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.Instant; import java.time.Instant;
import java.util.logging.Level;
import static de.steamwar.sql.Fight.create; import static de.steamwar.sql.Fight.create;
@ -58,14 +60,29 @@ public class FightStatistics {
}else{ }else{
blueResult = 0.5; blueResult = 0.5;
} }
if(Fight.getBlueTeam().getSchematic() != null && Fight.getRedTeam().getSchematic() != null){
int fightId = create(gameMode, Bukkit.getWorlds().get(0).getName(), starttime, Config.TimeoutTime - FightSystem.getFightTime(),
blueLeader.getId(), redLeader.getId(), Fight.getBlueTeam().getSchematic().getSchemID(), Fight.getRedTeam().getSchematic().getSchemID(), win, windescription);
for(FightPlayer fp : Fight.getBlueTeam().getPlayers()) Integer blueSchem, redSchem;
try{
blueSchem = Schematic.getSchemFromDB(Fight.getBlueTeam().getSchematic()).getSchemID();
}catch(SecurityException e){
blueSchem = null;
}
try{
redSchem = Schematic.getSchemFromDB(Fight.getRedTeam().getSchematic()).getSchemID();
}catch(SecurityException e){
redSchem = null;
}
try {
int fightId = create(gameMode, Bukkit.getWorlds().get(0).getName(), starttime, Config.TimeoutTime - FightSystem.getFightTime(),
blueLeader.getId(), redLeader.getId(), blueSchem, redSchem, win, windescription);
for (FightPlayer fp : Fight.getBlueTeam().getPlayers())
savePlayerStats(fp, fightId); savePlayerStats(fp, fightId);
for(FightPlayer fp : Fight.getRedTeam().getPlayers()) for (FightPlayer fp : Fight.getRedTeam().getPlayers())
savePlayerStats(fp, fightId); savePlayerStats(fp, fightId);
}catch(Exception e){
Bukkit.getLogger().log(Level.SEVERE, "Failed to save statistics", e);
} }
if(Config.Ranked && !Config.event()){ if(Config.Ranked && !Config.event()){