SteamWar/FightSystem
Archiviert
13
1

RecordSystem (Beta) #199

Manuell gemergt
Lixfel hat 40 Commits von recordSystem nach master 2020-11-01 20:11:45 +01:00 zusammengeführt
5 geänderte Dateien mit 69 neuen und 38 gelöschten Zeilen
Nur Änderungen aus Commit a495700f6f werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -34,11 +34,13 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.IFightSystem;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
import net.minecraft.server.v1_15_R1.Block;
import net.minecraft.server.v1_15_R1.ChunkSection;
import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
@ -211,7 +213,7 @@ public class TechHider_15 {
}*/
final int cY = chunkY;
Bukkit.getScheduler().runTaskAsynchronously(IFightSystem.getPlugin(),
Bukkit.getScheduler().runTask(IFightSystem.getPlugin(),
() -> fullChunkHider(p, chunkX, cY, chunkZ));
}
@ -230,38 +232,38 @@ public class TechHider_15 {
}
private static void fullChunkHider(Player player, int chunkX, int chunkY, int chunkZ){
ArrayList<MultiBlockChangeInfo> blockChangeList = new ArrayList<>();
if(!player.isOnline())
return;
Location location = new Location(WORLD, chunkX * 16f, chunkY * 16f, chunkZ * 16f);
int maxXp1 = (chunkX+1) * 16;
int maxYp1 = (chunkY+1) * 16;
int maxZp1 = (chunkZ+1) * 16;
while(location.getBlockX() < maxXp1){
while(location.getBlockY() < maxYp1){
while(location.getBlockZ() < maxZp1){
if(Config.HiddenBlockTags.contains(WORLD.getBlockAt(location).getType().name()))
blockChangeList.add(new MultiBlockChangeInfo(location, WRAPPED_BLOCK_DATA));
location.setZ(location.getZ() + 1);
ArrayList<MultiBlockChangeInfo> blockChangeList = new ArrayList<>();
ChunkCoordIntPair chunkCoords = new ChunkCoordIntPair(chunkX, chunkZ);
ChunkSection chunk = ((CraftWorld) WORLD).getHandle().getChunkAt(chunkX, chunkZ).getSections()[chunkY]; //This takes ~70ms async.
if(ChunkSection.a(chunk))
return;
int minY = chunkY * 16;
for(int x = 0; x < 16; x++){
for(int y = 0; y < 16; y++){
for(int z = 0; z < 16; z++){
if(Config.HiddenBlocks.contains(Block.REGISTRY_ID.getId(chunk.getType(x, y, z))))
blockChangeList.add(new MultiBlockChangeInfo((short)(x << 12 | z << 8 | (y + minY)), WRAPPED_BLOCK_DATA, chunkCoords));
}
location.setY(location.getY() + 1);
location.setZ(chunkZ * 16f);
}
location.setX(location.getX() + 1);
location.setY(chunkY * 16f);
location.setZ(chunkZ * 16f);
}
if(blockChangeList.isEmpty())
return;
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.MULTI_BLOCK_CHANGE);
packet.getChunkCoordIntPairs().write(0, new ChunkCoordIntPair(chunkX, chunkZ));
packet.getChunkCoordIntPairs().write(0, chunkCoords);
packet.getMultiBlockChangeInfoArrays().write(0, blockChangeList.toArray(new MultiBlockChangeInfo[0]));
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
} catch (InvocationTargetException e) {
throw new SecurityException("Something went wrong sending the multiblockchange packet", e);
} catch (NullPointerException e){
//ignored, player offline
}
}
}

Datei anzeigen

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

Datei anzeigen

@ -62,7 +62,7 @@ public class FightTeam implements IFightTeam{
private final String name;
private final String prefix;
private final ChatColor color;
private Schematic schematic;
private int schematic = 0;
private final Team team;
private final boolean blue;
@ -265,31 +265,40 @@ public class FightTeam implements IFightTeam{
FreezeWorld freezer = new FreezeWorld();
DyeColor c = ColorConverter.chat2dye(color);
Schematic schem;
try{
schem = Schematic.getSchemFromDB(this.schematic);
}catch(SecurityException e){
pasteDummy();
return;
}
EditSession e;
try {
switch(Core.getVersion()){
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);
break;
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);
break;
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);
break;
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);
break;
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);
break;
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);
}
} catch (Schematic.WrongVersionException ex) {
@ -309,7 +318,7 @@ public class FightTeam implements IFightTeam{
if(publics.isEmpty())
return;
schematic = publics.get(new Random().nextInt(publics.size()));
schematic = publics.get(new Random().nextInt(publics.size())).getSchemID();
pasteSchematic();
if(!Config.test() && leader != null)
@ -317,7 +326,7 @@ public class FightTeam implements IFightTeam{
}
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!");
if(!Config.test())
@ -331,13 +340,13 @@ public class FightTeam implements IFightTeam{
}
public boolean hasSchematic(){
return schematic != null;
return schematic != 0;
}
public void setReady(boolean ready) {
Player l = leader.getPlayer();
if(schematic == null){
if(schematic == 0){
l.sendMessage(FightSystem.PREFIX + "§cZuerst muss eine Schematic gewählt sein!");
return;
}
@ -370,7 +379,7 @@ public class FightTeam implements IFightTeam{
return prefix;
}
public Schematic getSchematic() {
public int getSchematic() {
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.FightTeam;
import de.steamwar.sql.Elo;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.logging.Level;
import static de.steamwar.sql.Fight.create;
@ -58,14 +60,29 @@ public class FightStatistics {
}else{
blueResult = 0.5;
}
if(Fight.getBlueTeam().getSchematic() != null && Fight.getRedTeam().getSchematic() != null){
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(), Fight.getBlueTeam().getSchematic().getSchemID(), Fight.getRedTeam().getSchematic().getSchemID(), win, windescription);
blueLeader.getId(), redLeader.getId(), blueSchem, redSchem, win, windescription);
for (FightPlayer fp : Fight.getBlueTeam().getPlayers())
savePlayerStats(fp, fightId);
for (FightPlayer fp : Fight.getRedTeam().getPlayers())
savePlayerStats(fp, fightId);
}catch(Exception e){
Bukkit.getLogger().log(Level.SEVERE, "Failed to save statistics", e);
}
if(Config.Ranked && !Config.event()){

Datei anzeigen

@ -1,6 +1,8 @@
name: FightSystem
version: "1.0"
authors: [Yaruma3341, Lixfel]
authors:
- Yaruma3341
- Lixfel
main: de.steamwar.fightsystem.FightSystem
depend: [SpigotCore, WorldEdit, ProtocolLib]
api-version: "1.13"