diff --git a/build.gradle b/build.gradle index eac6b6a..60ddaba 100644 --- a/build.gradle +++ b/build.gradle @@ -41,7 +41,7 @@ processResources { task copyJar(type: Copy) { from jar - into "C:/Users/Valdemar/Desktop/mc/TestServer1.16.5/plugins" + into "E:\\Rishi\\Codes\\Java Projects\\Minecraft Plugins\\PaperMC\\1.16.4\\Server Testing\\plugins" } build.finalizedBy copyJar diff --git a/src/main/java/io/github/simplexdev/simplexcore/strike/StrikeCommand.java b/src/main/java/io/github/simplexdev/simplexcore/strike/StrikeCommand.java deleted file mode 100644 index 7da7eb5..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/strike/StrikeCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -/* */ package io.github.simplexdev.simplexcore.strike; -/* */ -/* */ import io.github.simplexdev.simplexcore.strike.api.ConfigUser; -/* */ import java.util.Arrays; -/* */ import org.bukkit.command.Command; -/* */ import org.bukkit.command.CommandExecutor; -/* */ import org.bukkit.command.CommandSender; -/* */ import org.bukkit.plugin.java.JavaPlugin; -/* */ -/* */ -/* */ public class StrikeCommand -/* */ implements CommandExecutor -/* */ { -/* */ private static ConfigUser[] configUsers; -/* */ private final JavaPlugin plugin; -/* */ -/* */ public StrikeCommand(JavaPlugin plugin) { -/* 18 */ this.plugin = plugin; -/* */ } -/* */ -/* */ public static void loadInstances(ConfigUser... configUsers) { -/* 22 */ StrikeCommand.configUsers = configUsers; -/* */ } -/* */ -/* */ -/* */ -/* */ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { -/* 28 */ if (args[0].isEmpty() || args.length > 1) { -/* 29 */ return true; -/* */ } -/* 31 */ switch (args[0].toLowerCase()) { -/* */ case "reload": -/* 33 */ this.plugin.reloadConfig(); -/* 34 */ Arrays.stream(configUsers).forEach(configUser -> configUser.refresh()); -/* */ break; -/* */ } -/* */ -/* */ -/* 39 */ return true; -/* */ } -/* */ } - - -/* Location: E:\Rishi\Codes\Java Projects\Minecraft Plugins\PaperMC\1.16.4\Server Testing\plugins\strike-1.0-SNAPSHOT.jar!\io\github\simplexdev\simplexcore\strike\StrikeCommand.class - * Java compiler version: 8 (52.0) - * JD-Core Version: 1.1.3 - */ \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/simplexcore/strike/StrikePlugin.java b/src/main/java/io/github/simplexdev/simplexcore/strike/StrikePlugin.java deleted file mode 100644 index 3b0c0d8..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/strike/StrikePlugin.java +++ /dev/null @@ -1,57 +0,0 @@ -/* */ package io.github.simplexdev.simplexcore.strike; -/* */ -/* */ import io.github.simplexdev.simplexcore.strike.api.ConfigUser; -/* */ import io.github.simplexdev.simplexcore.strike.api.Spawn; -/* */ import io.github.simplexdev.simplexcore.strike.listeners.Grenade; -/* */ import io.github.simplexdev.simplexcore.strike.listeners.Gun; -/* */ import io.github.simplexdev.simplexcore.strike.listeners.Jumper; -/* */ import io.github.simplexdev.simplexcore.strike.listeners.SpawnController; -/* */ import org.bukkit.event.Listener; -/* */ import org.bukkit.plugin.Plugin; -/* */ import org.bukkit.plugin.java.JavaPlugin; -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ -/* */ public final class StrikePlugin -/* */ extends JavaPlugin -/* */ { -/* */ public void onEnable() { -/* 32 */ saveDefaultConfig(); -/* 33 */ Spawn.loadConfig(this); -/* */ -/* 35 */ Gun gun = new Gun(this); -/* 36 */ Jumper jumper = new Jumper(this); -/* 37 */ SpawnController spawnController = new SpawnController(this); -/* */ -/* 39 */ getServer().getPluginManager().registerEvents((Listener)gun, (Plugin)this); -/* 40 */ getServer().getPluginManager().registerEvents((Listener)jumper, (Plugin)this); -/* */ -/* 42 */ getServer().getPluginManager().registerEvents((Listener)new Grenade(this), (Plugin)this); -/* 43 */ getServer().getPluginManager().registerEvents((Listener)spawnController, (Plugin)this); -/* */ -/* 45 */ getCommand("strike").setExecutor(new StrikeCommand(this)); -/* */ -/* 47 */ StrikeCommand.loadInstances(new ConfigUser[] { (ConfigUser)gun, (ConfigUser)jumper, (ConfigUser)spawnController }); -/* */ } -/* */ -/* */ public void onDisable() {} -/* */ } - - -/* Location: E:\Rishi\Codes\Java Projects\Minecraft Plugins\PaperMC\1.16.4\Server Testing\plugins\strike-1.0-SNAPSHOT.jar!\io\github\simplexdev\simplexcore\strike\StrikePlugin.class - * Java compiler version: 8 (52.0) - * JD-Core Version: 1.1.3 - */ \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/simplexcore/strike/events/GrenadeKillEvent.java b/src/main/java/io/github/simplexdev/simplexcore/strike/events/GrenadeKillEvent.java deleted file mode 100644 index 800fc25..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/strike/events/GrenadeKillEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -/* */ package io.github.simplexdev.simplexcore.strike.events; -/* */ -/* */ import java.util.List; -/* */ import org.bukkit.entity.LivingEntity; -/* */ import org.bukkit.entity.Player; -/* */ import org.bukkit.event.Event; -/* */ import org.bukkit.event.HandlerList; -/* */ -/* */ public class GrenadeKillEvent -/* */ extends Event -/* */ { -/* 12 */ private static final HandlerList handlers = new HandlerList(); -/* */ private final Player killer; -/* */ private final List deadList; -/* */ -/* */ public GrenadeKillEvent(Player killer, List deadList) { -/* 17 */ this.killer = killer; -/* 18 */ this.deadList = deadList; -/* */ } -/* */ -/* */ public Player getKiller() { -/* 22 */ return this.killer; -/* */ } -/* */ -/* */ public List getDeadList() { -/* 26 */ return this.deadList; -/* */ } -/* */ -/* */ -/* */ public HandlerList getHandlers() { -/* 31 */ return handlers; -/* */ } -/* */ -/* */ -/* */ public static HandlerList getHandlerList() { -/* 36 */ return handlers; -/* */ } -/* */ } - - -/* Location: E:\Rishi\Codes\Java Projects\Minecraft Plugins\PaperMC\1.16.4\Server Testing\plugins\strike-1.0-SNAPSHOT.jar!\io\github\simplexdev\simplexcore\strike\events\GrenadeKillEvent.class - * Java compiler version: 8 (52.0) - * JD-Core Version: 1.1.3 - */ \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/simplexcore/strike/events/UseHealthPackageEvent.java b/src/main/java/io/github/simplexdev/simplexcore/strike/events/UseHealthPackageEvent.java deleted file mode 100644 index 8e5607c..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/strike/events/UseHealthPackageEvent.java +++ /dev/null @@ -1,35 +0,0 @@ -/* */ package io.github.simplexdev.simplexcore.strike.events; -/* */ -/* */ import org.bukkit.entity.Player; -/* */ import org.bukkit.event.Event; -/* */ import org.bukkit.event.HandlerList; -/* */ -/* */ public class UseHealthPackageEvent -/* */ extends Event { -/* 9 */ private static final HandlerList handlers = new HandlerList(); -/* */ private final Player player; -/* */ -/* */ public UseHealthPackageEvent(Player player) { -/* 13 */ this.player = player; -/* */ } -/* */ -/* */ public Player getPlayer() { -/* 17 */ return this.player; -/* */ } -/* */ -/* */ -/* */ public HandlerList getHandlers() { -/* 22 */ return handlers; -/* */ } -/* */ -/* */ -/* */ public static HandlerList getHandlerList() { -/* 27 */ return handlers; -/* */ } -/* */ } - - -/* Location: E:\Rishi\Codes\Java Projects\Minecraft Plugins\PaperMC\1.16.4\Server Testing\plugins\strike-1.0-SNAPSHOT.jar!\io\github\simplexdev\simplexcore\strike\events\UseHealthPackageEvent.class - * Java compiler version: 8 (52.0) - * JD-Core Version: 1.1.3 - */ \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/simplexcore/strike/listeners/Grenade.java b/src/main/java/io/github/simplexdev/simplexcore/strike/listeners/Grenade.java deleted file mode 100644 index cebb073..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/strike/listeners/Grenade.java +++ /dev/null @@ -1,127 +0,0 @@ -/* */ package io.github.simplexdev.simplexcore.strike.listeners; -/* */ -/* */ import io.github.simplexdev.simplexcore.strike.api.ConfigUser; -/* */ import io.github.simplexdev.simplexcore.strike.api.Spawn; -/* */ import java.util.ArrayList; -/* */ import java.util.Collection; -/* */ import java.util.HashMap; -/* */ import java.util.List; -/* */ import java.util.Map; -/* */ import org.bukkit.ChatColor; -/* */ import org.bukkit.GameMode; -/* */ import org.bukkit.Material; -/* */ import org.bukkit.entity.Item; -/* */ import org.bukkit.entity.LivingEntity; -/* */ import org.bukkit.entity.Player; -/* */ import org.bukkit.event.EventHandler; -/* */ import org.bukkit.event.entity.EntityDamageEvent; -/* */ import org.bukkit.event.player.PlayerAttemptPickupItemEvent; -/* */ import org.bukkit.event.player.PlayerInteractEvent; -/* */ import org.bukkit.inventory.ItemStack; -/* */ import org.bukkit.inventory.meta.ItemMeta; -/* */ import org.bukkit.plugin.Plugin; -/* */ import org.bukkit.plugin.java.JavaPlugin; -/* */ import org.bukkit.scheduler.BukkitRunnable; -/* */ -/* */ public class Grenade -/* */ implements ConfigUser { -/* 28 */ private static List items = new ArrayList<>(); -/* 29 */ private static Map> map = new HashMap<>(); -/* */ private final ItemStack grenadeItem; -/* */ private final JavaPlugin plugin; -/* */ private int explosionTime; -/* */ -/* */ public Grenade(JavaPlugin plugin) { -/* 35 */ this.plugin = plugin; -/* 36 */ this.grenadeItem = createItem(); -/* 37 */ this.explosionTime = plugin.getConfig().getInt("grenade.explosion-time", 1); -/* */ } -/* */ -/* */ -/* */ public ItemStack createItem() { -/* 42 */ ItemStack stack = new ItemStack(Material.MAGMA_CREAM, 1); -/* 43 */ ItemMeta meta = this.plugin.getServer().getItemFactory().getItemMeta(Material.MAGMA_CREAM); -/* */ -/* 45 */ meta.setDisplayName(ChatColor.RED + "Grenade"); -/* */ -/* 47 */ stack.setItemMeta(meta); -/* */ -/* 49 */ this.plugin.getServer().getOnlinePlayers().forEach(player -> player.getInventory().addItem(new ItemStack[] { stack })); -/* */ -/* 51 */ return stack; -/* */ } -/* */ -/* */ -/* */ -/* */ @EventHandler -/* */ private void throwGrenade(PlayerInteractEvent e) { -/* 58 */ ItemStack itemStack = e.getItem(); -/* 59 */ final Player player = e.getPlayer(); -/* */ -/* 61 */ if (!player.getWorld().equals(Spawn.getWorld()) || itemStack == null || !itemStack.isSimilar(this.grenadeItem) || e.getAction().toString().startsWith("LEFT")) { -/* */ return; -/* */ } -/* 64 */ if (player.getGameMode() != GameMode.CREATIVE) { -/* 65 */ if (itemStack.getAmount() == 1) { -/* 66 */ itemStack = null; -/* */ } else { -/* 68 */ itemStack.setAmount(itemStack.getAmount() - 1); -/* */ } -/* 70 */ player.getInventory().setItemInMainHand(itemStack); -/* */ } -/* */ -/* 73 */ final Item item = player.getWorld().dropItem(player.getEyeLocation(), new ItemStack(Material.MAGMA_CREAM)); -/* 74 */ item.setVelocity(player.getEyeLocation().getDirection().multiply(0.75D)); -/* */ -/* 76 */ (new BukkitRunnable() -/* */ { -/* */ public void run() { -/* 79 */ if (item != null) { -/* 80 */ item.getLocation().createExplosion(4.0F, false, false); -/* 81 */ Collection entities = item.getLocation().getNearbyLivingEntities(4.0D); -/* */ -/* 83 */ List players = new ArrayList<>(); -/* */ -/* 85 */ entities.forEach(livingEntity -> { -/* */ if (livingEntity instanceof Player) { -/* */ players.add((Player)livingEntity); -/* */ } -/* */ }); -/* 90 */ Grenade.map.put(player, players); -/* */ -/* 92 */ Grenade.items.remove(item); -/* 93 */ item.remove(); -/* */ } -/* */ } -/* 96 */ }).runTaskLater((Plugin)this.plugin, (20 * this.explosionTime)); -/* */ -/* 98 */ items.add(item); -/* */ } -/* */ -/* */ -/* */ @EventHandler -/* */ private void onPlayerDamage(EntityDamageEvent e) { -/* 104 */ if (!e.getEntity().getWorld().equals(Spawn.getWorld()) || !(e.getEntity() instanceof Player)) { -/* */ return; -/* */ } -/* */ -/* 108 */ Player player = (Player)e.getEntity(); -/* */ -/* 110 */ map.values().forEach(players -> System.out.println(players)); -/* */ } -/* */ -/* */ @EventHandler -/* */ private void cancelPickup(PlayerAttemptPickupItemEvent e) { -/* 115 */ if (!items.contains(e.getItem())) -/* */ return; -/* 117 */ e.setCancelled(true); -/* */ } -/* */ -/* */ public void refresh() {} -/* */ } - - -/* Location: E:\Rishi\Codes\Java Projects\Minecraft Plugins\PaperMC\1.16.4\Server Testing\plugins\strike-1.0-SNAPSHOT.jar!\io\github\simplexdev\simplexcore\strike\listeners\Grenade.class - * Java compiler version: 8 (52.0) - * JD-Core Version: 1.1.3 - */ \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/simplexcore/strike/listeners/HealthPackage.java b/src/main/java/io/github/simplexdev/simplexcore/strike/listeners/HealthPackage.java deleted file mode 100644 index b938a4f..0000000 --- a/src/main/java/io/github/simplexdev/simplexcore/strike/listeners/HealthPackage.java +++ /dev/null @@ -1,92 +0,0 @@ -/* */ package io.github.simplexdev.simplexcore.strike.listeners; -/* */ -/* */ import io.github.simplexdev.simplexcore.strike.api.ConfigUser; -/* */ import io.github.simplexdev.simplexcore.strike.api.Spawn; -/* */ import io.github.simplexdev.simplexcore.strike.events.GunKillEvent; -/* */ import io.github.simplexdev.simplexcore.strike.utils.SkullCreator; -/* */ import org.bukkit.ChatColor; -/* */ import org.bukkit.entity.Player; -/* */ import org.bukkit.event.EventHandler; -/* */ import org.bukkit.event.block.Action; -/* */ import org.bukkit.event.entity.PlayerDeathEvent; -/* */ import org.bukkit.event.player.PlayerInteractEvent; -/* */ import org.bukkit.inventory.ItemStack; -/* */ import org.bukkit.inventory.meta.ItemMeta; -/* */ import org.bukkit.plugin.java.JavaPlugin; -/* */ -/* */ public class HealthPackage -/* */ implements ConfigUser -/* */ { -/* */ private final ItemStack healthPackage; -/* */ private final JavaPlugin plugin; -/* */ private String usedMessage; -/* */ private int regainHealth; -/* */ -/* */ public HealthPackage(JavaPlugin plugin) { -/* 26 */ this.plugin = plugin; -/* 27 */ this.usedMessage = plugin.getConfig().getString("health-package.restore-health-message", "You have restored your health"); -/* 28 */ this.regainHealth = plugin.getConfig().getInt("health-package.restore-health"); -/* 29 */ this.healthPackage = createHealthPackage(); -/* */ } -/* */ -/* */ @EventHandler -/* */ public void onInteract(PlayerInteractEvent e) { -/* 34 */ Player player = e.getPlayer(); -/* 35 */ ItemStack item = player.getInventory().getItemInMainHand(); -/* */ -/* 37 */ if (!player.getWorld().equals(Spawn.getWorld())) { -/* */ return; -/* */ } -/* 40 */ if (player.getInventory().getItemInMainHand().isSimilar(this.healthPackage)) { -/* 41 */ if (e.getAction().equals(Action.LEFT_CLICK_BLOCK) || e.getAction().equals(Action.LEFT_CLICK_AIR)) { -/* */ return; -/* */ } -/* 44 */ player.setHealth(this.regainHealth); -/* 45 */ player.sendMessage(ChatColor.translateAlternateColorCodes('&', "usedMessage")); -/* */ -/* 47 */ if (item.getAmount() == 1) { -/* 48 */ player.getInventory().setItemInMainHand(null); -/* */ } else { -/* */ -/* 51 */ item.setAmount(item.getAmount() - 1); -/* */ } -/* 53 */ e.setCancelled(true); -/* */ } -/* */ } -/* */ public ItemStack createHealthPackage() { -/* 57 */ String base64 = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGExNTU4YTgzZjQwMjZkYjIzMmY4MGJjOTYxNWNjM2JhNDE1ZGM0MDk0MGE1YTEzYWUyYThjOTBiMTVjM2MzZSJ9fX0="; -/* */ -/* 59 */ ItemStack healthPackage = SkullCreator.itemFromBase64(base64); -/* 60 */ ItemMeta meta = healthPackage.getItemMeta(); -/* 61 */ meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', this.plugin.getConfig().getString("health-package.name"))); -/* 62 */ healthPackage.setItemMeta(meta); -/* */ -/* 64 */ return healthPackage; -/* */ } -/* */ -/* */ @EventHandler -/* */ public void onDeath(PlayerDeathEvent e) { -/* 69 */ Player player = e.getEntity(); -/* */ -/* 71 */ if (!player.getWorld().equals(Spawn.getWorld())) { -/* */ return; -/* */ } -/* 74 */ if (player.getWorld().equals(Spawn.getWorld())) { -/* 75 */ player.getKiller().getInventory().addItem(new ItemStack[] { this.healthPackage }); -/* */ } -/* */ } -/* */ -/* */ @EventHandler -/* */ private void onDeath(GunKillEvent e) { -/* 81 */ if (e.getDead() instanceof Player) -/* 82 */ e.getKiller().getInventory().addItem(new ItemStack[] { this.healthPackage }); -/* */ } -/* */ -/* */ public void refresh() {} -/* */ } - - -/* Location: E:\Rishi\Codes\Java Projects\Minecraft Plugins\PaperMC\1.16.4\Server Testing\plugins\strike-1.0-SNAPSHOT.jar!\io\github\simplexdev\simplexcore\strike\listeners\HealthPackage.class - * Java compiler version: 8 (52.0) - * JD-Core Version: 1.1.3 - */ \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/strike/StrikeCommand.java b/src/main/java/io/github/simplexdev/strike/StrikeCommand.java new file mode 100644 index 0000000..18906bc --- /dev/null +++ b/src/main/java/io/github/simplexdev/strike/StrikeCommand.java @@ -0,0 +1,38 @@ +package io.github.simplexdev.strike; + +import io.github.simplexdev.strike.api.ConfigUser; +import java.util.Arrays; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.java.JavaPlugin; + + +public class StrikeCommand implements CommandExecutor { + + private static ConfigUser[] configUsers; + private final JavaPlugin plugin; + + public StrikeCommand(JavaPlugin plugin) { + this.plugin = plugin; + } + + public static void loadInstances(ConfigUser... configUsers) { + StrikeCommand.configUsers = configUsers; + } + + + public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { + if (args[0].isEmpty() || args.length > 1) { + return true; + } + if ("reload".equals(args[0].toLowerCase())) { + this.plugin.reloadConfig(); + Arrays.stream(configUsers).forEach(configUser -> configUser.refresh()); + } + + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/strike/StrikePlugin.java b/src/main/java/io/github/simplexdev/strike/StrikePlugin.java new file mode 100644 index 0000000..f9e2477 --- /dev/null +++ b/src/main/java/io/github/simplexdev/strike/StrikePlugin.java @@ -0,0 +1,38 @@ +package io.github.simplexdev.strike; + +import io.github.simplexdev.strike.api.ConfigUser; +import io.github.simplexdev.strike.api.Spawn; +import io.github.simplexdev.strike.listeners.*; +import org.bukkit.event.Listener; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; + + +public final class StrikePlugin extends JavaPlugin { + + @Override + public void onEnable() { + saveDefaultConfig(); + Spawn.loadConfig(this); + + Gun gun = new Gun(this); + Jumper jumper = new Jumper(this); + SpawnController spawnController = new SpawnController(this); + HealthPackage healthPackage = new HealthPackage(this); + + getServer().getPluginManager().registerEvents(gun, this); + getServer().getPluginManager().registerEvents(jumper, this); + getServer().getPluginManager().registerEvents(spawnController, this); + getServer().getPluginManager().registerEvents(healthPackage, this); + + getServer().getPluginManager().registerEvents(new Grenade(this), this); + + getCommand("strike").setExecutor(new StrikeCommand(this)); + + StrikeCommand.loadInstances(gun, jumper, spawnController); + } + + @Override + public void onDisable() { + } +} \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/simplexcore/strike/api/ConfigUser.java b/src/main/java/io/github/simplexdev/strike/api/ConfigUser.java similarity index 86% rename from src/main/java/io/github/simplexdev/simplexcore/strike/api/ConfigUser.java rename to src/main/java/io/github/simplexdev/strike/api/ConfigUser.java index a87be5c..d1707d8 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/strike/api/ConfigUser.java +++ b/src/main/java/io/github/simplexdev/strike/api/ConfigUser.java @@ -1,4 +1,4 @@ -package io.github.simplexdev.simplexcore.strike.api; +package io.github.simplexdev.strike.api; import org.bukkit.event.Listener; diff --git a/src/main/java/io/github/simplexdev/simplexcore/strike/api/Spawn.java b/src/main/java/io/github/simplexdev/strike/api/Spawn.java similarity index 84% rename from src/main/java/io/github/simplexdev/simplexcore/strike/api/Spawn.java rename to src/main/java/io/github/simplexdev/strike/api/Spawn.java index 587ae89..e084f53 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/strike/api/Spawn.java +++ b/src/main/java/io/github/simplexdev/strike/api/Spawn.java @@ -1,4 +1,4 @@ -/* */ package io.github.simplexdev.simplexcore.strike.api; +/* */ package io.github.simplexdev.strike.api; /* */ /* */ import org.bukkit.Location; /* */ import org.bukkit.World; @@ -18,9 +18,9 @@ /* */ /* */ public static void setSpawn(Location spawn, JavaPlugin plugin) { /* 20 */ FileConfiguration config = plugin.getConfig(); -/* 21 */ config.set("spawn.coords.x", Double.valueOf(spawn.getX())); -/* 22 */ config.set("spawn.coords.y", Double.valueOf(spawn.getY())); -/* 23 */ config.set("spawn.coords.z", Double.valueOf(spawn.getZ())); +/* 21 */ config.set("spawn.coords.x",spawn.getX()); +/* 22 */ config.set("spawn.coords.y", spawn.getY()); +/* 23 */ config.set("spawn.coords.z", spawn.getZ()); /* */ /* 25 */ Spawn.spawn = spawn; /* */ } diff --git a/src/main/java/io/github/simplexdev/strike/api/utils/InventoryEdit.java b/src/main/java/io/github/simplexdev/strike/api/utils/InventoryEdit.java new file mode 100644 index 0000000..339e63d --- /dev/null +++ b/src/main/java/io/github/simplexdev/strike/api/utils/InventoryEdit.java @@ -0,0 +1,4 @@ +package io.github.simplexdev.strike.api.utils; + +public class InventoryEdit { +} diff --git a/src/main/java/io/github/simplexdev/simplexcore/strike/utils/SkullCreator.java b/src/main/java/io/github/simplexdev/strike/api/utils/SkullCreator.java similarity index 99% rename from src/main/java/io/github/simplexdev/simplexcore/strike/utils/SkullCreator.java rename to src/main/java/io/github/simplexdev/strike/api/utils/SkullCreator.java index a414704..b6a0543 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/strike/utils/SkullCreator.java +++ b/src/main/java/io/github/simplexdev/strike/api/utils/SkullCreator.java @@ -1,4 +1,4 @@ - package io.github.simplexdev.simplexcore.strike.utils; + package io.github.simplexdev.strike.api.utils; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; diff --git a/src/main/java/io/github/simplexdev/strike/events/GrenadeKillEvent.java b/src/main/java/io/github/simplexdev/strike/events/GrenadeKillEvent.java new file mode 100644 index 0000000..8325d7a --- /dev/null +++ b/src/main/java/io/github/simplexdev/strike/events/GrenadeKillEvent.java @@ -0,0 +1,36 @@ + package io.github.simplexdev.strike.events; + + import java.util.List; + import org.bukkit.entity.LivingEntity; + import org.bukkit.entity.Player; + import org.bukkit.event.Event; + import org.bukkit.event.HandlerList; + + public class GrenadeKillEvent + extends Event { + private static final HandlerList handlers = new HandlerList(); + private final Player killer; + private final Player dead; + + public GrenadeKillEvent(Player killer, Player dead) { + this.killer = killer; + this.dead = dead; + } + + public Player getKiller() { + return this.killer; + } + + public Player getDead() { + return dead; + } + + public HandlerList getHandlers() { + return handlers; + } + + + public static HandlerList getHandlerList() { + return handlers; + } + } \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/simplexcore/strike/events/GunKillEvent.java b/src/main/java/io/github/simplexdev/strike/events/GunKillEvent.java similarity index 94% rename from src/main/java/io/github/simplexdev/simplexcore/strike/events/GunKillEvent.java rename to src/main/java/io/github/simplexdev/strike/events/GunKillEvent.java index 807b028..cf74ca2 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/strike/events/GunKillEvent.java +++ b/src/main/java/io/github/simplexdev/strike/events/GunKillEvent.java @@ -1,4 +1,4 @@ -/* */ package io.github.simplexdev.simplexcore.strike.events; +/* */ package io.github.simplexdev.strike.events; /* */ /* */ import org.bukkit.entity.LivingEntity; /* */ import org.bukkit.entity.Player; diff --git a/src/main/java/io/github/simplexdev/strike/listeners/Grenade.java b/src/main/java/io/github/simplexdev/strike/listeners/Grenade.java new file mode 100644 index 0000000..6692685 --- /dev/null +++ b/src/main/java/io/github/simplexdev/strike/listeners/Grenade.java @@ -0,0 +1,129 @@ +package io.github.simplexdev.strike.listeners; + +import io.github.simplexdev.strike.api.ConfigUser; +import io.github.simplexdev.strike.api.Spawn; +import io.github.simplexdev.strike.events.GrenadeKillEvent; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.entity.Item; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerAttemptPickupItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; + +import java.util.*; + +public class Grenade implements ConfigUser { + private static final List items = new ArrayList<>(); + private static final Map> map = new HashMap<>(); + private final ItemStack grenadeItem; + private final JavaPlugin plugin; + private final int explosionTime; + + public Grenade(JavaPlugin plugin) { + this.plugin = plugin; + this.grenadeItem = createItem(); + this.explosionTime = plugin.getConfig().getInt("grenade.explosion-time", 1); + } + + + public ItemStack createItem() { + ItemStack stack = new ItemStack(Material.MAGMA_CREAM, 1); + ItemMeta meta = this.plugin.getServer().getItemFactory().getItemMeta(Material.MAGMA_CREAM); + + meta.setDisplayName(ChatColor.RED + "Grenade"); + + stack.setItemMeta(meta); + + this.plugin.getServer().getOnlinePlayers().forEach(player -> player.getInventory().addItem(new ItemStack[]{stack})); + + return stack; + } + + + @EventHandler + private void throwGrenade(PlayerInteractEvent e) { + ItemStack itemStack = e.getItem(); + final Player player = e.getPlayer(); + + if (!player.getWorld().equals(Spawn.getWorld()) || itemStack == null || !itemStack.isSimilar(this.grenadeItem) || e.getAction().toString().startsWith("LEFT")) { + return; + } + if (player.getGameMode() != GameMode.CREATIVE) { + if (itemStack.getAmount() == 1) { + itemStack = null; + } else { + itemStack.setAmount(itemStack.getAmount() - 1); + } + player.getInventory().setItemInMainHand(itemStack); + } + + final Item item = player.getWorld().dropItem(player.getEyeLocation(), new ItemStack(Material.MAGMA_CREAM)); + item.setVelocity(player.getEyeLocation().getDirection().multiply(0.75D)); + + (new BukkitRunnable() { + public void run() { + if (item != null) { + item.getLocation().createExplosion(4.0F, false, false); + Collection entities = item.getLocation().getNearbyLivingEntities(4.0D); + + List players = new ArrayList<>(); + + entities.forEach(livingEntity -> { + if (livingEntity instanceof Player) { + players.add((Player) livingEntity); + } + }); + Grenade.map.put(player, players); + + Grenade.items.remove(item); + item.remove(); + } + } + }).runTaskLater(this.plugin, (20 * this.explosionTime)); + + items.add(item); + } + + + @EventHandler + private void onPlayerDamage(EntityDamageEvent e) { + if (!e.getEntity().getWorld().equals(Spawn.getWorld()) || !(e.getEntity() instanceof Player)) + return; + + Player player = (Player) e.getEntity(); + Player killer = null; + + for (Map.Entry> entry : map.entrySet()) { + + if (entry.getValue().contains(player)) { + + if (player.getHealth() <= e.getFinalDamage()) + killer = entry.getKey(); + + entry.getValue().remove(player); + } + } + + if (killer != null) + Bukkit.getPluginManager().callEvent(new GrenadeKillEvent(killer, player)); + } + + @EventHandler + private void cancelPickup(PlayerAttemptPickupItemEvent e) { + if (!items.contains(e.getItem())) + return; + e.setCancelled(true); + } + + public void refresh() { + } +} \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/simplexcore/strike/listeners/Gun.java b/src/main/java/io/github/simplexdev/strike/listeners/Gun.java similarity index 95% rename from src/main/java/io/github/simplexdev/simplexcore/strike/listeners/Gun.java rename to src/main/java/io/github/simplexdev/strike/listeners/Gun.java index 6cac2e6..5e70471 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/strike/listeners/Gun.java +++ b/src/main/java/io/github/simplexdev/strike/listeners/Gun.java @@ -1,11 +1,13 @@ -/* */ package io.github.simplexdev.simplexcore.strike.listeners; -/* */ import io.github.simplexdev.simplexcore.strike.api.Spawn; +/* */ package io.github.simplexdev.strike.listeners; +/* */ import io.github.simplexdev.strike.api.ConfigUser; +import io.github.simplexdev.strike.api.Spawn; /* */ import java.util.Collection; /* */ import java.util.HashMap; -/* */ import org.bukkit.ChatColor; -/* */ import org.bukkit.Location; -/* */ import org.bukkit.Material; -/* */ import org.bukkit.World; +/* */ import io.github.simplexdev.strike.events.GunKillEvent; +import org.bukkit.*; +/* */ +/* */ +/* */ /* */ import org.bukkit.entity.Entity; /* */ import org.bukkit.entity.LivingEntity; /* */ import org.bukkit.entity.Player; @@ -20,7 +22,7 @@ /* */ import org.bukkit.plugin.java.JavaPlugin; /* */ import org.bukkit.scheduler.BukkitRunnable; /* */ -/* */ public final class Gun implements ConfigUser { +/* */ public class Gun implements ConfigUser { /* 24 */ private static final HashMap ammoMap = new HashMap<>(); /* */ /* */ private final ItemStack gunItemStack; diff --git a/src/main/java/io/github/simplexdev/strike/listeners/HealthPackage.java b/src/main/java/io/github/simplexdev/strike/listeners/HealthPackage.java new file mode 100644 index 0000000..433abfa --- /dev/null +++ b/src/main/java/io/github/simplexdev/strike/listeners/HealthPackage.java @@ -0,0 +1,98 @@ + package io.github.simplexdev.strike.listeners; + + import io.github.simplexdev.strike.api.ConfigUser; + import io.github.simplexdev.strike.api.Spawn; + import io.github.simplexdev.strike.events.GrenadeKillEvent; + import io.github.simplexdev.strike.events.GunKillEvent; + import io.github.simplexdev.strike.api.utils.SkullCreator; + import org.bukkit.ChatColor; + import org.bukkit.Material; + import org.bukkit.entity.Player; + import org.bukkit.event.EventHandler; + import org.bukkit.event.block.Action; + import org.bukkit.event.entity.PlayerDeathEvent; + import org.bukkit.event.player.PlayerInteractEvent; + import org.bukkit.inventory.ItemStack; + import org.bukkit.inventory.meta.ItemMeta; + import org.bukkit.plugin.java.JavaPlugin; + + public class HealthPackage + implements ConfigUser { + private final JavaPlugin plugin; + private ItemStack healthPackage; + private String usedMessage; + private int regainHealth; + + public HealthPackage(JavaPlugin plugin) { + this.plugin = plugin; + refresh(); + } + + @EventHandler + public void onInteract(PlayerInteractEvent e) { + Player player = e.getPlayer(); + ItemStack item = player.getInventory().getItemInMainHand(); + + if (!player.getWorld().equals(Spawn.getWorld())) { + return; + } + if (player.getInventory().getItemInMainHand().isSimilar(this.healthPackage)) { + if (e.getAction().equals(Action.LEFT_CLICK_BLOCK) || e.getAction().equals(Action.LEFT_CLICK_AIR)) { + return; + } + player.setHealth(this.regainHealth); + player.sendMessage(ChatColor.translateAlternateColorCodes('&', usedMessage)); + + if (item.getAmount() == 1) { + player.getInventory().setItemInMainHand(null); + } else { + + item.setAmount(item.getAmount() - 1); + } + e.setCancelled(true); + } + } + + public ItemStack createHealthPackage() { + String base64 = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGExNTU4YTgzZjQwMjZkYjIzMmY4MGJjOTYxNWNjM2JhNDE1ZGM0MDk0MGE1YTEzYWUyYThjOTBiMTVjM2MzZSJ9fX0="; + + ItemStack healthPackage = SkullCreator.itemFromBase64(base64); + ItemMeta meta = plugin.getServer().getItemFactory().getItemMeta(Material.PLAYER_HEAD); + + meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', this.plugin.getConfig().getString("health-package.name"))); + + healthPackage.setItemMeta(meta); + + return healthPackage; + } + + @EventHandler + public void onDeath(PlayerDeathEvent e) { + Player player = e.getEntity(); + + if (player.getWorld().equals(Spawn.getWorld())) { + + if (player.getKiller() != null) + player.getKiller().getInventory().addItem(new ItemStack[]{this.healthPackage}); + + e.getDrops().clear(); + } + } + + @EventHandler + private void onDeath(GunKillEvent e) { + if (e.getDead() instanceof Player) + e.getKiller().getInventory().addItem(new ItemStack[]{this.healthPackage}); + } + + @EventHandler + private void onDeath(GrenadeKillEvent e) { + e.getKiller().getInventory().addItem(this.healthPackage); + } + + public void refresh() { + this.usedMessage = plugin.getConfig().getString("health-package.restore-health-message", "You have restored your health"); + this.regainHealth = plugin.getConfig().getInt("health-package.restore-health"); + this.healthPackage = createHealthPackage(); + } + } \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/simplexcore/strike/listeners/Jumper.java b/src/main/java/io/github/simplexdev/strike/listeners/Jumper.java similarity index 92% rename from src/main/java/io/github/simplexdev/simplexcore/strike/listeners/Jumper.java rename to src/main/java/io/github/simplexdev/strike/listeners/Jumper.java index 1955372..3a23305 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/strike/listeners/Jumper.java +++ b/src/main/java/io/github/simplexdev/strike/listeners/Jumper.java @@ -1,11 +1,12 @@ -/* */ package io.github.simplexdev.simplexcore.strike.listeners; +/* */ package io.github.simplexdev.strike.listeners; /* */ /* */ import com.destroystokyo.paper.event.player.PlayerJumpEvent; -/* */ import io.github.simplexdev.simplexcore.strike.api.ConfigUser; +/* */ import io.github.simplexdev.strike.api.ConfigUser; /* */ import java.util.HashMap; /* */ import java.util.Map; /* */ import java.util.UUID; -/* */ import org.bukkit.ChatColor; +/* */ +import org.bukkit.ChatColor; /* */ import org.bukkit.GameMode; /* */ import org.bukkit.entity.Player; /* */ import org.bukkit.event.EventHandler; @@ -14,8 +15,7 @@ /* */ import org.bukkit.plugin.java.JavaPlugin; /* */ import org.bukkit.scheduler.BukkitRunnable; /* */ -/* */ public final class Jumper -/* */ implements ConfigUser +/* */ public class Jumper implements ConfigUser /* */ { /* 20 */ private static final Map playersOnCoolDown = new HashMap<>(); /* */ private final JavaPlugin plugin; diff --git a/src/main/java/io/github/simplexdev/simplexcore/strike/listeners/SpawnController.java b/src/main/java/io/github/simplexdev/strike/listeners/SpawnController.java similarity index 89% rename from src/main/java/io/github/simplexdev/simplexcore/strike/listeners/SpawnController.java rename to src/main/java/io/github/simplexdev/strike/listeners/SpawnController.java index 18ed3be..13bfe0e 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/strike/listeners/SpawnController.java +++ b/src/main/java/io/github/simplexdev/strike/listeners/SpawnController.java @@ -1,8 +1,9 @@ -/* */ package io.github.simplexdev.simplexcore.strike.listeners; +/* */ package io.github.simplexdev.strike.listeners; /* */ -/* */ import io.github.simplexdev.simplexcore.strike.api.ConfigUser; -/* */ import io.github.simplexdev.simplexcore.strike.api.Spawn; -/* */ import org.bukkit.Material; +/* */ import io.github.simplexdev.strike.api.ConfigUser; +/* */ import io.github.simplexdev.strike.api.Spawn; +/* */ +import org.bukkit.Material; /* */ import org.bukkit.entity.Player; /* */ import org.bukkit.event.EventHandler; /* */ import org.bukkit.event.EventPriority; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..13565a7 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1,27 @@ +double-jump: + cooldown: 10 #Time in Seconds + cooldown-finish-message: "Done" + +gun: + ammo: 30 + name: "Gun" #Gun Name + damage: 3 #Damage Per Shoot + reload-time: 2 #Time in Seconds + range: 30 #Blocks the bullet can travel (must be below 120) + +grenade: + name: "Grenade" #Name of the Grenade + explosion-time: 1 #Time in seconds + +health-package: + name: "&cHealth Package" + restore-health: 20 + restore-health-message: "You have restored your health" + +spawn: + respawn-message: "you respawned" #respawn message + world: "world" #the world name + coords: #x,y,z coordinates of the spawn + x: 0 + y: 0 + z: 0 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 348c077..55060fd 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,4 +1,8 @@ name: Strike version: @version@ -main: io.github.simpledev.strike.Strike +main: io.github.simplexdev.strike.StrikePlugin api-version: 1.16 +commands: + strike: + usage: + description: ok \ No newline at end of file