Updated to ContextAware Alias.
This commit is contained in:
15
src/main/java/me/trouper/clonedupecore/CloneDupeContext.java
Normal file
15
src/main/java/me/trouper/clonedupecore/CloneDupeContext.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package me.trouper.clonedupecore;
|
||||
|
||||
import me.trouper.alias.server.ContextAware;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public interface CloneDupeContext extends ContextAware {
|
||||
@Override
|
||||
default Class<? extends JavaPlugin> getPluginClass() {
|
||||
return CloneDupeCore.class;
|
||||
}
|
||||
|
||||
default CloneDupeCore getInstance() {
|
||||
return CloneDupeCore.getInstance();
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,21 @@ package me.trouper.clonedupecore;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
|
||||
import me.trouper.alias.Alias;
|
||||
import me.trouper.clonedupecore.server.Manager;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import me.trouper.alias.AliasContext;
|
||||
import me.trouper.alias.AliasContextProvider;
|
||||
import me.trouper.alias.data.Common;
|
||||
import me.trouper.clonedupecore.data.IO;
|
||||
import me.trouper.clonedupecore.data.io.Config;
|
||||
import me.trouper.clonedupecore.server.systems.trims.TrimManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class CloneDupeCore extends JavaPlugin {
|
||||
public class CloneDupeCore extends JavaPlugin {
|
||||
|
||||
private static CloneDupeCore instance;
|
||||
private Manager manager;
|
||||
private IO io;
|
||||
private Common common;
|
||||
private AliasContext alias;
|
||||
private TrimManager trimManager;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
@@ -27,38 +33,70 @@ public final class CloneDupeCore extends JavaPlugin {
|
||||
getLogger().info("Initializing PacketEvents");
|
||||
PacketEvents.getAPI().init();
|
||||
|
||||
getLogger().info("Instantiating Manager");
|
||||
manager = new Manager(instance);
|
||||
getLogger().info("Initializing IO");
|
||||
|
||||
getLogger().info("Initializing Manager");
|
||||
manager.init();
|
||||
io = new IO(getDataFolder());
|
||||
|
||||
getLogger().info("Successfully enabled CloneDupeCore.");
|
||||
getLogger().info("Initializing Alias");
|
||||
common = new Common(getClass().getPackageName(), 0xFF00AA, 0xFFDDDD, "CloneDupeCore", "CloneDupe> ", false,
|
||||
"http://api.trouper.me:9090/download/plugins/CloneDupe/CloneDupeCore-1.0.0-all.jar");
|
||||
alias = new AliasContext(this, common);
|
||||
AliasContextProvider.registerContext(this, alias);
|
||||
|
||||
alias.initialize();
|
||||
io.loadAll();
|
||||
|
||||
updateCommon();
|
||||
cleanup();
|
||||
|
||||
trimManager = new TrimManager();
|
||||
trimManager.register();
|
||||
trimManager.startTicking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("Cleaning up...");
|
||||
manager.cleanup();
|
||||
getLogger().info("Saving all IO files.");
|
||||
manager.io.saveAll();
|
||||
|
||||
getLogger().info("Terminating PacketEventsAPI.");
|
||||
PacketEvents.getAPI().terminate();
|
||||
|
||||
cleanup();
|
||||
io.saveAll();
|
||||
|
||||
getLogger().info("Stopping Alias.");
|
||||
Alias.stop(getInstance(),getManager().common);
|
||||
alias.shutdown();
|
||||
}
|
||||
|
||||
public void updateCommon() {
|
||||
Config config = alias.getDataManager().get(Config.class);
|
||||
common.setMainColor(config.messages.mainColor);
|
||||
common.setSecondaryColor(config.messages.secondaryColor);
|
||||
common.setFlatPrefix(config.messages.flatPrefix);
|
||||
common.setPluginName(config.messages.pluginName);
|
||||
common.setDebugMode(config.debugMode);
|
||||
config.debuggerExclusions.forEach(common::addDebuggerExclusion);
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
alias.getDisplayManager().getBlockDisplayRaytracer().cleanup();
|
||||
}
|
||||
|
||||
public IO getIO() {
|
||||
return io;
|
||||
}
|
||||
|
||||
public Common getCommon() {
|
||||
return common;
|
||||
}
|
||||
|
||||
public AliasContext getAliasContext() {
|
||||
return alias;
|
||||
}
|
||||
|
||||
public TrimManager getTrimManager() {
|
||||
return trimManager;
|
||||
}
|
||||
|
||||
public static CloneDupeCore getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public NamespacedKey getNameSpace() {
|
||||
return new NamespacedKey(getInstance(),"clone_dupe_core");
|
||||
}
|
||||
|
||||
public Manager getManager() {
|
||||
return manager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
package me.trouper.clonedupecore.data;
|
||||
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import me.trouper.clonedupecore.CloneDupeCore;
|
||||
import me.trouper.clonedupecore.data.io.Config;
|
||||
import me.trouper.clonedupecore.data.io.NBTConfig;
|
||||
import me.trouper.clonedupecore.data.io.Storage;
|
||||
|
||||
public interface Data {
|
||||
|
||||
Data data = new Data() {};
|
||||
|
||||
public interface Data extends CloneDupeContext {
|
||||
default Config getConfig() {
|
||||
return CloneDupeCore.getInstance().getManager().io.config;
|
||||
return getDataManager().get(Config.class);
|
||||
}
|
||||
|
||||
default Storage getStorage() {
|
||||
return CloneDupeCore.getInstance().getManager().io.storage;
|
||||
return getDataManager().get(Storage.class);
|
||||
}
|
||||
|
||||
default NBTConfig getNBT() {
|
||||
return CloneDupeCore.getInstance().getManager().io.nbtConfig;
|
||||
return getDataManager().get(NBTConfig.class);
|
||||
}
|
||||
|
||||
default IO getIO() {
|
||||
return CloneDupeCore.getInstance().getManager().io;
|
||||
return CloneDupeCore.getInstance().getIO();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +1,36 @@
|
||||
package me.trouper.clonedupecore.data;
|
||||
|
||||
import me.trouper.alias.data.JsonSerializable;
|
||||
import me.trouper.clonedupecore.CloneDupeCore;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import me.trouper.clonedupecore.data.io.Config;
|
||||
import me.trouper.clonedupecore.data.io.NBTConfig;
|
||||
import me.trouper.clonedupecore.data.io.Storage;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class IO {
|
||||
public class IO implements CloneDupeContext {
|
||||
public final File DATA_FOLDER;
|
||||
public final File CONFIG_FILE;
|
||||
public final File STORAGE_FILE;
|
||||
public final File NBT_FILE;
|
||||
|
||||
public Config config;
|
||||
public Storage storage;
|
||||
public NBTConfig nbtConfig;
|
||||
|
||||
public IO(File dataFolder) {
|
||||
DATA_FOLDER = dataFolder;
|
||||
CONFIG_FILE = new File(DATA_FOLDER,"/config.json");
|
||||
STORAGE_FILE = new File(DATA_FOLDER, "/storage.json");
|
||||
NBT_FILE = new File(DATA_FOLDER, "/enchants.json");
|
||||
config = new Config();
|
||||
storage = new Storage();
|
||||
nbtConfig = new NBTConfig();
|
||||
}
|
||||
|
||||
public void loadAll() {
|
||||
CloneDupeCore.getInstance().getLogger().info("Loading all IO Files");
|
||||
config = JsonSerializable.load(CONFIG_FILE,Config.class,new Config());
|
||||
storage = JsonSerializable.load(STORAGE_FILE,Storage.class,new Storage());
|
||||
nbtConfig = JsonSerializable.load(NBT_FILE, NBTConfig.class,new NBTConfig());
|
||||
saveAll();
|
||||
getInstance().getLogger().info("Loading all IO Files");
|
||||
getDataManager().load(Config.class);
|
||||
getDataManager().load(Storage.class);
|
||||
getDataManager().load(NBTConfig.class);
|
||||
}
|
||||
|
||||
public void saveAll() {
|
||||
CloneDupeCore.getInstance().getLogger().info("Saving all IO Files");
|
||||
if (config == null) config = new Config();
|
||||
if (storage == null) storage = new Storage();
|
||||
if (nbtConfig == null) nbtConfig = new NBTConfig();
|
||||
config.save();
|
||||
storage.save();
|
||||
nbtConfig.save();
|
||||
getInstance().getLogger().info("Saving all IO Files");
|
||||
getDataManager().save(Config.class);
|
||||
getDataManager().save(Storage.class);
|
||||
getDataManager().save(NBTConfig.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package me.trouper.clonedupecore.data.io;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import me.trouper.alias.data.JsonSerializable;
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.clonedupecore.CloneDupeCore;
|
||||
import me.trouper.clonedupecore.data.SerialLocation;
|
||||
|
||||
@@ -17,7 +15,8 @@ public class Config implements JsonSerializable<Config> {
|
||||
|
||||
@Override
|
||||
public File getFile() {
|
||||
return CloneDupeCore.getInstance().getManager().io.CONFIG_FILE;
|
||||
return CloneDupeCore.getInstance().
|
||||
getIO().CONFIG_FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
public class NBTConfig implements JsonSerializable<NBTConfig> {
|
||||
@Override
|
||||
public File getFile() {
|
||||
return CloneDupeCore.getInstance().getManager().io.NBT_FILE;
|
||||
return CloneDupeCore.getInstance().getIO().NBT_FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,15 +4,13 @@ import me.trouper.alias.data.JsonSerializable;
|
||||
import me.trouper.clonedupecore.CloneDupeCore;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class Storage implements JsonSerializable<Storage> {
|
||||
@Override
|
||||
public File getFile() {
|
||||
return CloneDupeCore.getInstance().getManager().io.STORAGE_FILE;
|
||||
return CloneDupeCore.getInstance().getIO().STORAGE_FILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
package me.trouper.clonedupecore.server;
|
||||
|
||||
import me.trouper.alias.Alias;
|
||||
import me.trouper.alias.data.Common;
|
||||
import me.trouper.alias.server.systems.tracing.BlockDisplayRaytracer;
|
||||
import me.trouper.clonedupecore.CloneDupeCore;
|
||||
import me.trouper.clonedupecore.data.IO;
|
||||
import me.trouper.clonedupecore.server.trims.TrimManager;
|
||||
import me.trouper.clonedupecore.server.trims.animations.*;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Manager {
|
||||
|
||||
public IO io;
|
||||
public Common common;
|
||||
public TrimManager trimManager;
|
||||
|
||||
public Manager(JavaPlugin instance) {
|
||||
io = new IO(instance.getDataFolder());
|
||||
common = new Common(instance.getClass().getPackageName(),0xFF00AA,0xFFDDDD,"CloneDupeCore","CloneDupe> ",false,"http://api.trouper.me:9090/download/plugins/CloneDupe/CloneDupeCore-1.0.0-all.jar");
|
||||
trimManager = new TrimManager();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
io.loadAll();
|
||||
|
||||
setCommon();
|
||||
|
||||
Alias.register(CloneDupeCore.getInstance(),common);
|
||||
cleanup();
|
||||
|
||||
trimManager.register(new AmethystAnimation());
|
||||
trimManager.register(new AmethystAnimation());
|
||||
trimManager.register(new CopperAnimation());
|
||||
trimManager.register(new DiamondAnimation());
|
||||
trimManager.register(new EmeraldAnimation());
|
||||
trimManager.register(new GoldAnimation());
|
||||
trimManager.register(new IronAnimation());
|
||||
trimManager.register(new LapisAnimation());
|
||||
trimManager.register(new NetheriteAnimation());
|
||||
trimManager.register(new QuartzAnimation());
|
||||
trimManager.register(new RedstoneAnimation());
|
||||
trimManager.register();
|
||||
trimManager.startTicking();
|
||||
}
|
||||
|
||||
public void setCommon() {
|
||||
common.setMainColor(io.config.messages.mainColor);
|
||||
common.setSecondaryColor(io.config.messages.secondaryColor);
|
||||
common.setFlatPrefix(io.config.messages.flatPrefix);
|
||||
common.setPluginName(io.config.messages.pluginName);
|
||||
common.setDebugMode(io.config.debugMode);
|
||||
io.config.debuggerExclusions.forEach(exclusion -> common.addDebuggerExclusion(exclusion));
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
BlockDisplayRaytracer.cleanup();
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,11 @@ import me.trouper.alias.server.commands.CommandRegistry;
|
||||
import me.trouper.alias.server.commands.Permission;
|
||||
import me.trouper.alias.server.commands.QuickCommand;
|
||||
import me.trouper.alias.server.commands.completions.CompletionBuilder;
|
||||
import me.trouper.alias.server.systems.Text;
|
||||
import me.trouper.alias.server.systems.tracing.BlockDisplayRaytracer;
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.alias.update.AutoUpdater;
|
||||
import me.trouper.alias.utils.FormatUtils;
|
||||
import me.trouper.alias.utils.SoundPlayer;
|
||||
import me.trouper.clonedupecore.CloneDupeCore;
|
||||
import me.trouper.clonedupecore.data.Data;
|
||||
import me.trouper.clonedupecore.server.trims.ValidArmorType;
|
||||
import me.trouper.clonedupecore.server.trims.ValidMaterial;
|
||||
import me.trouper.clonedupecore.server.systems.trims.ValidArmorType;
|
||||
import me.trouper.clonedupecore.server.systems.trims.ValidMaterial;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -80,8 +75,8 @@ public class AdminCommand implements QuickCommand, Data {
|
||||
|
||||
private void handleUpdate(CommandSender sender, Args args) {
|
||||
infoAny(sender,"Checking for an update...");
|
||||
Bukkit.getScheduler().runTask(main.getPlugin(),()->{
|
||||
if (AutoUpdater.checkUpdate(main.getPlugin(),main.getCommon())) {
|
||||
Bukkit.getScheduler().runTask(getPlugin(),()->{
|
||||
if (getContext().getAutoUpdater().checkUpdate()) {
|
||||
successAny(sender,"Updated plugin has been downloaded to {0}.","plugins/update");
|
||||
} else {
|
||||
successAny(sender,"Plugin is up-to-date!");
|
||||
@@ -92,12 +87,12 @@ public class AdminCommand implements QuickCommand, Data {
|
||||
|
||||
private void handleCleanup(CommandSender sender, Args args) {
|
||||
infoAny(sender,"Cleaning up temporary entities on all loaded worlds.");
|
||||
Bukkit.getScheduler().runTask(main.getPlugin(),()->{
|
||||
Bukkit.getScheduler().runTask(getPlugin(),()->{
|
||||
int count = 0;
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
for (Chunk chunk : world.getLoadedChunks()) {
|
||||
for (Entity entity : chunk.getEntities()) {
|
||||
if (entity.getScoreboardTags().contains(main.getCommon().getTempTag())) {
|
||||
if (entity.getScoreboardTags().contains(getCommon().getTempTag())) {
|
||||
entity.remove();
|
||||
count++;
|
||||
}
|
||||
@@ -112,7 +107,7 @@ public class AdminCommand implements QuickCommand, Data {
|
||||
private void handleReload(CommandSender sender, Args args) {
|
||||
successAny(sender,"Reloading IO and common...");
|
||||
getIO().loadAll();
|
||||
CloneDupeCore.getInstance().getManager().setCommon();
|
||||
getInstance().updateCommon();
|
||||
}
|
||||
|
||||
private void handleTrim(CommandSender sender, Args args) {
|
||||
@@ -125,15 +120,15 @@ public class AdminCommand implements QuickCommand, Data {
|
||||
return;
|
||||
}
|
||||
|
||||
ValidMaterial validMaterial = main.randomizer().getRandomElement(ValidMaterial.values());
|
||||
ValidArmorType validArmorType = main.randomizer().getRandomElement(ValidArmorType.values());
|
||||
ValidMaterial validMaterial = randomizer().getRandomElement(ValidMaterial.values());
|
||||
ValidArmorType validArmorType = randomizer().getRandomElement(ValidArmorType.values());
|
||||
if (args.getSize() >= 2) validMaterial = args.get(1).toEnum(ValidMaterial.class);
|
||||
if (args.getSize() >= 3) validArmorType = args.get(2).toEnum(ValidArmorType.class);
|
||||
|
||||
TrimPattern pattern = TrimPattern.SILENCE;
|
||||
TrimMaterial material = validMaterial.getCanonical();
|
||||
|
||||
if (material == null) material = main.randomizer().getRandomElement(ValidMaterial.values()).getCanonical();
|
||||
if (material == null) material = randomizer().getRandomElement(ValidMaterial.values()).getCanonical();
|
||||
|
||||
p.getEquipment().setHelmet(createTestArmor(new ItemStack(validArmorType.getHelmet()),pattern,material));
|
||||
p.getEquipment().setChestplate(createTestArmor(new ItemStack(validArmorType.getChestplate()),pattern,material));
|
||||
@@ -142,15 +137,15 @@ public class AdminCommand implements QuickCommand, Data {
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
double finalI = i;
|
||||
Bukkit.getScheduler().runTaskLater(main.getPlugin(),()->{
|
||||
DisplayUtils.ring(p.getLocation().clone().add(0, finalI / 5D,0),0.5, Color.RED,0.5F);
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(),()->{
|
||||
getContext().getDisplayManager().getPatterns().ring(p.getLocation().clone().add(0, finalI / 5D,0),0.5, Color.RED,0.5F);
|
||||
},i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
double finalI = i;
|
||||
Bukkit.getScheduler().runTaskLater(main.getPlugin(),()->{
|
||||
DisplayUtils.ring(p.getLocation().clone().add(0,2,0).subtract(0,finalI / 5D,0),0.5,Color.RED,0.5F);
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(),()->{
|
||||
getContext().getDisplayManager().getPatterns().ring(p.getLocation().clone().add(0,2,0).subtract(0,finalI / 5D,0),0.5,Color.RED,0.5F);
|
||||
},10 + i);
|
||||
}
|
||||
|
||||
@@ -165,12 +160,12 @@ public class AdminCommand implements QuickCommand, Data {
|
||||
throw new IllegalArgumentException("You must input armor ONLY");
|
||||
}
|
||||
|
||||
armor.displayName(Text.color("&eTesting Armor").decoration(TextDecoration.ITALIC,false));
|
||||
armor.displayName(getTextSystem().color("&eTesting Armor").decoration(TextDecoration.ITALIC,false));
|
||||
armor.lore(List.of(
|
||||
Text.color("&8&l| &7%s".formatted(FormatUtils.formatEnum(ValidMaterial.validate(trimMaterial)))).decoration(TextDecoration.ITALIC,false),
|
||||
Text.color("&8&l| &7Won't Break").decoration(TextDecoration.ITALIC,false),
|
||||
Text.color("&8&l| &7Vanishes on death").decoration(TextDecoration.ITALIC,false),
|
||||
Text.color("&8&l| &7This armor is for testing purposes &c&lONLY&7!").decoration(TextDecoration.ITALIC,false)
|
||||
getTextSystem().color("&8&l| &7%s".formatted(FormatUtils.formatEnum(ValidMaterial.validate(trimMaterial)))).decoration(TextDecoration.ITALIC,false),
|
||||
getTextSystem().color("&8&l| &7Won't Break").decoration(TextDecoration.ITALIC,false),
|
||||
getTextSystem().color("&8&l| &7Vanishes on death").decoration(TextDecoration.ITALIC,false),
|
||||
getTextSystem().color("&8&l| &7This armor is for testing purposes &c&lONLY&7!").decoration(TextDecoration.ITALIC,false)
|
||||
));
|
||||
armor.addEnchant(Enchantment.VANISHING_CURSE,1,true);
|
||||
armor.addEnchant(Enchantment.PROTECTION, 4, true);
|
||||
@@ -199,7 +194,7 @@ public class AdminCommand implements QuickCommand, Data {
|
||||
getConfig().debugMode = result = !getConfig().debugMode;
|
||||
getConfig().save();
|
||||
|
||||
CloneDupeCore.getInstance().getManager().common.setDebugMode(result);
|
||||
getInstance().updateCommon();
|
||||
|
||||
successAny(sender,"Toggled debug mode {0}.",result ? "on" : "off");
|
||||
}
|
||||
@@ -212,7 +207,7 @@ public class AdminCommand implements QuickCommand, Data {
|
||||
getConfig().debuggerExclusions.add(exclusion);
|
||||
getConfig().save();
|
||||
|
||||
CloneDupeCore.getInstance().getManager().common.addDebuggerExclusion(exclusion);
|
||||
getInstance().updateCommon();
|
||||
|
||||
successAny(sender, "Excluded {0} from the debugger.", exclusion);
|
||||
}
|
||||
@@ -225,7 +220,7 @@ public class AdminCommand implements QuickCommand, Data {
|
||||
getConfig().debuggerExclusions.remove(exclusion);
|
||||
getConfig().save();
|
||||
|
||||
CloneDupeCore.getInstance().getManager().common.removeDebuggerExclusion(exclusion);
|
||||
getInstance().updateCommon();
|
||||
|
||||
successAny(sender, "Removed exclusion for {0} on the debugger.", exclusion);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ import me.trouper.alias.server.commands.Permission;
|
||||
import me.trouper.alias.server.commands.QuickCommand;
|
||||
import me.trouper.alias.server.commands.completions.CompletionBuilder;
|
||||
import me.trouper.alias.server.systems.Text;
|
||||
import me.trouper.alias.server.systems.freeze.FreezeSession;
|
||||
import me.trouper.alias.utils.SoundPlayer;
|
||||
import me.trouper.clonedupecore.data.Data;
|
||||
import me.trouper.clonedupecore.data.SerialLocation;
|
||||
import me.trouper.clonedupecore.server.punishment.Freeze;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.title.Title;
|
||||
@@ -22,6 +22,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.HashSet;
|
||||
|
||||
@CommandRegistry(
|
||||
value = "freeze",
|
||||
@@ -44,16 +45,9 @@ public class FreezeCommand implements QuickCommand, Data {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean frozen = Freeze.getFrozen().containsKey(target.getUniqueId()) || "unfreeze".equals(label) || "unscreenshare".equals(label);
|
||||
boolean frozen = getContext().getFreezeManager().isFrozen(target.getUniqueId()) || "unfreeze".equals(label) || "unscreenshare".equals(label);
|
||||
if (frozen) {
|
||||
Freeze.thawPlayer(target.getUniqueId());
|
||||
infoAny(sender,"Completed ScreenShare/Freeze on {0}.",target.name());
|
||||
infoAny(target,"You have been released!");
|
||||
target.showTitle(Title.title(
|
||||
Text.format(Text.Pallet.SUCCESS,"Screenshare Complete!").decorate(TextDecoration.BOLD),
|
||||
Text.format(Text.Pallet.INFO,"Thank you for your cooperation."),
|
||||
Title.Times.times(Duration.ZERO,Duration.of(3, ChronoUnit.SECONDS),Duration.ZERO)
|
||||
));
|
||||
getContext().getFreezeManager().getSession(target.getUniqueId()).thaw();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,12 +71,12 @@ public class FreezeCommand implements QuickCommand, Data {
|
||||
}
|
||||
|
||||
Title attemptTitle = Title.title(
|
||||
Text.format(Text.Pallet.ERROR,"You are being Screenshared!").decorate(TextDecoration.BOLD),
|
||||
Text.format(Text.Pallet.INFO,"Join the {0} VC using {1}!","'ScreenShare'", "/discord"),
|
||||
getTextSystem().format(Text.Pallet.ERROR,"You are being Screenshared!").decorate(TextDecoration.BOLD),
|
||||
getTextSystem().format(Text.Pallet.INFO,"Join the {0} VC using {1}!","'ScreenShare'", "/discord"),
|
||||
Title.Times.times(Duration.ZERO,Duration.of(10, ChronoUnit.SECONDS),Duration.ZERO)
|
||||
);
|
||||
|
||||
Component attemptMessage = Text.color("""
|
||||
Component attemptMessage = getTextSystem().color("""
|
||||
&cLeaving before or during a ScreenShare results in:
|
||||
&f➤ 1st Offense: 7d ban
|
||||
&f➤ 2nd Offense: 14d ban
|
||||
@@ -91,19 +85,35 @@ public class FreezeCommand implements QuickCommand, Data {
|
||||
&cYou Have &l5 Minutes&r&c To Join '&4ScreenShare&c' VC.
|
||||
""");
|
||||
|
||||
Freeze.FrozenPlayer fp = new Freeze.FrozenPlayer(target.getUniqueId(), target.getLocation().clone(), (player)->{
|
||||
Freeze.thawPlayer(target.getUniqueId());
|
||||
getConfig().freezeCommandsOnQuit.forEach(cmd -> Bukkit.dispatchCommand(sender,cmd.replace("{0}",player.getName())));
|
||||
infoAny(sender,"{0} left while being Screenshared/Frozen, and has been punished as a result.",target.name());
|
||||
}, (player)->{
|
||||
player.showTitle(attemptTitle);
|
||||
player.sendMessage(attemptMessage);
|
||||
SoundPlayer.play(player, Sound.BLOCK_NOTE_BLOCK_BASS);
|
||||
});
|
||||
Title thawTitle = Title.title(
|
||||
getTextSystem().format(Text.Pallet.SUCCESS,"Screenshare Complete!").decorate(TextDecoration.BOLD),
|
||||
getTextSystem().format(Text.Pallet.INFO,"Thank you for your cooperation."),
|
||||
Title.Times.times(Duration.ZERO,Duration.of(3, ChronoUnit.SECONDS),Duration.ZERO)
|
||||
);
|
||||
|
||||
target.teleport(freezeLoc);
|
||||
Location finalFreezeLoc = freezeLoc;
|
||||
FreezeSession freeze = new FreezeSession.Builder(getContext(),target.getUniqueId(),target.getLocation())
|
||||
.onStart(()->{
|
||||
target.teleport(finalFreezeLoc);
|
||||
})
|
||||
.onMove(player -> {
|
||||
player.showTitle(attemptTitle);
|
||||
player.sendMessage(attemptMessage);
|
||||
SoundPlayer.play(player, Sound.BLOCK_NOTE_BLOCK_BASS);
|
||||
})
|
||||
.onQuit((player -> {
|
||||
getConfig().freezeCommandsOnQuit.forEach(cmd -> Bukkit.dispatchCommand(sender,cmd.replace("{0}",player.getName())));
|
||||
infoAny(sender,"{0} left while being Screenshared/Frozen, and has been punished as a result.",target.name());
|
||||
}))
|
||||
.onThaw(()->{
|
||||
infoAny(sender,"Completed ScreenShare/Freeze on {0}.",target.name());
|
||||
infoAny(target,"You have been released!");
|
||||
target.showTitle(thawTitle);
|
||||
})
|
||||
.allowCommands(new HashSet<>(getConfig().allowedFreezeCommands))
|
||||
.build();
|
||||
|
||||
Freeze.freezePlayer(fp);
|
||||
freeze.start();
|
||||
}
|
||||
|
||||
private void handleLocationUpdate(CommandSender sender) {
|
||||
|
||||
@@ -4,17 +4,18 @@ import club.minnced.discord.webhook.WebhookClient;
|
||||
import club.minnced.discord.webhook.WebhookClientBuilder;
|
||||
import club.minnced.discord.webhook.send.WebhookEmbed;
|
||||
import club.minnced.discord.webhook.send.WebhookEmbedBuilder;
|
||||
import me.trouper.alias.server.commands.*;
|
||||
import me.trouper.alias.server.commands.Args;
|
||||
import me.trouper.alias.server.commands.CommandRegistry;
|
||||
import me.trouper.alias.server.commands.Permission;
|
||||
import me.trouper.alias.server.commands.QuickCommandListener;
|
||||
import me.trouper.alias.server.commands.completions.CompletionBuilder;
|
||||
import me.trouper.alias.server.events.QuickListener;
|
||||
import me.trouper.alias.server.systems.Text;
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.alias.utils.misc.ArrayUtils;
|
||||
import me.trouper.alias.utils.misc.TimeUtils;
|
||||
import me.trouper.clonedupecore.data.Data;
|
||||
import me.trouper.clonedupecore.server.punishment.LiteBansManager;
|
||||
import me.trouper.clonedupecore.server.punishment.WrappedEntry;
|
||||
import me.trouper.clonedupecore.server.punishment.animations.*;
|
||||
import me.trouper.clonedupecore.server.systems.punishment.LiteBansManager;
|
||||
import me.trouper.clonedupecore.server.systems.punishment.WrappedEntry;
|
||||
import me.trouper.clonedupecore.server.systems.punishment.animations.*;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -24,8 +25,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.awt.desktop.QuitEvent;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -66,7 +65,7 @@ public class OffendCommand implements QuickCommandListener, Data {
|
||||
String.join(", ", getConfig().banTemplates));
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(main.getPlugin(), ()->{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), ()->{
|
||||
handlePunish(sender, target, template);
|
||||
});
|
||||
}
|
||||
@@ -86,7 +85,7 @@ public class OffendCommand implements QuickCommandListener, Data {
|
||||
@EventHandler
|
||||
public void onDisconnect(PlayerQuitEvent e) {
|
||||
recentlyDisconnected.add(e.getPlayer().getName());
|
||||
Bukkit.getScheduler().runTaskLater(main.getPlugin(),()->{
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(),()->{
|
||||
recentlyDisconnected.remove(e.getPlayer().getName());
|
||||
},20*120);
|
||||
}
|
||||
@@ -95,18 +94,18 @@ public class OffendCommand implements QuickCommandListener, Data {
|
||||
if (template == null) {
|
||||
List<WrappedEntry> allBans = liteBansManager.getPlayerBans(target);
|
||||
|
||||
Component historyMessage = Text.format(Text.Pallet.INFO, "All bans for {0}: ", target.getName())
|
||||
Component historyMessage = getTextSystem().format(Text.Pallet.INFO, "All bans for {0}: ", target.getName())
|
||||
.appendNewline();
|
||||
|
||||
if (allBans.isEmpty()) {
|
||||
historyMessage = historyMessage.append(Text.format(Text.Pallet.LOCATION, "No bans found."));
|
||||
historyMessage = historyMessage.append(getTextSystem().format(Text.Pallet.LOCATION, "No bans found."));
|
||||
} else {
|
||||
for (WrappedEntry ban : allBans) {
|
||||
String status = ban.isActive() ? "Active" : "Expired/Unbanned";
|
||||
String duration = ban.isPermanent() ? "Permanent" : TimeUtils.formatTime(ban.getDateEnd());
|
||||
|
||||
historyMessage = historyMessage
|
||||
.append(Text.format(Text.Pallet.LOCATION,
|
||||
.append(getTextSystem().format(Text.Pallet.LOCATION,
|
||||
"{0} - {1} - {2} - {3}",
|
||||
TimeUtils.formatTime(ban.getDateStart()),
|
||||
ban.getReason(),
|
||||
@@ -123,18 +122,18 @@ public class OffendCommand implements QuickCommandListener, Data {
|
||||
short index = (short) getConfig().banTemplates.indexOf(template);
|
||||
List<WrappedEntry> templateBans = liteBansManager.getPlayerBansByTemplate(target, index);
|
||||
|
||||
Component historyMessage = Text.format(Text.Pallet.INFO,
|
||||
Component historyMessage = getTextSystem().format(Text.Pallet.INFO,
|
||||
"{0} template bans for {1}: ", template, target.getName()).appendNewline();
|
||||
|
||||
if (templateBans.isEmpty()) {
|
||||
historyMessage = historyMessage.append(Text.format(Text.Pallet.LOCATION, "No bans found for this template."));
|
||||
historyMessage = historyMessage.append(getTextSystem().format(Text.Pallet.LOCATION, "No bans found for this template."));
|
||||
} else {
|
||||
for (WrappedEntry ban : templateBans) {
|
||||
String status = ban.isActive() ? "Active" : "Expired/Unbanned";
|
||||
String duration = ban.isPermanent() ? "Permanent" : TimeUtils.formatTime(ban.getDateEnd());
|
||||
|
||||
historyMessage = historyMessage
|
||||
.append(Text.format(Text.Pallet.LOCATION,
|
||||
.append(getTextSystem().format(Text.Pallet.LOCATION,
|
||||
"{0} - {1} - {2}",
|
||||
TimeUtils.formatTime(ban.getDateStart()),
|
||||
duration,
|
||||
@@ -150,7 +149,7 @@ public class OffendCommand implements QuickCommandListener, Data {
|
||||
if (liteBansManager.isPlayerBanned(target)) {
|
||||
WrappedEntry activeBan = liteBansManager.getActiveBan(target);
|
||||
if (activeBan != null) {
|
||||
sender.sendMessage(Text.format(Text.Pallet.ERROR,
|
||||
sender.sendMessage(getTextSystem().format(Text.Pallet.ERROR,
|
||||
"{0} is already banned for: {1}", target.getName(), activeBan.getReason()));
|
||||
return;
|
||||
}
|
||||
@@ -159,12 +158,12 @@ public class OffendCommand implements QuickCommandListener, Data {
|
||||
short index = (short) getConfig().banTemplates.indexOf(template);
|
||||
int currentBans = liteBansManager.getBanCountByTemplate(target, index);
|
||||
|
||||
sender.sendMessage(Text.format(Text.Pallet.INFO,
|
||||
sender.sendMessage(getTextSystem().format(Text.Pallet.INFO,
|
||||
"Executing ban for {0} using template {1} (Previous offenses: {2})",
|
||||
target.getName(), template, currentBans));
|
||||
|
||||
Runnable banPlayer = () -> {
|
||||
Verbose.send("Executing ban due to animation finishing.");
|
||||
getVerbose().send("Executing ban due to animation finishing.");
|
||||
liteBansManager.executeBan(target, template, sender);
|
||||
|
||||
WebhookClientBuilder builder = new WebhookClientBuilder(getConfig().banWebhook);
|
||||
@@ -177,16 +176,16 @@ public class OffendCommand implements QuickCommandListener, Data {
|
||||
c.send(embedBuilder.build());
|
||||
}
|
||||
|
||||
sender.sendMessage(Text.format(Text.Pallet.SUCCESS, "Successfully banned {0} using template {1}", target.getName(), template));
|
||||
sender.sendMessage(getTextSystem().format(Text.Pallet.SUCCESS, "Successfully banned {0} using template {1}", target.getName(), template));
|
||||
};
|
||||
|
||||
Verbose.send("Banning with animation...");
|
||||
PunishmentAnimation animation = main.randomizer().getRandomElement(ANIMATION_FACTORIES).create(main.getPlugin(), target.getPlayer(), banPlayer);
|
||||
getVerbose().send("Banning with animation...");
|
||||
PunishmentAnimation animation = randomizer().getRandomElement(ANIMATION_FACTORIES).create(getPlugin(), target.getPlayer(), banPlayer);
|
||||
|
||||
try {
|
||||
animation.run();
|
||||
} catch (Exception e) {
|
||||
Verbose.send("Animation generated an exception before it could run! Banning player...");
|
||||
getVerbose().send("Animation generated an exception before it could run! Banning player...");
|
||||
e.printStackTrace();
|
||||
banPlayer.run();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import me.trouper.alias.server.commands.CommandRegistry;
|
||||
import me.trouper.alias.server.commands.Permission;
|
||||
import me.trouper.alias.server.commands.QuickCommand;
|
||||
import me.trouper.alias.server.commands.completions.CompletionBuilder;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
@@ -15,7 +16,7 @@ import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandRegistry(value = "ping", permission = @Permission("clonedupe.ping"),printStackTrace = true)
|
||||
public class PingCommand implements QuickCommand {
|
||||
public class PingCommand implements QuickCommand, CloneDupeContext {
|
||||
|
||||
@Override
|
||||
public void handleCommand(CommandSender sender, Command command, String label, Args args) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import me.trouper.alias.server.commands.CommandRegistry;
|
||||
import me.trouper.alias.server.commands.Permission;
|
||||
import me.trouper.alias.server.commands.QuickCommand;
|
||||
import me.trouper.alias.server.commands.completions.CompletionBuilder;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Statistic;
|
||||
@@ -12,15 +13,14 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@CommandRegistry(
|
||||
value = "statedit",
|
||||
permission = @Permission("clonedupe.statedit"),
|
||||
usage = "/statedit <player> <statistic> <add|subtract|set|get> [value]",
|
||||
printStackTrace = true
|
||||
)
|
||||
public class StatisticsCommand implements QuickCommand {
|
||||
public class StatisticsCommand implements QuickCommand, CloneDupeContext {
|
||||
|
||||
@Override
|
||||
public void handleCommand(CommandSender sender, Command command, String label, Args args) {
|
||||
if (args.getSize() < 3) {
|
||||
@@ -91,4 +91,5 @@ public class StatisticsCommand implements QuickCommand {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import me.trouper.alias.server.commands.Args;
|
||||
import me.trouper.alias.server.commands.CommandRegistry;
|
||||
import me.trouper.alias.server.commands.QuickCommand;
|
||||
import me.trouper.alias.server.commands.completions.CompletionBuilder;
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.clonedupecore.data.Data;
|
||||
import me.trouper.clonedupecore.server.gui.TrimEffectGui;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -55,4 +54,5 @@ public class TrimCommand implements QuickCommand, Data {
|
||||
public void handleCompletion(CommandSender commandSender, Command command, String s, Args args, CompletionBuilder b) {
|
||||
b.then(b.arg("global","self"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ import me.trouper.alias.server.commands.QuickCommand;
|
||||
import me.trouper.alias.server.commands.completions.CompletionBuilder;
|
||||
import me.trouper.alias.server.systems.AbstractWand;
|
||||
import me.trouper.alias.server.systems.Text;
|
||||
import me.trouper.clonedupecore.server.trolls.*;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import me.trouper.clonedupecore.server.systems.trolls.*;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@CommandRegistry(value = "clonetroll",permission = @Permission("clonedupe.troll"),printStackTrace = true)
|
||||
public class TrollCommand implements QuickCommand {
|
||||
public class TrollCommand implements QuickCommand, CloneDupeContext {
|
||||
|
||||
public final List<TrollFeature> trollRegistry = new ArrayList<>();
|
||||
|
||||
@@ -59,7 +59,7 @@ public class TrollCommand implements QuickCommand {
|
||||
.append(Component.text(":",NamedTextColor.WHITE))).appendNewline();
|
||||
|
||||
for (TrollFeature troll : trollRegistry) {
|
||||
helpMessage = helpMessage.append(Text.format(Text.Pallet.NEUTRAL,"[{0}] - {1}: {2}",troll.getRating(),troll.getName(),troll.getDescription())).appendNewline();
|
||||
helpMessage = helpMessage.append(getTextSystem().format(Text.Pallet.NEUTRAL,"[{0}] - {1}: {2}",troll.getRating(),troll.getName(),troll.getDescription())).appendNewline();
|
||||
}
|
||||
|
||||
if (args.getSize() < 1 || (args.getSize() == 1 && Objects.equals("info",args.get(0).toString()))) {
|
||||
@@ -134,4 +134,5 @@ public class TrollCommand implements QuickCommand {
|
||||
b.arg("info")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package me.trouper.clonedupecore.server.commands;
|
||||
|
||||
import me.trouper.alias.Alias;
|
||||
import me.trouper.alias.server.commands.Args;
|
||||
import me.trouper.alias.server.commands.CommandRegistry;
|
||||
import me.trouper.alias.server.commands.Permission;
|
||||
import me.trouper.alias.server.commands.QuickCommand;
|
||||
import me.trouper.alias.server.commands.completions.CompletionBuilder;
|
||||
import me.trouper.alias.server.systems.AbstractWand;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -15,8 +15,6 @@ import org.bukkit.entity.Player;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static me.trouper.alias.Alias.getAutoRegistrar;
|
||||
|
||||
@CommandRegistry(
|
||||
value = "wand",
|
||||
usage = "/wand <name>",
|
||||
@@ -24,7 +22,7 @@ import static me.trouper.alias.Alias.getAutoRegistrar;
|
||||
consoleAllowed = false,
|
||||
blocksAllowed = false
|
||||
)
|
||||
public class WandCommand implements QuickCommand {
|
||||
public class WandCommand implements QuickCommand, CloneDupeContext {
|
||||
|
||||
@Override
|
||||
public void handleCommand(CommandSender sender, Command command, String label, Args args) {
|
||||
@@ -60,4 +58,5 @@ public class WandCommand implements QuickCommand {
|
||||
.collect(Collectors.toList()))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package me.trouper.clonedupecore.server.events;
|
||||
|
||||
import me.trouper.alias.server.events.QuickListener;
|
||||
import me.trouper.clonedupecore.CloneDupeCore;
|
||||
import me.trouper.clonedupecore.data.Data;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.items.ItemCheck;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -9,7 +9,7 @@ import org.bukkit.event.inventory.InventoryCreativeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class CreativeHotbarEvent implements QuickListener {
|
||||
public class CreativeHotbarEvent implements QuickListener, Data {
|
||||
|
||||
@EventHandler
|
||||
private void onNBT(InventoryCreativeEvent e) {
|
||||
@@ -22,7 +22,7 @@ public class CreativeHotbarEvent implements QuickListener {
|
||||
if (i.getItemMeta() == null) return;
|
||||
if (!i.hasItemMeta()) return;
|
||||
|
||||
if (CloneDupeCore.getInstance().getManager().io.config.nbtWhitelist.contains(p.getUniqueId().toString())) return;
|
||||
if (getConfig().nbtWhitelist.contains(p.getUniqueId().toString())) return;
|
||||
if (new ItemCheck().passes(i)) return;
|
||||
|
||||
e.setCancelled(true);
|
||||
@@ -32,4 +32,5 @@ public class CreativeHotbarEvent implements QuickListener {
|
||||
e.setCurrentItem(replacement);
|
||||
e.getCursor().setItemMeta(meta);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
package me.trouper.clonedupecore.server.events;
|
||||
|
||||
import me.trouper.alias.server.events.QuickListener;
|
||||
import me.trouper.clonedupecore.data.Data;
|
||||
import me.trouper.clonedupecore.server.punishment.Freeze;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class FreezeEvents implements QuickListener {
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent e) {
|
||||
Freeze.FrozenPlayer frozen = Freeze.getFrozen().get(e.getPlayer().getUniqueId());
|
||||
if (frozen == null) return;
|
||||
if (frozen.movementAllowed()) return;
|
||||
|
||||
if (!e.getFrom().toVector().equals(e.getTo().toVector())) {
|
||||
e.setTo(e.getFrom());
|
||||
}
|
||||
if (frozen.getOnMove() != null) frozen.getOnMove().accept(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
Freeze.FrozenPlayer frozen = Freeze.getFrozen().get(e.getPlayer().getUniqueId());
|
||||
if (frozen == null) return;
|
||||
|
||||
e.setCancelled(true);
|
||||
if (frozen.getOnMove() != null) frozen.getOnMove().accept(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCommand(PlayerCommandPreprocessEvent e) {
|
||||
Freeze.FrozenPlayer frozen = Freeze.getFrozen().get(e.getPlayer().getUniqueId());
|
||||
if (frozen == null) return;
|
||||
if (frozen.commandsAllowed()) return;
|
||||
|
||||
String baseCmd = e.getMessage().replace("/", "").split(" ")[0].toLowerCase();
|
||||
if (!Data.data.getConfig().allowedFreezeCommands.contains(baseCmd)) {
|
||||
e.setCancelled(true);
|
||||
if (frozen.getOnMove() != null) frozen.getOnMove().accept(e.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamageByEntity(EntityDamageByEntityEvent e) {
|
||||
if (!(e.getEntity() instanceof Player p)) return;
|
||||
Freeze.FrozenPlayer frozen = Freeze.getFrozen().get(p.getUniqueId());
|
||||
if (frozen == null) return;
|
||||
if (frozen.damageAllowed()) return;
|
||||
|
||||
e.setCancelled(true);
|
||||
if (frozen.getOnMove() != null) frozen.getOnMove().accept(p);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamageByBlock(EntityDamageByBlockEvent e) {
|
||||
if (!(e.getEntity() instanceof Player p)) return;
|
||||
Freeze.FrozenPlayer frozen = Freeze.getFrozen().get(p.getUniqueId());
|
||||
if (frozen == null) return;
|
||||
if (frozen.damageAllowed()) return;
|
||||
|
||||
e.setCancelled(true);
|
||||
if (frozen.getOnMove() != null) frozen.getOnMove().accept(p);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
Freeze.FrozenPlayer frozen = Freeze.getFrozen().get(e.getPlayer().getUniqueId());
|
||||
if (frozen == null) return;
|
||||
|
||||
if (frozen.getOnQuit() != null) frozen.getOnQuit().accept(e.getPlayer());
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
package me.trouper.clonedupecore.server.events;
|
||||
|
||||
import me.trouper.alias.server.events.QuickListener;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class JoinEvent implements QuickListener {
|
||||
public class JoinEvent implements QuickListener, CloneDupeContext {
|
||||
|
||||
@EventHandler
|
||||
private void onJoin(PlayerJoinEvent e) {
|
||||
@@ -18,4 +19,5 @@ public class JoinEvent implements QuickListener {
|
||||
p.setAllowFlight(false);
|
||||
infoAny(p,"Flight has been disable when joining.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package me.trouper.clonedupecore.server.events.hotbar;
|
||||
|
||||
import me.trouper.alias.server.ContextAware;
|
||||
import me.trouper.clonedupecore.data.Data;
|
||||
import me.trouper.clonedupecore.data.io.NBTConfig;
|
||||
|
||||
public abstract class AbstractCheck<T> implements Data {
|
||||
public abstract class AbstractCheck<T> implements ContextAware, Data {
|
||||
public NBTConfig config = getNBT();
|
||||
public abstract boolean passes(T input);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package me.trouper.clonedupecore.server.events.hotbar.entities;
|
||||
|
||||
import de.tr7zw.nbtapi.NBT;
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.alias.utils.InventoryUtils;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.AbstractCheck;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.items.ItemCheck;
|
||||
@@ -21,37 +20,37 @@ public class EntityCheck extends AbstractCheck<Entity> {
|
||||
public boolean passes(Entity entity) {
|
||||
if (entity instanceof Item itemEntity) {
|
||||
if (!new ItemCheck().passes(itemEntity.getItemStack())) {
|
||||
Verbose.send("Entity failed check: Item not allowed.");
|
||||
getVerbose().send("Entity failed check: Item not allowed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Inventory inv = InventoryUtils.getInventory(entity);
|
||||
if (inv != null && !new InventoryCheck().passes(inv)) {
|
||||
Verbose.send("Entity inventory failed check.");
|
||||
getVerbose().send("Entity inventory failed check.");
|
||||
return false;
|
||||
}
|
||||
if (entity instanceof Villager villager) {
|
||||
for (MerchantRecipe recipe : villager.getRecipes()) {
|
||||
if (!new ItemCheck().passes(recipe.getResult())) {
|
||||
Verbose.send("Villager recipe failed check.");
|
||||
getVerbose().send("Villager recipe failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (entity instanceof Mob mob) {
|
||||
if (!new EquipmentCheck().passes(mob)) {
|
||||
Verbose.send("Mob equipment failed check.");
|
||||
getVerbose().send("Mob equipment failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!entity.getPassengers().isEmpty()) {
|
||||
if (!config.allowRecursion) {
|
||||
Verbose.send("Entity recursion not allowed.");
|
||||
getVerbose().send("Entity recursion not allowed.");
|
||||
return false;
|
||||
}
|
||||
for (Entity passenger : entity.getPassengers()) {
|
||||
if (!passes(passenger)) {
|
||||
Verbose.send("Entity passenger failed check.");
|
||||
getVerbose().send("Entity passenger failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -59,16 +58,16 @@ public class EntityCheck extends AbstractCheck<Entity> {
|
||||
AtomicBoolean failsTiming = new AtomicBoolean(false);
|
||||
NBT.get(entity, nbt -> {
|
||||
if (nbt.hasTag("DeathTime") && nbt.getInteger("DeathTime") < 1) {
|
||||
Verbose.send("Entity death time check failed.");
|
||||
getVerbose().send("Entity death time check failed.");
|
||||
failsTiming.set(true);
|
||||
}
|
||||
if (nbt.hasTag("HurtTime") && nbt.getInteger("HurtTime") < 1) {
|
||||
Verbose.send("Entity hurt time check failed.");
|
||||
getVerbose().send("Entity hurt time check failed.");
|
||||
failsTiming.set(true);
|
||||
}
|
||||
});
|
||||
if (failsTiming.get()) {
|
||||
Verbose.send("Entity timing check failed.");
|
||||
getVerbose().send("Entity timing check failed.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package me.trouper.clonedupecore.server.events.hotbar.entities;
|
||||
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.AbstractCheck;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -14,7 +13,7 @@ public class EntitySnapshotCheck extends AbstractCheck<EntitySnapshot> {
|
||||
Location loc = new Location(Bukkit.getWorlds().getFirst(), 0, 1000000, 0);
|
||||
Entity temp = input.createEntity(loc);
|
||||
boolean result = new EntityCheck().passes(temp);
|
||||
Verbose.send("Temp Entity %s Entity Check", result ? "failed" : "passed");
|
||||
getVerbose().send("Temp Entity %s Entity Check", result ? "failed" : "passed");
|
||||
temp.remove();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package me.trouper.clonedupecore.server.events.hotbar.entities;
|
||||
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.AbstractCheck;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.items.ItemCheck;
|
||||
import org.bukkit.entity.Mob;
|
||||
@@ -11,12 +10,12 @@ public class EquipmentCheck extends AbstractCheck<Mob> {
|
||||
|
||||
@Override
|
||||
public boolean passes(Mob mob) {
|
||||
Verbose.send("Running mob check.");
|
||||
getVerbose().send("Running mob check.");
|
||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
if (mob.getEquipment().getItem(slot).isEmpty()) continue;
|
||||
ItemStack item = mob.getEquipment().getItem(slot);
|
||||
if (!new ItemCheck().passes(item)) {
|
||||
Verbose.send("Equipment slot did not pass.");
|
||||
getVerbose().send("Equipment slot did not pass.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package me.trouper.clonedupecore.server.events.hotbar.items;
|
||||
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.AbstractCheck;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -18,7 +17,7 @@ public class EnchantmentCheck extends AbstractCheck<ItemStack> {
|
||||
}
|
||||
|
||||
public boolean hasIllegalEnchants(ItemStack item) {
|
||||
Verbose.send("Checking item for illegal enchants: ", item.getType().name());
|
||||
getVerbose().send("Checking item for illegal enchants: ", item.getType().name());
|
||||
if (item.hasItemMeta() && item.getItemMeta().hasEnchants()) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
Map<Enchantment, Integer> enchantments = meta.getEnchants();
|
||||
|
||||
@@ -2,9 +2,7 @@ package me.trouper.clonedupecore.server.events.hotbar.items;
|
||||
|
||||
import de.tr7zw.nbtapi.NBT;
|
||||
import de.tr7zw.nbtapi.iface.ReadWriteNBT;
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.alias.utils.InventoryUtils;
|
||||
import me.trouper.clonedupecore.CloneDupeCore;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.AbstractCheck;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.misc.BlockStateCheck;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.misc.InventoryCheck;
|
||||
@@ -22,23 +20,23 @@ public class ItemCheck extends AbstractCheck<ItemStack> {
|
||||
try {
|
||||
return scan(item);
|
||||
} catch (Exception ex) {
|
||||
CloneDupeCore.getInstance().getLogger().warning("Caught an exception while handling an item check: " + Arrays.toString(ex.getStackTrace()));
|
||||
getInstance().getLogger().warning("Caught an exception while handling an item check: " + Arrays.toString(ex.getStackTrace()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean scan(ItemStack item) {
|
||||
Verbose.send("Checking item: " + item.getType().name());
|
||||
getVerbose().send("Checking item: " + item.getType().name());
|
||||
|
||||
// No metadata? Nothing to check.
|
||||
if (item.getItemMeta() == null) {
|
||||
Verbose.send("Item passes because it has no metadata.");
|
||||
getVerbose().send("Item passes because it has no metadata.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!new MetaCheck().passes(item)) {
|
||||
Verbose.send("Item failed metadata check.");
|
||||
getVerbose().send("Item failed metadata check.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -48,33 +46,33 @@ public class ItemCheck extends AbstractCheck<ItemStack> {
|
||||
ReadWriteNBT components = nbt.getCompound("components");
|
||||
if (components != null) {
|
||||
if (!new ComponentCheck().passes(components)) {
|
||||
Verbose.send("Components check failed.");
|
||||
getVerbose().send("Components check failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn egg checks.
|
||||
if (!new SpawnEggCheck().passes(item)) {
|
||||
Verbose.send("Spawn egg check failed.");
|
||||
getVerbose().send("Spawn egg check failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!new BlockStateCheck().passes(item)) {
|
||||
Verbose.send("Block State check failed.");
|
||||
getVerbose().send("Block State check failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for an inventory inside the item.
|
||||
Inventory inv = InventoryUtils.getInventory(item);
|
||||
if (inv != null) {
|
||||
Verbose.send("Item contains an inventory: " + inv);
|
||||
getVerbose().send("Item contains an inventory: " + inv);
|
||||
if (!new InventoryCheck().passes(inv)) {
|
||||
Verbose.send("Item failed inventory check.");
|
||||
getVerbose().send("Item failed inventory check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Verbose.send("Item passed all checks.");
|
||||
getVerbose().send("Item passed all checks.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package me.trouper.clonedupecore.server.events.hotbar.items;
|
||||
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.AbstractCheck;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -15,30 +14,30 @@ public class MetaCheck extends AbstractCheck<ItemStack> {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
// Name, lore, potion, attribute and enchantment checks.
|
||||
if (!config.allowName && meta.hasDisplayName()) {
|
||||
Verbose.send("Custom names not allowed.");
|
||||
getVerbose().send("Custom names not allowed.");
|
||||
return false;
|
||||
}
|
||||
if (!config.allowLore && meta.hasLore()) {
|
||||
Verbose.send("Custom lore not allowed.");
|
||||
getVerbose().send("Custom lore not allowed.");
|
||||
return false;
|
||||
}
|
||||
if (!config.allowBooks && meta instanceof BookMeta) {
|
||||
Verbose.send("Item failed book check.");
|
||||
getVerbose().send("Item failed book check.");
|
||||
return false;
|
||||
}
|
||||
if (!config.allowPotions &&
|
||||
(item.getType().equals(Material.POTION) ||
|
||||
item.getType().equals(Material.SPLASH_POTION) ||
|
||||
item.getType().equals(Material.LINGERING_POTION))) {
|
||||
Verbose.send("Potions not allowed.");
|
||||
getVerbose().send("Potions not allowed.");
|
||||
return false;
|
||||
}
|
||||
if (!config.allowAttributes && meta.hasAttributeModifiers()) {
|
||||
Verbose.send("Attribute modifiers not allowed.");
|
||||
getVerbose().send("Attribute modifiers not allowed.");
|
||||
return false;
|
||||
}
|
||||
if (config.globalMaxEnchant != 0 && new EnchantmentCheck().hasIllegalEnchants(item)) {
|
||||
Verbose.send("Illegal enchantments found.");
|
||||
getVerbose().send("Illegal enchantments found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
package me.trouper.clonedupecore.server.events.hotbar.items;
|
||||
|
||||
import de.tr7zw.nbtapi.NBT;
|
||||
import kotlin.Pair;
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.clonedupecore.CloneDupeCore;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.AbstractCheck;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class RateLimitCheck extends AbstractCheck<Pair<Player,ItemStack>> {
|
||||
|
||||
public static Map<UUID, Integer> dataUsed = new HashMap<>();
|
||||
public static Map<UUID, Integer> itemsUsed = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public boolean passes(Pair<Player,ItemStack> input) {
|
||||
Player player = input.getFirst();
|
||||
UUID uuid = player.getUniqueId();
|
||||
ItemStack item = input.getSecond();
|
||||
|
||||
return itemLimit(uuid,item) && dataLimit(uuid,item);
|
||||
}
|
||||
|
||||
private boolean itemLimit(UUID uuid, ItemStack item) {
|
||||
int currentUsed = itemsUsed.getOrDefault(uuid,0);
|
||||
Verbose.send("Current Player used items: " + currentUsed);
|
||||
currentUsed++;
|
||||
itemsUsed.put(uuid,currentUsed);
|
||||
return currentUsed <= config.rateLimit.rateLimitItems;
|
||||
}
|
||||
|
||||
|
||||
private boolean dataLimit(UUID uuid, ItemStack item) {
|
||||
int currentData = dataUsed.getOrDefault(uuid,0);
|
||||
|
||||
Verbose.send("Current Player used data: " + currentData);
|
||||
try {
|
||||
int itemData = NBT.readNbt(item).toString().length();
|
||||
Verbose.send("Item data: " + itemData);
|
||||
if (currentData < config.rateLimit.maxOverhead) currentData += itemData;
|
||||
} catch (Exception e) {
|
||||
CloneDupeCore.getInstance().getLogger().warning("Could not determine size of item. Blocking.");
|
||||
CloneDupeCore.getInstance().getLogger().warning(Arrays.toString(e.getStackTrace()));
|
||||
return false;
|
||||
}
|
||||
|
||||
dataUsed.put(uuid,currentData);
|
||||
|
||||
Verbose.send("New Player used data: " + currentData);
|
||||
|
||||
return currentData <= config.rateLimit.rateLimitBytes;
|
||||
}
|
||||
|
||||
public void decayData() {
|
||||
for (UUID uuid : dataUsed.keySet()) {
|
||||
int currentData = dataUsed.get(uuid);
|
||||
if (currentData > 0) {
|
||||
currentData -= config.rateLimit.byteDecay;
|
||||
dataUsed.put(uuid, Math.max(0, currentData));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void decayItems() {
|
||||
for (UUID uuid : itemsUsed.keySet()) {
|
||||
int currentItems = itemsUsed.get(uuid);
|
||||
if (currentItems > 0) {
|
||||
currentItems -= config.rateLimit.itemDecay;
|
||||
itemsUsed.put(uuid, Math.max(0, currentItems));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package me.trouper.clonedupecore.server.events.hotbar.items;
|
||||
|
||||
import de.tr7zw.nbtapi.NBT;
|
||||
import de.tr7zw.nbtapi.iface.ReadWriteNBT;
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.AbstractCheck;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.entities.EntitySnapshotCheck;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.nbt.EntityDataCheck;
|
||||
@@ -13,10 +12,10 @@ public class SpawnEggCheck extends AbstractCheck<ItemStack> {
|
||||
|
||||
@Override
|
||||
public boolean passes(ItemStack item) {
|
||||
Verbose.send("Running spawn egg checks on item: ",item.getType().name());
|
||||
getVerbose().send("Running spawn egg checks on item: ",item.getType().name());
|
||||
if (!item.getType().name().toLowerCase().contains("spawn_egg")) return true;
|
||||
if (!SpawnEggCheck.entityMatches(item)) {
|
||||
Verbose.send("Spawn egg entity doesn't match item type.");
|
||||
if (!entityMatches(item)) {
|
||||
getVerbose().send("Spawn egg entity doesn't match item type.");
|
||||
return false;
|
||||
}
|
||||
ReadWriteNBT nbt = NBT.itemStackToNBT(item);
|
||||
@@ -24,14 +23,14 @@ public class SpawnEggCheck extends AbstractCheck<ItemStack> {
|
||||
if (components != null) {
|
||||
var entityData = components.getCompound("minecraft:entity_data");
|
||||
if (!new EntityDataCheck().passes(entityData)) {
|
||||
Verbose.send("Spawn egg entity data check failed.");
|
||||
getVerbose().send("Spawn egg entity data check failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.hasItemMeta() && item.getItemMeta() instanceof SpawnEggMeta sem) {
|
||||
if (sem.getSpawnedEntity() != null && !new EntitySnapshotCheck().passes(sem.getSpawnedEntity())) {
|
||||
Verbose.send("Spawn egg entity snapshot check failed.");
|
||||
getVerbose().send("Spawn egg entity snapshot check failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -39,7 +38,7 @@ public class SpawnEggCheck extends AbstractCheck<ItemStack> {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean entityMatches(ItemStack item) {
|
||||
private boolean entityMatches(ItemStack item) {
|
||||
if (item.hasItemMeta() && item.getItemMeta() instanceof SpawnEggMeta sem) {
|
||||
String eggEntityName = item.getType().name().replace("_SPAWN_EGG", "");
|
||||
return sem.getSpawnedEntity() != null &&
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package me.trouper.clonedupecore.server.events.hotbar.misc;
|
||||
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.AbstractCheck;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.entities.EntitySnapshotCheck;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.items.ItemCheck;
|
||||
@@ -18,7 +17,7 @@ public class BlockStateCheck extends AbstractCheck<ItemStack> {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
if (!(meta instanceof BlockStateMeta blockStateMeta)) {
|
||||
Verbose.send("Item passes due to not being a block state meta");
|
||||
getVerbose().send("Item passes due to not being a block state meta");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -28,7 +27,7 @@ public class BlockStateCheck extends AbstractCheck<ItemStack> {
|
||||
for (int slot = 0; slot < 4; slot++) {
|
||||
ItemStack campfireItem = campfire.getItem(slot);
|
||||
if (campfireItem != null && !new ItemCheck().passes(campfireItem)) {
|
||||
Verbose.send("Campfire item failed check.");
|
||||
getVerbose().send("Campfire item failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -40,7 +39,7 @@ public class BlockStateCheck extends AbstractCheck<ItemStack> {
|
||||
BlockState bs = blockStateMeta.getBlockState();
|
||||
if (bs instanceof Lectern lectern) {
|
||||
if (!new InventoryCheck().passes(lectern.getInventory())) {
|
||||
Verbose.send("Lectern inventory failed check.");
|
||||
getVerbose().send("Lectern inventory failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -49,7 +48,7 @@ public class BlockStateCheck extends AbstractCheck<ItemStack> {
|
||||
BlockState bs = blockStateMeta.getBlockState();
|
||||
if (bs instanceof ChiseledBookshelf bookshelf) {
|
||||
if (!new InventoryCheck().passes(bookshelf.getInventory())) {
|
||||
Verbose.send("Chiseled bookshelf inventory failed check.");
|
||||
getVerbose().send("Chiseled bookshelf inventory failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -62,11 +61,11 @@ public class BlockStateCheck extends AbstractCheck<ItemStack> {
|
||||
if (spawner.getSpawnedEntity() != null) {
|
||||
if (spawner.getSpawnedEntity().getEntityType().equals(EntityType.FALLING_BLOCK) ||
|
||||
spawner.getSpawnedEntity().getEntityType().equals(EntityType.COMMAND_BLOCK_MINECART)) {
|
||||
Verbose.send("Spawner contains disallowed entity type.");
|
||||
getVerbose().send("Spawner contains disallowed entity type.");
|
||||
return false;
|
||||
}
|
||||
if (!new EntitySnapshotCheck().passes(spawner.getSpawnedEntity())) {
|
||||
Verbose.send("Spawner entity snapshot check failed.");
|
||||
getVerbose().send("Spawner entity snapshot check failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -77,18 +76,18 @@ public class BlockStateCheck extends AbstractCheck<ItemStack> {
|
||||
if (item.getType() == Material.TRIAL_SPAWNER) {
|
||||
BlockState bs = blockStateMeta.getBlockState();
|
||||
if (bs instanceof TrialSpawner spawner) {
|
||||
Verbose.send("Running trial spawner check.");
|
||||
getVerbose().send("Running trial spawner check.");
|
||||
if (spawner.getNormalConfiguration() != null) {
|
||||
TrialSpawnerConfiguration config = spawner.getNormalConfiguration();
|
||||
if (config.getSpawnedEntity() != null && !new EntitySnapshotCheck().passes(config.getSpawnedEntity())) {
|
||||
Verbose.send("Trial Spawner failed check: Normal entity snapshot not allowed.");
|
||||
getVerbose().send("Trial Spawner failed check: Normal entity snapshot not allowed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (spawner.getOminousConfiguration() != null) {
|
||||
TrialSpawnerConfiguration config = spawner.getOminousConfiguration();
|
||||
if (config.getSpawnedEntity() != null && !new EntitySnapshotCheck().passes(config.getSpawnedEntity())) {
|
||||
Verbose.send("Trial Spawner failed check: Ominous entity snapshot not allowed.");
|
||||
getVerbose().send("Trial Spawner failed check: Ominous entity snapshot not allowed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package me.trouper.clonedupecore.server.events.hotbar.misc;
|
||||
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.alias.utils.InventoryUtils;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.AbstractCheck;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.items.ItemCheck;
|
||||
@@ -11,25 +10,25 @@ public class InventoryCheck extends AbstractCheck<Inventory> {
|
||||
|
||||
@Override
|
||||
public boolean passes(Inventory inv) {
|
||||
Verbose.send("Running Inventory Check");
|
||||
getVerbose().send("Running Inventory Check");
|
||||
|
||||
for (ItemStack i : inv.getContents()) {
|
||||
if (i == null || i.getType().isAir()) continue;
|
||||
if (!new ItemCheck().passes(i)) {
|
||||
Verbose.send("Inventory item failed check.");
|
||||
getVerbose().send("Inventory item failed check.");
|
||||
return false;
|
||||
}
|
||||
Inventory subInventory = InventoryUtils.getInventory(i);
|
||||
if (subInventory != null && !config.allowRecursion) {
|
||||
Verbose.send("Recursion is disabled. Failing check.");
|
||||
getVerbose().send("Recursion is disabled. Failing check.");
|
||||
return false;
|
||||
}
|
||||
if (subInventory != null && !passes(subInventory)) {
|
||||
Verbose.send("Sub-inventory failed check.");
|
||||
getVerbose().send("Sub-inventory failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Verbose.send("Inventory passed all checks.");
|
||||
getVerbose().send("Inventory passed all checks.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,27 @@
|
||||
package me.trouper.clonedupecore.server.events.hotbar.nbt;
|
||||
|
||||
import de.tr7zw.nbtapi.iface.ReadWriteNBT;
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.AbstractCheck;
|
||||
|
||||
public class ComponentCheck extends AbstractCheck<ReadWriteNBT> {
|
||||
|
||||
@Override
|
||||
public boolean passes(ReadWriteNBT components) {
|
||||
Verbose.send("Checking Consumable & tool");
|
||||
getVerbose().send("Checking Consumable & tool");
|
||||
if (!config.allowCustomConsumables && components.getCompound("minecraft:consumable") != null) {
|
||||
Verbose.send("Item is consumable and not allowed.");
|
||||
getVerbose().send("Item is consumable and not allowed.");
|
||||
return false;
|
||||
}
|
||||
if (!config.allowCustomTools && components.getCompound("minecraft:tool") != null) {
|
||||
Verbose.send("Item is custom tool and not allowed.");
|
||||
getVerbose().send("Item is custom tool and not allowed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Verbose.send("Checking Entity data");
|
||||
getVerbose().send("Checking Entity data");
|
||||
|
||||
ReadWriteNBT entityData = components.getCompound("minecraft:entity_data");
|
||||
if (!new EntityDataCheck().passes(entityData)) {
|
||||
Verbose.send("Entity Data Check Failed.");
|
||||
getVerbose().send("Entity Data Check Failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package me.trouper.clonedupecore.server.events.hotbar.nbt;
|
||||
|
||||
import de.tr7zw.nbtapi.NBT;
|
||||
import de.tr7zw.nbtapi.iface.ReadWriteNBT;
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.AbstractCheck;
|
||||
import me.trouper.clonedupecore.server.events.hotbar.items.ItemCheck;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -11,30 +10,30 @@ public class EntityDataCheck extends AbstractCheck<ReadWriteNBT> {
|
||||
@Override
|
||||
public boolean passes(ReadWriteNBT entityData) {
|
||||
if (entityData == null) {
|
||||
Verbose.send("Entity Data check passed. There was no data.");
|
||||
getVerbose().send("Entity Data check passed. There was no data.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ReadWriteNBT itemData = entityData.getCompound("Item");
|
||||
if (itemData != null) {
|
||||
Verbose.send("Entity data holds an item");
|
||||
getVerbose().send("Entity data holds an item");
|
||||
ItemStack heldItem = NBT.itemStackFromNBT(itemData);
|
||||
if (heldItem != null && !new ItemCheck().passes(heldItem)) {
|
||||
Verbose.send("Item contents failed check.");
|
||||
getVerbose().send("Item contents failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (entityData.hasTag("DeathTime") && entityData.getInteger("DeathTime") < 1) {
|
||||
Verbose.send("Death time check failed.");
|
||||
getVerbose().send("Death time check failed.");
|
||||
return false;
|
||||
}
|
||||
if (entityData.hasTag("HurtTime") && entityData.getInteger("HurtTime") < 1) {
|
||||
Verbose.send("Hurt time check failed.");
|
||||
getVerbose().send("Hurt time check failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Verbose.send("Entity Data check passed. There was no flagging.");
|
||||
getVerbose().send("Entity Data check passed. There was no flagging.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ import me.trouper.alias.server.systems.gui.QuickGui;
|
||||
import me.trouper.alias.utils.ItemBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -8,7 +8,6 @@ import me.trouper.clonedupecore.data.Data;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
package me.trouper.clonedupecore.server.punishment;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Freeze {
|
||||
|
||||
private static final Map<UUID, FrozenPlayer> FROZEN_PLAYERS = new HashMap<>();
|
||||
|
||||
public static void quickFreeze(Player player) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (!FROZEN_PLAYERS.containsKey(uuid)) {
|
||||
FrozenPlayer frozen = new FrozenPlayer(uuid, player.getLocation(), null, null);
|
||||
FROZEN_PLAYERS.put(uuid, frozen);
|
||||
}
|
||||
}
|
||||
|
||||
public static void freezePlayer(FrozenPlayer player) {
|
||||
UUID uuid = player.getUuid();
|
||||
if (!FROZEN_PLAYERS.containsKey(uuid)) {
|
||||
FROZEN_PLAYERS.put(uuid, player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void thawPlayer(UUID uuid) {
|
||||
FROZEN_PLAYERS.remove(uuid).teleportBack();
|
||||
}
|
||||
|
||||
public static Map<UUID, FrozenPlayer> getFrozen() {
|
||||
return Collections.unmodifiableMap(FROZEN_PLAYERS);
|
||||
}
|
||||
|
||||
public static boolean isFrozen(UUID uuid) {
|
||||
return FROZEN_PLAYERS.containsKey(uuid);
|
||||
}
|
||||
|
||||
public static FrozenPlayer get(UUID uuid) {
|
||||
return FROZEN_PLAYERS.get(uuid);
|
||||
}
|
||||
|
||||
public static class FrozenPlayer {
|
||||
private final UUID uuid;
|
||||
private final Location backLocation;
|
||||
private final Consumer<OfflinePlayer> onQuit;
|
||||
private final Consumer<Player> onMove;
|
||||
private boolean allowMovement = false;
|
||||
private boolean allowDamage = false;
|
||||
private boolean allowCommands = false;
|
||||
|
||||
public FrozenPlayer(UUID uuid, Location backLocation, Consumer<OfflinePlayer> onQuit, Consumer<Player> onMove) {
|
||||
this.uuid = uuid;
|
||||
this.backLocation = backLocation;
|
||||
this.onQuit = onQuit;
|
||||
this.onMove = onMove;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public Consumer<Player> getOnMove() {
|
||||
return onMove;
|
||||
}
|
||||
|
||||
public Consumer<OfflinePlayer> getOnQuit() {
|
||||
return onQuit;
|
||||
}
|
||||
|
||||
public void teleportBack() {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player == null) return;
|
||||
player.teleport(backLocation);
|
||||
}
|
||||
|
||||
public void setAllowDamage(boolean allowDamage) {
|
||||
this.allowDamage = allowDamage;
|
||||
}
|
||||
|
||||
public void setAllowMovement(boolean allowMovement) {
|
||||
this.allowMovement = allowMovement;
|
||||
}
|
||||
|
||||
public boolean commandsAllowed() {
|
||||
return allowCommands;
|
||||
}
|
||||
|
||||
public void setAllowCommands(boolean allowCommands) {
|
||||
this.allowCommands = allowCommands;
|
||||
}
|
||||
|
||||
public boolean damageAllowed() {
|
||||
return allowDamage;
|
||||
}
|
||||
|
||||
public boolean movementAllowed() {
|
||||
return allowMovement;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import me.trouper.alias.server.commands.Permission;
|
||||
import me.trouper.alias.server.commands.QuickCommand;
|
||||
import me.trouper.alias.server.commands.completions.CompletionBuilder;
|
||||
import me.trouper.alias.server.systems.Text;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -16,7 +17,7 @@ import org.bukkit.command.CommandSender;
|
||||
value = "broadcast",
|
||||
permission = @Permission("clonedupe.broadcast")
|
||||
)
|
||||
public class BroadcastCommand implements QuickCommand {
|
||||
public class BroadcastCommand implements QuickCommand, CloneDupeContext {
|
||||
|
||||
@Override
|
||||
public void handleCommand(CommandSender sender, Command command, String label, Args args) {
|
||||
@@ -27,9 +28,9 @@ public class BroadcastCommand implements QuickCommand {
|
||||
} catch (Exception ex) {
|
||||
message = args.get(0) + " " + message;
|
||||
}
|
||||
Component text = Text.color(message);
|
||||
Component text = getTextSystem().color(message);
|
||||
Audience players = Audience.audience(Bukkit.getOnlinePlayers());
|
||||
Text.message(pallet,players,text);
|
||||
getTextSystem().message(pallet,players,text);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,7 +4,6 @@ import me.trouper.alias.server.systems.AbstractWand;
|
||||
import me.trouper.alias.utils.ItemBuilder;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class DashWand extends AbstractWand {
|
||||
public DashWand() {
|
||||
@@ -13,7 +12,7 @@ public class DashWand extends AbstractWand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRightClick(Player player) {
|
||||
public void onRightClick(Player player) {
|
||||
player.setVelocity(player.getVelocity().add(player.getEyeLocation().getDirection().normalize().multiply(2)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package me.trouper.clonedupecore.server.scripts;
|
||||
|
||||
import me.trouper.alias.server.events.QuickListener;
|
||||
import me.trouper.alias.server.systems.AbstractWand;
|
||||
import me.trouper.alias.server.systems.freeze.FreezeSession;
|
||||
import me.trouper.alias.server.systems.world.Snapshot;
|
||||
import me.trouper.alias.utils.ItemBuilder;
|
||||
import me.trouper.alias.utils.TargetingUtils;
|
||||
import me.trouper.clonedupecore.server.punishment.Freeze;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
@@ -21,7 +21,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class JailHeadWand extends AbstractWand implements QuickListener {
|
||||
public class JailHeadWand extends AbstractWand implements CloneDupeContext {
|
||||
public JailHeadWand() {
|
||||
super("clonedupe.jailwand", ItemBuilder.of(Material.PLAYER_HEAD)
|
||||
.createCustomHead("http://textures.minecraft.net/texture/a63b87ee6a55f2bf0135b26bd96ec279eded175f948c036d88a60725e127371c","Port-a-Jail")
|
||||
@@ -32,18 +32,20 @@ public class JailHeadWand extends AbstractWand implements QuickListener {
|
||||
private final Map<UUID,Jail> jailed = new HashMap<>();
|
||||
|
||||
@Override
|
||||
protected void onRightClick(Player player) {
|
||||
public void onRightClick(Player player) {
|
||||
Optional<LivingEntity> optional = TargetingUtils.livingClosestAngle(player.getEyeLocation(),player.getEyeLocation().getDirection(),10,0.5);
|
||||
if (optional.isEmpty() || !(optional.get() instanceof Player target)) return;
|
||||
if (jailed.containsKey(target.getUniqueId())) {
|
||||
Freeze.thawPlayer(target.getUniqueId());
|
||||
getContext().getFreezeManager().getSession(target.getUniqueId()).thaw();
|
||||
jailed.remove(target.getUniqueId()).revertCage();
|
||||
return;
|
||||
}
|
||||
Freeze.quickFreeze(target);
|
||||
Freeze.FrozenPlayer fp = new Freeze.FrozenPlayer(target.getUniqueId(),target.getLocation().clone(),null,null);
|
||||
fp.setAllowMovement(true);
|
||||
Freeze.freezePlayer(fp);
|
||||
|
||||
FreezeSession freeze = new FreezeSession.Builder(getContext(), target.getUniqueId(),target.getLocation())
|
||||
.allowMovement()
|
||||
.allowDamage()
|
||||
.build();
|
||||
freeze.start();
|
||||
|
||||
Jail jail = new Jail(target);
|
||||
jail.createCage();
|
||||
|
||||
@@ -2,11 +2,12 @@ package me.trouper.clonedupecore.server.scripts;
|
||||
|
||||
import me.trouper.alias.server.events.QuickListener;
|
||||
import me.trouper.alias.server.events.custom.PlayerSpawnEntityEvent;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import org.bukkit.entity.Endermite;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
public class MobDisablers implements QuickListener {
|
||||
public class MobDisablers implements QuickListener, CloneDupeContext {
|
||||
|
||||
@EventHandler
|
||||
public void onSpawn(PlayerSpawnEntityEvent e) {
|
||||
@@ -20,4 +21,5 @@ public class MobDisablers implements QuickListener {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import me.trouper.alias.server.commands.CommandRegistry;
|
||||
import me.trouper.alias.server.commands.Permission;
|
||||
import me.trouper.alias.server.commands.QuickCommand;
|
||||
import me.trouper.alias.server.commands.completions.CompletionBuilder;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import me.trouper.clonedupecore.server.gui.RtpGui;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -16,7 +17,7 @@ import org.bukkit.entity.Player;
|
||||
blocksAllowed = false,
|
||||
consoleAllowed = false
|
||||
)
|
||||
public class RtpCommand implements QuickCommand {
|
||||
public class RtpCommand implements QuickCommand, CloneDupeContext {
|
||||
@Override
|
||||
public void handleCommand(CommandSender sender, Command command, String label, Args args) {
|
||||
new RtpGui().create().build().open((Player) sender);
|
||||
@@ -26,4 +27,5 @@ public class RtpCommand implements QuickCommand {
|
||||
public void handleCompletion(CommandSender sender, Command command, String label, Args args, CompletionBuilder b) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SpawnCommand implements QuickCommandListener, Data {
|
||||
Location l = setter.getLocation();
|
||||
getConfig().spawnLocation = SerialLocation.translate(l);
|
||||
getConfig().save();
|
||||
info(sender, Component.text("Set the spawn location to {0}."), Text.format(Text.Pallet.LOCATION,"({0},{1},{2})",l.getBlockX(),l.getBlockY(),l.getBlockZ()));
|
||||
info(sender, Component.text("Set the spawn location to {0}."), getTextSystem().format(Text.Pallet.LOCATION,"({0},{1},{2})",l.getBlockX(),l.getBlockY(),l.getBlockZ()));
|
||||
return;
|
||||
}
|
||||
Player target = Bukkit.getPlayerExact(args.get(0).toString());
|
||||
@@ -81,7 +81,7 @@ public class SpawnCommand implements QuickCommandListener, Data {
|
||||
successAny(player, "Teleporting to spawn in {0} seconds. Don't move or take damage!", WARMUP_TICKS / 20);
|
||||
AtomicInteger secondsLeft = new AtomicInteger((int) WARMUP_TICKS / 20);
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(main.getPlugin(),(task)->{
|
||||
Bukkit.getScheduler().runTaskTimer(getPlugin(),(task)->{
|
||||
if (!warmups.containsKey(player.getUniqueId()) || secondsLeft.get() < 0 || !player.isOnline()) {
|
||||
task.cancel();
|
||||
return;
|
||||
@@ -89,7 +89,7 @@ public class SpawnCommand implements QuickCommandListener, Data {
|
||||
|
||||
if (secondsLeft.get() % 5 == 0 || secondsLeft.get() <= 3) {
|
||||
if (secondsLeft.get() > 0) {
|
||||
player.sendActionBar(Text.format(Text.Pallet.INFO,"Teleporting in {0}!",secondsLeft.get()));
|
||||
player.sendActionBar(getTextSystem().format(Text.Pallet.INFO,"Teleporting in {0}!",secondsLeft.get()));
|
||||
} else {
|
||||
warmups.remove(player.getUniqueId());
|
||||
teleportToSpawn(player, true);
|
||||
@@ -152,4 +152,5 @@ public class SpawnCommand implements QuickCommandListener, Data {
|
||||
if (p.getLocation().distanceSquared(loc) > 100*100) return;
|
||||
p.teleport(loc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
package me.trouper.clonedupecore.server.punishment;
|
||||
package me.trouper.clonedupecore.server.systems.punishment;
|
||||
|
||||
import club.minnced.discord.webhook.WebhookClient;
|
||||
import club.minnced.discord.webhook.WebhookClientBuilder;
|
||||
import club.minnced.discord.webhook.send.WebhookEmbed;
|
||||
import club.minnced.discord.webhook.send.WebhookEmbedBuilder;
|
||||
import litebans.api.Database;
|
||||
import litebans.api.Entry;
|
||||
import me.trouper.alias.server.Main;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -16,9 +11,8 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LiteBansManager {
|
||||
public class LiteBansManager implements CloneDupeContext {
|
||||
|
||||
/**
|
||||
* Get all ban entries for a specific player
|
||||
@@ -131,7 +125,7 @@ public class LiteBansManager {
|
||||
* Execute a ban using LiteBans template system
|
||||
*/
|
||||
public void executeBan(OfflinePlayer player, String template, CommandSender executor) {
|
||||
Bukkit.getScheduler().runTask(Main.main.getPlugin(),()-> {
|
||||
Bukkit.getScheduler().runTask(getPlugin(),()-> {
|
||||
Bukkit.dispatchCommand(executor,
|
||||
String.format("litebans:ban %s %s -s", player.getName(), template));
|
||||
});
|
||||
@@ -1,10 +1,9 @@
|
||||
package me.trouper.clonedupecore.server.punishment;
|
||||
package me.trouper.clonedupecore.server.systems.punishment;
|
||||
|
||||
import me.trouper.clonedupecore.data.Data;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Instant;
|
||||
|
||||
public class WrappedEntry implements Data {
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
package me.trouper.clonedupecore.server.punishment.animations;
|
||||
package me.trouper.clonedupecore.server.systems.punishment.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.alias.server.systems.visual.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.punishment.Freeze;
|
||||
import me.trouper.alias.server.systems.freeze.FreezeSession;
|
||||
import me.trouper.alias.utils.ParticleUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class AnvilAnimation extends PunishmentAnimation {
|
||||
@@ -28,10 +23,10 @@ public class AnvilAnimation extends PunishmentAnimation {
|
||||
|
||||
@Override
|
||||
protected void tick(int ticksElapsed) {
|
||||
Freeze.quickFreeze(player);
|
||||
new FreezeSession.Builder(getContext(),player.getUniqueId(),player.getLocation()).build().start();
|
||||
if (!spawned) {
|
||||
spawnAnvilRing();
|
||||
DisplayUtils.ring(player.getLocation().add(0,10,0),5,1,(point)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(player.getLocation().add(0,10,0),5,1,(point)->{
|
||||
ParticleUtils.builder()
|
||||
.type(Particle.CLOUD)
|
||||
.speed(0.07F)
|
||||
@@ -44,7 +39,7 @@ public class AnvilAnimation extends PunishmentAnimation {
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
int finalI = i;
|
||||
DisplayUtils.ring(player.getLocation().add(0,0.1,0), (double)i/2D,0.5,(point)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(player.getLocation().add(0,0.1,0), (double)i/2D,0.5,(point)->{
|
||||
ParticleUtils.builder()
|
||||
.type(Particle.DUST)
|
||||
.data(new Particle.DustOptions(finalI % 2 == 0 ? Color.RED : Color.WHITE,2F))
|
||||
@@ -67,7 +62,7 @@ public class AnvilAnimation extends PunishmentAnimation {
|
||||
int amount = 12;
|
||||
for (int i = 0; i < amount; i++) {
|
||||
int finalI = i;
|
||||
Bukkit.getScheduler().runTaskLater(main.getPlugin(),()->{
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(),()->{
|
||||
double angle = 2 * Math.PI * finalI / amount;
|
||||
int RADIUS = 5;
|
||||
double x = center.getX() + RADIUS * Math.cos(angle);
|
||||
@@ -91,7 +86,7 @@ public class AnvilAnimation extends PunishmentAnimation {
|
||||
|
||||
@Override
|
||||
protected void cleanup() {
|
||||
Freeze.thawPlayer(player.getUniqueId());
|
||||
getContext().getFreezeManager().getSession(player.getUniqueId()).thaw();
|
||||
for (FallingBlock block : spawnedAnvils) {
|
||||
if (!block.isDead()) {
|
||||
block.remove();
|
||||
@@ -1,8 +1,7 @@
|
||||
package me.trouper.clonedupecore.server.punishment.animations;
|
||||
package me.trouper.clonedupecore.server.systems.punishment.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.alias.server.systems.freeze.FreezeSession;
|
||||
import me.trouper.alias.utils.VectorUtils;
|
||||
import me.trouper.clonedupecore.server.punishment.Freeze;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
@@ -27,8 +26,7 @@ public class GwenAnimation extends PunishmentAnimation {
|
||||
|
||||
@Override
|
||||
protected void tick(int ticksElapsed) {
|
||||
Freeze.quickFreeze(player);
|
||||
|
||||
new FreezeSession.Builder(getContext(),player.getUniqueId(),player.getLocation()).build().start();
|
||||
Location head = player.getEyeLocation();
|
||||
Location center = head.clone().add(0, 3, 0);
|
||||
World w = head.getWorld();
|
||||
@@ -37,7 +35,7 @@ public class GwenAnimation extends PunishmentAnimation {
|
||||
head.getWorld().spawnParticle(Particle.EXPLOSION_EMITTER,head,10,1,1,1);
|
||||
head.getWorld().strikeLightningEffect(head);
|
||||
|
||||
Verbose.send("Closing G.W.E.N. animation");
|
||||
getVerbose().send("Closing G.W.E.N. animation");
|
||||
close();
|
||||
return;
|
||||
}
|
||||
@@ -86,7 +84,7 @@ public class GwenAnimation extends PunishmentAnimation {
|
||||
|
||||
@Override
|
||||
protected void cleanup() {
|
||||
Freeze.thawPlayer(player.getUniqueId());
|
||||
getContext().getFreezeManager().getSession(player.getUniqueId()).thaw();
|
||||
|
||||
for (Entity entity : guardians) {
|
||||
if (entity == null) continue;
|
||||
@@ -1,8 +1,6 @@
|
||||
package me.trouper.clonedupecore.server.punishment.animations;
|
||||
package me.trouper.clonedupecore.server.systems.punishment.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.tracing.BlockDisplayRaytracer;
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.clonedupecore.server.punishment.Freeze;
|
||||
import me.trouper.alias.server.systems.freeze.FreezeSession;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -19,7 +17,7 @@ public class LaserAnimation extends PunishmentAnimation {
|
||||
|
||||
@Override
|
||||
protected void tick(int ticksElapsed) {
|
||||
Freeze.quickFreeze(player);
|
||||
new FreezeSession.Builder(getContext(),player.getUniqueId(),player.getLocation()).build().start();
|
||||
Location target = player.getEyeLocation();
|
||||
Location center = player.getLocation();
|
||||
|
||||
@@ -29,12 +27,12 @@ public class LaserAnimation extends PunishmentAnimation {
|
||||
}
|
||||
|
||||
if (ticksElapsed == 1) {
|
||||
DisplayUtils.sphereWave(target,8,1,1,(point)->{
|
||||
getContext().getDisplayManager().getPatterns().sphereWave(target,8,1,1,(point)->{
|
||||
point.getWorld().spawnParticle(Particle.SMOKE,point,2,0.5,0.5,0.5,0.01);
|
||||
point.getWorld().spawnParticle(Particle.FLAME,point,2,0.5,0.5,0.5,0.01);
|
||||
});
|
||||
|
||||
DisplayUtils.wave(player.getLocation().clone().add(0,0.5,0),5,point -> {
|
||||
getContext().getDisplayManager().getPatterns().wave(player.getLocation().clone().add(0,0.5,0),5,point -> {
|
||||
Block block = point.getWorld().getBlockAt(point.clone().subtract(0,2,0));
|
||||
point.getWorld().spawn(point, FallingBlock.class,(launched)->{
|
||||
launched.setVelocity(point.toVector().subtract(center.toVector()).normalize().multiply(0.4).setY(1));
|
||||
@@ -51,14 +49,14 @@ public class LaserAnimation extends PunishmentAnimation {
|
||||
Location orbit = player.getLocation().clone().add(200-ticksElapsed*2,0,100);
|
||||
orbit.setY(315);
|
||||
|
||||
Bukkit.getScheduler().runTask(main.getPlugin(),()->{
|
||||
BlockDisplayRaytracer.trace(Material.SMOOTH_QUARTZ,target,orbit,0.5,2);
|
||||
BlockDisplayRaytracer.trace(Material.RED_STAINED_GLASS,target,orbit,1 + main.random().nextDouble(),2);
|
||||
Bukkit.getScheduler().runTask(getPlugin(),()->{
|
||||
getDisplayManager().getBlockDisplayRaytracer().trace(Material.SMOOTH_QUARTZ,target,orbit,0.5,2);
|
||||
getDisplayManager().getBlockDisplayRaytracer().trace(Material.RED_STAINED_GLASS,target,orbit,1 + random().nextDouble(),2);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanup() {
|
||||
Freeze.thawPlayer(player.getUniqueId());
|
||||
getContext().getFreezeManager().getSession(player.getUniqueId()).thaw();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package me.trouper.clonedupecore.server.punishment.animations;
|
||||
package me.trouper.clonedupecore.server.systems.punishment.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.visual.ParticleUtils;
|
||||
import me.trouper.alias.server.systems.freeze.FreezeSession;
|
||||
import me.trouper.alias.utils.ParticleUtils;
|
||||
import me.trouper.alias.utils.SoundPlayer;
|
||||
import me.trouper.clonedupecore.server.punishment.Freeze;
|
||||
import me.trouper.clonedupecore.server.trolls.DragTrollWand;
|
||||
import me.trouper.clonedupecore.server.systems.trolls.DragTrollWand;
|
||||
import me.trouper.clonedupecore.utils.PlayerUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -21,7 +21,7 @@ public class LightningAnimation extends PunishmentAnimation {
|
||||
|
||||
@Override
|
||||
protected void tick(int ticksElapsed) {
|
||||
Freeze.quickFreeze(player);
|
||||
new FreezeSession.Builder(getContext(),player.getUniqueId(),player.getLocation()).build().start();
|
||||
Location cloudCenter = player.getLocation().clone().add(0,10,0);
|
||||
ParticleUtils.builder()
|
||||
.type(Particle.CLOUD)
|
||||
@@ -34,8 +34,8 @@ public class LightningAnimation extends PunishmentAnimation {
|
||||
.offset(0.3,1,0.3)
|
||||
.spawn(player.getLocation().clone().add(0,1,0));
|
||||
|
||||
double x = main.randomizer().getRandomDouble(-4,4);
|
||||
double z = main.randomizer().getRandomDouble(-4,4);
|
||||
double x = randomizer().getRandomDouble(-4,4);
|
||||
double z = randomizer().getRandomDouble(-4,4);
|
||||
Location lightningLoc = cloudCenter.clone().add(x,0,z);
|
||||
|
||||
if (ticksElapsed > 40) {
|
||||
@@ -44,7 +44,7 @@ public class LightningAnimation extends PunishmentAnimation {
|
||||
new SoundPlayer(Sound.ENTITY_LIGHTNING_BOLT_IMPACT,1,1).playAt(player.getLocation(),30);
|
||||
new SoundPlayer(Sound.ENTITY_LIGHTNING_BOLT_THUNDER,1,1).playAt(lightningLoc,30);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
DragTrollWand.drawLightning(lightningLoc,player.getEyeLocation(), Material.BLUE_ICE, Material.LIGHT_BLUE_STAINED_GLASS);
|
||||
new DragTrollWand().drawLightning(lightningLoc,player.getEyeLocation(), Material.BLUE_ICE, Material.LIGHT_BLUE_STAINED_GLASS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,6 @@ public class LightningAnimation extends PunishmentAnimation {
|
||||
|
||||
@Override
|
||||
protected void cleanup() {
|
||||
Freeze.thawPlayer(player.getUniqueId());
|
||||
getContext().getFreezeManager().getSession(player.getUniqueId()).thaw();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package me.trouper.clonedupecore.server.punishment.animations;
|
||||
package me.trouper.clonedupecore.server.systems.punishment.animations;
|
||||
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.clonedupecore.server.punishment.Freeze;
|
||||
import me.trouper.clonedupecore.server.trolls.DragTrollWand;
|
||||
import me.trouper.clonedupecore.server.trolls.MatrixTroll;
|
||||
import org.bukkit.Bukkit;
|
||||
import me.trouper.alias.server.systems.freeze.FreezeSession;
|
||||
import me.trouper.clonedupecore.server.systems.trolls.DragTrollWand;
|
||||
import me.trouper.clonedupecore.server.systems.trolls.MatrixTroll;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -16,12 +14,9 @@ import org.bukkit.entity.TextDisplay;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Transformation;
|
||||
import org.joml.AxisAngle4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@@ -43,16 +38,16 @@ public class MatrixAnimation extends PunishmentAnimation{
|
||||
center.setPitch(0);
|
||||
|
||||
ThreadLocalRandom random = ThreadLocalRandom.current();
|
||||
DragTrollWand.drawLightning(center,center.clone().add(
|
||||
new DragTrollWand().drawLightning(center,center.clone().add(
|
||||
random.nextDouble(-8,8),
|
||||
random.nextDouble(0,8),
|
||||
random.nextDouble(-8,8)
|
||||
), Material.LIME_CONCRETE,Material.LIME_STAINED_GLASS);
|
||||
|
||||
if (ticksElapsed != 1) return;
|
||||
Freeze.quickFreeze(player);
|
||||
new FreezeSession.Builder(getContext(),player.getUniqueId(),player.getLocation()).build().start();
|
||||
|
||||
DisplayUtils.sphereWave(center,5,0.5,2,(point)->{
|
||||
getContext().getDisplayManager().getPatterns().sphereWave(center,5,0.5,2,(point)->{
|
||||
TextDisplay display = point.getWorld().spawn(point,TextDisplay.class,(td)->{
|
||||
td.text(MatrixTroll.generateMatrix(2,2));
|
||||
td.setBillboard(Display.Billboard.FIXED);
|
||||
@@ -69,7 +64,7 @@ public class MatrixAnimation extends PunishmentAnimation{
|
||||
td.setBrightness(new Display.Brightness(15,15));
|
||||
});
|
||||
|
||||
ScheduledTask task = display.getScheduler().runAtFixedRate(main.getPlugin(),(t)->{
|
||||
ScheduledTask task = display.getScheduler().runAtFixedRate(getPlugin(),(t)->{
|
||||
float yawDegrees = random.nextFloat() * 360;
|
||||
float yawRadians = (float) Math.toRadians(yawDegrees);
|
||||
AxisAngle4f angle = new AxisAngle4f(yawRadians,0,1,0);
|
||||
@@ -88,7 +83,7 @@ public class MatrixAnimation extends PunishmentAnimation{
|
||||
|
||||
@Override
|
||||
protected void cleanup() {
|
||||
Freeze.thawPlayer(player.getUniqueId());
|
||||
getContext().getFreezeManager().getSession(player.getUniqueId()).thaw();
|
||||
for (Map.Entry<Entity, ScheduledTask> entry : cleanupList.entrySet()) {
|
||||
entry.getValue().cancel();
|
||||
entry.getKey().remove();
|
||||
@@ -1,7 +1,6 @@
|
||||
package me.trouper.clonedupecore.server.punishment.animations;
|
||||
package me.trouper.clonedupecore.server.systems.punishment.animations;
|
||||
|
||||
import me.trouper.alias.server.Main;
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -9,7 +8,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
public abstract class PunishmentAnimation extends BukkitRunnable implements Closeable, Main {
|
||||
public abstract class PunishmentAnimation extends BukkitRunnable implements Closeable, CloneDupeContext {
|
||||
|
||||
protected final JavaPlugin plugin;
|
||||
protected final String playerName;
|
||||
@@ -28,7 +27,7 @@ public abstract class PunishmentAnimation extends BukkitRunnable implements Clos
|
||||
this.playerName = player.getName();
|
||||
this.finishTask = finishTask;
|
||||
|
||||
Verbose.send("Animation created, running task timer...");
|
||||
getVerbose().send("Animation created, running task timer...");
|
||||
runTaskTimer(plugin, 0L, 1L);
|
||||
}
|
||||
|
||||
@@ -43,19 +42,19 @@ public abstract class PunishmentAnimation extends BukkitRunnable implements Clos
|
||||
|
||||
this.player = Bukkit.getPlayerExact(playerName);
|
||||
if (this.player == null || !this.player.isOnline()) {
|
||||
Verbose.send("Finishing animation due to player logging off!");
|
||||
getVerbose().send("Finishing animation due to player logging off!");
|
||||
finishAnimation();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Bukkit.getScheduler().runTask(main.getPlugin(),()->{
|
||||
Bukkit.getScheduler().runTask(getPlugin(),()->{
|
||||
tick(ticksElapsed++);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Verbose.send("An animation experienced an unexpected runtime exception while ticking.");
|
||||
getVerbose().send("An animation experienced an unexpected runtime exception while ticking.");
|
||||
e.printStackTrace();
|
||||
Bukkit.getScheduler().runTask(main.getPlugin(), this::finishAnimation);
|
||||
Bukkit.getScheduler().runTask(getPlugin(), this::finishAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,4 +89,5 @@ public abstract class PunishmentAnimation extends BukkitRunnable implements Clos
|
||||
public boolean isFinished() {
|
||||
return finished;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
package me.trouper.clonedupecore.server.trims;
|
||||
package me.trouper.clonedupecore.server.systems.trims;
|
||||
|
||||
import me.trouper.alias.server.Main;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class MaterialAnimation implements Main {
|
||||
public abstract class MaterialAnimation implements CloneDupeContext {
|
||||
|
||||
|
||||
private final ValidMaterial material;
|
||||
private final long loopDuration;
|
||||
|
||||
@@ -26,4 +28,4 @@ public abstract class MaterialAnimation implements Main {
|
||||
public abstract void tickMoving(Player player, Set<Player> viewers, long loopTime);
|
||||
public abstract void tickStationary(Player player, Set<Player> viewers, long loopTime);
|
||||
public abstract void onRemove(OfflinePlayer player);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package me.trouper.clonedupecore.server.trims;
|
||||
package me.trouper.clonedupecore.server.systems.trims;
|
||||
|
||||
import me.trouper.alias.server.Registrar;
|
||||
import me.trouper.alias.server.events.QuickListener;
|
||||
import me.trouper.alias.server.events.Registrar;
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.clonedupecore.data.Data;
|
||||
import me.trouper.clonedupecore.server.systems.trims.animations.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -23,13 +23,26 @@ public class TrimManager implements QuickListener, Data {
|
||||
private final ConcurrentHashMap<UUID, MaterialAnimation> lastAnimationMap = new ConcurrentHashMap<>();
|
||||
private final Set<UUID> isStationary = new HashSet<>();
|
||||
|
||||
public void register(MaterialAnimation animation) {
|
||||
public TrimManager() {
|
||||
this.addAnimation(new AmethystAnimation());
|
||||
this.addAnimation(new CopperAnimation());
|
||||
this.addAnimation(new DiamondAnimation());
|
||||
this.addAnimation(new EmeraldAnimation());
|
||||
this.addAnimation(new GoldAnimation());
|
||||
this.addAnimation(new IronAnimation());
|
||||
this.addAnimation(new LapisAnimation());
|
||||
this.addAnimation(new NetheriteAnimation());
|
||||
this.addAnimation(new QuartzAnimation());
|
||||
this.addAnimation(new RedstoneAnimation());
|
||||
}
|
||||
|
||||
public void addAnimation(MaterialAnimation animation) {
|
||||
allAnimations.add(animation);
|
||||
}
|
||||
|
||||
public void startTicking() {
|
||||
AtomicInteger globalTime = new AtomicInteger(0);
|
||||
Bukkit.getScheduler().runTaskTimer(main.getPlugin(), () -> {
|
||||
Bukkit.getScheduler().runTaskTimer(getPlugin(), () -> {
|
||||
Bukkit.getOnlinePlayers().forEach(player->{
|
||||
if (!player.isOnline()) return;
|
||||
tickPlayer(player, globalTime.get());
|
||||
@@ -44,7 +57,7 @@ public class TrimManager implements QuickListener, Data {
|
||||
if (!player.isOnline()) return;
|
||||
if (activeAnimation == null && lastAnimationMap.containsKey(playerId)) {
|
||||
MaterialAnimation lastAnimation = lastAnimationMap.remove(playerId);
|
||||
Verbose.send("Player has no active animation, removing and stopping {0}, their last active animation.", lastAnimation.getMaterial().name());
|
||||
getVerbose().send("Player has no active animation, removing and stopping {0}, their last active animation.", lastAnimation.getMaterial().name());
|
||||
lastAnimation.onRemove(player);
|
||||
return;
|
||||
}
|
||||
@@ -85,7 +98,7 @@ public class TrimManager implements QuickListener, Data {
|
||||
|
||||
public void tick(Location currentLocation) {
|
||||
long now = System.currentTimeMillis();
|
||||
if (lastLocation.distanceSquared(currentLocation) > 0.01) {
|
||||
if (!currentLocation.getWorld().getName().equals(lastLocation.getWorld().getName()) || lastLocation.distanceSquared(currentLocation) > 0.01) {
|
||||
lastMovedTime = now;
|
||||
}
|
||||
isStationary = (now - lastMovedTime) >= 1000;
|
||||
@@ -121,13 +134,13 @@ public class TrimManager implements QuickListener, Data {
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
UUID playerId = player.getUniqueId();
|
||||
Verbose.send("{0} has quit!",player.getName());
|
||||
getVerbose().send("{0} has quit!",player.getName());
|
||||
if (lastAnimationMap.containsKey(playerId)) {
|
||||
MaterialAnimation lastAnimation = lastAnimationMap.get(playerId);
|
||||
Verbose.send("Last animation for {0} is {1}.",player.getName(),lastAnimation.getMaterial().name());
|
||||
getVerbose().send("Last animation for {0} is {1}.",player.getName(),lastAnimation.getMaterial().name());
|
||||
lastAnimation.onRemove(player);
|
||||
} else {
|
||||
Verbose.send("{0} had no active animations.",player.getName());
|
||||
getVerbose().send("{0} had no active animations.",player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.trouper.clonedupecore.server.trims;
|
||||
package me.trouper.clonedupecore.server.systems.trims;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
@@ -38,7 +38,7 @@ public enum ValidArmorType {
|
||||
return boots;
|
||||
}
|
||||
|
||||
public static ValidArmorType validate(Material armor) {
|
||||
public ValidArmorType validate(Material armor) {
|
||||
for (ValidArmorType value : values()) {
|
||||
if (value.helmet.equals(armor) || value.chestplate.equals(armor) || value.leggings.equals(armor) || value.boots.equals(armor)) return value;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.trouper.clonedupecore.server.trims;
|
||||
package me.trouper.clonedupecore.server.systems.trims;
|
||||
|
||||
import me.trouper.clonedupecore.utils.ArmorUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -1,9 +1,8 @@
|
||||
package me.trouper.clonedupecore.server.trims.animations;
|
||||
package me.trouper.clonedupecore.server.systems.trims.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.alias.server.systems.visual.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.trims.ValidMaterial;
|
||||
import me.trouper.alias.utils.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.systems.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.systems.trims.ValidMaterial;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -36,7 +35,7 @@ public class AmethystAnimation extends MaterialAnimation {
|
||||
double phase = (loopTime / (double) LOOP_DURATION) * 2 * Math.PI;
|
||||
double radius = 1.5 + 0.5 * Math.sin(phase * 2);
|
||||
|
||||
DisplayUtils.ring(playerLoc, radius, (point)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(playerLoc, radius, (point)->{
|
||||
ParticleUtils.builder()
|
||||
.type(Particle.DUST)
|
||||
.data(new Particle.DustOptions(AMETHYST_COLOR,1F))
|
||||
@@ -59,7 +58,7 @@ public class AmethystAnimation extends MaterialAnimation {
|
||||
}
|
||||
|
||||
if (loopTime % 20 == 0) {
|
||||
DisplayUtils.helix(playerLoc.clone().subtract(0, 0.5, 0), 0.8, (loc)->{
|
||||
getContext().getDisplayManager().getPatterns().helix(playerLoc.clone().subtract(0, 0.5, 0), 0.8, (loc)->{
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.DUST)
|
||||
@@ -1,10 +1,12 @@
|
||||
package me.trouper.clonedupecore.server.trims.animations;
|
||||
package me.trouper.clonedupecore.server.systems.trims.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.alias.server.systems.visual.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.trims.ValidMaterial;
|
||||
import org.bukkit.*;
|
||||
import me.trouper.alias.utils.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.systems.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.systems.trims.ValidMaterial;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Transformation;
|
||||
@@ -48,11 +50,11 @@ public class CopperAnimation extends MaterialAnimation {
|
||||
BlockDisplay display = player.getWorld().spawn(loc, BlockDisplay.class,disp->{
|
||||
disp.setVisibleByDefault(false);
|
||||
viewers.forEach(viewer->{
|
||||
viewer.showEntity(main.getPlugin(),disp);
|
||||
viewer.showEntity(getContext().getPlugin(),disp);
|
||||
});
|
||||
});
|
||||
display.setBlock(Material.COPPER_BLOCK.createBlockData());
|
||||
display.addScoreboardTag(main.getCommon().getTempTag());
|
||||
display.addScoreboardTag(getContext().getCommon().getTempTag());
|
||||
display.setInterpolationDuration(1);
|
||||
display.setInterpolationDelay(0);
|
||||
list.add(display);
|
||||
@@ -87,7 +89,7 @@ public class CopperAnimation extends MaterialAnimation {
|
||||
|
||||
if (loopTime % 25 == 0) {
|
||||
Location groundLoc = player.getLocation();
|
||||
DisplayUtils.wave(groundLoc, 4.0, 1.2f, 0.5, (point) -> {
|
||||
getContext().getDisplayManager().getPatterns().wave(groundLoc, 4.0, 1.2f, 0.5, (point) -> {
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.BLOCK)
|
||||
@@ -98,7 +100,7 @@ public class CopperAnimation extends MaterialAnimation {
|
||||
|
||||
if (loopTime % 15 == 0) {
|
||||
Location groundLoc = player.getLocation();
|
||||
DisplayUtils.wave(groundLoc, 2.0, 0.4f, 0.2, (point) -> {
|
||||
getContext().getDisplayManager().getPatterns().wave(groundLoc, 2.0, 0.4f, 0.2, (point) -> {
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.WAX_ON)
|
||||
@@ -1,9 +1,8 @@
|
||||
package me.trouper.clonedupecore.server.trims.animations;
|
||||
package me.trouper.clonedupecore.server.systems.trims.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.alias.server.systems.visual.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.trims.ValidMaterial;
|
||||
import me.trouper.alias.utils.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.systems.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.systems.trims.ValidMaterial;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -48,12 +47,12 @@ public class DiamondAnimation extends MaterialAnimation {
|
||||
BlockDisplay display = player.getWorld().spawn(initialLoc, BlockDisplay.class,disp->{
|
||||
disp.setVisibleByDefault(false);
|
||||
viewers.forEach(viewer->{
|
||||
viewer.showEntity(main.getPlugin(),disp);
|
||||
viewer.showEntity(getContext().getPlugin(),disp);
|
||||
});
|
||||
});
|
||||
|
||||
display.setBlock(Material.DIAMOND_BLOCK.createBlockData());
|
||||
display.addScoreboardTag(main.getCommon().getTempTag());
|
||||
display.addScoreboardTag(getContext().getCommon().getTempTag());
|
||||
display.setInterpolationDuration(1);
|
||||
display.setInterpolationDelay(0);
|
||||
list.add(display);
|
||||
@@ -1,12 +1,10 @@
|
||||
package me.trouper.clonedupecore.server.trims.animations;
|
||||
package me.trouper.clonedupecore.server.systems.trims.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.alias.server.systems.visual.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.trims.ValidMaterial;
|
||||
import me.trouper.alias.utils.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.systems.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.systems.trims.ValidMaterial;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -55,7 +53,7 @@ public class EmeraldAnimation extends MaterialAnimation {
|
||||
|
||||
double pulsePhase = (loopTime % 30) / 30.0 * 2 * Math.PI;
|
||||
double pulseRadius = 2.0 + 0.5 * Math.sin(pulsePhase);
|
||||
DisplayUtils.ring(playerLoc, pulseRadius,0.9,(loc)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(playerLoc, pulseRadius,0.9,(loc)->{
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.HAPPY_VILLAGER)
|
||||
@@ -1,9 +1,8 @@
|
||||
package me.trouper.clonedupecore.server.trims.animations;
|
||||
package me.trouper.clonedupecore.server.systems.trims.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.alias.server.systems.visual.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.trims.ValidMaterial;
|
||||
import me.trouper.alias.utils.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.systems.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.systems.trims.ValidMaterial;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -19,7 +18,7 @@ public class GoldAnimation extends MaterialAnimation {
|
||||
|
||||
@Override
|
||||
public void tickMoving(Player player, Set<Player> viewers, long loopTime) {
|
||||
DisplayUtils.ring(player.getLocation().clone().add(0, 2.1, 0), 0.3, 0.5f,(point)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(player.getLocation().clone().add(0, 2.1, 0), 0.3, 0.5f,(point)->{
|
||||
ParticleUtils.builder()
|
||||
.type(Particle.DUST)
|
||||
.data(new Particle.DustOptions(GOLD_COLOR,0.3F))
|
||||
@@ -42,7 +41,7 @@ public class GoldAnimation extends MaterialAnimation {
|
||||
|
||||
double crownAngle = (loopTime / (double) LOOP_DURATION) * 2 * Math.PI;
|
||||
|
||||
DisplayUtils.ring(player.getLocation().clone().add(0, 2.1, 0), 0.3, 0.5f,(point)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(player.getLocation().clone().add(0, 2.1, 0), 0.3, 0.5f,(point)->{
|
||||
ParticleUtils.builder()
|
||||
.type(Particle.DUST)
|
||||
.data(new Particle.DustOptions(GOLD_COLOR,0.5F))
|
||||
@@ -73,7 +72,7 @@ public class GoldAnimation extends MaterialAnimation {
|
||||
double ringPhase = wealthPhase + ring * Math.PI / 2;
|
||||
double ringHeight = Math.sin(ringPhase) * 0.3;
|
||||
|
||||
DisplayUtils.ring(playerLoc.clone().add(0, ringHeight + 0.6, 0), ringRadius, 0.8f,(loc)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(playerLoc.clone().add(0, ringHeight + 0.6, 0), ringRadius, 0.8f,(loc)->{
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.DUST)
|
||||
@@ -1,9 +1,9 @@
|
||||
package me.trouper.clonedupecore.server.trims.animations;
|
||||
package me.trouper.clonedupecore.server.systems.trims.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.alias.server.systems.visual.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.trims.ValidMaterial;
|
||||
import me.trouper.alias.utils.ParticleUtils;
|
||||
import me.trouper.alias.utils.misc.Randomizer;
|
||||
import me.trouper.clonedupecore.server.systems.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.systems.trims.ValidMaterial;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.ItemDisplay;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -58,11 +58,11 @@ public class IronAnimation extends MaterialAnimation {
|
||||
ItemDisplay shield = player.getWorld().spawn(initialLoc, ItemDisplay.class,disp->{
|
||||
disp.setVisibleByDefault(false);
|
||||
viewers.forEach(viewer->{
|
||||
viewer.showEntity(main.getPlugin(),disp);
|
||||
viewer.showEntity(getContext().getPlugin(),disp);
|
||||
});
|
||||
});
|
||||
shield.setItemStack(new ItemStack(main.randomizer().getRandomElement(IRON_ITEMS)));
|
||||
shield.addScoreboardTag(main.getCommon().getTempTag());
|
||||
shield.setItemStack(new ItemStack(new Randomizer().getRandomElement(IRON_ITEMS)));
|
||||
shield.addScoreboardTag(getContext().getCommon().getTempTag());
|
||||
shield.setInterpolationDuration(1);
|
||||
shield.setInterpolationDelay(0);
|
||||
list.add(shield);
|
||||
@@ -112,7 +112,7 @@ public class IronAnimation extends MaterialAnimation {
|
||||
}
|
||||
|
||||
if (loopTime % 30 == 0) {
|
||||
DisplayUtils.wave(playerLoc, 3.5, loc->{
|
||||
getContext().getDisplayManager().getPatterns().wave(playerLoc, 3.5, loc->{
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.DUST)
|
||||
@@ -123,7 +123,7 @@ public class IronAnimation extends MaterialAnimation {
|
||||
|
||||
if (loopTime % 5 == 0) {
|
||||
Location dustLoc = playerLoc.clone().add(0, 0.1, 0);
|
||||
DisplayUtils.ring(dustLoc, 1.8, 0.18,(loc)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(dustLoc, 1.8, 0.18,(loc)->{
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.BLOCK)
|
||||
@@ -1,9 +1,8 @@
|
||||
package me.trouper.clonedupecore.server.trims.animations;
|
||||
package me.trouper.clonedupecore.server.systems.trims.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.alias.server.systems.visual.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.trims.ValidMaterial;
|
||||
import me.trouper.alias.utils.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.systems.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.systems.trims.ValidMaterial;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -19,7 +18,7 @@ public class LapisAnimation extends MaterialAnimation {
|
||||
|
||||
@Override
|
||||
public void tickMoving(Player player, Set<Player> viewers, long loopTime) {
|
||||
DisplayUtils.ring(player.getLocation().clone().add(0, 2.1, 0), 0.3, 0.5f,(point)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(player.getLocation().clone().add(0, 2.1, 0), 0.3, 0.5f,(point)->{
|
||||
ParticleUtils.builder()
|
||||
.type(Particle.ENCHANT)
|
||||
.viewers(viewers)
|
||||
@@ -41,7 +40,7 @@ public class LapisAnimation extends MaterialAnimation {
|
||||
|
||||
double magicAngle = (loopTime / (double) LOOP_DURATION) * 2 * Math.PI;
|
||||
|
||||
DisplayUtils.ring(player.getLocation().clone().add(0, 2.1, 0), 0.3, 0.5f,(point)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(player.getLocation().clone().add(0, 2.1, 0), 0.3, 0.5f,(point)->{
|
||||
ParticleUtils.builder()
|
||||
.type(Particle.ENCHANT)
|
||||
.viewers(viewers)
|
||||
@@ -59,7 +58,7 @@ public class LapisAnimation extends MaterialAnimation {
|
||||
int startAngle = (int)(Math.toDegrees(circleAngle) + segment * 60);
|
||||
int endAngle = startAngle + 30;
|
||||
|
||||
DisplayUtils.arc(circleCenter, circleRadius, startAngle, endAngle, 0.2, (loc)->{
|
||||
getContext().getDisplayManager().getPatterns().arc(circleCenter, circleRadius, startAngle, endAngle, 0.2, (loc)->{
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.DUST)
|
||||
@@ -93,7 +92,7 @@ public class LapisAnimation extends MaterialAnimation {
|
||||
}
|
||||
|
||||
if (loopTime % 15 == 0) {
|
||||
DisplayUtils.vortex(playerLoc.clone().subtract(0, 0.5, 0), 0.8,(loc)->{
|
||||
getContext().getDisplayManager().getPatterns().vortex(playerLoc.clone().subtract(0, 0.5, 0), 0.8,(loc)->{
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.DUST)
|
||||
@@ -122,7 +121,7 @@ public class LapisAnimation extends MaterialAnimation {
|
||||
(int)(181 * pulseIntensity + 255 * (1 - pulseIntensity))
|
||||
);
|
||||
|
||||
DisplayUtils.ring(playerLoc, 2.2, (loc)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(playerLoc, 2.2, (loc)->{
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.DUST)
|
||||
@@ -1,10 +1,8 @@
|
||||
package me.trouper.clonedupecore.server.trims.animations;
|
||||
package me.trouper.clonedupecore.server.systems.trims.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.alias.server.systems.visual.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.trims.ValidMaterial;
|
||||
import me.trouper.alias.utils.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.systems.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.systems.trims.ValidMaterial;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -44,18 +42,18 @@ public class NetheriteAnimation extends MaterialAnimation {
|
||||
double angle = (loopTime / (double) LOOP_DURATION) * 2 * Math.PI;
|
||||
|
||||
List<BlockDisplay> displays = activeDisplays.computeIfAbsent(playerId, id -> {
|
||||
Verbose.send("{0} needed new BlockDisplays",player.getName());
|
||||
getVerbose().send("{0} needed new BlockDisplays",player.getName());
|
||||
List<BlockDisplay> list = new ArrayList<>();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Location initialLoc = player.getLocation().add(0, 1, 0);
|
||||
BlockDisplay display = player.getWorld().spawn(initialLoc, BlockDisplay.class,disp->{
|
||||
disp.setVisibleByDefault(false);
|
||||
viewers.forEach(viewer->{
|
||||
viewer.showEntity(main.getPlugin(),disp);
|
||||
viewer.showEntity(getContext().getPlugin(),disp);
|
||||
});
|
||||
});
|
||||
display.setBlock(Material.NETHERITE_BLOCK.createBlockData());
|
||||
display.addScoreboardTag(main.getCommon().getTempTag());
|
||||
display.addScoreboardTag(getContext().getCommon().getTempTag());
|
||||
display.setInterpolationDuration(1);
|
||||
display.setInterpolationDelay(0);
|
||||
list.add(display);
|
||||
@@ -99,7 +97,7 @@ public class NetheriteAnimation extends MaterialAnimation {
|
||||
}
|
||||
|
||||
if (loopTime % 50 == 0) {
|
||||
DisplayUtils.fanWaveRandom(playerLoc, 4.5, 8, (loc)->{
|
||||
getContext().getDisplayManager().getPatterns().fanWaveRandom(playerLoc, 4.5, 8, (loc)->{
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.DUST)
|
||||
@@ -110,7 +108,7 @@ public class NetheriteAnimation extends MaterialAnimation {
|
||||
|
||||
double auraPhase = (loopTime % 60) / 60.0 * 2 * Math.PI;
|
||||
double auraRadius = 2.8 + 0.7 * Math.sin(auraPhase * 2);
|
||||
DisplayUtils.ring(playerLoc.clone().add(0, 0.2, 0), auraRadius,0.8, (loc)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(playerLoc.clone().add(0, 0.2, 0), auraRadius,0.8, (loc)->{
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.FLAME)
|
||||
@@ -1,17 +1,10 @@
|
||||
package me.trouper.clonedupecore.server.trims.animations;
|
||||
package me.trouper.clonedupecore.server.systems.trims.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.TaskManager;
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.alias.server.systems.visual.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.trims.ValidMaterial;
|
||||
import me.trouper.alias.utils.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.systems.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.systems.trims.ValidMaterial;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Transformation;
|
||||
import org.joml.AxisAngle4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -72,7 +65,7 @@ public class QuartzAnimation extends MaterialAnimation {
|
||||
double ringPhase = purifyPhase + ring * Math.PI;
|
||||
double ringHeight = Math.sin(ringPhase) * 0.4;
|
||||
|
||||
DisplayUtils.ring(playerLoc.clone().add(0, ringHeight, 0), ringRadius,(point)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(playerLoc.clone().add(0, ringHeight, 0), ringRadius,(point)->{
|
||||
ParticleUtils.builder()
|
||||
.type(Particle.DUST)
|
||||
.data(new Particle.DustOptions(QUARTZ_COLOR,1F))
|
||||
@@ -1,9 +1,8 @@
|
||||
package me.trouper.clonedupecore.server.trims.animations;
|
||||
package me.trouper.clonedupecore.server.systems.trims.animations;
|
||||
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.alias.server.systems.visual.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.trims.ValidMaterial;
|
||||
import me.trouper.alias.utils.ParticleUtils;
|
||||
import me.trouper.clonedupecore.server.systems.trims.MaterialAnimation;
|
||||
import me.trouper.clonedupecore.server.systems.trims.ValidMaterial;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -69,7 +68,7 @@ public class RedstoneAnimation extends MaterialAnimation {
|
||||
Math.sin(torchAngle) * 2.2
|
||||
);
|
||||
|
||||
DisplayUtils.beam(torchLoc,
|
||||
getContext().getDisplayManager().getPatterns().beam(torchLoc,
|
||||
(loc)->{
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
@@ -81,7 +80,7 @@ public class RedstoneAnimation extends MaterialAnimation {
|
||||
}
|
||||
|
||||
if (loopTime % 30 == 0) {
|
||||
DisplayUtils.wave(playerLoc.clone(), 3.0, 0.8f, 0.4, (loc)->{
|
||||
getContext().getDisplayManager().getPatterns().wave(playerLoc.clone(), 3.0, 0.8f, 0.4, (loc)->{
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.ENCHANTED_HIT)
|
||||
@@ -111,7 +110,7 @@ public class RedstoneAnimation extends MaterialAnimation {
|
||||
(int)(50 * coreIntensity)
|
||||
);
|
||||
|
||||
DisplayUtils.ring(playerLoc, 1.2, 0.2f,(point)->{
|
||||
getContext().getDisplayManager().getPatterns().ring(playerLoc, 1.2, 0.2f,(point)->{
|
||||
ParticleUtils.builder()
|
||||
.viewers(viewers)
|
||||
.type(Particle.DUST)
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.trouper.clonedupecore.server.trolls;
|
||||
package me.trouper.clonedupecore.server.systems.trolls;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
@@ -1,11 +1,8 @@
|
||||
package me.trouper.clonedupecore.server.trolls;
|
||||
package me.trouper.clonedupecore.server.systems.trolls;
|
||||
|
||||
import me.trouper.alias.server.ContextAware;
|
||||
import me.trouper.alias.server.systems.AbstractWand;
|
||||
import me.trouper.alias.server.systems.Text;
|
||||
import me.trouper.alias.server.systems.tracing.BlockDisplayRaytracer;
|
||||
import me.trouper.alias.server.systems.tracing.CustomDisplayRaytracer;
|
||||
import me.trouper.alias.server.systems.tracing.Point;
|
||||
import me.trouper.alias.server.systems.visual.DisplayUtils;
|
||||
import me.trouper.alias.server.systems.display.tracing.Point;
|
||||
import me.trouper.alias.utils.ItemBuilder;
|
||||
import me.trouper.alias.utils.SoundPlayer;
|
||||
import me.trouper.clonedupecore.utils.PlayerUtils;
|
||||
@@ -19,7 +16,6 @@ import org.bukkit.damage.DamageType;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@@ -27,7 +23,7 @@ import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class DragTrollWand extends AbstractWand implements TrollFeature {
|
||||
public class DragTrollWand extends AbstractWand implements TrollFeature, ContextAware {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@@ -41,20 +37,18 @@ public class DragTrollWand extends AbstractWand implements TrollFeature {
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Gets a wand which you can use to controll players";
|
||||
return "Gets a wand which you can use to control players";
|
||||
}
|
||||
|
||||
public static final ItemStack DRAG_WAND = ItemBuilder.of(Material.BREEZE_ROD)
|
||||
.displayName(Component.text("Drag Wand", NamedTextColor.DARK_AQUA).decoration(TextDecoration.ITALIC,false).decoration(TextDecoration.BOLD,true))
|
||||
.loreComponent(
|
||||
Text.color("&1▪ &bRight-Click:&7 Select Player"),
|
||||
Text.color("&1▪ &bLeft-Click:&7 Throw"),
|
||||
Text.color("&1▪ &bSneak Left-Click:&7 Electrocute")
|
||||
)
|
||||
.build();
|
||||
|
||||
public DragTrollWand() {
|
||||
super("clonedupe.troll", DRAG_WAND);
|
||||
super("clonedupe.troll", ItemBuilder.of(Material.BREEZE_ROD)
|
||||
.displayName(Component.text("Drag Wand", NamedTextColor.DARK_AQUA).decoration(TextDecoration.ITALIC,false).decoration(TextDecoration.BOLD,true))
|
||||
.loreMiniMessage(
|
||||
("<dark_blue>▪ <aqua>Right-Click:<gray> Select Player"),
|
||||
("<dark_blue>▪ <aqua>Left-Click:<gray> Throw"),
|
||||
("<dark_blue>▪ <aqua>Sneak Left-Click:<gray> Electrocute")
|
||||
)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,22 +60,22 @@ public class DragTrollWand extends AbstractWand implements TrollFeature {
|
||||
private final Map<UUID, DragTask> playerDragMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
protected void onRightClick(Player player) {
|
||||
public void onRightClick(Player player) {
|
||||
handleDragPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLeftClick(Player player) {
|
||||
public void onLeftClick(Player player) {
|
||||
handleThrowPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLeftClickSneak(Player player) {
|
||||
public void onLeftClickSneak(Player player) {
|
||||
handleElectrocute(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScrollUp(Player p) {
|
||||
public void onScrollUp(Player p) {
|
||||
if (!playerDragMap.containsKey(p.getUniqueId())) return;
|
||||
DragTask task = playerDragMap.get(p.getUniqueId());
|
||||
|
||||
@@ -90,7 +84,7 @@ public class DragTrollWand extends AbstractWand implements TrollFeature {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScrollDown(Player p) {
|
||||
public void onScrollDown(Player p) {
|
||||
if (!playerDragMap.containsKey(p.getUniqueId())) return;
|
||||
DragTask task = playerDragMap.get(p.getUniqueId());
|
||||
|
||||
@@ -113,7 +107,7 @@ public class DragTrollWand extends AbstractWand implements TrollFeature {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomDisplayRaytracer.trace(user.getEyeLocation(),user.getEyeLocation().getDirection(),30,0.5, point -> {
|
||||
getDisplayManager().getCustomRaytracer().trace(user.getEyeLocation(),user.getEyeLocation().getDirection(),30,0.5, point -> {
|
||||
List<Entity> targets = point.getNearbyEntities(user,1, entity -> entity instanceof LivingEntity);
|
||||
if (targets.isEmpty()) return false;
|
||||
LivingEntity target = (LivingEntity) targets.getFirst();
|
||||
@@ -122,7 +116,7 @@ public class DragTrollWand extends AbstractWand implements TrollFeature {
|
||||
target.setGlowing(true);
|
||||
if (target instanceof Player t) t.setAllowFlight(true);
|
||||
|
||||
DisplayUtils.helix(target.getLocation(),0.6,(helix)->{
|
||||
getContext().getDisplayManager().getPatterns().helix(target.getLocation(),0.6,(helix)->{
|
||||
user.getWorld().spawnParticle(Particle.SOUL_FIRE_FLAME,helix,1,0,0,0,0);
|
||||
},0.02,2);
|
||||
|
||||
@@ -132,7 +126,7 @@ public class DragTrollWand extends AbstractWand implements TrollFeature {
|
||||
}
|
||||
|
||||
private DragTask startDragging(Player user, LivingEntity victim) {
|
||||
return new DragTask(victim.getUniqueId(), Bukkit.getScheduler().runTaskTimer(main.getPlugin(), () -> {
|
||||
return new DragTask(victim.getUniqueId(), Bukkit.getScheduler().runTaskTimer(getPlugin(), () -> {
|
||||
if (victim == null) {
|
||||
playerDragMap.remove(user.getUniqueId()).drop();
|
||||
return;
|
||||
@@ -144,7 +138,7 @@ public class DragTrollWand extends AbstractWand implements TrollFeature {
|
||||
|
||||
DragTask task = playerDragMap.get(user.getUniqueId());
|
||||
|
||||
Point point = CustomDisplayRaytracer.blocksInFrontOf(user.getEyeLocation(), user.getEyeLocation().getDirection(),task.getDistance(), false);
|
||||
Point point = getDisplayManager().getCustomRaytracer().blocksInFrontOf(user.getEyeLocation(), user.getEyeLocation().getDirection(),task.getDistance(), false);
|
||||
victim.teleport(point.getLoc().clone().subtract(0, 1, 0));
|
||||
|
||||
user.sendActionBar(Component.text("You ", NamedTextColor.GREEN).append(Component.text("⇄ ",NamedTextColor.WHITE)).append(Component.text(victim.getName(),NamedTextColor.AQUA)).append(Component.text(" | ",NamedTextColor.GRAY)).append(Component.text(Math.round(task.getDistance()),NamedTextColor.DARK_GREEN)));
|
||||
@@ -173,7 +167,7 @@ public class DragTrollWand extends AbstractWand implements TrollFeature {
|
||||
}
|
||||
|
||||
AtomicInteger ticksRemaining = new AtomicInteger(60);
|
||||
Bukkit.getScheduler().runTaskTimer(main.getPlugin(),(shockTask)->{
|
||||
Bukkit.getScheduler().runTaskTimer(getPlugin(),(shockTask)->{
|
||||
if (ticksRemaining.getAndDecrement() <= 0 || target == null) {
|
||||
shockTask.cancel();
|
||||
return;
|
||||
@@ -185,7 +179,7 @@ public class DragTrollWand extends AbstractWand implements TrollFeature {
|
||||
|
||||
}
|
||||
|
||||
public static void drawLightning(Location start, Location end, Material blockInner, Material blockOuter) {
|
||||
public void drawLightning(Location start, Location end, Material blockInner, Material blockOuter) {
|
||||
int segments = 10;
|
||||
double maxOffset = 0.5;
|
||||
long stayTime = 10L;
|
||||
@@ -208,13 +202,13 @@ public class DragTrollWand extends AbstractWand implements TrollFeature {
|
||||
);
|
||||
Location next = current.clone().add(direction).add(offset);
|
||||
|
||||
BlockDisplayRaytracer.trace(blockInner, current, next, thickness, stayTime, viewers);
|
||||
BlockDisplayRaytracer.trace(blockOuter, current, next, thicknessOut, stayTime, viewers);
|
||||
getDisplayManager().getBlockDisplayRaytracer().trace(blockInner, current, next, thickness, stayTime, viewers);
|
||||
getDisplayManager().getBlockDisplayRaytracer().trace(blockOuter, current, next, thicknessOut, stayTime, viewers);
|
||||
current = next;
|
||||
}
|
||||
|
||||
BlockDisplayRaytracer.trace(blockInner, current, end, thickness, stayTime, viewers);
|
||||
BlockDisplayRaytracer.trace(blockOuter, current, end, thicknessOut, stayTime, viewers);
|
||||
getDisplayManager().getBlockDisplayRaytracer().trace(blockInner, current, end, thickness, stayTime, viewers);
|
||||
getDisplayManager().getBlockDisplayRaytracer().trace(blockOuter, current, end, thicknessOut, stayTime, viewers);
|
||||
end.getWorld().spawnParticle(Particle.FLASH,end,0,0,0,0,0);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.trouper.clonedupecore.server.trolls;
|
||||
package me.trouper.clonedupecore.server.systems.trolls;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityAnimation;
|
||||
@@ -33,7 +33,7 @@ public class FlickerTroll implements TrollFeature {
|
||||
public void execute(CommandSender sender, Player target) {
|
||||
var player = PacketEvents.getAPI().getPlayerManager().getUser(target);
|
||||
eepyPlayers.add(target.getUniqueId());
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(main.getPlugin(), (t) -> {
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(getPlugin(), (t) -> {
|
||||
if (!eepyPlayers.contains(target.getUniqueId())) t.cancel();
|
||||
player.sendPacket(new WrapperPlayServerEntityAnimation(target.getEntityId(), WrapperPlayServerEntityAnimation.EntityAnimationType.WAKE_UP));
|
||||
}, 1, 1);
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.trouper.clonedupecore.server.trolls;
|
||||
package me.trouper.clonedupecore.server.systems.trolls;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
@@ -68,7 +68,7 @@ public class LSDTroll implements TrollFeature {
|
||||
final int radius = 8;
|
||||
AtomicInteger ticksPassed = new AtomicInteger(0);
|
||||
|
||||
lsdTasks.put(target.getUniqueId(),Bukkit.getScheduler().runTaskTimer(main.getPlugin(),()->{
|
||||
lsdTasks.put(target.getUniqueId(),Bukkit.getScheduler().runTaskTimer(getPlugin(),()->{
|
||||
if (!target.isOnline()) {
|
||||
try {
|
||||
lsdTasks.remove(target.getUniqueId()).cancel();
|
||||
@@ -1,17 +1,19 @@
|
||||
package me.trouper.clonedupecore.server.trolls;
|
||||
package me.trouper.clonedupecore.server.systems.trolls;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.protocol.player.User;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSetPlayerInventory;
|
||||
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
||||
import me.trouper.alias.server.systems.Text;
|
||||
import me.trouper.alias.utils.ItemBuilder;
|
||||
import me.trouper.alias.utils.SoundPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -53,7 +55,7 @@ public class LiarTroll implements TrollFeature {
|
||||
AtomicBoolean inverse = new AtomicBoolean(false);
|
||||
AtomicInteger timeRemaining = new AtomicInteger(15 * 20);
|
||||
|
||||
Bukkit.getScheduler().runTaskTimer(main.getPlugin(), (task)->{
|
||||
Bukkit.getScheduler().runTaskTimer(getPlugin(), (task)->{
|
||||
if (!activeLiars.containsKey(target.getUniqueId())) {
|
||||
task.cancel();
|
||||
return;
|
||||
@@ -79,15 +81,15 @@ public class LiarTroll implements TrollFeature {
|
||||
|
||||
WrapperPlayServerSetPlayerInventory packet = new WrapperPlayServerSetPlayerInventory(37,SpigotConversionUtil.fromBukkitItemStack(displayItem));
|
||||
Title title = Title.title(
|
||||
Text.color("&c⚠ &4&lWARNING &r&c⚠"),
|
||||
Text.color("&7&nLEGGINGS COMBUSTION EMINENT!"),
|
||||
getTextSystem().color("&c⚠ &4&lWARNING &r&c⚠"),
|
||||
getTextSystem().color("&7&nLEGGINGS COMBUSTION EMINENT!"),
|
||||
Title.Times.times(Duration.of(0, ChronoUnit.SECONDS),Duration.of(1, ChronoUnit.SECONDS),Duration.of(0, ChronoUnit.SECONDS))
|
||||
);
|
||||
|
||||
if (inverse.get()) {
|
||||
title = Title.title(
|
||||
Text.color("&e⚠ &4&l&nWARNING&r &e⚠"),
|
||||
Text.color("&7LEGGINGS COMBUSTION EMINENT!"),
|
||||
getTextSystem().color("&e⚠ &4&l&nWARNING&r &e⚠"),
|
||||
getTextSystem().color("&7LEGGINGS COMBUSTION EMINENT!"),
|
||||
Title.Times.times(Duration.of(0, ChronoUnit.SECONDS),Duration.of(1, ChronoUnit.SECONDS),Duration.of(0, ChronoUnit.SECONDS)))
|
||||
;
|
||||
ItemStack pants = displayItem.withType(Material.WHITE_WOOL);
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.trouper.clonedupecore.server.trolls;
|
||||
package me.trouper.clonedupecore.server.systems.trolls;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerChangeGameState;
|
||||
@@ -1,30 +1,27 @@
|
||||
package me.trouper.clonedupecore.server.trolls;
|
||||
package me.trouper.clonedupecore.server.systems.trolls;
|
||||
|
||||
import me.trouper.alias.server.systems.AbstractWand;
|
||||
import me.trouper.alias.server.systems.Text;
|
||||
import me.trouper.alias.server.systems.Verbose;
|
||||
import me.trouper.alias.server.systems.tracing.BlockDisplayRaytracer;
|
||||
import me.trouper.alias.server.systems.tracing.CustomDisplayRaytracer;
|
||||
import me.trouper.alias.server.systems.tracing.Point;
|
||||
import me.trouper.alias.server.systems.display.tracing.CustomRaytracer;
|
||||
import me.trouper.alias.server.systems.display.tracing.Point;
|
||||
import me.trouper.alias.server.systems.world.Explosion;
|
||||
import me.trouper.alias.server.systems.world.ExplosionOptions;
|
||||
import me.trouper.alias.server.systems.world.ExplosionResult;
|
||||
import me.trouper.alias.server.systems.world.ExplosionUtils;
|
||||
import me.trouper.alias.utils.FormatUtils;
|
||||
import me.trouper.alias.utils.ItemBuilder;
|
||||
import me.trouper.alias.utils.SoundPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.UUID;
|
||||
@@ -32,16 +29,16 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class OrbitalTrollWand extends AbstractWand implements TrollFeature {
|
||||
private static final ItemStack ORBITAL_WAND = ItemBuilder.of(Material.TRIPWIRE_HOOK)
|
||||
.displayName(Text.color("&4&lOrbital Sky Torch").decoration(TextDecoration.ITALIC,false))
|
||||
.loreComponent(
|
||||
Text.color("&8▪ &cRight-Click:&f Aim Cannon"),
|
||||
Text.color("&8▪ &cRight-Click Again:&f Charge Ion Beam"),
|
||||
Text.color("&8▪ &cLeft-Click:&f Call off shot"),
|
||||
Text.color("&8▪ &cSwap-Hands:&f Undo"),
|
||||
Text.color("&7"),
|
||||
Text.color("&7Now Includes &oreal&r&7 orbital configurations!"),
|
||||
Text.color("&7"),
|
||||
Text.color("&8Thank you TheCymaera and HeroBrayden!")
|
||||
.displayName("<reset><red><bold>Orbital Sky Torch")
|
||||
.loreMiniMessage(
|
||||
"<gray>▪ <red>Right-Click:<white> Aim Cannon",
|
||||
"<gray>▪ <red>Right-Click Again:<white> Charge Ion Beam",
|
||||
"<gray>▪ <red>Left-Click:<white> Call off shot",
|
||||
"<gray>▪ <red>Swap-Hands:<white> Undo",
|
||||
"<gray>",
|
||||
"<gray>Now Includes <italic>real</italic> orbital configurations!",
|
||||
"<gray>",
|
||||
"<gray>Thank you TheCymaera and HeroBrayden!"
|
||||
)
|
||||
.build();
|
||||
|
||||
@@ -98,64 +95,64 @@ public class OrbitalTrollWand extends AbstractWand implements TrollFeature {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSwapHand(Player player) {
|
||||
public void onSwapHand(Player player) {
|
||||
try {
|
||||
if (undoHistory(player)) {
|
||||
Text.message(Text.Pallet.SUCCESS, false, player, SUCCESS_RESTORE);
|
||||
getTextSystem().message(Text.Pallet.SUCCESS, false, player, SUCCESS_RESTORE);
|
||||
SoundPlayer.play(player, Sound.ENTITY_ILLUSIONER_PREPARE_BLINDNESS, 10, 1);
|
||||
} else if (cannonMap.containsKey(player.getUniqueId())) {
|
||||
cannonMap.get(player.getUniqueId()).destroy();
|
||||
Text.message(Text.Pallet.SUCCESS, false, player, SUCCESS_DEACTIVATED);
|
||||
getTextSystem().message(Text.Pallet.SUCCESS, false, player, SUCCESS_DEACTIVATED);
|
||||
} else {
|
||||
Text.message(Text.Pallet.ERROR, false, player, ERROR_EMPTY_STACK);
|
||||
getTextSystem().message(Text.Pallet.ERROR, false, player, ERROR_EMPTY_STACK);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Text.message(Text.Pallet.ERROR, false, player, ERROR_EXCEPTION);
|
||||
getTextSystem().message(Text.Pallet.ERROR, false, player, ERROR_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRightClick(Player player) {
|
||||
public void onRightClick(Player player) {
|
||||
UUID playerId = player.getUniqueId();
|
||||
OrbitalIonCannon playerCannon = cannonMap.get(playerId);
|
||||
|
||||
if (playerCannon != null) {
|
||||
if (playerCannon.getFireTask() != null || playerCannon.getChargeTask() != null) {
|
||||
Text.message(Text.Pallet.ERROR, false, player, ERROR_ALREADY_CHARGING);
|
||||
getTextSystem().message(Text.Pallet.ERROR, false, player, ERROR_ALREADY_CHARGING);
|
||||
return;
|
||||
}
|
||||
playerCannon.charge();
|
||||
Text.message(Text.Pallet.SUCCESS, false, player, SUCCESS_CHARGING);
|
||||
getTextSystem().message(Text.Pallet.SUCCESS, false, player, SUCCESS_CHARGING);
|
||||
return;
|
||||
}
|
||||
|
||||
OrbitalIonCannon cannon = new OrbitalIonCannon(player, traceTargets(player));
|
||||
cannonMap.put(playerId, cannon);
|
||||
Text.message(Text.Pallet.SUCCESS, false, player, SUCCESS_AIM);
|
||||
getTextSystem().message(Text.Pallet.SUCCESS, false, player, SUCCESS_AIM);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLeftClick(Player player) {
|
||||
public void onLeftClick(Player player) {
|
||||
UUID playerId = player.getUniqueId();
|
||||
OrbitalIonCannon playerCannon = cannonMap.get(playerId);
|
||||
|
||||
if (playerCannon == null) {
|
||||
Text.message(Text.Pallet.ERROR, false, player, ERROR_NOT_CONTROLLING);
|
||||
getTextSystem().message(Text.Pallet.ERROR, false, player, ERROR_NOT_CONTROLLING);
|
||||
return;
|
||||
}
|
||||
|
||||
playerCannon.destroy();
|
||||
cannonMap.remove(playerId);
|
||||
Text.message(Text.Pallet.SUCCESS, false, player, SUCCESS_DEACTIVATED);
|
||||
getTextSystem().message(Text.Pallet.SUCCESS, false, player, SUCCESS_DEACTIVATED);
|
||||
SoundPlayer.play(player, Sound.BLOCK_BEACON_DEACTIVATE, 1, 0.5F);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScrollDown(Player player) {
|
||||
public void onScrollDown(Player player) {
|
||||
OrbitalIonCannon cannon = cannonMap.get(player.getUniqueId());
|
||||
if (cannon == null) {
|
||||
Text.message(Text.Pallet.ERROR, false, player, ERROR_NOT_CONTROLLING);
|
||||
getTextSystem().message(Text.Pallet.ERROR, false, player, ERROR_NOT_CONTROLLING);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -167,21 +164,21 @@ public class OrbitalTrollWand extends AbstractWand implements TrollFeature {
|
||||
cannon.setPower(Math.max(1, cannon.getPower() - 5));
|
||||
SoundPlayer.play(player, Sound.BLOCK_NOTE_BLOCK_HAT, 1, 1.7F);
|
||||
|
||||
player.sendActionBar(Text.format(Text.Pallet.INFO, "Set ion cannon power to {0}.", cannon.getPower()));
|
||||
player.sendActionBar(getTextSystem().format(Text.Pallet.INFO, "Set ion cannon power to {0}.", cannon.getPower()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScrollUp(Player player) {
|
||||
public void onScrollUp(Player player) {
|
||||
OrbitalIonCannon cannon = cannonMap.get(player.getUniqueId());
|
||||
if (cannon == null) {
|
||||
Text.message(Text.Pallet.ERROR, false, player, ERROR_NOT_CONTROLLING);
|
||||
getTextSystem().message(Text.Pallet.ERROR, false, player, ERROR_NOT_CONTROLLING);
|
||||
return;
|
||||
}
|
||||
|
||||
cannon.setPower(Math.min(MAX_POWER, cannon.getPower() + 5));
|
||||
SoundPlayer.play(player, Sound.BLOCK_NOTE_BLOCK_HAT, 1, 0.8F);
|
||||
|
||||
player.sendActionBar(Text.format(Text.Pallet.INFO, "Set ion cannon power to {0}.", cannon.getPower()));
|
||||
player.sendActionBar(getTextSystem().format(Text.Pallet.INFO, "Set ion cannon power to {0}.", cannon.getPower()));
|
||||
}
|
||||
|
||||
public class OrbitalIonCannon {
|
||||
@@ -221,20 +218,20 @@ public class OrbitalTrollWand extends AbstractWand implements TrollFeature {
|
||||
|
||||
updateOrbitLocation();
|
||||
setSkyRenderLocation(getSimulatedOrbit().getRenderLocation(getTargetLocation()));
|
||||
setSkyTraceLocation(CustomDisplayRaytracer.blocksInFrontOf(getTargetLocation(), getSimulatedOrbit().getNormalToSatellite(getTargetLocation().toVector()), Math.max(5,power), false).getLoc());
|
||||
setSkyTraceLocation(getDisplayManager().getCustomRaytracer().blocksInFrontOf(getTargetLocation(), getSimulatedOrbit().getNormalToSatellite(getTargetLocation().toVector()), Math.max(5,power), false).getLoc());
|
||||
|
||||
if (aimTask != null && !aimTask.isCancelled()) {
|
||||
setTargetLocation(traceTargets(getOwner()));
|
||||
}
|
||||
|
||||
setGroundTraced(CustomDisplayRaytracer.trace(getSkyTraceLocation(), getTargetLocation().clone().toVector().subtract(getSkyTraceLocation().clone().toVector()),Math.max(5,power), 5, (point) -> {
|
||||
setGroundTraced(getDisplayManager().getCustomRaytracer().trace(getSkyTraceLocation(), getTargetLocation().clone().toVector().subtract(getSkyTraceLocation().clone().toVector()),Math.max(5,power), 5, (point) -> {
|
||||
Material type = point.getLoc().getBlock().getType();
|
||||
return type.isCollidable();
|
||||
}).getLoc());
|
||||
|
||||
ticksElapsed++;
|
||||
}
|
||||
}.runTaskTimer(main.getPlugin(), 0, 1);
|
||||
}.runTaskTimer(getPlugin(), 0, 1);
|
||||
|
||||
private OrbitalIonCannon(Player owner, Location target) {
|
||||
this.owner = owner;
|
||||
@@ -242,7 +239,7 @@ public class OrbitalTrollWand extends AbstractWand implements TrollFeature {
|
||||
this.targetLocation = target;
|
||||
this.power = 20;
|
||||
this.simulatedOrbit = new OrbitalConfiguration(target.toVector().clone().add(new Vector(random().nextInt(-30_000_000,30_000_000),target.getY(),random().nextInt(-30_000_000,30_000_000))));
|
||||
this.setAimTask(aimRunnable.runTaskTimer(main.getPlugin(), 0, 1));
|
||||
this.setAimTask(aimRunnable.runTaskTimer(getPlugin(), 0, 1));
|
||||
}
|
||||
|
||||
private final BukkitRunnable fireRunnable = new BukkitRunnable() {
|
||||
@@ -259,10 +256,10 @@ public class OrbitalTrollWand extends AbstractWand implements TrollFeature {
|
||||
}
|
||||
|
||||
if (ticksElapsed <= 40) {
|
||||
BlockDisplay inner = BlockDisplayRaytracer.trace(Material.WHITE_CONCRETE_POWDER, getGroundTraced(), getSkyRenderLocation(), 1, 2);
|
||||
BlockDisplay inner = getDisplayManager().getBlockDisplayRaytracer().trace(Material.WHITE_CONCRETE_POWDER, getGroundTraced(), getSkyRenderLocation(), 1, 2);
|
||||
inner.setGlowing(true);
|
||||
inner.setGlowColorOverride(Color.fromRGB(0xFFDDDD));
|
||||
BlockDisplayRaytracer.trace(Material.WHITE_STAINED_GLASS, getGroundTraced(), getSkyRenderLocation(), 1.5 + main.random().nextDouble(), 2);
|
||||
getDisplayManager().getBlockDisplayRaytracer().trace(Material.WHITE_STAINED_GLASS, getGroundTraced(), getSkyRenderLocation(), 1.5 + random().nextDouble(), 2);
|
||||
}
|
||||
|
||||
if (ticksElapsed == 0) {
|
||||
@@ -275,7 +272,7 @@ public class OrbitalTrollWand extends AbstractWand implements TrollFeature {
|
||||
.setDestructionDelay(1);
|
||||
|
||||
Stack<ExplosionResult> history = playerHistory.computeIfAbsent(ownerId, k -> new Stack<>());
|
||||
setExplosionResult(ExplosionUtils.createExplosion(getGroundTraced(), options));
|
||||
setExplosionResult(new Explosion(getContext()).createExplosion(getGroundTraced(), options));
|
||||
history.push(getExplosionResult());
|
||||
}
|
||||
|
||||
@@ -290,7 +287,7 @@ public class OrbitalTrollWand extends AbstractWand implements TrollFeature {
|
||||
public void run() {
|
||||
final int delay = 40;
|
||||
if (ticksElapsed >= delay) {
|
||||
setFireTask(fireRunnable.runTaskTimer(main.getPlugin(), 0, 1));
|
||||
setFireTask(fireRunnable.runTaskTimer(getPlugin(), 0, 1));
|
||||
cannonMap.remove(ownerId);
|
||||
this.cancel();
|
||||
chargeTask = null;
|
||||
@@ -308,10 +305,10 @@ public class OrbitalTrollWand extends AbstractWand implements TrollFeature {
|
||||
double thickness = (double) ticksElapsed / delay;
|
||||
int otherValues = ((ticksElapsed / delay * 100) + 100);
|
||||
|
||||
BlockDisplay inner = BlockDisplayRaytracer.trace(Material.RED_CONCRETE, getGroundTraced(), getSkyRenderLocation(), thickness, 2);
|
||||
BlockDisplay inner = getDisplayManager().getBlockDisplayRaytracer().trace(Material.RED_CONCRETE, getGroundTraced(), getSkyRenderLocation(), thickness, 2);
|
||||
inner.setGlowing(true);
|
||||
inner.setGlowColorOverride(Color.fromRGB(255, otherValues, otherValues));
|
||||
BlockDisplayRaytracer.trace(Material.ORANGE_STAINED_GLASS, getGroundTraced(), getSkyRenderLocation(), thickness + 0.1, 2);
|
||||
getDisplayManager().getBlockDisplayRaytracer().trace(Material.ORANGE_STAINED_GLASS, getGroundTraced(), getSkyRenderLocation(), thickness + 0.1, 2);
|
||||
|
||||
ticksElapsed++;
|
||||
}
|
||||
@@ -332,10 +329,10 @@ public class OrbitalTrollWand extends AbstractWand implements TrollFeature {
|
||||
new SoundPlayer(Sound.BLOCK_RESPAWN_ANCHOR_CHARGE, getPower() * 20, 0.5F).playAt(groundTraced, getPower() * 10);
|
||||
}
|
||||
|
||||
BlockDisplay inner = BlockDisplayRaytracer.trace(Material.RED_CONCRETE_POWDER, getGroundTraced(), getSkyRenderLocation(), 0.1, 2);
|
||||
BlockDisplay inner = getDisplayManager().getBlockDisplayRaytracer().trace(Material.RED_CONCRETE_POWDER, getGroundTraced(), getSkyRenderLocation(), 0.1, 2);
|
||||
inner.setGlowing(true);
|
||||
inner.setGlowColorOverride(Color.fromRGB(0xFF0000));
|
||||
BlockDisplayRaytracer.trace(Material.RED_STAINED_GLASS, getGroundTraced(), getSkyRenderLocation(), 0.2, 2);
|
||||
getDisplayManager().getBlockDisplayRaytracer().trace(Material.RED_STAINED_GLASS, getGroundTraced(), getSkyRenderLocation(), 0.2, 2);
|
||||
|
||||
ticksElapsed++;
|
||||
}
|
||||
@@ -374,7 +371,7 @@ public class OrbitalTrollWand extends AbstractWand implements TrollFeature {
|
||||
if (this.aimTask != null && !this.aimTask.isCancelled()) {
|
||||
this.aimTask.cancel();
|
||||
}
|
||||
this.setChargeTask(this.chargeRunnable.runTaskTimer(main.getPlugin(), 0, 1));
|
||||
this.setChargeTask(this.chargeRunnable.runTaskTimer(getPlugin(), 0, 1));
|
||||
}
|
||||
|
||||
public Player getOwner() { return owner; }
|
||||
@@ -476,8 +473,8 @@ public class OrbitalTrollWand extends AbstractWand implements TrollFeature {
|
||||
public void setBaseSatellite(Vector baseSatellite) { this.baseSatellite = baseSatellite; }
|
||||
}
|
||||
|
||||
private static Location traceTargets(Player player) {
|
||||
Point hit = CustomDisplayRaytracer.trace(player.getEyeLocation(), player.getEyeLocation().getDirection(), 128, CustomDisplayRaytracer.HIT_BLOCK);
|
||||
private Location traceTargets(Player player) {
|
||||
Point hit = getDisplayManager().getCustomRaytracer().trace(player.getEyeLocation(), player.getEyeLocation().getDirection(), 128, CustomRaytracer.HIT_BLOCK);
|
||||
return hit.getLoc();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package me.trouper.clonedupecore.server.trolls;
|
||||
package me.trouper.clonedupecore.server.systems.trolls;
|
||||
|
||||
import me.trouper.alias.server.systems.AbstractWand;
|
||||
import me.trouper.alias.server.systems.tracing.BlockDisplayRaytracer;
|
||||
import me.trouper.alias.utils.ItemBuilder;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -46,42 +44,42 @@ public class TestTrollWand extends AbstractWand implements TrollFeature{
|
||||
public void stop(CommandSender sender, Player target) {}
|
||||
|
||||
@Override
|
||||
protected void onScrollUp(Player player) {
|
||||
public void onScrollUp(Player player) {
|
||||
infoAny(player, "You scrolled upwards");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScrollDown(Player player) {
|
||||
public void onScrollDown(Player player) {
|
||||
infoAny(player, "You scrolled downwards");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSwapHand(Player player) {
|
||||
public void onSwapHand(Player player) {
|
||||
infoAny(player, "You swapped hands");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSwapHandSneak(Player player) {
|
||||
public void onSwapHandSneak(Player player) {
|
||||
infoAny(player, "You swapped hands while sneaking");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLeftClick(Player player) {
|
||||
public void onLeftClick(Player player) {
|
||||
infoAny(player, "You left clicked");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLeftClickSneak(Player player) {
|
||||
public void onLeftClickSneak(Player player) {
|
||||
infoAny(player, "You left clicked while sneaking");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRightClick(Player player) {
|
||||
public void onRightClick(Player player) {
|
||||
infoAny(player, "You right clicked");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRightClickSneak(Player player) {
|
||||
public void onRightClickSneak(Player player) {
|
||||
infoAny(player, "You right clicked while sneaking");
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package me.trouper.clonedupecore.server.trolls;
|
||||
package me.trouper.clonedupecore.server.systems.trolls;
|
||||
|
||||
import me.trouper.alias.server.events.QuickListener;
|
||||
import me.trouper.clonedupecore.CloneDupeContext;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface TrollFeature extends QuickListener {
|
||||
public interface TrollFeature extends QuickListener, CloneDupeContext {
|
||||
|
||||
String getName();
|
||||
|
||||
String getDescription();
|
||||
@@ -1,11 +1,8 @@
|
||||
package me.trouper.clonedupecore.server.trolls;
|
||||
package me.trouper.clonedupecore.server.systems.trolls;
|
||||
|
||||
import me.trouper.alias.server.systems.AbstractWand;
|
||||
import me.trouper.alias.server.systems.Text;
|
||||
import me.trouper.alias.server.systems.tracing.CustomDisplayRaytracer;
|
||||
import me.trouper.alias.utils.ItemBuilder;
|
||||
import me.trouper.alias.utils.SoundPlayer;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
@@ -24,10 +21,10 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class VoidTrollWand extends AbstractWand implements TrollFeature {
|
||||
private static final ItemStack VOID_WAND = ItemBuilder.of(Material.ECHO_SHARD)
|
||||
.displayName(Text.color("&5&lVoid Wand").decoration(TextDecoration.ITALIC,false))
|
||||
.loreComponent(
|
||||
Text.color("&8▪ &dRight-Click:&f Abyss"),
|
||||
Text.color("&8▪ &dLeft-Click:&f Engulf")
|
||||
.displayName("<reset><dark_purple><bold>Void Wand")
|
||||
.loreMiniMessage(
|
||||
"<dark_gray>▪ <light_purple>Right-Click:<white> Abyss",
|
||||
"<dark_gray>▪ <light_purple>Left-Click:<white> Engulf"
|
||||
)
|
||||
.build();
|
||||
|
||||
@@ -57,8 +54,8 @@ public class VoidTrollWand extends AbstractWand implements TrollFeature {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRightClick(Player player) {
|
||||
CustomDisplayRaytracer.traceDelayed(main.getPlugin(),player.getEyeLocation(),player.getEyeLocation().getDirection(),30,1, point -> {
|
||||
public void onRightClick(Player player) {
|
||||
getDisplayManager().getCustomRaytracer().traceDelayed(getPlugin(),player.getEyeLocation(),player.getEyeLocation().getDirection(),30,1, point -> {
|
||||
List<LivingEntity> targets = point.getNearbyEntities(player,1,true, entity->entity instanceof LivingEntity).stream().map(entity -> (LivingEntity) entity).toList();
|
||||
if (targets.isEmpty()) {
|
||||
SoundPlayer.play(point.getLoc(), Sound.BLOCK_SOUL_SAND_BREAK, 1,0.4F,10);
|
||||
@@ -74,7 +71,7 @@ public class VoidTrollWand extends AbstractWand implements TrollFeature {
|
||||
|
||||
World w = target.getWorld();
|
||||
AtomicInteger counter = new AtomicInteger(0);
|
||||
Bukkit.getScheduler().runTaskTimer(main.getPlugin(),(task) -> {
|
||||
Bukkit.getScheduler().runTaskTimer(getPlugin(),(task) -> {
|
||||
if (counter.getAndIncrement() > 60) {
|
||||
task.cancel();
|
||||
return;
|
||||
@@ -90,8 +87,8 @@ public class VoidTrollWand extends AbstractWand implements TrollFeature {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLeftClick(Player player) {
|
||||
CustomDisplayRaytracer.traceDelayed(main.getPlugin(),player.getEyeLocation(),player.getEyeLocation().getDirection(),30,1,point -> {
|
||||
public void onLeftClick(Player player) {
|
||||
getDisplayManager().getCustomRaytracer().traceDelayed(getPlugin(),player.getEyeLocation(),player.getEyeLocation().getDirection(),30,1,point -> {
|
||||
List<LivingEntity> targets = point.getNearbyEntities(player, 1, true, entity -> entity instanceof LivingEntity).stream().map(entity -> (LivingEntity) entity).toList();
|
||||
if (targets.isEmpty()) {
|
||||
SoundPlayer.play(point.getLoc(), Sound.BLOCK_SOUL_SAND_BREAK, 1,0.4F,10);
|
||||
@@ -105,7 +102,7 @@ public class VoidTrollWand extends AbstractWand implements TrollFeature {
|
||||
});
|
||||
}
|
||||
|
||||
public void engulf(LivingEntity target) {
|
||||
private void engulf(LivingEntity target) {
|
||||
List<BlockDisplay> displays = new ArrayList<>();
|
||||
|
||||
final double effectLength = 80;
|
||||
@@ -117,7 +114,7 @@ public class VoidTrollWand extends AbstractWand implements TrollFeature {
|
||||
final Location targetLoc = target.getLocation();
|
||||
|
||||
AtomicInteger ticksElapsed = new AtomicInteger();
|
||||
Bukkit.getScheduler().runTaskTimer(main.getPlugin(),(task)->{
|
||||
Bukkit.getScheduler().runTaskTimer(getPlugin(),(task)->{
|
||||
if (ticksElapsed.getAndIncrement() > effectLength) {
|
||||
target.setHealth(0);
|
||||
SoundPlayer.play(targetLoc, Sound.ENTITY_DROWNED_DEATH_WATER, 1,0.4F,10);
|
||||
@@ -135,7 +132,7 @@ public class VoidTrollWand extends AbstractWand implements TrollFeature {
|
||||
},0,1);
|
||||
}
|
||||
|
||||
public static List<BlockDisplay> voidRing(Location center, double yOffset, double radius, int blockCount) {
|
||||
private List<BlockDisplay> voidRing(Location center, double yOffset, double radius, int blockCount) {
|
||||
List<BlockDisplay> displays = new ArrayList<>();
|
||||
ThreadLocalRandom localRandom = ThreadLocalRandom.current();
|
||||
|
||||
@@ -1,25 +1,13 @@
|
||||
package me.trouper.clonedupecore.utils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.damage.DamageSource;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class PlayerUtils {
|
||||
|
||||
private static float clampPitch(float pitch) {
|
||||
|
||||
Reference in New Issue
Block a user