allow crafting heads

this makes #whatever more important
This commit is contained in:
TheTechRobo 2022-04-10 18:24:42 -04:00
parent deb8542abe
commit bcae6883b0
3 changed files with 39 additions and 5 deletions

View File

@ -3,4 +3,9 @@ banDuration: 5 # days
onDeathRemove: 4.0 # 2 hearts
headsGive: 4.0 # 2 hearts
lifextractorEnabled: true
startingLives: 2 # different than hearts
heartExtractorEnabled: true
startingLives: 2 # different than hearts
crafting:
allowCraftingHeads: true
allowCraftingLives: true

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import org.bukkit.Sound;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -25,7 +26,7 @@ public class DeathListener implements Listener {
ItemStack skull = rethead(e.getEntity());
e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), skull);
}
public ItemStack rethead(Player p) {
public ItemStack rethead(OfflinePlayer p) {
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
SkullMeta meta = (SkullMeta) skull.getItemMeta();
meta.setOwningPlayer(p);
@ -34,6 +35,9 @@ public class DeathListener implements Listener {
skull.setItemMeta(newmeta);
return skull;
}
public ItemStack rethead(Player p) {
return rethead((OfflinePlayer) p);
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
this.scores.addPlayerToScoreboard(e.getPlayer());

View File

@ -8,6 +8,7 @@ import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.java.JavaPlugin;
public class LifestealPlugin extends JavaPlugin {
private DeathListener dl;
public void addRecipes() {
LifeExtractor lifextractor = new LifeExtractor();
lifextractor.create();
@ -45,14 +46,38 @@ public class LifestealPlugin extends JavaPlugin {
recipe.setIngredient('B', Material.BUCKET);
recipe.setIngredient('S', Material.STICK);
Bukkit.addRecipe(recipe);
item = this.dl.rethead(Bukkit.getOfflinePlayer("D"));
key = new NamespacedKey(this, "headRecipe0");
recipe = new ShapedRecipe(key, item);
recipe.shape("did", " ", " ");
recipe.setIngredient('d', Material.DIAMOND);
recipe.setIngredient('i', Material.IRON_INGOT);
Bukkit.addRecipe(recipe);
item = this.dl.rethead(Bukkit.getOfflinePlayer("D"));
key = new NamespacedKey(this, "headRecipe1");
recipe = new ShapedRecipe(key, item);
recipe.shape("WWW", "WsW", "WWW");
recipe.setIngredient('W', Material.STICK);
recipe.setIngredient('s', Material.NETHERITE_SCRAP);
Bukkit.addRecipe(recipe);
item = this.dl.rethead(Bukkit.getOfflinePlayer("D"));
key = new NamespacedKey(this, "headRecipe2");
recipe = new ShapedRecipe(key, item);
recipe.shape("RR ", " ", " ");
recipe.setIngredient('R', Material.REDSTONE_BLOCK);
Bukkit.addRecipe(recipe);
}
@Override
public void onEnable() {
DeathListener dl = new DeathListener();
dl.initialise(this);
getServer().getPluginManager().registerEvents(dl, this);
this.dl = dl;
this.dl.initialise(this);
getServer().getPluginManager().registerEvents(this.dl, this);
DeleteMyData dlmydata = new DeleteMyData();
dlmydata.initialise(dl.scores);
dlmydata.initialise(this.dl.scores);
this.getCommand("deletemydata").setExecutor(dlmydata);
this.getCommand("setHearts").setExecutor(new ExploitAbuse101ByLunarRam());
addRecipes();