-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Downsize classes - Overhaul config.yml - Take advantage of BlockDropItemEvent for drop logic - Allow configuration of drops to remove - Add /dropsoverhaul command - Add /dropsoverhaul reload to reload configuration - Rename /killdrops to /dropsoverhaul killdrops - Allow messages to be configured in config.yml - Remove default-everyone-killdrops option, permission can just be negated - Add BitByLogic to authors
- Loading branch information
1 parent
11ae51c
commit 443f0b0
Showing
7 changed files
with
170 additions
and
286 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/main/java/org/infotoast/dropsoverhaul/DropsOverhaul.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.infotoast.dropsoverhaul; | ||
|
||
import org.bukkit.entity.Item; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.block.BlockDropItemEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
import org.infotoast.dropsoverhaul.command.DropsOverhaulCommand; | ||
|
||
import java.util.HashMap; | ||
|
||
public class DropsOverhaul extends JavaPlugin implements Listener { | ||
|
||
@Override | ||
public void onEnable() { | ||
saveDefaultConfig(); | ||
|
||
getCommand("dropsoverhaul").setExecutor(new DropsOverhaulCommand(this)); | ||
getServer().getPluginManager().registerEvents(this, this); | ||
|
||
getLogger().info("DropsOverhaul has been enabled!"); | ||
} | ||
|
||
@EventHandler | ||
public void onBlockDrop(BlockDropItemEvent event) { | ||
if (!getConfig().getStringList("Settings.Drops-To-Remove").contains(event.getBlockState().getType().name())) { | ||
return; | ||
} | ||
|
||
event.setCancelled(true); | ||
|
||
ItemStack[] items = event.getItems().stream().map(Item::getItemStack).toArray(ItemStack[]::new); | ||
HashMap<Integer, ItemStack> leftOver = event.getPlayer().getInventory().addItem(items); | ||
|
||
if (leftOver.isEmpty() || getConfig().getBoolean("Settings.Full-Inventory-Delete")) { | ||
return; | ||
} | ||
|
||
leftOver.values().forEach(item -> event.getPlayer().getWorld().dropItemNaturally(event.getPlayer().getLocation(), item)); | ||
} | ||
|
||
} |
100 changes: 0 additions & 100 deletions
100
src/main/java/org/infotoast/dropsoverhaul/ItemLists.java
This file was deleted.
Oops, something went wrong.
110 changes: 0 additions & 110 deletions
110
src/main/java/org/infotoast/dropsoverhaul/Listener.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.