mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2024-10-31 22:38:48 +00:00
Merge branch 'master' of git@git.coding.net:502647092/Residence-Fix.git
This commit is contained in:
commit
d7c16fd25a
23
.classpath
Normal file
23
.classpath
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="lib" path="lib/Essentials.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/Vault.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/WorldEdit.jar"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,8 +1,3 @@
|
|||||||
# Eclipse stuff
|
|
||||||
/.classpath
|
|
||||||
/.project
|
|
||||||
/.settings
|
|
||||||
|
|
||||||
# netbeans
|
# netbeans
|
||||||
/nbproject
|
/nbproject
|
||||||
|
|
||||||
|
23
.project
Normal file
23
.project
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Residence-Fix</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
3
.settings/org.eclipse.core.resources.prefs
Normal file
3
.settings/org.eclipse.core.resources.prefs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding/<project>=UTF-8
|
||||||
|
encoding/src=UTF-8
|
5
.settings/org.eclipse.jdt.core.prefs
Normal file
5
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.7
|
4
.settings/org.eclipse.m2e.core.prefs
Normal file
4
.settings/org.eclipse.m2e.core.prefs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
package com.bekvon.bukkit.residence.listeners;
|
package com.bekvon.bukkit.residence.listeners;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
@ -66,13 +67,19 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onEndermanChangeBlock(EntityChangeBlockEvent event) {
|
public void onEndermanChangeBlock(EntityChangeBlockEvent event) {
|
||||||
if (event.getEntityType() != EntityType.ENDERMAN && event.getEntityType() != EntityType.WITHER) {
|
if (event.getEntityType() != EntityType.ENDERMAN
|
||||||
|
&& event.getEntityType() != EntityType.WITHER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FlagPermissions perms = Residence.getPermsByLoc(event.getBlock().getLocation());
|
FlagPermissions perms = Residence.getPermsByLoc(event.getBlock()
|
||||||
FlagPermissions world = Residence.getWorldFlags().getPerms(event.getBlock().getWorld().getName());
|
.getLocation());
|
||||||
|
FlagPermissions world = Residence.getWorldFlags().getPerms(
|
||||||
|
event.getBlock().getWorld().getName());
|
||||||
if (event.getEntityType() == EntityType.WITHER) {
|
if (event.getEntityType() == EntityType.WITHER) {
|
||||||
if (!perms.has("wither", perms.has("explode", world.has("wither", world.has("explode", true))))) {
|
if (!perms.has(
|
||||||
|
"wither",
|
||||||
|
perms.has("explode",
|
||||||
|
world.has("wither", world.has("explode", true))))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!perms.has("build", true)) {
|
} else if (!perms.has("build", true)) {
|
||||||
@ -87,7 +94,8 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
FlagPermissions perms = Residence.getPermsByLoc(block.getLocation());
|
FlagPermissions perms = Residence.getPermsByLoc(block.getLocation());
|
||||||
boolean hastrample = perms.has("trample", perms.has("hasbuild", true));
|
boolean hastrample = perms.has("trample", perms.has("hasbuild", true));
|
||||||
if(!hastrample && !(entity.getType() == EntityType.FALLING_BLOCK) && (mat == Material.SOIL || mat == Material.SOUL_SAND)){
|
if (!hastrample && !(entity.getType() == EntityType.FALLING_BLOCK)
|
||||||
|
&& (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,7 +105,12 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAnimal(Entity ent) {
|
private boolean isAnimal(Entity ent) {
|
||||||
return (ent instanceof Horse || ent instanceof Bat || ent instanceof Snowman || ent instanceof IronGolem || ent instanceof Ocelot || ent instanceof Pig || ent instanceof Sheep || ent instanceof Chicken || ent instanceof Wolf || ent instanceof Cow || ent instanceof Squid || ent instanceof Villager || ent instanceof Rabbit);
|
return (ent instanceof Horse || ent instanceof Bat
|
||||||
|
|| ent instanceof Snowman || ent instanceof IronGolem
|
||||||
|
|| ent instanceof Ocelot || ent instanceof Pig
|
||||||
|
|| ent instanceof Sheep || ent instanceof Chicken
|
||||||
|
|| ent instanceof Wolf || ent instanceof Cow
|
||||||
|
|| ent instanceof Squid || ent instanceof Villager || ent instanceof Rabbit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
@ -109,7 +122,8 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player cause;
|
Player cause;
|
||||||
if ((damager instanceof Arrow) && (!(((Arrow) damager).getShooter() instanceof Player))) {
|
if ((damager instanceof Arrow)
|
||||||
|
&& (!(((Arrow) damager).getShooter() instanceof Player))) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (damager instanceof Player) {
|
} else if (damager instanceof Player) {
|
||||||
@ -123,11 +137,15 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
ClaimedResidence res = Residence.getResidenceManager().getByLoc(entity.getLocation());
|
ClaimedResidence res = Residence.getResidenceManager().getByLoc(
|
||||||
|
entity.getLocation());
|
||||||
|
|
||||||
if (res != null && !res.getPermissions().playerHas(cause.getName(), "animalkilling", true)) {
|
if (res != null
|
||||||
|
&& !res.getPermissions().playerHas(cause.getName(),
|
||||||
|
"animalkilling", true)) {
|
||||||
if (isAnimal(entity)) {
|
if (isAnimal(entity)) {
|
||||||
cause.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoPermission"));
|
cause.sendMessage(ChatColor.RED
|
||||||
|
+ Residence.getLanguage().getPhrase("NoPermission"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,12 +172,15 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
if (Residence.isResAdminOn(player)) {
|
if (Residence.isResAdminOn(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FlagPermissions perms = Residence.getPermsByLocForPlayer(event.getEntity().getLocation(), player);
|
FlagPermissions perms = Residence.getPermsByLocForPlayer(event
|
||||||
|
.getEntity().getLocation(), player);
|
||||||
String pname = player.getName();
|
String pname = player.getName();
|
||||||
String world = player.getWorld().getName();
|
String world = player.getWorld().getName();
|
||||||
if (!perms.playerHas(pname, world, "place", perms.playerHas(pname, world, "build", true))) {
|
if (!perms.playerHas(pname, world, "place",
|
||||||
|
perms.playerHas(pname, world, "build", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED
|
||||||
|
+ Residence.getLanguage().getPhrase("NoPermission"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,11 +194,14 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String pname = player.getName();
|
String pname = player.getName();
|
||||||
FlagPermissions perms = Residence.getPermsByLocForPlayer(event.getEntity().getLocation(), player);
|
FlagPermissions perms = Residence.getPermsByLocForPlayer(event
|
||||||
|
.getEntity().getLocation(), player);
|
||||||
String world = event.getEntity().getWorld().getName();
|
String world = event.getEntity().getWorld().getName();
|
||||||
if (!perms.playerHas(pname, world, "destroy", perms.playerHas(pname, world, "build", true))) {
|
if (!perms.playerHas(pname, world, "destroy",
|
||||||
|
perms.playerHas(pname, world, "build", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoPermission"));
|
player.sendMessage(ChatColor.RED
|
||||||
|
+ Residence.getLanguage().getPhrase("NoPermission"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,7 +209,8 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onEntityCombust(EntityCombustEvent event) {
|
public void onEntityCombust(EntityCombustEvent event) {
|
||||||
FlagPermissions perms = Residence.getPermsByLoc(event.getEntity().getLocation());
|
FlagPermissions perms = Residence.getPermsByLoc(event.getEntity()
|
||||||
|
.getLocation());
|
||||||
if (!perms.has("burn", true)) {
|
if (!perms.has("burn", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -194,14 +219,16 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||||
EntityType entity = event.getEntityType();
|
EntityType entity = event.getEntityType();
|
||||||
FlagPermissions perms = Residence.getPermsByLoc(event.getEntity().getLocation());
|
FlagPermissions perms = Residence.getPermsByLoc(event.getEntity()
|
||||||
|
.getLocation());
|
||||||
if (entity == EntityType.CREEPER) {
|
if (entity == EntityType.CREEPER) {
|
||||||
if (!perms.has("creeper", perms.has("explode", true))) {
|
if (!perms.has("creeper", perms.has("explode", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getEntity().remove();
|
event.getEntity().remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT) {
|
if (entity == EntityType.PRIMED_TNT
|
||||||
|
|| entity == EntityType.MINECART_TNT) {
|
||||||
if (!perms.has("tnt", perms.has("explode", true))) {
|
if (!perms.has("tnt", perms.has("explode", true))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getEntity().remove();
|
event.getEntity().remove();
|
||||||
@ -233,14 +260,17 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
Boolean cancel = false;
|
Boolean cancel = false;
|
||||||
EntityType entity = event.getEntityType();
|
EntityType entity = event.getEntityType();
|
||||||
FlagPermissions perms = Residence.getPermsByLoc(event.getEntity().getLocation());
|
FlagPermissions perms = Residence.getPermsByLoc(event.getEntity()
|
||||||
FlagPermissions world = Residence.getWorldFlags().getPerms(event.getEntity().getWorld().getName());
|
.getLocation());
|
||||||
|
FlagPermissions world = Residence.getWorldFlags().getPerms(
|
||||||
|
event.getEntity().getWorld().getName());
|
||||||
if (entity == EntityType.CREEPER) {
|
if (entity == EntityType.CREEPER) {
|
||||||
if (!perms.has("creeper", perms.has("explode", true))) {
|
if (!perms.has("creeper", perms.has("explode", true))) {
|
||||||
cancel = true;
|
cancel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT) {
|
if (entity == EntityType.PRIMED_TNT
|
||||||
|
|| entity == EntityType.MINECART_TNT) {
|
||||||
if (!perms.has("tnt", perms.has("explode", true))) {
|
if (!perms.has("tnt", perms.has("explode", true))) {
|
||||||
cancel = true;
|
cancel = true;
|
||||||
}
|
}
|
||||||
@ -256,7 +286,10 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entity == EntityType.WITHER_SKULL || entity == EntityType.WITHER) {
|
if (entity == EntityType.WITHER_SKULL || entity == EntityType.WITHER) {
|
||||||
if (!perms.has("wither", perms.has("explode", world.has("wither", world.has("explode", true))))) {
|
if (!perms.has(
|
||||||
|
"wither",
|
||||||
|
perms.has("explode",
|
||||||
|
world.has("wither", world.has("explode", true))))) {
|
||||||
cancel = true;
|
cancel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,8 +299,16 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
List<Block> preserve = new ArrayList<Block>();
|
List<Block> preserve = new ArrayList<Block>();
|
||||||
for (Block block : event.blockList()) {
|
for (Block block : event.blockList()) {
|
||||||
FlagPermissions blockperms = Residence.getPermsByLoc(block.getLocation());
|
FlagPermissions blockperms = Residence.getPermsByLoc(block
|
||||||
if ((!blockperms.has("wither", blockperms.has("explode", world.has("wither", world.has("explode", true)))) && (entity == EntityType.WITHER || entity == EntityType.WITHER_SKULL) || (!blockperms.has("fireball", blockperms.has("explode", true)) && (entity == EntityType.FIREBALL || entity == EntityType.SMALL_FIREBALL)) || (!blockperms.has("tnt", blockperms.has("explode", true)) && (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT)) || (!blockperms.has("creeper", blockperms.has("explode", true)) && entity == EntityType.CREEPER))) {
|
.getLocation());
|
||||||
|
if ((!blockperms.has("wither", blockperms.has("explode",
|
||||||
|
world.has("wither", world.has("explode", true))))
|
||||||
|
&& (entity == EntityType.WITHER || entity == EntityType.WITHER_SKULL)
|
||||||
|
|| (!blockperms.has("fireball",
|
||||||
|
blockperms.has("explode", true)) && (entity == EntityType.FIREBALL || entity == EntityType.SMALL_FIREBALL))
|
||||||
|
|| (!blockperms.has("tnt",
|
||||||
|
blockperms.has("explode", true)) && (entity == EntityType.PRIMED_TNT || entity == EntityType.MINECART_TNT)) || (!blockperms
|
||||||
|
.has("creeper", blockperms.has("explode", true)) && entity == EntityType.CREEPER))) {
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
preserve.add(block);
|
preserve.add(block);
|
||||||
}
|
}
|
||||||
@ -284,12 +325,14 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
Entity ent = event.getEntity();
|
Entity ent = event.getEntity();
|
||||||
boolean srcpvp = Residence.getPermsByLoc(ent.getLocation()).has("pvp", true);
|
boolean srcpvp = Residence.getPermsByLoc(ent.getLocation()).has("pvp",
|
||||||
|
true);
|
||||||
Iterator<LivingEntity> it = event.getAffectedEntities().iterator();
|
Iterator<LivingEntity> it = event.getAffectedEntities().iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
LivingEntity target = it.next();
|
LivingEntity target = it.next();
|
||||||
if (target.getType() == EntityType.PLAYER) {
|
if (target.getType() == EntityType.PLAYER) {
|
||||||
Boolean tgtpvp = Residence.getPermsByLoc(target.getLocation()).has("pvp", true);
|
Boolean tgtpvp = Residence.getPermsByLoc(target.getLocation())
|
||||||
|
.has("pvp", true);
|
||||||
if (!srcpvp || !tgtpvp) {
|
if (!srcpvp || !tgtpvp) {
|
||||||
event.setIntensity(target, 0);
|
event.setIntensity(target, 0);
|
||||||
}
|
}
|
||||||
@ -299,13 +342,15 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
||||||
if (event.getEntityType() == EntityType.ITEM_FRAME || event.getEntityType() == EntityType.ARMOR_STAND) {
|
if (event.getEntityType() == EntityType.ITEM_FRAME
|
||||||
|
|| event.getEntityType() == EntityType.ARMOR_STAND) {
|
||||||
Entity dmgr = event.getDamager();
|
Entity dmgr = event.getDamager();
|
||||||
Player player;
|
Player player;
|
||||||
if (event.getDamager() instanceof Player) {
|
if (dmgr instanceof Player) {
|
||||||
player = (Player) event.getDamager();
|
player = (Player) event.getDamager();
|
||||||
} else {
|
} else {
|
||||||
if (dmgr instanceof Projectile && ((Projectile) dmgr).getShooter() instanceof Player) {
|
if (dmgr instanceof Projectile
|
||||||
|
&& ((Projectile) dmgr).getShooter() instanceof Player) {
|
||||||
player = (Player) ((Projectile) dmgr).getShooter();
|
player = (Player) ((Projectile) dmgr).getShooter();
|
||||||
} else
|
} else
|
||||||
return;
|
return;
|
||||||
@ -314,12 +359,26 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
if (Residence.isResAdminOn(player))
|
if (Residence.isResAdminOn(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Note: Location of entity, not player; otherwise player could stand outside of res and still damage
|
// Note: Location of entity, not player; otherwise player could
|
||||||
|
// stand outside of res and still damage
|
||||||
Location loc = event.getEntity().getLocation();
|
Location loc = event.getEntity().getLocation();
|
||||||
ClaimedResidence res = Residence.getResidenceManager().getByLoc(loc);
|
ClaimedResidence res = Residence.getResidenceManager()
|
||||||
if (res != null && !res.getPermissions().playerHas(player.getName(), "container", false)) {
|
.getByLoc(loc);
|
||||||
|
if (res != null) {
|
||||||
|
if (!res.getPermissions().has("container", false)) {
|
||||||
|
if (isMonster(dmgr)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("FlagDeny", "container"));
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!res.getPermissions().playerHas(player.getName(),
|
||||||
|
"container", false)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
player.sendMessage(ChatColor.RED
|
||||||
|
+ Residence.getLanguage().getPhrase("FlagDeny",
|
||||||
|
"container"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -330,22 +389,27 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
if (ent.hasMetadata("NPC")) {
|
if (ent.hasMetadata("NPC")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean tamedWolf = ent instanceof Wolf ? ((Wolf)ent).isTamed() : false;
|
boolean tamedWolf = ent instanceof Wolf ? ((Wolf) ent).isTamed()
|
||||||
ClaimedResidence area = Residence.getResidenceManager().getByLoc(ent.getLocation());
|
: false;
|
||||||
|
ClaimedResidence area = Residence.getResidenceManager().getByLoc(
|
||||||
|
ent.getLocation());
|
||||||
/* Living Entities */
|
/* Living Entities */
|
||||||
if (event instanceof EntityDamageByEntityEvent) {
|
if (event instanceof EntityDamageByEntityEvent) {
|
||||||
EntityDamageByEntityEvent attackevent = (EntityDamageByEntityEvent) event;
|
EntityDamageByEntityEvent attackevent = (EntityDamageByEntityEvent) event;
|
||||||
Entity damager = attackevent.getDamager();
|
Entity damager = attackevent.getDamager();
|
||||||
ClaimedResidence srcarea = null;
|
ClaimedResidence srcarea = null;
|
||||||
if (damager != null) {
|
if (damager != null) {
|
||||||
srcarea = Residence.getResidenceManager().getByLoc(damager.getLocation());
|
srcarea = Residence.getResidenceManager().getByLoc(
|
||||||
|
damager.getLocation());
|
||||||
}
|
}
|
||||||
boolean srcpvp = true;
|
boolean srcpvp = true;
|
||||||
if (srcarea != null) {
|
if (srcarea != null) {
|
||||||
srcpvp = srcarea.getPermissions().has("pvp", true);
|
srcpvp = srcarea.getPermissions().has("pvp", true);
|
||||||
}
|
}
|
||||||
ent = attackevent.getEntity();
|
ent = attackevent.getEntity();
|
||||||
if ((ent instanceof Player || tamedWolf) && (damager instanceof Player || (damager instanceof Arrow && (((Arrow)damager).getShooter() instanceof Player)))) {
|
if ((ent instanceof Player || tamedWolf)
|
||||||
|
&& (damager instanceof Player || (damager instanceof Arrow && (((Arrow) damager)
|
||||||
|
.getShooter() instanceof Player)))) {
|
||||||
Player attacker = null;
|
Player attacker = null;
|
||||||
if (damager instanceof Player) {
|
if (damager instanceof Player) {
|
||||||
attacker = (Player) damager;
|
attacker = (Player) damager;
|
||||||
@ -353,28 +417,38 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
attacker = (Player) ((Arrow) damager).getShooter();
|
attacker = (Player) ((Arrow) damager).getShooter();
|
||||||
}
|
}
|
||||||
if (!srcpvp) {
|
if (!srcpvp) {
|
||||||
attacker.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("NoPVPZone"));
|
attacker.sendMessage(ChatColor.RED
|
||||||
|
+ Residence.getLanguage().getPhrase("NoPVPZone"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Check for Player vs Player */
|
/* Check for Player vs Player */
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
/* World PvP */
|
/* World PvP */
|
||||||
if (!Residence.getWorldFlags().getPerms(damager.getWorld().getName()).has("pvp", true)) {
|
if (!Residence.getWorldFlags()
|
||||||
attacker.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("WorldPVPDisabled"));
|
.getPerms(damager.getWorld().getName())
|
||||||
|
.has("pvp", true)) {
|
||||||
|
attacker.sendMessage(ChatColor.RED
|
||||||
|
+ Residence.getLanguage().getPhrase(
|
||||||
|
"WorldPVPDisabled"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Normal PvP */
|
/* Normal PvP */
|
||||||
if (!area.getPermissions().has("pvp", true)) {
|
if (!area.getPermissions().has("pvp", true)) {
|
||||||
attacker.sendMessage(ChatColor.RED+Residence.getLanguage().getPhrase("NoPVPZone"));
|
attacker.sendMessage(ChatColor.RED
|
||||||
|
+ Residence.getLanguage()
|
||||||
|
.getPhrase("NoPVPZone"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if ((ent instanceof Player || tamedWolf) && (damager instanceof Creeper)) {
|
} else if ((ent instanceof Player || tamedWolf)
|
||||||
|
&& (damager instanceof Creeper)) {
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
if (!Residence.getWorldFlags().getPerms(damager.getWorld().getName()).has("creeper", true)) {
|
if (!Residence.getWorldFlags()
|
||||||
|
.getPerms(damager.getWorld().getName())
|
||||||
|
.has("creeper", true)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -385,19 +459,22 @@ public class ResidenceEntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
if (!Residence.getWorldFlags().getPerms(ent.getWorld().getName()).has("damage", true) && (ent instanceof Player || tamedWolf)) {
|
if (!Residence.getWorldFlags().getPerms(ent.getWorld().getName())
|
||||||
|
.has("damage", true)
|
||||||
|
&& (ent instanceof Player || tamedWolf)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!area.getPermissions().has("damage", true) && (ent instanceof Player || tamedWolf)) {
|
if (!area.getPermissions().has("damage", true)
|
||||||
|
&& (ent instanceof Player || tamedWolf)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
/* Put out a fire on a player */
|
/* Put out a fire on a player */
|
||||||
if ((ent instanceof Player || tamedWolf)
|
if ((ent instanceof Player || tamedWolf)
|
||||||
&& (event.getCause() == EntityDamageEvent.DamageCause.FIRE
|
&& (event.getCause() == EntityDamageEvent.DamageCause.FIRE || event
|
||||||
|| event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK)) {
|
.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK)) {
|
||||||
ent.setFireTicks(0);
|
ent.setFireTicks(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user