1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Removed a bunch of deprecated code

This commit is contained in:
TheBusyBiscuit 2019-08-30 12:13:45 +02:00
parent 5793508144
commit 7e63ad9040
5 changed files with 46 additions and 63 deletions

View File

@ -58,7 +58,6 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.Block.TreeCalculator;
import me.mrCookieSlime.CSCoreLibPlugin.general.Block.Vein;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.SkullItem;
import me.mrCookieSlime.CSCoreLibPlugin.general.Math.DoubleHandler;
import me.mrCookieSlime.CSCoreLibPlugin.general.Particles.FireworkShow;
import me.mrCookieSlime.CSCoreLibPlugin.general.Player.PlayerInventory;
@ -2351,20 +2350,14 @@ public final class SlimefunSetup {
for (int i = 0; i < 2; i++) {
gifts.add(new CustomItem(SlimefunItems.EASTER_CARROT_PIE, 4));
gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_APPLE_PIE, 4));
gifts.add(new CustomItem(SlimefunItems.CARROT_JUICE, 1));
gifts.add(new ItemStack(Material.EMERALD));
gifts.add(new ItemStack(Material.CAKE));
gifts.add(new ItemStack(Material.RABBIT_FOOT));
gifts.add(new ItemStack(Material.GOLDEN_CARROT, 4));
}
gifts.add(new SkullItem("TheBusyBiscuit"));
gifts.add(new SkullItem("timtower"));
gifts.add(new SkullItem("bwfcwalshy"));
gifts.add(new SkullItem("jadedcat"));
gifts.add(new SkullItem("ZeldoKavira"));
gifts.add(new SkullItem("eyamaz"));
gifts.add(new SkullItem("Kaelten"));
gifts.add(new SkullItem("Myrathi"));
p.getWorld().dropItemNaturally(p.getLocation(), gifts.get(SlimefunStartup.randomize(gifts.size())));
p.getWorld().dropItemNaturally(p.getLocation(), gifts.get(random.nextInt(gifts.size())));
return true;
}
else return false;

View File

