This repository has been archived by the owner on Dec 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2380b7b
commit c6c922d
Showing
18 changed files
with
1,524 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
EndCrate: | ||
Broadcast: false | ||
|
||
Preview: true | ||
Hide-Percentages: false | ||
Key: | ||
Item: EYE_OF_ENDER | ||
Name: "&2&lEndCrate Key" | ||
Enchanted: true | ||
Lore: | ||
- "&aYou can use this key" | ||
- "&ain spawn!" | ||
Winnings: | ||
1: | ||
Name: "&a&l1x kit Ender" | ||
Item-Type: DIAMOND_SWORD | ||
Percentage: 25 | ||
Messages: | ||
- 'You have won 1x kit Ender' | ||
Commands: | ||
- 'kit ender %player%' | ||
2: | ||
Name: "&a&l$1000" | ||
Item-Type: PAPER | ||
Enchanted: true | ||
Percentage: 25 | ||
Messages: | ||
- 'You have won $1000' | ||
Commands: | ||
- 'eco give %player% 1000' | ||
3: | ||
Name: "&a&l$2500" | ||
Item-Type: PAPER | ||
Enchanted: true | ||
Percentage: 25 | ||
Messages: | ||
- 'You have won $2500' | ||
Commands: | ||
- 'eco give %player% 2500' | ||
4: | ||
Name: "&a&l$5000" | ||
Item-Type: PAPER | ||
Enchanted: true | ||
Percentage: 25 | ||
Messages: | ||
- 'You have won $5000' | ||
Commands: | ||
- 'eco give %player% 5000' |
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,3 @@ | ||
Crates: 0 | ||
CrateLocations: | ||
EndCrate: |
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,115 @@ | ||
/* | ||
AUTHOR: FlupMC | ||
CONTRIBUTORS: Steilgaard | ||
WEBSITE: simonmaribo.dk | ||
SUPPORT: discord.simonmaribo.dk | ||
Copyright 2021 © Simon Maribo | ||
*/ | ||
package dk.simonmaribo.endcrate; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.Material; | ||
import org.bukkit.World; | ||
import org.bukkit.enchantments.Enchantment; | ||
import org.bukkit.inventory.Inventory; | ||
import org.bukkit.inventory.ItemFlag; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.ItemMeta; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class CrateConfig { | ||
|
||
private ItemStack key; | ||
private Inventory preview; | ||
private ArrayList<Prize> prizes = new ArrayList<>(); | ||
private ArrayList<Location> crateLocations = new ArrayList<>(); | ||
public CrateConfig(){ | ||
} | ||
public void reloadLocations(){ | ||
crateLocations.clear(); | ||
try{ | ||
for (String id : Main.cratelocationsYML.getConfigurationSection("CrateLocations.EndCrate").getKeys(false)) { | ||
double x = Main.cratelocationsYML.getDouble("CrateLocations.EndCrate." + id + ".x"); | ||
double y = Main.cratelocationsYML.getDouble("CrateLocations.EndCrate." + id + ".y"); | ||
double z = Main.cratelocationsYML.getDouble("CrateLocations.EndCrate." + id + ".z"); | ||
String w = Main.cratelocationsYML.getString("CrateLocations.EndCrate." + id + ".world"); | ||
World world = Bukkit.getWorld(w); | ||
crateLocations.add(new Location(world, x, y, z)); | ||
} | ||
} catch(NullPointerException exception){ | ||
Bukkit.getConsoleSender().sendMessage("[EndCrate] No Locations found! Create some crates!"); | ||
} | ||
} | ||
public void reload() { | ||
// Generate KEY | ||
String ITEM_TYPE = Main.endcrateYML.getString("EndCrate.Key.Item"); | ||
String ITEM_NAME = Main.endcrateYML.getString("EndCrate.Key.Name"); | ||
List<String> ITEM_LORE = Main.endcrateYML.getStringList("EndCrate.Key.Lore"); | ||
boolean ITEM_ENCHANTED = Main.endcrateYML.getBoolean("EndCrate.Key.Enchanted"); | ||
|
||
ItemStack key = new ItemStack(Material.valueOf(ITEM_TYPE.toUpperCase())); | ||
|
||
if(ITEM_ENCHANTED) key.addUnsafeEnchantment(Enchantment.LURE, 1); | ||
|
||
ItemMeta meta = key.getItemMeta(); | ||
|
||
meta.setDisplayName(Main.getColored(ITEM_NAME)); | ||
meta.setLore(Main.getColored(ITEM_LORE)); | ||
if(ITEM_ENCHANTED) meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); | ||
|
||
key.setItemMeta(meta); | ||
|
||
this.key = key; | ||
|
||
// Generate Preview INV | ||
int size = 9; | ||
Set<String> prizes = Main.endcrateYML.getConfigurationSection("EndCrate.Winnings").getKeys(false); | ||
if (prizes.size() > 9) size = 18; | ||
if (prizes.size() > 18) size = 27; | ||
if (prizes.size() > 27) size = 36; | ||
if (prizes.size() > 36) size = 45; | ||
if (prizes.size() > 45) size = 54; | ||
Inventory inventory = Bukkit.createInventory(null, size, Main.getColored(Main.messagesYML.getString("preview-title"))); | ||
|
||
|
||
float totalPercentage = 0.00f; | ||
|
||
int n = 0; | ||
for(String winning : prizes){ | ||
Prize prize = new Prize(winning); | ||
inventory.setItem(n, prize.getPreviewItem()); | ||
this.prizes.add(prize); | ||
totalPercentage += prize.getPercentage(); | ||
n++; | ||
} | ||
this.preview = inventory; | ||
if(totalPercentage > 100.00f){ | ||
Main.getInstance().getLogger().warning("The total percentage for the EndCrate is over 100%"); | ||
} | ||
if(totalPercentage < 100.00f){ | ||
Main.getInstance().getLogger().warning("The total percentage for the EndCrate is under 100%"); | ||
} | ||
|
||
} | ||
public ItemStack getKey(){ | ||
return this.key; | ||
} | ||
|
||
public Inventory getPreview(){ | ||
return this.preview; | ||
} | ||
public ArrayList<Prize> getPrizes(){ | ||
return this.prizes; | ||
} | ||
|
||
public ArrayList<Location> getCrateLocations() { | ||
return crateLocations; | ||
} | ||
} |
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,36 @@ | ||
/* | ||
AUTHOR: FlupMC | ||
CONTRIBUTORS: Steilgaard | ||
WEBSITE: simonmaribo.dk | ||
SUPPORT: discord.simonmaribo.dk | ||
Copyright 2021 © Simon Maribo | ||
*/ | ||
package dk.simonmaribo.endcrate; | ||
|
||
import org.bukkit.Location; | ||
|
||
public class CrateLocation { | ||
|
||
|
||
public static void addCrate(Location loc){ | ||
int n = Main.cratelocationsYML.getInt("Crates"); | ||
n++; | ||
Main.cratelocationsYML.set("Crates", n); | ||
Main.cratelocationsYML.set("CrateLocations.EndCrate." + String.valueOf(n) + ".world", loc.getWorld().getName()); | ||
Main.cratelocationsYML.set("CrateLocations.EndCrate." + String.valueOf(n) + ".x", loc.getX()); | ||
Main.cratelocationsYML.set("CrateLocations.EndCrate." + String.valueOf(n) + ".y", loc.getY()); | ||
Main.cratelocationsYML.set("CrateLocations.EndCrate." + String.valueOf(n) + ".z", loc.getZ()); | ||
Main.cratelocationsYMLWrapper.saveConfig(); | ||
Main.rc.reloadLocations(); | ||
} | ||
public static void removeCrate(String id){ | ||
Main.cratelocationsYML.set("CrateLocations.EndCrate." + id, null); | ||
Main.cratelocationsYMLWrapper.saveConfig(); | ||
Main.rc.reloadLocations(); | ||
} | ||
|
||
|
||
} |
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,154 @@ | ||
/* | ||
AUTHOR: FlupMC | ||
CONTRIBUTORS: Steilgaard | ||
WEBSITE: simonmaribo.dk | ||
SUPPORT: discord.simonmaribo.dk | ||
Copyright 2021 © Simon Maribo | ||
*/ | ||
package dk.simonmaribo.endcrate; | ||
|
||
import dk.simonmaribo.endcrate.events.PlayerOpenCrate; | ||
import dk.simonmaribo.endcrate.utils.SkullCreator; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.Sound; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.entity.ArmorStand; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
import org.inventivetalent.particle.ParticleEffect; | ||
|
||
import java.util.Collection; | ||
|
||
public class CrateOpen { | ||
|
||
public static void openEndCrate(Block block, Player player){ | ||
Location portalLoc = block.getLocation(); | ||
Location armorStandLoc = portalLoc.add(0.5, -0.5, 0.5); | ||
|
||
|
||
// Custom Event | ||
Prize generatedPrize = new RandomPrize().getPrize(); | ||
PlayerOpenCrate playerOpenCrate = new PlayerOpenCrate(player, block, generatedPrize); | ||
Bukkit.getServer().getPluginManager().callEvent(playerOpenCrate); | ||
Prize prizeWon = playerOpenCrate.getPrize(); | ||
|
||
if(!playerOpenCrate.isCancelled()){ | ||
String holoOverCrate = Main.messagesYML.getString("hologram-over-crate"); | ||
ArmorStand armorStand = (ArmorStand) armorStandLoc.getWorld().spawnEntity(armorStandLoc, EntityType.ARMOR_STAND); | ||
armorStand.setGravity(false); | ||
armorStand.setSmall(true); | ||
armorStand.setVisible(false); | ||
armorStand.setCustomName("EndCrateArmorStand"); | ||
ItemStack head = SkullCreator.itemFromUrl("http://textures.minecraft.net/texture/1fe8e7f2db8eaa88a041c89d4c353d066cc4edef77edcf5e08bb5d3baad"); | ||
armorStand.setHelmet(head); | ||
final Collection<? extends Player> players = Bukkit.getOnlinePlayers(); | ||
new BukkitRunnable(){ | ||
int i = 0; | ||
public void run() { | ||
i++; | ||
armorStandLoc.add(0,0.025,0); | ||
armorStand.teleport(armorStandLoc); | ||
ParticleEffect.SPELL_WITCH.send(players,armorStand.getEyeLocation(),0,0,0,0.1,1); | ||
if(i >= 7) cancel(); | ||
} | ||
}.runTaskTimer(Main.getInstance(),0L, 1L); | ||
new BukkitRunnable(){ | ||
public void run() { | ||
player.playSound(armorStand.getLocation(), Sound.CHICKEN_EGG_POP, (float) 1.99, 0); | ||
cancel(); | ||
} | ||
}.runTaskTimer(Main.getInstance(),7L, 1L); | ||
|
||
new BukkitRunnable(){ | ||
int i = 0; | ||
public void run() { | ||
i++; | ||
if (i == 1) player.playSound(armorStand.getLocation(), Sound.ENDERMAN_TELEPORT, (float) 1.99, 0); | ||
armorStandLoc.add(0,0.15,0); | ||
armorStand.teleport(armorStandLoc); | ||
ParticleEffect.SPELL_WITCH.send(players,armorStand.getEyeLocation(),0,0,0,0.1,1); | ||
if(i >= 8) cancel(); | ||
} | ||
}.runTaskTimer(Main.getInstance(),27L, 1L); | ||
int delay = 80; | ||
new BukkitRunnable(){ | ||
int i = 1; | ||
public void run() { | ||
if(i == 1)player.playSound(armorStand.getLocation(), Sound.PORTAL_TRIGGER, (float) 1.99, (float) 1.05); | ||
ParticleEffect.SPELL_WITCH.send(players,armorStand.getLocation().add(0,1,0),0,0,0,0.1,3); | ||
Location loc = armorStand.getLocation(); | ||
loc.setYaw((float) (i * i * 0.25)); | ||
loc.add(0, 0.001, 0); | ||
armorStand.teleport(loc); | ||
if(i >= delay + 1) cancel(); | ||
i++; | ||
} | ||
}.runTaskTimer(Main.getInstance(),55L, 1L); | ||
|
||
new BukkitRunnable() { | ||
int i = 0; | ||
|
||
@Override | ||
public void run() { | ||
i++; | ||
if (i == 1) { | ||
Location loc = armorStand.getEyeLocation(); | ||
loc.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1f, false, false); | ||
ParticleEffect.CLOUD.send(players, armorStand.getLocation().add(0, 1, 0), 0, 0, 0, 0.1, 10); | ||
player.playSound(armorStand.getLocation(), Sound.LEVEL_UP, (float) 1.99, 0); | ||
} | ||
if (i == 50) { | ||
armorStand.remove(); | ||
|
||
cancel(); | ||
} | ||
} | ||
}.runTaskTimer(Main.getInstance(), delay + 55L, 1L); | ||
new BukkitRunnable() { | ||
int i = 0; | ||
|
||
@Override | ||
public void run() { | ||
i++; | ||
if (i == 1) { | ||
ArmorStand hologram = (ArmorStand) armorStand.getWorld().spawnEntity(armorStand.getLocation().add(0, -0.5, 0), EntityType.ARMOR_STAND); | ||
hologram.setGravity(false); | ||
hologram.setVisible(false); | ||
hologram.setCustomNameVisible(true); | ||
hologram.setCustomName(Main.getColored(holoOverCrate)); | ||
|
||
ArmorStand hologram2 = (ArmorStand) armorStand.getWorld().spawnEntity(armorStand.getLocation().add(0, -0.8, 0), EntityType.ARMOR_STAND); | ||
hologram2.setGravity(false); | ||
hologram2.setVisible(false); | ||
hologram2.setCustomNameVisible(true); | ||
hologram2.setCustomName(Main.getColored(prizeWon.getName())); | ||
|
||
} | ||
if(i == 5){ | ||
prizeWon.runMessages(player); | ||
prizeWon.runCommands(player); | ||
} | ||
if (i == 50) { | ||
for (Entity ent : armorStand.getWorld().getChunkAt(armorStand.getLocation()).getEntities()){ | ||
if(ent.getCustomName() != null) { | ||
if (ent.getCustomName().equals(Main.getColored(holoOverCrate)) || ent.getCustomName().equals(Main.getColored(prizeWon.getName()))) { | ||
ent.remove(); | ||
} | ||
} | ||
} | ||
cancel(); | ||
} | ||
} | ||
}.runTaskTimer(Main.getInstance(), delay + 55L, 1L); | ||
|
||
} | ||
} | ||
|
||
} |
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,36 @@ | ||
/* | ||
AUTHOR: FlupMC | ||
CONTRIBUTORS: Steilgaard | ||
WEBSITE: simonmaribo.dk | ||
SUPPORT: discord.simonmaribo.dk | ||
Copyright 2021 © Simon Maribo | ||
*/ | ||
package dk.simonmaribo.endcrate; | ||
|
||
import org.bukkit.Location; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
public class EndCrateAPI { | ||
|
||
public static void openPreview(Player player) { | ||
player.openInventory(Main.rc.getPreview()); | ||
} | ||
|
||
public static void giveKey(Player player, int amount) { | ||
ItemStack key = Main.rc.getKey(); | ||
key.setAmount(amount); | ||
player.getInventory().addItem(key); | ||
} | ||
|
||
public static void openCrate(Location location, Player player) { | ||
Block block = location.getBlock(); | ||
CrateOpen.openEndCrate(block, player); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.