Skip to content

Commit

Permalink
Feature requests
Browse files Browse the repository at this point in the history
  • Loading branch information
MrButtersDEV committed Aug 18, 2023
1 parent 576c747 commit 5f0e3de
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>us.thezircon.play</groupId>
<artifactId>AutoPickup</artifactId>
<version>1.4.2-SNAPSHOT</version>
<version>1.4.3-SNAPSHOT</version>
<packaging>jar</packaging>

<name>AutoPickup</name>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/us/thezircon/play/autopickup/AutoPickup.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void onEnable() {
getServer().getPluginManager().registerEvents(new PlayerInteractEventListener(), this);
getServer().getPluginManager().registerEvents(new PlayerDropItemEventListener(), this);
getServer().getPluginManager().registerEvents(new ItemSpawnEventListener(), this);

getServer().getPluginManager().registerEvents(new EntityDropItemEventListener(), this);


if (usingMythicMobs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ public void onBreak(BlockBreakEvent e) {
return;
}

Bukkit.getScheduler().runTaskAsynchronously(PLUGIN, new Runnable() {
@Override
public void run() {
if (!player.hasPermission("autopickup.pickup.mined")) {
PLUGIN.autopickup_list.remove(player);
}
if (!player.hasPermission("autopickup.pickup.mined.autosmelt")) {
PLUGIN.auto_smelt_blocks.remove(player);
}
}
});

Block block = e.getBlock();
Location loc = e.getBlock().getLocation();
boolean doFullInvMSG = PLUGIN.getConfig().getBoolean("doFullInvMSG");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package us.thezircon.play.autopickup.listeners;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -31,7 +32,16 @@ public void onDeath(EntityDeathEvent e) {
Player player = e.getEntity().getKiller();

if (!PLUGIN.autopickup_list_mobs.contains(player)) return;


Bukkit.getScheduler().runTaskAsynchronously(PLUGIN, new Runnable() {
@Override
public void run() {
if (!player.hasPermission("autopickup.pickup.entities")) {
PLUGIN.autopickup_list_mobs.remove(player);
}
}
});

boolean doFullInvMSG = PLUGIN.getConfig().getBoolean("doFullInvMSG");

Location loc = e.getEntity().getKiller().getLocation();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package us.thezircon.play.autopickup.listeners;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDropItemEvent;
import org.bukkit.event.player.PlayerShearEntityEvent;
import org.bukkit.inventory.ItemStack;
import us.thezircon.play.autopickup.AutoPickup;

import java.util.HashMap;
import java.util.Iterator;
import java.util.UUID;

public class EntityDropItemEventListener implements Listener {

private static final AutoPickup PLUGIN = AutoPickup.getPlugin(AutoPickup.class);

private static HashMap<UUID, UUID> player_sheep_map = new HashMap<>();

@EventHandler
public void onSheer(PlayerShearEntityEvent e) {
player_sheep_map.put(e.getEntity().getUniqueId(), e.getPlayer().getUniqueId());
}

@EventHandler
public void onDrop(EntityDropItemEvent e) {

boolean doFullInvMSG = PLUGIN.getConfig().getBoolean("doFullInvMSG");

if (AutoPickup.worldsBlacklist!=null && AutoPickup.worldsBlacklist.contains(e.getEntity().getWorld().getName())) {
return;
}

UUID sheep = e.getEntity().getUniqueId();
if (player_sheep_map.containsKey(sheep)) {
Player player = Bukkit.getPlayer(player_sheep_map.get(sheep));
if (!PLUGIN.autopickup_list.contains(player)) {
return;
}

// Drops
ItemStack drops = e.getItemDrop().getItemStack();
e.getItemDrop().remove();
HashMap<Integer, ItemStack> leftOver = player.getInventory().addItem(drops);
if (leftOver.keySet().size()>0) {
for (ItemStack item : leftOver.values()) {
player.getWorld().dropItemNaturally(e.getItemDrop().getLocation(), item);
}
if (doFullInvMSG) {
long secondsLeft;
long cooldown = 15000; // 15 sec
if (AutoPickup.lastInvFullNotification.containsKey(player.getUniqueId())) {
secondsLeft = (AutoPickup.lastInvFullNotification.get(player.getUniqueId())/1000)+ cooldown/1000 - (System.currentTimeMillis()/1000);
} else {
secondsLeft = 0;
}
if (secondsLeft<=0) {
player.sendMessage(PLUGIN.getMsg().getPrefix() + " " + PLUGIN.getMsg().getFullInventory());
AutoPickup.lastInvFullNotification.put(player.getUniqueId(), System.currentTimeMillis());
}
}
}

Bukkit.getScheduler().runTaskAsynchronously(PLUGIN, new Runnable() {
@Override
public void run() {
if (!player.hasPermission("autopickup.pickup.mined")) {
PLUGIN.autopickup_list.remove(player);
}
}
});
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import org.bukkit.Tag;
import org.bukkit.entity.Player;
import org.bukkit.inventory.*;
import us.thezircon.play.autopickup.AutoPickup;

import java.util.*;

public class AutoSmelt {

private static final AutoPickup PLUGIN = AutoPickup.getPlugin(AutoPickup.class);

public boolean isAutoSmeltEnabled = false;
public static Material[] ignore = {Material.COAL_ORE, Material.REDSTONE_ORE, Material.DIAMOND_ORE, Material.EMERALD_ORE, Material.LAPIS_ORE, Material.NETHER_QUARTZ_ORE};
public static List<Material> ignoreMaterials = Arrays.asList(ignore);
Expand All @@ -19,11 +22,16 @@ public boolean isEnabled() {
}

public static ItemStack smelt(ItemStack itemStack, Player player) {
List<String> blacklist = PLUGIN.getBlacklistConf().getStringList("AutoSmeltBlacklist");

if (ignoreMaterials.contains(itemStack.getType())) {
return itemStack;
}

if (blacklist.contains(itemStack.getType().toString())) {
return itemStack;
}

ItemStack result = itemStack;
Iterator<Recipe> iter = Bukkit.recipeIterator();
while (iter.hasNext()) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/us/thezircon/play/autopickup/utils/VersionChk.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import us.thezircon.play.autopickup.AutoPickup;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Arrays;
import java.util.logging.Logger;

import static com.google.common.net.HttpHeaders.USER_AGENT;
Expand Down Expand Up @@ -58,7 +60,17 @@ public static void checkVersion(String name, int id) throws Exception { //https:

// Config Version:
double configVersion = PLUGIN.getConfig().getDouble("ConfigVersion");
if (configVersion<=1.2) {
PLUGIN.getConfig().set("ConfigVersion", 1.3);
PLUGIN.getBlacklistConf().set("doAutoSmeltBlacklist", false);
PLUGIN.getBlacklistConf().set("AutoSmeltBlacklist", Arrays.asList("OAK_LOG"));

File conf = new File(PLUGIN.getDataFolder(), "config.yml");
File fileBlacklist = new File(PLUGIN.getDataFolder(), "blacklist.yml");

PLUGIN.getConfig().save(conf);
PLUGIN.getBlacklistConf().save(fileBlacklist);
}


}
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/blacklist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#Set to "true" if you would like to enable the blacklist
doBlacklisted: false
doBlacklistedEntities: true
doAutoSmeltBlacklist: false

#By listing blocks below you are adding them to the blacklist therefore causing them to drop to the ground.
Blacklisted:
Expand All @@ -28,3 +29,7 @@ BlacklistedEntities:

BlacklistedWorlds:
- example

#These materials will be ignored when auto smelt is enabled. Only items that can be smelted should be added.
AutoSmeltBlacklist:
- OAK_LOG
2 changes: 1 addition & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ConfigVersion: 1.2
ConfigVersion: 1.3
#############################################################################################################
# _ _____ _ _ #
# /\ | | | __ \ (_) | | #
Expand Down
5 changes: 5 additions & 0 deletions target/classes/blacklist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#Set to "true" if you would like to enable the blacklist
doBlacklisted: false
doBlacklistedEntities: true
doAutoSmeltBlacklist: false

#By listing blocks below you are adding them to the blacklist therefore causing them to drop to the ground.
Blacklisted:
Expand All @@ -28,3 +29,7 @@ BlacklistedEntities:

BlacklistedWorlds:
- example

#These materials will be ignored when auto smelt is enabled. Only items that can be smelted should be added.
AutoSmeltBlacklist:
- OAK_LOG
2 changes: 1 addition & 1 deletion target/classes/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ConfigVersion: 1.2
ConfigVersion: 1.3
#############################################################################################################
# _ _____ _ _ #
# /\ | | | __ \ (_) | | #
Expand Down
2 changes: 1 addition & 1 deletion target/classes/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: AutoPickup
version: 1.4.2-SNAPSHOT
version: 1.4.3-SNAPSHOT
main: us.thezircon.play.autopickup.AutoPickup
prefix: AutoPickup
authors: [BUTTERFIELD8]
Expand Down

0 comments on commit 5f0e3de

Please sign in to comment.