Merge branch 'master' into Anti_Ice_Melt
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Commit
bfb394c609
@ -152,7 +152,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
ProtocolAPI.tinyProtocol.close();
|
|
||||||
GlobalRecorder.getInstance().close();
|
GlobalRecorder.getInstance().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
package de.steamwar.fightsystem.fight;
|
package de.steamwar.fightsystem.fight;
|
||||||
|
|
||||||
import com.comphenix.tinyprotocol.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.ArenaMode;
|
import de.steamwar.fightsystem.ArenaMode;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.record.GlobalRecorder;
|
import de.steamwar.fightsystem.record.GlobalRecorder;
|
||||||
import de.steamwar.fightsystem.utils.ProtocolAPI;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -146,7 +146,7 @@ public class Fight {
|
|||||||
|
|
||||||
private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClass, playerInfoPacket, GameProfile.class, int.class, enumGamemode, iChatBaseComponent);
|
private static final Reflection.ConstructorInvoker playerInfoDataConstructor = Reflection.getConstructor(playerInfoDataClass, playerInfoPacket, GameProfile.class, int.class, enumGamemode, iChatBaseComponent);
|
||||||
public static void pseudoSpectator(Player player, boolean enable) {
|
public static void pseudoSpectator(Player player, boolean enable) {
|
||||||
ProtocolAPI.tinyProtocol.sendPacket(player, playerInfoPacket(updateGamemode, new GameProfile(player.getUniqueId(), player.getName()), enable ? creative : spectator));
|
TinyProtocol.instance.sendPacket(player, playerInfoPacket(updateGamemode, new GameProfile(player.getUniqueId(), player.getName()), enable ? creative : spectator));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object playerInfoPacket(Object action, GameProfile profile, Object mode) {
|
public static Object playerInfoPacket(Object action, GameProfile profile, Object mode) {
|
||||||
|
@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config;
|
|||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
@ -41,8 +42,9 @@ public class PistonListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePistonExtend(BlockPistonExtendEvent e){
|
public void handlePistonExtend(BlockPistonExtendEvent e){
|
||||||
|
BlockFace face = e.getDirection();
|
||||||
for(Block block : e.getBlocks()){
|
for(Block block : e.getBlocks()){
|
||||||
if(!Config.BlueExtendRegion.inRegion(block) && !Config.RedExtendRegion.inRegion(block)){
|
if(!Config.BlueExtendRegion.inRegion(block.getRelative(face)) && !Config.RedExtendRegion.inRegion(block.getRelative(face))){
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.fightsystem.record;
|
package de.steamwar.fightsystem.record;
|
||||||
|
|
||||||
import com.comphenix.tinyprotocol.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
@ -72,22 +73,22 @@ public class REntity {
|
|||||||
public static void playerJoins(Player player) {
|
public static void playerJoins(Player player) {
|
||||||
for(REntity entity : entities.values()){
|
for(REntity entity : entities.values()){
|
||||||
if(entity.entityType == EntityType.PLAYER){
|
if(entity.entityType == EntityType.PLAYER){
|
||||||
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getPlayerInfoPacket());
|
TinyProtocol.instance.sendPacket(player, entity.getPlayerInfoPacket());
|
||||||
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getNamedSpawnPacket());
|
TinyProtocol.instance.sendPacket(player, entity.getNamedSpawnPacket());
|
||||||
for (Map.Entry<String, ItemStack> entry : entity.itemSlots.entrySet()) {
|
for (Map.Entry<String, ItemStack> entry : entity.itemSlots.entrySet()) {
|
||||||
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getEquipmentPacket(entry.getKey(), entry.getValue()));
|
TinyProtocol.instance.sendPacket(player, entity.getEquipmentPacket(entry.getKey(), entry.getValue()));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getSpawnEntityPacket());
|
TinyProtocol.instance.sendPacket(player, entity.getSpawnEntityPacket());
|
||||||
}
|
}
|
||||||
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getTeleportPacket());
|
TinyProtocol.instance.sendPacket(player, entity.getTeleportPacket());
|
||||||
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getHeadRotationPacket());
|
TinyProtocol.instance.sendPacket(player, entity.getHeadRotationPacket());
|
||||||
|
|
||||||
if(entity.fireTick != 0) {
|
if(entity.fireTick != 0) {
|
||||||
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getDataWatcherPacket(entityStatusWatcher, (byte) 1));
|
TinyProtocol.instance.sendPacket(player, entity.getDataWatcherPacket(entityStatusWatcher, (byte) 1));
|
||||||
}
|
}
|
||||||
if(entity.sneaks) {
|
if(entity.sneaks) {
|
||||||
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getDataWatcherPacket(sneakingDataWatcher, BlockIdWrapper.impl.getPose(true)));
|
TinyProtocol.instance.sendPacket(player, entity.getDataWatcherPacket(sneakingDataWatcher, BlockIdWrapper.impl.getPose(true)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
|
||||||
import io.netty.channel.Channel;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -42,23 +40,20 @@ public class ProtocolAPI {
|
|||||||
private static final Map<Class<?>, BiFunction<Player, Object, Object>> outgoingHandler = new HashMap<>();
|
private static final Map<Class<?>, BiFunction<Player, Object, Object>> outgoingHandler = new HashMap<>();
|
||||||
private static final Map<Class<?>, BiFunction<Player, Object, Object>> incomingHandler = new HashMap<>();
|
private static final Map<Class<?>, BiFunction<Player, Object, Object>> incomingHandler = new HashMap<>();
|
||||||
|
|
||||||
public static final TinyProtocol tinyProtocol = new TinyProtocol(FightSystem.getPlugin()) {
|
static {
|
||||||
@Override
|
TinyProtocol.instance.setOutFilter((receiver, channel, packet) -> {
|
||||||
public Object onPacketOutAsync(Player receiver, Channel channel, Object packet) {
|
|
||||||
BiFunction<Player, Object, Object> handler = outgoingHandler.get(packet.getClass());
|
BiFunction<Player, Object, Object> handler = outgoingHandler.get(packet.getClass());
|
||||||
if(handler == null)
|
if(handler == null)
|
||||||
return packet;
|
return packet;
|
||||||
return handler.apply(receiver, packet);
|
return handler.apply(receiver, packet);
|
||||||
}
|
});
|
||||||
|
TinyProtocol.instance.setInFilter((sender, channel, packet) -> {
|
||||||
@Override
|
|
||||||
public Object onPacketInAsync(Player sender, Channel channel, Object packet) {
|
|
||||||
BiFunction<Player, Object, Object> handler = incomingHandler.get(packet.getClass());
|
BiFunction<Player, Object, Object> handler = incomingHandler.get(packet.getClass());
|
||||||
if(handler == null)
|
if(handler == null)
|
||||||
return packet;
|
return packet;
|
||||||
return handler.apply(sender, packet);
|
return handler.apply(sender, packet);
|
||||||
}
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
public static void setOutgoingHandler(Class<?> packetClass, BiFunction<Player, Object, Object> handler) {
|
public static void setOutgoingHandler(Class<?> packetClass, BiFunction<Player, Object, Object> handler) {
|
||||||
outgoingHandler.put(packetClass, handler);
|
outgoingHandler.put(packetClass, handler);
|
||||||
@ -77,7 +72,7 @@ public class ProtocolAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void broadcastPacket(Object packet) {
|
public static void broadcastPacket(Object packet) {
|
||||||
Bukkit.getOnlinePlayers().stream().map(tinyProtocol::getChannel).filter(tinyProtocol::hasInjected).forEach(channel -> tinyProtocol.sendPacket(channel, packet));
|
Bukkit.getOnlinePlayers().stream().map(TinyProtocol.instance::getChannel).filter(TinyProtocol.instance::hasInjected).forEach(channel -> TinyProtocol.instance.sendPacket(channel, packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BiFunction<Object, UnaryOperator<Object>, Object> arrayCloneGenerator(Class<?> elementClass) {
|
public static BiFunction<Object, UnaryOperator<Object>, Object> arrayCloneGenerator(Class<?> elementClass) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren