mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-07 16:27:49 +01:00
Optimize and fix pvp permission message
This commit is contained in:
parent
00e5ff18ec
commit
7fd6f967dc
@ -8,7 +8,8 @@ import com.songoda.skyblock.permission.ListeningPermission;
|
|||||||
import com.songoda.skyblock.permission.PermissionHandler;
|
import com.songoda.skyblock.permission.PermissionHandler;
|
||||||
import com.songoda.skyblock.permission.PermissionType;
|
import com.songoda.skyblock.permission.PermissionType;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -29,25 +30,22 @@ public class PvpPermission extends ListeningPermission {
|
|||||||
@PermissionHandler
|
@PermissionHandler
|
||||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||||
Player attacker = null;
|
Player attacker = null;
|
||||||
if (event.getDamager() instanceof Player)
|
if (event.getDamager() instanceof Player) {
|
||||||
attacker = (Player) event.getDamager();
|
attacker = (Player) event.getDamager();
|
||||||
else if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player)
|
} else if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player) {
|
||||||
attacker = (Player) ((Projectile) event.getDamager()).getShooter();
|
attacker = (Player) ((Projectile) event.getDamager()).getShooter();
|
||||||
|
}
|
||||||
|
|
||||||
if(attacker instanceof Player
|
if(attacker != null && event.getEntity() instanceof Player){
|
||||||
&& event.getEntity() instanceof Player){
|
|
||||||
Player victim = (Player) event.getEntity();
|
|
||||||
|
|
||||||
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
|
||||||
FileConfiguration configLoad = config.getFileConfiguration();
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
if (configLoad.getBoolean("Island.Settings.PvP.Enable")) {
|
if (configLoad.getBoolean("Island.Settings.PvP.Enable") || !configLoad.getBoolean("Island.PvP.Enable")) {
|
||||||
event.setCancelled(true);
|
|
||||||
} else if (!configLoad.getBoolean("Island.PvP.Enable")) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelAndMessage(event, victim, plugin, messageManager);
|
cancelAndMessage(event, attacker, plugin, messageManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user