Add Arrows Stopping in Techhider Blocks
Dieser Commit ist enthalten in:
Ursprung
da157fef72
Commit
664350d286
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
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.utils;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
|
public class ArrowStopper_12 {
|
||||||
|
private ArrowStopper_12(){}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
static int blockToId(Block block){
|
||||||
|
return block.getTypeId() << 4 + block.getData();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
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.utils;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
|
||||||
|
|
||||||
|
public class ArrowStopper_15 {
|
||||||
|
private ArrowStopper_15(){}
|
||||||
|
|
||||||
|
static int blockToId(Block block){
|
||||||
|
return net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS());
|
||||||
|
}
|
||||||
|
}
|
@ -80,6 +80,7 @@ public class Config {
|
|||||||
public static final int ArenaMaxX;
|
public static final int ArenaMaxX;
|
||||||
public static final int ArenaMaxZ;
|
public static final int ArenaMaxZ;
|
||||||
public static final boolean GroundWalkable;
|
public static final boolean GroundWalkable;
|
||||||
|
public static final int ArrowTechhiderCollision;
|
||||||
|
|
||||||
//schematic parameter
|
//schematic parameter
|
||||||
public static final boolean RanksEnabled;
|
public static final boolean RanksEnabled;
|
||||||
@ -188,6 +189,7 @@ public class Config {
|
|||||||
double teamBlueSpawnOffsetX = worldconfig.getDouble("Arena.SpawnOffset.x");
|
double teamBlueSpawnOffsetX = worldconfig.getDouble("Arena.SpawnOffset.x");
|
||||||
double teamBlueSpawnOffsetY = worldconfig.getDouble("Arena.SpawnOffset.y");
|
double teamBlueSpawnOffsetY = worldconfig.getDouble("Arena.SpawnOffset.y");
|
||||||
double teamBlueSpawnOffsetZ = worldconfig.getDouble("Arena.SpawnOffset.z");
|
double teamBlueSpawnOffsetZ = worldconfig.getDouble("Arena.SpawnOffset.z");
|
||||||
|
ArrowTechhiderCollision = config.getInt("Times.ArrowTechhiderCollision");
|
||||||
|
|
||||||
RanksEnabled = config.getBoolean("Schematic.RanksEnabled");
|
RanksEnabled = config.getBoolean("Schematic.RanksEnabled");
|
||||||
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
|
SchematicType = de.steamwar.sql.SchematicType.fromDB(config.getString("Schematic.SchematicType"));
|
||||||
|
@ -32,10 +32,7 @@ import de.steamwar.fightsystem.record.RecordSystem;
|
|||||||
import de.steamwar.fightsystem.record.Recorder;
|
import de.steamwar.fightsystem.record.Recorder;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependent;
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
import de.steamwar.fightsystem.utils.EnterHandler;
|
import de.steamwar.fightsystem.utils.*;
|
||||||
import de.steamwar.fightsystem.utils.FightScoreboard;
|
|
||||||
import de.steamwar.fightsystem.utils.FightStatistics;
|
|
||||||
import de.steamwar.fightsystem.utils.TechHider;
|
|
||||||
import de.steamwar.fightsystem.winconditions.*;
|
import de.steamwar.fightsystem.winconditions.*;
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.sql.EventFight;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
@ -72,6 +69,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
TechHider.init();
|
TechHider.init();
|
||||||
FightScoreboard.init();
|
FightScoreboard.init();
|
||||||
RecordSystem.init();
|
RecordSystem.init();
|
||||||
|
ArrowStopper.init();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CommandRemover.removeAll("gamemode");
|
CommandRemover.removeAll("gamemode");
|
||||||
|
86
FightSystem_Main/src/de/steamwar/fightsystem/utils/ArrowStopper.java
Normale Datei
86
FightSystem_Main/src/de/steamwar/fightsystem/utils/ArrowStopper.java
Normale Datei
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
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.utils;
|
||||||
|
|
||||||
|
import de.steamwar.core.Core;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.states.StateDependent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.AbstractArrow;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class ArrowStopper implements StateDependent {
|
||||||
|
|
||||||
|
private BukkitTask task;
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
if(Config.ArrowTechhiderCollision == -1)
|
||||||
|
return;
|
||||||
|
FightSystem.registerStateDependent(new ArrowStopper());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void run() {
|
||||||
|
Collection<Entity> arrows = Bukkit.getWorlds().get(0).getEntitiesByClasses(AbstractArrow.class);
|
||||||
|
if(arrows.isEmpty())
|
||||||
|
return;
|
||||||
|
for (Entity entity : arrows) {
|
||||||
|
if(entity.getTicksLived() > Config.ArrowTechhiderCollision)
|
||||||
|
continue;
|
||||||
|
if(Config.HiddenBlocks.contains(blockToId(entity.getLocation().getBlock())))
|
||||||
|
entity.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<FightState> enabled() {
|
||||||
|
return EnumSet.of(FightState.RUNNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable() {
|
||||||
|
task = Bukkit.getScheduler().runTaskTimerAsynchronously(FightSystem.getPlugin(), this::run, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
task.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int blockToId(Block block){
|
||||||
|
switch(Core.getVersion()){
|
||||||
|
case 8:
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
case 12:
|
||||||
|
return ArrowStopper_12.blockToId(block);
|
||||||
|
case 15:
|
||||||
|
default:
|
||||||
|
return ArrowStopper_15.blockToId(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren