SteamWar/FightSystem
Archiviert
13
1

Make arena leaveable #334

Zusammengeführt
Lixfel hat 1 Commits von arenaLeaveable nach master 2022-03-04 16:32:48 +01:00 zusammengeführt
18 geänderte Dateien mit 186 neuen und 79 gelöschten Zeilen

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.listener.Recording; import de.steamwar.fightsystem.listener.Recording;
import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.record.GlobalRecorder;
@ -76,7 +77,8 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
return new Listener() { return new Listener() {
@EventHandler @EventHandler
public void onArrowPickup(PlayerPickupArrowEvent e){ public void onArrowPickup(PlayerPickupArrowEvent e){
e.setCancelled(true); if(Fight.fighting(e.getPlayer()))
e.setCancelled(true);
} }
}; };
} }
@ -86,7 +88,8 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
return new Listener() { return new Listener() {
@EventHandler @EventHandler
public void onSwapItems(PlayerSwapHandItemsEvent event) { public void onSwapItems(PlayerSwapHandItemsEvent event) {
event.setCancelled(true); if(Fight.fighting(event.getPlayer()))
event.setCancelled(true);
} }
}; };
} }

Datei anzeigen

@ -43,6 +43,8 @@ Arena:
GroundWalkable: true # defaults to true if missing GroundWalkable: true # defaults to true if missing
# Disable snow and ice melting # Disable snow and ice melting
DisableSnowMelt: false # defaults to false if missing DisableSnowMelt: false # defaults to false if missing
# Allow leaving the arena area as spectator
Leaveable: false # defaults to false if missing
Schematic: Schematic:
# The size of the schematics # The size of the schematics

Datei anzeigen

