fixed some lints and some bugs in the teams implementation

This commit is contained in:
2025-09-07 20:45:27 +01:00
parent 3ca436b7e4
commit ec542a6188
13 changed files with 378 additions and 173 deletions
@@ -12,7 +12,6 @@ public final class Fantasysmp extends JavaPlugin {
@Override
public void onEnable() {
Items items = new Items(this);
getCommand("items").setExecutor(items);
// Plugin startup logic
@@ -39,9 +38,9 @@ public final class Fantasysmp extends JavaPlugin {
heresyChecker.scheduleHeresyChecker();
getServer().getPluginManager().registerEvents(heresyChecker, this);
getServer().getPluginManager().registerEvents(new DeathMessageCustomiser(), this);
getServer()
.getPluginManager()
.registerEvents(new DeathMessageCustomiser(), this);
XrayDetector xrayDetector = new XrayDetector();
getServer().getPluginManager().registerEvents(xrayDetector, this);
@@ -115,6 +115,7 @@ public class XrayDetector implements Listener {
try {
reader = new BufferedReader(new FileReader(file));
this.token = reader.readLine();
reader.close();
} catch (Exception e) {
e.printStackTrace();
return;
@@ -1,5 +1,7 @@
package dev.zxq5.fantasysmp.groups;
import static org.bukkit.Bukkit.getServer;
import dev.zxq5.fantasysmp.chatutils.Chat;
import dev.zxq5.fantasysmp.warps.Warp;
import dev.zxq5.fantasysmp.warps.WarpType;
@@ -12,17 +14,17 @@ import org.bukkit.entity.Player;
*
* ** PLAYER **
*
* team list => TODO
* team create <name> => TODO
* team rename <new name> => TODO
* team list => DONE
* team create <name> => DONE
* team rename <new name> => TODO TEST
* team transfer <player> => TODO
* team join <name> => TODO
* team invite <player> => TODO
* team leave => TODO
* team disband => TODO
* team setwarp => TODO
* team disband => DONE
* team setwarp => DONE
* team delwarp => TODO
* team warp <name> => TODO
* team warp <name> => TODO TEST
* team kick => TODO
* team log => TODO
*
@@ -102,7 +104,6 @@ public class Commands implements CommandExecutor {
}
Team.createTeam(caller, args[1]);
Chat.success(caller, "Created team " + args[1] + "!");
}
public void handleSetColour(Player caller, String[] args) {
@@ -115,7 +116,6 @@ public class Commands implements CommandExecutor {
if (team == null) return;
team.setColour(caller, args[1]);
Chat.success(caller, "Set colour to " + args[1] + "!");
}
public void handleRename(Player caller, String[] args) {
@@ -135,7 +135,6 @@ public class Commands implements CommandExecutor {
if (team == null) return;
team.renameTeam(caller, args[1]);
Chat.success(caller, "Renamed team to " + args[1] + "!");
}
public void handleSetTag(Player caller, String[] args) {
@@ -170,6 +169,8 @@ public class Commands implements CommandExecutor {
Chat.error(caller, "Usage: /team transfer <player>");
return;
}
Team.fromMember(caller).transferTeam(caller, args[1]);
// Chat.success(caller, "Transferred ownership to: " + args[1] + "!");
}
@@ -25,6 +25,7 @@ public class Team {
private ArrayList<String> logs;
private String teamUUID;
private String tag;
private ChatColor color;
public Team(Player creator, String name, String tag) {
this.name = name;
@@ -103,23 +104,24 @@ public class Team {
return;
}
switch (colour) {
case "red" -> this.tag = ChatColor.RED + this.tag;
case "green" -> this.tag = ChatColor.GREEN + this.tag;
case "blue" -> this.tag = ChatColor.BLUE + this.tag;
case "yellow" -> this.tag = ChatColor.YELLOW + this.tag;
case "aqua" -> this.tag = ChatColor.AQUA + this.tag;
case "dark_aqua" -> this.tag = ChatColor.DARK_AQUA + this.tag;
case "dark_blue" -> this.tag = ChatColor.DARK_BLUE + this.tag;
case "dark_gray" -> this.tag = ChatColor.DARK_GRAY + this.tag;
case "dark_green" -> this.tag = ChatColor.DARK_GREEN + this.tag;
case "dark_purple" -> this.tag = ChatColor.DARK_PURPLE + this.tag;
case "gold" -> this.tag = ChatColor.GOLD + this.tag;
case "gray" -> this.tag = ChatColor.GRAY + this.tag;
case "light_purple" -> this.tag = ChatColor.LIGHT_PURPLE + this.tag;
case "white" -> this.tag = ChatColor.WHITE + this.tag;
case "black" -> this.tag = ChatColor.BLACK + this.tag;
}
this.color = switch (colour) {
case "red" -> ChatColor.RED;
case "green" -> ChatColor.GREEN;
case "blue" -> ChatColor.BLUE;
case "yellow" -> ChatColor.YELLOW;
case "aqua" -> ChatColor.AQUA;
case "dark_aqua" -> ChatColor.DARK_AQUA;
case "dark_blue" -> ChatColor.DARK_BLUE;
case "dark_gray" -> ChatColor.DARK_GRAY;
case "dark_green" -> ChatColor.DARK_GREEN;
case "dark_purple" -> ChatColor.DARK_PURPLE;
case "gold" -> ChatColor.GOLD;
case "gray" -> ChatColor.GRAY;
case "light_purple" -> ChatColor.LIGHT_PURPLE;
case "white" -> ChatColor.WHITE;
case "black" -> ChatColor.BLACK;
default -> ChatColor.WHITE;
};
this.log(
player.getName() + " changed the team colour to " + colour + "."
@@ -338,7 +340,7 @@ public class Team {
}
public String getTag() {
return this.tag;
return this.color + this.tag;
}
public static void error(Player player, Error error) {
@@ -1,37 +1,43 @@
package dev.zxq5.fantasysmp.items.gear;
import static org.bukkit.Bukkit.*;
import dev.zxq5.fantasysmp.items.GenericGearSet;
import dev.zxq5.fantasysmp.util.LoreChecker;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.*;
import org.bukkit.command.CommandExecutor;
import org.bukkit.damage.DamageType;
import org.bukkit.entity.Player;
import org.bukkit.entity.SmallFireball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.List;
public class BlazingGear extends GenericGearSet implements CommandExecutor {
import static org.bukkit.Bukkit.*;
public class BlazingGear extends GenericGearSet implements Listener, CommandExecutor {
private ArrayList<Player> cooldown = new ArrayList<>();
private final ArrayList<DamageType> damageTypes = new ArrayList<>(List.of(
DamageType.HOT_FLOOR,
DamageType.ON_FIRE,
DamageType.IN_FIRE,
DamageType.LAVA
));
private final ArrayList<DamageType> damageTypes = new ArrayList<>(
List.of(
DamageType.HOT_FLOOR,
DamageType.ON_FIRE,
DamageType.IN_FIRE,
DamageType.LAVA
)
);
@Override
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
public boolean onCommand(
org.bukkit.command.CommandSender sender,
org.bukkit.command.Command command,
String label,
String[] args
) {
Player player = (Player) sender;
player.getInventory().addItem(this.getSword());
player.getInventory().addItem(this.getHelmet());
@@ -46,15 +52,39 @@ public class BlazingGear extends GenericGearSet implements Listener, CommandExec
public void registerRecipes() {}
@EventHandler
public void onPlayerSetOnFire(org.bukkit.event.entity.EntityDamageEvent event) {
public void onPlayerSetOnFire(
org.bukkit.event.entity.EntityDamageEvent event
) {
if (!(event.getEntity() instanceof Player player)) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getHelmet(), this.helmet.lore))) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getChestplate(), this.chestplate.lore))) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getLeggings(), this.leggings.lore))) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getBoots(), this.boots.lore))) return;
if (
!(LoreChecker.itemLoreContains(
player.getInventory().getHelmet(),
this.helmet.lore
))
) return;
if (
!(LoreChecker.itemLoreContains(
player.getInventory().getChestplate(),
this.chestplate.lore
))
) return;
if (
!(LoreChecker.itemLoreContains(
player.getInventory().getLeggings(),
this.leggings.lore
))
) return;
if (
!(LoreChecker.itemLoreContains(
player.getInventory().getBoots(),
this.boots.lore
))
) return;
if (damageTypes.contains(event.getDamageSource().getDamageType())) event.setCancelled(true);
if (
damageTypes.contains(event.getDamageSource().getDamageType())
) event.setCancelled(true);
player.setFireTicks(0);
}
@@ -64,7 +94,10 @@ public class BlazingGear extends GenericGearSet implements Listener, CommandExec
Player player = event.getPlayer();
ItemStack item = event.getItem(); // Get the item the player interacted with
if (!(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
if (
!(event.getAction() == Action.RIGHT_CLICK_AIR ||
event.getAction() == Action.RIGHT_CLICK_BLOCK)
) {
return;
}
@@ -74,18 +107,37 @@ public class BlazingGear extends GenericGearSet implements Listener, CommandExec
Plugin plugin = getPluginManager().getPlugin("fantasysmp");
cooldown.add(player);
Bukkit.getScheduler().runTaskLater(plugin, () -> cooldown.remove(player), 25);
Bukkit.getScheduler().runTaskLater(
plugin,
() -> cooldown.remove(player),
25
);
shootFireball(player);
Bukkit.getScheduler().runTaskLater(plugin, () -> shootFireball(player), 4);
Bukkit.getScheduler().runTaskLater(plugin, () -> shootFireball(player), 8);
Bukkit.getScheduler().runTaskLater(
plugin,
() -> shootFireball(player),
4
);
Bukkit.getScheduler().runTaskLater(
plugin,
() -> shootFireball(player),
8
);
}
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (!(event.getDamager() instanceof Player player)) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getItemInMainHand(), this.sword.lore))) return;
if (event.getEntity().getFireTicks() < 240) event.getEntity().setFireTicks(240);
if (
!(LoreChecker.itemLoreContains(
player.getInventory().getItemInMainHand(),
this.sword.lore
))
) return;
if (event.getEntity().getFireTicks() < 240) event
.getEntity()
.setFireTicks(240);
}
public void shootFireball(Player player) {
@@ -107,11 +159,13 @@ public class BlazingGear extends GenericGearSet implements Listener, CommandExec
this.helmet.customItemModel = "blazing_helmet";
this.helmet.customEquipmentModel = "blazing";
this.chestplate.name = ChatColor.GOLD + "Blazing Chestplate" + ChatColor.RESET;
this.chestplate.name =
ChatColor.GOLD + "Blazing Chestplate" + ChatColor.RESET;
this.chestplate.customItemModel = "blazing_chestplate";
this.chestplate.customEquipmentModel = "blazing";
this.leggings.name = ChatColor.GOLD + "Blazing Leggings" + ChatColor.RESET;
this.leggings.name =
ChatColor.GOLD + "Blazing Leggings" + ChatColor.RESET;
this.leggings.customItemModel = "blazing_leggings";
this.leggings.customEquipmentModel = "blazing";
@@ -121,8 +175,10 @@ public class BlazingGear extends GenericGearSet implements Listener, CommandExec
this.sword.lore = "Forged from molten lava and the essence of blazes";
this.helmet.lore = "Forged from molten lava and the essence of blazes";
this.chestplate.lore = "Forged from molten lava and the essence of blazes";
this.leggings.lore = "Forged from molten lava and the essence of blazes";
this.chestplate.lore =
"Forged from molten lava and the essence of blazes";
this.leggings.lore =
"Forged from molten lava and the essence of blazes";
this.boots.lore = "Forged from molten lava and the essence of blazes";
}
}
@@ -6,11 +6,16 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class CrimsonGear extends GenericGearSet implements CommandExecutor, Listener {
public class CrimsonGear extends GenericGearSet implements CommandExecutor {
@Override
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
public boolean onCommand(
org.bukkit.command.CommandSender sender,
org.bukkit.command.Command command,
String label,
String[] args
) {
Player player = (Player) sender;
player.getInventory().addItem(this.getSword());
@@ -22,19 +27,50 @@ public class CrimsonGear extends GenericGearSet implements CommandExecutor, List
}
@EventHandler
public void onEntityDamageByEntity(org.bukkit.event.entity.EntityDamageByEntityEvent event) {
public void onEntityDamageByEntity(
org.bukkit.event.entity.EntityDamageByEntityEvent event
) {
if (!(event.getDamager() instanceof Player player)) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getItemInMainHand(), this.sword.lore))) return;
if (
!(LoreChecker.itemLoreContains(
player.getInventory().getItemInMainHand(),
this.sword.lore
))
) return;
player.setHealth( Math.min(player.getHealth() + 1, player.getMaxHealth()) );
player.setHealth(
Math.min(player.getHealth() + 1, player.getMaxHealth())
);
if (!(LoreChecker.itemLoreContains(player.getInventory().getHelmet(), this.helmet.lore))) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getChestplate(), this.chestplate.lore))) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getLeggings(), this.leggings.lore))) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getBoots(), this.boots.lore))) return;
if (
!(LoreChecker.itemLoreContains(
player.getInventory().getHelmet(),
this.helmet.lore
))
) return;
if (
!(LoreChecker.itemLoreContains(
player.getInventory().getChestplate(),
this.chestplate.lore
))
) return;
if (
!(LoreChecker.itemLoreContains(
player.getInventory().getLeggings(),
this.leggings.lore
))
) return;
if (
!(LoreChecker.itemLoreContains(
player.getInventory().getBoots(),
this.boots.lore
))
) return;
player.setHealth( Math.min(player.getHealth() + 1, player.getMaxHealth()) );
player.setFoodLevel( Math.min(player.getFoodLevel() + 1, 20) );
player.setHealth(
Math.min(player.getHealth() + 1, player.getMaxHealth())
);
player.setFoodLevel(Math.min(player.getFoodLevel() + 1, 20));
}
@Override
@@ -46,24 +82,31 @@ public class CrimsonGear extends GenericGearSet implements CommandExecutor, List
this.sword.customItemModel = "crimson_sword";
this.sword.lore = "Live off the blood of your enemies.";
this.helmet.name = ChatColor.DARK_RED + "Crimson Helmet" + ChatColor.RESET;
this.helmet.name =
ChatColor.DARK_RED + "Crimson Helmet" + ChatColor.RESET;
this.helmet.customItemModel = "crimson_helmet";
this.helmet.customEquipmentModel = "crimson";
this.helmet.lore = "A helmet that grants its wearer vampiric senses.";
this.chestplate.name = ChatColor.DARK_RED + "Crimson Chestplate" + ChatColor.RESET;
this.chestplate.name =
ChatColor.DARK_RED + "Crimson Chestplate" + ChatColor.RESET;
this.chestplate.customItemModel = "crimson_chestplate";
this.chestplate.customEquipmentModel = "crimson";
this.chestplate.lore = "A chestplate that strengthens the heart of the wearer.";
this.chestplate.lore =
"A chestplate that strengthens the heart of the wearer.";
this.leggings.name = ChatColor.DARK_RED + "Crimson Leggings" + ChatColor.RESET;
this.leggings.name =
ChatColor.DARK_RED + "Crimson Leggings" + ChatColor.RESET;
this.leggings.customItemModel = "crimson_leggings";
this.leggings.customEquipmentModel = "crimson";
this.leggings.lore = "Leggings that enhance the wearer's speed and agility.";
this.leggings.lore =
"Leggings that enhance the wearer's speed and agility.";
this.boots.name = ChatColor.DARK_RED + "Crimson Boots" + ChatColor.RESET;
this.boots.name =
ChatColor.DARK_RED + "Crimson Boots" + ChatColor.RESET;
this.boots.customItemModel = "crimson_boots";
this.boots.customEquipmentModel = "crimson";
this.boots.lore = "Boots that allow the wearer to move silently and swiftly.";
this.boots.lore =
"Boots that allow the wearer to move silently and swiftly.";
}
}
@@ -12,16 +12,13 @@ import org.bukkit.damage.DamageType;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.*;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
public class DragonGear
extends GenericGearSet
implements Listener, CommandExecutor {
public class DragonGear extends GenericGearSet implements CommandExecutor {
private ArrayList<Player> cooldown = new ArrayList<>();
@@ -2,25 +2,29 @@ package dev.zxq5.fantasysmp.items.gear;
import dev.zxq5.fantasysmp.items.GenericGearSet;
import dev.zxq5.fantasysmp.util.LoreChecker;
import java.util.ArrayList;
import java.util.Objects;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.*;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Objects;
public class EnderGear extends GenericGearSet implements CommandExecutor {
public class EnderGear extends GenericGearSet implements Listener, CommandExecutor {
private ArrayList<Player> cooldown = new ArrayList<>();
@Override
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
public boolean onCommand(
org.bukkit.command.CommandSender sender,
org.bukkit.command.Command command,
String label,
String[] args
) {
Player player = (Player) sender;
player.getInventory().addItem(this.getSword());
player.getInventory().addItem(this.getHelmet());
@@ -39,7 +43,10 @@ public class EnderGear extends GenericGearSet implements Listener, CommandExecut
Player player = event.getPlayer();
ItemStack item = event.getItem(); // Get the item the player interacted with
if (!(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
if (
!(event.getAction() == Action.RIGHT_CLICK_AIR ||
event.getAction() == Action.RIGHT_CLICK_BLOCK)
) {
return;
}
@@ -48,32 +55,52 @@ public class EnderGear extends GenericGearSet implements Listener, CommandExecut
Location old_location = player.getLocation();
World world = player.getWorld();
Vector direction = old_location.getDirection();
// find nearest block in that direction
Block block = player.getTargetBlock(null, 64);
if (block.getType() == Material.AIR || block.getType() == Material.CAVE_AIR) {
if (
block.getType() == Material.AIR ||
block.getType() == Material.CAVE_AIR
) {
return;
}
player.playSound(old_location, Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 1.0f);
player.playSound(
old_location,
Sound.ENTITY_ENDERMAN_TELEPORT,
1.0f,
1.0f
);
world.spawnParticle(Particle.PORTAL, old_location, 100);
Location new_location = block.getLocation();
new_location.setPitch(old_location.getPitch());
new_location.setYaw(old_location.getYaw());
player.setVelocity(new Vector(player.getVelocity().getX(), 0, player.getVelocity().getZ()));
player.setVelocity(
new Vector(
player.getVelocity().getX(),
0,
player.getVelocity().getZ()
)
);
player.teleport(new_location);
player.playSound(new_location, Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 1.0f);
player.playSound(
new_location,
Sound.ENTITY_ENDERMAN_TELEPORT,
1.0f,
1.0f
);
world.spawnParticle(Particle.PORTAL, new_location, 100);
cooldown.add(player);
Bukkit.getScheduler().scheduleSyncDelayedTask(
Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("fantasysmp")),
() -> cooldown.remove(player),
25
Objects.requireNonNull(
Bukkit.getPluginManager().getPlugin("fantasysmp")
),
() -> cooldown.remove(player),
25
);
}
@@ -84,15 +111,18 @@ public class EnderGear extends GenericGearSet implements Listener, CommandExecut
this.sword.name = ChatColor.DARK_AQUA + "Ender Sword" + ChatColor.RESET;
this.sword.customItemModel = "ender_sword";
this.helmet.name = ChatColor.DARK_AQUA + "Ender Helmet" + ChatColor.RESET;
this.helmet.name =
ChatColor.DARK_AQUA + "Ender Helmet" + ChatColor.RESET;
this.helmet.customItemModel = "ender_helmet";
this.helmet.customEquipmentModel = "ender";
this.chestplate.name = ChatColor.DARK_AQUA + "Ender Chestplate" + ChatColor.RESET;
this.chestplate.name =
ChatColor.DARK_AQUA + "Ender Chestplate" + ChatColor.RESET;
this.chestplate.customItemModel = "ender_chestplate";
this.chestplate.customEquipmentModel = "ender";
this.leggings.name = ChatColor.DARK_AQUA + "Ender Leggings" + ChatColor.RESET;
this.leggings.name =
ChatColor.DARK_AQUA + "Ender Leggings" + ChatColor.RESET;
this.leggings.customItemModel = "ender_leggings";
this.leggings.customEquipmentModel = "ender";
@@ -102,8 +132,10 @@ public class EnderGear extends GenericGearSet implements Listener, CommandExecut
this.sword.lore = "A sword forged from the essence of ender pearls,";
this.helmet.lore = "A helmet forged from the essence of ender pearls,";
this.chestplate.lore = "A chestplate forged from the essence of ender pearls,";
this.leggings.lore = "Leggings forged from the essence of ender pearls,";
this.chestplate.lore =
"A chestplate forged from the essence of ender pearls,";
this.leggings.lore =
"Leggings forged from the essence of ender pearls,";
this.boots.lore = "Boots forged from the essence of ender pearls,";
}
}
@@ -1,5 +1,7 @@
package dev.zxq5.fantasysmp.items.gear;
import static org.bukkit.Bukkit.getServer;
import dev.zxq5.fantasysmp.items.GenericGearSet;
import dev.zxq5.fantasysmp.util.LoreChecker;
import org.bukkit.Location;
@@ -9,17 +11,19 @@ import org.bukkit.World;
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.potion.PotionEffectType;
import static org.bukkit.Bukkit.getServer;
public class LightningSword extends GenericGearSet implements Listener, CommandExecutor {
public class LightningSword extends GenericGearSet implements CommandExecutor {
@Override
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
public boolean onCommand(
org.bukkit.command.CommandSender sender,
org.bukkit.command.Command command,
String label,
String[] args
) {
Player player = (Player) sender;
player.getInventory().addItem(this.getSword());
return true;
@@ -28,7 +32,10 @@ public class LightningSword extends GenericGearSet implements Listener, CommandE
@Override
public void registerRecipes() {
ItemStack sword = this.getSword();
NamespacedKey swordKey = new NamespacedKey("fantasysmp.items", "lightning_sword");
NamespacedKey swordKey = new NamespacedKey(
"fantasysmp.items",
"lightning_sword"
);
ShapedRecipe swordRecipe = new ShapedRecipe(swordKey, sword);
swordRecipe.shape(" N ", " N ", " R ");
swordRecipe.setIngredient('N', Material.NETHER_STAR);
@@ -37,23 +44,29 @@ public class LightningSword extends GenericGearSet implements Listener, CommandE
}
@EventHandler
public void onEntityDamageByEntity(org.bukkit.event.entity.EntityDamageByEntityEvent event) {
public void onEntityDamageByEntity(
org.bukkit.event.entity.EntityDamageByEntityEvent event
) {
// checks that it is a player that is performing the attack.
if (!(event.getDamager() instanceof org.bukkit.entity.Player player)) {
return;
}
if (!( LoreChecker.itemLoreContains(player.getInventory().getItemInMainHand(), this.sword.lore) )) return;
if (
player.isOnGround()
|| player.getVelocity().getY() >= 0
|| player.isClimbing()
|| player.isInWater()
|| player.isInsideVehicle()
|| player.hasPotionEffect(PotionEffectType.BLINDNESS)
!(LoreChecker.itemLoreContains(
player.getInventory().getItemInMainHand(),
this.sword.lore
))
) return;
if (
player.isOnGround() ||
player.getVelocity().getY() >= 0 ||
player.isClimbing() ||
player.isInWater() ||
player.isInsideVehicle() ||
player.hasPotionEffect(PotionEffectType.BLINDNESS)
) return;
Location location = event.getEntity().getLocation();
World world = location.getWorld();
@@ -64,17 +77,25 @@ public class LightningSword extends GenericGearSet implements Listener, CommandE
}
@EventHandler
public void onEntityDamage(org.bukkit.event.entity.EntityDamageEvent event) {
public void onEntityDamage(
org.bukkit.event.entity.EntityDamageEvent event
) {
if (event.getEntity() instanceof Player player) {
if (!(event
.getDamageSource()
.getDamageType()
.getKey()
.toString()
.equals("minecraft:lightning_bolt")
)) return;
if (
!(event
.getDamageSource()
.getDamageType()
.getKey()
.toString()
.equals("minecraft:lightning_bolt"))
) return;
if (LoreChecker.itemLoreContains(player.getInventory().getItemInMainHand(), this.sword.lore)) {
if (
LoreChecker.itemLoreContains(
player.getInventory().getItemInMainHand(),
this.sword.lore
)
) {
event.setCancelled(true);
return;
}
@@ -83,13 +104,29 @@ public class LightningSword extends GenericGearSet implements Listener, CommandE
@EventHandler
public void onEntityDeath(org.bukkit.event.entity.EntityDeathEvent event) {
if (event.getEntity() instanceof Mob mob) {
if (event.getEntity() instanceof Mob) {
if (
event.getDamageSource().getDamageType().getKey().toString().equals("minecraft:lightning_bolt")
|| event.getDamageSource().getDamageType().getKey().toString().equals("minecraft:on_fire")
event
.getDamageSource()
.getDamageType()
.getKey()
.toString()
.equals("minecraft:lightning_bolt") ||
event
.getDamageSource()
.getDamageType()
.getKey()
.toString()
.equals("minecraft:on_fire")
) {
Entity e = event.getEntity();
((ExperienceOrb) e.getLocation().getWorld().spawn(e.getLocation(), ExperienceOrb.class)).setExperience(10);
((ExperienceOrb) e
.getLocation()
.getWorld()
.spawn(
e.getLocation(),
ExperienceOrb.class
)).setExperience(10);
}
}
}
@@ -9,12 +9,9 @@ import org.bukkit.Material;
import org.bukkit.command.CommandExecutor;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
public class PoseidonGear
extends GenericGearSet
implements CommandExecutor, Listener {
public class PoseidonGear extends GenericGearSet implements CommandExecutor {
@Override
public boolean onCommand(
@@ -6,21 +6,29 @@ import org.bukkit.*;
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class StevensWrath extends GenericGearSet implements Listener, CommandExecutor {
public class StevensWrath extends GenericGearSet implements CommandExecutor {
@Override
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
public boolean onCommand(
org.bukkit.command.CommandSender sender,
org.bukkit.command.Command command,
String label,
String[] args
) {
Player player = (Player) sender;
player.getInventory().addItem(this.getSword());
return true;
}
@EventHandler
public void onCraft(org.bukkit.event.inventory.PrepareItemCraftEvent event) {
public void onCraft(
org.bukkit.event.inventory.PrepareItemCraftEvent event
) {
if (!event.getInventory().contains(Material.NETHERITE_BLOCK)) return;
if (!event.getInventory().contains(new LightningSword().getSword())) return;
if (
!event.getInventory().contains(new LightningSword().getSword())
) return;
event.getInventory().setResult(new StevensWrath().getSword());
}
@@ -28,17 +36,24 @@ public class StevensWrath extends GenericGearSet implements Listener, CommandExe
public void registerRecipes() {}
@EventHandler
public void onEntityDamageByEntity(org.bukkit.event.entity.EntityDamageByEntityEvent event) {
public void onEntityDamageByEntity(
org.bukkit.event.entity.EntityDamageByEntityEvent event
) {
// checks that it is a player that is performing the attack.
if (!(event.getDamager() instanceof org.bukkit.entity.Player player)) {
return;
}
if (!(
LoreChecker.itemLoreContains(player.getInventory().getItemInMainHand(), this.sword.lore)
|| LoreChecker.itemLoreContains(player.getInventory().getItemInOffHand(), this.sword.lore)
)) return;
if (
!(LoreChecker.itemLoreContains(
player.getInventory().getItemInMainHand(),
this.sword.lore
) ||
LoreChecker.itemLoreContains(
player.getInventory().getItemInOffHand(),
this.sword.lore
))
) return;
Location location = event.getEntity().getLocation();
World world = location.getWorld();
@@ -49,19 +64,29 @@ public class StevensWrath extends GenericGearSet implements Listener, CommandExe
}
@EventHandler
public void onEntityDamage(org.bukkit.event.entity.EntityDamageEvent event) {
public void onEntityDamage(
org.bukkit.event.entity.EntityDamageEvent event
) {
if (event.getEntity() instanceof Player player) {
if (
!(event
.getDamageSource()
.getDamageType()
.getKey()
.toString()
.equals("minecraft:lightning_bolt"))
) return;
if (!(event
.getDamageSource()
.getDamageType()
.getKey()
.toString()
.equals("minecraft:lightning_bolt")
)) return;
if (LoreChecker.itemLoreContains(player.getInventory().getItemInMainHand(), this.sword.lore) ||
LoreChecker.itemLoreContains(player.getInventory().getItemInOffHand(), this.sword.lore)) {
if (
LoreChecker.itemLoreContains(
player.getInventory().getItemInMainHand(),
this.sword.lore
) ||
LoreChecker.itemLoreContains(
player.getInventory().getItemInOffHand(),
this.sword.lore
)
) {
event.setCancelled(true);
}
}
@@ -71,8 +96,11 @@ public class StevensWrath extends GenericGearSet implements Listener, CommandExe
public StevensWrath() {
this.setTier6();
this.sword.name = ChatColor.LIGHT_PURPLE + "Stevens Wrath" + ChatColor.RESET;
this.sword.name =
ChatColor.LIGHT_PURPLE + "Stevens Wrath" + ChatColor.RESET;
this.sword.customItemModel = "stevens_wrath";
this.sword.lore = ChatColor.LIGHT_PURPLE + "All who oppose the mighty Steven shall face his wrath of lightning.";
this.sword.lore =
ChatColor.LIGHT_PURPLE +
"All who oppose the mighty Steven shall face his wrath of lightning.";
}
}
@@ -4,11 +4,18 @@ import dev.zxq5.fantasysmp.items.GenericGearSet;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
public class TrueNetheriteGear extends GenericGearSet implements CommandExecutor, Listener {
public class TrueNetheriteGear
extends GenericGearSet
implements CommandExecutor {
@Override
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
public boolean onCommand(
org.bukkit.command.CommandSender sender,
org.bukkit.command.Command command,
String label,
String[] args
) {
Player player = (Player) sender;
player.getInventory().addItem(this.getSword());
@@ -24,27 +31,35 @@ public class TrueNetheriteGear extends GenericGearSet implements CommandExecutor
public TrueNetheriteGear() {
this.setTier6();
this.sword.name = ChatColor.WHITE + "True Netherite Sword" + ChatColor.RESET;
this.sword.name =
ChatColor.WHITE + "True Netherite Sword" + ChatColor.RESET;
this.sword.lore = "A sword forged with the skulls of wither skeletons.";
this.sword.customItemModel = "true_netherite_sword";
this.sword.lore = "Destruction awaits.";
this.helmet.name = ChatColor.WHITE + "True Netherite Helmet" + ChatColor.RESET;
this.helmet.lore = "A helmet forged with the skulls of wither skeletons.";
this.helmet.name =
ChatColor.WHITE + "True Netherite Helmet" + ChatColor.RESET;
this.helmet.lore =
"A helmet forged with the skulls of wither skeletons.";
this.helmet.customItemModel = "true_netherite_helmet";
this.helmet.customEquipmentModel = "true_netherite";
this.chestplate.name = ChatColor.WHITE + "True Netherite Chestplate" + ChatColor.RESET;
this.chestplate.lore = "A chestplate forged with the skulls of wither skeletons.";
this.chestplate.name =
ChatColor.WHITE + "True Netherite Chestplate" + ChatColor.RESET;
this.chestplate.lore =
"A chestplate forged with the skulls of wither skeletons.";
this.chestplate.customItemModel = "true_netherite_chestplate";
this.chestplate.customEquipmentModel = "true_netherite";
this.leggings.name = ChatColor.WHITE + "True Netherite Leggings" + ChatColor.RESET;
this.leggings.lore = "Leggings forged with the skulls of wither skeletons.";
this.leggings.name =
ChatColor.WHITE + "True Netherite Leggings" + ChatColor.RESET;
this.leggings.lore =
"Leggings forged with the skulls of wither skeletons.";
this.leggings.customItemModel = "true_netherite_leggings";
this.leggings.customEquipmentModel = "true_netherite";
this.boots.name = ChatColor.WHITE + "True Netherite Boots" + ChatColor.RESET;
this.boots.name =
ChatColor.WHITE + "True Netherite Boots" + ChatColor.RESET;
this.boots.lore = "Boots forged with the skulls of wither skeletons.";
this.boots.customItemModel = "true_netherite_boots";
this.boots.customEquipmentModel = "true_netherite";
@@ -12,7 +12,6 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.WitherSkull;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
@@ -20,9 +19,7 @@ import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.SmithingTransformRecipe;
import org.bukkit.potion.PotionEffect;
public class WitheriteGear
extends GenericGearSet
implements Listener, CommandExecutor {
public class WitheriteGear extends GenericGearSet implements CommandExecutor {
private ArrayList<Player> cooldown = new ArrayList<>();