Skip to content

Commit

Permalink
1.4.2
Browse files Browse the repository at this point in the history
- Fixed starting coins not being applied correctly
- Made flask healing optional in settings
- Modified default kit settings
- Changed Mage kit to a debuffer
- Fixed database file separator bug
  • Loading branch information
Foulest committed Oct 31, 2024
1 parent 24d332a commit afcccfe
Show file tree
Hide file tree
Showing 15 changed files with 124 additions and 147 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'net.foulest'
version = '1.4.1'
version = '1.4.2'
description = 'KitPvP'

// Set the project's language level
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/foulest/kitpvp/data/PlayerData.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public boolean load() {
String uuidString = uniqueId.toString();

defaultStats.put("uuid", uuidString);
defaultStats.put("coins", 500);
defaultStats.put("coins", Settings.startingCoins);
defaultStats.put("experience", 0);
defaultStats.put("kills", 0);
defaultStats.put("deaths", 0);
Expand Down
34 changes: 18 additions & 16 deletions src/main/java/net/foulest/kitpvp/kits/Kit.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import net.foulest.kitpvp.data.PlayerData;
import net.foulest.kitpvp.data.PlayerDataManager;
import net.foulest.kitpvp.enchants.Enchants;
import net.foulest.kitpvp.listeners.FlaskListener;
import net.foulest.kitpvp.util.MessageUtil;
import net.foulest.kitpvp.util.Settings;
import net.foulest.kitpvp.util.item.ItemBuilder;
import org.bukkit.Location;
import org.bukkit.Material;
Expand Down Expand Up @@ -214,21 +214,23 @@ default void apply(Player player) {
}

// Set the flask item.
ItemStack flaskItem = new ItemBuilder(Material.POTION).name("&aFlask &7(Right Click)").getItem();
flaskItem.setDurability((short) 8229);
flaskItem.setAmount(FlaskListener.MAX_FLASKS);
player.getInventory().setItem(i, flaskItem);
break;

// if (playerData.isUsingSoup()) {
// ItemBuilder soupItemBuilder = new ItemBuilder(Material.MUSHROOM_SOUP).name("&fMushroom Stew");
// ItemStack soupItemStack = soupItemBuilder.getItem();
// player.getInventory().setItem(i, soupItemStack);
// } else {
// ItemBuilder potionItemBuilder = new ItemBuilder(Material.POTION).durability(16421).name("&fSplash Potion of Healing");
// ItemStack potionItemStack = potionItemBuilder.getItem();
// player.getInventory().setItem(i, potionItemStack);
// }
if (Settings.flaskEnabled) {
ItemStack flaskItem = new ItemBuilder(Material.POTION).name("&aFlask &7(Right Click)").getItem();
flaskItem.setDurability((short) 8229);
flaskItem.setAmount(Settings.flaskAmount);
player.getInventory().setItem(i, flaskItem);
break;
} else {
if (playerData.isUsingSoup()) {
ItemBuilder soupItemBuilder = new ItemBuilder(Material.MUSHROOM_SOUP).name("&fMushroom Stew");
ItemStack soupItemStack = soupItemBuilder.getItem();
player.getInventory().setItem(i, soupItemStack);
} else {
ItemBuilder potionItemBuilder = new ItemBuilder(Material.POTION).durability(16421).name("&fSplash Potion of Healing");
ItemStack potionItemStack = potionItemBuilder.getItem();
player.getInventory().setItem(i, potionItemStack);
}
}
}

// Sets the player's armor.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/foulest/kitpvp/kits/type/Archer.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public List<ItemBuilder> getItems() {
// Damage value: 4.0
ItemBuilder sword = new ItemBuilder(Material.WOOD_SWORD).unbreakable(true).hideInfo();

// Damage value: 4.5
ItemBuilder bow = new ItemBuilder(Material.BOW).unbreakable(true).hideInfo().enchant(Enchantment.ARROW_DAMAGE, 1);
// Damage value: 2.0
ItemBuilder bow = new ItemBuilder(Material.BOW).unbreakable(true).hideInfo();

