Skip to content

Commit

Permalink
Add allow-mob-drops flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dumbo52 committed Oct 21, 2014
1 parent 26e33a8 commit b391240
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Available flags:
|-----------------------|---------------|
| compass | true |
| allow-drops | true |
| allow-mob-drops | true |
| sprint | true |
| use-dispenser | true |
| use-note-block | false |
| use-workbench | true |
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.michaelelin</groupId>
<artifactId>NerdFlags</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.1</version>
<build>
<sourceDirectory>${basedir}/src</sourceDirectory>
<resources>
Expand Down
11 changes: 10 additions & 1 deletion src/com/michaelelin/NerdFlags/NerdFlagsListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
Expand Down Expand Up @@ -38,7 +39,15 @@ public void onItemSpawn(ItemSpawnEvent event) {
}
}

// WE checks this at a NORMAL priority, so we'll intercept it beforehand.
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDeath(EntityDeathEvent event) {
ApplicableRegionSet setAtLocation = worldguard.getGlobalRegionManager().get(event.getEntity().getLocation().getWorld()).getApplicableRegions(event.getEntity().getLocation());
if (!setAtLocation.allows(plugin.ALLOW_MOB_DROPS)) {
event.getDrops().clear();
}
}

// WE checks this at a NORMAL priority, so we'll intercept it beforehand.
@EventHandler(priority = EventPriority.LOW)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getItem() != null && event.getItem().getTypeId() == worldedit.getWorldEdit().getConfiguration().navigationWand) {
Expand Down
5 changes: 5 additions & 0 deletions src/com/michaelelin/NerdFlags/NerdFlagsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class NerdFlagsPlugin extends JavaPlugin {
private long timestamp;

public StateFlag ALLOW_DROPS;
public StateFlag ALLOW_MOB_DROPS;

public StateFlag COMPASS;

Expand Down Expand Up @@ -52,12 +53,16 @@ public void onEnable() {
getServer().getPluginManager().registerEvents(listener, this);

ALLOW_DROPS = new StateFlag("allow-drops", true);
ALLOW_MOB_DROPS = new StateFlag("allow-mob-drops", true);
COMPASS = new StateFlag("compass", true);

wgCustomFlagsPlugin.addCustomFlag(ALLOW_DROPS);
wgCustomFlagsPlugin.addCustomFlag(ALLOW_MOB_DROPS);
wgCustomFlagsPlugin.addCustomFlag(COMPASS);

saveDefaultConfig();
loadConfig();

wgCustomFlagsPlugin.addCustomFlag(USE_DISPENSER);
wgCustomFlagsPlugin.addCustomFlag(USE_NOTE_BLOCK);
wgCustomFlagsPlugin.addCustomFlag(USE_WORKBENCH);
Expand Down

0 comments on commit b391240

Please sign in to comment.