SteamWar/FightSystem
Archiviert
13
1

Improving Array

Dieser Commit ist enthalten in:
Chaoscaot 2020-11-28 13:11:43 +01:00
Ursprung 9984fc0179
Commit 5eedf7bf50

Datei anzeigen

@ -26,7 +26,6 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.states.StateDependent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.AbstractArrow;
@ -52,18 +51,14 @@ public class ArrowStopper implements StateDependent {
if(arrows.isEmpty()) if(arrows.isEmpty())
return; return;
for (Entity entity : arrows) { for (Entity entity : arrows) {
if(entity.getTicksLived() > Config.ArrowTechhiderCollision){ if(entity.getTicksLived() > Config.ArrowTechhiderCollision ||
LAST_LOCATION.remove(entity); ((AbstractArrow) entity).isInBlock()){
continue;
}
if(((AbstractArrow) entity).isInBlock()) {
LAST_LOCATION.remove(entity); LAST_LOCATION.remove(entity);
continue; continue;
} }
if(!LAST_LOCATION.containsKey(entity)) if(!LAST_LOCATION.containsKey(entity))
LAST_LOCATION.put(entity, ((Player) ((AbstractArrow) entity).getShooter()).getEyeLocation()); LAST_LOCATION.put(entity, ((Player) ((AbstractArrow) entity).getShooter()).getEyeLocation());
Location last = LAST_LOCATION.get(entity); Location last = LAST_LOCATION.remove(entity);
LAST_LOCATION.remove(entity);
if(checkBlocks(entity.getLocation().getBlock(), last.getBlock())) if(checkBlocks(entity.getLocation().getBlock(), last.getBlock()))
entity.remove(); entity.remove();
else else
@ -78,7 +73,7 @@ public class ArrowStopper implements StateDependent {
@Override @Override
public void enable() { public void enable() {
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::run, 1, 0); task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::run, 1, 1);
} }
@Override @Override