bugfixes
This commit is contained in:
parent
b66174136a
commit
8aa5ba9bdd
2 changed files with 25 additions and 13 deletions
|
|
@ -21,6 +21,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -56,8 +57,9 @@ public class EggHuntListener implements Listener {
|
|||
static public World end;
|
||||
|
||||
|
||||
public EggHuntListener(Logger logger, FileSave config) {
|
||||
public EggHuntListener(Logger logger, FileSave conf) {
|
||||
EggHuntListener.logger = logger;
|
||||
config=conf;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -403,7 +405,7 @@ public class EggHuntListener implements Listener {
|
|||
public static void resetEggOwner(boolean announce) {
|
||||
if (announce) {
|
||||
if (owner!=null) {
|
||||
announce(String.format("%s no longer owns the dragon egg", owner));
|
||||
announce(String.format("%s no longer owns the dragon egg", egghunt.get_username_from_uuid(owner)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -474,6 +476,16 @@ public class EggHuntListener implements Listener {
|
|||
setEggLocation(new_egg_loc,Egg_Storage_Type.BLOCK);
|
||||
announce("The dragon egg has spawned in the end!");
|
||||
}
|
||||
|
||||
public static void spawnEggItem(Location loc){
|
||||
ItemStack egg=new ItemStack(Material.DRAGON_EGG);
|
||||
egg.setAmount(1);
|
||||
Item drop=loc.getWorld().dropItem(loc, egg);
|
||||
drop.setGravity(false);
|
||||
drop.setGlowing(true);
|
||||
drop.setVelocity(new Vector().setX(0).setY(0).setZ(0));
|
||||
setEggLocation(drop, Egg_Storage_Type.ITEM);
|
||||
}
|
||||
|
||||
public static void announce(String message) {
|
||||
List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());
|
||||
|
|
|
|||
|
|
@ -72,27 +72,27 @@ public class EventScheduler extends BukkitRunnable {
|
|||
|
||||
public void removeEgg(Entity container) {
|
||||
Location l=container.getLocation();
|
||||
|
||||
EggHuntListener.resetEggOwner(true);
|
||||
removeFromInventory(Material.DRAGON_EGG,container);
|
||||
if (EggHuntListener.egg_inv) {
|
||||
respawnEgg(l);
|
||||
//get coords for egg to spawn at
|
||||
//TODO: handle negative y coords in 1.17
|
||||
int y_pos=Math.max(0, l.getWorld().getHighestBlockAt(l).getY()+2);
|
||||
if (y_pos<2) {
|
||||
y_pos=60;
|
||||
}
|
||||
l.setY(y_pos);
|
||||
EggHuntListener.spawnEggItem(l);
|
||||
} else {
|
||||
EggHuntListener.eggDestroyed();
|
||||
}
|
||||
EggHuntListener.resetEggOwner(true);
|
||||
}
|
||||
|
||||
//spawn a new egg item
|
||||
public void respawnEgg(Location loc){
|
||||
loc.setY(Math.max(60, loc.getWorld().getHighestBlockAt(loc).getY()+2));
|
||||
ItemStack egg=new ItemStack(Material.DRAGON_EGG);
|
||||
egg.setAmount(1);
|
||||
Item drop=loc.getWorld().dropItem(loc, egg);
|
||||
drop.setGravity(false);
|
||||
drop.setGlowing(true);
|
||||
}
|
||||
|
||||
|
||||
public void removeFromInventory(Material m, Entity entity) {
|
||||
EggHuntListener.stored_as=Egg_Storage_Type.DNE;
|
||||
if (entity instanceof Player) {
|
||||
Player player= (Player)entity;
|
||||
player.getInventory().remove(m);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue