Skip to content

Commit

Permalink
PhatLoots v5.6.4
Browse files Browse the repository at this point in the history
Fix issues with mob loots on newer Paper 1.21 servers.
  • Loading branch information
Redned235 committed Jul 19, 2024
1 parent a7edddc commit 03d02b0
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 65 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
val supportedVersions = listOf("1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4", "1.20.5", "1.20.6", "1.21")

group = "com.codisimus.plugins"
version = "5.6.3"
version = "5.6.4"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/com/codisimus/plugins/phatloots/PhatLootChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Chest;
Expand All @@ -30,21 +29,30 @@
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

/**
* A PhatLootChest is a Block location and a Map of Users with times attached to them
*
* @author Codisimus
*/
public class PhatLootChest {
private static Set<Material> untriggeredRedstone = EnumSet.of(
private static Set<Material> untriggeredRedstone = Set.of(
Material.REDSTONE, Material.REDSTONE_WIRE, Material.COMPARATOR,
Material.REDSTONE_LAMP, Material.REDSTONE_TORCH,
Material.REPEATER, Material.DISPENSER, Material.DROPPER,
Material.NOTE_BLOCK, Material.PISTON, Material.TNT
);
private static EnumSet<Material> triggeredRedstone = EnumSet.of(
private static Set<Material> triggeredRedstone = Set.of(
Material.REDSTONE_WIRE, Material.COMPARATOR,
Material.REDSTONE_LAMP, Material.REDSTONE_TORCH,
Material.REPEATER, Material.PISTON
Expand Down
71 changes: 56 additions & 15 deletions src/main/java/com/codisimus/plugins/phatloots/PhatLoots.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,51 @@
package com.codisimus.plugins.phatloots;

import com.codisimus.plugins.phatloots.commands.*;
import com.codisimus.plugins.phatloots.conditions.*;
import com.codisimus.plugins.phatloots.commands.CommandHandler;
import com.codisimus.plugins.phatloots.commands.LootCommand;
import com.codisimus.plugins.phatloots.commands.ManageLootCommand;
import com.codisimus.plugins.phatloots.commands.ManageMoneyLootCommand;
import com.codisimus.plugins.phatloots.commands.ManageMythicDropsLootCommand;
import com.codisimus.plugins.phatloots.commands.ManageMythicMobsLootCommand;
import com.codisimus.plugins.phatloots.commands.VariableLootCommand;
import com.codisimus.plugins.phatloots.conditions.BiomeCondition;
import com.codisimus.plugins.phatloots.conditions.ExperienceCondition;
import com.codisimus.plugins.phatloots.conditions.HealthCondition;
import com.codisimus.plugins.phatloots.conditions.ItemCondition;
import com.codisimus.plugins.phatloots.conditions.LootCondition;
import com.codisimus.plugins.phatloots.conditions.PermissionCondition;
import com.codisimus.plugins.phatloots.conditions.PlaceholderDataCondition;
import com.codisimus.plugins.phatloots.conditions.RegionCondition;
import com.codisimus.plugins.phatloots.conditions.TimeCondition;
import com.codisimus.plugins.phatloots.conditions.WeatherCondition;
import com.codisimus.plugins.phatloots.events.ChestRespawnEvent.RespawnReason;
import com.codisimus.plugins.phatloots.gui.InventoryConditionListener;
import com.codisimus.plugins.phatloots.gui.InventoryListener;
import com.codisimus.plugins.phatloots.hook.PluginHookManager;
import com.codisimus.plugins.phatloots.listeners.*;
import com.codisimus.plugins.phatloots.loot.*;
import com.codisimus.plugins.phatloots.listeners.BlockLootListener;
import com.codisimus.plugins.phatloots.listeners.CitizensListener;
import com.codisimus.plugins.phatloots.listeners.DispenserListener;
import com.codisimus.plugins.phatloots.listeners.FishingListener;
import com.codisimus.plugins.phatloots.listeners.LootBagListener;
import com.codisimus.plugins.phatloots.listeners.LootingBonusListener;
import com.codisimus.plugins.phatloots.listeners.MobDeathListener;
import com.codisimus.plugins.phatloots.listeners.MobListener;
import com.codisimus.plugins.phatloots.listeners.MobSpawnListener;
import com.codisimus.plugins.phatloots.listeners.PhatLootsListener;
import com.codisimus.plugins.phatloots.listeners.VoteListener;
import com.codisimus.plugins.phatloots.loot.CommandLoot;
import com.codisimus.plugins.phatloots.loot.Experience;
import com.codisimus.plugins.phatloots.loot.Gem;
import com.codisimus.plugins.phatloots.loot.Item;
import com.codisimus.plugins.phatloots.loot.LootCollection;
import com.codisimus.plugins.phatloots.loot.Message;
import com.codisimus.plugins.phatloots.loot.Money;
import com.codisimus.plugins.phatloots.loot.MythicDropsItem;
import com.codisimus.plugins.phatloots.loot.MythicMobsItem;
import com.codisimus.plugins.phatloots.loot.UnidentifiedItem;
import com.codisimus.plugins.phatloots.regions.RegionHook;
import com.codisimus.plugins.phatloots.regions.WorldGuardRegionHook;
import com.codisimus.plugins.phatloots.util.PhatLootsUtil;
import com.google.common.io.Files;
import java.io.*;
import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
Expand All @@ -30,9 +55,25 @@
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.entity.Player;
import org.bukkit.plugin.*;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* Loads Plugin and manages Data/Listeners/etc.
*
Expand All @@ -49,7 +90,7 @@ public class PhatLoots extends JavaPlugin {
public static long autoSavePeriod;
public static CommandHandler handler;
public static final HashMap<String, RegionHook> regionHooks = new HashMap<>(); //Plugin Name -> RegionHook
public static final EnumMap<Material, HashMap<String, String>> types = new EnumMap<>(Material.class); //Material -> World Name -> PhatLoot Name
public static final Map<Material, HashMap<String, String>> types = new HashMap<>(); //Material -> World Name -> PhatLoot Name
private static final HashMap<String, PhatLoot> phatLoots = new HashMap<>(); //PhatLoot Name -> PhatLoot

private PluginHookManager hookManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,46 +73,42 @@ public PhatLoot getPhatLoot(LivingEntity entity) {
if (mobTypes) {
switch (entity.getType()) {
case ZOMBIFIED_PIGLIN:
case ZOMBIE: //'BabyVillager' | 'Baby' | 'Villager' | 'Normal'
case ZOMBIE:
Zombie zombie = (Zombie) entity;
if (zombie.isBaby()) {
specificType = zombie.isVillager() ? "BabyVillager" : "Baby";
} else if (zombie.isVillager()) {
specificType = "Villager";
if (!zombie.isAdult()) {
specificType = "Baby";
} else {
specificType = "Normal";
}
break;
case SKELETON: //'Wither' | 'Normal'
specificType = toCamelCase(((Skeleton) entity).getSkeletonType());
case ZOMBIE_VILLAGER:
ZombieVillager zombieVillager = (ZombieVillager) entity;
if (!zombieVillager.isAdult()) {
specificType = "Baby";
} else {
specificType = "Normal";
}
break;
case VILLAGER: //Profession
specificType = toCamelCase(((Villager) entity).getProfession());
Villager villager = (Villager) entity;
String professionName = villager.getProfession().getKey().getKey();

// Capitalize the first letter of the profession
specificType = toProperCase(professionName);
break;
case CREEPER: //'Powered' | 'Normal'
Creeper creeper = (Creeper) entity;
specificType = creeper.isPowered() ? "Powered" : "Normal";
break;
case HORSE: //Color + Style (type is also determined by variant
Horse horse = (Horse) entity;
type = toCamelCase(horse.getVariant());
if (horse.getVariant() == Variant.HORSE) {
specificType = toCamelCase(horse.getColor());
switch (horse.getStyle()) {
case WHITE_DOTS:
specificType += "Spotted";
break;
case BLACK_DOTS:
specificType += "Dark";
break;
case WHITE:
specificType += "Light";
break;
case WHITEFIELD:
specificType += "Milky";
break;
}
switch (horse.getStyle()) {
case WHITE_DOTS -> specificType = "Spotted";
case BLACK_DOTS -> specificType = "Dark";
case WHITE -> specificType = "Light";
case WHITEFIELD -> specificType = "Milky";
}

break;
case SHEEP: //Color
Sheep sheep = (Sheep) entity;
Expand Down
27 changes: 17 additions & 10 deletions src/main/java/com/codisimus/plugins/phatloots/loot/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
import com.codisimus.plugins.phatloots.PhatLoot;
import com.codisimus.plugins.phatloots.PhatLoots;
import com.codisimus.plugins.phatloots.util.PhatLootsUtil;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
Expand All @@ -18,6 +14,17 @@
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
* An Item is the Loot representation of an ItemStack
*
Expand Down Expand Up @@ -94,7 +101,7 @@ public class Item extends Loot {
Enchantment.DURABILITY, Enchantment.MENDING
};
/* MATERIALS */
private static final EnumSet<Material> ARMOR_MATERIAL_SET = EnumSet.of(
private static final Set<Material> ARMOR_MATERIAL_SET = Set.of(
Material.NETHERITE_HELMET, Material.NETHERITE_CHESTPLATE,
Material.NETHERITE_LEGGINGS, Material.NETHERITE_BOOTS,
Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE,
Expand All @@ -109,23 +116,23 @@ public class Item extends Loot {
Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS,
Material.TURTLE_HELMET
);
private static final EnumSet<Material> SWORD_MATERIAL_SET = EnumSet.of(
private static final Set<Material> SWORD_MATERIAL_SET = Set.of(
Material.NETHERITE_SWORD, Material.DIAMOND_SWORD, Material.IRON_SWORD,
Material.GOLDEN_SWORD, Material.STONE_SWORD, Material.WOODEN_SWORD
);
private static final EnumSet<Material> AXE_MATERIAL_SET = EnumSet.of(
private static final Set<Material> AXE_MATERIAL_SET = Set.of(
Material.NETHERITE_AXE, Material.DIAMOND_AXE, Material.IRON_AXE,
Material.GOLDEN_AXE, Material.STONE_AXE, Material.WOODEN_AXE
);
private static final EnumSet<Material> PICKAXE_MATERIAL_SET = EnumSet.of(
private static final Set<Material> PICKAXE_MATERIAL_SET = Set.of(
Material.NETHERITE_PICKAXE, Material.DIAMOND_PICKAXE, Material.IRON_PICKAXE,
Material.GOLDEN_PICKAXE, Material.STONE_PICKAXE, Material.WOODEN_PICKAXE
);
private static final EnumSet<Material> SPADE_MATERIAL_SET = EnumSet.of(
private static final Set<Material> SPADE_MATERIAL_SET = Set.of(
Material.NETHERITE_SHOVEL, Material.DIAMOND_SHOVEL, Material.IRON_SHOVEL,
Material.GOLDEN_SHOVEL, Material.STONE_SHOVEL, Material.WOODEN_SHOVEL
);
private static final EnumSet<Material> HOE_MATERIAL_SET = EnumSet.of(
private static final Set<Material> HOE_MATERIAL_SET = Set.of(
Material.NETHERITE_HOE, Material.DIAMOND_HOE, Material.IRON_HOE,
Material.GOLDEN_HOE, Material.STONE_HOE, Material.WOODEN_HOE
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
package com.codisimus.plugins.phatloots.util;

import java.io.FilenameFilter;
import java.util.EnumSet;
import java.util.LinkedList;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

import com.codisimus.plugins.phatloots.PhatLoot;
import com.codisimus.plugins.phatloots.PhatLoots;
import com.codisimus.plugins.phatloots.PhatLootsConfig;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.apache.commons.lang3.text.WordUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.entity.Player;
import org.bukkit.inventory.DoubleChestInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

import java.io.FilenameFilter;
import java.util.LinkedList;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

/**
* Utility Variables/Methods commonly used by PhatLoots and its add-ons
*
Expand Down

0 comments on commit 03d02b0

Please sign in to comment.