worked on anticheat, added new item sets, refactored warps, working on teams and ranks - will be integrated with the warps system. working on general stability improvements / bugfixes
Java CI with Maven / build (push) Successful in 1m16s
Java CI with Maven / build (push) Successful in 1m16s
This commit is contained in:
@@ -2,6 +2,7 @@ package dev.zxq5.fantasysmp;
|
||||
|
||||
import dev.zxq5.fantasysmp.events.HereticWarner;
|
||||
import dev.zxq5.fantasysmp.events.StevenKillCheck;
|
||||
import dev.zxq5.fantasysmp.events.XrayDetector;
|
||||
import dev.zxq5.fantasysmp.items.*;
|
||||
import dev.zxq5.fantasysmp.warps.Warp;
|
||||
import dev.zxq5.fantasysmp.warps.Warper;
|
||||
@@ -24,19 +25,19 @@ public final class Fantasysmp extends JavaPlugin {
|
||||
|
||||
getCommand("home").setExecutor(new Warper());
|
||||
getCommand("sethome").setExecutor(new Warper());
|
||||
|
||||
getCommand("setwarp").setExecutor(new Warper());
|
||||
getCommand("delwarp").setExecutor(new Warper());
|
||||
getCommand("warp").setExecutor(new Warper());
|
||||
|
||||
getCommand("reloadwarps").setExecutor(new Warper());
|
||||
|
||||
getServer().broadcastMessage("registered commands + \n /home \n /sethome \n /warp \n /setwarp");
|
||||
getCommand("rewarps").setExecutor(new Warper());
|
||||
getCommand("warps").setExecutor(new Warper());
|
||||
|
||||
getServer().getPluginManager().registerEvents(new StevenKillCheck(), this);
|
||||
|
||||
HereticWarner hereticWarner = new HereticWarner();
|
||||
hereticWarner.checkHereticInventory();
|
||||
|
||||
XrayDetector xrayDetector = new XrayDetector();
|
||||
getServer().getPluginManager().registerEvents(xrayDetector, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package dev.zxq5.fantasysmp.chatutils;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class Chat {
|
||||
public static String EVENTPREFIX = ChatColor.WHITE + "<" + ChatColor.AQUA + "Server" + ChatColor.WHITE + "> " + ChatColor.RESET;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.zxq5.fantasysmp.events;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -8,15 +9,24 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.bukkit.Bukkit.getConsoleSender;
|
||||
import static org.bukkit.Bukkit.getPluginManager;
|
||||
import static org.bukkit.Bukkit.*;
|
||||
|
||||
public class XrayDetector implements Listener {
|
||||
private HashMap<Player, HashMap<Material, Integer>> players = new HashMap<>();
|
||||
private final HashMap<Player, HashMap<Material, Integer>> players = new HashMap<>();
|
||||
private String token;
|
||||
|
||||
private final ArrayList<Material> trackedBlocks = new ArrayList<>(Arrays.asList(
|
||||
Material.ANCIENT_DEBRIS,
|
||||
@@ -31,13 +41,12 @@ public class XrayDetector implements Listener {
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
HashMap<Material, Integer> blocks = this.players.get(player);
|
||||
HashMap<Material, Integer> blocks;
|
||||
Material block = event.getBlock().getType();
|
||||
Plugin plugin = getPluginManager().getPlugin("fantasysmp");
|
||||
|
||||
if (!this.players.containsKey(player)) {
|
||||
this.players.put(player, new HashMap<>());
|
||||
}
|
||||
if (!this.players.containsKey(player)) this.players.put(player, new HashMap<>());
|
||||
blocks = this.players.get(player);
|
||||
|
||||
if (this.trackedBlocks.contains(block)) {
|
||||
if (!(blocks.containsKey(block))) blocks.put(block, 0);
|
||||
@@ -45,13 +54,71 @@ public class XrayDetector implements Listener {
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
blocks.put(block, blocks.get(block) - 1);
|
||||
}, 18000);
|
||||
}, 1200);
|
||||
}
|
||||
}
|
||||
|
||||
for (HashMap.Entry<Material, Integer> nextBlock : blocks.entrySet()) {
|
||||
if (nextBlock.getValue() > 30) {
|
||||
getConsoleSender().sendMessage("Player " + player.getName() + " has broken 30 " + nextBlock.getKey().name() + " in the last 30 minutes!!! (possible xray)");
|
||||
private void uploadData() {
|
||||
HashMap<String, HashMap<String, Integer>> data = new HashMap<>();
|
||||
for (Map.Entry<Player, HashMap<Material, Integer>> entry : players.entrySet()) {
|
||||
HashMap<String, Integer> materials = new HashMap<>();
|
||||
|
||||
for (Map.Entry<Material, Integer> materialEntry : entry.getValue().entrySet()) {
|
||||
materials.put(materialEntry.getKey().toString(), materialEntry.getValue());
|
||||
}
|
||||
|
||||
data.put(entry.getKey().getName(), materials);
|
||||
}
|
||||
|
||||
Gson gson = new Gson();
|
||||
|
||||
HttpClient client = HttpClient.newHttpClient();
|
||||
HttpRequest request = HttpRequest.newBuilder(URI.create("https://mcapi.zxq5.dev/xray?token=" + token))
|
||||
.header("Content-Type", "application/json")
|
||||
.POST(HttpRequest.BodyPublishers.ofString(gson.toJson(data)))
|
||||
.build();
|
||||
|
||||
client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
|
||||
.thenApply(HttpResponse::body)
|
||||
.join();
|
||||
}
|
||||
|
||||
public XrayDetector() {
|
||||
File dataFolder = getServer().getPluginManager().getPlugin("Fantasysmp").getDataFolder();
|
||||
File file = new File(dataFolder, "token.txt");
|
||||
|
||||
BufferedReader reader;
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
this.token = reader.readLine();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(getPluginManager().getPlugin("fantasysmp"), this::uploadData, 0, 20 * 60);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package dev.zxq5.fantasysmp.groups;
|
||||
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/*
|
||||
* Commands:
|
||||
*
|
||||
* ** PLAYER **
|
||||
*
|
||||
* team list => TODO
|
||||
* team create <name> => TODO
|
||||
* team <name> rename <new name> => TODO
|
||||
* team <name> transfer <player> => TODO
|
||||
* team join <name> => TODO
|
||||
* team <name> invite <player> => TODO
|
||||
* team <name> leave => TODO
|
||||
* team <name> disband => TODO
|
||||
* team <name> setwarp => TODO
|
||||
* team delwarp => TODO
|
||||
* team kick => TODO
|
||||
* team log => TODO
|
||||
*
|
||||
* ** ADMIN ONLY **
|
||||
*
|
||||
* rank create <name> => TODO
|
||||
* rank <name> rename <new name> => TODO
|
||||
* rank <name> delete => TODO
|
||||
* rank add <player> <name> => TODO
|
||||
* rank remove <player> <name> => TODO
|
||||
* */
|
||||
|
||||
public class Commands implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player player)) return false;
|
||||
|
||||
if (command.getName().equals("team")) handleTeamCommands(player, args);
|
||||
if (command.getName().equals("rank")) handleRankCommands(player, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void handleTeamCommands(Player player, String[] args) {}
|
||||
|
||||
public void handleRankCommands(Player player, String[] args) {}
|
||||
|
||||
public Commands() {}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package dev.zxq5.fantasysmp.groups;
|
||||
|
||||
public class Ranks {
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package dev.zxq5.fantasysmp.groups;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import java.io.*;
|
||||
import static org.bukkit.Bukkit.getServer;
|
||||
|
||||
public class Team {
|
||||
private static Team[] teams;
|
||||
|
||||
private String name;
|
||||
private String ownerUUID;
|
||||
private String[] members;
|
||||
private String[] tag;
|
||||
|
||||
public static void loadTeams() throws Exception {
|
||||
File dataFolder = getServer().getPluginManager().getPlugin("Fantasysmp").getDataFolder();
|
||||
File file = new File(dataFolder, "warps.json");
|
||||
|
||||
if (!file.exists()) {
|
||||
createTeamsFile();
|
||||
}
|
||||
|
||||
BufferedReader reader;
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
|
||||
Gson gson = new Gson();
|
||||
teams = gson.fromJson(reader, Team[].class);
|
||||
|
||||
reader.close();
|
||||
}
|
||||
|
||||
public static void saveTeams() throws Exception {
|
||||
File dataFolder = getServer().getPluginManager().getPlugin("Fantasysmp").getDataFolder();
|
||||
File file = new File(dataFolder, "teams.json");
|
||||
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(teams);
|
||||
Writer writer = new FileWriter(file);
|
||||
writer.write(json);
|
||||
writer.close();
|
||||
}
|
||||
|
||||
public static void createTeamsFile() {
|
||||
File dataFolder = getServer().getPluginManager().getPlugin("Fantasysmp").getDataFolder();
|
||||
File file = new File(dataFolder, "teams.json");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
Team[] t = new Team[0];
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(t);
|
||||
Writer writer = new FileWriter(file);
|
||||
writer.write(json);
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
package dev.zxq5.fantasysmp.items;
|
||||
|
||||
import dev.zxq5.fantasysmp.util.LoreChecker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@@ -123,6 +125,14 @@ public abstract class GenericGearSet implements HasRecipes, Listener {
|
||||
boots.knockbackResistance = 0.1;
|
||||
}
|
||||
|
||||
public boolean hasGear(Player player) {
|
||||
return (LoreChecker.itemLoreContains(player.getInventory().getHelmet(), this.helmet.lore)
|
||||
&& LoreChecker.itemLoreContains(player.getInventory().getChestplate(), this.chestplate.lore)
|
||||
&& LoreChecker.itemLoreContains(player.getInventory().getLeggings(), this.leggings.lore)
|
||||
&& LoreChecker.itemLoreContains(player.getInventory().getBoots(), this.boots.lore)
|
||||
);
|
||||
}
|
||||
|
||||
// this must be overridden by the child class.
|
||||
public static void init() {}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package dev.zxq5.fantasysmp.items;
|
||||
|
||||
import dev.zxq5.fantasysmp.items.food.AppleCider;
|
||||
import dev.zxq5.fantasysmp.items.food.AppleJuice;
|
||||
import dev.zxq5.fantasysmp.items.gear.*;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -37,6 +39,9 @@ public class Items implements CommandExecutor {
|
||||
case "blazing" -> handler = new BlazingGear();
|
||||
case "dragon" -> handler = new DragonGear();
|
||||
case "trueneth" -> handler = new TrueNetheriteGear();
|
||||
case "ender" -> handler = new EnderGear();
|
||||
case "poseidon" -> handler = new PoseidonGear();
|
||||
case "crimson" -> handler = new CrimsonGear();
|
||||
default -> { return false; }
|
||||
}
|
||||
|
||||
@@ -67,8 +72,26 @@ public class Items implements CommandExecutor {
|
||||
dragon.registerRecipes();
|
||||
dragon.registerEvents(plugin);
|
||||
|
||||
EnderGear ender = new EnderGear();
|
||||
ender.registerRecipes();
|
||||
ender.registerEvents(plugin);
|
||||
|
||||
TrueNetheriteGear trueNetherite = new TrueNetheriteGear();
|
||||
trueNetherite.registerRecipes();
|
||||
trueNetherite.registerEvents(plugin);
|
||||
|
||||
PoseidonGear poseidon = new PoseidonGear();
|
||||
poseidon.registerRecipes();
|
||||
poseidon.registerEvents(plugin);
|
||||
|
||||
CrimsonGear crimson = new CrimsonGear();
|
||||
crimson.registerRecipes();
|
||||
crimson.registerEvents(plugin);
|
||||
|
||||
AppleJuice appleJuice = new AppleJuice();
|
||||
appleJuice.registerEvents(plugin);
|
||||
|
||||
AppleCider appleCider = new AppleCider();
|
||||
appleCider.registerEvents(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package dev.zxq5.fantasysmp.items.food;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.inventory.meta.components.FoodComponent;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class AppleCider extends GenericDrink {
|
||||
|
||||
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.getDrink());
|
||||
return true;
|
||||
}
|
||||
|
||||
public AppleCider() {
|
||||
this.name = "Apple Cider";
|
||||
this.lore = "A stronger drink";
|
||||
|
||||
this.ingredients.put(new ItemStack(Material.APPLE, 1), 1);
|
||||
this.ingredients.put(new AppleJuice().getDrink(), 1);
|
||||
this.ingredients.put(new ItemStack(Material.SUGAR, 1), 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDrink() {
|
||||
ItemStack item = super.getDrink();
|
||||
PotionMeta meta = (PotionMeta) item.getItemMeta();
|
||||
|
||||
if (meta == null) {
|
||||
Bukkit.getConsoleSender().sendMessage("Meta is null on a drink!!!!! this should not happen!!!!");
|
||||
return item;
|
||||
}
|
||||
|
||||
meta.addCustomEffect(new org.bukkit.potion.PotionEffect(
|
||||
PotionEffectType.SATURATION, 20, 5
|
||||
), true);
|
||||
meta.addCustomEffect(new org.bukkit.potion.PotionEffect(
|
||||
PotionEffectType.SPEED, 10 * 20, 1
|
||||
), true);
|
||||
|
||||
meta.setColor(org.bukkit.Color.fromRGB(255, 255, 0));
|
||||
meta.setMaxStackSize(16);
|
||||
FoodComponent food = meta.getFood();
|
||||
food.setNutrition(8);
|
||||
food.setSaturation(8);
|
||||
food.setCanAlwaysEat(true);
|
||||
meta.setFood(food);
|
||||
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package dev.zxq5.fantasysmp.items.food;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.inventory.meta.components.FoodComponent;
|
||||
|
||||
public class AppleJuice extends GenericDrink {
|
||||
|
||||
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.getDrink());
|
||||
return true;
|
||||
}
|
||||
|
||||
public AppleJuice() {
|
||||
this.name = "Apple Juice";
|
||||
this.lore = "A refreshing drink";
|
||||
|
||||
this.ingredients.put(new ItemStack(Material.APPLE, 1), 1);
|
||||
this.ingredients.put(GenericDrink.WATER_BOTTLE, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDrink() {
|
||||
ItemStack item = super.getDrink();
|
||||
PotionMeta meta = (PotionMeta) item.getItemMeta();
|
||||
|
||||
meta.setColor(org.bukkit.Color.fromRGB(255, 255, 0));
|
||||
meta.setMaxStackSize(16);
|
||||
FoodComponent food = meta.getFood();
|
||||
food.setNutrition(6);
|
||||
food.setSaturation(6);
|
||||
food.setCanAlwaysEat(true);
|
||||
meta.setFood(food);
|
||||
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,25 +1,52 @@
|
||||
package dev.zxq5.fantasysmp.items.food;
|
||||
|
||||
import dev.zxq5.fantasysmp.items.HasRecipes;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class GenericDrink implements Listener, CommandExecutor, HasRecipes {
|
||||
public String name;
|
||||
public String lore;
|
||||
protected static ItemStack WATER_BOTTLE = new ItemStack(Material.GLASS_BOTTLE, 1);
|
||||
protected HashMap<ItemStack, Integer> ingredients = new HashMap<>();
|
||||
|
||||
protected String name;
|
||||
protected String lore;
|
||||
|
||||
public void registerEvents(Plugin plugin) {
|
||||
Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public abstract void itemCraftingHandler(org.bukkit.event.inventory.PrepareItemCraftEvent event);
|
||||
public void itemCraftingHandler(org.bukkit.event.inventory.PrepareItemCraftEvent event) {
|
||||
ItemStack item = getDrink();
|
||||
int sum = ingredients
|
||||
.values()
|
||||
.stream()
|
||||
.mapToInt(Integer::intValue)
|
||||
.sum();
|
||||
|
||||
long count = Arrays
|
||||
.stream(event.getInventory().getMatrix())
|
||||
.filter(Objects::nonNull)
|
||||
.mapToInt(ItemStack::getAmount)
|
||||
.sum();
|
||||
|
||||
if (sum != count) return;
|
||||
for (ItemStack ingredient : ingredients.keySet()) {
|
||||
if (!event.getInventory().containsAtLeast(ingredient, ingredients.get(ingredient))) return;
|
||||
}
|
||||
event.getInventory().setResult(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args);
|
||||
public abstract boolean onCommand(org.bukkit.command.CommandSender csender, org.bukkit.command.Command command, String label, String[] args);
|
||||
|
||||
public abstract void registerRecipes();
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.bukkit.Bukkit.*;
|
||||
@@ -30,6 +31,13 @@ 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
|
||||
));
|
||||
|
||||
@Override
|
||||
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
@@ -54,9 +62,7 @@ public class BlazingGear extends GenericGearSet implements Listener, CommandExec
|
||||
if (!(LoreChecker.itemLoreContains(player.getInventory().getLeggings(), this.leggings.lore))) return;
|
||||
if (!(LoreChecker.itemLoreContains(player.getInventory().getBoots(), this.boots.lore))) return;
|
||||
|
||||
if (event.getDamageSource().getDamageType() == DamageType.ON_FIRE) event.setCancelled(true);
|
||||
if (event.getDamageSource().getDamageType() == DamageType.IN_FIRE) event.setCancelled(true);
|
||||
if (event.getDamageSource().getDamageType() == DamageType.LAVA) event.setCancelled(true);
|
||||
if (damageTypes.contains(event.getDamageSource().getDamageType())) event.setCancelled(true);
|
||||
|
||||
player.setFireTicks(0);
|
||||
}
|
||||
@@ -102,22 +108,22 @@ public class BlazingGear extends GenericGearSet implements Listener, CommandExec
|
||||
|
||||
public BlazingGear() {
|
||||
this.setTier4();
|
||||
this.sword.name = "Blazing Sword";
|
||||
this.sword.name = ChatColor.GOLD + "Blazing Sword" + ChatColor.RESET;
|
||||
this.sword.customItemModel = "blazing_sword";
|
||||
|
||||
this.helmet.name = "Blazing Helmet";
|
||||
this.helmet.name = ChatColor.GOLD + "Blazing Helmet" + ChatColor.RESET;
|
||||
this.helmet.customItemModel = "blazing_helmet";
|
||||
this.helmet.customEquipmentModel = "blazing";
|
||||
|
||||
this.chestplate.name = "Blazing Chestplate";
|
||||
this.chestplate.name = ChatColor.GOLD + "Blazing Chestplate" + ChatColor.RESET;
|
||||
this.chestplate.customItemModel = "blazing_chestplate";
|
||||
this.chestplate.customEquipmentModel = "blazing";
|
||||
|
||||
this.leggings.name = "Blazing Leggings";
|
||||
this.leggings.name = ChatColor.GOLD + "Blazing Leggings" + ChatColor.RESET;
|
||||
this.leggings.customItemModel = "blazing_leggings";
|
||||
this.leggings.customEquipmentModel = "blazing";
|
||||
|
||||
this.boots.name = "Blazing Boots";
|
||||
this.boots.name = ChatColor.GOLD + "Blazing Boots" + ChatColor.RESET;
|
||||
this.boots.customItemModel = "blazing_boots";
|
||||
this.boots.customEquipmentModel = "blazing";
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package dev.zxq5.fantasysmp.items.gear;
|
||||
|
||||
import dev.zxq5.fantasysmp.items.GenericGearSet;
|
||||
import dev.zxq5.fantasysmp.util.LoreChecker;
|
||||
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 {
|
||||
@Override
|
||||
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());
|
||||
player.getInventory().addItem(this.getChestplate());
|
||||
player.getInventory().addItem(this.getLeggings());
|
||||
player.getInventory().addItem(this.getBoots());
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
player.setHealth( Math.min(player.getHealth() + 1, player.getMaxHealth()) );
|
||||
player.setFoodLevel( Math.min(player.getFoodLevel() + 1, 20) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {}
|
||||
|
||||
public CrimsonGear() {
|
||||
this.setTier5();
|
||||
this.sword.name = ChatColor.DARK_RED + "Bloodlust" + ChatColor.RESET;
|
||||
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.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.customItemModel = "crimson_chestplate";
|
||||
this.chestplate.customEquipmentModel = "crimson";
|
||||
this.chestplate.lore = "A chestplate that strengthens the heart of the wearer.";
|
||||
|
||||
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.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.";
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import org.bukkit.*;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.damage.DamageType;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -26,6 +27,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.bukkit.Bukkit.broadcastMessage;
|
||||
import static org.bukkit.Bukkit.getServer;
|
||||
|
||||
public class DragonGear extends GenericGearSet implements Listener, CommandExecutor {
|
||||
@@ -69,6 +71,36 @@ public class DragonGear extends GenericGearSet implements Listener, CommandExecu
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(org.bukkit.event.entity.EntityDamageEvent event) {
|
||||
// check if fall damage
|
||||
if (!(event.getEntity() instanceof Player player)) return;
|
||||
if (!(LoreChecker.itemLoreContains(player.getInventory().getHelmet(), this.helmet.lore)
|
||||
&& LoreChecker.itemLoreContains(player.getInventory().getChestplate(), this.chestplate.lore)
|
||||
&& LoreChecker.itemLoreContains(player.getInventory().getLeggings(), this.leggings.lore)
|
||||
&& LoreChecker.itemLoreContains(player.getInventory().getBoots(), this.boots.lore)
|
||||
)) return;
|
||||
if (!(event.getDamageSource().getDamageType() == DamageType.FLY_INTO_WALL)) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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 (!(player.isFlying() || player.isGliding())) return;
|
||||
|
||||
double baseDamage = event.getDamage();
|
||||
double newDamage = baseDamage * Math.min(Math.max(player.getVelocity().length(), 1.0), 2.0);
|
||||
|
||||
broadcastMessage("damage " + baseDamage);
|
||||
broadcastMessage("velocity " + player.getVelocity().length());
|
||||
broadcastMessage("new damage " + newDamage);
|
||||
|
||||
event.setDamage(newDamage);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@@ -83,10 +115,11 @@ public class DragonGear extends GenericGearSet implements Listener, CommandExecu
|
||||
|
||||
Location location = player.getLocation();
|
||||
Vector direction = location.getDirection();
|
||||
|
||||
player.setVelocity(direction.multiply(2.0));
|
||||
player.playSound(location, Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 1.0f);
|
||||
player.playSound(location, Sound.ENTITY_ENDER_DRAGON_FLAP, 1.0f, 1.0f);
|
||||
World world = player.getWorld();
|
||||
world.spawnParticle(Particle.PORTAL, location, 1);
|
||||
world.spawnParticle(Particle.DRAGON_BREATH, location, 100);
|
||||
|
||||
cooldown.add(player);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(
|
||||
@@ -114,22 +147,22 @@ public class DragonGear extends GenericGearSet implements Listener, CommandExecu
|
||||
|
||||
public DragonGear() {
|
||||
this.setTier5();
|
||||
this.sword.name = "Dragon Sword";
|
||||
this.sword.name = ChatColor.DARK_PURPLE + "Dragon Sword" + ChatColor.RESET;
|
||||
this.sword.customItemModel = "dragon_sword";
|
||||
|
||||
this.helmet.name = "Dragon Helmet";
|
||||
this.helmet.name = ChatColor.DARK_PURPLE + "Dragon Helmet" + ChatColor.RESET;
|
||||
this.helmet.customItemModel = "dragon_helmet";
|
||||
this.helmet.customEquipmentModel = "dragon";
|
||||
|
||||
this.chestplate.name = "Dragon Chestplate";
|
||||
this.chestplate.name = ChatColor.DARK_PURPLE + "Dragon Chestplate" + ChatColor.RESET;
|
||||
this.chestplate.customItemModel = "dragon_chestplate";
|
||||
this.chestplate.customEquipmentModel = "dragon";
|
||||
|
||||
this.leggings.name = "Dragon Leggings";
|
||||
this.leggings.name = ChatColor.DARK_PURPLE + "Dragon Leggings" + ChatColor.RESET;
|
||||
this.leggings.customItemModel = "dragon_leggings";
|
||||
this.leggings.customEquipmentModel = "dragon";
|
||||
|
||||
this.boots.name = "Dragon Boots";
|
||||
this.boots.name = ChatColor.DARK_PURPLE + "Dragon Boots" + ChatColor.RESET;
|
||||
this.boots.customItemModel = "dragon_boots";
|
||||
this.boots.customEquipmentModel = "dragon";
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package dev.zxq5.fantasysmp.items.gear;
|
||||
|
||||
import dev.zxq5.fantasysmp.items.GenericGearSet;
|
||||
import dev.zxq5.fantasysmp.util.LoreChecker;
|
||||
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 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) {
|
||||
Player player = (Player) sender;
|
||||
player.getInventory().addItem(this.getSword());
|
||||
player.getInventory().addItem(this.getHelmet());
|
||||
player.getInventory().addItem(this.getChestplate());
|
||||
player.getInventory().addItem(this.getLeggings());
|
||||
player.getInventory().addItem(this.getBoots());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
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)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(LoreChecker.itemLoreContains(item, this.sword.lore))) return;
|
||||
if (cooldown.contains(player)) return;
|
||||
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
||||
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.teleport(new_location);
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
public static void init() {}
|
||||
|
||||
public EnderGear() {
|
||||
this.setTier4();
|
||||
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.customItemModel = "ender_helmet";
|
||||
this.helmet.customEquipmentModel = "ender";
|
||||
|
||||
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.customItemModel = "ender_leggings";
|
||||
this.leggings.customEquipmentModel = "ender";
|
||||
|
||||
this.boots.name = ChatColor.DARK_AQUA + "Ender Boots" + ChatColor.RESET;
|
||||
this.boots.customItemModel = "ender_boots";
|
||||
this.boots.customEquipmentModel = "ender";
|
||||
|
||||
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.boots.lore = "Boots forged from the essence of ender pearls,";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package dev.zxq5.fantasysmp.items.gear;
|
||||
|
||||
import dev.zxq5.fantasysmp.items.GenericGearSet;
|
||||
import dev.zxq5.fantasysmp.items.ItemStats;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import static org.bukkit.Bukkit.getPluginManager;
|
||||
|
||||
public class PoseidonGear extends GenericGearSet implements CommandExecutor, Listener {
|
||||
@Override
|
||||
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.getTrident());
|
||||
player.getInventory().addItem(this.getHelmet());
|
||||
player.getInventory().addItem(this.getChestplate());
|
||||
player.getInventory().addItem(this.getLeggings());
|
||||
player.getInventory().addItem(this.getBoots());
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack getTrident() {
|
||||
ItemStack item = super.getSword();
|
||||
item.addUnsafeEnchantment(Enchantment.RIPTIDE, 5);
|
||||
return item;
|
||||
}
|
||||
|
||||
public ItemStack getHelmet() {
|
||||
ItemStack item = super.getHelmet();
|
||||
item.addUnsafeEnchantment(Enchantment.AQUA_AFFINITY, 3);
|
||||
return item;
|
||||
}
|
||||
|
||||
public ItemStack getBoots() {
|
||||
ItemStack item = super.getBoots();
|
||||
item.addUnsafeEnchantment(Enchantment.DEPTH_STRIDER, 5);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(getPluginManager().getPlugin("fantasysmp"), this::checkPlayerAir, 0, 20);
|
||||
}
|
||||
|
||||
public void checkPlayerAir() {
|
||||
// any players wearing the armour will never run out of breath
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (this.hasGear(player)) {
|
||||
if (player.getRemainingAir() < player.getMaximumAir()) {
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PoseidonGear() {
|
||||
this.setTier5();
|
||||
this.sword.setMaterial(Material.TRIDENT);
|
||||
this.sword.attackDamage = 10;
|
||||
this.sword.attackSpeed = 1.2f;
|
||||
this.sword.name = ChatColor.AQUA + "Poseidon's Fury" + ChatColor.RESET;
|
||||
this.sword.lore = "A powerful trident imbued with the power of the ocean.";
|
||||
this.sword.customItemModel = "poseidons_trident";
|
||||
|
||||
this.helmet.name = ChatColor.AQUA + "Poseidon's Crown" + ChatColor.RESET;
|
||||
this.helmet.lore = "A helmet granted to those who harness the power of the ocean.";
|
||||
this.helmet.customItemModel = "poseidons_helmet";
|
||||
this.helmet.customEquipmentModel = "poseidon";
|
||||
|
||||
this.chestplate.name = ChatColor.AQUA + "Poseidon's Chestplate" + ChatColor.RESET;
|
||||
this.chestplate.lore = "A chestplate granted to those who harness the power of the ocean.";
|
||||
this.chestplate.customItemModel = "poseidons_chestplate";
|
||||
this.chestplate.customEquipmentModel = "poseidon";
|
||||
|
||||
this.leggings.name = ChatColor.AQUA + "Poseidon's Leggings" + ChatColor.RESET;
|
||||
this.leggings.lore = "Leggings granted to those who harness the power of the ocean.";
|
||||
this.leggings.customItemModel = "poseidons_leggings";
|
||||
this.leggings.customEquipmentModel = "poseidon";
|
||||
|
||||
this.boots.name = ChatColor.AQUA + "Poseidon's Boots" + ChatColor.RESET;
|
||||
this.boots.lore = "Boots granted to those who harness the power of the ocean.";
|
||||
this.boots.customItemModel = "poseidons_boots";
|
||||
this.boots.customEquipmentModel = "poseidon";
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,22 @@
|
||||
package dev.zxq5.fantasysmp.items.gear;
|
||||
|
||||
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 {
|
||||
@Override
|
||||
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
|
||||
player.getInventory().addItem(this.getSword());
|
||||
player.getInventory().addItem(this.getHelmet());
|
||||
player.getInventory().addItem(this.getChestplate());
|
||||
player.getInventory().addItem(this.getLeggings());
|
||||
player.getInventory().addItem(this.getBoots());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -15,8 +24,29 @@ public class TrueNetheriteGear extends GenericGearSet implements CommandExecutor
|
||||
|
||||
public TrueNetheriteGear() {
|
||||
this.setTier6();
|
||||
this.sword.name = "True Netherite Sword";
|
||||
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.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.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.customItemModel = "true_netherite_leggings";
|
||||
this.leggings.customEquipmentModel = "true_netherite";
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.bukkit.potion.PotionEffect;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.bukkit.Bukkit.broadcastMessage;
|
||||
import static org.bukkit.Bukkit.getServer;
|
||||
|
||||
public class WitheriteGear extends GenericGearSet implements Listener, CommandExecutor {
|
||||
@@ -143,29 +144,28 @@ public class WitheriteGear extends GenericGearSet implements Listener, CommandEx
|
||||
|
||||
public WitheriteGear() {
|
||||
this.setTier5();
|
||||
this.sword.name = "Witherite Sword";
|
||||
this.sword.name = ChatColor.BLACK + "Witherite Sword" + ChatColor.RESET;
|
||||
this.sword.lore = "A sword forged with the skulls of wither skeletons.";
|
||||
this.sword.customItemModel = "witherite_sword";
|
||||
|
||||
this.helmet.name = "Witherite Helmet";
|
||||
this.helmet.name = ChatColor.BLACK + "Witherite Helmet" + ChatColor.RESET;
|
||||
this.helmet.lore = "A helmet forged with the skulls of wither skeletons.";
|
||||
this.helmet.customItemModel = "witherite_helmet";
|
||||
this.helmet.customEquipmentModel = "witherite";
|
||||
|
||||
this.chestplate.name = "Witherite Chestplate";
|
||||
this.chestplate.name = ChatColor.BLACK + "Witherite Chestplate" + ChatColor.RESET;
|
||||
this.chestplate.lore = "A chestplate forged with the skulls of wither skeletons.";
|
||||
this.chestplate.customItemModel = "witherite_chestplate";
|
||||
this.chestplate.customEquipmentModel = "witherite";
|
||||
|
||||
this.leggings.name = "Witherite Leggings";
|
||||
this.leggings.name = ChatColor.BLACK + "Witherite Leggings" + ChatColor.RESET;
|
||||
this.leggings.lore = "Leggings forged with the skulls of wither skeletons.";
|
||||
this.leggings.customItemModel = "witherite_leggings";
|
||||
this.leggings.customEquipmentModel = "witherite";
|
||||
|
||||
this.boots.name = "Witherite Boots";
|
||||
this.boots.name = ChatColor.BLACK + "Witherite Boots" + ChatColor.RESET;
|
||||
this.boots.lore = "Boots forged with the skulls of wither skeletons.";
|
||||
this.boots.customItemModel = "witherite_boots";
|
||||
this.boots.customEquipmentModel = "witherite";
|
||||
|
||||
this.sword.lore = "A sword forged with the skulls of wither skeletons.";
|
||||
this.helmet.lore = "A helmet forged with the skulls of wither skeletons.";
|
||||
this.chestplate.lore = "A chestplate forged with the skulls of wither skeletons.";
|
||||
this.leggings.lore = "Leggings forged with the skulls of wither skeletons.";
|
||||
this.boots.lore = "Boots forged with the skulls of wither skeletons.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package dev.zxq5.fantasysmp.warps;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -104,6 +105,18 @@ public class Warp {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String listWarps(UUID player) {
|
||||
String message = ChatColor.WHITE + "All Warps: [\n" + ChatColor.GREEN;
|
||||
|
||||
for (Warp warp : warps) {
|
||||
if (warp.type.equals(WarpType.PUBLIC) || warp.setby.equals(player.toString())) {
|
||||
message += " " + warp.name + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return message + ChatColor.WHITE + "]";
|
||||
}
|
||||
|
||||
public static void setHome(Player player) {
|
||||
setWarp("Home (" + player.getName() + ")", player, WarpType.HOME);
|
||||
}
|
||||
|
||||
@@ -1,73 +1,136 @@
|
||||
package dev.zxq5.fantasysmp.warps;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static dev.zxq5.fantasysmp.chatutils.Chat.EVENTPREFIX;
|
||||
|
||||
/*
|
||||
* Commands:
|
||||
*
|
||||
* ** PLAYER **
|
||||
*
|
||||
* home => DONE
|
||||
* sethome => DONE
|
||||
* warp <name> => DONE
|
||||
*
|
||||
* ** ADMIN ONLY **
|
||||
*
|
||||
* rewarps => DONE
|
||||
* setwarp <name> => DONE
|
||||
* delwarp <name> => TODO
|
||||
* */
|
||||
|
||||
public class Warper 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, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.getName().equals("reloadwarps")) {
|
||||
// reply
|
||||
try {
|
||||
Warp.loadWarps();
|
||||
} catch (Exception e) {
|
||||
player.sendMessage("Failed to reload warps. please contact an admin.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
switch (command.getName()) {
|
||||
case "home" -> this.handleHome(player, args);
|
||||
case "sethome" -> this.handleSetHome(player, args);
|
||||
case "warp" -> this.handleWarp(player, args);
|
||||
case "setwarp" -> this.handleSetWarp(player, args);
|
||||
case "delwarp" -> this.handleDelWarp(player, args);
|
||||
case "rewarps" -> this.handleReWarps(player, args);
|
||||
case "warps" -> this.handleWarpsOther(player, args);
|
||||
}
|
||||
|
||||
if (command.getName().equals("home")) {
|
||||
if (args.length != 0) {
|
||||
player.sendMessage("Usage: /home");
|
||||
return true;
|
||||
}
|
||||
|
||||
public void handleHome(Player player, String[] args) {
|
||||
if (args.length != 0) {
|
||||
this.error(player,"Usage: /home");
|
||||
return;
|
||||
}
|
||||
|
||||
Warp warp = Warp.getHome(player.getUniqueId());
|
||||
|
||||
if (warp != null) {
|
||||
warp.execute(player);
|
||||
}
|
||||
if (warp == null) {
|
||||
this.error(player,"No home set! use /sethome to set one.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (command.getName().equals("sethome")) {
|
||||
warp.execute(player);
|
||||
this.success(player,"Warped Home!");
|
||||
}
|
||||
|
||||
public void handleSetHome(Player player, String[] args) {
|
||||
if (args.length != 0) {
|
||||
player.sendMessage("Usage: /sethome");
|
||||
return true;
|
||||
this.error(player,"Usage: /sethome");
|
||||
return;
|
||||
}
|
||||
|
||||
Warp.setHome(player);
|
||||
this.success(player,"Home set Successfully!");
|
||||
}
|
||||
|
||||
if (command.getName().equals("warp")) {
|
||||
public void handleWarp(Player player, String[] args) {
|
||||
if (args.length != 1) {
|
||||
player.sendMessage("Usage: /warp <name>");
|
||||
return true;
|
||||
this.error(player, "Usage: /warp <name>");
|
||||
return;
|
||||
}
|
||||
|
||||
Warp warp = Warp.getWarp(args[0]);
|
||||
|
||||
if (warp != null) {
|
||||
if (warp == null) {
|
||||
this.error(player, "Location [" + args[0] + "] does not exist or is not accessible to you!");
|
||||
return;
|
||||
};
|
||||
warp.execute(player);
|
||||
}
|
||||
this.success(player, "Warped!");
|
||||
}
|
||||
|
||||
if (command.getName().equals("setwarp")) {
|
||||
public void handleSetWarp(Player player, String[] args) {
|
||||
if (!(player.hasPermission("fantasysmp.manage_warps"))) {
|
||||
player.sendMessage("You do not have permission to use this command.");
|
||||
return false;
|
||||
this.error(player, "You do not have permission to use this command.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length != 1) {
|
||||
player.sendMessage("Usage: /setwarp <name>");
|
||||
return true;
|
||||
this.error(player, "Usage: /setwarp <name>");
|
||||
return;
|
||||
}
|
||||
|
||||
Warp.setWarp(args[0], player, WarpType.PUBLIC);
|
||||
this.success(player, "Warp [" + args[0] + "] set Successfully!");
|
||||
}
|
||||
return true;
|
||||
|
||||
public void handleDelWarp(Player player, String[] args) {
|
||||
|
||||
}
|
||||
|
||||
public void handleReWarps(Player player, String[] args) {
|
||||
try {
|
||||
Warp.loadWarps();
|
||||
} catch (Exception e) {
|
||||
this.error(player, "Failed to reload warps. please contact zxq5.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.success(player, "Successfully reloaded warps from warps.json");
|
||||
}
|
||||
|
||||
public void handleWarpsOther(Player player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
this.info(player, Warp.listWarps(player.getUniqueId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void error(Player player, String message) {
|
||||
player.sendMessage(EVENTPREFIX + ChatColor.RED + message);
|
||||
}
|
||||
|
||||
public void success(Player player, String message) {
|
||||
player.sendMessage(EVENTPREFIX + ChatColor.GREEN + message);
|
||||
}
|
||||
|
||||
public void info(Player player, String message) {
|
||||
player.sendMessage(EVENTPREFIX + message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,10 +27,20 @@ commands:
|
||||
usage: /setwarp <warp name>
|
||||
permission: fantasysmp.manage_warps
|
||||
|
||||
reloadwarps:
|
||||
delwarp:
|
||||
description: delete a warp
|
||||
usage: /delwarp <warp name>
|
||||
permission: fantasysmp.manage_warps
|
||||
|
||||
warps:
|
||||
description: list all warps
|
||||
usage: /warps
|
||||
permission: fantasysmp.warps
|
||||
|
||||
rewarps:
|
||||
description: reload warps
|
||||
usage: /reloadwarps
|
||||
permission: fantasysmp.admin
|
||||
usage: /rewarps
|
||||
permission: fantasysmp.manage_warps
|
||||
|
||||
warp:
|
||||
description: teleport to a warp
|
||||
@@ -49,7 +59,7 @@ permissions:
|
||||
|
||||
fantasysmp.manage_warps:
|
||||
description: commands for managing warps
|
||||
default: true
|
||||
default: false
|
||||
|
||||
fantasysmp.home:
|
||||
description: commands for teleporting home
|
||||
|
||||
Reference in New Issue
Block a user