-
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.
Merge pull request #1 from BitByLogics/main
Code overhaul/cleanup
- Loading branch information
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.