mirror of
https://github.com/SimplexDevelopment/StrikePlugin.git
synced 2024-12-23 01:17:36 +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 io.github.simplexdev.strike.api.ConfigUser;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import io.github.simplexdev.strike.api.Spawn;
|
||||||
import io.github.simplexdev.strike.api.utils.InventoryEditConfigManager;
|
import io.github.simplexdev.strike.api.utils.InventoryEditConfigManager;
|
||||||
import io.github.simplexdev.strike.listeners.InventoryEditGUI;
|
import io.github.simplexdev.strike.listeners.InventoryEditGUI;
|
||||||
|
import io.github.simplexdev.strike.listeners.SpawnController;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -45,6 +47,11 @@ public class StrikeCommand implements CommandExecutor {
|
|||||||
player.getInventory().setContents(new InventoryEditConfigManager(plugin).getInventory(player));
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,15 @@
|
|||||||
package io.github.simplexdev.strike;
|
package io.github.simplexdev.strike;
|
||||||
|
|
||||||
import io.github.simplexdev.strike.api.Spawn;
|
import io.github.simplexdev.strike.api.Spawn;
|
||||||
import io.github.simplexdev.strike.api.utils.InventoryEditConfigManager;
|
|
||||||
import io.github.simplexdev.strike.listeners.*;
|
import io.github.simplexdev.strike.listeners.*;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
|
||||||
public final class StrikePlugin extends JavaPlugin {
|
public final class StrikePlugin extends JavaPlugin {
|
||||||
//TODO
|
//TODO
|
||||||
// Full Ammo after dead
|
|
||||||
// Fall Damage Disable
|
// Fall Damage Disable
|
||||||
// Health Pack head not working
|
// Bullet through Grass, Glass, Fence, Gates, Bars
|
||||||
// Bullet through Grass
|
|
||||||
// Ammo CHat Remove
|
|
||||||
// NPC Edit
|
// NPC Edit
|
||||||
// SetSpawn
|
|
||||||
// LaunchPad
|
// LaunchPad
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,11 +3,5 @@ package io.github.simplexdev.strike.api;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
public interface ConfigUser extends 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;
|
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;
|
|
||||||
/* */ }
|
|
||||||
/* */ }
|
|
||||||
|
|
||||||
|
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
|
import java.io.File;
|
||||||
* Java compiler version: 8 (52.0)
|
import java.io.IOException;
|
||||||
* JD-Core Version: 1.1.3
|
|
||||||
*/
|
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 io.github.simplexdev.strike.listeners.HealthPackage;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.MemorySection;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -14,7 +13,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class InventoryEditConfigManager {
|
public class InventoryEditConfigManager {
|
||||||
@ -106,6 +104,8 @@ public class InventoryEditConfigManager {
|
|||||||
return i;
|
return i;
|
||||||
|
|
||||||
return 0;
|
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.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
import java.lang.reflect.Field;
|
import org.bukkit.Bukkit;
|
||||||
import java.lang.reflect.Method;
|
import org.bukkit.Material;
|
||||||
import java.net.URI;
|
import org.bukkit.SkullType;
|
||||||
import java.net.URISyntaxException;
|
import org.bukkit.block.Block;
|
||||||
import java.util.Base64;
|
import org.bukkit.block.Skull;
|
||||||
import java.util.UUID;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
import org.bukkit.SkullType;
|
|
||||||
import org.bukkit.block.Block;
|
import java.lang.reflect.Field;
|
||||||
import org.bukkit.block.Skull;
|
import java.lang.reflect.Method;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import java.net.URI;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import java.net.URISyntaxException;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
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 static ItemStack itemFromUrl(String url) {
|
||||||
public class SkullCreator {
|
return itemWithUrl(createSkull(), url);
|
||||||
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) {
|
public static ItemStack itemFromBase64(String base64) {
|
||||||
return itemWithName(createSkull(), name);
|
return itemWithBase64(createSkull(), base64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ItemStack itemFromUuid(UUID id) {
|
@Deprecated
|
||||||
return itemWithUuid(createSkull(), id);
|
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) {
|
public static ItemStack itemWithUuid(ItemStack item, UUID id) {
|
||||||
return itemWithUrl(createSkull(), url);
|
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) {
|
public static ItemStack itemWithUrl(ItemStack item, String url) {
|
||||||
return itemWithBase64(createSkull(), base64);
|
notNull(item, "item");
|
||||||
}
|
notNull(url, "url");
|
||||||
|
|
||||||
|
return itemWithBase64(item, urlToBase64(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Deprecated
|
public static ItemStack itemWithBase64(ItemStack item, String base64) {
|
||||||
public static ItemStack itemWithName(ItemStack item, String name) {
|
notNull(item, "item");
|
||||||
notNull(item, "item");
|
notNull(base64, "base64");
|
||||||
notNull(name, "name");
|
|
||||||
|
|
||||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
if (!(item.getItemMeta() instanceof SkullMeta)) {
|
||||||
meta.setOwner(name);
|
return null;
|
||||||
item.setItemMeta((ItemMeta) meta);
|
}
|
||||||
|
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||||
|
mutateItemMeta(meta, base64);
|
||||||
|
item.setItemMeta((ItemMeta) meta);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ItemStack itemWithUuid(ItemStack item, UUID id) {
|
@Deprecated
|
||||||
notNull(item, "item");
|
public static void blockWithName(Block block, String name) {
|
||||||
notNull(id, "id");
|
notNull(block, "block");
|
||||||
|
notNull(name, "name");
|
||||||
|
|
||||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
Skull state = (Skull) block.getState();
|
||||||
meta.setOwner(Bukkit.getOfflinePlayer(id).getName());
|
state.setOwner(name);
|
||||||
item.setItemMeta((ItemMeta) meta);
|
state.update(false, false);
|
||||||
|
}
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static ItemStack itemWithUrl(ItemStack item, String url) {
|
public static void blockWithUuid(Block block, UUID id) {
|
||||||
notNull(item, "item");
|
notNull(block, "block");
|
||||||
notNull(url, "url");
|
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) {
|
public static void blockWithUrl(Block block, String url) {
|
||||||
notNull(item, "item");
|
notNull(block, "block");
|
||||||
notNull(base64, "base64");
|
notNull(url, "url");
|
||||||
|
|
||||||
if (!(item.getItemMeta() instanceof SkullMeta)) {
|
blockWithBase64(block, urlToBase64(url));
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
|
||||||
mutateItemMeta(meta, base64);
|
|
||||||
item.setItemMeta((ItemMeta) meta);
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Deprecated
|
public static void blockWithBase64(Block block, String base64) {
|
||||||
public static void blockWithName(Block block, String name) {
|
notNull(block, "block");
|
||||||
notNull(block, "block");
|
notNull(base64, "base64");
|
||||||
notNull(name, "name");
|
|
||||||
|
|
||||||
Skull state = (Skull) block.getState();
|
setToSkull(block);
|
||||||
state.setOwner(name);
|
Skull state = (Skull) block.getState();
|
||||||
state.update(false, false);
|
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) {
|
private static String urlToBase64(String url) {
|
||||||
notNull(block, "block");
|
URI actualUrl;
|
||||||
notNull(id, "id");
|
try {
|
||||||
|
actualUrl = new URI(url);
|
||||||
setToSkull(block);
|
} catch (URISyntaxException e) {
|
||||||
Skull state = (Skull) block.getState();
|
throw new RuntimeException(e);
|
||||||
state.setOwner(Bukkit.getOfflinePlayer(id).getName());
|
}
|
||||||
state.update(false, false);
|
String toEncode = "{\"textures\":{\"SKIN\":{\"url\":\"" + actualUrl.toString() + "\"}}}";
|
||||||
}
|
return Base64.getEncoder().encodeToString(toEncode.getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void blockWithUrl(Block block, String url) {
|
private static GameProfile makeProfile(String b64) {
|
||||||
notNull(block, "block");
|
UUID id = new UUID(b64.substring(b64.length() - 20).hashCode(), b64.substring(b64.length() - 10).hashCode());
|
||||||
notNull(url, "url");
|
|
||||||
|
|
||||||
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) {
|
try {
|
||||||
notNull(block, "block");
|
if (metaProfileField == null) {
|
||||||
notNull(base64, "base64");
|
metaProfileField = meta.getClass().getDeclaredField("profile");
|
||||||
|
metaProfileField.setAccessible(true);
|
||||||
setToSkull(block);
|
}
|
||||||
Skull state = (Skull) block.getState();
|
metaProfileField.set(meta, makeProfile(b64));
|
||||||
mutateBlockState(state, base64);
|
} catch (NoSuchFieldException | IllegalAccessException ex2) {
|
||||||
state.update(false, false);
|
ex2.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
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!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static String urlToBase64(String url) {
|
private static void checkLegacy() {
|
||||||
URI actualUrl;
|
try {
|
||||||
try {
|
Material.class.getDeclaredField("PLAYER_HEAD");
|
||||||
actualUrl = new URI(url);
|
Material.valueOf("SKULL");
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
String toEncode = "{\"textures\":{\"SKIN\":{\"url\":\"" + actualUrl.toString() + "\"}}}";
|
|
||||||
return Base64.getEncoder().encodeToString(toEncode.getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!warningPosted) {
|
||||||
private static GameProfile makeProfile(String b64) {
|
Bukkit.getLogger().warning("SKULLCREATOR API - Using the legacy bukkit API with 1.13+ bukkit versions is not supported!");
|
||||||
UUID id = new UUID(b64.substring(b64.length() - 20).hashCode(), b64.substring(b64.length() - 10).hashCode());
|
warningPosted = true;
|
||||||
|
}
|
||||||
GameProfile profile = new GameProfile(id, "aaaaa");
|
} catch (NoSuchFieldException | IllegalArgumentException noSuchFieldException) {
|
||||||
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) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +1,33 @@
|
|||||||
package io.github.simplexdev.strike.events;
|
package io.github.simplexdev.strike.events;
|
||||||
|
|
||||||
import java.util.List;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
public class GrenadeKillEvent
|
public class GrenadeKillEvent extends Event {
|
||||||
extends Event {
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private final Player killer;
|
||||||
private final Player killer;
|
private final Player dead;
|
||||||
private final Player dead;
|
|
||||||
|
|
||||||
public GrenadeKillEvent(Player killer, Player dead) {
|
public GrenadeKillEvent(Player killer, Player dead) {
|
||||||
this.killer = killer;
|
this.killer = killer;
|
||||||
this.dead = dead;
|
this.dead = dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getKiller() {
|
public Player getKiller() {
|
||||||
return this.killer;
|
return this.killer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getDead() {
|
public Player getDead() {
|
||||||
return dead;
|
return dead;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,42 +1,36 @@
|
|||||||
/* */ package io.github.simplexdev.strike.events;
|
package io.github.simplexdev.strike.events;
|
||||||
/* */
|
|
||||||
/* */ import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
/* */ import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
/* */ import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
/* */ import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
/* */
|
|
||||||
/* */ public class GunKillEvent
|
public class GunKillEvent extends Event {
|
||||||
/* */ extends Event {
|
private static final HandlerList handlers = new HandlerList();
|
||||||
/* 10 */ private static final HandlerList handlers = new HandlerList();
|
private final Player killer;
|
||||||
/* */ private final Player killer;
|
private final LivingEntity dead;
|
||||||
/* */ private final LivingEntity dead;
|
|
||||||
/* */
|
public GunKillEvent(Player killer, LivingEntity dead) {
|
||||||
/* */ public GunKillEvent(Player killer, LivingEntity dead) {
|
this.killer = killer;
|
||||||
/* 15 */ this.killer = killer;
|
this.dead = dead;
|
||||||
/* 16 */ this.dead = dead;
|
}
|
||||||
/* */ }
|
|
||||||
/* */
|
public Player getKiller() {
|
||||||
/* */ public Player getKiller() {
|
return this.killer;
|
||||||
/* 20 */ return this.killer;
|
}
|
||||||
/* */ }
|
|
||||||
/* */
|
public LivingEntity getDead() {
|
||||||
/* */ public LivingEntity getDead() {
|
return this.dead;
|
||||||
/* 24 */ return this.dead;
|
}
|
||||||
/* */ }
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
/* */ public HandlerList getHandlers() {
|
|
||||||
/* 29 */ return handlers;
|
|
||||||
/* */ }
|
|
||||||
/* */
|
|
||||||
/* */
|
|
||||||
/* */ public static HandlerList getHandlerList() {
|
|
||||||
/* 34 */ 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\GunKillEvent.class
|
public HandlerList getHandlers() {
|
||||||
* Java compiler version: 8 (52.0)
|
return handlers;
|
||||||
* JD-Core Version: 1.1.3
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -18,11 +19,14 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Gun implements ConfigUser {
|
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;
|
private final ItemStack gunItemStack;
|
||||||
|
|
||||||
@ -32,6 +36,38 @@ public class Gun implements ConfigUser {
|
|||||||
|
|
||||||
private int maxDistance;
|
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) {
|
public Gun(JavaPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -76,6 +112,12 @@ public class Gun implements ConfigUser {
|
|||||||
}).runTaskTimer((Plugin) this.plugin, 0L, 7L);
|
}).runTaskTimer((Plugin) this.plugin, 0L, 7L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
private void onDeath(PlayerDeathEvent e) {
|
||||||
|
if (ammoMap.containsKey(e.getEntity()))
|
||||||
|
ammoMap.replace(e.getEntity(), maxAmmo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onRightClick(PlayerInteractEvent e) {
|
private void onRightClick(PlayerInteractEvent e) {
|
||||||
@ -89,7 +131,7 @@ public class Gun implements ConfigUser {
|
|||||||
int ammo = this.maxAmmo;
|
int ammo = this.maxAmmo;
|
||||||
|
|
||||||
if (!ammoMap.containsKey(itemStack)) {
|
if (!ammoMap.containsKey(itemStack)) {
|
||||||
ammoMap.put(itemStack, Integer.valueOf(this.maxAmmo - 1));
|
ammoMap.put(player, Integer.valueOf(this.maxAmmo - 1));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ammo = ((Integer) ammoMap.get(itemStack)).intValue();
|
ammo = ((Integer) ammoMap.get(itemStack)).intValue();
|
||||||
@ -97,22 +139,20 @@ public class Gun implements ConfigUser {
|
|||||||
if (ammo == 1) {
|
if (ammo == 1) {
|
||||||
(new BukkitRunnable() {
|
(new BukkitRunnable() {
|
||||||
public void run() {
|
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"));
|
}).runTaskLater((Plugin) this.plugin, 20L * this.plugin.getConfig().getInt("gun.reload-time"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((Integer) ammoMap.get(itemStack)).intValue() != 0) {
|
if (((Integer) ammoMap.get(itemStack)).intValue() != 0) {
|
||||||
ammoMap.replace(itemStack, Integer.valueOf(ammo - 1));
|
ammoMap.replace(player, Integer.valueOf(ammo - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ammo <= 0) {
|
if (ammo <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.sendMessage(String.valueOf(ammo));
|
|
||||||
|
|
||||||
spawnParticle(player, player.getEyeLocation().clone(), 0.0D);
|
Entity entity = getEntity(player, player.getEyeLocation().clone(), 0.0D);
|
||||||
Entity entity = player.getTargetEntity(this.maxDistance);
|
|
||||||
|
|
||||||
if (!(entity instanceof LivingEntity)) {
|
if (!(entity instanceof LivingEntity)) {
|
||||||
return;
|
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();
|
World world = location.getWorld();
|
||||||
|
|
||||||
location.add(location.getDirection().multiply(0.1D));
|
location.add(location.getDirection().multiply(0.1D));
|
||||||
@ -136,15 +176,17 @@ public class Gun implements ConfigUser {
|
|||||||
|
|
||||||
distance += 0.1D;
|
distance += 0.1D;
|
||||||
|
|
||||||
if (location.getBlock().getType() != Material.AIR || distance > this.maxDistance) {
|
if (!passThroughBlocks.contains(location.getBlock().getType()) || distance > this.maxDistance) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
Collection<LivingEntity> entities = location.getNearbyLivingEntities(0.1D);
|
Collection<LivingEntity> entities = location.getNearbyLivingEntities(0.1D);
|
||||||
|
|
||||||
if (!entities.isEmpty() && entities.size() == 1 && !entities.contains(player)) {
|
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.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class HealthPackage
|
public class HealthPackage implements ConfigUser {
|
||||||
implements ConfigUser {
|
|
||||||
private final JavaPlugin plugin;
|
private final JavaPlugin plugin;
|
||||||
private ItemStack healthPackage;
|
private ItemStack healthPackage;
|
||||||
private String usedMessage;
|
private String usedMessage;
|
||||||
@ -56,7 +55,7 @@
|
|||||||
public ItemStack createItem() {
|
public ItemStack createItem() {
|
||||||
String base64 = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGExNTU4YTgzZjQwMjZkYjIzMmY4MGJjOTYxNWNjM2JhNDE1ZGM0MDk0MGE1YTEzYWUyYThjOTBiMTVjM2MzZSJ9fX0=";
|
String base64 = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGExNTU4YTgzZjQwMjZkYjIzMmY4MGJjOTYxNWNjM2JhNDE1ZGM0MDk0MGE1YTEzYWUyYThjOTBiMTVjM2MzZSJ9fX0=";
|
||||||
|
|
||||||
ItemStack healthPackage = SkullCreator.itemFromBase64(base64);
|
ItemStack healthPackage = SkullCreator.itemWithUrl(SkullCreator.createSkull(), base64);
|
||||||
ItemMeta meta = plugin.getServer().getItemFactory().getItemMeta(Material.PLAYER_HEAD);
|
ItemMeta meta = plugin.getServer().getItemFactory().getItemMeta(Material.PLAYER_HEAD);
|
||||||
|
|
||||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', this.plugin.getConfig().getString("health-package.name")));
|
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', this.plugin.getConfig().getString("health-package.name")));
|
||||||
|
@ -1,80 +1,75 @@
|
|||||||
/* */ package io.github.simplexdev.strike.listeners;
|
package io.github.simplexdev.strike.listeners;
|
||||||
/* */
|
|
||||||
/* */ import com.destroystokyo.paper.event.player.PlayerJumpEvent;
|
import com.destroystokyo.paper.event.player.PlayerJumpEvent;
|
||||||
/* */ import io.github.simplexdev.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.GameMode;
|
||||||
/* */ import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
/* */ import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
/* */ import org.bukkit.event.player.PlayerToggleFlightEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
/* */ import org.bukkit.plugin.Plugin;
|
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||||
/* */ import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
/* */ import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
/* */
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
/* */ public class Jumper implements ConfigUser
|
|
||||||
/* */ {
|
import java.util.HashMap;
|
||||||
/* 20 */ private static final Map<UUID, Long> playersOnCoolDown = new HashMap<>();
|
import java.util.Map;
|
||||||
/* */ private final JavaPlugin plugin;
|
import java.util.UUID;
|
||||||
/* */ private Integer coolDownTime;
|
|
||||||
/* */
|
public class Jumper implements ConfigUser {
|
||||||
/* */ public Jumper(JavaPlugin plugin) {
|
private static final Map<UUID, Long> playersOnCoolDown = new HashMap<>();
|
||||||
/* 25 */ this.plugin = plugin;
|
private final JavaPlugin plugin;
|
||||||
/* 26 */ this.coolDownTime = Integer.valueOf(plugin.getConfig().getInt("double-jump.cooldown"));
|
private Integer coolDownTime;
|
||||||
/* */ }
|
|
||||||
/* */
|
public Jumper(JavaPlugin plugin) {
|
||||||
/* */
|
this.plugin = plugin;
|
||||||
/* */
|
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"));
|
|
||||||
/* */ }
|
|
||||||
/* */ }
|
|
||||||
|
|
||||||
|
|
||||||
/* 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
|
@EventHandler
|
||||||
* Java compiler version: 8 (52.0)
|
private void onPlayerMove(PlayerMoveEvent e) {
|
||||||
* JD-Core Version: 1.1.3
|
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.ConfigUser;
|
||||||
import io.github.simplexdev.strike.api.Spawn;
|
import io.github.simplexdev.strike.api.Spawn;
|
||||||
import io.github.simplexdev.strike.api.utils.InventoryEditConfigManager;
|
import io.github.simplexdev.strike.api.utils.InventoryEditConfigManager;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -11,8 +12,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
|
||||||
public class SpawnController
|
public class SpawnController implements ConfigUser {
|
||||||
implements ConfigUser {
|
|
||||||
private final JavaPlugin plugin;
|
private final JavaPlugin plugin;
|
||||||
|
|
||||||
public SpawnController(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() {
|
public void refresh() {
|
||||||
Spawn.loadConfig(this.plugin);
|
Spawn.loadConfig(this.plugin);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user