Skip to content

Commit

Permalink
Listener rewrite & more config readability
Browse files Browse the repository at this point in the history
  • Loading branch information
EvModder committed Sep 20, 2019
1 parent 15512ad commit 1f1171a
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 96 deletions.
28 changes: 21 additions & 7 deletions config.yml
@@ -1,37 +1,50 @@
# Only drop heads when killed directly by a player
player-kills-only: true

# Whether to drop heads if killed by projectile weapon from a player
# Only checked if player-kills-only is true
drop-for-ranged-kills: false

# Whether to drop heads for any death cause if last-damager is a player
# Only checked if player-kills-only is true
drop-for-indirect-kills: false

# Only drop player heads (you can also do this in "default chances" file
# by making all mobs except players have a 0% chance of dropping a head)
player-heads-only: false

# Whether to keep entity heads synced with the latest vanilla textures
refresh-textures: true

# Whether to reset the item name for a head when refreshing its texture
refresh-item-names: false

# When a player changes their skin, should old heads be updated to the
# new texture? Note: to refresh, heads must be mined or dropped
update-on-skin-change: false

# Enable the mechanic where any mob killed by a charged creeper explosion
# will drop its head with 100% probability * the spawn-cause modifier
# This setting will override "player-kills-only" (but not "player-heads-only")
# This setting overrides "player-kills-only" (but not "player-heads-only")
charged-creeper-drops: true

# A Minecraft easter egg is that mobs named 'Dinnerbone' or 'Grumm' are
# upside down.. If you want their heads to share this trait, set to true
grumm-heads: true

# Percent increase in drop chance per looting level
looting-bonus: 0.4

# Uses non-linear (taylor series modifiers) when calculating drop chance
use-taylor-modifiers: true
# Uses non-linear function when calculating drop chance looting modifier.
# If set to 'false', each looting level will add 1% to the drop chance.
use-taylor-modifiers: false

# Only drop heads if the killer used an axe
must-use-axe: false

# Enable plugin Updater (checks for new versions with new head textures)
update-plugin: true
# Note: Disabled by default because some servers have reported errors
update-plugin: false

# Run in debug mode (prints extra information to console)
debug-messages: true

# (Optional) Whitelist of tools a player must be using for heads to drop
# If "must-use-axe" is enabled, this list will be ignored
Expand All @@ -43,6 +56,7 @@ must-use:

# (Optional) Let certain tools have a higher chance of beheading
# The number is the percent increase in drop chance when using that tool
# Eg: 3 = 3x chance, 0.8 = 80% chance increase, etc.
specific-tool-modifiers:
GOLD_AXE: 3
DIAMOND_AXE: 1
Expand Down
16 changes: 8 additions & 8 deletions head-drop-rates.txt
@@ -1,21 +1,21 @@
PLAYER: 0.15
UNKNOWN: 0.0001
BAT: 0.01
BLAZE: 0.02
BLAZE: 0.009
CAT: 0.008
CAVE_SPIDER: 0.001
CHICKEN: 0.001
COD: 0.009
COW: 0.004
COW: 0.003
CREEPER: 0.04 : NoLooting
DOLPHIN: 0.01
DONKEY: 0.007
DROWNED: 0.008
DROWNED: 0.005
ELDER_GUARDIAN: 0.05
ENDER_DRAGON: 0.5
ENDERMAN: 0.005
ENDERMITE: 0.01
EVOKER: 0.15
EVOKER: 0.008
GHAST: 0.006
GIANT: 0.05
GUARDIAN: 0.004
Expand All @@ -34,7 +34,7 @@ PARROT: 0.008
PHANTOM: 0.009
PIG: 0.004
PIG_ZOMBIE: 0.002
PILLAGER: 0.01
PILLAGER: 0.008
POLAR_BEAR: 0.008
PUFFERFISH: 0.012
RABBIT: 0.003
Expand All @@ -47,21 +47,21 @@ SKELETON: 0.007
SKELETON_HORSE: 0.01
SLIME: 0.006
SNOWMAN: 0.008
SPIDER: 0.007
SPIDER: 0.006
SQUID: 0.005
STRAY: 0.009
TROPICAL_FISH: 0.02
TURTLE: 0.007
TRADER_LLAMA: 0.012
VEX: 0.007
VILLAGER: 0.007
VINDICATOR: 0.01
VINDICATOR: 0.008
WANDERING_TRADER: 0.017
WITCH: 0.004
WITHER: 0.05
WITHER_SKELETON: 0.025 # Vanilla default
WOLF: 0.007
ZOMBIE: 0.007
ZOMBIE: 0.006
ZOMBIE_HORSE: 0.007
ZOMBIE_VILLAGER: 0.008

