Search in sources :

Example 21 with Crate

use of com.badbones69.crazycrates.api.objects.Crate in project Crazy-Crates by Crazy-Crew.

the class HolographicSupport method createHologram.

public void createHologram(Block block, Crate crate) {
    CrateHologram crateHologram = crate.getHologram();
    if (!crateHologram.isEnabled())
        return;
    double height = crateHologram.getHeight();
    Hologram hologram = HologramsAPI.createHologram(CrazyManager.getJavaPlugin(), block.getLocation().add(.5, height, .5));
    crateHologram.getMessages().forEach(line -> hologram.appendTextLine(color(line)));
    holograms.put(block, hologram);
}
Also used : CrateHologram(com.badbones69.crazycrates.api.objects.CrateHologram) CrateHologram(com.badbones69.crazycrates.api.objects.CrateHologram) Hologram(com.gmail.filoghost.holographicdisplays.api.Hologram)

Example 22 with Crate

use of com.badbones69.crazycrates.api.objects.Crate in project Crazy-Crates by Crazy-Crew.

the class BrokeLocationsControl method onWorldLoad.

@EventHandler
public void onWorldLoad(WorldLoadEvent e) {
    if (!cc.getBrokeCrateLocations().isEmpty()) {
        int fixedAmount = 0;
        List<BrokeLocation> fixedWorlds = new ArrayList<>();
        for (BrokeLocation brokeLocation : cc.getBrokeCrateLocations()) {
            Location location = brokeLocation.getLocation();
            if (location.getWorld() != null) {
                cc.getCrateLocations().add(new CrateLocation(brokeLocation.getLocationName(), brokeLocation.getCrate(), location));
                if (cc.getHologramController() != null) {
                    cc.getHologramController().createHologram(location.getBlock(), brokeLocation.getCrate());
                }
                fixedWorlds.add(brokeLocation);
                fixedAmount++;
            }
        }
        cc.getBrokeCrateLocations().removeAll(fixedWorlds);
        if (fileManager.isLogging()) {
            CrazyManager.getJavaPlugin().getLogger().warning("Fixed " + fixedAmount + " broken crate locations.");
            if (cc.getBrokeCrateLocations().isEmpty()) {
                CrazyManager.getJavaPlugin().getLogger().warning("All broken crate locations have been fixed.");
            }
        }
    }
}
Also used : BrokeLocation(com.badbones69.crazycrates.api.enums.BrokeLocation) CrateLocation(com.badbones69.crazycrates.api.objects.CrateLocation) ArrayList(java.util.ArrayList) Location(org.bukkit.Location) CrateLocation(com.badbones69.crazycrates.api.objects.CrateLocation) BrokeLocation(com.badbones69.crazycrates.api.enums.BrokeLocation) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Crate (com.badbones69.crazycrates.api.objects.Crate)11 ItemStack (org.bukkit.inventory.ItemStack)10 EventHandler (org.bukkit.event.EventHandler)9 Prize (com.badbones69.crazycrates.api.objects.Prize)8 Player (org.bukkit.entity.Player)8 Inventory (org.bukkit.inventory.Inventory)8 PlayerPrizeEvent (com.badbones69.crazycrates.api.events.PlayerPrizeEvent)7 FileConfiguration (org.bukkit.configuration.file.FileConfiguration)6 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)6 ArrayList (java.util.ArrayList)4 BrokeLocation (com.badbones69.crazycrates.api.enums.BrokeLocation)3 KeyType (com.badbones69.crazycrates.api.enums.KeyType)3 ItemBuilder (com.badbones69.crazycrates.api.objects.ItemBuilder)3 Tier (com.badbones69.crazycrates.api.objects.Tier)3 Location (org.bukkit.Location)3 PlayerReceiveKeyEvent (com.badbones69.crazycrates.api.events.PlayerReceiveKeyEvent)2 CosmicCrateManager (com.badbones69.crazycrates.api.managers.CosmicCrateManager)2 CrateHologram (com.badbones69.crazycrates.api.objects.CrateHologram)2 CrateLocation (com.badbones69.crazycrates.api.objects.CrateLocation)2 QuickCrate (com.badbones69.crazycrates.cratetypes.QuickCrate)2