This commit is contained in:
Marco-Byte-1 2021-03-05 21:14:01 +05:30
parent c8e83cae42
commit 51770dee82
13 changed files with 448 additions and 426 deletions

View File

@ -3,8 +3,10 @@ package io.github.simplexdev.strike;
import io.github.simplexdev.strike.api.ConfigUser;
import java.util.Arrays;
import io.github.simplexdev.strike.api.Spawn;
import io.github.simplexdev.strike.api.utils.InventoryEditConfigManager;
import io.github.simplexdev.strike.listeners.InventoryEditGUI;
import io.github.simplexdev.strike.listeners.SpawnController;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -45,6 +47,11 @@ public class StrikeCommand implements CommandExecutor {
player.getInventory().setContents(new InventoryEditConfigManager(plugin).getInventory(player));
}
else if ("set-spawn".equalsIgnoreCase(args[0]) && sender instanceof Player) {
Player player = ((Player) sender);
new SpawnController(plugin).setSpawn(player.getLocation());
}
return true;
}

View File

@ -1,20 +1,15 @@
package io.github.simplexdev.strike;
import io.github.simplexdev.strike.api.Spawn;
import io.github.simplexdev.strike.api.utils.InventoryEditConfigManager;
import io.github.simplexdev.strike.listeners.*;
import org.bukkit.plugin.java.JavaPlugin;
public final class StrikePlugin extends JavaPlugin {
//TODO
// Full Ammo after dead
// Fall Damage Disable
// Health Pack head not working
// Bullet through Grass
// Ammo CHat Remove
// Bullet through Grass, Glass, Fence, Gates, Bars
// NPC Edit
// SetSpawn
// LaunchPad
@Override

View File

@ -5,9 +5,3 @@ import org.bukkit.event.Listener;
public interface ConfigUser extends Listener {
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\api\ConfigUser.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

View File

@ -1,46 +1,53 @@
/* */ package io.github.simplexdev.strike.api;
/* */
/* */ import org.bukkit.Location;
/* */ import org.bukkit.World;
/* */ import org.bukkit.configuration.file.FileConfiguration;
/* */ import org.bukkit.plugin.java.JavaPlugin;
/* */
/* */ public class Spawn {
/* 9 */ private static World world = null;
/* 10 */ private static Location spawn = null;
/* */
/* */ public static void loadConfig(JavaPlugin plugin) {
/* 13 */ FileConfiguration config = plugin.getConfig();
/* */
/* 15 */ world = plugin.getServer().getWorld(config.getString("spawn.world"));
/* 16 */ spawn = new Location(world, config.getInt("spawn.location.x"), config.getInt("spawn.location.y"), config.getInt("spawn.location.z"));
/* */ }
/* */
/* */ public static void setSpawn(Location spawn, JavaPlugin plugin) {
/* 20 */ FileConfiguration config = plugin.getConfig();
/* 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;
/* */ }
/* */
/* */ public static void setWorld(World world, JavaPlugin plugin) {
/* 29 */ plugin.getConfig().set("spawn.world", world.getName());
/* 30 */ Spawn.world = world;
/* */ }
/* */
/* */ public static World getWorld() {
/* 34 */ return world;
/* */ }
/* */
/* */ public static Location getSpawn() {
/* 38 */ return spawn;
/* */ }
/* */ }
package io.github.simplexdev.strike.api;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
/* 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\api\Spawn.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/
import java.io.File;
import java.io.IOException;
public class Spawn {
private static World world = null;
private static Location spawn = null;
public static void loadConfig(JavaPlugin plugin) {
FileConfiguration config = plugin.getConfig();
world = plugin.getServer().getWorld(config.getString("spawn.world"));
spawn = new Location(world, config.getInt("spawn.location.x"), config.getInt("spawn.location.y"), config.getInt("spawn.location.z"));
}
public static void setSpawn(Location spawn, JavaPlugin plugin) {
FileConfiguration config = plugin.getConfig();
config.set("spawn.coords.x", spawn.getX());
config.set("spawn.coords.y", spawn.getY());
config.set("spawn.coords.z", spawn.getZ());
try {
config.save(new File(config.getCurrentPath()));
} catch (IOException e) {
e.printStackTrace();
}
Spawn.spawn = spawn;
}
public static void setWorld(World world, JavaPlugin plugin) {
plugin.getConfig().set("spawn.world", world.getName());
try {
plugin.getConfig().save(new File(plugin.getConfig().getCurrentPath()));
} catch (IOException e) {
e.printStackTrace();
}
Spawn.world = world;
}
public static World getWorld() {
return world;
}
public static Location getSpawn() {
return spawn;
}
}

View File

@ -1,7 +0,0 @@
package io.github.simplexdev.strike.api.utils;
public class InstanceStorage {
}

View File

@ -5,7 +5,6 @@ import io.github.simplexdev.strike.listeners.Gun;
import io.github.simplexdev.strike.listeners.HealthPackage;
import org.bukkit.Material;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.MemorySection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
@ -14,7 +13,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Set;
public class InventoryEditConfigManager {
@ -106,6 +104,8 @@ public class InventoryEditConfigManager {
return i;
return 0;
};
}
;
}

View File

@ -2,12 +2,6 @@
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Base64;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.SkullType;
@ -17,12 +11,12 @@
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Base64;
import java.util.UUID;
public class SkullCreator {

View File

@ -1,13 +1,10 @@
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 {
public class GrenadeKillEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private final Player killer;
private final Player dead;

View File

@ -1,42 +1,36 @@
/* */ package io.github.simplexdev.strike.events;
/* */
/* */ import org.bukkit.entity.LivingEntity;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.event.Event;
/* */ import org.bukkit.event.HandlerList;
/* */
/* */ public class GunKillEvent
/* */ extends Event {
/* 10 */ private static final HandlerList handlers = new HandlerList();
/* */ private final Player killer;
/* */ private final LivingEntity dead;
/* */
/* */ public GunKillEvent(Player killer, LivingEntity dead) {
/* 15 */ this.killer = killer;
/* 16 */ this.dead = dead;
/* */ }
/* */
/* */ public Player getKiller() {
/* 20 */ return this.killer;
/* */ }
/* */
/* */ public LivingEntity getDead() {
/* 24 */ return this.dead;
/* */ }
/* */
/* */
/* */ public HandlerList getHandlers() {
/* 29 */ return handlers;
/* */ }
/* */
/* */
/* */ public static HandlerList getHandlerList() {
/* 34 */ return handlers;
/* */ }
/* */ }
package io.github.simplexdev.strike.events;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class GunKillEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private final Player killer;
private final LivingEntity dead;
public GunKillEvent(Player killer, LivingEntity dead) {
this.killer = killer;
this.dead = dead;
}
public Player getKiller() {
return this.killer;
}
public LivingEntity getDead() {
return this.dead;
}
/* 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\GunKillEvent.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event;
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.event.player.PlayerItemHeldEvent;
import org.bukkit.inventory.ItemStack;
@ -18,11 +19,14 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
public class Gun implements ConfigUser {
private static final HashMap<ItemStack, Integer> ammoMap = new HashMap<>();
private static final HashMap<Player, Integer> ammoMap = new HashMap<>();
private static final List<Material> passThroughBlocks = setPassThroughBlocks();
private final ItemStack gunItemStack;
@ -32,6 +36,38 @@ public class Gun implements ConfigUser {
private int maxDistance;
private static List<Material> setPassThroughBlocks() {
ArrayList<Material> blocks = new ArrayList<>();
blocks.add(Material.TALL_GRASS);
blocks.add(Material.IRON_BARS);
blocks.add(Material.ACACIA_FENCE);
blocks.add(Material.BIRCH_FENCE);
blocks.add(Material.CRIMSON_FENCE);
blocks.add(Material.JUNGLE_FENCE);
blocks.add(Material.OAK_FENCE);
blocks.add(Material.SPRUCE_FENCE);
blocks.add(Material.WARPED_FENCE);
blocks.add(Material.DARK_OAK_FENCE);
blocks.add(Material.NETHER_BRICK_FENCE);
blocks.add(Material.WALL_TORCH);
blocks.add(Material.TORCH);
blocks.add(Material.REDSTONE_TORCH);
blocks.add(Material.REDSTONE_WALL_TORCH);
blocks.add(Material.SOUL_TORCH);
blocks.add(Material.ACACIA_FENCE_GATE);
blocks.add(Material.BIRCH_FENCE_GATE);
blocks.add(Material.CRIMSON_FENCE_GATE);
blocks.add(Material.JUNGLE_FENCE_GATE);
blocks.add(Material.OAK_FENCE_GATE);
blocks.add(Material.SPRUCE_FENCE_GATE);
blocks.add(Material.WARPED_FENCE_GATE);
blocks.add(Material.DARK_OAK_FENCE_GATE);
blocks.add(Material.WATER);
blocks.add(Material.LAVA);
return blocks;
}
public Gun(JavaPlugin plugin) {
this.plugin = plugin;
@ -76,6 +112,12 @@ public class Gun implements ConfigUser {
}).runTaskTimer((Plugin) this.plugin, 0L, 7L);
}
@EventHandler
private void onDeath(PlayerDeathEvent e) {
if (ammoMap.containsKey(e.getEntity()))
ammoMap.replace(e.getEntity(), maxAmmo);
}
@EventHandler
private void onRightClick(PlayerInteractEvent e) {
@ -89,7 +131,7 @@ public class Gun implements ConfigUser {
int ammo = this.maxAmmo;
if (!ammoMap.containsKey(itemStack)) {
ammoMap.put(itemStack, Integer.valueOf(this.maxAmmo - 1));
ammoMap.put(player, Integer.valueOf(this.maxAmmo - 1));
} else {
ammo = ((Integer) ammoMap.get(itemStack)).intValue();
@ -97,22 +139,20 @@ public class Gun implements ConfigUser {
if (ammo == 1) {
(new BukkitRunnable() {
public void run() {
Gun.ammoMap.replace(itemStack, Integer.valueOf(Gun.this.maxAmmo));
Gun.ammoMap.replace(player, Integer.valueOf(Gun.this.maxAmmo));
}
}).runTaskLater((Plugin) this.plugin, 20L * this.plugin.getConfig().getInt("gun.reload-time"));
}
if (((Integer) ammoMap.get(itemStack)).intValue() != 0) {
ammoMap.replace(itemStack, Integer.valueOf(ammo - 1));
ammoMap.replace(player, Integer.valueOf(ammo - 1));
}
}
if (ammo <= 0) {
return;
}
player.sendMessage(String.valueOf(ammo));
spawnParticle(player, player.getEyeLocation().clone(), 0.0D);
Entity entity = player.getTargetEntity(this.maxDistance);
Entity entity = getEntity(player, player.getEyeLocation().clone(), 0.0D);
if (!(entity instanceof LivingEntity)) {
return;
@ -128,7 +168,7 @@ public class Gun implements ConfigUser {
}
private void spawnParticle(Player player, Location location, double distance) {
private Entity getEntity(Player player, Location location, double distance) {
World world = location.getWorld();
location.add(location.getDirection().multiply(0.1D));
@ -136,15 +176,17 @@ public class Gun implements ConfigUser {
distance += 0.1D;
if (location.getBlock().getType() != Material.AIR || distance > this.maxDistance) {
return;
if (!passThroughBlocks.contains(location.getBlock().getType()) || distance > this.maxDistance) {
return null;
}
Collection<LivingEntity> entities = location.getNearbyLivingEntities(0.1D);
if (!entities.isEmpty() && entities.size() == 1 && !entities.contains(player)) {
return;
return entities.iterator().next();
}
spawnParticle(player, location, distance);
Entity entity = getEntity(player, location, distance);
return entity;
}

View File

@ -16,8 +16,7 @@
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
public class HealthPackage
implements ConfigUser {
public class HealthPackage implements ConfigUser {
private final JavaPlugin plugin;
private ItemStack healthPackage;
private String usedMessage;
@ -56,7 +55,7 @@
public ItemStack createItem() {
String base64 = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGExNTU4YTgzZjQwMjZkYjIzMmY4MGJjOTYxNWNjM2JhNDE1ZGM0MDk0MGE1YTEzYWUyYThjOTBiMTVjM2MzZSJ9fX0=";
ItemStack healthPackage = SkullCreator.itemFromBase64(base64);
ItemStack healthPackage = SkullCreator.itemWithUrl(SkullCreator.createSkull(), base64);
ItemMeta meta = plugin.getServer().getItemFactory().getItemMeta(Material.PLAYER_HEAD);
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', this.plugin.getConfig().getString("health-package.name")));

View File

@ -1,80 +1,75 @@
/* */ package io.github.simplexdev.strike.listeners;
/* */
/* */ import com.destroystokyo.paper.event.player.PlayerJumpEvent;
/* */ import io.github.simplexdev.strike.api.ConfigUser;
/* */ import java.util.HashMap;
/* */ import java.util.Map;
/* */ import java.util.UUID;
/* */
package io.github.simplexdev.strike.listeners;
import com.destroystokyo.paper.event.player.PlayerJumpEvent;
import io.github.simplexdev.strike.api.ConfigUser;
import org.bukkit.ChatColor;
/* */ import org.bukkit.GameMode;
/* */ import org.bukkit.entity.Player;
/* */ import org.bukkit.event.EventHandler;
/* */ import org.bukkit.event.player.PlayerToggleFlightEvent;
/* */ import org.bukkit.plugin.Plugin;
/* */ import org.bukkit.plugin.java.JavaPlugin;
/* */ import org.bukkit.scheduler.BukkitRunnable;
/* */
/* */ public class Jumper implements ConfigUser
/* */ {
/* 20 */ private static final Map<UUID, Long> playersOnCoolDown = new HashMap<>();
/* */ private final JavaPlugin plugin;
/* */ private Integer coolDownTime;
/* */
/* */ public Jumper(JavaPlugin plugin) {
/* 25 */ this.plugin = plugin;
/* 26 */ this.coolDownTime = Integer.valueOf(plugin.getConfig().getInt("double-jump.cooldown"));
/* */ }
/* */
/* */
/* */
/* */ @EventHandler
/* */ private void onPlayerJump(PlayerJumpEvent e) {
/* 33 */ Player player = e.getPlayer();
/* 34 */ GameMode mode = player.getGameMode();
/* */
/* 36 */ if (mode == GameMode.CREATIVE || mode == GameMode.SPECTATOR) {
/* */ return;
/* */ }
/* 39 */ if (playersOnCoolDown.containsKey(player.getUniqueId())) {
/* */ return;
/* */ }
/* 42 */ player.setAllowFlight(true);
/* */ }
/* */
/* */
/* */ @EventHandler
/* */ private void onFlightAccessChange(PlayerToggleFlightEvent e) {
/* 48 */ final Player player = e.getPlayer();
/* 49 */ GameMode mode = player.getGameMode();
/* */
/* 51 */ if (mode == GameMode.CREATIVE || mode == GameMode.SPECTATOR) {
/* */ return;
/* */ }
/* 54 */ e.setCancelled(true);
/* 55 */ player.setAllowFlight(false);
/* */
/* 57 */ player.setVelocity(player.getLocation().getDirection().multiply(0.5D).setY(0.5D));
/* */
/* 59 */ playersOnCoolDown.put(player.getPlayer().getUniqueId(), Long.valueOf((this.coolDownTime.intValue() * 1000) + System.currentTimeMillis()));
/* */
/* 61 */ (new BukkitRunnable()
/* */ {
/* */ public void run() {
/* 64 */ Jumper.playersOnCoolDown.remove(player.getPlayer().getUniqueId());
/* 65 */ player.sendMessage(ChatColor.translateAlternateColorCodes('&', Jumper.this.plugin.getConfig().getString("double-jump.cooldown-finish-message")));
/* */ }
/* 67 */ }).runTaskLater((Plugin)this.plugin, 20L * this.coolDownTime.intValue());
/* */ }
/* */
/* */
/* */ public void refresh() {
/* 72 */ this.coolDownTime = Integer.valueOf(this.plugin.getConfig().getInt("double-jump.cooldown"));
/* */ }
/* */ }
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class Jumper implements ConfigUser {
private static final Map<UUID, Long> playersOnCoolDown = new HashMap<>();
private final JavaPlugin plugin;
private Integer coolDownTime;
public Jumper(JavaPlugin plugin) {
this.plugin = plugin;
this.coolDownTime = Integer.valueOf(plugin.getConfig().getInt("double-jump.cooldown"));
}
/* 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\Jumper.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/
@EventHandler
private void onPlayerMove(PlayerMoveEvent e) {
Player player = e.getPlayer();
GameMode mode = player.getGameMode();
if (mode == GameMode.CREATIVE || mode == GameMode.SPECTATOR) {
return;
}
player.setAllowFlight(true);
if (playersOnCoolDown.containsKey(player.getUniqueId())) {
return;
}
}
@EventHandler
private void onFlightAccessChange(PlayerToggleFlightEvent e) {
final Player player = e.getPlayer();
GameMode mode = player.getGameMode();
if (mode == GameMode.CREATIVE || mode == GameMode.SPECTATOR) {
return;
}
player.setAllowFlight(false);
e.setCancelled(true);
player.setVelocity(player.getLocation().getDirection().multiply(0.5D).setY(0.5D));
playersOnCoolDown.put(player.getPlayer().getUniqueId(), Long.valueOf((this.coolDownTime.intValue() * 1000) + System.currentTimeMillis()));
(new BukkitRunnable() {
public void run() {
Jumper.playersOnCoolDown.remove(player.getPlayer().getUniqueId());
player.sendMessage(ChatColor.translateAlternateColorCodes('&', Jumper.this.plugin.getConfig().getString("double-jump.cooldown-finish-message")));
}
}).runTaskLater((Plugin) this.plugin, 20L * this.coolDownTime.intValue());
}
public void refresh() {
this.coolDownTime = Integer.valueOf(this.plugin.getConfig().getInt("double-jump.cooldown"));
}
}

View File

@ -3,6 +3,7 @@ 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.api.utils.InventoryEditConfigManager;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -11,8 +12,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class SpawnController
implements ConfigUser {
public class SpawnController implements ConfigUser {
private final JavaPlugin plugin;
public SpawnController(JavaPlugin plugin) {
@ -35,6 +35,11 @@ public class SpawnController
}
}
public void setSpawn(Location location) {
Spawn.setSpawn(location, plugin);
Spawn.setWorld(location.getWorld(), plugin);
}
public void refresh() {
Spawn.loadConfig(this.plugin);
}