Skip to content

Commit

Permalink
Merge pull request #1 from BitByLogics/main
Browse files Browse the repository at this point in the history
Code overhaul/cleanup
  • Loading branch information
FrankTCA authored May 29, 2024
2 parents 11ae51c + 443f0b0 commit 9d0e208
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 286 deletions.
43 changes: 43 additions & 0 deletions src/main/java/org/infotoast/dropsoverhaul/DropsOverhaul.java
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 src/main/java/org/infotoast/dropsoverhaul/ItemLists.java

This file was deleted.

110 changes: 0 additions & 110 deletions src/main/java/org/infotoast/dropsoverhaul/Listener.java

This file was deleted.

61 changes: 0 additions & 61 deletions src/main/java/org/infotoast/dropsoverhaul/Plugin.java

This file was deleted.

Loading

0 comments on commit 9d0e208

Please sign in to comment.