BlockState Hanging Punch in 1.7.2
This commit is contained in:
parent
8a76616969
commit
06e08c630e
3 changed files with 35 additions and 3 deletions
4
pom.xml
4
pom.xml
|
@ -3,13 +3,13 @@
|
||||||
<groupId>de.jaschastarke</groupId>
|
<groupId>de.jaschastarke</groupId>
|
||||||
<artifactId>LimitedCreative</artifactId>
|
<artifactId>LimitedCreative</artifactId>
|
||||||
<name>LimitedCreative</name>
|
<name>LimitedCreative</name>
|
||||||
<version>2.2-SNAPSHOT</version>
|
<version>2.3-SNAPSHOT</version>
|
||||||
<url>https://github.com/possi/LimitedCreative</url>
|
<url>https://github.com/possi/LimitedCreative</url>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<plib.version>1.4-SNAPSHOT</plib.version>
|
<plib.version>1.4-SNAPSHOT</plib.version>
|
||||||
<bukkit.version>1.6.4-R1.0</bukkit.version>
|
<bukkit.version>1.7.2-R0.1-SNAPSHOT</bukkit.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
|
|
|
@ -5,9 +5,11 @@ import java.util.Date;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.ItemFrame;
|
import org.bukkit.entity.ItemFrame;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
|
@ -48,6 +50,34 @@ public class HangingListener implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
public void onPlayerLeftInteractEntity(EntityDamageByEntityEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getEntity().getWorld().getName()))
|
||||||
|
return;
|
||||||
|
if (event.getDamager() instanceof Player && event.getEntity() instanceof ItemFrame) {
|
||||||
|
if (mod.getModel().isRestricted(event.getEntity().getLocation().getBlock())) {
|
||||||
|
if (mod.isDebug())
|
||||||
|
mod.getLog().debug("Modifying hanging: " + event.getEntity().getLocation().toString());
|
||||||
|
|
||||||
|
if (((Player) event.getDamager()).getGameMode() != GameMode.CREATIVE) {
|
||||||
|
if (mod.isDebug())
|
||||||
|
mod.getLog().debug("... was placed by creative. Modify prevented");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
BlockState s = new BlockState();
|
||||||
|
s.setLocation(event.getEntity().getLocation().getBlock().getLocation());
|
||||||
|
s.setPlayer((Player) event.getDamager());
|
||||||
|
s.setDate(new Date());
|
||||||
|
|
||||||
|
if (mod.isDebug())
|
||||||
|
mod.getLog().debug("Saving BlockState: " + s.toString());
|
||||||
|
|
||||||
|
mod.getModel().setState(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onHangingBreak(HangingBreakEvent event) {
|
public void onHangingBreak(HangingBreakEvent event) {
|
||||||
|
|
|
@ -92,7 +92,9 @@ public class GMPermConfig extends Configuration implements IConfigurationSubGrou
|
||||||
*/
|
*/
|
||||||
@IsConfigurationNode(order = 300)
|
@IsConfigurationNode(order = 300)
|
||||||
public String getAdventureGroup() {
|
public String getAdventureGroup() {
|
||||||
return config.getString("adventureGroup");
|
if (config.isBoolean("adventureGroup"))
|
||||||
|
return null;
|
||||||
|
return config.getString("adventureGroup", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue