CinematicView upload

This commit is contained in:
Radim Lipovčan 2024-12-27 14:18:37 +01:00
parent 8e83d08607
commit c332382025
28 changed files with 4635 additions and 0 deletions

6
META-INF/MANIFEST.MF Normal file
View File

@ -0,0 +1,6 @@
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: dewet
Build-Jdk: 21.0.4

View File

@ -0,0 +1,5 @@
#Generated by Maven
#Wed Dec 18 10:02:47 SAST 2024
artifactId=CinematicView
groupId=cinematicview
version=1.32

View File

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cinematicview</groupId>
<artifactId>CinematicView</artifactId>
<version>1.32</version>
<packaging>jar</packaging>
<name>CinematicView</name>
<properties>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>2.0.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.21.1-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.21.1-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.21.1-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.21.1-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>C:\Users\dewet\OneDrive\Desktop\Vanilla Minecraft Server\plugins</outputDirectory>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.21.1-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

View File

@ -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<LuckPerms> 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();
}
}
}

View File

@ -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) {
};
}
}

View File

@ -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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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;
}
}

View File

@ -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<String> lore) {
ItemMeta itemMeta = this.itemStack.getItemMeta();
assert itemMeta != null;
itemMeta.setLore(lore);
this.itemStack.setItemMeta(itemMeta);
}
public ItemStack getItem() {
return this.itemStack;
}
}

View File

@ -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;
}
}

View File

@ -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<String> 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();
}
}

View File

@ -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();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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<String> 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<String> 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<String, String> map = new HashMap();
map.put(setting.toUpperCase(), viewName);
plugin.getPlayerManager().getCustomPlayer(uuid).setSetting(map);
}
public void removeChatSetting(UUID uuid, CinematicView plugin) {
Map<String, String> 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);
}
}
}

View File

@ -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<String> 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 ");
}
}

View File

@ -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<String> 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<String> 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 ");
}
}
}
}
}
}

View File

@ -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<String> first(Player player) {
List<String> firstList = new ArrayList();
firstList.add("view");
if (this.isAllowed.checkAdminPerms(player)) {
firstList.add("admin");
}
firstList.add("help");
firstList.add("open");
return firstList;
}
public List<String> second() {
List<String> 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<String> admin() {
List<String> adminList = new ArrayList();
adminList.add("force");
adminList.add("reload");
adminList.add("show");
return adminList;
}
public List<String> adminShow() {
List<String> list = new ArrayList();
list.add("all");
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
LuckPerms luckPerms = (LuckPerms)provider.getProvider();
List<Group> 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<String> owned(Player player) {
File file = this.common.getPlayerFile(player.getUniqueId());
FileConfiguration playerFile = this.common.getFileConfig(file);
Set<String> viewKeys = ((ConfigurationSection)Objects.requireNonNull(playerFile.getConfigurationSection("Owned"))).getKeys(false);
if (this.isAllowed.checkAdminPerms(player)) {
viewKeys = this.common.getAllViews();
}
return new ArrayList(viewKeys);
}
public List<String> type() {
List<String> typeList = new ArrayList();
typeList.add("type");
typeList.add("interval");
typeList.add("titletype");
typeList.add("travel");
typeList.add("follow-up");
return typeList;
}
public List<String> types() {
List<String> typeList = new ArrayList();
typeList.add("public");
typeList.add("private");
return typeList;
}
public List<String> titleTypes() {
List<String> list = new ArrayList();
list.add("title");
list.add("subtitle");
list.add("none");
return list;
}
public List<String> travelTypes() {
List<String> list = new ArrayList();
list.add("teleport");
list.add("move");
return list;
}
public List<String> views(Player player) {
Set<String> viewKeys = this.common.getPlayerViews(player.getUniqueId());
Set<String> 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<String> 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<String> locations(String viewName, Player player) {
File file = this.common.getPlayerFile(player.getUniqueId());
FileConfiguration playerFile = this.common.getFileConfig(file);
List<String> 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<String> online(Player p) {
List<String> 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<String> 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<String> sounds() {
List<String> 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<String> help() {
List<String> list = new ArrayList();
list.add("1");
list.add("2");
list.add("3");
return list;
}
public List<String> empty() {
return new ArrayList();
}
}

View File

@ -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<String> 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<String> 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;
}
}
}

View File

@ -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<String, String> 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);
}
}
}
}
}
}

View File

@ -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<Location> 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());
}
}

View File

@ -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. <location> <title>." + 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);
}
}
}
}
}
}

View File

@ -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<Player> 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<String> 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<String> 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();
}
}
}
}

View File

@ -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;
}
}

View File

@ -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) {
}
}

View File

@ -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<Metrics.JsonObjectBuilder> appendPlatformDataConsumer;
private final Consumer<Metrics.JsonObjectBuilder> appendServiceDataConsumer;
private final Consumer<Runnable> submitTaskConsumer;
private final Supplier<Boolean> checkServiceEnabledSupplier;
private final BiConsumer<String, Throwable> errorLogger;
private final Consumer<String> infoLogger;
private final boolean logErrors;
private final boolean logSentData;
private final boolean logResponseStatusText;
private final Set<Metrics.CustomChart> customCharts = new HashSet();
private final boolean enabled;
public MetricsBase(String platform, String serverUuid, int serviceId, boolean enabled, Consumer<Metrics.JsonObjectBuilder> appendPlatformDataConsumer, Consumer<Metrics.JsonObjectBuilder> appendServiceDataConsumer, Consumer<Runnable> submitTaskConsumer, Supplier<Boolean> checkServiceEnabledSupplier, BiConsumer<String, Throwable> errorLogger, Consumer<String> 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<String, Throwable> 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<Integer> callable;
public SingleLineChart(String chartId, Callable<Integer> 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<Map<String, Map<String, Integer>>> callable;
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
super(chartId);
this.callable = callable;
}
public Metrics.JsonObjectBuilder.JsonObject getChartData() throws Exception {
Metrics.JsonObjectBuilder valuesBuilder = new Metrics.JsonObjectBuilder();
Map<String, Map<String, Integer>> map = (Map)this.callable.call();
if (map != null && !map.isEmpty()) {
boolean reallyAllSkipped = true;
Iterator var4 = map.entrySet().iterator();
while(var4.hasNext()) {
Entry<String, Map<String, Integer>> entryValues = (Entry)var4.next();
Metrics.JsonObjectBuilder valueBuilder = new Metrics.JsonObjectBuilder();
boolean allSkipped = true;
for(Iterator var8 = ((Map)map.get(entryValues.getKey())).entrySet().iterator(); var8.hasNext(); allSkipped = false) {
Entry<String, Integer> valueEntry = (Entry)var8.next();
valueBuilder.appendField((String)valueEntry.getKey(), (Integer)valueEntry.getValue());
}
if (!allSkipped) {
reallyAllSkipped = false;
valuesBuilder.appendField((String)entryValues.getKey(), valueBuilder.build());
}
}
if (reallyAllSkipped) {
return null;
} else {
return (new Metrics.JsonObjectBuilder()).appendField("values", valuesBuilder.build()).build();
}
} else {
return null;
}
}
}
public static class AdvancedBarChart extends Metrics.CustomChart {
private final Callable<Map<String, int[]>> callable;
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
super(chartId);
this.callable = callable;
}
protected Metrics.JsonObjectBuilder.JsonObject getChartData() throws Exception {
Metrics.JsonObjectBuilder valuesBuilder = new Metrics.JsonObjectBuilder();
Map<String, int[]> map = (Map)this.callable.call();
if (map != null && !map.isEmpty()) {
boolean allSkipped = true;
Iterator var4 = map.entrySet().iterator();
while(var4.hasNext()) {
Entry<String, int[]> entry = (Entry)var4.next();
if (((int[])entry.getValue()).length != 0) {
allSkipped = false;
valuesBuilder.appendField((String)entry.getKey(), (int[])entry.getValue());
}
}
if (allSkipped) {
return null;
} else {
return (new Metrics.JsonObjectBuilder()).appendField("values", valuesBuilder.build()).build();
}
} else {
return null;
}
}
}
public static class SimpleBarChart extends Metrics.CustomChart {
private final Callable<Map<String, Integer>> callable;
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
protected Metrics.JsonObjectBuilder.JsonObject getChartData() throws Exception {
Metrics.JsonObjectBuilder valuesBuilder = new Metrics.JsonObjectBuilder();
Map<String, Integer> map = (Map)this.callable.call();
if (map != null && !map.isEmpty()) {
Iterator var3 = map.entrySet().iterator();
while(var3.hasNext()) {
Entry<String, Integer> entry = (Entry)var3.next();
valuesBuilder.appendField((String)entry.getKey(), new int[]{(Integer)entry.getValue()});
}
return (new Metrics.JsonObjectBuilder()).appendField("values", valuesBuilder.build()).build();
} else {
return null;
}
}
}
public static class AdvancedPie extends Metrics.CustomChart {
private final Callable<Map<String, Integer>> callable;
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
protected Metrics.JsonObjectBuilder.JsonObject getChartData() throws Exception {
Metrics.JsonObjectBuilder valuesBuilder = new Metrics.JsonObjectBuilder();
Map<String, Integer> map = (Map)this.callable.call();
if (map != null && !map.isEmpty()) {
boolean allSkipped = true;
Iterator var4 = map.entrySet().iterator();
while(var4.hasNext()) {
Entry<String, Integer> entry = (Entry)var4.next();
if ((Integer)entry.getValue() != 0) {
allSkipped = false;
valuesBuilder.appendField((String)entry.getKey(), (Integer)entry.getValue());
}
}
if (allSkipped) {
return null;
} else {
return (new Metrics.JsonObjectBuilder()).appendField("values", valuesBuilder.build()).build();
}
} else {
return null;
}
}
}
public static class MultiLineChart extends Metrics.CustomChart {
private final Callable<Map<String, Integer>> callable;
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
protected Metrics.JsonObjectBuilder.JsonObject getChartData() throws Exception {
Metrics.JsonObjectBuilder valuesBuilder = new Metrics.JsonObjectBuilder();
Map<String, Integer> map = (Map)this.callable.call();
if (map != null && !map.isEmpty()) {
boolean allSkipped = true;
Iterator var4 = map.entrySet().iterator();
while(var4.hasNext()) {
Entry<String, Integer> entry = (Entry)var4.next();
if ((Integer)entry.getValue() != 0) {
allSkipped = false;
valuesBuilder.appendField((String)entry.getKey(), (Integer)entry.getValue());
}
}
if (allSkipped) {
return null;
} else {
return (new Metrics.JsonObjectBuilder()).appendField("values", valuesBuilder.build()).build();
}
} else {
return null;
}
}
}
public static class SimplePie extends Metrics.CustomChart {
private final Callable<String> callable;
public SimplePie(String chartId, Callable<String> callable) {
super(chartId);
this.callable = callable;
}
protected Metrics.JsonObjectBuilder.JsonObject getChartData() throws Exception {
String value = (String)this.callable.call();
return value != null && !value.isEmpty() ? (new Metrics.JsonObjectBuilder()).appendField("value", value).build() : null;
}
}
}