@ -1,7 +1,7 @@
package me.mrCookieSlime.Slimefun.api;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
@ -9,31 +9,31 @@ import org.bukkit.inventory.ItemStack;
import me.mrCookieSlime.Slimefun.SlimefunStartup;
@Deprecated
public class Soul {
public final class Soul {
public static void storeItem(UUID uuid, ItemStack drop) {
List<ItemStack> items = new ArrayList<>();
if (SlimefunStartup.instance.getUtilities().soulbound.containsKey(uuid)) items = SlimefunStartup.instance.getUtilities().soulbound.get(uuid);
items.add(drop);
SlimefunStartup.instance.getUtilities().soulbound.put(uuid, items);
private Soul() {}
public static void storeItem(UUID uuid, int slot, ItemStack item) {
Map<Integer, ItemStack> items = SlimefunStartup.instance.getUtilities().soulbound.get(uuid);
if (items == null) {
items = new HashMap<>();
SlimefunStartup.instance.getUtilities().soulbound.put(uuid, items);
}
items.put(slot, item);
}
public static void retrieveItems(Player p) {
if (SlimefunStartup.instance.getUtilities().soulbound.containsKey(p.getUniqueId())) {
for (ItemStack item: SlimefunStartup.instance.getUtilities().soulbound.get(p.getUniqueId())) {
if (item.equals(p.getInventory().getHelmet())) continue;
if (item.equals(p.getInventory().getChestplate())) continue;
if (item.equals(p.getInventory().getLeggings())) continue;
if (item.equals(p.getInventory().getBoots())) continue;
if (item.equals(p.getInventory().getItemInOffHand())) continue;
if(!p.getInventory().contains(item)) {
p.getInventory().addItem(item);
}
Map<Integer, ItemStack> items = SlimefunStartup.instance.getUtilities().soulbound.get(p.getUniqueId());
if (items != null) {
for (Map.Entry<Integer, ItemStack> entry: items.entrySet()) {
p.getInventory().setItem(entry.getKey(), entry.getValue());
}
SlimefunStartup.instance.getUtilities().soulbound.remove(p.getUniqueId());
}
SlimefunStartup.instance.getUtilities().soulbound.remove(p.getUniqueId());
}
}

View File

@ -56,19 +56,18 @@ public class DamageListener implements Listener {
Slimefun.getGPSNetwork().addWaypoint(p, "&4Deathpoint &7" + format.format(new Date()), p.getLocation().getBlock().getLocation());
}
for (int slot = 0; slot < p.getInventory().getSize(); slot++) {
ItemStack item = p.getInventory().getItem(slot);
if (isSoulbound(item)) {
Soul.storeItem(p.getUniqueId(), slot, item);
}
}
Iterator<ItemStack> drops = e.getDrops().iterator();
while (drops.hasNext()) {
ItemStack item = drops.next();
if (item != null) {
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.BOUND_BACKPACK, false)) {
Soul.storeItem(e.getEntity().getUniqueId(), item);
drops.remove();
}
else if (SlimefunItem.getByItem(removeEnchantments(item)) instanceof SoulboundItem) {
Soul.storeItem(e.getEntity().getUniqueId(), item);
drops.remove();
}
}
if (isSoulbound(item)) drops.remove();
}
}
@ -133,7 +132,14 @@ public class DamageListener implements Listener {
}
}
@EventHandler
private boolean isSoulbound(ItemStack item) {
if (item == null || item.getType() == null || item.getType() == Material.AIR) return false;
else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.BOUND_BACKPACK, false)) return true;
else if (SlimefunItem.getByItem(removeEnchantments(item)) instanceof SoulboundItem) return true;
else return false;
}
@EventHandler
public void onArrowHit(EntityDamageEvent e) {
if (e.getEntity() instanceof Player && e.getCause() == DamageCause.FALL && utilities.damage.contains(e.getEntity().getUniqueId())) {
e.setCancelled(true);

View File

@ -22,7 +22,6 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.inventory.ItemStack;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.SkullItem;
import me.mrCookieSlime.CSCoreLibPlugin.general.Particles.FireworkShow;
import me.mrCookieSlime.CSCoreLibPlugin.general.Player.PlayerInventory;
import me.mrCookieSlime.Slimefun.SlimefunStartup;
@ -134,6 +133,7 @@ public class ToolListener implements Listener {
PlayerInventory.consumeItemInHand(e.getPlayer());
FireworkShow.launchRandom(e.getPlayer(), 3);
List<ItemStack> gifts = new ArrayList<>();
for (int i = 0; i < 2; i++) {
gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_HOT_CHOCOLATE, 1));
gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_CHOCOLATE_APPLE, 4));
@ -146,25 +146,9 @@ public class ToolListener implements Listener {
gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_APPLE_CIDER, 1));
gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_FRUIT_CAKE, 4));
gifts.add(new CustomItem(SlimefunItems.CHRISTMAS_APPLE_PIE, 4));
gifts.add(new ItemStack(Material.EMERALD));
}
gifts.add(new SkullItem("TheBusyBiscuit"));
gifts.add(new SkullItem("timtower"));
gifts.add(new SkullItem("bwfcwalshy"));
gifts.add(new SkullItem("jadedcat"));
gifts.add(new SkullItem("ZeldoKavira"));
gifts.add(new SkullItem("eyamaz"));
gifts.add(new SkullItem("Kaelten"));
gifts.add(new SkullItem("ahamling27"));
gifts.add(new SkullItem("Myrathi"));
new String(
"Good day to whoever is just looking through my code." +
"Since it is Christmas, I wanted to add some Christmas flavour to this Plugin." +
"So, I hope you don't mind that I implemented some of your Heads >.>" +
"Merry Christmas everyone!" +
"" +
"- mrCookieSlime"
);
e.getBlockPlaced().getWorld().dropItemNaturally(e.getBlockPlaced().getLocation(), gifts.get(random.nextInt(gifts.size())));
}
else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.CARGO_INPUT, false)) {

View File

@ -39,7 +39,7 @@ public final class Utilities {
public Set<Location> altarinuse = new HashSet<>();
public Set<AltarRecipe> altarRecipes = new HashSet<>();
public Map<UUID, List<ItemStack>> soulbound = new HashMap<>();
public Map<UUID, Map<Integer, ItemStack>> soulbound = new HashMap<>();
public List<UUID> blocks = new ArrayList<>();
public List<UUID> cancelPlace = new ArrayList<>();
public Map<UUID, ItemStack> arrows = new HashMap<>();