diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..793eeb3
--- /dev/null
+++ b/META-INF/MANIFEST.MF
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Archiver-Version: Plexus Archiver
+Created-By: Apache Maven
+Built-By: dewet
+Build-Jdk: 21.0.4
+
diff --git a/META-INF/maven/cinematicview/CinematicView/pom.properties b/META-INF/maven/cinematicview/CinematicView/pom.properties
new file mode 100644
index 0000000..e1b5faa
--- /dev/null
+++ b/META-INF/maven/cinematicview/CinematicView/pom.properties
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Wed Dec 18 10:02:47 SAST 2024
+artifactId=CinematicView
+groupId=cinematicview
+version=1.32
diff --git a/META-INF/maven/cinematicview/CinematicView/pom.xml b/META-INF/maven/cinematicview/CinematicView/pom.xml
new file mode 100644
index 0000000..4d03390
--- /dev/null
+++ b/META-INF/maven/cinematicview/CinematicView/pom.xml
@@ -0,0 +1,122 @@
+
+
+ 4.0.0
+
+ cinematicview
+ CinematicView
+ 1.32
+ jar
+
+ CinematicView
+
+
+ 17
+ UTF-8
+
+
+
+
+
+ net.md-5
+ specialsource-maven-plugin
+ 2.0.3
+
+
+ package
+
+ remap
+
+ remap-obf
+
+ org.spigotmc:minecraft-server:1.21.1-R0.1-SNAPSHOT:txt:maps-mojang
+ true
+ org.spigotmc:spigot:1.21.1-R0.1-SNAPSHOT:jar:remapped-mojang
+ true
+ remapped-obf
+
+
+
+ package
+
+ remap
+
+ remap-spigot
+
+ ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar
+ org.spigotmc:minecraft-server:1.21.1-R0.1-SNAPSHOT:csrg:maps-spigot
+ org.spigotmc:spigot:1.21.1-R0.1-SNAPSHOT:jar:remapped-obf
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ ${java.version}
+ ${java.version}
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.2.4
+
+
+ package
+
+ shade
+
+
+ false
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 2.3.1
+
+ C:\Users\dewet\OneDrive\Desktop\Vanilla Minecraft Server\plugins
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
+
+
+ spigotmc-repo
+ https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+ sonatype
+ https://oss.sonatype.org/content/groups/public/
+
+
+
+
+
+ org.spigotmc
+ spigot
+ 1.21.1-R0.1-SNAPSHOT
+ remapped-mojang
+ provided
+
+
+ net.luckperms
+ api
+ 5.4
+ provided
+
+
+
diff --git a/README.md b/README.md
deleted file mode 100644
index e69de29..0000000
diff --git a/cinematicview/cinematicview/CinematicView.java b/cinematicview/cinematicview/CinematicView.java
new file mode 100644
index 0000000..4229bc9
--- /dev/null
+++ b/cinematicview/cinematicview/CinematicView.java
@@ -0,0 +1,183 @@
+package cinematicview.cinematicview;
+
+import cinematicview.cinematicview.Commands.Commands;
+import cinematicview.cinematicview.Commands.TabCompletion;
+import cinematicview.cinematicview.CustomConfig.CustomConfig;
+import cinematicview.cinematicview.Listeners.ChatMessage;
+import cinematicview.cinematicview.Listeners.ExitViewListener;
+import cinematicview.cinematicview.Listeners.InventoryClick;
+import cinematicview.cinematicview.Listeners.Join;
+import cinematicview.cinematicview.Listeners.UpdateChecker;
+import cinematicview.cinematicview.PlayerManager.PlayerManager;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Objects;
+import net.luckperms.api.LuckPerms;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.ConsoleCommandSender;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.PluginDescriptionFile;
+import org.bukkit.plugin.RegisteredServiceProvider;
+import org.bukkit.plugin.java.JavaPlugin;
+
+public final class CinematicView extends JavaPlugin {
+ private PlayerManager playerManager;
+
+ public void onEnable() {
+ int pluginId = 22755;
+ new Metrics(this, pluginId);
+ CustomConfig.setup();
+ this.getConfig().options().copyDefaults(true);
+ this.saveDefaultConfig();
+ this.getCommand("cinematicview").setExecutor(new Commands(this));
+ this.getCommand("cinematicview").setTabCompleter(new TabCompletion());
+ this.getServer().getPluginManager().registerEvents(new ExitViewListener(this), this);
+ this.getServer().getPluginManager().registerEvents(new InventoryClick(this), this);
+ this.getServer().getPluginManager().registerEvents(new Join(this), this);
+ this.getServer().getPluginManager().registerEvents(new ChatMessage(this), this);
+ ConsoleCommandSender var10000 = this.getServer().getConsoleSender();
+ String var10001 = String.valueOf(ChatColor.AQUA);
+ var10000.sendMessage("[" + var10001 + "CinematicView" + String.valueOf(ChatColor.WHITE) + "] CinematicView has been loaded.");
+ PluginDescriptionFile pdf = this.getDescription();
+ UpdateChecker updateChecker = new UpdateChecker(pdf.getVersion());
+ updateChecker.check();
+ this.getServer().getPluginManager().registerEvents(updateChecker, this);
+ if (updateChecker.isAvailable()) {
+ var10000 = Bukkit.getConsoleSender();
+ var10001 = String.valueOf(ChatColor.AQUA);
+ var10000.sendMessage("\n[" + var10001 + "CinematicView" + String.valueOf(ChatColor.WHITE) + "] 'CinematicView " + updateChecker.getLatestVersion() + "' is available. You are on version 'CinematicView " + updateChecker.getVersion() + "' \n ");
+ }
+
+ RegisteredServiceProvider provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
+ if (provider == null) {
+ var10000 = Bukkit.getConsoleSender();
+ var10001 = String.valueOf(ChatColor.AQUA);
+ var10000.sendMessage("\n[" + var10001 + "CinematicView" + String.valueOf(ChatColor.WHITE) + "] LuckPerms has not been detected on the server. Certain features (1 feature) will not work.\n ");
+ }
+
+ try {
+ this.setConfig();
+ } catch (IOException var7) {
+ throw new RuntimeException(var7);
+ }
+
+ this.playerManager = new PlayerManager();
+ }
+
+ public void onDisable() {
+ ConsoleCommandSender var10000 = this.getServer().getConsoleSender();
+ String var10001 = String.valueOf(ChatColor.AQUA);
+ var10000.sendMessage("[" + var10001 + "CinematicView" + String.valueOf(ChatColor.WHITE) + "] CinematicView shutting down.");
+ }
+
+ public PlayerManager getPlayerManager() {
+ return this.playerManager;
+ }
+
+ public void setConfig() throws IOException {
+ File config = new File(((Plugin)Objects.requireNonNull(Bukkit.getServer().getPluginManager().getPlugin("CinematicView"))).getDataFolder(), "config.yml");
+ FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(config);
+ boolean maxView = true;
+ int maxViews = 5;
+ int interval = 6;
+ boolean maxLoc = true;
+ int maxLocs = 10;
+ boolean perms = true;
+ boolean lockRot = true;
+ int maxViewInterval = 20;
+ boolean pumpkin = false;
+ String allExclude = "none";
+ boolean showViewMessage = true;
+ String moveFunction = "original";
+ boolean showNPC = false;
+ if (fileConfiguration.get("maximum-views") != null) {
+ maxView = fileConfiguration.getBoolean("maximum-views");
+ }
+
+ if (fileConfiguration.get("maximum-views-amount") != null) {
+ maxViews = fileConfiguration.getInt("maximum-views-amount");
+ }
+
+ if (fileConfiguration.get("default-interval") != null) {
+ interval = fileConfiguration.getInt("default-interval");
+ }
+
+ if (fileConfiguration.get("maximum-locations") != null) {
+ maxLoc = fileConfiguration.getBoolean("maximum-locations");
+ }
+
+ if (fileConfiguration.get("maximum-locations-amount") != null) {
+ maxLocs = fileConfiguration.getInt("maximum-locations-amount");
+ }
+
+ if (fileConfiguration.get("permissions") != null) {
+ perms = fileConfiguration.getBoolean("permissions");
+ }
+
+ if (fileConfiguration.get("lock-rotation") != null) {
+ lockRot = fileConfiguration.getBoolean("lock-rotation");
+ }
+
+ if (fileConfiguration.get("maximum-view-interval") != null) {
+ maxViewInterval = fileConfiguration.getInt("maximum-view-interval");
+ }
+
+ if (fileConfiguration.get("pumpkin-head") != null) {
+ pumpkin = fileConfiguration.getBoolean("pumpkin-head");
+ }
+
+ if (fileConfiguration.get("all-exclude") != null) {
+ allExclude = fileConfiguration.getString("all-exclude");
+ }
+
+ if (fileConfiguration.get("show-view-message") != null) {
+ showViewMessage = fileConfiguration.getBoolean("show-view-message");
+ }
+
+ if (fileConfiguration.get("move-function") != null) {
+ moveFunction = fileConfiguration.getString("move-function");
+ }
+
+ if (fileConfiguration.get("show-npc") != null) {
+ showNPC = fileConfiguration.getBoolean("show-npc");
+ }
+
+ if (config.delete()) {
+ File newConfig = new File(((Plugin)Objects.requireNonNull(Bukkit.getServer().getPluginManager().getPlugin("CinematicView"))).getDataFolder(), "config.yml");
+ FileWriter fw = new FileWriter(newConfig);
+ fw.write("###########################################################\n# Please ensure that these settings have the correct type #\n# If an integer is needed, make sure the setting has an #\n# integer, same is needed for (true/false) #\n###########################################################\n");
+ fw.write("\n# Will players have a maximum amount of views (true/false)");
+ fw.write("\nmaximum-views: " + maxView);
+ fw.write("\n# If players have a maximum amount of views, what is the maximum amount (integer)");
+ fw.write("\nmaximum-views-amount: " + maxViews);
+ fw.write("\n\n# Default interval between Locations for when a View is created (seconds)");
+ fw.write("\ndefault-interval: " + interval);
+ fw.write("\n\n# Will views have a maximum amount of locations (true/false)");
+ fw.write("\nmaximum-locations: " + maxLoc);
+ fw.write("\n# If views have a maximum amount of locations, what is the maximum amount (integer)");
+ fw.write("\nmaximum-locations-amount: " + maxLocs);
+ fw.write("\n\n# Is permissions enabled (true/false)\n# If set to false, players will be able to create and modify their Views by default. OP is then needed for admin commands or the permission 'cinematicview.admin'\n# If set to true, players will need to be given permissions manually with a separate Permissions Plugin. Permission example: 'cinematicview.basic'\n");
+ fw.write("permissions: " + perms);
+ fw.write("\n\n# If set to true, player will be unable to rotate (look around) when showing a view (true/false)");
+ fw.write("\nlock-rotation: " + lockRot);
+ fw.write("\n\n# Maximum value for view interval possible (integer)");
+ fw.write("\nmaximum-view-interval: " + maxViewInterval);
+ fw.write("\n\n# Add a pumpkin head when showing a view (true/false)");
+ fw.write("\npumpkin-head: " + pumpkin);
+ fw.write("\n\n# When forcing all players to show a view, who should be excluded (string):\n# Options:\n# - none\n# - admins\n# - user\n");
+ fw.write("all-exclude: " + allExclude);
+ fw.write("\n\n# Should messages be displayed when showing a view (true/false)");
+ fw.write("\nshow-view-message: " + showViewMessage);
+ fw.write("\n\n# Which move function you would like to use when showing a cinematic. \n# Options:\n# - original\n# - smooth\n# Please be aware that the 'smooth' option is not perfect yet. At low cinematic intervals\n# it can cause players to be kicked and also spam the console with 'Moved too quickly'\n# The moved to quickly can be adjusted through server settings. \n# There is also protection against players being kicked as they will be teleported back and put\n# into the correct gamemode if they are kicked\n");
+ fw.write("move-function: " + moveFunction);
+ fw.write("\n\n# Add an NPC at player's original location when showing a cinematic");
+ fw.write("\nshow-npc: " + showNPC);
+ fw.close();
+ }
+
+ }
+}
diff --git a/cinematicview/cinematicview/Classes/DummyConnection.java b/cinematicview/cinematicview/Classes/DummyConnection.java
new file mode 100644
index 0000000..39266f8
--- /dev/null
+++ b/cinematicview/cinematicview/Classes/DummyConnection.java
@@ -0,0 +1,22 @@
+package cinematicview.cinematicview.Classes;
+
+import com.mojang.authlib.GameProfile;
+import net.minecraft.network.NetworkManager;
+import net.minecraft.network.protocol.EnumProtocolDirection;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.level.EntityPlayer;
+import net.minecraft.server.network.CommonListenerCookie;
+import net.minecraft.server.network.PlayerConnection;
+
+public class DummyConnection extends PlayerConnection {
+ private static final NetworkManager DUMMY_CONNECTION;
+
+ public DummyConnection(MinecraftServer server, EntityPlayer player, GameProfile profile) {
+ super(server, DUMMY_CONNECTION, player, CommonListenerCookie.a(profile, false));
+ }
+
+ static {
+ DUMMY_CONNECTION = new NetworkManager(EnumProtocolDirection.a) {
+ };
+ }
+}
diff --git a/cinematicview/cinematicview/Classes/ViewInventory.java b/cinematicview/cinematicview/Classes/ViewInventory.java
new file mode 100644
index 0000000..201bcce
--- /dev/null
+++ b/cinematicview/cinematicview/Classes/ViewInventory.java
@@ -0,0 +1,300 @@
+package cinematicview.cinematicview.Classes;
+
+import cinematicview.cinematicview.CinematicView;
+import cinematicview.cinematicview.Functions.Common;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.InventoryHolder;
+
+public class ViewInventory implements InventoryHolder {
+ private final Inventory inv;
+ private final CinematicView plugin;
+ private String viewName;
+ private File playerFile;
+ private FileConfiguration playerConfig;
+ Common common = new Common();
+
+ public ViewInventory(CinematicView plugin, String invTitle, Player player) {
+ this.inv = plugin.getServer().createInventory(this, 54, invTitle);
+ this.plugin = plugin;
+ this.viewName = invTitle;
+ this.playerFile = this.common.getPlayerFile(player.getUniqueId());
+ this.playerConfig = this.common.getFileConfig(this.playerFile);
+ }
+
+ public void create() {
+ this.setOne();
+ this.setTwo();
+ this.setThree();
+ this.setFour();
+ this.addMisc();
+ }
+
+ public void setOne() {
+ ViewItems addItem = new ViewItems(Material.EMERALD);
+ addItem.addName(String.valueOf(ChatColor.GREEN) + "Add");
+ List lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Add a Location");
+ lore.add(" ");
+ int size = this.playerConfig.getInt("Owned." + this.viewName + ".Size");
+ int maxSize = 0;
+ if (this.plugin.getConfig().getBoolean("maximum-views")) {
+ maxSize = this.plugin.getConfig().getInt("maximum-views-amount");
+ }
+
+ String string = maxSize != 0 ? String.valueOf(ChatColor.WHITE) + "Total Locations: " + String.valueOf(ChatColor.AQUA) + size + String.valueOf(ChatColor.WHITE) + "/" + String.valueOf(ChatColor.AQUA) + maxSize : String.valueOf(ChatColor.WHITE) + "Total Locations: " + String.valueOf(ChatColor.AQUA) + size;
+ lore.add(string);
+ addItem.addLore(lore);
+ this.inv.setItem(10, addItem.getItem());
+ ViewItems removeItem = new ViewItems(Material.REDSTONE);
+ removeItem.addName(String.valueOf(ChatColor.RED) + "Remove");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Remove a Location");
+ lore.add(" ");
+ lore.add(string);
+ removeItem.addLore(lore);
+ this.inv.setItem(19, removeItem.getItem());
+ ViewItems removeAllItem = new ViewItems(Material.TNT);
+ removeAllItem.addName(String.valueOf(ChatColor.RED) + "Remove All");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Remove All Locations");
+ lore.add(" ");
+ lore.add(string);
+ removeAllItem.addLore(lore);
+ this.inv.setItem(28, removeAllItem.getItem());
+ ViewItems deleteItem = new ViewItems(Material.BARRIER);
+ deleteItem.addName(String.valueOf(ChatColor.RED) + "Delete");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Delete the View");
+ removeAllItem.addLore(lore);
+ deleteItem.addLore(lore);
+ this.inv.setItem(37, deleteItem.getItem());
+ }
+
+ public void setTwo() {
+ ViewItems replaceItem = new ViewItems(Material.PISTON);
+ replaceItem.addName(String.valueOf(ChatColor.AQUA) + "Replace");
+ List lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Replace a Location");
+ lore.add(" ");
+ int size = this.playerConfig.getInt("Owned." + this.viewName + ".Size");
+ String var10000 = String.valueOf(ChatColor.WHITE);
+ String string = var10000 + "Total Locations: " + String.valueOf(ChatColor.AQUA) + size;
+ lore.add(string);
+ replaceItem.addLore(lore);
+ this.inv.setItem(12, replaceItem.getItem());
+ ViewItems swapItem = new ViewItems(Material.STICKY_PISTON);
+ swapItem.addName(String.valueOf(ChatColor.AQUA) + "Swap");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Swap two Locations");
+ lore.add(" ");
+ lore.add(string);
+ swapItem.addLore(lore);
+ this.inv.setItem(21, swapItem.getItem());
+ ViewItems insertItem = new ViewItems(Material.HOPPER);
+ insertItem.addName(String.valueOf(ChatColor.AQUA) + "Insert");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Insert a Location");
+ lore.add(" ");
+ lore.add(string);
+ insertItem.addLore(lore);
+ this.inv.setItem(30, insertItem.getItem());
+ ViewItems travelItem = new ViewItems(Material.DIAMOND_BOOTS);
+ travelItem.addName(String.valueOf(ChatColor.AQUA) + "Travel");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Set the Travel Type");
+ lore.add(" ");
+ string = "teleport";
+ if (this.playerConfig.get("Owned." + this.viewName + ".Travel") != null) {
+ string = this.playerConfig.getString("Owned." + this.viewName + ".Travel");
+ }
+
+ String var10001 = String.valueOf(ChatColor.WHITE);
+ lore.add(var10001 + "Current: " + String.valueOf(ChatColor.AQUA) + string);
+ travelItem.addLore(lore);
+ this.inv.setItem(39, travelItem.getItem());
+ }
+
+ public void setThree() {
+ ViewItems infoItem = new ViewItems(Material.BOOK);
+ infoItem.addName(String.valueOf(ChatColor.AQUA) + "Information");
+ List lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Get View Information");
+ infoItem.addLore(lore);
+ this.inv.setItem(14, infoItem.getItem());
+ ViewItems locationItem = new ViewItems(Material.MAP);
+ locationItem.addName(String.valueOf(ChatColor.AQUA) + "Location Information");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Get Location Information");
+ lore.add(" ");
+ int size = this.playerConfig.getInt("Owned." + this.viewName + ".Size");
+ String var10000 = String.valueOf(ChatColor.WHITE);
+ String string = var10000 + "Total Locations: " + String.valueOf(ChatColor.AQUA) + size;
+ lore.add(string);
+ locationItem.addLore(lore);
+ this.inv.setItem(23, locationItem.getItem());
+ ViewItems titleType = new ViewItems(Material.BIRCH_SIGN);
+ titleType.addName(String.valueOf(ChatColor.AQUA) + "Title Type");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Set the Title Type");
+ lore.add(" ");
+ string = "none";
+ if (this.playerConfig.get("Owned." + this.viewName + ".TitleType") != null) {
+ string = this.playerConfig.getString("Owned." + this.viewName + ".TitleType");
+ }
+
+ String var10001 = String.valueOf(ChatColor.WHITE);
+ lore.add(var10001 + "Current: " + String.valueOf(ChatColor.AQUA) + string);
+ titleType.addLore(lore);
+ this.inv.setItem(32, titleType.getItem());
+ ViewItems titleItem = new ViewItems(Material.NAME_TAG);
+ titleItem.addName(String.valueOf(ChatColor.AQUA) + "Title");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Add a Title to a Location");
+ lore.add(" ");
+ if (this.playerConfig.get("Owned." + this.viewName + ".Titles") != null) {
+ if (this.playerConfig.getConfigurationSection("Owned." + this.viewName + ".Titles") != null) {
+ Set titles = this.playerConfig.getConfigurationSection("Owned." + this.viewName + ".Titles").getKeys(false);
+ lore.add(String.valueOf(ChatColor.WHITE) + "Current:");
+ lore.add(" ");
+ Iterator var9 = titles.iterator();
+
+ while(var9.hasNext()) {
+ String t = (String)var9.next();
+ var10001 = String.valueOf(ChatColor.AQUA);
+ lore.add(var10001 + t + ": " + String.valueOf(ChatColor.WHITE) + this.playerConfig.getString("Owned." + this.viewName + ".Titles." + t + ".Title"));
+ }
+ } else {
+ var10001 = String.valueOf(ChatColor.WHITE);
+ lore.add(var10001 + "Current: " + String.valueOf(ChatColor.AQUA) + "none");
+ }
+ } else {
+ var10001 = String.valueOf(ChatColor.WHITE);
+ lore.add(var10001 + "Current: " + String.valueOf(ChatColor.AQUA) + "none");
+ }
+
+ titleItem.addLore(lore);
+ this.inv.setItem(41, titleItem.getItem());
+ }
+
+ public void setFour() {
+ ViewItems intervalItem = new ViewItems(Material.REPEATER);
+ intervalItem.addName(String.valueOf(ChatColor.AQUA) + "Interval");
+ List lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Set the View Interval");
+ lore.add(" ");
+ int interval = this.playerConfig.getInt("Owned." + this.viewName + ".Interval");
+ String var10000 = String.valueOf(ChatColor.WHITE);
+ String string = var10000 + "Current: " + String.valueOf(ChatColor.AQUA) + interval + String.valueOf(ChatColor.WHITE) + " second(s)";
+ lore.add(string);
+ intervalItem.addLore(lore);
+ this.inv.setItem(16, intervalItem.getItem());
+ ViewItems typeItem = new ViewItems(Material.OAK_SIGN);
+ typeItem.addName(String.valueOf(ChatColor.AQUA) + "Type");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Set the View Type");
+ lore.add(" ");
+ string = this.playerConfig.getString("Owned." + this.viewName + ".Type");
+ String var10001 = String.valueOf(ChatColor.WHITE);
+ lore.add(var10001 + "Current: " + String.valueOf(ChatColor.AQUA) + string);
+ typeItem.addLore(lore);
+ this.inv.setItem(25, typeItem.getItem());
+ ViewItems inviteItem = new ViewItems(Material.LIME_CONCRETE);
+ inviteItem.addName(String.valueOf(ChatColor.GREEN) + "Invite");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Invite a Player to the View");
+ inviteItem.addLore(lore);
+ this.inv.setItem(34, inviteItem.getItem());
+ ViewItems uninviteItem = new ViewItems(Material.RED_TERRACOTTA);
+ uninviteItem.addName(String.valueOf(ChatColor.RED) + "Uninvite");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Uninvite a Player to the View");
+ uninviteItem.addLore(lore);
+ this.inv.setItem(43, uninviteItem.getItem());
+ }
+
+ public void addMisc() {
+ ViewItems showItem = new ViewItems(Material.GRASS_BLOCK);
+ showItem.addName(String.valueOf(ChatColor.AQUA) + "Show");
+ List lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Show the View");
+ showItem.addLore(lore);
+ this.inv.setItem(47, showItem.getItem());
+ ViewItems contItem = new ViewItems(Material.ANVIL);
+ contItem.addName(String.valueOf(ChatColor.AQUA) + "Next View");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Set the follow-up View");
+ lore.add(" ");
+ String string = "none";
+ if (this.playerConfig.get("Owned." + this.viewName + ".FollowUp") != null) {
+ string = this.playerConfig.getString("Owned." + this.viewName + ".FollowUp");
+ }
+
+ String var10001 = String.valueOf(ChatColor.WHITE);
+ lore.add(var10001 + "Current: " + String.valueOf(ChatColor.AQUA) + string);
+ contItem.addLore(lore);
+ this.inv.setItem(49, contItem.getItem());
+ ViewItems soundItem = new ViewItems(Material.JUKEBOX);
+ soundItem.addName(String.valueOf(ChatColor.AQUA) + "Sound");
+ lore = new ArrayList();
+ lore.add(" ");
+ lore.add(String.valueOf(ChatColor.WHITE) + "Set the follow-up View");
+ lore.add(" ");
+ string = "none";
+ if (this.playerConfig.get("Owned." + this.viewName + ".Sound") != null) {
+ string = this.playerConfig.getString("Owned." + this.viewName + ".Sound");
+ }
+
+ var10001 = String.valueOf(ChatColor.WHITE);
+ lore.add(var10001 + "Current: " + String.valueOf(ChatColor.AQUA) + string);
+ soundItem.addLore(lore);
+ this.inv.setItem(51, soundItem.getItem());
+ }
+
+ public void confirm(String title) {
+ ViewItems confirmItem = new ViewItems(Material.LIME_CONCRETE);
+ String var10001 = String.valueOf(ChatColor.GREEN);
+ confirmItem.addName(var10001 + title);
+ this.inv.setItem(10, confirmItem.getItem());
+ ViewItems declineItem = new ViewItems(Material.RED_CONCRETE);
+ declineItem.addName(String.valueOf(ChatColor.RED) + "Decline");
+ this.inv.setItem(16, declineItem.getItem());
+ ViewItems separate = new ViewItems(Material.BLACK_STAINED_GLASS_PANE);
+ separate.addName(" ");
+
+ for(int i = 4; i < 50; i += 9) {
+ this.inv.setItem(i, separate.getItem());
+ }
+
+ }
+
+ public Inventory getInventory() {
+ return this.inv;
+ }
+}
diff --git a/cinematicview/cinematicview/Classes/ViewItems.java b/cinematicview/cinematicview/Classes/ViewItems.java
new file mode 100644
index 0000000..3fc45a9
--- /dev/null
+++ b/cinematicview/cinematicview/Classes/ViewItems.java
@@ -0,0 +1,36 @@
+package cinematicview.cinematicview.Classes;
+
+import java.util.List;
+import org.bukkit.Material;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+public class ViewItems extends ItemStack {
+ private final ItemStack itemStack;
+
+ public ViewItems(Material material) {
+ this.itemStack = new ItemStack(material);
+ }
+
+ public void addName(String name) {
+ ItemMeta itemMeta = this.itemStack.getItemMeta();
+
+ assert itemMeta != null;
+
+ itemMeta.setDisplayName(name);
+ this.itemStack.setItemMeta(itemMeta);
+ }
+
+ public void addLore(List lore) {
+ ItemMeta itemMeta = this.itemStack.getItemMeta();
+
+ assert itemMeta != null;
+
+ itemMeta.setLore(lore);
+ this.itemStack.setItemMeta(itemMeta);
+ }
+
+ public ItemStack getItem() {
+ return this.itemStack;
+ }
+}
diff --git a/cinematicview/cinematicview/Commands/Commands.java b/cinematicview/cinematicview/Commands/Commands.java
new file mode 100644
index 0000000..03977be
--- /dev/null
+++ b/cinematicview/cinematicview/Commands/Commands.java
@@ -0,0 +1,222 @@
+package cinematicview.cinematicview.Commands;
+
+import cinematicview.cinematicview.CinematicView;
+import cinematicview.cinematicview.Functions.BasicView;
+import cinematicview.cinematicview.Functions.InfoView;
+import cinematicview.cinematicview.Functions.ModifyView;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+public class Commands implements CommandExecutor {
+ private final CinematicView plugin;
+
+ public Commands(CinematicView plugin) {
+ this.plugin = plugin;
+ }
+
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ BasicView basicView = new BasicView();
+ ModifyView modifyView = new ModifyView();
+ InfoView infoView = new InfoView();
+ switch(args.length) {
+ case 1:
+ if (args[0].equalsIgnoreCase("help")) {
+ basicView.help1(sender);
+ return true;
+ }
+
+ basicView.seeHelp(sender);
+ break;
+ case 2:
+ if (args[0].equalsIgnoreCase("test")) {
+ basicView.spawnNPC((Player)sender, this.plugin, 100L);
+ return true;
+ }
+
+ if (args[0].equalsIgnoreCase("admin") && args[1].equalsIgnoreCase("reload")) {
+ basicView.reload(sender, this.plugin);
+ return true;
+ }
+
+ if (args[0].equalsIgnoreCase("help")) {
+ basicView.help(sender, args[1]);
+ return true;
+ }
+
+ if (args[0].equalsIgnoreCase("view") && args[1].equalsIgnoreCase("stop")) {
+ basicView.stopView(sender, this.plugin, true, true);
+ return true;
+ }
+
+ if (args[0].equalsIgnoreCase("open")) {
+ basicView.openGUI(sender, args[1], this.plugin);
+ return true;
+ }
+
+ basicView.seeHelp(sender);
+ break;
+ case 3:
+ if (!args[0].equalsIgnoreCase("view")) {
+ basicView.seeHelp(sender);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("show")) {
+ basicView.view(args[2], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("create")) {
+ basicView.create(args[2], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("add")) {
+ basicView.add(args[2], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("removeall")) {
+ basicView.removeAll(args[2], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("delete")) {
+ basicView.delete(args[2], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("info")) {
+ infoView.getView(args[2], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("sound")) {
+ modifyView.setSound(args[2], sender, "none", this.plugin);
+ return true;
+ }
+
+ basicView.seeHelp(sender);
+ break;
+ case 4:
+ if (!args[0].equalsIgnoreCase("view") && !args[0].equalsIgnoreCase("admin")) {
+ basicView.seeHelp(sender);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("remove")) {
+ basicView.remove(args[2], args[3], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("invite")) {
+ modifyView.member(args[2], args[3], sender, true, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("uninvite")) {
+ modifyView.member(args[2], args[3], sender, false, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("force") && args[0].equalsIgnoreCase("admin")) {
+ basicView.force(args[2], args[3], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("show") && args[0].equalsIgnoreCase("admin")) {
+ basicView.adminShow(args[2], args[3], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("location")) {
+ infoView.getLocation(args[2], args[3], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("replace")) {
+ basicView.replace(args[2], args[3], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("insert")) {
+ modifyView.insert(args[2], args[3], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("title")) {
+ modifyView.title(args[2], args[3], false, (String)null, sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("sound")) {
+ modifyView.setSound(args[2], sender, args[3], this.plugin);
+ return true;
+ }
+
+ basicView.seeHelp(sender);
+ break;
+ case 5:
+ if (!args[0].equalsIgnoreCase("view")) {
+ basicView.seeHelp(sender);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("swap")) {
+ modifyView.swap(args[2], args[3], args[4], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("set") && args[3].equalsIgnoreCase("type")) {
+ modifyView.type(args[2], args[4], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("set") && args[3].equalsIgnoreCase("interval")) {
+ modifyView.interval(args[2], args[4], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("title")) {
+ modifyView.title(args[2], args[3], true, args[4], sender, this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("set") && args[3].equalsIgnoreCase("titletype")) {
+ modifyView.titleType(args[2], sender, args[4], this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("set") && args[3].equalsIgnoreCase("travel")) {
+ modifyView.travelType(args[2], sender, args[4], this.plugin);
+ return true;
+ }
+
+ if (args[1].equalsIgnoreCase("set") && args[3].equalsIgnoreCase("follow-up")) {
+ basicView.setFollowUp(args[2], sender, args[4], this.plugin);
+ return true;
+ }
+
+ basicView.seeHelp(sender);
+ break;
+ default:
+ if (args.length > 4 && args[0].equalsIgnoreCase("view") && args[1].equalsIgnoreCase("title")) {
+ StringBuilder title = new StringBuilder();
+
+ for(int i = 4; i < args.length; ++i) {
+ title.append(args[i]).append(" ");
+ }
+
+ title.deleteCharAt(title.length() - 1);
+ modifyView.title(args[2], args[3], true, title.toString(), sender, this.plugin);
+ return true;
+ }
+
+ basicView.seeHelp(sender);
+ }
+
+ return true;
+ }
+}
diff --git a/cinematicview/cinematicview/Commands/TabCompletion.java b/cinematicview/cinematicview/Commands/TabCompletion.java
new file mode 100644
index 0000000..3b5543f
--- /dev/null
+++ b/cinematicview/cinematicview/Commands/TabCompletion.java
@@ -0,0 +1,155 @@
+package cinematicview.cinematicview.Commands;
+
+import cinematicview.cinematicview.Functions.TabComplete;
+import java.util.ArrayList;
+import java.util.List;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.command.TabCompleter;
+import org.bukkit.entity.Player;
+import org.bukkit.util.StringUtil;
+
+public class TabCompletion implements TabCompleter {
+ public List onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
+ TabComplete tabComplete = new TabComplete();
+ if (commandSender instanceof Player) {
+ Player p = (Player)commandSender;
+ List viewsList;
+ List sounds;
+ switch(strings.length) {
+ case 1:
+ return tabComplete.first(p);
+ case 2:
+ if (strings[0].equalsIgnoreCase("view")) {
+ viewsList = tabComplete.second();
+ return (List)StringUtil.copyPartialMatches(strings[1], viewsList, new ArrayList());
+ }
+
+ if (!strings[0].equalsIgnoreCase("admin") || !p.hasPermission("cinematicview.admin") && !p.isOp()) {
+ if (strings[0].equalsIgnoreCase("open")) {
+ viewsList = tabComplete.owned(p);
+ return (List)StringUtil.copyPartialMatches(strings[1], viewsList, new ArrayList());
+ }
+
+ if (strings[0].equalsIgnoreCase("help")) {
+ return tabComplete.help();
+ }
+ break;
+ }
+
+ return tabComplete.admin();
+ case 3:
+ if (!strings[0].equalsIgnoreCase("view") && !strings[0].equalsIgnoreCase("admin")) {
+ return tabComplete.empty();
+ }
+
+ if (strings[1].equalsIgnoreCase("force") && (p.hasPermission("cinematicview.admin") || p.isOp())) {
+ viewsList = tabComplete.owned(p);
+ return (List)StringUtil.copyPartialMatches(strings[2], viewsList, new ArrayList());
+ }
+
+ if (strings[1].equalsIgnoreCase("show")) {
+ viewsList = tabComplete.views(p);
+ return (List)StringUtil.copyPartialMatches(strings[2], viewsList, new ArrayList());
+ }
+
+ viewsList = tabComplete.second();
+ viewsList.remove("show");
+ viewsList.remove("stop");
+ if (viewsList.contains(strings[1])) {
+ sounds = tabComplete.owned(p);
+ return (List)StringUtil.copyPartialMatches(strings[2], sounds, new ArrayList());
+ }
+ break;
+ case 4:
+ if (strings[0].equalsIgnoreCase("admin")) {
+ if (strings[1].equalsIgnoreCase("force") && (p.hasPermission("cinematicview.admin") || p.isOp())) {
+ return tabComplete.online(p);
+ }
+
+ if (!strings[1].equalsIgnoreCase("show") || !p.hasPermission("cinematicview.admin") && !p.isOp()) {
+ return tabComplete.empty();
+ }
+
+ viewsList = tabComplete.adminShow();
+ return (List)StringUtil.copyPartialMatches(strings[3], viewsList, new ArrayList());
+ }
+
+ if (!strings[0].equalsIgnoreCase("view")) {
+ return null;
+ }
+
+ viewsList = tabComplete.owned(p);
+ if (strings[1].equalsIgnoreCase("remove") && viewsList.contains(strings[2])) {
+ return tabComplete.locations(strings[2], p);
+ }
+
+ if (strings[1].equalsIgnoreCase("location") && viewsList.contains(strings[2])) {
+ return tabComplete.locations(strings[2], p);
+ }
+
+ if (strings[1].equalsIgnoreCase("replace") && viewsList.contains(strings[2])) {
+ return tabComplete.locations(strings[2], p);
+ }
+
+ if (strings[1].equalsIgnoreCase("insert") && viewsList.contains(strings[2])) {
+ return tabComplete.locations(strings[2], p);
+ }
+
+ if (strings[1].equalsIgnoreCase("swap") && viewsList.contains(strings[2])) {
+ return tabComplete.locations(strings[2], p);
+ }
+
+ if (strings[1].equalsIgnoreCase("set")) {
+ return tabComplete.type();
+ }
+
+ if (strings[1].equalsIgnoreCase("title") && viewsList.contains(strings[2])) {
+ return tabComplete.locations(strings[2], p);
+ }
+
+ if (strings[1].equalsIgnoreCase("invite") && viewsList.contains(strings[2])) {
+ return tabComplete.online(p);
+ }
+
+ if (strings[1].equalsIgnoreCase("uninvite") && viewsList.contains(strings[2])) {
+ return tabComplete.members(p, strings[2]);
+ }
+
+ if (strings[1].equalsIgnoreCase("sound") && viewsList.contains(strings[2])) {
+ sounds = tabComplete.sounds();
+ return (List)StringUtil.copyPartialMatches(strings[3], sounds, new ArrayList());
+ }
+ break;
+ case 5:
+ if (!strings[0].equalsIgnoreCase("view")) {
+ return null;
+ }
+
+ viewsList = tabComplete.owned(p);
+ if (strings[1].equalsIgnoreCase("swap") && viewsList.contains(strings[2])) {
+ return tabComplete.locations(strings[2], p);
+ }
+
+ if (strings[1].equalsIgnoreCase("set") && strings[3].equalsIgnoreCase("type")) {
+ return tabComplete.types();
+ }
+
+ if (strings[1].equalsIgnoreCase("set") && strings[3].equalsIgnoreCase("titletype")) {
+ return tabComplete.titleTypes();
+ }
+
+ if (strings[1].equalsIgnoreCase("set") && strings[3].equalsIgnoreCase("travel")) {
+ return tabComplete.travelTypes();
+ }
+
+ if (strings[1].equalsIgnoreCase("set") && strings[3].equalsIgnoreCase("follow-up")) {
+ viewsList.add("none");
+ return viewsList;
+ }
+ }
+ }
+
+ return tabComplete.empty();
+ }
+}
diff --git a/cinematicview/cinematicview/CustomConfig/CustomConfig.java b/cinematicview/cinematicview/CustomConfig/CustomConfig.java
new file mode 100644
index 0000000..bef808c
--- /dev/null
+++ b/cinematicview/cinematicview/CustomConfig/CustomConfig.java
@@ -0,0 +1,38 @@
+package cinematicview.cinematicview.CustomConfig;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Objects;
+import org.bukkit.Bukkit;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.plugin.Plugin;
+
+public class CustomConfig {
+ public static File file;
+ public static FileConfiguration fileConfig;
+
+ public static void setup() {
+ file = new File(((Plugin)Objects.requireNonNull(Bukkit.getServer().getPluginManager().getPlugin("CinematicView"))).getDataFolder(), "userdata/Views.yml");
+ fileConfig = YamlConfiguration.loadConfiguration(file);
+ if (!file.exists()) {
+ fileConfig.createSection("Views");
+ save();
+ }
+
+ }
+
+ public static void save() {
+ try {
+ fileConfig.save(file);
+ } catch (IOException var1) {
+ var1.printStackTrace();
+ }
+
+ }
+
+ public static void reload() {
+ fileConfig = YamlConfiguration.loadConfiguration(file);
+ save();
+ }
+}
diff --git a/cinematicview/cinematicview/Functions/BasicView.java b/cinematicview/cinematicview/Functions/BasicView.java
new file mode 100644
index 0000000..f8654e7
--- /dev/null
+++ b/cinematicview/cinematicview/Functions/BasicView.java
@@ -0,0 +1,1106 @@
+package cinematicview.cinematicview.Functions;
+
+import cinematicview.cinematicview.CinematicView;
+import cinematicview.cinematicview.Classes.DummyConnection;
+import cinematicview.cinematicview.Classes.ViewInventory;
+import cinematicview.cinematicview.CustomConfig.CustomConfig;
+import cinematicview.cinematicview.PlayerManager.CustomPlayer;
+import cinematicview.cinematicview.PlayerManager.PlayerManager;
+import com.mojang.authlib.GameProfile;
+import com.mojang.authlib.properties.Property;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.UUID;
+import net.luckperms.api.LuckPerms;
+import net.luckperms.api.model.group.Group;
+import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
+import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
+import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy;
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
+import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket.a;
+import net.minecraft.network.protocol.game.PacketPlayOutEntity.PacketPlayOutEntityLook;
+import net.minecraft.network.syncher.DataWatcher;
+import net.minecraft.network.syncher.DataWatcherObject;
+import net.minecraft.network.syncher.DataWatcherRegistry;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.level.EntityPlayer;
+import net.minecraft.server.level.EntityTrackerEntry;
+import net.minecraft.server.level.WorldServer;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Chunk;
+import org.bukkit.GameMode;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.World;
+import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.craftbukkit.v1_21_R1.CraftWorld;
+import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer;
+import org.bukkit.entity.BlockDisplay;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.plugin.RegisteredServiceProvider;
+import org.bukkit.scheduler.BukkitRunnable;
+import org.bukkit.util.Vector;
+
+public class BasicView {
+ Common common = new Common();
+ isAllowed isAllowed = new isAllowed();
+ private ItemStack headItem;
+ public static List playerShow = new ArrayList();
+ String pluginName;
+ String viewRestricted;
+ String pluginReload;
+ String help;
+ String seeHelp;
+ String viewObstructed;
+ String noViewStop;
+ String viewStop;
+
+ public BasicView() {
+ String var10001 = String.valueOf(ChatColor.AQUA);
+ this.pluginName = "\n[" + var10001 + "CinematicView" + String.valueOf(ChatColor.WHITE) + "] ";
+ this.viewRestricted = this.pluginName + "View is restricted.\n ";
+ this.pluginReload = this.pluginName + "CinematicView has been reloaded.\n ";
+ this.help = this.pluginName + "Not a valid help page. '/cv help' has 3 Pages.\n ";
+ this.seeHelp = this.pluginName + "Incorrect use of command. See /cv help.\n ";
+ this.viewObstructed = this.pluginName + "View location obstructed.\n ";
+ this.noViewStop = this.pluginName + "There is no view to stop.\n ";
+ this.viewStop = this.pluginName + "Stopping view.\n ";
+ }
+
+ public List getPlayerShow() {
+ return playerShow;
+ }
+
+ public void create(String viewName, CommandSender sender, CinematicView plugin) {
+ if (sender instanceof Player) {
+ Player player = (Player)sender;
+ if (!this.isAllowed.viewExists(player, viewName, true)) {
+ return;
+ }
+
+ if (this.isAllowed.checkBasicPerms(player, plugin)) {
+ return;
+ }
+
+ this.viewSetup(player, viewName, plugin);
+ this.addViewsFile(player, viewName);
+ viewName = this.common.addColourName(viewName);
+ player.sendMessage(this.pluginName + "Created view called " + viewName + ".\n ");
+ }
+
+ }
+
+ public void viewSetup(Player player, String viewName, CinematicView plugin) {
+ File file = this.common.getPlayerFile(player.getUniqueId());
+ FileConfiguration playerFile = this.common.getFileConfig(file);
+ String viewPath = this.common.getViewPath(viewName);
+ playerFile.set(viewPath + "Owner", player.getName());
+ playerFile.set(viewPath + "Size", 0);
+ playerFile.set(viewPath + "Interval", plugin.getConfig().getInt("default-interval"));
+ playerFile.set(viewPath + "Type", "Private");
+ playerFile.createSection(viewPath + "Members");
+ playerFile.createSection(viewPath + "Locations");
+ this.common.saveFile(playerFile, file);
+ }
+
+ public void add(String viewName, CommandSender sender, CinematicView plugin) {
+ if (sender instanceof Player) {
+ Player player = (Player)sender;
+ if (this.isAllowed.viewExists(player, viewName, false)) {
+ return;
+ }
+
+ if (this.isAllowed.checkBasicPerms(player, plugin)) {
+ return;
+ }
+
+ if (!this.isAllowed.checkMaxViews(sender, plugin, viewName)) {
+ return;
+ }
+
+ if (this.isAllowed.checkOwner(sender, viewName)) {
+ return;
+ }
+
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ if (this.isAllowed.checkWorld(player, targetUUID, viewName)) {
+ return;
+ }
+
+ this.addLocation(file, targetFile, player, viewName);
+ }
+
+ }
+
+ public void addLocation(File file, FileConfiguration fileConfig, Player player, String viewName) {
+ String viewPath = this.common.getViewPath(viewName);
+ int viewSize = fileConfig.getInt(viewPath + "Size");
+ ++viewSize;
+ fileConfig.set(viewPath + "Locations." + viewSize, player.getLocation());
+ fileConfig.set(viewPath + "Size", viewSize);
+ this.common.saveFile(fileConfig, file);
+ viewName = this.common.addColourName(viewName);
+ player.sendMessage(this.pluginName + "Added location to " + viewName + " View.\n ");
+ }
+
+ public void remove(String viewName, String viewLocation, CommandSender sender, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.checkBasicPerms(sender, plugin)) {
+ if (!this.isAllowed.checkLocation(sender, viewLocation, viewName)) {
+ if (!this.isAllowed.checkOwner(sender, viewName)) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ this.removeLocation(file, targetFile, sender, viewName, viewLocation);
+ }
+ }
+ }
+ }
+ }
+
+ public void removeLocation(File file, FileConfiguration fileConfig, CommandSender sender, String viewName, String viewLocation) {
+ String viewPath = this.common.getViewPath(viewName);
+ int location = this.common.parseInteger(viewLocation);
+ int viewSize = fileConfig.getInt(viewPath + ".Size");
+ fileConfig.set(viewPath + "Locations." + viewLocation, (Object)null);
+
+ while(location < viewSize) {
+ fileConfig.set(viewPath + "Locations." + location, fileConfig.getLocation(viewPath + "Locations." + (location + 1)));
+ fileConfig.set(viewPath + "Locations." + (location + 1), (Object)null);
+ fileConfig.set(viewPath + "Titles." + location + ".Title", fileConfig.getString(viewPath + "Titles." + (location + 1) + ".Title"));
+ fileConfig.set(viewPath + "Titles." + (location + 1), (Object)null);
+ ++location;
+ }
+
+ fileConfig.set(viewPath + "Size", viewSize - 1);
+ this.common.saveFile(fileConfig, file);
+ viewName = this.common.addColourName(viewName);
+ sender.sendMessage(this.pluginName + "Removed location " + viewLocation + " from " + viewName + " View.\n ");
+ }
+
+ public void removeAll(String viewName, CommandSender sender, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.checkBasicPerms(sender, plugin)) {
+ if (!this.isAllowed.checkOwner(sender, viewName)) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ if (!this.isAllowed.isSizeZero(sender, viewName)) {
+ this.removeAllLocations(file, targetFile, sender, viewName);
+ }
+ }
+ }
+ }
+ }
+
+ public void removeAllLocations(File file, FileConfiguration fileConfig, CommandSender sender, String viewName) {
+ String viewPath = this.common.getViewPath(viewName);
+ fileConfig.set(viewPath + "Size", 0);
+ List locations = fileConfig.getStringList(viewPath + "Locations");
+ List titles = fileConfig.getStringList(viewPath + "Titles");
+ titles.clear();
+ locations.clear();
+ fileConfig.set(viewPath + "Locations", locations);
+ fileConfig.set(viewPath + "Titles", titles);
+ this.common.saveFile(fileConfig, file);
+ viewName = this.common.addColourName(viewName);
+ sender.sendMessage(this.pluginName + "Removed all locations from " + viewName + " View.\n ");
+ }
+
+ public void view(String viewName, CommandSender sender, CinematicView plugin) {
+ if (sender instanceof Player) {
+ Player player = (Player)sender;
+ File playerFile = this.common.getPlayerFile(player.getUniqueId());
+ FileConfiguration playerConfig = this.common.getFileConfig(playerFile);
+ if (this.isAllowed.isShowing(player, plugin)) {
+ return;
+ }
+
+ if (this.isAllowed.viewExists(player, viewName, false)) {
+ return;
+ }
+
+ if (this.isAllowed.isSizeZero(player, viewName)) {
+ return;
+ }
+
+ boolean showViewMessage = plugin.getConfig().getBoolean("show-view-message");
+ if (this.checkViewPublic(viewName)) {
+ this.showView(viewName, player, plugin, showViewMessage, true);
+ return;
+ }
+
+ if (this.isAllowed.checkBasicPerms(player, plugin)) {
+ return;
+ }
+
+ if (this.isAllowed.checkAdminPerms(sender)) {
+ this.showView(viewName, player, plugin, showViewMessage, true);
+ return;
+ }
+
+ if (this.checkViewMember(viewName, player.getName())) {
+ this.showView(viewName, player, plugin, showViewMessage, true);
+ return;
+ }
+
+ String viewPath = this.common.getViewPath(viewName);
+ if (Objects.equals(playerConfig.getString(viewPath + "Owner"), player.getName())) {
+ this.showView(viewName, player, plugin, showViewMessage, true);
+ return;
+ }
+
+ player.sendMessage(this.viewRestricted);
+ }
+
+ }
+
+ public void showView(String viewName, Player player, CinematicView plugin, boolean showMessage, boolean doSetup) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File targetFile = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetConfig = this.common.getFileConfig(targetFile);
+ String viewPath = this.common.getViewPath(viewName);
+ int viewSize = this.common.getViewSize(viewName);
+ long interval = targetConfig.getLong(viewPath + "Interval") * 20L;
+ String travel = "teleport";
+ if (targetConfig.get(viewPath + ".Travel") != null) {
+ travel = targetConfig.getString(viewPath + ".Travel");
+ }
+
+ if (doSetup) {
+ this.showSetup(player, plugin, viewName, showMessage, targetConfig, viewPath);
+ }
+
+ List locations = new ArrayList();
+ List titles = new ArrayList();
+ boolean locObstructed = false;
+
+ for(int j = 1; j <= viewSize; ++j) {
+ Location loc = targetConfig.getLocation("Owned." + viewName + ".Locations." + j);
+ String title = targetConfig.getString("Owned." + viewName + ".Titles." + j + ".Title");
+
+ assert loc != null;
+
+ Location checkPos = new Location(loc.getWorld(), loc.getX(), loc.getY() + 1.0D, loc.getZ());
+ if (checkPos.getBlock().getType().equals(Material.AIR)) {
+ locations.add(loc);
+ titles.add(title);
+ } else if (!locObstructed) {
+ locObstructed = true;
+ player.sendMessage(this.viewObstructed);
+ }
+ }
+
+ assert travel != null;
+
+ if (travel.equalsIgnoreCase("teleport")) {
+ this.showTitle(player, titles, targetConfig, viewPath, interval, plugin);
+ this.teleport(plugin, player, targetConfig, locations, viewName, interval);
+ } else if (travel.equalsIgnoreCase("move")) {
+ this.showTitle(player, titles, targetConfig, viewPath, interval, plugin);
+ if (plugin.getConfig().get("move-function") != null && plugin.getConfig().getString("move-function").equalsIgnoreCase("smooth")) {
+ this.moveSmooth(plugin, player, targetConfig, locations, viewName, interval);
+ return;
+ }
+
+ this.moveTeleport(plugin, player, targetConfig, locations, viewName, interval);
+ }
+
+ }
+
+ void teleport(final CinematicView plugin, final Player player, final FileConfiguration targetConfig, final List locations, final String viewName, long interval) {
+ (new BukkitRunnable() {
+ int i = 0;
+
+ public void run() {
+ if (plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()) != null && plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getTaskID() == 0) {
+ plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).setTaskID(this.getTaskId());
+ }
+
+ if (!plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getShowingView()) {
+ this.cancel();
+ } else if (this.i >= locations.size()) {
+ this.cancel();
+ if (targetConfig.get("Owned." + viewName + ".FollowUp") != null) {
+ String nextView = targetConfig.getString("Owned." + viewName + ".FollowUp");
+ BasicView.this.showView(nextView, player, plugin, false, false);
+ } else {
+ BasicView.this.stopView(player, plugin, false, false);
+ }
+ } else {
+ Location viewLocation = (Location)locations.get(this.i);
+ BasicView.this.loadChunks(viewLocation.getChunk(), plugin);
+ player.teleport(viewLocation, TeleportCause.PLUGIN);
+ ++this.i;
+ }
+ }
+ }).runTaskTimer(plugin, 2L, interval);
+ }
+
+ void moveSmooth(final CinematicView plugin, final Player player, final FileConfiguration targetConfig, List locations, final String viewName, long interval) {
+ final List updatedLocs = new ArrayList();
+ int locPlaces = (int)interval / 20;
+
+ for(int j = 0; j < locations.size() - 1; ++j) {
+ Location startLoc = (Location)locations.get(j);
+ if (j == 0) {
+ updatedLocs.add(startLoc);
+ }
+
+ Location endLoc = (Location)locations.get(j + 1);
+ double dx = endLoc.getX() - startLoc.getX();
+ double dy = endLoc.getY() - startLoc.getY();
+ double dz = endLoc.getZ() - startLoc.getZ();
+ float dyaw = endLoc.getYaw() - startLoc.getYaw();
+ float dpitch = endLoc.getPitch() - startLoc.getPitch();
+ if (dyaw > 180.0F) {
+ dyaw -= 360.0F;
+ } else if (dyaw < -180.0F) {
+ dyaw += 360.0F;
+ }
+
+ if (dpitch < -180.0F) {
+ dpitch += 360.0F;
+ } else if (dpitch > 180.0F) {
+ dpitch -= 360.0F;
+ }
+
+ for(float k = 1.0F; k <= (float)locPlaces; ++k) {
+ float mult = k / (float)locPlaces;
+ updatedLocs.add(new Location(startLoc.getWorld(), startLoc.getX() + dx * (double)mult, startLoc.getY() + dy * (double)mult, startLoc.getZ() + dz * (double)mult, startLoc.getYaw() + dyaw * mult, startLoc.getPitch() + dpitch * mult));
+ }
+ }
+
+ Location firstLoc = (Location)updatedLocs.get(0);
+ firstLoc = new Location(firstLoc.getWorld(), firstLoc.getX(), firstLoc.getY() + 1.75D, firstLoc.getZ(), firstLoc.getYaw(), firstLoc.getPitch());
+ final BlockDisplay blockDisplay = (BlockDisplay)firstLoc.getWorld().spawnEntity(firstLoc, EntityType.BLOCK_DISPLAY);
+ blockDisplay.setBlock(Material.AIR.createBlockData());
+ blockDisplay.setTeleportDuration(20);
+ player.teleport((Location)updatedLocs.get(0));
+ (new BukkitRunnable() {
+ int i = 0;
+
+ public void run() {
+ if (plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()) != null && plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getTaskID() == 0) {
+ plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).setTaskID(this.getTaskId());
+ }
+
+ if (!plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getShowingView()) {
+ this.cancel();
+ } else {
+ if (player.getSpectatorTarget() != blockDisplay) {
+ player.setGameMode(GameMode.SPECTATOR);
+ player.setSpectatorTarget(blockDisplay);
+ }
+
+ if (this.i >= updatedLocs.size() - 1) {
+ this.cancel();
+ blockDisplay.remove();
+ if (targetConfig.get("Owned." + viewName + ".FollowUp") != null) {
+ String nextView = targetConfig.getString("Owned." + viewName + ".FollowUp");
+ BasicView.this.showView(nextView, player, plugin, false, false);
+ } else {
+ BasicView.this.stopView(player, plugin, false, false);
+ }
+ } else {
+ if (this.i < updatedLocs.size() - 1) {
+ Location endLoc = (Location)updatedLocs.get(this.i + 1);
+ endLoc = new Location(endLoc.getWorld(), endLoc.getX(), endLoc.getY() + 1.75D, endLoc.getZ(), endLoc.getYaw(), endLoc.getPitch());
+ blockDisplay.teleport(endLoc, TeleportCause.PLUGIN);
+ Vector vector = new Vector(0, 0, 0);
+ player.setVelocity(vector);
+ }
+
+ ++this.i;
+ }
+ }
+ }
+ }).runTaskTimer(plugin, 2L, 20L);
+ }
+
+ void moveTeleport(final CinematicView plugin, final Player player, final FileConfiguration targetConfig, final List locations, final String viewName, final long interval) {
+ (new BukkitRunnable() {
+ int i = 0;
+
+ public void run() {
+ if (plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()) != null && plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getTaskID() == 0) {
+ plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).setTaskID(this.getTaskId());
+ }
+
+ if (!plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getShowingView()) {
+ this.cancel();
+ } else if (this.i >= locations.size() - 1) {
+ this.cancel();
+ if (targetConfig.get("Owned." + viewName + ".FollowUp") != null) {
+ String nextView = targetConfig.getString("Owned." + viewName + ".FollowUp");
+ BasicView.this.showView(nextView, player, plugin, false, false);
+ } else {
+ BasicView.this.stopView(player, plugin, false, false);
+ }
+ } else {
+ Location viewLocation = (Location)locations.get(this.i);
+ player.teleport(viewLocation, TeleportCause.PLUGIN);
+ if (this.i < locations.size() - 1) {
+ Location nextLoc = (Location)locations.get(this.i + 1);
+ double dx = nextLoc.getX() - viewLocation.getX();
+ double dy = nextLoc.getY() - viewLocation.getY();
+ double dz = nextLoc.getZ() - viewLocation.getZ();
+ float dpitch = nextLoc.getPitch() - viewLocation.getPitch();
+ float dyaw = nextLoc.getYaw() - viewLocation.getYaw();
+ if (dyaw > 180.0F) {
+ dyaw -= 360.0F;
+ } else if (dyaw < -180.0F) {
+ dyaw += 360.0F;
+ }
+
+ if (dpitch < -180.0F) {
+ dpitch += 360.0F;
+ } else if (dpitch > 180.0F) {
+ dpitch -= 360.0F;
+ }
+
+ (new BukkitRunnable(viewLocation, dyaw, dpitch, dx, dy, dz) {
+ int ticksPassed;
+ // $FF: synthetic field
+ final Location val$viewLocation;
+ // $FF: synthetic field
+ final float val$finalDyaw;
+ // $FF: synthetic field
+ final float val$finalDpitch;
+ // $FF: synthetic field
+ final double val$dx;
+ // $FF: synthetic field
+ final double val$dy;
+ // $FF: synthetic field
+ final double val$dz;
+ // $FF: synthetic field
+ final this$1;
+
+ {
+ this.this$1 = this$1;
+ this.val$viewLocation = var2;
+ this.val$finalDyaw = var3;
+ this.val$finalDpitch = var4;
+ this.val$dx = var5;
+ this.val$dy = var7;
+ this.val$dz = var9;
+ this.ticksPassed = 0;
+ }
+
+ public void run() {
+ if (this.this$1.val$plugin.getPlayerManager().getCustomPlayer(this.this$1.val$player.getUniqueId()) != null && this.this$1.val$plugin.getPlayerManager().getCustomPlayer(this.this$1.val$player.getUniqueId()).getInnerTask() == 0) {
+ this.this$1.val$plugin.getPlayerManager().getCustomPlayer(this.this$1.val$player.getUniqueId()).setInnerTask(this.getTaskId());
+ }
+
+ if (!this.this$1.val$plugin.getPlayerManager().getCustomPlayer(this.this$1.val$player.getUniqueId()).getShowingView()) {
+ this.cancel();
+ } else {
+ if ((long)this.ticksPassed >= this.this$1.val$interval) {
+ this.cancel();
+ }
+
+ double mult = (double)this.ticksPassed / (double)this.this$1.val$interval;
+ if ((long)this.ticksPassed < this.this$1.val$interval) {
+ float newYaw = this.val$viewLocation.getYaw() + this.val$finalDyaw * (float)mult;
+ float newPitch = this.val$viewLocation.getPitch() + this.val$finalDpitch * (float)mult;
+ double x = this.val$viewLocation.getX() + this.val$dx * mult;
+ double y = this.val$viewLocation.getY() + this.val$dy * mult;
+ double z = this.val$viewLocation.getZ() + this.val$dz * mult;
+ Location newLocation = this.this$1.val$player.getLocation();
+ newLocation.setX(x);
+ newLocation.setY(y);
+ newLocation.setZ(z);
+ newLocation.setYaw(newYaw);
+ newLocation.setPitch(newPitch);
+ this.this$1.val$player.teleport(newLocation, TeleportCause.PLUGIN);
+ }
+
+ ++this.ticksPassed;
+ }
+ }
+ }).runTaskTimer(plugin, 0L, 1L);
+ }
+
+ ++this.i;
+ }
+ }
+ }).runTaskTimer(plugin, 2L, interval);
+ }
+
+ void showTitle(final Player player, final List titles, final FileConfiguration fileConfig, final String viewPath, final long interval, CinematicView plugin) {
+ if (fileConfig.get(viewPath + "TitleType") != null) {
+ (new BukkitRunnable() {
+ int i = 0;
+
+ public void run() {
+ if (this.i > titles.size() - 1) {
+ this.cancel();
+ } else {
+ String locTitle = (String)titles.get(this.i);
+ if (locTitle != null) {
+ String titleType = fileConfig.getString(viewPath + "TitleType");
+
+ assert titleType != null;
+
+ if (interval == 20L) {
+ if (titleType.equalsIgnoreCase("title")) {
+ player.sendTitle(locTitle, (String)null, 0, 20, 0);
+ } else if (titleType.equalsIgnoreCase("subtitle")) {
+ player.sendTitle(" ", locTitle, 0, 20, 0);
+ }
+ } else if (titleType.equalsIgnoreCase("title")) {
+ player.sendTitle(locTitle, (String)null, 10, 20, 10);
+ } else if (titleType.equalsIgnoreCase("subtitle")) {
+ player.sendTitle(" ", locTitle, 10, 20, 10);
+ }
+ }
+
+ ++this.i;
+ }
+ }
+ }).runTaskTimer(plugin, 2L, interval);
+ }
+
+ }
+
+ public void showSetup(final Player player, CinematicView plugin, final String viewName, boolean showMessage, FileConfiguration targetConfig, String viewPath) {
+ PlayerManager playerManager = plugin.getPlayerManager();
+ playerManager.getCustomPlayer(player.getUniqueId()).setShowingView(true);
+ playerManager.getCustomPlayer(player.getUniqueId()).setGameMode(player.getGameMode());
+ playerManager.getCustomPlayer(player.getUniqueId()).setLocation(player.getLocation());
+ player.setWalkSpeed(0.0F);
+ player.setFlySpeed(0.0F);
+ player.setGameMode(GameMode.SPECTATOR);
+ this.common.hidePlayer(player, plugin);
+ playerShow.add(player);
+ long delay = targetConfig.getLong(viewPath + "Interval") * 20L;
+ String travel = "teleport";
+ if (targetConfig.get(viewPath + ".Travel") != null) {
+ travel = targetConfig.getString(viewPath + ".Travel");
+ }
+
+ int size = targetConfig.getInt(viewPath + ".Size");
+
+ assert travel != null;
+
+ if (travel.equalsIgnoreCase("teleport")) {
+ delay *= (long)size;
+ } else {
+ delay *= (long)(size - 1);
+ }
+
+ if (plugin.getConfig().getBoolean("show-npc")) {
+ this.spawnNPC(player, plugin, delay);
+ }
+
+ if (plugin.getConfig().getBoolean("pumpkin-head")) {
+ ItemStack pumpkin = new ItemStack(Material.CARVED_PUMPKIN);
+ if (player.getInventory().getHelmet() != null) {
+ this.headItem = player.getInventory().getHelmet();
+ }
+
+ player.getInventory().setHelmet(pumpkin);
+ }
+
+ if (showMessage) {
+ player.sendMessage(this.pluginName + "Viewing " + viewName + ".\n ");
+ }
+
+ (new BukkitRunnable() {
+ public void run() {
+ UUID targetUUID = BasicView.this.common.getPlayerUUID(viewName);
+ File file = BasicView.this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = BasicView.this.common.getFileConfig(file);
+ String s = targetFile.getString("Owned." + viewName + ".Sound");
+ if (s != null) {
+ player.playSound(player, Sound.valueOf(s), Float.MAX_VALUE, 1.0F);
+ }
+
+ }
+ }).runTaskLater(plugin, 2L);
+ }
+
+ public void delete(String viewName, CommandSender sender, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.checkBasicPerms(sender, plugin)) {
+ if (!this.isAllowed.checkOwner(sender, viewName)) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ this.deleteView(file, targetFile, sender, viewName);
+ }
+ }
+ }
+ }
+
+ public void spawnNPC(Player player, CinematicView plugin, long delay) {
+ Location location = player.getLocation();
+ CraftPlayer craftPlayer = (CraftPlayer)player;
+ EntityPlayer serverPlayer = craftPlayer.getHandle();
+ MinecraftServer server = serverPlayer.cO();
+ WorldServer level = ((CraftWorld)player.getWorld()).getHandle();
+ GameProfile playerProfile = craftPlayer.getProfile();
+ Property skinProperty = (Property)playerProfile.getProperties().get("textures").iterator().next();
+ GameProfile profile = new GameProfile(UUID.randomUUID(), player.getName());
+ profile.getProperties().put("textures", new Property("textures", skinProperty.value(), skinProperty.signature()));
+ final EntityPlayer npc = new EntityPlayer(server, level, profile, serverPlayer.C());
+ npc.c = new DummyConnection(server, npc, profile);
+ npc.a_(location.getX(), location.getY(), location.getZ());
+ npc.p(false);
+ EntityTrackerEntry npcServerEntity = new EntityTrackerEntry(serverPlayer.A(), serverPlayer, 0, false, (packet) -> {
+ }, Set.of());
+ DataWatcher synchedEntityData = npc.ar();
+ synchedEntityData.a(new DataWatcherObject(17, DataWatcherRegistry.a), (byte)126);
+ ClientboundPlayerInfoUpdatePacket packet1 = new ClientboundPlayerInfoUpdatePacket(a.a, npc);
+ PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(npc, npcServerEntity);
+ PacketPlayOutEntityMetadata packet3 = new PacketPlayOutEntityMetadata(npc.an(), synchedEntityData.c());
+ PacketPlayOutEntityLook packet4 = new PacketPlayOutEntityLook(npc.getBukkitEntity().getEntityId(), (byte)((int)(location.getYaw() * 256.0F / 360.0F)), (byte)((int)(location.getPitch() % 360.0F * 256.0F / 360.0F)), false);
+ Iterator var20 = Bukkit.getOnlinePlayers().iterator();
+
+ while(var20.hasNext()) {
+ Player onlinePlayer = (Player)var20.next();
+ ((CraftPlayer)onlinePlayer).getHandle().c.b(packet1);
+ ((CraftPlayer)onlinePlayer).getHandle().c.b(packet2);
+ ((CraftPlayer)onlinePlayer).getHandle().c.b(packet3);
+ ((CraftPlayer)onlinePlayer).getHandle().c.b(packet4);
+ }
+
+ (new BukkitRunnable() {
+ public void run() {
+ ClientboundPlayerInfoRemovePacket removeTabPacket = new ClientboundPlayerInfoRemovePacket(List.of(npc.cz()));
+ Iterator var2 = Bukkit.getOnlinePlayers().iterator();
+
+ while(var2.hasNext()) {
+ Player onlinePlayer = (Player)var2.next();
+ ((CraftPlayer)onlinePlayer).getHandle().c.b(removeTabPacket);
+ }
+
+ PacketPlayOutEntityMetadata hideHeadPacket = new PacketPlayOutEntityMetadata(npc.an(), npc.ar().c());
+ Iterator var7 = Bukkit.getOnlinePlayers().iterator();
+
+ while(var7.hasNext()) {
+ Player onlinePlayerx = (Player)var7.next();
+ ((CraftPlayer)onlinePlayerx).getHandle().c.b(hideHeadPacket);
+ }
+
+ PacketPlayOutEntityDestroy removeEntityPacket = new PacketPlayOutEntityDestroy(new int[]{npc.an()});
+ Iterator var9 = Bukkit.getOnlinePlayers().iterator();
+
+ while(var9.hasNext()) {
+ Player onlinePlayerxx = (Player)var9.next();
+ ((CraftPlayer)onlinePlayerxx).getHandle().c.b(removeEntityPacket);
+ }
+
+ }
+ }).runTaskLater(plugin, delay + 2L);
+ }
+
+ public void deleteView(File file, FileConfiguration fileConfig, CommandSender sender, String viewName) {
+ File views = this.common.getViewsFile();
+ FileConfiguration viewsFile = this.common.getFileConfig(views);
+ fileConfig.set("Owned." + viewName, (Object)null);
+ viewsFile.set("Views." + viewName, (Object)null);
+ this.common.saveFile(viewsFile, views);
+ this.common.saveFile(fileConfig, file);
+ viewName = this.common.addColourName(viewName);
+ sender.sendMessage(this.pluginName + "Deleted View " + viewName + ".\n ");
+ }
+
+ public void force(String viewName, String targetName, CommandSender sender, CinematicView plugin) {
+ if (this.isAllowed.checkAdminPerms(sender)) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.isSizeZero(sender, viewName)) {
+ if (!this.isAllowed.isOnline(sender, targetName)) {
+ Player target = Bukkit.getPlayer(targetName);
+
+ assert target != null;
+
+ if (this.isAllowed.isShowing(target, plugin)) {
+ this.stopView(target, plugin, false, false);
+ }
+
+ this.showView(viewName, target, plugin, false, true);
+ viewName = this.common.addColourName(viewName);
+ sender.sendMessage(this.pluginName + "Forced " + viewName + " View for " + targetName + ".\n ");
+ }
+ }
+ }
+ }
+ }
+
+ public void adminShow(String viewName, String target, CommandSender sender, CinematicView plugin) {
+ if (this.isAllowed.checkAdminPerms(sender)) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.isSizeZero(sender, viewName)) {
+ String var10001;
+ if (target.equalsIgnoreCase("all")) {
+ Player[] players = (Player[])Bukkit.getOnlinePlayers().toArray(new Player[0]);
+ String allExclude = plugin.getConfig().getString("all-exclude");
+
+ assert allExclude != null;
+
+ Player[] var16 = players;
+ int var17 = players.length;
+
+ for(int var19 = 0; var19 < var17; ++var19) {
+ Player p = var16[var19];
+ if (allExclude.equalsIgnoreCase("admins")) {
+ if (this.isAllowed.checkAdminPerms(p)) {
+ continue;
+ }
+ } else if (allExclude.equalsIgnoreCase("user") && sender instanceof Player) {
+ Player pl = (Player)sender;
+ if (p.getUniqueId().equals(pl.getUniqueId())) {
+ continue;
+ }
+ }
+
+ if (this.isAllowed.isShowing(p, plugin)) {
+ this.stopView(p, plugin, false, false);
+ }
+
+ this.showView(viewName, p, plugin, false, true);
+ }
+
+ var10001 = this.pluginName;
+ sender.sendMessage(var10001 + "Forced " + this.common.addColourName(viewName) + " View for all players.\n ");
+ } else {
+ RegisteredServiceProvider provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
+ if (provider != null) {
+ LuckPerms luckPerms = (LuckPerms)provider.getProvider();
+ List groups = luckPerms.getGroupManager().getLoadedGroups().stream().toList();
+ List groupNames = new ArrayList();
+ Iterator var9 = groups.iterator();
+
+ while(var9.hasNext()) {
+ Group g = (Group)var9.next();
+ groupNames.add(g.getName());
+ }
+
+ if (groupNames.contains(target)) {
+ Player[] onlinePlayer = (Player[])Bukkit.getOnlinePlayers().toArray(new Player[0]);
+ Player[] var20 = onlinePlayer;
+ int var11 = onlinePlayer.length;
+
+ for(int var12 = 0; var12 < var11; ++var12) {
+ Player p = var20[var12];
+ if (p.hasPermission("group." + target)) {
+ this.showView(viewName, p, plugin, false, true);
+ }
+ }
+
+ var10001 = this.pluginName;
+ sender.sendMessage(var10001 + "Showing View to " + this.common.addColourName(target) + " group.\n ");
+ } else {
+ sender.sendMessage(this.pluginName + "That group does not exist.\n ");
+ }
+ } else {
+ sender.sendMessage(this.pluginName + "LuckPerms has not been detected on the server. Certain features (1 feature) will not work.\n ");
+ }
+
+ }
+ }
+ }
+ }
+ }
+
+ public void reload(CommandSender sender, CinematicView plugin) {
+ if (this.isAllowed.checkAdminPerms(sender)) {
+ plugin.reloadConfig();
+ plugin.saveDefaultConfig();
+ plugin.getConfig().options().copyDefaults(true);
+ plugin.saveConfig();
+ CustomConfig.reload();
+ sender.sendMessage(this.pluginReload);
+ }
+ }
+
+ public void replace(String viewName, String viewLocation, CommandSender sender, CinematicView plugin) {
+ if (sender instanceof Player) {
+ Player player = (Player)sender;
+ if (this.isAllowed.viewExists(player, viewName, false)) {
+ return;
+ }
+
+ if (this.isAllowed.checkBasicPerms(sender, plugin)) {
+ return;
+ }
+
+ if (this.isAllowed.checkLocation(sender, viewLocation, viewName)) {
+ return;
+ }
+
+ if (this.isAllowed.checkOwner(sender, viewName)) {
+ return;
+ }
+
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ this.replaceLocation(file, targetFile, player, viewName, viewLocation);
+ }
+
+ }
+
+ public void replaceLocation(File file, FileConfiguration fileConfig, Player player, String viewName, String viewLocation) {
+ String viewPath = this.common.getViewPath(viewName);
+ fileConfig.set(viewPath + "Locations." + viewLocation, player.getLocation());
+ this.common.saveFile(fileConfig, file);
+ viewName = this.common.addColourName(viewName);
+ player.sendMessage(this.pluginName + "Replaced location " + viewLocation + " for " + viewName + " View.\n ");
+ }
+
+ public void help(CommandSender sender, String page) {
+ int Page = this.common.parseInteger(page);
+ if (Page > 0 && Page <= 3) {
+ switch(Page) {
+ case 1:
+ this.help1(sender);
+ break;
+ case 2:
+ this.help2(sender);
+ break;
+ case 3:
+ this.help3(sender);
+ }
+
+ } else {
+ sender.sendMessage(this.help);
+ }
+ }
+
+ public void help1(CommandSender sender) {
+ String var10000 = String.valueOf(ChatColor.AQUA);
+ String viewInfoHeader = "\n[" + var10000 + "CinematicView Help (Page 1 / 3)" + String.valueOf(ChatColor.WHITE) + "]";
+ String view = "/cv view show " + String.valueOf(ChatColor.AQUA) + " (Show a view)";
+ String create = "/cv view create " + String.valueOf(ChatColor.AQUA) + " (Create a view)";
+ String open = "/cv open " + String.valueOf(ChatColor.AQUA) + " (Opens a GUI to manage a View)";
+ String add = "/cv view add " + String.valueOf(ChatColor.AQUA) + " (Add a location to a view)";
+ String remove = "/cv view remove " + String.valueOf(ChatColor.AQUA) + " (Removes a specific location from a view)";
+ String removeall = "/cv view removeall " + String.valueOf(ChatColor.AQUA) + " (Removes all locations from a view)";
+ String delete = "/cv view delete " + String.valueOf(ChatColor.AQUA) + " (Deletes a view)";
+ String nextPage = "/cv help 2" + String.valueOf(ChatColor.AQUA) + " (For next page)\n ";
+ sender.sendMessage(viewInfoHeader);
+ sender.sendMessage(" ");
+ sender.sendMessage(view);
+ sender.sendMessage(create);
+ sender.sendMessage(open);
+ sender.sendMessage(add);
+ sender.sendMessage(remove);
+ sender.sendMessage(removeall);
+ sender.sendMessage(delete);
+ sender.sendMessage(nextPage);
+ }
+
+ public void help2(CommandSender sender) {
+ String var10000 = String.valueOf(ChatColor.AQUA);
+ String viewInfoHeader = "\n[" + var10000 + "CinematicView Help (Page 2 / 3)" + String.valueOf(ChatColor.WHITE) + "]";
+ String info = "/cv view info " + String.valueOf(ChatColor.AQUA) + " (Gives you the information of a view)";
+ String location = "/cv view location " + String.valueOf(ChatColor.AQUA) + " (Gives you the information of a specific location)";
+ String type = "/cv view set type " + String.valueOf(ChatColor.AQUA) + " (Sets the type of the view)";
+ String interval = "/cv view set interval " + String.valueOf(ChatColor.AQUA) + " (Sets the time interval between locations)";
+ String travel = "/cv view set travel " + String.valueOf(ChatColor.AQUA) + " (Sets the travel type of the view)";
+ String invite = "/cv view invite " + String.valueOf(ChatColor.AQUA) + " (Add a member to a view)";
+ String uninvite = "/cv view uninvite " + String.valueOf(ChatColor.AQUA) + " (Remove a member from a view)";
+ String nextPage = "/cv help 3" + String.valueOf(ChatColor.AQUA) + " (For next page)\n ";
+ sender.sendMessage(viewInfoHeader);
+ sender.sendMessage(" ");
+ sender.sendMessage(info);
+ sender.sendMessage(location);
+ sender.sendMessage(type);
+ sender.sendMessage(interval);
+ sender.sendMessage(travel);
+ sender.sendMessage(invite);
+ sender.sendMessage(uninvite);
+ sender.sendMessage(nextPage);
+ }
+
+ public void help3(CommandSender sender) {
+ String var10000 = String.valueOf(ChatColor.AQUA);
+ String viewInfoHeader = "\n[" + var10000 + "CinematicView Help (Page 3 / 3)" + String.valueOf(ChatColor.WHITE) + "]";
+ String replace = "/cv view replace " + String.valueOf(ChatColor.AQUA) + " (Replace a specific location)";
+ String swap = "/cv view swap " + String.valueOf(ChatColor.AQUA) + " (Swap two locations)";
+ String insert = "/cv view insert " + String.valueOf(ChatColor.AQUA) + " (Insert a location at a specific point)";
+ String title = "/cv view title " + String.valueOf(ChatColor.AQUA) + " (Adds a title to the specified location)";
+ String titletype = "/cv view set titletype " + String.valueOf(ChatColor.AQUA) + " (Sets the title type for the view)";
+ String followUp = "/cv view set follow-up " + String.valueOf(ChatColor.AQUA) + " (Sets the follow up view for the view)";
+ String sound = "/cv view sound " + String.valueOf(ChatColor.AQUA) + "(Sets the sound at the start of the view)";
+ String force = "/cv admin force " + String.valueOf(ChatColor.AQUA) + " (Force a player/all to see a view)";
+ String reload = "/cv admin reload" + String.valueOf(ChatColor.AQUA) + " (Reload the plugin)\n ";
+ sender.sendMessage(viewInfoHeader);
+ sender.sendMessage(" ");
+ sender.sendMessage(replace);
+ sender.sendMessage(swap);
+ sender.sendMessage(insert);
+ sender.sendMessage(title);
+ sender.sendMessage(titletype);
+ sender.sendMessage(followUp);
+ sender.sendMessage(sound);
+ sender.sendMessage(force);
+ sender.sendMessage(reload);
+ }
+
+ public void seeHelp(CommandSender sender) {
+ if (sender instanceof Player) {
+ Player p = (Player)sender;
+ p.sendMessage(this.seeHelp);
+ }
+
+ }
+
+ public void stopView(CommandSender sender, CinematicView plugin, boolean checkPerm, boolean sendMsg) {
+ if (sender instanceof Player) {
+ Player player = (Player)sender;
+ if (checkPerm && this.isAllowed.checkBasicPerms(sender, plugin)) {
+ return;
+ }
+
+ if (!plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getShowingView()) {
+ player.sendMessage(this.noViewStop);
+ return;
+ }
+
+ CustomPlayer customPlayer = plugin.getPlayerManager().getCustomPlayer(player.getUniqueId());
+ if (player.getGameMode() == GameMode.SPECTATOR) {
+ player.setSpectatorTarget((Entity)null);
+ }
+
+ player.setGameMode(customPlayer.getGameMode());
+ player.teleport(customPlayer.getLocation());
+ player.stopAllSounds();
+ if (plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getTaskID() != 0) {
+ Bukkit.getScheduler().cancelTask(plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getTaskID());
+ }
+
+ if (plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getInnerTask() != 0) {
+ Bukkit.getScheduler().cancelTask(plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getInnerTask());
+ }
+
+ plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).setShowingView(false);
+ player.setWalkSpeed(0.2F);
+ player.setFlySpeed(0.1F);
+ if (sendMsg) {
+ player.sendMessage(this.viewStop);
+ }
+
+ this.common.showPlayer(player, plugin);
+ if (plugin.getConfig().getBoolean("pumpkin-head")) {
+ if (this.headItem != null) {
+ player.getInventory().setHelmet(this.headItem);
+ } else {
+ player.getInventory().setHelmet((ItemStack)null);
+ }
+ }
+
+ playerShow.remove(player);
+ }
+
+ }
+
+ public void openGUI(CommandSender sender, String viewName, CinematicView plugin) {
+ if (sender instanceof Player) {
+ Player player = (Player)sender;
+ if (this.isAllowed.viewExists(player, viewName, false)) {
+ return;
+ }
+
+ if (this.isAllowed.checkBasicPerms(player, plugin)) {
+ return;
+ }
+
+ if (this.isAllowed.checkOwner(sender, viewName)) {
+ return;
+ }
+
+ ViewInventory inv = new ViewInventory(plugin, viewName, player);
+ inv.create();
+ player.openInventory(inv.getInventory());
+ }
+
+ }
+
+ public void addViewsFile(Player player, String viewName) {
+ File views = this.common.getViewsFile();
+ FileConfiguration viewsFile = this.common.getFileConfig(views);
+ viewsFile.set("Views." + viewName, player.getName());
+ this.common.saveFile(viewsFile, views);
+ }
+
+ public boolean checkViewPublic(String viewName) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ String viewPath = this.common.getViewPath(viewName);
+ return ((String)Objects.requireNonNull(targetFile.getString(viewPath + "Type"))).equalsIgnoreCase("Public");
+ }
+
+ public boolean checkViewMember(String viewName, String playerName) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ String viewPath = this.common.getViewPath(viewName);
+ List members = targetFile.getStringList(viewPath + "Members");
+ return members.contains(playerName);
+ }
+
+ public void loadChunks(Chunk chunk, CinematicView plugin) {
+ int offset = plugin.getConfig().getInt("chunky-radius");
+ World world = chunk.getWorld();
+ int baseX = chunk.getX();
+ int baseZ = chunk.getZ();
+
+ for(int x = -offset; x <= offset; ++x) {
+ for(int z = -offset; z <= offset; ++z) {
+ if (world.isChunkLoaded(baseX + x, baseZ + z)) {
+ world.getChunkAt(baseX + x, baseZ + z);
+ }
+ }
+ }
+
+ }
+
+ public void setFollowUp(String currentView, CommandSender sender, String nextView, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, currentView, false)) {
+ if (!this.isAllowed.checkBasicPerms(sender, plugin)) {
+ if (!this.isAllowed.checkOwner(sender, currentView)) {
+ UUID targetUUID = this.common.getPlayerUUID(currentView);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ String viewPath = this.common.getViewPath(currentView);
+ if (nextView.equals("none")) {
+ if (targetFile.get(viewPath + "FollowUp") == null) {
+ sender.sendMessage(this.pluginName + currentView + " already doesn't have a follow up View.\n ");
+ } else {
+ targetFile.set(viewPath + "FollowUp", (Object)null);
+ this.common.saveFile(targetFile, file);
+ sender.sendMessage(this.pluginName + "Removed " + currentView + "'s follow up View.\n ");
+ }
+ } else if (currentView.equals(nextView)) {
+ sender.sendMessage(this.pluginName + "Cannot set the follow up View as the same View.\n ");
+ } else if (!this.isAllowed.viewExists(sender, nextView, false)) {
+ if (!this.isAllowed.checkOwner(sender, nextView)) {
+ targetFile.set(viewPath + "FollowUp", nextView);
+ this.common.saveFile(targetFile, file);
+ String var10001 = this.pluginName;
+ sender.sendMessage(var10001 + "Set " + currentView + "'s follow up View to " + String.valueOf(ChatColor.AQUA) + nextView + String.valueOf(ChatColor.WHITE) + ".\n ");
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/cinematicview/cinematicview/Functions/Common.java b/cinematicview/cinematicview/Functions/Common.java
new file mode 100644
index 0000000..9f6a65d
--- /dev/null
+++ b/cinematicview/cinematicview/Functions/Common.java
@@ -0,0 +1,136 @@
+package cinematicview.cinematicview.Functions;
+
+import cinematicview.cinematicview.CinematicView;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.UUID;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+public class Common {
+ public Integer parseInteger(String viewLocation) {
+ byte location = 0;
+
+ int location;
+ try {
+ location = Integer.parseInt(viewLocation);
+ } catch (NumberFormatException var4) {
+ return Integer.valueOf(location);
+ }
+
+ return location;
+ }
+
+ public void saveFile(FileConfiguration fileConfiguration, File file) {
+ try {
+ fileConfiguration.save(file);
+ } catch (IOException var4) {
+ var4.printStackTrace();
+ }
+
+ }
+
+ public String getViewPath(String viewName) {
+ return "Owned." + viewName + ".";
+ }
+
+ public String addColourName(String viewName) {
+ String var10000 = String.valueOf(ChatColor.AQUA);
+ return var10000 + viewName + String.valueOf(ChatColor.WHITE);
+ }
+
+ public Set getAllViews() {
+ File views = this.getViewsFile();
+ FileConfiguration viewsFile = this.getFileConfig(views);
+ return ((ConfigurationSection)Objects.requireNonNull(viewsFile.getConfigurationSection("Views"))).getKeys(false);
+ }
+
+ public File getViewsFile() {
+ return new File(((Plugin)Objects.requireNonNull(Bukkit.getServer().getPluginManager().getPlugin("CinematicView"))).getDataFolder(), "userdata/Views.yml");
+ }
+
+ public FileConfiguration getFileConfig(File file) {
+ return YamlConfiguration.loadConfiguration(file);
+ }
+
+ public File getPlayerFile(UUID uuid) {
+ return new File(((Plugin)Objects.requireNonNull(Bukkit.getServer().getPluginManager().getPlugin("CinematicView"))).getDataFolder(), "userdata/" + String.valueOf(uuid) + ".yml");
+ }
+
+ public Set getPlayerViews(UUID uuid) {
+ File file = this.getPlayerFile(uuid);
+ FileConfiguration playerFile = this.getFileConfig(file);
+ return ((ConfigurationSection)Objects.requireNonNull(playerFile.getConfigurationSection("Owned"))).getKeys(false);
+ }
+
+ public UUID getPlayerUUID(String viewName) {
+ File views = this.getViewsFile();
+ FileConfiguration viewsFile = this.getFileConfig(views);
+ String targetName = viewsFile.getString("Views." + viewName);
+ OfflinePlayer[] playerList = Bukkit.getOfflinePlayers();
+ OfflinePlayer[] var6 = playerList;
+ int var7 = playerList.length;
+
+ for(int var8 = 0; var8 < var7; ++var8) {
+ OfflinePlayer target = var6[var8];
+ if (target != null && target.getName() != null && ((String)Objects.requireNonNull(target.getName())).equalsIgnoreCase(targetName)) {
+ return target.getUniqueId();
+ }
+ }
+
+ return null;
+ }
+
+ public int getViewSize(String viewName) {
+ UUID targetUUID = this.getPlayerUUID(viewName);
+ File file = this.getPlayerFile(targetUUID);
+ FileConfiguration fileConfig = this.getFileConfig(file);
+ String viewPath = this.getViewPath(viewName);
+ return fileConfig.getInt(viewPath + "Size");
+ }
+
+ public void addChatSetting(UUID uuid, String setting, String viewName, CinematicView plugin) {
+ Map map = new HashMap();
+ map.put(setting.toUpperCase(), viewName);
+ plugin.getPlayerManager().getCustomPlayer(uuid).setSetting(map);
+ }
+
+ public void removeChatSetting(UUID uuid, CinematicView plugin) {
+ Map map = new HashMap();
+ plugin.getPlayerManager().getCustomPlayer(uuid).setSetting(map);
+ }
+
+ public void hidePlayer(Player player, CinematicView plugin) {
+ Player[] players = (Player[])Bukkit.getOnlinePlayers().toArray(new Player[0]);
+ Player[] var4 = players;
+ int var5 = players.length;
+
+ for(int var6 = 0; var6 < var5; ++var6) {
+ Player p = var4[var6];
+ p.hidePlayer(plugin, player);
+ }
+
+ }
+
+ public void showPlayer(Player player, CinematicView plugin) {
+ Player[] players = (Player[])Bukkit.getOnlinePlayers().toArray(new Player[0]);
+ Player[] var4 = players;
+ int var5 = players.length;
+
+ for(int var6 = 0; var6 < var5; ++var6) {
+ Player p = var4[var6];
+ p.showPlayer(plugin, player);
+ }
+
+ }
+}
diff --git a/cinematicview/cinematicview/Functions/InfoView.java b/cinematicview/cinematicview/Functions/InfoView.java
new file mode 100644
index 0000000..4a01f02
--- /dev/null
+++ b/cinematicview/cinematicview/Functions/InfoView.java
@@ -0,0 +1,113 @@
+package cinematicview.cinematicview.Functions;
+
+import cinematicview.cinematicview.CinematicView;
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.file.FileConfiguration;
+
+public class InfoView {
+ Common common = new Common();
+ isAllowed isAllowed = new isAllowed();
+ String viewInfoHeader;
+
+ public InfoView() {
+ String var10001 = String.valueOf(ChatColor.AQUA);
+ this.viewInfoHeader = "\n[" + var10001 + "View Information" + String.valueOf(ChatColor.WHITE) + "]\n ";
+ }
+
+ public void getView(String viewName, CommandSender sender, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.checkInfoPerms(sender, plugin)) {
+ if (!this.isAllowed.checkOwner(sender, viewName)) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ this.getViewInformation(targetFile, sender, viewName);
+ }
+ }
+ }
+ }
+
+ public void getViewInformation(FileConfiguration fileConfig, CommandSender sender, String viewName) {
+ String viewPath = this.common.getViewPath(viewName);
+ String viewOwner = fileConfig.getString(viewPath + "Owner");
+ int viewSize = fileConfig.getInt(viewPath + "Size");
+ int viewInterval = fileConfig.getInt(viewPath + "Interval");
+ String viewType = fileConfig.getString(viewPath + "Type");
+ sender.sendMessage(this.viewInfoHeader);
+ String var10001 = String.valueOf(ChatColor.AQUA);
+ sender.sendMessage(var10001 + "View Name" + String.valueOf(ChatColor.WHITE) + ": " + viewName);
+ var10001 = String.valueOf(ChatColor.AQUA);
+ sender.sendMessage(var10001 + "View Owner" + String.valueOf(ChatColor.WHITE) + ": " + viewOwner);
+ var10001 = String.valueOf(ChatColor.AQUA);
+ sender.sendMessage(var10001 + "View Location Size" + String.valueOf(ChatColor.WHITE) + ": " + viewSize);
+ var10001 = String.valueOf(ChatColor.AQUA);
+ sender.sendMessage(var10001 + "View Interval" + String.valueOf(ChatColor.WHITE) + ": " + viewInterval);
+ var10001 = String.valueOf(ChatColor.AQUA);
+ sender.sendMessage(var10001 + "View Type" + String.valueOf(ChatColor.WHITE) + ": " + viewType);
+ List members = fileConfig.getStringList(viewPath + "Members");
+ if (!members.isEmpty()) {
+ StringBuilder viewMembers = new StringBuilder();
+ var10001 = String.valueOf(ChatColor.AQUA);
+ viewMembers.append(var10001 + "View Members" + String.valueOf(ChatColor.WHITE) + ": ");
+ int size = viewMembers.length();
+ Iterator var12 = members.iterator();
+
+ while(var12.hasNext()) {
+ String member = (String)var12.next();
+ if (viewMembers.length() == size) {
+ viewMembers.append(member);
+ } else {
+ var10001 = String.valueOf(ChatColor.AQUA);
+ viewMembers.append(var10001 + "," + String.valueOf(ChatColor.WHITE) + " ").append(member);
+ }
+ }
+
+ sender.sendMessage(String.valueOf(viewMembers) + "\n ");
+ } else {
+ sender.sendMessage("\n ");
+ }
+ }
+
+ public void getLocation(String viewName, String viewLocation, CommandSender sender, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.checkInfoPerms(sender, plugin)) {
+ if (!this.isAllowed.checkOwner(sender, viewName)) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ this.getLocationInfo(targetFile, sender, viewName, viewLocation);
+ }
+ }
+ }
+ }
+
+ public void getLocationInfo(FileConfiguration fileConfig, CommandSender sender, String viewName, String viewLocation) {
+ String viewPath = this.common.getViewPath(viewName);
+ Location location = fileConfig.getLocation(viewPath + "Locations." + viewLocation);
+
+ assert location != null;
+
+ String viewWorld = ((World)Objects.requireNonNull(location.getWorld())).getName();
+ int viewX = (int)location.getX();
+ int viewY = (int)location.getY();
+ int viewZ = (int)location.getZ();
+ String var10001 = String.valueOf(ChatColor.AQUA);
+ sender.sendMessage("\n[" + var10001 + "View Location " + viewLocation + " Information" + String.valueOf(ChatColor.WHITE) + "]\n ");
+ var10001 = String.valueOf(ChatColor.AQUA);
+ sender.sendMessage(var10001 + "World" + String.valueOf(ChatColor.WHITE) + ": " + viewWorld);
+ var10001 = String.valueOf(ChatColor.AQUA);
+ sender.sendMessage(var10001 + "X" + String.valueOf(ChatColor.WHITE) + ": " + viewX);
+ var10001 = String.valueOf(ChatColor.AQUA);
+ sender.sendMessage(var10001 + "Y" + String.valueOf(ChatColor.WHITE) + ": " + viewY);
+ var10001 = String.valueOf(ChatColor.AQUA);
+ sender.sendMessage(var10001 + "Z" + String.valueOf(ChatColor.WHITE) + ": " + viewZ + "\n ");
+ }
+}
diff --git a/cinematicview/cinematicview/Functions/ModifyView.java b/cinematicview/cinematicview/Functions/ModifyView.java
new file mode 100644
index 0000000..300f1af
--- /dev/null
+++ b/cinematicview/cinematicview/Functions/ModifyView.java
@@ -0,0 +1,315 @@
+package cinematicview.cinematicview.Functions;
+
+import cinematicview.cinematicview.CinematicView;
+import java.io.File;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.Sound;
+import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+
+public class ModifyView {
+ Common common = new Common();
+ isAllowed isAllowed = new isAllowed();
+ String pluginName;
+ String noTitle;
+
+ public ModifyView() {
+ String var10001 = String.valueOf(ChatColor.AQUA);
+ this.pluginName = "\n[" + var10001 + "CinematicView" + String.valueOf(ChatColor.WHITE) + "] ";
+ this.noTitle = this.pluginName + "View location already has no Title.\n ";
+ }
+
+ public void type(String viewName, String type, CommandSender sender, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.checkBasicPerms(sender, plugin)) {
+ if (!this.isAllowed.checkOwner(sender, viewName)) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ if (!this.isAllowed.checkType(targetFile, viewName, type, sender)) {
+ this.setType(file, targetFile, sender, viewName, type);
+ }
+ }
+ }
+ }
+ }
+
+ public void setType(File file, FileConfiguration fileConfig, CommandSender sender, String viewName, String type) {
+ String viewPath = this.common.getViewPath(viewName);
+ viewName = this.common.addColourName(viewName);
+ if (type.equalsIgnoreCase("private")) {
+ fileConfig.set(viewPath + "Type", "Private");
+ this.common.saveFile(fileConfig, file);
+ sender.sendMessage(this.pluginName + "Set " + viewName + " View to Private.\n ");
+ } else {
+ if (type.equalsIgnoreCase("public")) {
+ fileConfig.set(viewPath + "Type", "Public");
+ this.common.saveFile(fileConfig, file);
+ sender.sendMessage(this.pluginName + "Set " + viewName + " View to Public.\n ");
+ }
+
+ }
+ }
+
+ public void interval(String viewName, String interval, CommandSender sender, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.checkBasicPerms(sender, plugin)) {
+ if (!this.isAllowed.checkOwner(sender, viewName)) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ if (!this.isAllowed.checkInterval(interval, sender)) {
+ int Interval = this.common.parseInteger(interval);
+ this.setInterval(file, targetFile, sender, viewName, Interval, plugin);
+ }
+ }
+ }
+ }
+ }
+
+ public void setInterval(File file, FileConfiguration fileConfig, CommandSender sender, String viewName, int interval, CinematicView plugin) {
+ String viewPath = this.common.getViewPath(viewName);
+ viewName = this.common.addColourName(viewName);
+ if (interval > plugin.getConfig().getInt("maximum-view-interval")) {
+ interval = plugin.getConfig().getInt("maximum-view-interval");
+ sender.sendMessage(this.pluginName + "Interval too large, it has been set to the maximum of " + this.common.addColourName(Integer.toString(interval)) + ".\n ");
+ } else {
+ String var10001 = this.pluginName;
+ sender.sendMessage(var10001 + "Interval changed to " + this.common.addColourName(Integer.toString(interval)) + " for " + viewName + " View.\n ");
+ }
+
+ fileConfig.set(viewPath + "Interval", interval);
+ this.common.saveFile(fileConfig, file);
+ }
+
+ public void member(String viewName, String targetName, CommandSender sender, boolean AddOrRemove, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.checkBasicPerms(sender, plugin)) {
+ if (!this.isAllowed.checkOwner(sender, viewName)) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ String viewPath = this.common.getViewPath(viewName);
+ List members = targetFile.getStringList(viewPath + "Members");
+ if (!this.isAllowed.checkMember(sender, targetName, members, AddOrRemove)) {
+ this.AddRemoveMember(file, targetFile, sender, viewName, targetName, members, AddOrRemove);
+ }
+ }
+ }
+ }
+ }
+
+ public void AddRemoveMember(File file, FileConfiguration fileConfig, CommandSender sender, String viewName, String targetName, List members, boolean AddOrRemove) {
+ String viewPath = this.common.getViewPath(viewName);
+ String var10001;
+ if (AddOrRemove) {
+ members.add(targetName);
+ fileConfig.set(viewPath + "Members", members);
+ this.common.saveFile(fileConfig, file);
+ var10001 = this.pluginName;
+ sender.sendMessage(var10001 + targetName + " is now a member of " + String.valueOf(ChatColor.AQUA) + viewName + String.valueOf(ChatColor.WHITE) + " View.\n ");
+ } else {
+ members.remove(targetName);
+ fileConfig.set(viewPath + "Members", members);
+ this.common.saveFile(fileConfig, file);
+ var10001 = this.pluginName;
+ sender.sendMessage(var10001 + targetName + " is no longer a member of " + String.valueOf(ChatColor.AQUA) + viewName + String.valueOf(ChatColor.WHITE) + " View.\n ");
+ }
+ }
+
+ public void swap(String viewName, String firstLoc, String secondLoc, CommandSender sender, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.checkBasicPerms(sender, plugin)) {
+ if (!this.isAllowed.checkLocation(sender, firstLoc, viewName)) {
+ if (!this.isAllowed.checkLocation(sender, secondLoc, viewName)) {
+ if (!this.isAllowed.checkOwner(sender, viewName)) {
+ if (Objects.equals(firstLoc, secondLoc)) {
+ sender.sendMessage(this.pluginName + "Cannot swap the same location.\n ");
+ } else {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ int FirstLoc = this.common.parseInteger(firstLoc);
+ int SecondLoc = this.common.parseInteger(secondLoc);
+ this.swapLocations(file, targetFile, sender, viewName, FirstLoc, SecondLoc);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void swapLocations(File file, FileConfiguration fileConfig, CommandSender sender, String viewName, int firstLoc, int secondLoc) {
+ String viewPath = this.common.getViewPath(viewName);
+ viewName = this.common.addColourName(viewName);
+ Location hold = fileConfig.getLocation(viewPath + "Locations." + firstLoc);
+ fileConfig.set(viewPath + "Locations." + firstLoc, fileConfig.getLocation(viewPath + "Locations." + secondLoc));
+ fileConfig.set(viewPath + "Locations." + secondLoc, hold);
+ String titleHold = fileConfig.getString(viewPath + "Titles." + firstLoc + ".Title");
+ fileConfig.set(viewPath + "Titles." + firstLoc + ".Title", fileConfig.getString(viewPath + "Titles." + secondLoc + ".Title"));
+ fileConfig.set(viewPath + "Titles." + secondLoc + ".Title", titleHold);
+ this.common.saveFile(fileConfig, file);
+ sender.sendMessage(this.pluginName + "Swapped location " + firstLoc + " and " + secondLoc + " for " + viewName + " View.\n ");
+ }
+
+ public void insert(String viewName, String viewLocation, CommandSender sender, CinematicView plugin) {
+ if (sender instanceof Player) {
+ Player player = (Player)sender;
+ if (this.isAllowed.viewExists(player, viewName, false)) {
+ return;
+ }
+
+ if (this.isAllowed.checkBasicPerms(sender, plugin)) {
+ return;
+ }
+
+ if (this.isAllowed.checkLocation(player, viewLocation, viewName)) {
+ return;
+ }
+
+ if (this.isAllowed.checkOwner(sender, viewName)) {
+ return;
+ }
+
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ int location = this.common.parseInteger(viewLocation);
+ this.insertLocation(file, targetFile, player, viewName, location);
+ }
+
+ }
+
+ public void insertLocation(File file, FileConfiguration fileConfig, Player player, String viewName, int location) {
+ String viewPath = this.common.getViewPath(viewName);
+ int viewSize = this.common.getViewSize(viewName);
+ viewName = this.common.addColourName(viewName);
+ fileConfig.set(viewPath + "Size", viewSize + 1);
+
+ while(viewSize >= location) {
+ fileConfig.set(viewPath + "Locations." + (viewSize + 1), fileConfig.getLocation(viewPath + "Locations." + viewSize));
+ fileConfig.set(viewPath + "Titles." + (viewSize + 1) + ".Title", fileConfig.getString(viewPath + "Titles." + viewSize + ".Title"));
+ --viewSize;
+ }
+
+ fileConfig.set(viewPath + "Locations." + location, player.getLocation());
+ fileConfig.set(viewPath + "Titles." + location, (Object)null);
+ this.common.saveFile(fileConfig, file);
+ player.sendMessage(this.pluginName + "Inserted location at " + location + " for " + viewName + " View.\n ");
+ }
+
+ public void title(String viewName, String viewLocation, boolean hasTitle, String title, CommandSender sender, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.checkBasicPerms(sender, plugin)) {
+ if (!this.isAllowed.checkLocation(sender, viewLocation, viewName)) {
+ if (!this.isAllowed.checkOwner(sender, viewName)) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ int location = this.common.parseInteger(viewLocation);
+ this.setTitle(file, targetFile, sender, viewName, location, hasTitle, title);
+ }
+ }
+ }
+ }
+ }
+
+ public void setTitle(File file, FileConfiguration fileConfig, CommandSender sender, String viewName, int location, boolean hasTitle, String title) {
+ String viewPath = this.common.getViewPath(viewName);
+ viewName = this.common.addColourName(viewName);
+ if (!hasTitle) {
+ if (fileConfig.get(viewPath + "Titles." + location + ".Title") != null) {
+ fileConfig.set(viewPath + "Titles." + location, (Object)null);
+ this.common.saveFile(fileConfig, file);
+ sender.sendMessage(this.pluginName + "Removed " + viewName + " " + location + " Location's Title.\n ");
+ } else {
+ sender.sendMessage(this.noTitle);
+ }
+
+ } else {
+ title = ChatColor.translateAlternateColorCodes('&', title);
+ fileConfig.set(viewPath + "Titles." + location + ".Title", title);
+ this.common.saveFile(fileConfig, file);
+ sender.sendMessage(this.pluginName + "Set " + viewName + " " + location + " Location's Title to " + title + ".\n ");
+ }
+ }
+
+ public void titleType(String viewName, CommandSender sender, String type, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.checkBasicPerms(sender, plugin)) {
+ if (!type.equalsIgnoreCase("title") && !type.equalsIgnoreCase("subtitle") && !type.equalsIgnoreCase("none")) {
+ sender.sendMessage(this.pluginName + "Incorrect title type specified.\n ");
+ } else if (!this.isAllowed.checkOwner(sender, viewName)) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ String viewPath = this.common.getViewPath(viewName);
+ if (type.equalsIgnoreCase("none")) {
+ targetFile.set(viewPath + "TitleType", (Object)null);
+ } else {
+ targetFile.set(viewPath + "TitleType", type);
+ }
+
+ this.common.saveFile(targetFile, file);
+ String var10001 = this.pluginName;
+ sender.sendMessage(var10001 + "Set " + viewName + "'s title type to " + String.valueOf(ChatColor.AQUA) + type.toLowerCase() + String.valueOf(ChatColor.WHITE) + ".\n ");
+ }
+ }
+ }
+ }
+
+ public void travelType(String viewName, CommandSender sender, String type, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.checkBasicPerms(sender, plugin)) {
+ if (!type.equalsIgnoreCase("teleport") && !type.equalsIgnoreCase("move")) {
+ sender.sendMessage(this.pluginName + "Incorrect travel type specified.\n ");
+ } else if (!this.isAllowed.checkOwner(sender, viewName)) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ String viewPath = this.common.getViewPath(viewName);
+ targetFile.set(viewPath + "Travel", type);
+ this.common.saveFile(targetFile, file);
+ String var10001 = this.pluginName;
+ sender.sendMessage(var10001 + "Set " + viewName + "'s travel type to " + String.valueOf(ChatColor.AQUA) + type.toLowerCase() + String.valueOf(ChatColor.WHITE) + ".\n ");
+ }
+ }
+ }
+ }
+
+ public void setSound(String viewName, CommandSender sender, String sound, CinematicView plugin) {
+ if (!this.isAllowed.viewExists(sender, viewName, false)) {
+ if (!this.isAllowed.checkBasicPerms(sender, plugin)) {
+ if (!this.isAllowed.checkOwner(sender, viewName)) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ String viewPath = this.common.getViewPath(viewName);
+ if (sound.equalsIgnoreCase("none")) {
+ targetFile.set(viewPath + "Sound", (Object)null);
+ this.common.saveFile(targetFile, file);
+ sender.sendMessage(this.pluginName + "Removed the sound for " + viewName + ".\n ");
+ } else {
+ try {
+ Sound.valueOf(sound.toUpperCase());
+ } catch (IllegalArgumentException var10) {
+ sender.sendMessage(this.pluginName + "No sound with that name exists.\n ");
+ return;
+ }
+
+ targetFile.set(viewPath + "Sound", sound);
+ this.common.saveFile(targetFile, file);
+ String var10001 = this.pluginName;
+ sender.sendMessage(var10001 + "Set " + viewName + "'s Sound to " + String.valueOf(ChatColor.AQUA) + sound.toUpperCase() + String.valueOf(ChatColor.WHITE) + ".\n ");
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/cinematicview/cinematicview/Functions/TabComplete.java b/cinematicview/cinematicview/Functions/TabComplete.java
new file mode 100644
index 0000000..06f0842
--- /dev/null
+++ b/cinematicview/cinematicview/Functions/TabComplete.java
@@ -0,0 +1,217 @@
+package cinematicview.cinematicview.Functions;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.UUID;
+import net.luckperms.api.LuckPerms;
+import net.luckperms.api.model.group.Group;
+import org.bukkit.Bukkit;
+import org.bukkit.Sound;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.RegisteredServiceProvider;
+
+public class TabComplete {
+ Common common = new Common();
+ isAllowed isAllowed = new isAllowed();
+
+ public List first(Player player) {
+ List firstList = new ArrayList();
+ firstList.add("view");
+ if (this.isAllowed.checkAdminPerms(player)) {
+ firstList.add("admin");
+ }
+
+ firstList.add("help");
+ firstList.add("open");
+ return firstList;
+ }
+
+ public List second() {
+ List secondList = new ArrayList();
+ secondList.add("show");
+ secondList.add("remove");
+ secondList.add("removeall");
+ secondList.add("add");
+ secondList.add("create");
+ secondList.add("info");
+ secondList.add("set");
+ secondList.add("invite");
+ secondList.add("uninvite");
+ secondList.add("delete");
+ secondList.add("location");
+ secondList.add("swap");
+ secondList.add("replace");
+ secondList.add("insert");
+ secondList.add("stop");
+ secondList.add("title");
+ secondList.add("sound");
+ return secondList;
+ }
+
+ public List admin() {
+ List adminList = new ArrayList();
+ adminList.add("force");
+ adminList.add("reload");
+ adminList.add("show");
+ return adminList;
+ }
+
+ public List adminShow() {
+ List list = new ArrayList();
+ list.add("all");
+ RegisteredServiceProvider provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
+ if (provider != null) {
+ LuckPerms luckPerms = (LuckPerms)provider.getProvider();
+ List groups = luckPerms.getGroupManager().getLoadedGroups().stream().toList();
+ Iterator var5 = groups.iterator();
+
+ while(var5.hasNext()) {
+ Group g = (Group)var5.next();
+ list.add(g.getName());
+ }
+ }
+
+ return list;
+ }
+
+ public List owned(Player player) {
+ File file = this.common.getPlayerFile(player.getUniqueId());
+ FileConfiguration playerFile = this.common.getFileConfig(file);
+ Set viewKeys = ((ConfigurationSection)Objects.requireNonNull(playerFile.getConfigurationSection("Owned"))).getKeys(false);
+ if (this.isAllowed.checkAdminPerms(player)) {
+ viewKeys = this.common.getAllViews();
+ }
+
+ return new ArrayList(viewKeys);
+ }
+
+ public List type() {
+ List typeList = new ArrayList();
+ typeList.add("type");
+ typeList.add("interval");
+ typeList.add("titletype");
+ typeList.add("travel");
+ typeList.add("follow-up");
+ return typeList;
+ }
+
+ public List types() {
+ List typeList = new ArrayList();
+ typeList.add("public");
+ typeList.add("private");
+ return typeList;
+ }
+
+ public List titleTypes() {
+ List list = new ArrayList();
+ list.add("title");
+ list.add("subtitle");
+ list.add("none");
+ return list;
+ }
+
+ public List travelTypes() {
+ List list = new ArrayList();
+ list.add("teleport");
+ list.add("move");
+ return list;
+ }
+
+ public List views(Player player) {
+ Set viewKeys = this.common.getPlayerViews(player.getUniqueId());
+ Set allViews = this.common.getAllViews();
+ if (!player.isOp() && !player.hasPermission("cinematicview.admin")) {
+ Iterator var4 = allViews.iterator();
+
+ while(true) {
+ while(var4.hasNext()) {
+ String viewName = (String)var4.next();
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File viewFile = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(viewFile);
+ String viewPath = this.common.getViewPath(viewName);
+ if (targetFile.get(viewPath + "Type") != null && ((String)Objects.requireNonNull(targetFile.getString(viewPath + "Type"))).equalsIgnoreCase("Public")) {
+ viewKeys.add(viewName);
+ } else {
+ List member = targetFile.getStringList(viewPath + "Members");
+ if (member.contains(player.getName())) {
+ viewKeys.add(viewName);
+ }
+ }
+ }
+
+ if (this.isAllowed.checkAdminPerms(player)) {
+ viewKeys = this.common.getAllViews();
+ }
+
+ return new ArrayList(viewKeys);
+ }
+ } else {
+ return allViews.stream().toList();
+ }
+ }
+
+ public List locations(String viewName, Player player) {
+ File file = this.common.getPlayerFile(player.getUniqueId());
+ FileConfiguration playerFile = this.common.getFileConfig(file);
+ List locationsList = new ArrayList();
+ int viewSize = playerFile.getInt("Owned." + viewName + ".Size");
+
+ for(int i = 1; i <= viewSize; ++i) {
+ locationsList.add(String.valueOf(i));
+ }
+
+ return locationsList;
+ }
+
+ public List online(Player p) {
+ List online = new ArrayList();
+ Iterator var3 = Bukkit.getServer().getOnlinePlayers().iterator();
+
+ while(var3.hasNext()) {
+ Player player = (Player)var3.next();
+ online.add(player.getName());
+ }
+
+ online.remove(p.getName());
+ return online;
+ }
+
+ public List members(Player player, String viewName) {
+ File file = this.common.getPlayerFile(player.getUniqueId());
+ FileConfiguration playerFile = this.common.getFileConfig(file);
+ String viewPath = this.common.getViewPath(viewName);
+ return playerFile.getStringList(viewPath + "Members");
+ }
+
+ public List sounds() {
+ List list = new ArrayList();
+ Sound[] var2 = Sound.values();
+ int var3 = var2.length;
+
+ for(int var4 = 0; var4 < var3; ++var4) {
+ Sound s = var2[var4];
+ list.add(s.toString());
+ }
+
+ return list;
+ }
+
+ public List help() {
+ List list = new ArrayList();
+ list.add("1");
+ list.add("2");
+ list.add("3");
+ return list;
+ }
+
+ public List empty() {
+ return new ArrayList();
+ }
+}
diff --git a/cinematicview/cinematicview/Functions/isAllowed.java b/cinematicview/cinematicview/Functions/isAllowed.java
new file mode 100644
index 0000000..1b4748b
--- /dev/null
+++ b/cinematicview/cinematicview/Functions/isAllowed.java
@@ -0,0 +1,235 @@
+package cinematicview.cinematicview.Functions;
+
+import cinematicview.cinematicview.CinematicView;
+import java.io.File;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.UUID;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.command.CommandSender;
+import org.bukkit.command.ConsoleCommandSender;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+
+public class isAllowed {
+ Common common = new Common();
+ String adminPermission = "cinematicview.admin";
+ String pluginName;
+ String viewExist;
+ String noPermission;
+ String noViewName;
+ String multipleWorlds;
+ String noValidLocation;
+ String noPlayerFound;
+ String noValidType;
+ String noValidInterval;
+ String noViewLocations;
+ String alreadyView;
+
+ public isAllowed() {
+ String var10001 = String.valueOf(ChatColor.AQUA);
+ this.pluginName = "\n[" + var10001 + "CinematicView" + String.valueOf(ChatColor.WHITE) + "] ";
+ this.viewExist = this.pluginName + "A View with that name already exists.\n ";
+ this.noPermission = this.pluginName + "You do not have permission to execute this command.\n ";
+ this.noViewName = this.pluginName + "No View with that name exists.\n ";
+ this.multipleWorlds = this.pluginName + "Cannot set locations that are in separate worlds.\n ";
+ this.noValidLocation = this.pluginName + "No valid view location specified.\n ";
+ this.noPlayerFound = this.pluginName + "No player was found with that Username.\n ";
+ this.noValidType = this.pluginName + "No valid type specified.\n ";
+ this.noValidInterval = this.pluginName + "No valid view interval specified.\n ";
+ this.noViewLocations = this.pluginName + "View has no set locations.\n ";
+ this.alreadyView = this.pluginName + "Cannot show another view at this time.\n ";
+ }
+
+ public boolean viewExists(CommandSender sender, String viewName, boolean create) {
+ Set viewKeys = this.common.getAllViews();
+ if (viewKeys.contains(viewName)) {
+ if (create) {
+ sender.sendMessage(this.viewExist);
+ }
+
+ return false;
+ } else {
+ if (!create) {
+ sender.sendMessage(this.noViewName);
+ }
+
+ return true;
+ }
+ }
+
+ public boolean checkBasicPerms(CommandSender sender, CinematicView plugin) {
+ boolean isPermsEnabled = plugin.getConfig().getBoolean("permissions");
+ if (sender instanceof ConsoleCommandSender) {
+ return false;
+ } else if (this.checkAdminPerms(sender)) {
+ return false;
+ } else if (!isPermsEnabled) {
+ return false;
+ } else if (sender.hasPermission("cinematicview.basic")) {
+ return false;
+ } else {
+ sender.sendMessage(this.noPermission);
+ return true;
+ }
+ }
+
+ public boolean checkInfoPerms(CommandSender sender, CinematicView plugin) {
+ boolean isPermsEnabled = plugin.getConfig().getBoolean("permissions");
+ if (sender instanceof ConsoleCommandSender) {
+ return false;
+ } else if (this.checkAdminPerms(sender)) {
+ return false;
+ } else if (!isPermsEnabled) {
+ return false;
+ } else if (sender.hasPermission("cinematicview.info")) {
+ return false;
+ } else {
+ sender.sendMessage(this.noPermission);
+ return true;
+ }
+ }
+
+ public boolean checkAdminPerms(CommandSender sender) {
+ return sender.isOp() || sender.hasPermission(this.adminPermission);
+ }
+
+ public boolean checkWorld(Player player, UUID uuid, String viewName) {
+ File file = this.common.getPlayerFile(uuid);
+ FileConfiguration playerFile = this.common.getFileConfig(file);
+ String viewPath = this.common.getViewPath(viewName);
+ int viewSize = this.common.getViewSize(viewName);
+ if (viewSize != 0) {
+ Location firstLoc = playerFile.getLocation(viewPath + "Locations.1");
+
+ assert firstLoc != null;
+
+ if (!((World)Objects.requireNonNull(player.getLocation().getWorld())).getName().equals(((World)Objects.requireNonNull(firstLoc.getWorld())).getName())) {
+ player.sendMessage(this.multipleWorlds);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public boolean isShowing(Player player, CinematicView plugin) {
+ if (plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getShowingView()) {
+ player.sendMessage(this.alreadyView);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public boolean checkMaxViews(CommandSender sender, CinematicView plugin, String viewName) {
+ boolean maxEnabled = plugin.getConfig().getBoolean("maximum-locations");
+ int maxPositions = plugin.getConfig().getInt("maximum-locations-amount");
+ int viewSize = this.common.getViewSize(viewName);
+ if (maxEnabled && viewSize >= maxPositions) {
+ viewName = this.common.addColourName(viewName);
+ sender.sendMessage(this.pluginName + "Maximum locations reached for " + viewName + " View.\n ");
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ public boolean checkLocation(CommandSender sender, String viewLocation, String viewName) {
+ if (this.isSizeZero(sender, viewName)) {
+ return true;
+ } else {
+ int location = this.common.parseInteger(viewLocation);
+ int viewSize = this.common.getViewSize(viewName);
+ if (location <= 0) {
+ sender.sendMessage(this.noValidLocation);
+ return true;
+ } else if (location > viewSize) {
+ String var10001 = this.pluginName;
+ sender.sendMessage(var10001 + "View only has " + String.valueOf(ChatColor.AQUA) + viewSize + String.valueOf(ChatColor.WHITE) + " locations.\n ");
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public boolean isSizeZero(CommandSender sender, String viewName) {
+ int viewSize = this.common.getViewSize(viewName);
+ if (viewSize == 0) {
+ sender.sendMessage(this.noViewLocations);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public boolean isOnline(CommandSender sender, String targetName) {
+ Player target = Bukkit.getPlayerExact(targetName);
+ if (target == null) {
+ sender.sendMessage(this.noPlayerFound);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public boolean checkType(FileConfiguration fileConfig, String viewName, String type, CommandSender sender) {
+ String viewPath = this.common.getViewPath(viewName);
+ viewName = this.common.addColourName(viewName);
+ if (!type.equalsIgnoreCase("private") && !type.equalsIgnoreCase("public")) {
+ sender.sendMessage(this.noValidType);
+ return true;
+ } else if (((String)Objects.requireNonNull(fileConfig.getString(viewPath + "Type"))).equalsIgnoreCase(type) && type.equalsIgnoreCase("private")) {
+ sender.sendMessage(this.pluginName + "View " + viewName + " is already Private.\n ");
+ return true;
+ } else if (((String)Objects.requireNonNull(fileConfig.getString(viewPath + "Type"))).equalsIgnoreCase(type) && type.equalsIgnoreCase("public")) {
+ sender.sendMessage(this.pluginName + "View " + viewName + " is already Public.\n ");
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public boolean checkInterval(String interval, CommandSender sender) {
+ int Interval = this.common.parseInteger(interval);
+ if (Interval <= 0) {
+ sender.sendMessage(this.noValidInterval);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public boolean checkMember(CommandSender sender, String targetName, List members, boolean AddOrRemove) {
+ if (AddOrRemove && members.contains(targetName)) {
+ sender.sendMessage(this.pluginName + "Player is already a member.\n ");
+ return true;
+ } else if (!AddOrRemove && !members.contains(targetName)) {
+ sender.sendMessage(this.pluginName + "Player is already not a member.\n ");
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public boolean checkOwner(CommandSender sender, String viewName) {
+ UUID targetUUID = this.common.getPlayerUUID(viewName);
+ File file = this.common.getPlayerFile(targetUUID);
+ FileConfiguration targetFile = this.common.getFileConfig(file);
+ if (!(sender instanceof ConsoleCommandSender) && !this.checkAdminPerms(sender)) {
+ if (Objects.equals(targetFile.getString("Owned." + viewName + ".Owner"), sender.getName())) {
+ return false;
+ } else {
+ sender.sendMessage(this.noPermission);
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+}
diff --git a/cinematicview/cinematicview/Listeners/ChatMessage.java b/cinematicview/cinematicview/Listeners/ChatMessage.java
new file mode 100644
index 0000000..77811fc
--- /dev/null
+++ b/cinematicview/cinematicview/Listeners/ChatMessage.java
@@ -0,0 +1,163 @@
+package cinematicview.cinematicview.Listeners;
+
+import cinematicview.cinematicview.CinematicView;
+import cinematicview.cinematicview.Functions.BasicView;
+import cinematicview.cinematicview.Functions.Common;
+import cinematicview.cinematicview.Functions.InfoView;
+import cinematicview.cinematicview.Functions.ModifyView;
+import java.util.Map;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.AsyncPlayerChatEvent;
+
+public class ChatMessage implements Listener {
+ private final CinematicView plugin;
+ String pluginName;
+ Common common;
+ BasicView basicView;
+ ModifyView modifyView;
+ InfoView infoView;
+
+ public ChatMessage(CinematicView plugin) {
+ String var10001 = String.valueOf(ChatColor.AQUA);
+ this.pluginName = "\n[" + var10001 + "CinematicView" + String.valueOf(ChatColor.WHITE) + "] ";
+ this.common = new Common();
+ this.basicView = new BasicView();
+ this.modifyView = new ModifyView();
+ this.infoView = new InfoView();
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void onChatMessage(AsyncPlayerChatEvent e) {
+ Player player = e.getPlayer();
+ if (this.plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getSetting().isEmpty()) {
+ e.setCancelled(false);
+ } else {
+ Map setting = this.plugin.getPlayerManager().getCustomPlayer(player.getUniqueId()).getSetting();
+ String cancel = e.getMessage();
+ if (cancel.equalsIgnoreCase("cancel")) {
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ player.sendMessage(this.pluginName + "Cancelled.\n ");
+ e.setCancelled(true);
+ } else {
+ String message;
+ if (setting.get("REMOVE") != null) {
+ message = e.getMessage();
+ this.basicView.remove((String)setting.get("REMOVE"), message, player, this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ } else if (setting.get("REPLACE") != null) {
+ message = e.getMessage();
+ this.basicView.replace((String)setting.get("REPLACE"), message, player, this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ } else {
+ String[] args;
+ if (setting.get("SWAP") != null) {
+ message = e.getMessage();
+ args = message.split(" ");
+ if (args.length == 1) {
+ player.sendMessage(this.pluginName + "No valid view location specified.\n ");
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ } else {
+ this.modifyView.swap((String)setting.get("SWAP"), args[0], args[1], player, this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ }
+ } else if (setting.get("INSERT") != null) {
+ message = e.getMessage();
+ this.modifyView.insert((String)setting.get("INSERT"), message, player, this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ } else if (setting.get("LOCATION_INFO") != null) {
+ message = e.getMessage();
+ this.infoView.getLocation((String)setting.get("LOCATION_INFO"), message, player, this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ } else if (setting.get("TITLE") == null) {
+ if (setting.get("INTERVAL") != null) {
+ message = e.getMessage();
+ this.modifyView.interval((String)setting.get("INTERVAL"), message, player, this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ } else if (setting.get("TYPE") != null) {
+ message = e.getMessage();
+ this.modifyView.type((String)setting.get("TYPE"), message, player, this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ } else if (setting.get("INVITE") != null) {
+ message = e.getMessage();
+ args = message.split(" ");
+ this.modifyView.member((String)setting.get("INVITE"), args[0], player, true, this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ } else {
+ if (setting.get("UNINVITE") != null) {
+ message = e.getMessage();
+ args = message.split(" ");
+ this.modifyView.member((String)setting.get("UNINVITE"), args[0], player, false, this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ }
+
+ if (setting.get("TITLETYPE") != null) {
+ message = e.getMessage();
+ args = message.split(" ");
+ this.modifyView.titleType((String)setting.get("TITLETYPE"), player, args[0], this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ }
+
+ if (setting.get("TRAVELTYPE") != null) {
+ message = e.getMessage();
+ args = message.split(" ");
+ this.modifyView.travelType((String)setting.get("TRAVELTYPE"), player, args[0], this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ }
+
+ if (setting.get("FOLLOWUP") != null) {
+ message = e.getMessage();
+ args = message.split(" ");
+ this.basicView.setFollowUp((String)setting.get("FOLLOWUP"), player, args[0], this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ }
+
+ if (setting.get("SOUND") != null) {
+ message = e.getMessage();
+ args = message.split(" ");
+ this.modifyView.setSound((String)setting.get("SOUND"), player, args[0], this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ }
+
+ }
+ } else {
+ message = e.getMessage();
+ args = message.split(" ");
+ StringBuilder title = new StringBuilder();
+ boolean hasTitle = true;
+ if (args.length > 1) {
+ for(int i = 1; i < args.length; ++i) {
+ title.append(args[i]).append(" ");
+ }
+
+ title.deleteCharAt(title.length() - 1);
+ } else {
+ hasTitle = false;
+ }
+
+ this.modifyView.title((String)setting.get("TITLE"), args[0], hasTitle, title.toString(), player, this.plugin);
+ this.common.removeChatSetting(player.getUniqueId(), this.plugin);
+ e.setCancelled(true);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/cinematicview/cinematicview/Listeners/ExitViewListener.java b/cinematicview/cinematicview/Listeners/ExitViewListener.java
new file mode 100644
index 0000000..c3fe91d
--- /dev/null
+++ b/cinematicview/cinematicview/Listeners/ExitViewListener.java
@@ -0,0 +1,87 @@
+package cinematicview.cinematicview.Listeners;
+
+import cinematicview.cinematicview.CinematicView;
+import cinematicview.cinematicview.Functions.BasicView;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import org.bukkit.Bukkit;
+import org.bukkit.GameMode;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.event.player.PlayerKickEvent;
+import org.bukkit.event.player.PlayerMoveEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.event.player.PlayerTeleportEvent;
+
+public class ExitViewListener implements Listener {
+ private final CinematicView plugin;
+ BasicView basicView = new BasicView();
+
+ public ExitViewListener(CinematicView plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void onPlayerTeleport(PlayerTeleportEvent e) {
+ HashSet locations = new HashSet();
+ Collection extends Player> players = Bukkit.getOnlinePlayers();
+ Iterator var4 = players.iterator();
+
+ while(var4.hasNext()) {
+ Player p = (Player)var4.next();
+ if (!this.plugin.getPlayerManager().getCustomPlayer(p.getUniqueId()).getShowingView()) {
+ locations.add(p.getLocation());
+ }
+ }
+
+ if (this.plugin.getPlayerManager().getCustomPlayer(e.getPlayer().getUniqueId()).getShowingView()) {
+ if (locations.contains(e.getTo())) {
+ e.setCancelled(true);
+ }
+
+ e.setCancelled(false);
+ }
+
+ }
+
+ @EventHandler
+ public void onPlayerMoveEvent(PlayerMoveEvent e) {
+ boolean canRotate = this.plugin.getConfig().getBoolean("lock-rotation");
+ if (canRotate && this.plugin.getPlayerManager().getCustomPlayer(e.getPlayer().getUniqueId()).getShowingView()) {
+ e.setCancelled(true);
+ }
+
+ }
+
+ @EventHandler
+ public void onOpenChestEvent(PlayerInteractEvent e) {
+ if (this.plugin.getPlayerManager().getCustomPlayer(e.getPlayer().getUniqueId()).getShowingView() && e.getPlayer().getGameMode().equals(GameMode.SPECTATOR)) {
+ e.setCancelled(true);
+ }
+
+ }
+
+ @EventHandler
+ public void onPlayerLeave(PlayerQuitEvent e) {
+ Player p = e.getPlayer();
+ if (this.plugin.getPlayerManager().getCustomPlayer(p.getUniqueId()) != null && this.plugin.getPlayerManager().getCustomPlayer(p.getUniqueId()).getShowingView()) {
+ this.basicView.stopView(p, this.plugin, false, false);
+ }
+
+ this.plugin.getPlayerManager().removeCustomPlayer(p.getUniqueId());
+ }
+
+ @EventHandler
+ public void onPlayerKick(PlayerKickEvent e) {
+ Player p = e.getPlayer();
+ if (this.plugin.getPlayerManager().getCustomPlayer(p.getUniqueId()) != null && this.plugin.getPlayerManager().getCustomPlayer(p.getUniqueId()).getShowingView()) {
+ this.basicView.stopView(p, this.plugin, false, false);
+ }
+
+ this.plugin.getPlayerManager().removeCustomPlayer(p.getUniqueId());
+ }
+}
diff --git a/cinematicview/cinematicview/Listeners/InventoryClick.java b/cinematicview/cinematicview/Listeners/InventoryClick.java
new file mode 100644
index 0000000..76963fe
--- /dev/null
+++ b/cinematicview/cinematicview/Listeners/InventoryClick.java
@@ -0,0 +1,161 @@
+package cinematicview.cinematicview.Listeners;
+
+import cinematicview.cinematicview.CinematicView;
+import cinematicview.cinematicview.Classes.ViewInventory;
+import cinematicview.cinematicview.Functions.BasicView;
+import cinematicview.cinematicview.Functions.Common;
+import cinematicview.cinematicview.Functions.InfoView;
+import java.io.File;
+import java.util.Objects;
+import org.bukkit.ChatColor;
+import org.bukkit.Material;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+
+public class InventoryClick implements Listener {
+ BasicView basicView = new BasicView();
+ Common common = new Common();
+ InfoView infoView = new InfoView();
+ private final CinematicView plugin;
+ String pluginName;
+ String cancel;
+
+ public InventoryClick(CinematicView plugin) {
+ String var10001 = String.valueOf(ChatColor.AQUA);
+ this.pluginName = "\n[" + var10001 + "CinematicView" + String.valueOf(ChatColor.WHITE) + "] ";
+ this.cancel = " Type 'cancel' in to cancel.\n ";
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void onPlayerClick(InventoryClickEvent e) {
+ if (e.getInventory().getHolder() instanceof ViewInventory) {
+ ItemStack item = e.getCurrentItem();
+ Player player = (Player)e.getWhoClicked();
+ if (item != null) {
+ String viewName = ChatColor.stripColor(e.getView().getTitle());
+ if (item.getType().equals(Material.GRASS_BLOCK)) {
+ player.closeInventory();
+ this.basicView.view(viewName, player, this.plugin);
+ e.setCancelled(true);
+ } else {
+ ViewInventory inv;
+ if (item.getType().equals(Material.EMERALD)) {
+ inv = new ViewInventory(this.plugin, viewName, player);
+ inv.confirm("Add");
+ player.openInventory(inv.getInventory());
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.TNT)) {
+ inv = new ViewInventory(this.plugin, viewName, player);
+ inv.confirm("Remove All");
+ player.openInventory(inv.getInventory());
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.BARRIER)) {
+ inv = new ViewInventory(this.plugin, viewName, player);
+ inv.confirm("Delete");
+ player.openInventory(inv.getInventory());
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.RED_CONCRETE)) {
+ this.basicView.openGUI(player, viewName, this.plugin);
+ e.setCancelled(true);
+ } else if (ChatColor.stripColor(((ItemMeta)Objects.requireNonNull(item.getItemMeta())).getDisplayName()).equalsIgnoreCase("add") && item.getType().equals(Material.LIME_CONCRETE)) {
+ this.basicView.add(viewName, player, this.plugin);
+ player.closeInventory();
+ e.setCancelled(true);
+ } else if (ChatColor.stripColor(((ItemMeta)Objects.requireNonNull(item.getItemMeta())).getDisplayName()).equalsIgnoreCase("remove all") && item.getType().equals(Material.LIME_CONCRETE)) {
+ this.basicView.removeAll(viewName, player, this.plugin);
+ this.basicView.openGUI(player, viewName, this.plugin);
+ e.setCancelled(true);
+ } else if (ChatColor.stripColor(((ItemMeta)Objects.requireNonNull(item.getItemMeta())).getDisplayName()).equalsIgnoreCase("delete") && item.getType().equals(Material.LIME_CONCRETE)) {
+ this.basicView.delete(viewName, player, this.plugin);
+ player.closeInventory();
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.REDSTONE)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "REMOVE", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the location you'd like to remove." + this.cancel);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.PISTON)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "REPLACE", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the location you'd like to replace." + this.cancel);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.STICKY_PISTON)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "SWAP", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the locations you'd like to swap." + this.cancel);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.HOPPER)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "INSERT", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the position where you'd like to insert a location." + this.cancel);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.BOOK)) {
+ File file = this.common.getPlayerFile(player.getUniqueId());
+ FileConfiguration fileConfig = this.common.getFileConfig(file);
+ player.closeInventory();
+ this.infoView.getViewInformation(fileConfig, player, viewName);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.MAP)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "LOCATION_INFO", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the location you'd like to see the information for." + this.cancel);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.NAME_TAG)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "TITLE", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the location and title you'd like to set. ." + this.cancel);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.REPEATER)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "INTERVAL", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the interval you'd like to set." + this.cancel);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.OAK_SIGN)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "TYPE", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the type you'd like to set (Private/Public)." + this.cancel);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.LIME_CONCRETE)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "INVITE", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the player you'd like to invite." + this.cancel);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.RED_TERRACOTTA)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "UNINVITE", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the player you'd like to uninvite." + this.cancel);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.BIRCH_SIGN)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "TITLETYPE", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the title type (title/subtitle/none)." + this.cancel);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.DIAMOND_BOOTS)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "TRAVELTYPE", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the travel type (teleport/move)." + this.cancel);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.ANVIL)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "FOLLOWUP", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the follow up View. Enter 'none' to remove the current follow up View." + this.cancel);
+ e.setCancelled(true);
+ } else if (item.getType().equals(Material.JUKEBOX)) {
+ player.closeInventory();
+ this.common.addChatSetting(player.getUniqueId(), "SOUND", viewName, this.plugin);
+ player.sendMessage(this.pluginName + "Please enter the sound. Enter 'none' to remove the sound from the View." + this.cancel);
+ e.setCancelled(true);
+ } else {
+ e.setCancelled(true);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/cinematicview/cinematicview/Listeners/Join.java b/cinematicview/cinematicview/Listeners/Join.java
new file mode 100644
index 0000000..7eff2d7
--- /dev/null
+++ b/cinematicview/cinematicview/Listeners/Join.java
@@ -0,0 +1,104 @@
+package cinematicview.cinematicview.Listeners;
+
+import cinematicview.cinematicview.CinematicView;
+import cinematicview.cinematicview.Functions.BasicView;
+import cinematicview.cinematicview.Functions.Common;
+import cinematicview.cinematicview.PlayerManager.CustomPlayer;
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import org.bukkit.Bukkit;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.plugin.Plugin;
+
+public class Join implements Listener {
+ private final CinematicView plugin;
+ Common common = new Common();
+ BasicView basicView = new BasicView();
+
+ public Join(CinematicView plugin) {
+ this.plugin = plugin;
+ }
+
+ @EventHandler
+ public void onPlayerJoin(PlayerJoinEvent e) {
+ File file = this.common.getPlayerFile(e.getPlayer().getUniqueId());
+ FileConfiguration playerFile = this.common.getFileConfig(file);
+ CustomPlayer customPlayer = new CustomPlayer();
+ this.plugin.getPlayerManager().addCustomPlayer(e.getPlayer().getUniqueId(), customPlayer);
+ List playerShow = this.basicView.getPlayerShow();
+ Iterator var6 = playerShow.iterator();
+
+ while(var6.hasNext()) {
+ Player player = (Player)var6.next();
+ e.getPlayer().hidePlayer(this.plugin, player);
+ }
+
+ if (!file.exists()) {
+ playerFile.createSection("Owned");
+
+ try {
+ playerFile.save(file);
+ } catch (IOException var16) {
+ var16.printStackTrace();
+ }
+ } else {
+ File oldViews = new File(((Plugin)Objects.requireNonNull(Bukkit.getServer().getPluginManager().getPlugin("CinematicView"))).getDataFolder(), "views.yml");
+ FileConfiguration fileConfig = this.common.getFileConfig(oldViews);
+ if (oldViews.exists() && oldViews.length() != 0L) {
+ Set viewKeys = ((ConfigurationSection)Objects.requireNonNull(fileConfig.getConfigurationSection("Views"))).getKeys(false);
+ if (viewKeys.isEmpty()) {
+ fileConfig.set("Views", (Object)null);
+ this.common.saveFile(fileConfig, oldViews);
+ return;
+ }
+
+ Iterator var9 = viewKeys.iterator();
+
+ while(true) {
+ String viewName;
+ String path;
+ do {
+ if (!var9.hasNext()) {
+ return;
+ }
+
+ viewName = (String)var9.next();
+ path = "Views." + viewName + ".";
+ } while(!Objects.equals(fileConfig.getString(path + "Owner"), e.getPlayer().getName()));
+
+ String viewPath = this.common.getViewPath(viewName);
+ playerFile.set(viewPath + "Owner", e.getPlayer().getName());
+ playerFile.set(viewPath + "Size", fileConfig.getInt(path + "Size"));
+ playerFile.set(viewPath + "Interval", fileConfig.getInt(path + "Interval"));
+ playerFile.set(viewPath + "Type", fileConfig.getString(path + "Type"));
+ List members = fileConfig.getStringList(viewPath + "Members");
+ playerFile.set(viewPath + "Members", members);
+
+ for(int i = 1; i <= fileConfig.getInt(path + "Size"); ++i) {
+ playerFile.set(viewPath + "Locations." + i, fileConfig.getLocation(path + "Locations." + i));
+ }
+
+ this.common.saveFile(playerFile, file);
+ fileConfig.set("Views." + viewName, (Object)null);
+ this.common.saveFile(fileConfig, oldViews);
+ File newViews = this.common.getViewsFile();
+ FileConfiguration viewsConfig = this.common.getFileConfig(newViews);
+ viewsConfig.set("Views." + viewName, e.getPlayer().getName());
+ this.common.saveFile(viewsConfig, newViews);
+ }
+ } else if (oldViews.length() == 0L) {
+ oldViews.delete();
+ }
+ }
+
+ }
+}
diff --git a/cinematicview/cinematicview/Listeners/UpdateChecker.java b/cinematicview/cinematicview/Listeners/UpdateChecker.java
new file mode 100644
index 0000000..ba42fe2
--- /dev/null
+++ b/cinematicview/cinematicview/Listeners/UpdateChecker.java
@@ -0,0 +1,72 @@
+package cinematicview.cinematicview.Listeners;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import javax.net.ssl.HttpsURLConnection;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerJoinEvent;
+
+public class UpdateChecker implements Listener {
+ private String url = "https://api.spigotmc.org/legacy/update.php?resource=";
+ private String id = "110459";
+ private boolean isAvailable;
+ private final String version;
+ private String latestVersion;
+ String adminPermission = "cinematicview.admin";
+
+ public UpdateChecker(String version) {
+ this.version = version;
+ }
+
+ public boolean isAvailable() {
+ return this.isAvailable;
+ }
+
+ @EventHandler
+ public void on(PlayerJoinEvent event) {
+ if ((event.getPlayer().isOp() || event.getPlayer().hasPermission(this.adminPermission)) && this.isAvailable) {
+ Player var10000 = event.getPlayer();
+ String var10001 = String.valueOf(ChatColor.AQUA);
+ var10000.sendMessage("\n[" + var10001 + "CinematicView" + String.valueOf(ChatColor.WHITE) + "] 'CinematicView " + this.latestVersion + "' is available. You are on version 'CinematicView " + this.version + "' \n ");
+ }
+
+ }
+
+ public void check() {
+ this.isAvailable = this.checkUpdate();
+ }
+
+ private boolean checkUpdate() {
+ try {
+ HttpsURLConnection connection = (HttpsURLConnection)(new URL(this.url + this.id)).openConnection();
+ connection.setRequestMethod("GET");
+ String raw = (new BufferedReader(new InputStreamReader(connection.getInputStream()))).readLine();
+ String remoteVersion;
+ if (raw.contains("-")) {
+ remoteVersion = raw.split("-")[0].trim();
+ } else {
+ remoteVersion = raw;
+ }
+
+ float fVersion = Float.parseFloat(this.version);
+ float fRemoteVersion = Float.parseFloat(remoteVersion);
+ this.latestVersion = remoteVersion;
+ return fRemoteVersion > fVersion;
+ } catch (IOException var6) {
+ return false;
+ }
+ }
+
+ public String getVersion() {
+ return this.version;
+ }
+
+ public String getLatestVersion() {
+ return this.latestVersion;
+ }
+}
diff --git a/cinematicview/cinematicview/Listeners/WorldChangeListener.java b/cinematicview/cinematicview/Listeners/WorldChangeListener.java
new file mode 100644
index 0000000..3d80939
--- /dev/null
+++ b/cinematicview/cinematicview/Listeners/WorldChangeListener.java
@@ -0,0 +1,11 @@
+package cinematicview.cinematicview.Listeners;
+
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.player.PlayerChangedWorldEvent;
+
+public class WorldChangeListener implements Listener {
+ @EventHandler
+ public void onWorldChange(PlayerChangedWorldEvent e) {
+ }
+}
diff --git a/cinematicview/cinematicview/Metrics.java b/cinematicview/cinematicview/Metrics.java
new file mode 100644
index 0000000..9aac374
--- /dev/null
+++ b/cinematicview/cinematicview/Metrics.java
@@ -0,0 +1,664 @@
+package cinematicview.cinematicview;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.UUID;
+import java.util.Map.Entry;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+import java.util.logging.Level;
+import java.util.stream.Collectors;
+import java.util.zip.GZIPOutputStream;
+import javax.net.ssl.HttpsURLConnection;
+import org.bukkit.Bukkit;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.java.JavaPlugin;
+
+public class Metrics {
+ private final Plugin plugin;
+ private final Metrics.MetricsBase metricsBase;
+
+ public Metrics(JavaPlugin plugin, int serviceId) {
+ this.plugin = plugin;
+ File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
+ File configFile = new File(bStatsFolder, "config.yml");
+ YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
+ if (!config.isSet("serverUuid")) {
+ config.addDefault("enabled", true);
+ config.addDefault("serverUuid", UUID.randomUUID().toString());
+ config.addDefault("logFailedRequests", false);
+ config.addDefault("logSentData", false);
+ config.addDefault("logResponseStatusText", false);
+ config.options().header("bStats (https://bStats.org) collects some basic information for plugin authors, like how\nmany people use their plugin and their total player count. It's recommended to keep bStats\nenabled, but if you're not comfortable with this, you can turn this setting off. There is no\nperformance penalty associated with having metrics enabled, and data sent to bStats is fully\nanonymous.").copyDefaults(true);
+
+ try {
+ config.save(configFile);
+ } catch (IOException var11) {
+ }
+ }
+
+ boolean enabled = config.getBoolean("enabled", true);
+ String serverUUID = config.getString("serverUuid");
+ boolean logErrors = config.getBoolean("logFailedRequests", false);
+ boolean logSentData = config.getBoolean("logSentData", false);
+ boolean logResponseStatusText = config.getBoolean("logResponseStatusText", false);
+ Consumer var10007 = this::appendPlatformData;
+ Consumer var10008 = this::appendServiceData;
+ Consumer var10009 = (submitDataTask) -> {
+ Bukkit.getScheduler().runTask(plugin, submitDataTask);
+ };
+ Objects.requireNonNull(plugin);
+ this.metricsBase = new Metrics.MetricsBase("bukkit", serverUUID, serviceId, enabled, var10007, var10008, var10009, plugin::isEnabled, (message, error) -> {
+ this.plugin.getLogger().log(Level.WARNING, message, error);
+ }, (message) -> {
+ this.plugin.getLogger().log(Level.INFO, message);
+ }, logErrors, logSentData, logResponseStatusText);
+ }
+
+ public void shutdown() {
+ this.metricsBase.shutdown();
+ }
+
+ public void addCustomChart(Metrics.CustomChart chart) {
+ this.metricsBase.addCustomChart(chart);
+ }
+
+ private void appendPlatformData(Metrics.JsonObjectBuilder builder) {
+ builder.appendField("playerAmount", this.getPlayerAmount());
+ builder.appendField("onlineMode", Bukkit.getOnlineMode() ? 1 : 0);
+ builder.appendField("bukkitVersion", Bukkit.getVersion());
+ builder.appendField("bukkitName", Bukkit.getName());
+ builder.appendField("javaVersion", System.getProperty("java.version"));
+ builder.appendField("osName", System.getProperty("os.name"));
+ builder.appendField("osArch", System.getProperty("os.arch"));
+ builder.appendField("osVersion", System.getProperty("os.version"));
+ builder.appendField("coreCount", Runtime.getRuntime().availableProcessors());
+ }
+
+ private void appendServiceData(Metrics.JsonObjectBuilder builder) {
+ builder.appendField("pluginVersion", this.plugin.getDescription().getVersion());
+ }
+
+ private int getPlayerAmount() {
+ try {
+ Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
+ return onlinePlayersMethod.getReturnType().equals(Collection.class) ? ((Collection)onlinePlayersMethod.invoke(Bukkit.getServer())).size() : ((Player[])onlinePlayersMethod.invoke(Bukkit.getServer())).length;
+ } catch (Exception var2) {
+ return Bukkit.getOnlinePlayers().size();
+ }
+ }
+
+ public static class MetricsBase {
+ public static final String METRICS_VERSION = "3.0.2";
+ private static final String REPORT_URL = "https://bStats.org/api/v2/data/%s";
+ private final ScheduledExecutorService scheduler;
+ private final String platform;
+ private final String serverUuid;
+ private final int serviceId;
+ private final Consumer appendPlatformDataConsumer;
+ private final Consumer appendServiceDataConsumer;
+ private final Consumer submitTaskConsumer;
+ private final Supplier checkServiceEnabledSupplier;
+ private final BiConsumer errorLogger;
+ private final Consumer infoLogger;
+ private final boolean logErrors;
+ private final boolean logSentData;
+ private final boolean logResponseStatusText;
+ private final Set customCharts = new HashSet();
+ private final boolean enabled;
+
+ public MetricsBase(String platform, String serverUuid, int serviceId, boolean enabled, Consumer appendPlatformDataConsumer, Consumer appendServiceDataConsumer, Consumer submitTaskConsumer, Supplier checkServiceEnabledSupplier, BiConsumer errorLogger, Consumer infoLogger, boolean logErrors, boolean logSentData, boolean logResponseStatusText) {
+ ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(1, (task) -> {
+ return new Thread(task, "bStats-Metrics");
+ });
+ scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
+ this.scheduler = scheduler;
+ this.platform = platform;
+ this.serverUuid = serverUuid;
+ this.serviceId = serviceId;
+ this.enabled = enabled;
+ this.appendPlatformDataConsumer = appendPlatformDataConsumer;
+ this.appendServiceDataConsumer = appendServiceDataConsumer;
+ this.submitTaskConsumer = submitTaskConsumer;
+ this.checkServiceEnabledSupplier = checkServiceEnabledSupplier;
+ this.errorLogger = errorLogger;
+ this.infoLogger = infoLogger;
+ this.logErrors = logErrors;
+ this.logSentData = logSentData;
+ this.logResponseStatusText = logResponseStatusText;
+ this.checkRelocation();
+ if (enabled) {
+ this.startSubmitting();
+ }
+
+ }
+
+ public void addCustomChart(Metrics.CustomChart chart) {
+ this.customCharts.add(chart);
+ }
+
+ public void shutdown() {
+ this.scheduler.shutdown();
+ }
+
+ private void startSubmitting() {
+ Runnable submitTask = () -> {
+ if (this.enabled && (Boolean)this.checkServiceEnabledSupplier.get()) {
+ if (this.submitTaskConsumer != null) {
+ this.submitTaskConsumer.accept(this::submitData);
+ } else {
+ this.submitData();
+ }
+
+ } else {
+ this.scheduler.shutdown();
+ }
+ };
+ long initialDelay = (long)(60000.0D * (3.0D + Math.random() * 3.0D));
+ long secondDelay = (long)(60000.0D * Math.random() * 30.0D);
+ this.scheduler.schedule(submitTask, initialDelay, TimeUnit.MILLISECONDS);
+ this.scheduler.scheduleAtFixedRate(submitTask, initialDelay + secondDelay, 1800000L, TimeUnit.MILLISECONDS);
+ }
+
+ private void submitData() {
+ Metrics.JsonObjectBuilder baseJsonBuilder = new Metrics.JsonObjectBuilder();
+ this.appendPlatformDataConsumer.accept(baseJsonBuilder);
+ Metrics.JsonObjectBuilder serviceJsonBuilder = new Metrics.JsonObjectBuilder();
+ this.appendServiceDataConsumer.accept(serviceJsonBuilder);
+ Metrics.JsonObjectBuilder.JsonObject[] chartData = (Metrics.JsonObjectBuilder.JsonObject[])this.customCharts.stream().map((customChart) -> {
+ return customChart.getRequestJsonObject(this.errorLogger, this.logErrors);
+ }).filter(Objects::nonNull).toArray((x$0) -> {
+ return new Metrics.JsonObjectBuilder.JsonObject[x$0];
+ });
+ serviceJsonBuilder.appendField("id", this.serviceId);
+ serviceJsonBuilder.appendField("customCharts", chartData);
+ baseJsonBuilder.appendField("service", serviceJsonBuilder.build());
+ baseJsonBuilder.appendField("serverUUID", this.serverUuid);
+ baseJsonBuilder.appendField("metricsVersion", "3.0.2");
+ Metrics.JsonObjectBuilder.JsonObject data = baseJsonBuilder.build();
+ this.scheduler.execute(() -> {
+ try {
+ this.sendData(data);
+ } catch (Exception var3) {
+ if (this.logErrors) {
+ this.errorLogger.accept("Could not submit bStats metrics data", var3);
+ }
+ }
+
+ });
+ }
+
+ private void sendData(Metrics.JsonObjectBuilder.JsonObject data) throws Exception {
+ if (this.logSentData) {
+ this.infoLogger.accept("Sent bStats metrics data: " + data.toString());
+ }
+
+ String url = String.format("https://bStats.org/api/v2/data/%s", this.platform);
+ HttpsURLConnection connection = (HttpsURLConnection)(new URL(url)).openConnection();
+ byte[] compressedData = compress(data.toString());
+ connection.setRequestMethod("POST");
+ connection.addRequestProperty("Accept", "application/json");
+ connection.addRequestProperty("Connection", "close");
+ connection.addRequestProperty("Content-Encoding", "gzip");
+ connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
+ connection.setRequestProperty("Content-Type", "application/json");
+ connection.setRequestProperty("User-Agent", "Metrics-Service/1");
+ connection.setDoOutput(true);
+ DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
+
+ try {
+ outputStream.write(compressedData);
+ } catch (Throwable var11) {
+ try {
+ outputStream.close();
+ } catch (Throwable var9) {
+ var11.addSuppressed(var9);
+ }
+
+ throw var11;
+ }
+
+ outputStream.close();
+ StringBuilder builder = new StringBuilder();
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+
+ String line;
+ try {
+ while((line = bufferedReader.readLine()) != null) {
+ builder.append(line);
+ }
+ } catch (Throwable var12) {
+ try {
+ bufferedReader.close();
+ } catch (Throwable var10) {
+ var12.addSuppressed(var10);
+ }
+
+ throw var12;
+ }
+
+ bufferedReader.close();
+ if (this.logResponseStatusText) {
+ this.infoLogger.accept("Sent data to bStats and received response: " + String.valueOf(builder));
+ }
+
+ }
+
+ private void checkRelocation() {
+ if (System.getProperty("bstats.relocatecheck") == null || !System.getProperty("bstats.relocatecheck").equals("false")) {
+ String defaultPackage = new String(new byte[]{111, 114, 103, 46, 98, 115, 116, 97, 116, 115});
+ String examplePackage = new String(new byte[]{121, 111, 117, 114, 46, 112, 97, 99, 107, 97, 103, 101});
+ if (Metrics.MetricsBase.class.getPackage().getName().startsWith(defaultPackage) || Metrics.MetricsBase.class.getPackage().getName().startsWith(examplePackage)) {
+ throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
+ }
+ }
+
+ }
+
+ private static byte[] compress(String str) throws IOException {
+ if (str == null) {
+ return null;
+ } else {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
+
+ try {
+ gzip.write(str.getBytes(StandardCharsets.UTF_8));
+ } catch (Throwable var6) {
+ try {
+ gzip.close();
+ } catch (Throwable var5) {
+ var6.addSuppressed(var5);
+ }
+
+ throw var6;
+ }
+
+ gzip.close();
+ return outputStream.toByteArray();
+ }
+ }
+ }
+
+ public abstract static class CustomChart {
+ private final String chartId;
+
+ protected CustomChart(String chartId) {
+ if (chartId == null) {
+ throw new IllegalArgumentException("chartId must not be null");
+ } else {
+ this.chartId = chartId;
+ }
+ }
+
+ public Metrics.JsonObjectBuilder.JsonObject getRequestJsonObject(BiConsumer errorLogger, boolean logErrors) {
+ Metrics.JsonObjectBuilder builder = new Metrics.JsonObjectBuilder();
+ builder.appendField("chartId", this.chartId);
+
+ try {
+ Metrics.JsonObjectBuilder.JsonObject data = this.getChartData();
+ if (data == null) {
+ return null;
+ }
+
+ builder.appendField("data", data);
+ } catch (Throwable var5) {
+ if (logErrors) {
+ errorLogger.accept("Failed to get data for custom chart with id " + this.chartId, var5);
+ }
+
+ return null;
+ }
+
+ return builder.build();
+ }
+
+ protected abstract Metrics.JsonObjectBuilder.JsonObject getChartData() throws Exception;
+ }
+
+ public static class JsonObjectBuilder {
+ private StringBuilder builder = new StringBuilder();
+ private boolean hasAtLeastOneField = false;
+
+ public JsonObjectBuilder() {
+ this.builder.append("{");
+ }
+
+ public Metrics.JsonObjectBuilder appendNull(String key) {
+ this.appendFieldUnescaped(key, "null");
+ return this;
+ }
+
+ public Metrics.JsonObjectBuilder appendField(String key, String value) {
+ if (value == null) {
+ throw new IllegalArgumentException("JSON value must not be null");
+ } else {
+ this.appendFieldUnescaped(key, "\"" + escape(value) + "\"");
+ return this;
+ }
+ }
+
+ public Metrics.JsonObjectBuilder appendField(String key, int value) {
+ this.appendFieldUnescaped(key, String.valueOf(value));
+ return this;
+ }
+
+ public Metrics.JsonObjectBuilder appendField(String key, Metrics.JsonObjectBuilder.JsonObject object) {
+ if (object == null) {
+ throw new IllegalArgumentException("JSON object must not be null");
+ } else {
+ this.appendFieldUnescaped(key, object.toString());
+ return this;
+ }
+ }
+
+ public Metrics.JsonObjectBuilder appendField(String key, String[] values) {
+ if (values == null) {
+ throw new IllegalArgumentException("JSON values must not be null");
+ } else {
+ String escapedValues = (String)Arrays.stream(values).map((value) -> {
+ return "\"" + escape(value) + "\"";
+ }).collect(Collectors.joining(","));
+ this.appendFieldUnescaped(key, "[" + escapedValues + "]");
+ return this;
+ }
+ }
+
+ public Metrics.JsonObjectBuilder appendField(String key, int[] values) {
+ if (values == null) {
+ throw new IllegalArgumentException("JSON values must not be null");
+ } else {
+ String escapedValues = (String)Arrays.stream(values).mapToObj(String::valueOf).collect(Collectors.joining(","));
+ this.appendFieldUnescaped(key, "[" + escapedValues + "]");
+ return this;
+ }
+ }
+
+ public Metrics.JsonObjectBuilder appendField(String key, Metrics.JsonObjectBuilder.JsonObject[] values) {
+ if (values == null) {
+ throw new IllegalArgumentException("JSON values must not be null");
+ } else {
+ String escapedValues = (String)Arrays.stream(values).map(Metrics.JsonObjectBuilder.JsonObject::toString).collect(Collectors.joining(","));
+ this.appendFieldUnescaped(key, "[" + escapedValues + "]");
+ return this;
+ }
+ }
+
+ private void appendFieldUnescaped(String key, String escapedValue) {
+ if (this.builder == null) {
+ throw new IllegalStateException("JSON has already been built");
+ } else if (key == null) {
+ throw new IllegalArgumentException("JSON key must not be null");
+ } else {
+ if (this.hasAtLeastOneField) {
+ this.builder.append(",");
+ }
+
+ this.builder.append("\"").append(escape(key)).append("\":").append(escapedValue);
+ this.hasAtLeastOneField = true;
+ }
+ }
+
+ public Metrics.JsonObjectBuilder.JsonObject build() {
+ if (this.builder == null) {
+ throw new IllegalStateException("JSON has already been built");
+ } else {
+ Metrics.JsonObjectBuilder.JsonObject object = new Metrics.JsonObjectBuilder.JsonObject(this.builder.append("}").toString());
+ this.builder = null;
+ return object;
+ }
+ }
+
+ private static String escape(String value) {
+ StringBuilder builder = new StringBuilder();
+
+ for(int i = 0; i < value.length(); ++i) {
+ char c = value.charAt(i);
+ if (c == '"') {
+ builder.append("\\\"");
+ } else if (c == '\\') {
+ builder.append("\\\\");
+ } else if (c <= 15) {
+ builder.append("\\u000").append(Integer.toHexString(c));
+ } else if (c <= 31) {
+ builder.append("\\u00").append(Integer.toHexString(c));
+ } else {
+ builder.append(c);
+ }
+ }
+
+ return builder.toString();
+ }
+
+ public static class JsonObject {
+ private final String value;
+
+ private JsonObject(String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return this.value;
+ }
+ }
+ }
+
+ public static class SingleLineChart extends Metrics.CustomChart {
+ private final Callable callable;
+
+ public SingleLineChart(String chartId, Callable callable) {
+ super(chartId);
+ this.callable = callable;
+ }
+
+ protected Metrics.JsonObjectBuilder.JsonObject getChartData() throws Exception {
+ int value = (Integer)this.callable.call();
+ return value == 0 ? null : (new Metrics.JsonObjectBuilder()).appendField("value", value).build();
+ }
+ }
+
+ public static class DrilldownPie extends Metrics.CustomChart {
+ private final Callable