Merge branch 'master' into recordSystem
Dieser Commit ist enthalten in:
Commit
a495700f6f
@ -34,11 +34,13 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.IFightSystem;
|
import de.steamwar.fightsystem.IFightSystem;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
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 net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
|
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.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -211,7 +213,7 @@ public class TechHider_15 {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
final int cY = chunkY;
|
final int cY = chunkY;
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(IFightSystem.getPlugin(),
|
Bukkit.getScheduler().runTask(IFightSystem.getPlugin(),
|
||||||
() -> fullChunkHider(p, chunkX, cY, chunkZ));
|
() -> 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){
|
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);
|
ArrayList<MultiBlockChangeInfo> blockChangeList = new ArrayList<>();
|
||||||
int maxXp1 = (chunkX+1) * 16;
|
ChunkCoordIntPair chunkCoords = new ChunkCoordIntPair(chunkX, chunkZ);
|
||||||
int maxYp1 = (chunkY+1) * 16;
|
ChunkSection chunk = ((CraftWorld) WORLD).getHandle().getChunkAt(chunkX, chunkZ).getSections()[chunkY]; //This takes ~70ms async.
|
||||||
int maxZp1 = (chunkZ+1) * 16;
|
if(ChunkSection.a(chunk))
|
||||||
while(location.getBlockX() < maxXp1){
|
return;
|
||||||
while(location.getBlockY() < maxYp1){
|
|
||||||
while(location.getBlockZ() < maxZp1){
|
int minY = chunkY * 16;
|
||||||
if(Config.HiddenBlockTags.contains(WORLD.getBlockAt(location).getType().name()))
|
for(int x = 0; x < 16; x++){
|
||||||
blockChangeList.add(new MultiBlockChangeInfo(location, WRAPPED_BLOCK_DATA));
|
for(int y = 0; y < 16; y++){
|
||||||
location.setZ(location.getZ() + 1);
|
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())
|
if(blockChangeList.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.MULTI_BLOCK_CHANGE);
|
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]));
|
packet.getMultiBlockChangeInfoArrays().write(0, blockChangeList.toArray(new MultiBlockChangeInfo[0]));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw new SecurityException("Something went wrong sending the multiblockchange packet", e);
|
throw new SecurityException("Something went wrong sending the multiblockchange packet", e);
|
||||||
|
} catch (NullPointerException e){
|
||||||
|
//ignored, player offline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,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;
|
||||||
|
|
||||||
@ -265,31 +265,40 @@ public class FightTeam implements IFightTeam{
|
|||||||
|
|
||||||
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) {
|
||||||
@ -309,7 +318,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)
|
||||||
@ -317,7 +326,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())
|
||||||
@ -331,13 +340,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;
|
||||||
}
|
}
|
||||||
@ -370,7 +379,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Schematic getSchematic() {
|
public int getSchematic() {
|
||||||
return schematic;
|
return schematic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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){
|
|
||||||
|
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(),
|
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())
|
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()){
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
name: FightSystem
|
name: FightSystem
|
||||||
version: "1.0"
|
version: "1.0"
|
||||||
authors: [Yaruma3341, Lixfel]
|
authors:
|
||||||
|
- Yaruma3341
|
||||||
|
- Lixfel
|
||||||
main: de.steamwar.fightsystem.FightSystem
|
main: de.steamwar.fightsystem.FightSystem
|
||||||
depend: [SpigotCore, WorldEdit, ProtocolLib]
|
depend: [SpigotCore, WorldEdit, ProtocolLib]
|
||||||
api-version: "1.13"
|
api-version: "1.13"
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren