Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra settings to manage drop behaviour of killed players #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/de/jeff_media/drop2inventory/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class Config {
public static final String COLLECT_BLOCK_EXP = "collect-block-exp";
public static final String COLLECT_MOB_DROPS = "collect-mob-drops";
public static final String COLLECT_MOB_EXP = "collect-mob-exp";
public static final String COLLECT_PLAYER_DROPS = "collect-player-drops";
public static final String COLLECT_PLAYER_EXP = "collect-player-exp";
public static final String AUTO_CONDENSE_ENABLED_BY_DEFAULT = "auto-condense-enabled-by-default";
public static final String FORCE_AUTO_CONDENSE = "force-auto-condense";
public static final String AUTO_SMELT_ENABLED_BY_DEFAULT = "auto-smelt-enabled-by-default";
Expand Down Expand Up @@ -77,9 +79,11 @@ public Config() {
conf.addDefault(SHOW_MESSAGE_AGAIN_AFTER_LOGOUT, true);
conf.addDefault(COLLECT_BLOCK_DROPS, true);
conf.addDefault(COLLECT_MOB_DROPS, true);
conf.addDefault(COLLECT_PLAYER_DROPS, true);
conf.addDefault(COLLECT_FISHING_DROPS, false);
conf.addDefault(COLLECT_BLOCK_EXP, true);
conf.addDefault(COLLECT_MOB_EXP, true);
conf.addDefault(COLLECT_PLAYER_EXP, true);
conf.addDefault(FORCE_AUTO_CONDENSE,false);
conf.addDefault(DETECT_LEGACY_DROPS,true);
conf.addDefault(DEFAULT_BOUNDING_BOX_RADIUS, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,16 @@ private static boolean isAllowedForEntity(Player player, Entity entity, boolean
return false;
}

if (!main.getConfig().getBoolean(Config.COLLECT_MOB_DROPS)) {
if (!main.getConfig().getBoolean(Config.COLLECT_MOB_DROPS) && !(entity instanceof Player)) {
if (main.isDebug()) main.debug("Collect mob drops is disabled");
return false;
}

if (!main.getConfig().getBoolean(Config.COLLECT_PLAYER_DROPS) && (entity instanceof Player)) {
if (main.isDebug()) main.debug("Collect player drops is disabled");
return false;
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ public void onBlockXP(BlockBreakEvent event) {

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityXP(EntityDeathEvent event) {
if(!main.getConfig().getBoolean(Config.COLLECT_MOB_EXP)) return;
if(!main.getConfig().getBoolean(Config.COLLECT_MOB_EXP) && !(event.getEntity() instanceof Player)) return;
if(!main.getConfig().getBoolean(Config.COLLECT_PLAYER_EXP) && (event.getEntity() instanceof Player)) return;
LivingEntity dead = event.getEntity();
Player killer = dead.getKiller();
if (killer == null) return;
Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,18 @@ collect-block-drops: true
collect-block-exp: true

# when set to true, mob/entity drops will be automatically collected if the plugin is enabled
# Note: Drops from entities (item frames, minecarts, etc.) count as mob drops
# Note: Drops from entities (item frames, minecarts, etc.) count as mob drops, however drops from killed players have their own setting
collect-mob-drops: true

# when set to true, mob/entity experience orbs will be automatically collected if the plugin is enabled
collect-mob-exp: true

# when set to true, inventory contents of killed players will be automatically collected if the plugin is enabled
collect-player-drops: true

# when set to true, experience orbs of killed players will be automatically collected if the plugin is enabled
collect-player-exp: true

# when set to true, fishes / drops caught via fishing will be automatically collected if the plugin is enabled
# Note: Disabled by default because this also removes the "drop flying towards player" animation
collect-fishing-drops: false
Expand Down