ItemBuilder special = new ItemBuilder(Material.FEATHER).unbreakable(true).hideInfo().name("&aSpeed Boost &7(Right Click)")
.lore("&7Gain a temporary speed boost.");
Expand All @@ -88,7 +88,7 @@ public ItemBuilder[] getArmor() {

@Override
public List<String> getLore() {
return new ArrayList<>(Arrays.asList("&7Style: &aMixed", "", "&7Master of long-ranged combat."));
return new ArrayList<>(Arrays.asList("&7Style: &aOffensive", "", "&7Master of long-ranged combat."));
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/foulest/kitpvp/kits/type/Fisherman.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public PotionEffect[] getPotionEffects() {

@Override
public List<ItemBuilder> getItems() {
// Damage value: 4.0
ItemBuilder sword = new ItemBuilder(Material.WOOD_SWORD).unbreakable(true).hideInfo();
// Damage value: 5.0
ItemBuilder sword = new ItemBuilder(Material.STONE_SWORD).unbreakable(true).hideInfo();

ItemBuilder special = new ItemBuilder(Material.FISHING_ROD).unbreakable(true).hideInfo().name("&aHookshot &7(Right Click)")
.lore("&7Hooks players to your location.");
Expand All @@ -80,7 +80,7 @@ public ItemBuilder[] getArmor() {

@Override
public List<String> getLore() {
return new ArrayList<>(Arrays.asList("&7Style: &aDefensive", "", "&7Hooks players to your location."));
return new ArrayList<>(Arrays.asList("&7Style: &aMixed", "", "&7Hooks players to your location."));
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/foulest/kitpvp/kits/type/Mage.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public List<ItemBuilder> getItems() {
// Damage value: 5.0
ItemBuilder sword = new ItemBuilder(Material.STONE_SWORD).unbreakable(true).hideInfo();

ItemBuilder special = new ItemBuilder(Material.GLOWSTONE_DUST).name("&aRandom Effect &7(Right Click)")
.lore("&7Gives you a random potion effect.");
ItemBuilder special = new ItemBuilder(Material.GLOWSTONE_DUST).name("&aStasis &7(Right Click)")
.lore("&7Debuff nearby players.");
return Arrays.asList(sword, special);
}

Expand All @@ -79,7 +79,7 @@ public ItemBuilder[] getArmor() {

@Override
public List<String> getLore() {
return new ArrayList<>(Arrays.asList("&7Style: &aMixed", "", "&7Gives you a random potion effect."));
return new ArrayList<>(Arrays.asList("&7Style: &aMixed", "", "&7Debuff nearby players."));
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/foulest/kitpvp/kits/type/Pyro.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public PotionEffect[] getPotionEffects() {

@Override
public List<ItemBuilder> getItems() {
// Damage value: 4.0
ItemBuilder sword = new ItemBuilder(Material.WOOD_SWORD).enchant(Enchantment.FIRE_ASPECT, 1).unbreakable(true).hideInfo();
// Damage value: 5.0
ItemBuilder sword = new ItemBuilder(Material.STONE_SWORD).enchant(Enchantment.FIRE_ASPECT, 1).unbreakable(true).hideInfo();

ItemBuilder special = new ItemBuilder(Material.FIREBALL).name("&aIgnite &7(Right Click)")
.lore("&7Ignites players on fire.");
Expand All @@ -83,7 +83,7 @@ public ItemBuilder[] getArmor() {

@Override
public List<String> getLore() {
return new ArrayList<>(Arrays.asList("&7Style: &aMixed", "", "&7Set other players ablaze."));
return new ArrayList<>(Arrays.asList("&7Style: &aOffensive", "", "&7Set other players ablaze."));
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/foulest/kitpvp/kits/type/Tank.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public PotionEffect[] getPotionEffects() {

@Override
public List<ItemBuilder> getItems() {
// Damage value: 4.0
ItemBuilder axe = new ItemBuilder(Material.STONE_AXE).unbreakable(true).hideInfo();
// Damage value: 3.0
ItemBuilder axe = new ItemBuilder(Material.WOOD_AXE).unbreakable(true).hideInfo();

ItemBuilder special = new ItemBuilder(Material.ANVIL).name("&aFortify &7(Right Click)")
.lore("&7Reduce all incoming damage.");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/foulest/kitpvp/kits/type/Vampire.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public ItemBuilder[] getArmor() {

@Override
public List<String> getLore() {
return new ArrayList<>(Arrays.asList("&7Style: &aOffensive", "", "&7Get life-steal on hit."));
return new ArrayList<>(Arrays.asList("&7Style: &aMixed", "", "&7Get life-steal on hit."));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ static void handleDeath(@NotNull Player receiver, boolean onPlayerQuit) {
int damagerCoins = damagerData.getCoins();

// Adds a Flask to the damager's inventory.
FlaskListener.addFlaskToInventory(damager, FlaskListener.MAX_FLASKS);
if (Settings.flaskEnabled) {
FlaskListener.addFlaskToInventory(damager, Settings.flaskAmount);
}

// Adds a kill to the damager.
damagerData.setKills(damagerKills + 1);
Expand Down
25 changes: 8 additions & 17 deletions src/main/java/net/foulest/kitpvp/listeners/FlaskListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.foulest.kitpvp.data.PlayerDataManager;
import net.foulest.kitpvp.region.Regions;
import net.foulest.kitpvp.util.MessageUtil;
import net.foulest.kitpvp.util.Settings;
import net.foulest.kitpvp.util.item.ItemBuilder;
import org.bukkit.Location;
import org.bukkit.Material;
Expand All @@ -29,8 +30,6 @@
@Data
public class FlaskListener implements Listener {

public static int MAX_FLASKS = 5;

private static ItemStack FLASK = new ItemBuilder(Material.POTION).hideInfo().durability(8229)
.name("&aFlask &7(Right Click)").getItem();

Expand All @@ -39,17 +38,13 @@ public class FlaskListener implements Listener {

/**
* Sets a cooldown for a specific kit.
*
* @param cooldownTime The time in seconds for the cooldown.
*/
private static void setFlaskCooldown(@NotNull PlayerData playerData, int cooldownTime) {
private static void setFlaskCooldown(@NotNull PlayerData playerData) {
Player player = playerData.getPlayer();

BukkitTask cooldownTask = new BukkitRunnable() {
@Override
public void run() {
MessageUtil.messagePlayer(player, "&aYour Flask cooldown has expired.");

// Set the player's flask back to a potion.
for (ItemStack item : player.getInventory().getContents()) {
if (item == null
Expand All @@ -69,7 +64,7 @@ public void run() {
}
}
}
}.runTaskLater(KitPvP.instance, cooldownTime * 20L);
}.runTaskLater(KitPvP.instance, Settings.flaskCooldown * 20L);

// Set the Flask cooldown and regeneration tasks.
playerData.setFlaskCooldownTask(cooldownTask);
Expand All @@ -92,9 +87,8 @@ static void addFlaskToInventory(@NotNull Player player, int amount) {
// Update the Flask amount.
int itemAmount = item.getAmount();

if (itemAmount < MAX_FLASKS) {
MessageUtil.messagePlayer(player, "&aYou received a Flask.");
item.setAmount(Math.min(itemAmount + amount, MAX_FLASKS));
if (itemAmount < Settings.flaskAmount) {
item.setAmount(Math.min(itemAmount + amount, Settings.flaskAmount));
player.updateInventory();
return;
}
Expand All @@ -103,7 +97,7 @@ static void addFlaskToInventory(@NotNull Player player, int amount) {

if (!hasFlasks) {
// Add the Flask to the player's inventory.
FLASK.setAmount(Math.min(amount, MAX_FLASKS));
FLASK.setAmount(Math.min(amount, Settings.flaskAmount));
player.getInventory().addItem(FLASK);
player.updateInventory();
}
Expand Down Expand Up @@ -159,8 +153,6 @@ public static void onRightClick(@NotNull PlayerInteractEvent event) {
// The Flask is ready to be used, as it's not a GLASS_BOTTLE.

if (health < maxHealth) {
int flaskDuration = 3;

// Removes the Flask from the player's inventory if there is only one.
// Otherwise, sets the Flask to a GLASS_BOTTLE with the amount of the Flask.
if (itemAmount == 1) {
Expand All @@ -174,14 +166,13 @@ public static void onRightClick(@NotNull PlayerInteractEvent event) {
player.updateInventory();

// Set the Flask cooldown.
setFlaskCooldown(playerData, flaskDuration);
setFlaskCooldown(playerData);

// Send the player a message and play a sound.
MessageUtil.messagePlayer(player, "&aYou used a Flask.");
player.playSound(playerLoc, Sound.DRINK, 1, 1);

// Heal the player for 5 hearts (10 health) over 3 seconds.
PotionEffect regeneration = new PotionEffect(PotionEffectType.REGENERATION, flaskDuration * 20, 3);
PotionEffect regeneration = new PotionEffect(PotionEffectType.REGENERATION, 3 * 20, 3);
player.addPotionEffect(regeneration);
} else {
MessageUtil.messagePlayer(player, "&cYou are already at full health.");
Expand Down
Loading

0 comments on commit afcccfe

Please sign in to comment.