@ -70,6 +70,7 @@ public class Config {
public static final int WaterDepth; public static final int WaterDepth;
public static final boolean GroundWalkable; public static final boolean GroundWalkable;
public static final boolean DisableSnowMelt; public static final boolean DisableSnowMelt;
public static final boolean ArenaLeaveable;
//schematic parameter //schematic parameter
public static final boolean RanksEnabled; public static final boolean RanksEnabled;
@ -166,6 +167,7 @@ public class Config {
PreperationArea = config.getInt("Arena.BorderFromSchematic", 12); PreperationArea = config.getInt("Arena.BorderFromSchematic", 12);
GroundWalkable = config.getBoolean("Arena.GroundWalkable", true); GroundWalkable = config.getBoolean("Arena.GroundWalkable", true);
DisableSnowMelt = config.getBoolean("Arena.DisableSnowMelt", false); DisableSnowMelt = config.getBoolean("Arena.DisableSnowMelt", false);
ArenaLeaveable = config.getBoolean("Arena.Leaveable", false);
int schemsizeX = config.getInt("Schematic.Size.x"); int schemsizeX = config.getInt("Schematic.Size.x");
int schemsizeY = config.getInt("Schematic.Size.y"); int schemsizeY = config.getInt("Schematic.Size.y");

Datei anzeigen

@ -75,6 +75,10 @@ public class Fight {
return null; return null;
} }
public static boolean fighting(Player player) {
return getPlayerTeam(player) != null;
}
public static FightTeam getRedTeam() { public static FightTeam getRedTeam() {
return redTeam; return redTeam;
} }

Datei anzeigen

@ -43,6 +43,9 @@ public class ArenaBorder implements Listener {
@EventHandler @EventHandler
public void arenaBorder(PlayerMoveEvent event){ public void arenaBorder(PlayerMoveEvent event){
Player player = event.getPlayer(); Player player = event.getPlayer();
if(Config.ArenaLeaveable && !Fight.fighting(player))
return;
Location to = event.getTo(); Location to = event.getTo();
assert to != null; assert to != null;

Datei anzeigen

@ -87,10 +87,11 @@ public class ArrowStopper {
} }
private boolean invalidEntity(Arrow entity) { private boolean invalidEntity(Arrow entity) {
Location location = entity.getLocation();
boolean teamFrom = entity.getVelocity().getZ() > 0; boolean teamFrom = entity.getVelocity().getZ() > 0;
boolean overMid = entity.getLocation().getZ() > Config.SpecSpawn.getZ(); boolean overMid = location.getZ() > Config.SpecSpawn.getZ();
boolean otherSide = teamFrom == overMid; boolean otherSide = teamFrom == overMid;
return otherSide || return otherSide || !Config.ArenaRegion.inRegion(location) ||
WorldOfColorWrapper.impl.isInBlock(entity) || WorldOfColorWrapper.impl.isInBlock(entity) ||
entity.getVelocity().equals(NULL_VECTOR); entity.getVelocity().equals(NULL_VECTOR);
} }

Datei anzeigen

@ -1,31 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.fight.Fight;
import org.bukkit.entity.Player;
public class BasicListener {
private BasicListener(){}
public static boolean notFighting(Player p){
return Fight.getFightPlayer(p) == null;
}
}

Datei anzeigen

@ -1,6 +1,5 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config; 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;
@ -17,7 +16,7 @@ public class BlockFadeListener implements Listener {
@EventHandler @EventHandler
public void onBlockFade(BlockFadeEvent event) { public void onBlockFade(BlockFadeEvent event) {
if (event.getBlock().getType() == Material.SNOW_BLOCK || event.getBlock().getType() == Material.SNOW || event.getBlock().getType() == Material.ICE) { if (Config.ArenaRegion.inRegion(event.getBlock()) && (event.getBlock().getType() == Material.SNOW_BLOCK || event.getBlock().getType() == Material.SNOW || event.getBlock().getType() == Material.ICE)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

Datei anzeigen

@ -20,7 +20,9 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
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 net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
@ -43,20 +45,25 @@ public class DenyWorldInteraction implements Listener {
@EventHandler @EventHandler
public void handleBlockBreak(BlockBreakEvent event) { public void handleBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
event.setCancelled(true); if(Fight.fighting(player)) {
FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", player, ChatMessageType.ACTION_BAR); event.setCancelled(true);
FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", player, ChatMessageType.ACTION_BAR);
}
} }
@EventHandler @EventHandler
public void handleBlockPlace(BlockPlaceEvent event) { public void handleBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
event.setCancelled(true); if(Fight.fighting(player)) {
FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR); event.setCancelled(true);
FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR);
}
} }
@EventHandler @EventHandler
public void handleEntityExplode(EntityExplodeEvent event) { public void handleEntityExplode(EntityExplodeEvent event) {
event.setCancelled(true); if(Config.ArenaRegion.inRegion(event.getLocation()))
event.setCancelled(true);
} }
@EventHandler @EventHandler
@ -67,10 +74,12 @@ public class DenyWorldInteraction implements Listener {
@EventHandler @EventHandler
public void handleProjectileLaunch(ProjectileLaunchEvent event) { public void handleProjectileLaunch(ProjectileLaunchEvent event) {
event.setCancelled(true); if(event.getEntity().getShooter() instanceof Player) {
if(event.getEntity().getShooter() instanceof Player){
Player player = (Player) event.getEntity().getShooter(); Player player = (Player) event.getEntity().getShooter();
FightSystem.getMessage().sendPrefixless("NO_BOW_USAGE", player, ChatMessageType.ACTION_BAR); if(Fight.fighting(player)) {
event.setCancelled(true);
FightSystem.getMessage().sendPrefixless("NO_BOW_USAGE", player, ChatMessageType.ACTION_BAR);
}
} }
} }
} }

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
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.event.EventHandler; import org.bukkit.event.EventHandler;
@ -35,11 +36,13 @@ public class EntityDamage implements Listener {
@EventHandler @EventHandler
public void handleEntityDamage(EntityDamageEvent event) { public void handleEntityDamage(EntityDamageEvent event) {
event.setCancelled(true); if(Config.ArenaRegion.inRegion(event.getEntity().getLocation()))
event.setCancelled(true);
} }
@EventHandler @EventHandler
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) { public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
event.setCancelled(true); if(Config.ArenaRegion.inRegion(event.getEntity().getLocation()))
event.setCancelled(true);
} }
} }

Datei anzeigen

@ -30,7 +30,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import java.util.Objects; import java.util.Objects;
@ -40,15 +39,6 @@ public class InFightDamage implements Listener {
new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this); new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this);
} }
@EventHandler
public void handleEntityDamage(EntityDamageEvent event) {
if(!(event.getEntity() instanceof Player))
return;
if(BasicListener.notFighting((Player)event.getEntity()))
event.setCancelled(true);
}
@EventHandler @EventHandler
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) { public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(!(event.getEntity() instanceof Player)) if(!(event.getEntity() instanceof Player))
@ -56,6 +46,9 @@ public class InFightDamage implements Listener {
return; return;
Player player = ((Player) event.getEntity()); Player player = ((Player) event.getEntity());
if(!Fight.fighting(player))
return;
Player damager; Player damager;
if(event.getDamager() instanceof Player) { if(event.getDamager() instanceof Player) {
@ -72,7 +65,7 @@ public class InFightDamage implements Listener {
return; return;
} }
if(BasicListener.notFighting(damager)){ if(!Fight.fighting(damager)){
event.setCancelled(true); event.setCancelled(true);
//Damager is not fighting //Damager is not fighting
return; return;

Datei anzeigen

@ -20,9 +20,12 @@
package de.steamwar.fightsystem.listener; package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
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.Material; import org.bukkit.Material;
import org.bukkit.entity.Player;
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.BlockDispenseEvent; import org.bukkit.event.block.BlockDispenseEvent;
@ -44,6 +47,9 @@ public class InFightInventory implements Listener {
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent event) { public void onInventoryClick(InventoryClickEvent event) {
if(!Fight.fighting((Player) event.getWhoClicked()))
return;
InventoryType top = event.getView().getTopInventory().getType(); InventoryType top = event.getView().getTopInventory().getType();
if(top == InventoryType.CRAFTING) if(top == InventoryType.CRAFTING)
return; return;
@ -54,6 +60,9 @@ public class InFightInventory implements Listener {
@EventHandler @EventHandler
public void onInventoryDrag(InventoryDragEvent event) { public void onInventoryDrag(InventoryDragEvent event) {
if(!Fight.fighting((Player) event.getWhoClicked()))
return;
if (event.getInventory().getType() != InventoryType.PLAYER) { if (event.getInventory().getType() != InventoryType.PLAYER) {
int inventorySize = event.getInventory().getSize(); int inventorySize = event.getInventory().getSize();
@ -68,7 +77,7 @@ public class InFightInventory implements Listener {
@EventHandler @EventHandler
public void onBlockDispense(BlockDispenseEvent e) { public void onBlockDispense(BlockDispenseEvent e) {
if(e.getItem().getType() == Material.TNT) if(Config.ArenaRegion.inRegion(e.getBlock()) && e.getItem().getType() == Material.TNT)
e.setCancelled(true); e.setCancelled(true);
} }
} }

Datei anzeigen

@ -0,0 +1,87 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2022 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.spigotmc.event.player.PlayerSpawnLocationEvent;
import java.util.HashMap;
import java.util.Map;
public class LeaveableArena implements Listener {
private final Map<Player, GameMode> spectatorsInArena = new HashMap<>();
public LeaveableArena() {
new StateDependentListener(Config.ArenaLeaveable, FightState.All, this);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onJoin(PlayerSpawnLocationEvent event) {
Player player = event.getPlayer();
if(Fight.fighting(player))
return;
if(Config.ArenaRegion.inRegion(event.getSpawnLocation())) {
markInArena(player);
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
if(Config.ArenaRegion.inRegion(event.getRespawnLocation())) {
markInArena(player);
} else {
spectatorsInArena.remove(player);
}
}
@EventHandler
public void arenaBorder(PlayerMoveEvent event){
Player player = event.getPlayer();
if(Fight.fighting(player))
return;
boolean inArena = Config.ArenaRegion.inRegion(event.getTo());
boolean spectator = spectatorsInArena.containsKey(player);
if(inArena && !spectator) {
markInArena(player);
} else if(!inArena && spectator) {
player.setGameMode(spectatorsInArena.remove(player));
}
}
private void markInArena(Player player) {
spectatorsInArena.put(player, player.getGameMode());
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
}
}

Datei anzeigen

@ -52,10 +52,12 @@ public class Permanent implements Listener {
@EventHandler @EventHandler
public void handlePlayerRespawn(PlayerRespawnEvent event){ public void handlePlayerRespawn(PlayerRespawnEvent event){
Player player = event.getPlayer(); Player player = event.getPlayer();
Fight.setPlayerGamemode(player, GameMode.SPECTATOR); if(Fight.fighting(player)) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
FightTeam team = Fight.getPlayerTeam(player); FightTeam team = Fight.getPlayerTeam(player);
event.setRespawnLocation(team == null ? Config.SpecSpawn : team.getSpawn()); event.setRespawnLocation(team == null ? Config.SpecSpawn : team.getSpawn());
}
} }
@EventHandler @EventHandler
@ -72,9 +74,8 @@ public class Permanent implements Listener {
event.setJoinMessage(null); event.setJoinMessage(null);
Player player = event.getPlayer(); Player player = event.getPlayer();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if (fightTeam == null) { if (!Config.ArenaLeaveable && !Fight.fighting(player)) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR); Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn); player.teleport(Config.SpecSpawn);
} }
@ -84,56 +85,66 @@ public class Permanent implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void handlePlayerDeath(PlayerDeathEvent event) { public void handlePlayerDeath(PlayerDeathEvent event) {
event.setDeathMessage(null); if(Fight.fighting(event.getEntity()))
event.setDeathMessage(null);
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void handlePlayerLeave(PlayerQuitEvent event) { public void handlePlayerLeave(PlayerQuitEvent event) {
event.setQuitMessage(null); if(Fight.fighting(event.getPlayer()))
event.setQuitMessage(null);
} }
@EventHandler @EventHandler
public void handleFoodLevelChange(FoodLevelChangeEvent event) { public void handleFoodLevelChange(FoodLevelChangeEvent event) {
event.setCancelled(true); if(Fight.fighting((Player) event.getEntity()))
event.setCancelled(true);
} }
@EventHandler @EventHandler
public void onWeatherChange(WeatherChangeEvent event){ public void onWeatherChange(WeatherChangeEvent event) {
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler
public void onSpawnerSpawn(SpawnerSpawnEvent e){ public void onSpawnerSpawn(SpawnerSpawnEvent e){
e.setCancelled(true); if(Config.ArenaRegion.inRegion(e.getSpawner().getBlock()))
e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onSleep(PlayerBedEnterEvent e) { public void onSleep(PlayerBedEnterEvent e) {
e.setCancelled(true); if(Fight.fighting(e.getPlayer()))
e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onCrafting(CraftItemEvent e){ public void onCrafting(CraftItemEvent e){
e.setCancelled(true); if(Fight.fighting((Player) e.getWhoClicked()))
e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onFurnace(FurnaceSmeltEvent e){ public void onFurnace(FurnaceSmeltEvent e){
e.setCancelled(true); if(Config.ArenaRegion.inRegion(e.getBlock()))
e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onDropPickup(InventoryPickupItemEvent e){ public void onDropPickup(InventoryPickupItemEvent e){
e.setCancelled(true); if(Config.ArenaRegion.inRegion(e.getItem().getLocation()))
e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onDropping(PlayerDropItemEvent e){ public void onDropping(PlayerDropItemEvent e){
e.setCancelled(true); if(Fight.fighting(e.getPlayer()))
e.setCancelled(true);
} }
@EventHandler @EventHandler
public void onWorldLoad(WorldLoadEvent e) { public void onWorldLoad(WorldLoadEvent e) {
e.getWorld().setAutoSave(false); if(!Config.ArenaLeaveable)
e.getWorld().setAutoSave(false);
} }
} }

Datei anzeigen

@ -43,6 +43,9 @@ public class PistonListener implements Listener {
@EventHandler @EventHandler
public void handlePistonExtend(BlockPistonExtendEvent e){ public void handlePistonExtend(BlockPistonExtendEvent e){
if(!Config.ArenaRegion.inRegion(e.getBlock()))
return;
BlockFace face = e.getDirection(); BlockFace face = e.getDirection();
for(Block block : e.getBlocks()){ for(Block block : e.getBlocks()){
Block target = block.getRelative(face); Block target = block.getRelative(face);
@ -55,6 +58,9 @@ public class PistonListener implements Listener {
@EventHandler @EventHandler
public void handlePistonRetract(BlockPistonRetractEvent e){ public void handlePistonRetract(BlockPistonRetractEvent e){
if(!Config.ArenaRegion.inRegion(e.getBlock()))
return;
for(Block block : e.getBlocks()){ for(Block block : e.getBlocks()){
if(!Config.BlueExtendRegion.inRegion(block) && !Config.RedExtendRegion.inRegion(block)) { if(!Config.BlueExtendRegion.inRegion(block) && !Config.RedExtendRegion.inRegion(block)) {
e.setCancelled(true); e.setCancelled(true);

Datei anzeigen

@ -120,7 +120,7 @@ public class Recording implements Listener {
private static final Reflection.FieldAccessor<?> blockDigType = Reflection.getField(blockDigPacket, playerDigType, 0); private static final Reflection.FieldAccessor<?> blockDigType = Reflection.getField(blockDigPacket, playerDigType, 0);
private static final Object releaseUseItem = playerDigType.getEnumConstants()[5]; private static final Object releaseUseItem = playerDigType.getEnumConstants()[5];
private Object blockDig(Player p, Object packet) { private Object blockDig(Player p, Object packet) {
if(blockDigType.get(packet) == releaseUseItem) if(!isNotSent(p) && blockDigType.get(packet) == releaseUseItem)
GlobalRecorder.getInstance().bowSpan(p, false, false); GlobalRecorder.getInstance().bowSpan(p, false, false);
return packet; return packet;
} }
@ -128,7 +128,7 @@ public class Recording implements Listener {
public static final Class<?> blockPlacePacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInBlockPlace"); public static final Class<?> blockPlacePacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInBlockPlace");
private Object blockPlace(Player p, Object packet) { private Object blockPlace(Player p, Object packet) {
boolean mainHand = BountifulWrapper.impl.mainHand(packet); boolean mainHand = BountifulWrapper.impl.mainHand(packet);
if(BountifulWrapper.impl.bowInHand(mainHand, p)) if(!isNotSent(p) && BountifulWrapper.impl.bowInHand(mainHand, p))
GlobalRecorder.getInstance().bowSpan(p, true, !mainHand); GlobalRecorder.getInstance().bowSpan(p, true, !mainHand);
return packet; return packet;
} }
@ -143,6 +143,9 @@ public class Recording implements Listener {
@EventHandler @EventHandler
public void onPlayerDeath(PlayerDeathEvent e) { public void onPlayerDeath(PlayerDeathEvent e) {
if(isNotSent(e.getEntity()))
return;
GlobalRecorder.getInstance().entityDespawns(e.getEntity()); GlobalRecorder.getInstance().entityDespawns(e.getEntity());
} }
@ -157,7 +160,7 @@ public class Recording implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent e){ public void onBlockPhysics(BlockPhysicsEvent e){
if(FlatteningWrapper.impl.doRecord(e)) if(FlatteningWrapper.impl.doRecord(e))
GlobalRecorder.getInstance().blockChange(e.getBlock()); GlobalRecorder.getInstance().blockChange(e.getBlock()); //TODO ?
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)

Datei anzeigen

@ -43,6 +43,9 @@ public class RunningWorldInteraction implements Listener {
@EventHandler @EventHandler
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
if(!Fight.fighting(event.getPlayer()))
return;
Inventory inventory = event.getPlayer().getInventory(); Inventory inventory = event.getPlayer().getInventory();
ItemStack stack = FlatteningWrapper.impl.onBreak(event.getBlock()); ItemStack stack = FlatteningWrapper.impl.onBreak(event.getBlock());

Datei anzeigen

@ -36,7 +36,7 @@ public class Shutdown implements Listener {
@EventHandler @EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) { public void handlePlayerQuit(PlayerQuitEvent event) {
if(Config.replayserver()) if(Config.replayserver() || Config.ArenaLeaveable)
return; return;
//Shutdown server if nobody online //Shutdown server if nobody online