mirror of
https://github.com/SimplexDevelopment/StrikePlugin.git
synced 2024-12-22 17:07:37 +00:00
Fixes
This commit is contained in:
parent
c8e83cae42
commit
51770dee82
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -3,11 +3,5 @@ package io.github.simplexdev.strike.api;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public interface ConfigUser extends Listener {
|
||||
void refresh();
|
||||
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
|
||||
*/
|
@ -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;
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package io.github.simplexdev.strike.api.utils;
|
||||
|
||||
public class InstanceStorage {
|
||||
|
||||
|
||||
|
||||
}
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
}
|
||||
|
@ -1,240 +1,234 @@
|
||||
package io.github.simplexdev.strike.api.utils;
|
||||
package io.github.simplexdev.strike.api.utils;
|
||||
|
||||
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;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.SkullType;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
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 {
|
||||
private static boolean warningPosted = false;
|
||||
private static Field blockProfileField;
|
||||
private static Method metaSetProfileMethod;
|
||||
private static Field metaProfileField;
|
||||
|
||||
public static ItemStack createSkull() {
|
||||
checkLegacy();
|
||||
|
||||
try {
|
||||
return new ItemStack(Material.valueOf("PLAYER_HEAD"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return new ItemStack(Material.valueOf("SKULL_ITEM"), 1, (short) 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack itemFromName(String name) {
|
||||
return itemWithName(createSkull(), name);
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack itemFromUuid(UUID id) {
|
||||
return itemWithUuid(createSkull(), id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class SkullCreator {
|
||||
private static boolean warningPosted = false;
|
||||
private static Field blockProfileField;
|
||||
private static Method metaSetProfileMethod;
|
||||
private static Field metaProfileField;
|
||||
|
||||
public static ItemStack createSkull() {
|
||||
checkLegacy();
|
||||
|
||||
try {
|
||||
return new ItemStack(Material.valueOf("PLAYER_HEAD"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return new ItemStack(Material.valueOf("SKULL_ITEM"), 1, (short) 3);
|
||||
}
|
||||
}
|
||||
public static ItemStack itemFromUrl(String url) {
|
||||
return itemWithUrl(createSkull(), url);
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack itemFromName(String name) {
|
||||
return itemWithName(createSkull(), name);
|
||||
}
|
||||
public static ItemStack itemFromBase64(String base64) {
|
||||
return itemWithBase64(createSkull(), base64);
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack itemFromUuid(UUID id) {
|
||||
return itemWithUuid(createSkull(), id);
|
||||
}
|
||||
@Deprecated
|
||||
public static ItemStack itemWithName(ItemStack item, String name) {
|
||||
notNull(item, "item");
|
||||
notNull(name, "name");
|
||||
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
meta.setOwner(name);
|
||||
item.setItemMeta((ItemMeta) meta);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack itemFromUrl(String url) {
|
||||
return itemWithUrl(createSkull(), url);
|
||||
}
|
||||
public static ItemStack itemWithUuid(ItemStack item, UUID id) {
|
||||
notNull(item, "item");
|
||||
notNull(id, "id");
|
||||
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
meta.setOwner(Bukkit.getOfflinePlayer(id).getName());
|
||||
item.setItemMeta((ItemMeta) meta);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack itemFromBase64(String base64) {
|
||||
return itemWithBase64(createSkull(), base64);
|
||||
}
|
||||
public static ItemStack itemWithUrl(ItemStack item, String url) {
|
||||
notNull(item, "item");
|
||||
notNull(url, "url");
|
||||
|
||||
return itemWithBase64(item, urlToBase64(url));
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public static ItemStack itemWithName(ItemStack item, String name) {
|
||||
notNull(item, "item");
|
||||
notNull(name, "name");
|
||||
public static ItemStack itemWithBase64(ItemStack item, String base64) {
|
||||
notNull(item, "item");
|
||||
notNull(base64, "base64");
|
||||
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
meta.setOwner(name);
|
||||
item.setItemMeta((ItemMeta) meta);
|
||||
if (!(item.getItemMeta() instanceof SkullMeta)) {
|
||||
return null;
|
||||
}
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
mutateItemMeta(meta, base64);
|
||||
item.setItemMeta((ItemMeta) meta);
|
||||
|
||||
return item;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack itemWithUuid(ItemStack item, UUID id) {
|
||||
notNull(item, "item");
|
||||
notNull(id, "id");
|
||||
@Deprecated
|
||||
public static void blockWithName(Block block, String name) {
|
||||
notNull(block, "block");
|
||||
notNull(name, "name");
|
||||
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
meta.setOwner(Bukkit.getOfflinePlayer(id).getName());
|
||||
item.setItemMeta((ItemMeta) meta);
|
||||
|
||||
return item;
|
||||
}
|
||||
Skull state = (Skull) block.getState();
|
||||
state.setOwner(name);
|
||||
state.update(false, false);
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack itemWithUrl(ItemStack item, String url) {
|
||||
notNull(item, "item");
|
||||
notNull(url, "url");
|
||||
public static void blockWithUuid(Block block, UUID id) {
|
||||
notNull(block, "block");
|
||||
notNull(id, "id");
|
||||
|
||||
return itemWithBase64(item, urlToBase64(url));
|
||||
}
|
||||
setToSkull(block);
|
||||
Skull state = (Skull) block.getState();
|
||||
state.setOwner(Bukkit.getOfflinePlayer(id).getName());
|
||||
state.update(false, false);
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack itemWithBase64(ItemStack item, String base64) {
|
||||
notNull(item, "item");
|
||||
notNull(base64, "base64");
|
||||
public static void blockWithUrl(Block block, String url) {
|
||||
notNull(block, "block");
|
||||
notNull(url, "url");
|
||||
|
||||
if (!(item.getItemMeta() instanceof SkullMeta)) {
|
||||
return null;
|
||||
}
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
mutateItemMeta(meta, base64);
|
||||
item.setItemMeta((ItemMeta) meta);
|
||||
|
||||
return item;
|
||||
}
|
||||
blockWithBase64(block, urlToBase64(url));
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public static void blockWithName(Block block, String name) {
|
||||
notNull(block, "block");
|
||||
notNull(name, "name");
|
||||
public static void blockWithBase64(Block block, String base64) {
|
||||
notNull(block, "block");
|
||||
notNull(base64, "base64");
|
||||
|
||||
Skull state = (Skull) block.getState();
|
||||
state.setOwner(name);
|
||||
state.update(false, false);
|
||||
}
|
||||
setToSkull(block);
|
||||
Skull state = (Skull) block.getState();
|
||||
mutateBlockState(state, base64);
|
||||
state.update(false, false);
|
||||
}
|
||||
|
||||
private static void setToSkull(Block block) {
|
||||
checkLegacy();
|
||||
|
||||
try {
|
||||
block.setType(Material.valueOf("PLAYER_HEAD"), false);
|
||||
} catch (IllegalArgumentException e) {
|
||||
block.setType(Material.valueOf("SKULL"), false);
|
||||
Skull state = (Skull) block.getState();
|
||||
state.setSkullType(SkullType.PLAYER);
|
||||
state.update(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
private static void notNull(Object o, String name) {
|
||||
if (o == null) {
|
||||
throw new NullPointerException(name + " should not be null!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void blockWithUuid(Block block, UUID id) {
|
||||
notNull(block, "block");
|
||||
notNull(id, "id");
|
||||
|
||||
setToSkull(block);
|
||||
Skull state = (Skull) block.getState();
|
||||
state.setOwner(Bukkit.getOfflinePlayer(id).getName());
|
||||
state.update(false, false);
|
||||
}
|
||||
private static String urlToBase64(String url) {
|
||||
URI actualUrl;
|
||||
try {
|
||||
actualUrl = new URI(url);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String toEncode = "{\"textures\":{\"SKIN\":{\"url\":\"" + actualUrl.toString() + "\"}}}";
|
||||
return Base64.getEncoder().encodeToString(toEncode.getBytes());
|
||||
}
|
||||
|
||||
|
||||
public static void blockWithUrl(Block block, String url) {
|
||||
notNull(block, "block");
|
||||
notNull(url, "url");
|
||||
private static GameProfile makeProfile(String b64) {
|
||||
UUID id = new UUID(b64.substring(b64.length() - 20).hashCode(), b64.substring(b64.length() - 10).hashCode());
|
||||
|
||||
blockWithBase64(block, urlToBase64(url));
|
||||
}
|
||||
GameProfile profile = new GameProfile(id, "aaaaa");
|
||||
profile.getProperties().put("textures", new Property("textures", b64));
|
||||
return profile;
|
||||
}
|
||||
|
||||
private static void mutateBlockState(Skull block, String b64) {
|
||||
try {
|
||||
if (blockProfileField == null) {
|
||||
blockProfileField = block.getClass().getDeclaredField("profile");
|
||||
blockProfileField.setAccessible(true);
|
||||
}
|
||||
blockProfileField.set(block, makeProfile(b64));
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void mutateItemMeta(SkullMeta meta, String b64) {
|
||||
try {
|
||||
if (metaSetProfileMethod == null) {
|
||||
metaSetProfileMethod = meta.getClass().getDeclaredMethod("setProfile", new Class[]{GameProfile.class});
|
||||
metaSetProfileMethod.setAccessible(true);
|
||||
}
|
||||
metaSetProfileMethod.invoke(meta, new Object[]{makeProfile(b64)});
|
||||
} catch (NoSuchMethodException | IllegalAccessException | java.lang.reflect.InvocationTargetException ex) {
|
||||
|
||||
|
||||
public static void blockWithBase64(Block block, String base64) {
|
||||
notNull(block, "block");
|
||||
notNull(base64, "base64");
|
||||
|
||||
setToSkull(block);
|
||||
Skull state = (Skull) block.getState();
|
||||
mutateBlockState(state, base64);
|
||||
state.update(false, false);
|
||||
}
|
||||
|
||||
private static void setToSkull(Block block) {
|
||||
checkLegacy();
|
||||
|
||||
try {
|
||||
block.setType(Material.valueOf("PLAYER_HEAD"), false);
|
||||
} catch (IllegalArgumentException e) {
|
||||
block.setType(Material.valueOf("SKULL"), false);
|
||||
Skull state = (Skull) block.getState();
|
||||
state.setSkullType(SkullType.PLAYER);
|
||||
state.update(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
private static void notNull(Object o, String name) {
|
||||
if (o == null) {
|
||||
throw new NullPointerException(name + " should not be null!");
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (metaProfileField == null) {
|
||||
metaProfileField = meta.getClass().getDeclaredField("profile");
|
||||
metaProfileField.setAccessible(true);
|
||||
}
|
||||
metaProfileField.set(meta, makeProfile(b64));
|
||||
} catch (NoSuchFieldException | IllegalAccessException ex2) {
|
||||
ex2.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static String urlToBase64(String url) {
|
||||
URI actualUrl;
|
||||
try {
|
||||
actualUrl = new URI(url);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
String toEncode = "{\"textures\":{\"SKIN\":{\"url\":\"" + actualUrl.toString() + "\"}}}";
|
||||
return Base64.getEncoder().encodeToString(toEncode.getBytes());
|
||||
}
|
||||
private static void checkLegacy() {
|
||||
try {
|
||||
Material.class.getDeclaredField("PLAYER_HEAD");
|
||||
Material.valueOf("SKULL");
|
||||
|
||||
|
||||
private static GameProfile makeProfile(String b64) {
|
||||
UUID id = new UUID(b64.substring(b64.length() - 20).hashCode(), b64.substring(b64.length() - 10).hashCode());
|
||||
|
||||
GameProfile profile = new GameProfile(id, "aaaaa");
|
||||
profile.getProperties().put("textures", new Property("textures", b64));
|
||||
return profile;
|
||||
}
|
||||
|
||||
private static void mutateBlockState(Skull block, String b64) {
|
||||
try {
|
||||
if (blockProfileField == null) {
|
||||
blockProfileField = block.getClass().getDeclaredField("profile");
|
||||
blockProfileField.setAccessible(true);
|
||||
}
|
||||
blockProfileField.set(block, makeProfile(b64));
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void mutateItemMeta(SkullMeta meta, String b64) {
|
||||
try {
|
||||
if (metaSetProfileMethod == null) {
|
||||
metaSetProfileMethod = meta.getClass().getDeclaredMethod("setProfile", new Class[]{GameProfile.class});
|
||||
metaSetProfileMethod.setAccessible(true);
|
||||
}
|
||||
metaSetProfileMethod.invoke(meta, new Object[]{makeProfile(b64)});
|
||||
} catch (NoSuchMethodException | IllegalAccessException | java.lang.reflect.InvocationTargetException ex) {
|
||||
|
||||
|
||||
try {
|
||||
if (metaProfileField == null) {
|
||||
metaProfileField = meta.getClass().getDeclaredField("profile");
|
||||
metaProfileField.setAccessible(true);
|
||||
}
|
||||
metaProfileField.set(meta, makeProfile(b64));
|
||||
} catch (NoSuchFieldException | IllegalAccessException ex2) {
|
||||
ex2.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void checkLegacy() {
|
||||
try {
|
||||
Material.class.getDeclaredField("PLAYER_HEAD");
|
||||
Material.valueOf("SKULL");
|
||||
|
||||
if (!warningPosted) {
|
||||
Bukkit.getLogger().warning("SKULLCREATOR API - Using the legacy bukkit API with 1.13+ bukkit versions is not supported!");
|
||||
warningPosted = true;
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalArgumentException noSuchFieldException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!warningPosted) {
|
||||
Bukkit.getLogger().warning("SKULLCREATOR API - Using the legacy bukkit API with 1.13+ bukkit versions is not supported!");
|
||||
warningPosted = true;
|
||||
}
|
||||
} catch (NoSuchFieldException | IllegalArgumentException noSuchFieldException) {
|
||||
}
|
||||
}
|
||||
}
|
@ -1,36 +1,33 @@
|
||||
package io.github.simplexdev.strike.events;
|
||||
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;
|
||||
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 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 GrenadeKillEvent(Player killer, Player dead) {
|
||||
this.killer = killer;
|
||||
this.dead = dead;
|
||||
}
|
||||
|
||||
public Player getKiller() {
|
||||
return this.killer;
|
||||
}
|
||||
public Player getKiller() {
|
||||
return this.killer;
|
||||
}
|
||||
|
||||
public Player getDead() {
|
||||
return dead;
|
||||
}
|
||||
public Player getDead() {
|
||||
return dead;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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")));
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user