Expand Down
2 changes: 1 addition & 1 deletion head-textures.txt
Expand Up @@ -157,7 +157,7 @@ TROPICAL_FISH|CLOWNFISH: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJ
TROPICAL_FISH|COTTON_CANDY_BETTA: xxx
TROPICAL_FISH|DOTTYBACK: xxx
TROPICAL_FISH|EMPEROR_RED_SNAPPER: xxx
TROPICAL_FISH|RED_EMPEROR: EMPEROR_RED_SNAPPER
TROPICAL_FISH|RED_EMPEROR: xxx
TROPICAL_FISH|GOATFISH: xxx
TROPICAL_FISH|MOORISH_IDOL: xxx
TROPICAL_FISH|ORNATE_BUTTERFLYFISH: xxx
Expand Down
14 changes: 7 additions & 7 deletions plugin.yml
@@ -1,36 +1,36 @@
name: DropHeads
main: net.evmodder.DropHeads.DropHeads
author: EvModder/EvilWitchdoctor
version: 3.2.8 #8=stable 1.14 release
version: 3.2.10 #10=item renaming,wither drop rate fix
api-version: 1.13

commands:
spawnhead:
description: Get a player or mob head
usage: /gethead [name]
aliases: [gethead,dhspawn,spawn-head,head,phspawn,skull]
permission: evp.dropheads.spawn
permission: dropheads.spawn
permission-message: You do not have permission to do this.

debug_all_heads:
description: Place all heads into the world around the player
usage: /debug_all_heads
permission: evp.dropheads.debug
permission: dropheads.debug
permission-message: You do not have permission to do this.

permissions:
evp.dropheads.alwaysbehead:
dropheads.alwaysbehead:
description: This player will get heads 100% of the time
default: false

evp.dropheads.canbehead:
dropheads.canbehead:
description: This player will be able to get heads
default: true

evp.dropheads.spawn:
dropheads.spawn:
description: Permission to spawn heads with a command
default: op

evp.dropheads.debug:
dropheads.debug:
description: Permission to spawn all the heads in a big cube
default: false
23 changes: 22 additions & 1 deletion src/net/evmodder/DropHeads/DropHeads.java
@@ -1,3 +1,21 @@
/*
* DropHeds - a Bukkit plugin for naturally dropping mob heads
*
* Copyright (C) 2017 - 2019 Nathan / EvModder
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.evmodder.DropHeads;

import net.evmodder.DropHeads.commands.*;
Expand All @@ -18,7 +36,10 @@ public final class DropHeads extends EvPlugin{
api = new HeadAPI();
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
getServer().getPluginManager().registerEvents(new EntityDeathListener(), this);
if(config.getBoolean("refresh-textures", true)){
if(config.getBoolean("drop-for-indirect-kills", false)){
getServer().getPluginManager().registerEvents(new EntityDamageListener(), this);
}
if(config.getBoolean("refresh-textures", false)){
getServer().getPluginManager().registerEvents(new ItemDropListener(), this);
getServer().getPluginManager().registerEvents(new BlockBreakListener(), this);
}
Expand Down
3 changes: 2 additions & 1 deletion src/net/evmodder/DropHeads/TextureKeyLookup.java
Expand Up @@ -122,7 +122,8 @@ static String getTextureKey(LivingEntity entity){
if(entity.getCustomName() != null && entity.getCustomName().equals("jeb_")) return "SHEEP|JEB";
else return "SHEEP|"+((Sheep)entity).getColor().name();
case SHULKER:
return "SHULKER|"+((Shulker)entity).getColor().name();
DyeColor color = ((Shulker)entity).getColor();
return color == null ? "SHULKER" : "SHULKER|"+color.name();
case TROPICAL_FISH:
TropicalFish f = (TropicalFish)entity;
return "TROPICAL_FISH|"+f.getBodyColor()+"|"+f.getPatternColor()+"|"+f.getPattern();
Expand Down
29 changes: 29 additions & 0 deletions src/net/evmodder/DropHeads/listeners/EntityDamageListener.java
@@ -0,0 +1,29 @@
package net.evmodder.DropHeads.listeners;

import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.metadata.FixedMetadataValue;
import net.evmodder.DropHeads.DropHeads;

public class EntityDamageListener implements Listener{
final DropHeads pl;
final boolean allowProjectileKills;

// Only enabled if drop-for-indirect-kills is TRUE
public EntityDamageListener(){
pl = DropHeads.getPlugin();
allowProjectileKills = pl.getConfig().getBoolean("drop-for-ranged-kills", false);
}
@EventHandler(priority = EventPriority.HIGH)
public void entityDamageEvent(EntityDamageByEntityEvent evt){
if(evt.isCancelled()) return;
if(evt.getDamager() instanceof Player || (allowProjectileKills && evt.getDamager() instanceof Projectile
&& ((Projectile)evt.getDamager()).getShooter() instanceof Player)){
evt.getEntity().setMetadata("PlayerDamage", new FixedMetadataValue(pl, System.currentTimeMillis()));
}
}
}

0 comments on commit 1f1171a

Please sign in to comment.