Implement basic canDamage

This commit is contained in:
samczsun 2017-03-09 17:56:53 -05:00 committed by cnr
parent 0735b415cf
commit 498df70a1f
3 changed files with 39 additions and 1 deletions

View File

@ -3,10 +3,12 @@ package mineplex.core.antihack;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.MobEffect;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.potion.PotionEffectType;
import com.mineplex.anticheat.api.MineplexLink;
@ -21,6 +23,8 @@ public class MineplexLinkImpl implements MineplexLink
{
private final DisguiseManager _disguiseManager = Managers.require(DisguiseManager.class);
private final RegisteredServiceProvider<RelationProvider> _relationProvider = Bukkit.getServicesManager().getRegistration(RelationProvider.class);
@Override
public EntityType getActiveDisguise(Player player)
{
@ -74,6 +78,6 @@ public class MineplexLinkImpl implements MineplexLink
@Override
public boolean canDamage(Player attacker, Entity target)
{
return true;
return _relationProvider != null && _relationProvider.getProvider().canDamage(attacker, target);
}
}

View File

@ -0,0 +1,9 @@
package mineplex.core.antihack;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public interface RelationProvider
{
boolean canDamage(Player player, Entity target);
}

View File

@ -7,7 +7,10 @@ import mineplex.core.aprilfools.AprilFoolsManager;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
import org.spigotmc.SpigotConfig;
@ -19,6 +22,7 @@ import mineplex.core.TwitchIntegrationFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antihack.RelationProvider;
import mineplex.core.antihack.logging.AntihackLogger;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.blood.Blood;
@ -80,6 +84,7 @@ import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import nautilus.game.arcade.anticheatmetadata.GameInfoMetadata;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameServerConfig;
import static mineplex.core.Managers.require;
@ -97,6 +102,26 @@ public class Arcade extends JavaPlugin
@Override
public void onEnable()
{
getServer().getServicesManager().register(RelationProvider.class, new RelationProvider()
{
@Override
public boolean canDamage(Player player, Entity target)
{
if (target instanceof Player)
{
return _gameManager.canHurt(player, (Player) target);
}
else if (target instanceof LivingEntity)
{
return _gameManager.GetGame() != null && _gameManager.GetGame().GetState() == Game.GameState.Live;
}
else
{
return false;
}
}
}, this, ServicePriority.Normal);
Bukkit.setSpawnRadius(0);
//Delete Old Games Folders
DeleteFolders();