Skip to content

Commit

Permalink
fix: plugin instancing
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueFalconHD committed Nov 7, 2023
1 parent 2935ae3 commit 98d876a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
import org.bukkit.entity.Player;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

public class PlayerKillDeathListener implements Listener {

private Sharpglow plugin;

public PlayerKillDeathListener(Sharpglow sharpglow) {
plugin = sharpglow;
}

private boolean canEnchantWithSharpness(Material material) {
// Define a list of materials that can be enchanted with Sharpness.
Material[] enchantable = {
Expand Down Expand Up @@ -40,7 +47,7 @@ private void killEffects(Player player) {
ItemStack item = player.getInventory().getItemInMainHand(); // Get the item in the player's main hand.
if (canEnchantWithSharpness(item.getType())) { // Check if the item can be enchanted with Sharpness.
// Apply the temporary enchantment to the item for 30 mins
Sharpglow.getTemporaryEnchantmentManager().applyTemporaryEnchantment(item, Enchantment.DAMAGE_ALL, 2, 20 * 60 * 30, player);
plugin.getTemporaryEnchantmentManager().applyTemporaryEnchantment(item, Enchantment.DAMAGE_ALL, 2, 20 * 60 * 30, player);
}

// give player glowing effect for 30 mins
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/bluefalconhd/sharpglow/Sharpglow.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void onEnable() {
// Register the MilkCancelListener class as a listener
getServer().getPluginManager().registerEvents(new MilkCancelListener(), this);
// Register the PlayerKillDeathListener class as a listener
getServer().getPluginManager().registerEvents(new PlayerKillDeathListener(), this);
getServer().getPluginManager().registerEvents(new PlayerKillDeathListener(this), this);
//
}

Expand All @@ -26,7 +26,7 @@ public void onDisable() {
getLogger().info("Sharpglow has been disabled!");
}

public static TemporaryEnchantmentManager getTemporaryEnchantmentManager() {
public TemporaryEnchantmentManager getTemporaryEnchantmentManager() {
return tempEnchantManager;
}
}

0 comments on commit 98d876a

Please sign in to comment.