Skip to content

Commit

Permalink
1.4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Foulest committed Jan 17, 2025
1 parent 7dc2b9e commit 03bd440
Show file tree
Hide file tree
Showing 35 changed files with 2,397 additions and 791 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.4'
version = '1.4.5'
description = 'KitPvP'

// Set the project's language level
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/net/foulest/kitpvp/KitPvP.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,22 @@ public void onEnable() {

// Loads the plugin's listeners.
MessageUtil.log(Level.INFO, "Loading Listeners...");
loadListeners(new DeathListener(), new EventListener(), new FlaskListener(),
new ArcherListener(), new FishermanListener(), new KangarooListener(),
new MageListener(), new NinjaListener(), new PyroListener(),
loadListeners(new DeathListener(), new EventListener(), new FlaskListener(), new ArcherListener(),
new FishermanListener(), new JesterListener(), new KangarooListener(), new MageListener(),
new NinjaListener(), new PyroListener(), new ReaperListener(), new SoldierListener(),
new TankListener(), new VampireListener());

// Loads the plugin's commands.
MessageUtil.log(Level.INFO, "Loading Commands...");
loadCommands(new BalanceCmd(), new BountyCmd(), new ClearKitCmd(), new CombatTagCmd(), new EcoCmd(),
new KitsCmd(), new PayCmd(), new SetSpawnCmd(), new SpawnCmd(), new StatsCmd(),
new KitShopCmd(), new ArmorColorCmd(), new KitEnchanterCmd(), new SoupCmd(),
new PotionsCmd(), new KitPvPCmd());
new PotionsCmd(), new KitPvPCmd(), new PlaySoundCmd());

// Loads the plugin's kits.
MessageUtil.log(Level.INFO, "Loading Kits...");
loadKits(new Archer(), new Fisherman(), new Kangaroo(), new Knight(), new Mage(),
new Ninja(), new Pyro(), new Tank(), new Vampire());
loadKits(new Archer(), new Fisherman(), new Jester(), new Kangaroo(), new Knight(), new Mage(),
new Ninja(), new Pyro(), new Reaper(), new Soldier(), new Tank(), new Vampire());

// Loads the spawn.
MessageUtil.log(Level.INFO, "Loading Spawn...");
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/net/foulest/kitpvp/cmds/BountyCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,15 @@
package net.foulest.kitpvp.cmds;

import lombok.Data;
import net.foulest.kitpvp.KitPvP;
import net.foulest.kitpvp.data.PlayerData;
import net.foulest.kitpvp.data.PlayerDataManager;
import net.foulest.kitpvp.kits.Kit;
import net.foulest.kitpvp.kits.KitManager;
import net.foulest.kitpvp.region.Spawn;
import net.foulest.kitpvp.util.ConstantUtil;
import net.foulest.kitpvp.util.MessageUtil;
import net.foulest.kitpvp.util.Settings;
import net.foulest.kitpvp.util.command.Command;
import net.foulest.kitpvp.util.command.CommandArgs;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/foulest/kitpvp/cmds/ClearKitCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private static void clearKit(@NotNull PlayerData playerData) {
playerData.clearCooldowns();
playerData.setActiveKit(null);

player.setMaxHealth(20);
player.setHealth(20);
player.getInventory().setHeldItemSlot(0);

Expand Down
55 changes: 29 additions & 26 deletions src/main/java/net/foulest/kitpvp/cmds/PayCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,71 +43,74 @@ public class PayCmd {
@Command(name = "pay", description = "Send coins to another player.",
usage = "/pay <player> <amount>", inGameOnly = true, permission = "kitpvp.pay")
public static void onCommand(@NotNull CommandArgs args) {
CommandSender sender = args.getSender();
CommandSender commandSender = args.getSender();
Player sender = args.getPlayer();

if (args.length() == 2) {
Player player = args.getPlayer();

// Checks if the player is null.
if (player == null) {
MessageUtil.messagePlayer(sender, ConstantUtil.IN_GAME_ONLY);
return;
}
// Checks if the player is null.
if (sender == null) {
MessageUtil.messagePlayer(commandSender, ConstantUtil.IN_GAME_ONLY);
return;
}

Location location = player.getLocation();
String playerName = player.getName();
if (args.length() == 2) {
// Sender data
PlayerData senderData = PlayerDataManager.getPlayerData(sender);
Location senderLoc = sender.getLocation();
String senderName = sender.getName();

// Target data
String desiredTarget = args.getArgs(0);
Player target = Bukkit.getPlayer(desiredTarget);

// Checks if the target is online.
if (target == null) {
MessageUtil.messagePlayer(player, ConstantUtil.PLAYER_NOT_FOUND);
MessageUtil.messagePlayer(sender, ConstantUtil.PLAYER_NOT_FOUND);
return;
}

String desiredAmount = args.getArgs(1);

// Checks if the amount is a number.
if (!StringUtils.isNumeric(desiredAmount)) {
MessageUtil.messagePlayer(player, "&c'" + desiredAmount + "' is not a valid amount.");
MessageUtil.messagePlayer(sender, "&c'" + desiredAmount + "' is not a valid amount.");
return;
}

int amount = Integer.parseInt(desiredAmount);

// Checks if the amount is negative.
if (amount < 0) {
MessageUtil.messagePlayer(player, "&cThe amount must be positive.");
MessageUtil.messagePlayer(sender, "&cThe amount must be positive.");
return;
}

// Checks if the sender is the target.
if (sender == target) {
player.playSound(location, Sound.VILLAGER_NO, 1.0F, 1.0F);
MessageUtil.messagePlayer(player, "&cYou can't pay yourself.");
if (commandSender == target) {
sender.playSound(senderLoc, Sound.VILLAGER_NO, 1.0F, 1.0F);
MessageUtil.messagePlayer(sender, "&cYou can't pay yourself.");
return;
}

// Target data
PlayerData targetData = PlayerDataManager.getPlayerData(target);
PlayerData senderData = PlayerDataManager.getPlayerData(player);
int targetCoins = targetData.getCoins();
String targetName = target.getName();

// Checks if the sender has enough coins.
if (senderData.getCoins() - amount <= 0) {
MessageUtil.messagePlayer(sender, ConstantUtil.NOT_ENOUGH_COINS);
MessageUtil.messagePlayer(commandSender, ConstantUtil.NOT_ENOUGH_COINS);
return;
}

int targetCoins = targetData.getCoins();

// Transfers the coins.
targetData.setCoins(targetCoins + amount);
senderData.removeCoins(amount);

MessageUtil.messagePlayer(player, "&a" + playerName + " sent you " + amount + " coins!");
MessageUtil.messagePlayer(sender, "&aYou sent " + playerName + " " + amount + " coins!");
return;
// Sends messages to the sender and target.
MessageUtil.messagePlayer(target, "&a" + senderName + " sent you " + amount + " coins!");
MessageUtil.messagePlayer(sender, "&aYou sent " + targetName + " " + amount + " coins!");
} else {
MessageUtil.messagePlayer(commandSender, "&cUsage: /pay <player> <amount>");
}

MessageUtil.messagePlayer(sender, "&cUsage: /pay <player> <amount>");
}
}
80 changes: 80 additions & 0 deletions src/main/java/net/foulest/kitpvp/cmds/PlaySoundCmd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* KitPvP - a fully-featured core plugin for the KitPvP gamemode.
* Copyright (C) 2024 Foulest (https://github.com/Foulest)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.foulest.kitpvp.cmds;

import lombok.Data;
import net.foulest.kitpvp.util.ConstantUtil;
import net.foulest.kitpvp.util.MessageUtil;
import net.foulest.kitpvp.util.command.Command;
import net.foulest.kitpvp.util.command.CommandArgs;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.Locale;

/**
* Command for testing different sounds.
*
* @author Foulest
*/
@Data
public class PlaySoundCmd {

@Command(name = "playsound", description = "Plays a specified or random sound.",
permission = "kitpvp.playsound", usage = "/playsound [name]", inGameOnly = true)
public static void onCommand(@NotNull CommandArgs args) {
CommandSender sender = args.getSender();
Player player = args.getPlayer();

// Checks if the player is null.
if (player == null) {
MessageUtil.messagePlayer(sender, ConstantUtil.IN_GAME_ONLY);
return;
}

Location location = player.getLocation();

// Prints the usage message.
if (args.length() > 1) {
MessageUtil.messagePlayer(sender, "&cUsage: /playsound [name]");
return;
}

// Plays a random sound.
if (args.length() == 0) {
// Randomly get a sound from the list.
Sound[] sounds = Sound.values();
Sound sound = sounds[(int) (Math.random() * sounds.length)];
String soundName = sound.name();

player.playSound(location, sound, 1.0F, 1.0F);
MessageUtil.messagePlayer(sender, "&aPlayed random sound: &e" + soundName);
return;
}

// Plays a specified sound.
String soundName = args.getArgs(0).toUpperCase(Locale.ROOT);
Sound sound = Sound.valueOf(soundName);

player.playSound(location, sound, 1.0F, 1.0F);
MessageUtil.messagePlayer(sender, "&aPlayed specified sound: &e" + soundName);
}
}
3 changes: 1 addition & 2 deletions src/main/java/net/foulest/kitpvp/cmds/SpawnCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import net.foulest.kitpvp.data.PlayerDataManager;
import net.foulest.kitpvp.region.Regions;
import net.foulest.kitpvp.region.Spawn;
import net.foulest.kitpvp.util.BlockUtil;
import net.foulest.kitpvp.util.ConstantUtil;
import net.foulest.kitpvp.util.MessageUtil;
import net.foulest.kitpvp.util.command.Command;
Expand Down Expand Up @@ -66,7 +65,7 @@ public static void onCommand(@NotNull CommandArgs args) {
}

// Checks if the player is on the ground.
if (!BlockUtil.isOnGroundOffset(player, 0.001)) {
if (player.getVelocity().getY() != -0.0784000015258789) {
MessageUtil.messagePlayer(args.getPlayer(), ConstantUtil.NOT_ON_GROUND);
return;
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/net/foulest/kitpvp/cooldown/Cooldown.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package net.foulest.kitpvp.cooldown;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.foulest.kitpvp.kits.Kit;
import org.bukkit.Material;
import org.bukkit.entity.Player;

@Data
@AllArgsConstructor
@EqualsAndHashCode
public class Cooldown {

public Player player;
public Kit kit;
public Material itemType;
@EqualsAndHashCode.Exclude
public long duration;
}
Loading

0 comments on commit 03bd440

Please sign in to comment.