-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed MaterialFillers since in case of not being an Item they wouldn't be displayed. Added PlayerFillers.
- Loading branch information
1 parent
00cf4c0
commit d518b5e
Showing
6 changed files
with
261 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/us/mytheria/bloblib/managers/fillermanager/AnyOtherPlayerFiller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package us.mytheria.bloblib.managers.fillermanager; | ||
|
||
import net.md_5.bungee.api.ChatColor; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Material; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.ItemMeta; | ||
import us.mytheria.bloblib.entities.VariableFiller; | ||
import us.mytheria.bloblib.entities.VariableValue; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class AnyOtherPlayerFiller implements VariableFiller { | ||
private Player exclude; | ||
|
||
public AnyOtherPlayerFiller(Player exclude) { | ||
this.exclude = exclude; | ||
} | ||
|
||
@Override | ||
public VariableValue[] page(int page, int itemsPerPage) { | ||
int start = (page - 1) * itemsPerPage; | ||
int end = start + (itemsPerPage - 1); | ||
ArrayList<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers()); | ||
players.forEach(player -> { | ||
if (player.getUniqueId().equals(exclude.getUniqueId())) { | ||
players.remove(player); | ||
} | ||
}); | ||
ArrayList<VariableValue> values = new ArrayList<>(); | ||
for (int i = start; i < end; i++) { | ||
Player player; | ||
try { | ||
player = players.get(i); | ||
ItemStack itemStack = new ItemStack(Material.LEATHER_CHESTPLATE); | ||
ItemMeta itemMeta = itemStack.getItemMeta(); | ||
itemMeta.setDisplayName(ChatColor.GOLD + player.getName()); | ||
itemStack.setItemMeta(itemMeta); | ||
values.add(new VariableValue(itemStack, player.getUniqueId())); | ||
} catch (IndexOutOfBoundsException e) { | ||
break; | ||
} | ||
} | ||
return values.toArray(new VariableValue[0]); | ||
} | ||
|
||
@Override | ||
public int totalPages(int itemsPerPage) { | ||
return (int) Math.ceil((double) Bukkit.getOnlinePlayers().size() - 1 / (double) itemsPerPage); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/us/mytheria/bloblib/managers/fillermanager/PlayerFiller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package us.mytheria.bloblib.managers.fillermanager; | ||
|
||
import net.md_5.bungee.api.ChatColor; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Material; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.ItemMeta; | ||
import us.mytheria.bloblib.entities.VariableFiller; | ||
import us.mytheria.bloblib.entities.VariableValue; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class PlayerFiller implements VariableFiller { | ||
|
||
public PlayerFiller() { | ||
} | ||
|
||
@Override | ||
public VariableValue[] page(int page, int itemsPerPage) { | ||
int start = (page - 1) * itemsPerPage; | ||
int end = start + (itemsPerPage - 1); | ||
ArrayList<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers()); | ||
ArrayList<VariableValue> values = new ArrayList<>(); | ||
for (int i = start; i < end; i++) { | ||
Player player; | ||
try { | ||
player = players.get(i); | ||
ItemStack itemStack = new ItemStack(Material.LEATHER_CHESTPLATE); | ||
ItemMeta itemMeta = itemStack.getItemMeta(); | ||
itemMeta.setDisplayName(ChatColor.GOLD + player.getName()); | ||
itemStack.setItemMeta(itemMeta); | ||
values.add(new VariableValue(itemStack, player.getUniqueId())); | ||
} catch (IndexOutOfBoundsException e) { | ||
break; | ||
} | ||
} | ||
return values.toArray(new VariableValue[0]); | ||
} | ||
|
||
@Override | ||
public int totalPages(int itemsPerPage) { | ||
return (int) Math.ceil((double) Bukkit.getOnlinePlayers().size() / (double) itemsPerPage); | ||
} | ||
} |
140 changes: 140 additions & 0 deletions
140
src/main/java/us/mytheria/bloblib/utilities/MaterialUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
package us.mytheria.bloblib.utilities; | ||
|
||
import org.bukkit.Material; | ||
|
||
import java.util.HashMap; | ||
|
||
public class MaterialUtil { | ||
|
||
public static void fillNonItem(HashMap<Material, Material> nonItem) { | ||
nonItem.put(Material.WATER, Material.WATER_BUCKET); | ||
nonItem.put(Material.LAVA, Material.LAVA_BUCKET); | ||
nonItem.put(Material.TALL_SEAGRASS, Material.SEAGRASS); | ||
nonItem.put(Material.PISTON_HEAD, Material.PISTON); | ||
nonItem.put(Material.MOVING_PISTON, Material.PISTON); | ||
nonItem.put(Material.WALL_TORCH, Material.TORCH); | ||
nonItem.put(Material.FIRE, Material.CAMPFIRE); | ||
nonItem.put(Material.SOUL_FIRE, Material.SOUL_CAMPFIRE); | ||
nonItem.put(Material.REDSTONE_WIRE, Material.REDSTONE); | ||
nonItem.put(Material.OAK_WALL_SIGN, Material.OAK_SIGN); | ||
nonItem.put(Material.SPRUCE_WALL_SIGN, Material.SPRUCE_SIGN); | ||
nonItem.put(Material.BIRCH_WALL_SIGN, Material.BIRCH_SIGN); | ||
nonItem.put(Material.ACACIA_WALL_SIGN, Material.ACACIA_SIGN); | ||
nonItem.put(Material.JUNGLE_WALL_SIGN, Material.JUNGLE_SIGN); | ||
nonItem.put(Material.DARK_OAK_WALL_SIGN, Material.DARK_OAK_SIGN); | ||
nonItem.put(Material.MANGROVE_WALL_SIGN, Material.MANGROVE_SIGN); | ||
nonItem.put(Material.REDSTONE_WALL_TORCH, Material.REDSTONE_TORCH); | ||
nonItem.put(Material.SOUL_WALL_TORCH, Material.SOUL_TORCH); | ||
nonItem.put(Material.NETHER_PORTAL, Material.OBSIDIAN); | ||
nonItem.put(Material.ATTACHED_PUMPKIN_STEM, Material.PUMPKIN); | ||
nonItem.put(Material.ATTACHED_MELON_STEM, Material.MELON); | ||
nonItem.put(Material.PUMPKIN_STEM, Material.PUMPKIN); | ||
nonItem.put(Material.MELON_STEM, Material.MELON); | ||
nonItem.put(Material.WATER_CAULDRON, Material.CAULDRON); | ||
nonItem.put(Material.LAVA_CAULDRON, Material.CAULDRON); | ||
nonItem.put(Material.POWDER_SNOW_CAULDRON, Material.CAULDRON); | ||
nonItem.put(Material.END_PORTAL, Material.END_PORTAL_FRAME); | ||
nonItem.put(Material.COCOA, Material.COCOA_BEANS); | ||
nonItem.put(Material.TRIPWIRE, Material.STRING); | ||
nonItem.put(Material.POTTED_OAK_SAPLING, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_SPRUCE_SAPLING, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_BIRCH_SAPLING, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_JUNGLE_SAPLING, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_ACACIA_SAPLING, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_DARK_OAK_SAPLING, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_MANGROVE_PROPAGULE, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_FERN, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_DANDELION, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_POPPY, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_BLUE_ORCHID, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_ALLIUM, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_AZURE_BLUET, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_RED_TULIP, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_ORANGE_TULIP, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_WHITE_TULIP, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_PINK_TULIP, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_OXEYE_DAISY, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_CORNFLOWER, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_LILY_OF_THE_VALLEY, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_WITHER_ROSE, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_RED_MUSHROOM, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_BROWN_MUSHROOM, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_DEAD_BUSH, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_CACTUS, Material.FLOWER_POT); | ||
nonItem.put(Material.CARROTS, Material.CARROT); | ||
nonItem.put(Material.POTATOES, Material.POTATO); | ||
nonItem.put(Material.SKELETON_WALL_SKULL, Material.SKELETON_SKULL); | ||
nonItem.put(Material.WITHER_SKELETON_WALL_SKULL, Material.WITHER_SKELETON_SKULL); | ||
nonItem.put(Material.ZOMBIE_WALL_HEAD, Material.ZOMBIE_HEAD); | ||
nonItem.put(Material.PLAYER_WALL_HEAD, Material.PLAYER_HEAD); | ||
nonItem.put(Material.CREEPER_WALL_HEAD, Material.CREEPER_HEAD); | ||
nonItem.put(Material.DRAGON_WALL_HEAD, Material.DRAGON_HEAD); | ||
nonItem.put(Material.WHITE_WALL_BANNER, Material.WHITE_BANNER); | ||
nonItem.put(Material.ORANGE_WALL_BANNER, Material.ORANGE_BANNER); | ||
nonItem.put(Material.MAGENTA_WALL_BANNER, Material.MAGENTA_BANNER); | ||
nonItem.put(Material.LIGHT_BLUE_WALL_BANNER, Material.LIGHT_BLUE_BANNER); | ||
nonItem.put(Material.YELLOW_WALL_BANNER, Material.YELLOW_BANNER); | ||
nonItem.put(Material.LIME_WALL_BANNER, Material.LIME_BANNER); | ||
nonItem.put(Material.PINK_WALL_BANNER, Material.PINK_BANNER); | ||
nonItem.put(Material.GRAY_WALL_BANNER, Material.GRAY_BANNER); | ||
nonItem.put(Material.LIGHT_GRAY_WALL_BANNER, Material.LIGHT_GRAY_BANNER); | ||
nonItem.put(Material.CYAN_WALL_BANNER, Material.CYAN_BANNER); | ||
nonItem.put(Material.PURPLE_WALL_BANNER, Material.PURPLE_BANNER); | ||
nonItem.put(Material.BLUE_WALL_BANNER, Material.BLUE_BANNER); | ||
nonItem.put(Material.BROWN_WALL_BANNER, Material.BROWN_BANNER); | ||
nonItem.put(Material.GREEN_WALL_BANNER, Material.GREEN_BANNER); | ||
nonItem.put(Material.RED_WALL_BANNER, Material.RED_BANNER); | ||
nonItem.put(Material.BLACK_WALL_BANNER, Material.BLACK_BANNER); | ||
nonItem.put(Material.BEETROOTS, Material.BEETROOT); | ||
nonItem.put(Material.END_GATEWAY, Material.END_PORTAL_FRAME); | ||
nonItem.put(Material.FROSTED_ICE, Material.ICE); | ||
nonItem.put(Material.KELP_PLANT, Material.KELP); | ||
nonItem.put(Material.DEAD_TUBE_CORAL_WALL_FAN, Material.DEAD_TUBE_CORAL_FAN); | ||
nonItem.put(Material.DEAD_BRAIN_CORAL_WALL_FAN, Material.DEAD_BRAIN_CORAL_FAN); | ||
nonItem.put(Material.DEAD_BUBBLE_CORAL_WALL_FAN, Material.DEAD_BUBBLE_CORAL_FAN); | ||
nonItem.put(Material.DEAD_FIRE_CORAL_WALL_FAN, Material.DEAD_FIRE_CORAL_FAN); | ||
nonItem.put(Material.DEAD_HORN_CORAL_WALL_FAN, Material.DEAD_HORN_CORAL_FAN); | ||
nonItem.put(Material.TUBE_CORAL_WALL_FAN, Material.TUBE_CORAL_FAN); | ||
nonItem.put(Material.BRAIN_CORAL_WALL_FAN, Material.BRAIN_CORAL_FAN); | ||
nonItem.put(Material.BUBBLE_CORAL_WALL_FAN, Material.BUBBLE_CORAL_FAN); | ||
nonItem.put(Material.FIRE_CORAL_WALL_FAN, Material.FIRE_CORAL_FAN); | ||
nonItem.put(Material.HORN_CORAL_WALL_FAN, Material.HORN_CORAL_FAN); | ||
nonItem.put(Material.BAMBOO_SAPLING, Material.BAMBOO); | ||
nonItem.put(Material.POTTED_BAMBOO, Material.FLOWER_POT); | ||
nonItem.put(Material.VOID_AIR, Material.GLASS); | ||
nonItem.put(Material.CAVE_AIR, Material.GLASS); | ||
nonItem.put(Material.BUBBLE_COLUMN, Material.WATER_BUCKET); | ||
nonItem.put(Material.SWEET_BERRY_BUSH, Material.SWEET_BERRIES); | ||
nonItem.put(Material.WEEPING_VINES_PLANT, Material.WEEPING_VINES); | ||
nonItem.put(Material.TWISTING_VINES_PLANT, Material.TWISTING_VINES); | ||
nonItem.put(Material.CRIMSON_WALL_SIGN, Material.CRIMSON_SIGN); | ||
nonItem.put(Material.WARPED_WALL_SIGN, Material.WARPED_SIGN); | ||
nonItem.put(Material.POTTED_CRIMSON_FUNGUS, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_WARPED_FUNGUS, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_CRIMSON_ROOTS, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_WARPED_ROOTS, Material.FLOWER_POT); | ||
nonItem.put(Material.CANDLE_CAKE, Material.CANDLE); | ||
nonItem.put(Material.WHITE_CANDLE_CAKE, Material.WHITE_CANDLE); | ||
nonItem.put(Material.ORANGE_CANDLE_CAKE, Material.ORANGE_CANDLE); | ||
nonItem.put(Material.MAGENTA_CANDLE_CAKE, Material.MAGENTA_CANDLE); | ||
nonItem.put(Material.LIGHT_BLUE_CANDLE_CAKE, Material.LIGHT_BLUE_CANDLE); | ||
nonItem.put(Material.YELLOW_CANDLE_CAKE, Material.YELLOW_CANDLE); | ||
nonItem.put(Material.LIME_CANDLE_CAKE, Material.LIME_CANDLE); | ||
nonItem.put(Material.PINK_CANDLE_CAKE, Material.PINK_CANDLE); | ||
nonItem.put(Material.GRAY_CANDLE_CAKE, Material.GRAY_CANDLE); | ||
nonItem.put(Material.LIGHT_GRAY_CANDLE_CAKE, Material.LIGHT_GRAY_CANDLE); | ||
nonItem.put(Material.CYAN_CANDLE_CAKE, Material.CYAN_CANDLE); | ||
nonItem.put(Material.PURPLE_CANDLE_CAKE, Material.PURPLE_CANDLE); | ||
nonItem.put(Material.BLUE_CANDLE_CAKE, Material.BLUE_CANDLE); | ||
nonItem.put(Material.BROWN_CANDLE_CAKE, Material.BROWN_CANDLE); | ||
nonItem.put(Material.GREEN_CANDLE_CAKE, Material.GREEN_CANDLE); | ||
nonItem.put(Material.RED_CANDLE_CAKE, Material.RED_CANDLE); | ||
nonItem.put(Material.BLACK_CANDLE_CAKE, Material.BLACK_CANDLE); | ||
nonItem.put(Material.POWDER_SNOW, Material.SNOWBALL); | ||
nonItem.put(Material.CAVE_VINES, Material.GLOW_BERRIES); | ||
nonItem.put(Material.CAVE_VINES_PLANT, Material.GLOW_BERRIES); | ||
nonItem.put(Material.BIG_DRIPLEAF_STEM, Material.BIG_DRIPLEAF); | ||
nonItem.put(Material.POTTED_AZALEA_BUSH, Material.FLOWER_POT); | ||
nonItem.put(Material.POTTED_FLOWERING_AZALEA_BUSH, Material.FLOWER_POT); | ||
} | ||
} |