leave command + boxcart update + mapreset
This commit is contained in:
8
pom.xml
8
pom.xml
@@ -86,5 +86,13 @@
|
||||
<version>7.3.9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fastasyncworldedit</groupId>
|
||||
<artifactId>FastAsyncWorldEdit-Bukkit</artifactId>
|
||||
<version>2.13.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -3,14 +3,20 @@ package hu.jgj52.wolfFFA.Commands;
|
||||
import hu.jgj52.wolfFFA.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Shulker;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@@ -210,6 +216,8 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
|
||||
ItemStack crossbow = new ItemStack(Material.CROSSBOW);
|
||||
ItemStack flintandsteel = new ItemStack(Material.FLINT_AND_STEEL);
|
||||
ItemStack totem = new ItemStack(Material.TOTEM_OF_UNDYING);
|
||||
ItemStack pickaxe = new ItemStack(Material.NETHERITE_PICKAXE);
|
||||
ItemStack shulker = new ItemStack(Material.RED_SHULKER_BOX);
|
||||
|
||||
sword.addEnchantment(Enchantment.SHARPNESS, 5);
|
||||
sword.addEnchantment(Enchantment.SWEEPING_EDGE, 3);
|
||||
@@ -234,6 +242,9 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
|
||||
flintandsteel.addEnchantment(Enchantment.MENDING, 1);
|
||||
shield.addEnchantment(Enchantment.UNBREAKING, 3);
|
||||
shield.addEnchantment(Enchantment.MENDING, 1);
|
||||
pickaxe.addEnchantment(Enchantment.UNBREAKING, 3);
|
||||
pickaxe.addEnchantment(Enchantment.MENDING, 1);
|
||||
pickaxe.addEnchantment(Enchantment.EFFICIENCY, 5);
|
||||
|
||||
PotionMeta fireresistancemeta = (PotionMeta) fireresistance.getItemMeta();
|
||||
fireresistancemeta.addCustomEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 9600, 0), true);
|
||||
@@ -248,6 +259,15 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
|
||||
speedmeta.setDisplayName("§fSplash Potion of Swiftness");
|
||||
speed.setItemMeta(speedmeta);
|
||||
|
||||
BlockStateMeta shulkermeta = (BlockStateMeta) shulker.getItemMeta();
|
||||
ShulkerBox shulkerbox = (ShulkerBox) shulkermeta.getBlockState();
|
||||
Inventory shulkerinv = shulkerbox.getInventory();
|
||||
for (int i = 0; i < 27; i++) {
|
||||
shulkerinv.setItem(i, new ItemStack(Material.TNT_MINECART));
|
||||
}
|
||||
shulkermeta.setBlockState(shulkerbox);
|
||||
shulker.setItemMeta(shulkermeta);
|
||||
|
||||
inv.setItem(getItemSlot("axe", "boxcart", player), axe);
|
||||
inv.setItem(getItemSlot("sword", "boxcart", player), sword);
|
||||
for (int slot : getItemSlotArray("enderpearl", "boxcart", player)) {
|
||||
@@ -274,6 +294,8 @@ public class EditKitCommand implements CommandExecutor, TabCompleter {
|
||||
inv.setItem(getItemSlot("cherrylog", "boxcart", player), cherrylog);
|
||||
inv.setItem(getItemSlot("crossbow", "boxcart", player), crossbow);
|
||||
inv.setItem(getItemSlot("flintandsteel", "boxcart", player), flintandsteel);
|
||||
inv.setItem(getItemSlot("pickaxe", "boxcart", player), pickaxe);
|
||||
inv.setItem(getItemSlot("shulker", "boxcart", player), shulker);
|
||||
inv.setItem(getItemSlot("totem", "boxcart", player), totem);
|
||||
|
||||
infoMeta.setDisplayName("§fBoxCart Kit");
|
||||
|
||||
53
src/main/java/hu/jgj52/wolfFFA/Commands/LeaveCommand.java
Normal file
53
src/main/java/hu/jgj52/wolfFFA/Commands/LeaveCommand.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package hu.jgj52.wolfFFA.Commands;
|
||||
|
||||
import hu.jgj52.wolfFFA.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
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.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LeaveCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
public LeaveCommand(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
|
||||
if (cmds.hasPermission("wolfffa.command.leave")) {
|
||||
if (cmds instanceof Player player) {
|
||||
Player dameger = plugin.getPlayers().get(player);
|
||||
if (dameger != null) {
|
||||
player.setKiller(plugin.getPlayers().get(player));
|
||||
plugin.getPlayers().remove(player);
|
||||
player.setHealth(0);
|
||||
} else {
|
||||
player.teleport(new Location(Bukkit.getWorld("world"), 0.5, 1, 0.5));
|
||||
player.getInventory().clear();
|
||||
player.setHealth(20D);
|
||||
player.setFoodLevel(20);
|
||||
player.setSaturation(5);
|
||||
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
|
||||
player.removePotionEffect(potionEffect.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender cmds, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
@@ -5,13 +5,16 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@@ -188,6 +191,8 @@ public class TpToFfaCommand implements CommandExecutor, TabCompleter {
|
||||
ItemStack crossbow = new ItemStack(Material.CROSSBOW);
|
||||
ItemStack flintandsteel = new ItemStack(Material.FLINT_AND_STEEL);
|
||||
ItemStack totem = new ItemStack(Material.TOTEM_OF_UNDYING);
|
||||
ItemStack pickaxe = new ItemStack(Material.NETHERITE_PICKAXE);
|
||||
ItemStack shulker = new ItemStack(Material.RED_SHULKER_BOX);
|
||||
|
||||
helmet.addEnchantment(Enchantment.PROTECTION, 4);
|
||||
helmet.addEnchantment(Enchantment.RESPIRATION, 3);
|
||||
@@ -199,6 +204,7 @@ public class TpToFfaCommand implements CommandExecutor, TabCompleter {
|
||||
leggings.addEnchantment(Enchantment.BLAST_PROTECTION, 4);
|
||||
leggings.addEnchantment(Enchantment.UNBREAKING, 3);
|
||||
leggings.addEnchantment(Enchantment.MENDING, 1);
|
||||
boots.addEnchantment(Enchantment.FEATHER_FALLING, 4);
|
||||
boots.addEnchantment(Enchantment.PROTECTION, 4);
|
||||
boots.addEnchantment(Enchantment.UNBREAKING,3);
|
||||
boots.addEnchantment(Enchantment.MENDING, 1);
|
||||
@@ -225,6 +231,9 @@ public class TpToFfaCommand implements CommandExecutor, TabCompleter {
|
||||
flintandsteel.addEnchantment(Enchantment.MENDING, 1);
|
||||
shield.addEnchantment(Enchantment.UNBREAKING, 3);
|
||||
shield.addEnchantment(Enchantment.MENDING, 1);
|
||||
pickaxe.addEnchantment(Enchantment.UNBREAKING, 3);
|
||||
pickaxe.addEnchantment(Enchantment.MENDING, 1);
|
||||
pickaxe.addEnchantment(Enchantment.EFFICIENCY, 5);
|
||||
|
||||
PotionMeta fireresistancemeta = (PotionMeta) fireresistance.getItemMeta();
|
||||
fireresistancemeta.addCustomEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 9600, 0), true);
|
||||
@@ -239,6 +248,15 @@ public class TpToFfaCommand implements CommandExecutor, TabCompleter {
|
||||
speedmeta.setDisplayName("§fSplash Potion of Swiftness");
|
||||
speed.setItemMeta(speedmeta);
|
||||
|
||||
BlockStateMeta shulkermeta = (BlockStateMeta) shulker.getItemMeta();
|
||||
ShulkerBox shulkerbox = (ShulkerBox) shulkermeta.getBlockState();
|
||||
Inventory shulkerinv = shulkerbox.getInventory();
|
||||
for (int i = 0; i < 27; i++) {
|
||||
shulkerinv.setItem(i, new ItemStack(Material.TNT_MINECART));
|
||||
}
|
||||
shulkermeta.setBlockState(shulkerbox);
|
||||
shulker.setItemMeta(shulkermeta);
|
||||
|
||||
player.getInventory().setArmorContents(new ItemStack[]{boots, leggings, chestplate, helmet});
|
||||
player.getInventory().setItem(getItemSlot("axe", "boxcart", player), axe);
|
||||
player.getInventory().setItem(getItemSlot("sword", "boxcart", player), sword);
|
||||
@@ -267,6 +285,8 @@ public class TpToFfaCommand implements CommandExecutor, TabCompleter {
|
||||
player.getInventory().setItem(getItemSlot("crossbow", "boxcart", player), crossbow);
|
||||
player.getInventory().setItem(getItemSlot("flintandsteel", "boxcart", player), flintandsteel);
|
||||
player.getInventory().setItem(getItemSlot("totem", "boxcart", player), totem);
|
||||
player.getInventory().setItem(getItemSlot("pickaxe", "boxcart", player), pickaxe);
|
||||
player.getInventory().setItem(getItemSlot("shulker", "boxcart", player), shulker);
|
||||
|
||||
World world = Bukkit.getWorld("world");
|
||||
double x = -1000.5;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package hu.jgj52.wolfFFA.Listeners;
|
||||
|
||||
import hu.jgj52.wolfFFA.Main;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
public class BlockBreakListener implements Listener {
|
||||
private final Main plugin;
|
||||
|
||||
public BlockBreakListener(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (!event.getPlayer().hasPermission("wolfffa.admin.bypass.netheriteblockbreak")) {
|
||||
if (event.getBlock().getType() == Material.NETHERITE_BLOCK) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,8 @@ public class KitListener implements Listener {
|
||||
Map<String, Object> boxcartKit = new HashMap<>();
|
||||
int[] boxcartstrenght = new int[]{16, 25, 34};
|
||||
int[] boxcartspeed = new int[]{17, 26, 35};
|
||||
int[] boxcartfireresistance = new int[]{18, 27};
|
||||
int[] boxcartcart = new int[]{4, 12, 21, 30, 13, 22, 31, 14, 23, 32, 15, 24, 33};
|
||||
int[] boxcartfireresistance = new int[]{24, 33};
|
||||
int[] boxcartcart = new int[]{4, 12, 21, 30, 13, 22, 31, 14, 23, 32, 15};
|
||||
int[] boxcartenderpearl = new int[]{2, 11, 20, 29};
|
||||
boxcartKit.put("axe", 0);
|
||||
boxcartKit.put("sword", 1);
|
||||
@@ -77,7 +77,9 @@ public class KitListener implements Listener {
|
||||
boxcartKit.put("speed", boxcartspeed);
|
||||
boxcartKit.put("fireresistance", boxcartfireresistance);
|
||||
boxcartKit.put("cherrylog", 10);
|
||||
boxcartKit.put("pickaxe", 18);
|
||||
boxcartKit.put("crossbow", 19);
|
||||
boxcartKit.put("shulker", 27);
|
||||
boxcartKit.put("flintandsteel", 28);
|
||||
boxcartKit.put("totem", 40);
|
||||
plugin.getConfig().set("kits.boxcart." + player.getUniqueId(), boxcartKit);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package hu.jgj52.wolfFFA.Listeners;
|
||||
|
||||
import hu.jgj52.wolfFFA.Main;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class PlayerDamegeListener implements Listener {
|
||||
private final Main plugin;
|
||||
|
||||
public PlayerDamegeListener(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(EntityDamageByEntityEvent e) {
|
||||
if (e.getEntity() instanceof Player player && e.getDamager() instanceof Player damager) {
|
||||
plugin.getPlayers().put(player, damager);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,22 @@
|
||||
package hu.jgj52.wolfFFA;
|
||||
|
||||
import hu.jgj52.wolfFFA.Commands.EditKitCommand;
|
||||
import hu.jgj52.wolfFFA.Commands.LeaveCommand;
|
||||
import hu.jgj52.wolfFFA.Commands.TpToFfaCommand;
|
||||
import hu.jgj52.wolfFFA.Listeners.BlockBreakListener;
|
||||
import hu.jgj52.wolfFFA.Listeners.KitListener;
|
||||
import hu.jgj52.wolfFFA.Listeners.PlayerDamegeListener;
|
||||
import hu.jgj52.wolfFFA.Utils.MapReset;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class Main extends JavaPlugin {
|
||||
|
||||
private MapReset mapReset;
|
||||
private final Map<Player, Player> players = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@@ -18,8 +26,11 @@ public final class Main extends JavaPlugin {
|
||||
|
||||
getCommand("tptoffa").setExecutor(new TpToFfaCommand(this));
|
||||
getCommand("editkit").setExecutor(new EditKitCommand(this));
|
||||
getCommand("leave").setExecutor(new LeaveCommand(this));
|
||||
|
||||
getServer().getPluginManager().registerEvents(new KitListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new BlockBreakListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerDamegeListener(this), this);
|
||||
|
||||
this.mapReset = new MapReset(this);
|
||||
}
|
||||
@@ -27,6 +38,7 @@ public final class Main extends JavaPlugin {
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
players.clear();
|
||||
}
|
||||
|
||||
public static Main getInstance() {
|
||||
@@ -36,4 +48,8 @@ public final class Main extends JavaPlugin {
|
||||
public MapReset getMapResetManager() {
|
||||
return this.mapReset;
|
||||
}
|
||||
|
||||
public Map<Player, Player> getPlayers() {
|
||||
return this.players;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package hu.jgj52.wolfFFA.Utils;
|
||||
|
||||
import com.fastasyncworldedit.core.FaweAPI;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.ClipboardFormat;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.ClipboardFormats;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.ClipboardReader;
|
||||
import com.fastasyncworldedit.core.function.operation.Operation;
|
||||
import com.fastasyncworldedit.core.function.operation.Operations;
|
||||
import com.fastasyncworldedit.core.worldedit.EditSession;
|
||||
import com.fastasyncworldedit.core.worldedit.session.ClipboardHolder;
|
||||
import com.fastasyncworldedit.core.worldedit.math.BlockVector3;
|
||||
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 org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@@ -22,16 +24,30 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class MapReset {
|
||||
private final JavaPlugin plugin;
|
||||
private BukkitTask resetTask;
|
||||
private static final long RESET_INTERVAL = 12000L;
|
||||
private static final int COUNTDOWN_SECONDS = 5;
|
||||
private static final long SCHEMATIC_PLACEMENT_DELAY = 60L;
|
||||
private static final Set<EntityType> ENTITIES_TO_REMOVE = EnumSet.of(
|
||||
EntityType.TNT_MINECART,
|
||||
EntityType.END_CRYSTAL
|
||||
);
|
||||
|
||||
private static final List<SchematicPlacement> SCHEMATICS = Arrays.asList(
|
||||
new SchematicPlacement("world", -76, 91, -1076, "uhc"),
|
||||
new SchematicPlacement("world", -924, 84, 1081, "boxcart")
|
||||
);
|
||||
|
||||
public MapReset(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
mapResetRunnable();
|
||||
startMapResetScheduler();
|
||||
}
|
||||
|
||||
public boolean placeSchematic(World world, int x, int y, int z, String schematicName) {
|
||||
@@ -48,30 +64,32 @@ public class MapReset {
|
||||
return false;
|
||||
}
|
||||
|
||||
try (ClipboardReader reader = format.getReader(new FileInputStream(schematicFile))) {
|
||||
ClipboardHolder clipboard = new ClipboardHolder(reader.read());
|
||||
try (FileInputStream fis = new FileInputStream(schematicFile);
|
||||
ClipboardReader reader = format.getReader(fis)) {
|
||||
|
||||
EditSession editSession = FaweAPI.getWorld(world.getName()).getEditSession();
|
||||
editSession.setFastMode(true); // Optimize for FAWE
|
||||
Clipboard clipboard = reader.read();
|
||||
com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(world);
|
||||
|
||||
Operation operation = clipboard
|
||||
.createPaste(editSession)
|
||||
.to(BlockVector3.at(x, y, z))
|
||||
.ignoreAirBlocks(false)
|
||||
.build();
|
||||
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;
|
||||
Operations.complete(operation);
|
||||
editSession.flushSession();
|
||||
return true;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Error reading schematic file: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().severe("Error placing schematic: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean placeSchematic(Location location, String schematicName) {
|
||||
@@ -85,110 +103,100 @@ public class MapReset {
|
||||
}
|
||||
|
||||
public void placeSchematicsSequentially() {
|
||||
class SchematicPlacement {
|
||||
final World world;
|
||||
final int x, y, z;
|
||||
final String name;
|
||||
|
||||
SchematicPlacement(World world, int x, int y, int z, String name) {
|
||||
this.world = world;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
List<SchematicPlacement> schematics = new ArrayList<>();
|
||||
schematics.add(new SchematicPlacement(Bukkit.getWorld("world"), -76, 91, -1076, "uhc"));
|
||||
schematics.add(new SchematicPlacement(Bukkit.getWorld("world"), -1078, 87, 1076, "boxcart"));
|
||||
|
||||
new BukkitRunnable() {
|
||||
int index = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (index < schematics.size()) {
|
||||
SchematicPlacement placement = schematics.get(index);
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.sendMessage("§ePlacing schematic " + placement.name + "...");
|
||||
if (index < SCHEMATICS.size()) {
|
||||
SchematicPlacement placement = SCHEMATICS.get(index);
|
||||
|
||||
World world = Bukkit.getWorld(placement.worldName);
|
||||
if (world == null) {
|
||||
index++;
|
||||
return;
|
||||
}
|
||||
|
||||
boolean success = placeSchematic(
|
||||
placement.world,
|
||||
world,
|
||||
placement.x,
|
||||
placement.y,
|
||||
placement.z,
|
||||
placement.name
|
||||
);
|
||||
|
||||
if (success) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.sendMessage("§aSchematic " + placement.name + " placed successfully!");
|
||||
}
|
||||
} else {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.sendMessage("§cFailed to place schematic " + placement.name);
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
} else {
|
||||
removeEntities();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.sendMessage("§cA mapok resetelve lettek!");
|
||||
}
|
||||
broadcastMessage("§cA mapok resetelve lettek!");
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 20L);
|
||||
}.runTaskTimer(plugin, 0L, SCHEMATIC_PLACEMENT_DELAY);
|
||||
}
|
||||
|
||||
private void removeEntities() {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (Entity entity : world.getEntities()) {
|
||||
if (entity.getType() == EntityType.TNT_MINECART ||
|
||||
entity.getType() == EntityType.END_CRYSTAL) {
|
||||
if (ENTITIES_TO_REMOVE.contains(entity.getType())) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mapResetRunnable() {
|
||||
if (resetTask != null && !resetTask.isCancelled()) {
|
||||
resetTask.cancel();
|
||||
}
|
||||
public void startMapResetScheduler() {
|
||||
stopScheduler();
|
||||
|
||||
resetTask = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new BukkitRunnable() {
|
||||
int countdown = 5;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (countdown > 0) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.sendMessage("§cA mapok resetelődnek " + countdown + " másodperc múlva!");
|
||||
}
|
||||
countdown--;
|
||||
} else {
|
||||
// Start sequential schematic placement
|
||||
placeSchematicsSequentially();
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 20L);
|
||||
startCountdown();
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 12000L);
|
||||
}.runTaskTimer(plugin, 0L, RESET_INTERVAL);
|
||||
}
|
||||
|
||||
private void startCountdown() {
|
||||
new BukkitRunnable() {
|
||||
int countdown = COUNTDOWN_SECONDS;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (countdown > 0) {
|
||||
broadcastMessage("§cA mapok resetelődnek " + countdown + " másodperc múlva!");
|
||||
countdown--;
|
||||
} else {
|
||||
placeSchematicsSequentially();
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 20L);
|
||||
}
|
||||
|
||||
private void broadcastMessage(String message) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
// Method to stop the scheduler (call this in onDisable)
|
||||
public void stopScheduler() {
|
||||
if (resetTask != null && !resetTask.isCancelled()) {
|
||||
resetTask.cancel();
|
||||
resetTask = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class SchematicPlacement {
|
||||
final String worldName;
|
||||
final int x, y, z;
|
||||
final String name;
|
||||
|
||||
SchematicPlacement(String worldName, int x, int y, int z, String name) {
|
||||
this.worldName = worldName;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,7 @@ commands:
|
||||
usage: /tptoffa <ffa> <player>
|
||||
editkit:
|
||||
permission: wolfffa.command.editkit
|
||||
usage: /editkit <kit>
|
||||
usage: /editkit <kit>
|
||||
leave:
|
||||
permission: wolfffa.command.leave
|
||||
usage: /leave
|
||||
Reference in New Issue
Block a user