update
This commit is contained in:
@@ -2,12 +2,18 @@ package lnmpro.Commands;
|
||||
|
||||
import lnmpro.Main;
|
||||
import lnmpro.Utils.Kits;
|
||||
import lnmpro.Utils.SchematicPlacer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -26,6 +32,8 @@ public class AcceptDuelCommand implements CommandExecutor, TabCompleter {
|
||||
if (sender instanceof Player player) {
|
||||
if (player.hasMetadata("DueledBy")) {
|
||||
Kits kitManager = new Kits(plugin);
|
||||
SchematicPlacer schematic = new SchematicPlacer(plugin);
|
||||
|
||||
UUID targetUUID = UUID.fromString(player.getMetadata("DueledBy").get(0).asString());
|
||||
Player enemy = Bukkit.getPlayer(targetUUID);
|
||||
String gamemode = player.getMetadata("DueledWithGamemode").get(0).asString();
|
||||
@@ -33,7 +41,40 @@ public class AcceptDuelCommand implements CommandExecutor, TabCompleter {
|
||||
player.sendMessage("cica " + gamemode);
|
||||
player.removeMetadata("DueledBy", plugin);
|
||||
player.removeMetadata("DueledWithGamemode", plugin);
|
||||
player.getInventory().setContents(kitManager.getMaceKit(player).getContents());
|
||||
|
||||
player.getInventory().clear();
|
||||
enemy.getInventory().clear();
|
||||
player.getInventory().setContents(kitManager.getAxeKit(player).getContents());
|
||||
enemy.getInventory().setContents(kitManager.getAxeKit(player).getContents());
|
||||
|
||||
World world = Bukkit.getWorld("world");
|
||||
int x = 1000;
|
||||
int y = 0;
|
||||
int z = -2000;
|
||||
|
||||
schematic.placeSchematic(world, x, y, z, "football");
|
||||
Location playerLoc = new Location(world, x + 19.5, y + 0.5, z + 0.5, 90, 0);
|
||||
Location enemyLoc = new Location(world, x - 17.5, y + 0.5, z + 0.5, -90, 0);
|
||||
|
||||
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
|
||||
player.removePotionEffect(potionEffect.getType());
|
||||
}
|
||||
for (PotionEffect potionEffect : enemy.getActivePotionEffects()) {
|
||||
enemy.removePotionEffect(potionEffect.getType());
|
||||
}
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 20, 1), true);
|
||||
enemy.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 20, 1), true);
|
||||
player.teleport(playerLoc);
|
||||
enemy.teleport(enemyLoc);
|
||||
player.setHealth(20D);
|
||||
enemy.setHealth(20D);
|
||||
player.setFoodLevel(20);
|
||||
enemy.setFoodLevel(20);
|
||||
player.setSaturation(5);
|
||||
enemy.setSaturation(5);
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
enemy.setGameMode(GameMode.ADVENTURE);
|
||||
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("nem vagy player nem fog sikerulni");
|
||||
|
||||
@@ -27,8 +27,6 @@ public class DenyDuelCommand implements CommandExecutor, TabCompleter {
|
||||
UUID targetUUID = UUID.fromString(player.getMetadata("DueledBy").get(0).asString());
|
||||
Player enemy = Bukkit.getPlayer(targetUUID);
|
||||
String gamemode = player.getMetadata("DueledWithGamemode").get(0).asString();
|
||||
enemy.sendMessage("nem cica " + gamemode);
|
||||
player.sendMessage("nem cica " + gamemode);
|
||||
player.removeMetadata("DueledBy", plugin);
|
||||
player.removeMetadata("DueledWithGamemode", plugin);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package lnmpro.Commands;
|
||||
import lnmpro.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -18,22 +17,18 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import org.bukkit.profile.PlayerProfile;
|
||||
import org.bukkit.profile.PlayerTextures;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.Collections;
|
||||
|
||||
public class DuelsCommand implements CommandExecutor, TabCompleter {
|
||||
public class DuelCommand implements CommandExecutor, TabCompleter {
|
||||
private final Main plugin;
|
||||
|
||||
public DuelsCommand(Main plugin) {
|
||||
public DuelCommand(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public final class Main extends JavaPlugin {
|
||||
saveDefaultConfig();
|
||||
saveConfig();
|
||||
|
||||
getCommand("duel").setExecutor(new DuelsCommand(this));
|
||||
getCommand("duel").setExecutor(new DuelCommand(this));
|
||||
getCommand("acceptduel").setExecutor(new AcceptDuelCommand(this));
|
||||
getCommand("denyduel").setExecutor(new DenyDuelCommand(this));
|
||||
|
||||
|
||||
@@ -228,6 +228,10 @@ public class Kits {
|
||||
|
||||
PlayerInventory inv = player.getInventory();
|
||||
|
||||
ItemStack helmet = new ItemStack(Material.DIAMOND_HELMET);
|
||||
ItemStack chestplate = new ItemStack(Material.DIAMOND_CHESTPLATE);
|
||||
ItemStack leggings = new ItemStack(Material.DIAMOND_LEGGINGS);
|
||||
ItemStack boots = new ItemStack(Material.DIAMOND_BOOTS);
|
||||
ItemStack axe = new ItemStack(Material.DIAMOND_AXE);
|
||||
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
|
||||
ItemStack crossbow = new ItemStack(Material.CROSSBOW);
|
||||
@@ -235,6 +239,7 @@ public class Kits {
|
||||
ItemStack arrow = new ItemStack(Material.ARROW, 6);
|
||||
ItemStack shield = new ItemStack(Material.SHIELD);
|
||||
|
||||
inv.setArmorContents(new ItemStack[]{boots, leggings, chestplate, helmet});
|
||||
inv.setItem(getItemSlot("axe", "axe", player), axe);
|
||||
inv.setItem(getItemSlot("sword", "axe", player), sword);
|
||||
inv.setItem(getItemSlot("crossbow", "axe", player), crossbow);
|
||||
|
||||
79
src/main/java/lnmpro/Utils/SchematicPlacer.java
Normal file
79
src/main/java/lnmpro/Utils/SchematicPlacer.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package lnmpro.Utils;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import lnmpro.Main;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SchematicPlacer {
|
||||
private final Main plugin;
|
||||
|
||||
public SchematicPlacer(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
public boolean placeSchematic(World world, int x, int y, int z, String schematicName) {
|
||||
File schematicFile = new File(plugin.getDataFolder() + File.separator + "schematics", schematicName + ".schem");
|
||||
|
||||
if (!schematicFile.exists()) {
|
||||
plugin.getLogger().warning("Schematic file not found: " + schematicFile.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
|
||||
ClipboardFormat format = ClipboardFormats.findByFile(schematicFile);
|
||||
if (format == null) {
|
||||
plugin.getLogger().warning("Unknown schematic format for file: " + schematicFile.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
|
||||
try (FileInputStream fis = new FileInputStream(schematicFile);
|
||||
ClipboardReader reader = format.getReader(fis)) {
|
||||
|
||||
Clipboard clipboard = reader.read();
|
||||
com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(world);
|
||||
|
||||
try (EditSession editSession = WorldEdit.getInstance().newEditSession(weWorld)) {
|
||||
Operation operation = new ClipboardHolder(clipboard)
|
||||
.createPaste(editSession)
|
||||
.to(BlockVector3.at(x, y, z))
|
||||
.ignoreAirBlocks(false)
|
||||
.build();
|
||||
|
||||
Operations.complete(operation);
|
||||
editSession.flushSession();
|
||||
return true;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Error reading schematic file: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().severe("Error placing schematic: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean placeSchematic(Location location, String schematicName) {
|
||||
return placeSchematic(
|
||||
location.getWorld(),
|
||||
location.getBlockX(),
|
||||
location.getBlockY(),
|
||||
location.getBlockZ(),
|
||||
schematicName
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1 @@
|
||||
kits:
|
||||
mace:
|
||||
kits: {}
|
||||
Reference in New Issue
Block a user