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