View File

@ -0,0 +1,63 @@
package cinematicview.cinematicview.PlayerManager;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.GameMode;
import org.bukkit.Location;
public class CustomPlayer {
private GameMode gameMode;
private Location location;
private boolean showingView = false;
private int taskID = 0;
private int innerTask = 0;
private Map<String, String> setting = new HashMap();
public void setInnerTask(int taskID) {
this.innerTask = taskID;
}
public void setTaskID(int taskID) {
this.taskID = taskID;
}
public void setSetting(Map<String, String> setting) {
this.setting = setting;
}
public void setShowingView(boolean bool) {
this.showingView = bool;
}
public void setGameMode(GameMode gameMode) {
this.gameMode = gameMode;
}
public void setLocation(Location location) {
this.location = location;
}
public GameMode getGameMode() {
return this.gameMode;
}
public Location getLocation() {
return this.location;
}
public int getInnerTask() {
return this.innerTask;
}
public int getTaskID() {
return this.taskID;
}
public boolean getShowingView() {
return this.showingView;
}
public Map<String, String> getSetting() {
return this.setting;
}
}

View File

@ -0,0 +1,20 @@
package cinematicview.cinematicview.PlayerManager;
import java.util.HashMap;
import java.util.UUID;
public class PlayerManager {
private HashMap<UUID, CustomPlayer> customPlayers = new HashMap();
public CustomPlayer getCustomPlayer(UUID uuid) {
return (CustomPlayer)this.customPlayers.get(uuid);
}
public void addCustomPlayer(UUID uuid, CustomPlayer player) {
this.customPlayers.put(uuid, player);
}
public void removeCustomPlayer(UUID uuid) {
this.customPlayers.remove(uuid);
}
}

57
config.yml Normal file
View File

@ -0,0 +1,57 @@
###########################################################
# Please ensure that these settings have the correct type #
# If an integer is needed, make sure the setting has an #
# integer, same is needed for (true/false) #
###########################################################
# Will players have a maximum amount of views (true/false)
maximum-views: true
# If players have a maximum amount of views, what is the maximum amount (integer)
maximum-views-amount: 5
# Default interval between Locations for when a View is created (seconds)
default-interval: 6
# Will views have a maximum amount of locations (true/false)
maximum-locations: true
# If views have a maximum amount of locations, what is the maximum amount (integer)
maximum-locations-amount: 10
# Is permissions enabled (true/false)
# 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'
# If set to true, players will need to be given permissions manually with a separate Permissions Plugin. Permission example: 'cinematicview.basic'
permissions: true
# If set to true, player will be unable to rotate (look around) when showing a view (true/false)
lock-rotation: true
# Maximum value for view interval possible (integer)
maximum-view-interval: 20
# Add a pumpkin head when showing a view (true/false)
pumpkin-head: false
# When forcing all players to show a view, who should be excluded (string):
# Options:
# - none
# - admin
# - user
all-exclude: none
# Should messages be displayed when showing a view (true/false)
show-view-message: true
# Which move function you would like to use when showing a cinematic.
# Options:
# - original
# - smooth
# Please be aware that the 'smooth' option is not perfect yet. At low cinematic intervals
# it can cause players to be kicked and also spam the console with 'Moved too quickly'
# The moved to quickly can be adjusted through server settings.
# There is also protection against players being kicked as they will be teleported back and put
# into the correct gamemode if they are kicked
move-function: original
# Add an NPC at player's original location when showing a cinematic
show-npc: false

22
plugin.yml Normal file
View File

@ -0,0 +1,22 @@
name: CinematicView
version: '1.32'
main: cinematicview.cinematicview.CinematicView
api-version: 1.19
authors: [ DWolfsDP ]
commands:
cinematicview:
description: Create views
usage: /<command>
aliases: [cv]
permissions:
cinematicview.basic:
description: Gives players the basic commands for creating and editing views
cinematicview.info:
description: Gives players the info commands for viewing information of views
cinematicview.admin:
description: Gives players the admin commands
dependencies:
server:
LuckPerms:
load: BEFORE
required: true