Open DrRek opened 2 months ago
Hotfix I've implemented in my server:
public static void dropEgg(Player player, Data data, Configuration config) {
Boolean hadToRemoveFromInventory = false;
// If player has dragon egg in the inventory it gets removed
if (player.getInventory().contains(Material.DRAGON_EGG)) {
// Set owner and remove
data.setEggOwner(player, config); //TODO is this necessary? player will likely already be owner
player.getInventory().remove(Material.DRAGON_EGG);
hadToRemoveFromInventory = true;
}
// If player has dragon egg in second hand it gets removed
if(player.getInventory().getItemInOffHand().getType().equals(Material.DRAGON_EGG)){
// Set owner and remove
data.setEggOwner(player, config); //TODO is this necessary? player will likely already be owner
player.getInventory().setItemInOffHand(null);
hadToRemoveFromInventory = true;
}
// If egg has been removed from the player it gets to spawn on the floor
if(hadToRemoveFromInventory){
// Drop it on the floor and set its location
//TODO use drop egg method in EggRespawn
Item eggDrop = player.getWorld().dropItem(player.getLocation(),
new ItemStack(Material.DRAGON_EGG));
eggDrop.setVelocity(new Vector(0, 0, 0));
data.updateEggLocation(eggDrop);
}
}
Not making a pr because I'm unsure about the impact on other server version
Describe the bug Any player can put the eng in the second (left hand) and disconnect from the game. The result is that the egg is not dropped and stays in the inventory
To Reproduce Log in Put the egg in the second hand selecting it and pressing F Log out
Expected behavior The egg is removed from the second hand and dropped on the ground
Actual behavior The egg stays in the invenotry of the logged out user
Version Information:
If applicable, also attach the following information:
Configuration and logs: If applicable, attach the
config.yml
anddata.yml
files inside the/plugins/EggHunt/
directory, which is generated when the plugin is first run.Also attach any relevant log files. Do not upload zipped log files (ending in
.gz
), first unzip the log file(s) inside with a utility like (7-zip)[https://www.7-zip.org/].Screenshots If applicable, attach screenshots to help explain the issue.
Additional context Add any other relevant context about the problem here.