mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-02-11 11:40:21 +00:00
Starting update to 1.13, DOES NOT BUILD
Starting update to 1.13, DOES NOT BUILD
This commit is contained in:
parent
8fd54284fa
commit
0d4e5b994b
3 changed files with 86 additions and 59 deletions
2
pom.xml
2
pom.xml
|
@ -85,7 +85,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.9.4-R0.1-SNAPSHOT</version>
|
<version>1.13-pre7-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -35,6 +35,7 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
import org.bukkit.material.Dye;
|
import org.bukkit.material.Dye;
|
||||||
|
import org.bukkit.material.Skull;
|
||||||
import org.bukkit.material.Wool;
|
import org.bukkit.material.Wool;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
@ -103,6 +104,10 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
||||||
private static Material[] blockMaterials;
|
private static Material[] blockMaterials;
|
||||||
private static Material[] itemMaterials;
|
private static Material[] itemMaterials;
|
||||||
|
|
||||||
|
private final class ColorInfo {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static { // @formatter:off
|
static { // @formatter:off
|
||||||
colorMapping = new LinkedHashMap<DyeColor, OrdinaryColor>();
|
colorMapping = new LinkedHashMap<DyeColor, OrdinaryColor>();
|
||||||
|
|
||||||
|
@ -144,66 +149,67 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
||||||
|
|
||||||
rainbowColors = new DyeColor[] { DyeColor.RED, DyeColor.ORANGE, DyeColor.YELLOW, DyeColor.LIME, DyeColor.LIGHT_BLUE, DyeColor.BLUE, DyeColor.PURPLE };
|
rainbowColors = new DyeColor[] { DyeColor.RED, DyeColor.ORANGE, DyeColor.YELLOW, DyeColor.LIME, DyeColor.LIGHT_BLUE, DyeColor.BLUE, DyeColor.PURPLE };
|
||||||
|
|
||||||
|
// All materials contain their > 1.13 name, followed by their legacy name, if applicable
|
||||||
blockMaterials = new Material[] {
|
blockMaterials = new Material[] {
|
||||||
Material.STONE,
|
ParticleUtils.closestMatchWithFallback("STONE"),
|
||||||
Material.GRASS,
|
ParticleUtils.closestMatchWithFallback("GRASS"),
|
||||||
Material.TNT,
|
ParticleUtils.closestMatchWithFallback("TNT"),
|
||||||
Material.COBBLESTONE,
|
ParticleUtils.closestMatchWithFallback("COBBLESTONE"),
|
||||||
Material.WOOD,
|
ParticleUtils.closestMatchWithFallback("OAK_WOOD", "WOOD"),
|
||||||
Material.BEDROCK,
|
ParticleUtils.closestMatchWithFallback("BEDROCK"),
|
||||||
Material.SAND,
|
ParticleUtils.closestMatchWithFallback("SAND"),
|
||||||
Material.LOG,
|
ParticleUtils.closestMatchWithFallback("OAK_LOG", "LOG"),
|
||||||
Material.SPONGE,
|
ParticleUtils.closestMatchWithFallback("SPONGE"),
|
||||||
Material.GLASS,
|
ParticleUtils.closestMatchWithFallback("GLASS"),
|
||||||
Material.WOOL,
|
ParticleUtils.closestMatchWithFallback("WHITE_WOOL", "WOOL"),
|
||||||
Material.IRON_BLOCK,
|
ParticleUtils.closestMatchWithFallback("IRON_BLOCK"),
|
||||||
Material.GOLD_BLOCK,
|
ParticleUtils.closestMatchWithFallback("GOLD_BLOCK"),
|
||||||
Material.DIAMOND_BLOCK,
|
ParticleUtils.closestMatchWithFallback("DIAMOND_BLOCK"),
|
||||||
Material.EMERALD_BLOCK,
|
ParticleUtils.closestMatchWithFallback("EMERALD_BLOCK"),
|
||||||
Material.COAL_BLOCK,
|
ParticleUtils.closestMatchWithFallback("COAL_BLOCK"),
|
||||||
Material.REDSTONE_BLOCK,
|
ParticleUtils.closestMatchWithFallback("REDSTONE_BLOCK"),
|
||||||
Material.BOOKSHELF,
|
ParticleUtils.closestMatchWithFallback("BOOKSHELF"),
|
||||||
Material.ICE,
|
ParticleUtils.closestMatchWithFallback("ICE"),
|
||||||
Material.CLAY,
|
ParticleUtils.closestMatchWithFallback("CLAY"),
|
||||||
Material.PUMPKIN,
|
ParticleUtils.closestMatchWithFallback("PUMPKIN"),
|
||||||
Material.MELON_BLOCK,
|
ParticleUtils.closestMatchWithFallback("MELON", "MELON_BLOCK"),
|
||||||
Material.NETHERRACK,
|
ParticleUtils.closestMatchWithFallback("NETHERRACK"),
|
||||||
Material.SOUL_SAND,
|
ParticleUtils.closestMatchWithFallback("SOUL_SAND"),
|
||||||
Material.GLOWSTONE,
|
ParticleUtils.closestMatchWithFallback("GLOWSTONE"),
|
||||||
Material.NETHER_BRICK,
|
ParticleUtils.closestMatchWithFallback("NETHER_BRICK"),
|
||||||
Material.ENDER_STONE,
|
ParticleUtils.closestMatchWithFallback("END_STONE", "ENDER_STONE"),
|
||||||
Material.PRISMARINE
|
ParticleUtils.closestMatchWithFallback("PRISMARINE")
|
||||||
};
|
};
|
||||||
|
|
||||||
itemMaterials = new Material[] {
|
itemMaterials = new Material[] {
|
||||||
Material.COAL,
|
ParticleUtils.closestMatchWithFallback("COAL"),
|
||||||
Material.IRON_INGOT,
|
ParticleUtils.closestMatchWithFallback("IRON_INGOT"),
|
||||||
Material.GOLD_INGOT,
|
ParticleUtils.closestMatchWithFallback("GOLD_INGOT"),
|
||||||
Material.REDSTONE,
|
ParticleUtils.closestMatchWithFallback("REDSTONE"),
|
||||||
Material.EMERALD,
|
ParticleUtils.closestMatchWithFallback("EMERALD"),
|
||||||
Material.QUARTZ,
|
ParticleUtils.closestMatchWithFallback("QUARTZ"),
|
||||||
Material.CLAY_BRICK,
|
ParticleUtils.closestMatchWithFallback("BRICK", "CLAY_BRICK"),
|
||||||
Material.GLOWSTONE_DUST,
|
ParticleUtils.closestMatchWithFallback("GLOWSTONE_DUST"),
|
||||||
Material.SUGAR_CANE,
|
ParticleUtils.closestMatchWithFallback("SUGAR_CANE"),
|
||||||
Material.FLINT,
|
ParticleUtils.closestMatchWithFallback("FLINT"),
|
||||||
Material.POTATO_ITEM,
|
ParticleUtils.closestMatchWithFallback("POTATO", "POTATO_ITEM"),
|
||||||
Material.CARROT_ITEM,
|
ParticleUtils.closestMatchWithFallback("CARROT", "CARROT_ITEM"),
|
||||||
Material.SNOW_BALL,
|
ParticleUtils.closestMatchWithFallback("SNOWBALL", "SNOW_BALL"),
|
||||||
Material.BONE,
|
ParticleUtils.closestMatchWithFallback("BONE"),
|
||||||
Material.ENDER_PEARL,
|
ParticleUtils.closestMatchWithFallback("ENDER_PEARL"),
|
||||||
Material.BLAZE_POWDER,
|
ParticleUtils.closestMatchWithFallback("BLAZE_POWDER"),
|
||||||
Material.NETHER_STALK,
|
ParticleUtils.closestMatchWithFallback("NETHER_WART", "NETHER_STALK"),
|
||||||
Material.FIREBALL,
|
ParticleUtils.closestMatchWithFallback("FIRE_CHARGE", "FIREBALL"),
|
||||||
Material.CHORUS_FRUIT,
|
ParticleUtils.closestMatchWithFallback("CHORUS_FRUIT"),
|
||||||
Material.PRISMARINE_CRYSTALS,
|
ParticleUtils.closestMatchWithFallback("PRISMARINE_CRYSTALS"),
|
||||||
Material.SULPHUR,
|
ParticleUtils.closestMatchWithFallback("GUNPOWDER", "SULPHUR"),
|
||||||
Material.APPLE,
|
ParticleUtils.closestMatchWithFallback("APPLE"),
|
||||||
Material.MELON,
|
ParticleUtils.closestMatchWithFallback("MELON"),
|
||||||
Material.COOKIE,
|
ParticleUtils.closestMatchWithFallback("COOKIE"),
|
||||||
Material.IRON_SPADE,
|
ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"),
|
||||||
Material.COMPASS,
|
ParticleUtils.closestMatchWithFallback("COMPASS"),
|
||||||
Material.WATCH,
|
ParticleUtils.closestMatchWithFallback("CLOCK", "WATCH"),
|
||||||
Material.NAME_TAG
|
ParticleUtils.closestMatchWithFallback("NAME_TAG")
|
||||||
};
|
};
|
||||||
} // @formatter:on
|
} // @formatter:on
|
||||||
|
|
||||||
|
@ -370,7 +376,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
||||||
|
|
||||||
inventory.clear(); // Make sure the inventory is always empty before we start adding items
|
inventory.clear(); // Make sure the inventory is always empty before we start adding items
|
||||||
|
|
||||||
ItemStack currentIcon = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
|
ItemStack currentIcon = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||||
SkullMeta currentIconMeta = (SkullMeta) currentIcon.getItemMeta();
|
SkullMeta currentIconMeta = (SkullMeta) currentIcon.getItemMeta();
|
||||||
currentIconMeta.setDisplayName(ChatColor.GREEN + player.getName());
|
currentIconMeta.setDisplayName(ChatColor.GREEN + player.getName());
|
||||||
String[] currentIconLore = new String[3];
|
String[] currentIconLore = new String[3];
|
||||||
|
@ -378,7 +384,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
||||||
currentIconLore[1] = ChatColor.YELLOW + "Style: " + ChatColor.AQUA + p.getParticleStyle().getName();
|
currentIconLore[1] = ChatColor.YELLOW + "Style: " + ChatColor.AQUA + p.getParticleStyle().getName();
|
||||||
currentIconLore[2] = ChatColor.YELLOW + "Active Data: " + ChatColor.AQUA + p.getParticleDataString();
|
currentIconLore[2] = ChatColor.YELLOW + "Active Data: " + ChatColor.AQUA + p.getParticleDataString();
|
||||||
currentIconMeta.setLore(Arrays.asList(currentIconLore));
|
currentIconMeta.setLore(Arrays.asList(currentIconLore));
|
||||||
currentIconMeta.setOwner(player.getName());
|
currentIconMeta.setOwningPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));
|
||||||
currentIcon.setItemMeta(currentIconMeta);
|
currentIcon.setItemMeta(currentIconMeta);
|
||||||
|
|
||||||
ItemStack effectIcon = new ItemStack(defaultMenuIcons[0], 1);
|
ItemStack effectIcon = new ItemStack(defaultMenuIcons[0], 1);
|
||||||
|
@ -568,6 +574,8 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryInteract(InventoryClickEvent e) {
|
public void onInventoryInteract(InventoryClickEvent e) {
|
||||||
|
if (isGuiDisabled()) return; // Don't worry about processing anything if the GUI is disabled
|
||||||
|
|
||||||
if (!(e.getWhoClicked() instanceof Player)) return; // Not sure if I actually have to check this
|
if (!(e.getWhoClicked() instanceof Player)) return; // Not sure if I actually have to check this
|
||||||
|
|
||||||
Player player = (Player) e.getWhoClicked();
|
Player player = (Player) e.getWhoClicked();
|
||||||
|
|
|
@ -32,6 +32,25 @@ public class ParticleUtils {
|
||||||
return null;
|
return null;
|
||||||
} // @formatter:on
|
} // @formatter:on
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds a block/item as a material from a list of possible strings
|
||||||
|
* Contains a fallback to the barrier icon just in case
|
||||||
|
*
|
||||||
|
* @param input A list of material names
|
||||||
|
* @return The first matching material
|
||||||
|
*/
|
||||||
|
public static Material closestMatchWithFallback(String... input) {
|
||||||
|
Material mat = null;
|
||||||
|
for (String name : input) {
|
||||||
|
mat = closestMatch(name);
|
||||||
|
if (mat != null)
|
||||||
|
return mat;
|
||||||
|
}
|
||||||
|
if (mat == null)
|
||||||
|
mat = Material.BARRIER;
|
||||||
|
return mat;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the smallest positive integer from an array
|
* Gets the smallest positive integer from an array
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue