Skip to content

Instantly share code, notes, and snippets.

@dashaw92
Created July 28, 2019 23:43
Show Gist options
  • Save dashaw92/851d02b24ccd73084b5852f029c3a8c7 to your computer and use it in GitHub Desktop.
Save dashaw92/851d02b24ccd73084b5852f029c3a8c7 to your computer and use it in GitHub Desktop.
Patch to update VanishNoPacket to Paper 1.14
From 103003e73788d85c14d9491eaad6d3b50a75278d Mon Sep 17 00:00:00 2001
From: dashaw92 <dashaw92@gmail.com>
Date: Sun, 28 Jul 2019 19:41:33 -0400
Subject: [PATCH] Updated to 1.14
---
.gitignore | 4 +
pom.xml | 391 +++++++-----------
.../vanish/VanishAnnounceManipulator.java | 23 +-
.../java/org/kitteh/vanish/VanishManager.java | 17 +-
.../java/org/kitteh/vanish/VanishPlugin.java | 162 +-------
.../org/kitteh/vanish/hooks/HookManager.java | 14 -
.../vanish/hooks/plugins/EssentialsHook.java | 1 -
.../listeners/ListenPlayerMessages.java | 1 +
.../vanish/listeners/ListenPlayerOther.java | 79 ++--
src/main/resources/plugin.yml | 8 +-
10 files changed, 233 insertions(+), 467 deletions(-)
create mode 100644 .gitignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..87b5c77
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+target/
+.settings/
+.classpath
+.project
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index b4bc518..6ed18d3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,243 +1,168 @@
-<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>org.kitteh</groupId>
- <artifactId>VanishNoPacket</artifactId>
- <packaging>jar</packaging>
+<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>org.kitteh</groupId>
+ <artifactId>VanishNoPacket</artifactId>
+ <packaging>jar</packaging>
- <name>VanishNoPacket</name>
- <version>3.20.1</version>
+ <name>VanishNoPacket</name>
+ <version>3.20.1</version>
- <url>http://github.com/mbax/VanishNoPacket</url>
+ <url>http://github.com/mbax/VanishNoPacket</url>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <vnp-version>${project.version}-unofficial</vnp-version>
- </properties>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <vnp-version>${project.version}-unofficial</vnp-version>
+ </properties>
- <profiles>
- <profile>
- <id>jenkins</id>
- <properties>
- <vnp-version>${project.version}-${buildNumber}</vnp-version>
- </properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>buildnumber-maven-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <phase>validate</phase>
- <goals>
- <goal>create</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <doCheck>true</doCheck>
- <revisionOnScmFailure>no-rev</revisionOnScmFailure>
- <scmDirectory>../../</scmDirectory>
- <shortRevisionLength>7</shortRevisionLength>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>release</id>
- <properties>
- <vnp-version>${project.version}</vnp-version>
- </properties>
- </profile>
- </profiles>
+ <profiles>
+ <profile>
+ <id>jenkins</id>
+ <properties>
+ <vnp-version>${project.version}-${buildNumber}</vnp-version>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>buildnumber-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <doCheck>true</doCheck>
+ <revisionOnScmFailure>no-rev</revisionOnScmFailure>
+ <scmDirectory>../../</scmDirectory>
+ <shortRevisionLength>7</shortRevisionLength>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>release</id>
+ <properties>
+ <vnp-version>${project.version}</vnp-version>
+ </properties>
+ </profile>
+ </profiles>
- <scm>
- <connection>scm:git:git://github.com/mbax/VanishNoPacket.git</connection>
- <developerConnection>scm:git:ssh://git@github.com/mbax/VanishNoPacket.git</developerConnection>
- <url>https://github.com/mbax/VanishNoPacket</url>
- </scm>
+ <scm>
+ <connection>scm:git:git://github.com/mbax/VanishNoPacket.git</connection>
+ <developerConnection>scm:git:ssh://git@github.com/mbax/VanishNoPacket.git</developerConnection>
+ <url>https://github.com/mbax/VanishNoPacket</url>
+ </scm>
- <repositories>
- <repository>
- <id>kitteh-repo</id>
- <url>http://repo.kitteh.org/content/groups/public</url>
- </repository>
- <repository>
- <id>bukkit-repo</id>
- <url>http://repo.bukkit.org/content/groups/public</url>
- </repository>
- </repositories>
+ <repositories>
+ <repository>
+ <id>kitteh-repo</id>
+ <url>http://repo.kitteh.org/content/groups/public</url>
+ </repository>
+ <repository>
+ <id>bukkit-repo</id>
+ <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
+ </repository>
+ <repository>
+ <id>papermc</id>
+ <url>https://papermc.io/repo/repository/maven-public/</url>
+ </repository>
+ </repositories>
- <dependencies>
- <dependency>
- <groupId>org.bukkit</groupId>
- <artifactId>bukkit</artifactId>
- <version>1.7.10-R0.1-SNAPSHOT</version>
- <type>jar</type>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>com.comphenix.protocol</groupId>
- <artifactId>ProtocolLib</artifactId>
- <version>1.5.1</version>
- <type>jar</type>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.getspout</groupId>
- <artifactId>spoutplugin</artifactId>
- <version>1.5.2-R1.0-SNAPSHOT-HOSTED</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.dynmap</groupId>
- <artifactId>DynmapCoreAPI</artifactId>
- <version>1.7</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>de.bananaco</groupId>
- <artifactId>bPermissions</artifactId>
- <version>v2.12-DEV</version>
- <optional>true</optional>
- <exclusions>
- <exclusion>
- <groupId>org.bukkit</groupId>
- <artifactId>craftbukkit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.bukkit</groupId>
- <artifactId>bukkit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>com.earth2me</groupId>
- <artifactId>essentials</artifactId>
- <version>2.11.1</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>uk.org.whoami</groupId>
- <artifactId>GeoIPTools</artifactId>
- <version>1.0</version>
- <optional>true</optional>
- <exclusions>
- <exclusion>
- <groupId>org.bukkit</groupId>
- <artifactId>bukkit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>com.ramblingwood.minecraft.jsonapi</groupId>
- <artifactId>JSONAPI</artifactId>
- <version>bleeding</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.kitteh</groupId>
- <artifactId>tagapi</artifactId>
- <version>3.0</version>
- <optional>true</optional>
- <exclusions>
- <exclusion>
- <groupId>org.bukkit</groupId>
- <artifactId>bukkit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>pgDev</groupId>
- <artifactId>disguisecraft</artifactId>
- <version>2.8-SNAPSHOT</version>
- <optional>true</optional>
- <exclusions>
- <exclusion>
- <groupId>org.bukkit</groupId>
- <artifactId>craftbukkit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>lishid</groupId>
- <artifactId>orebfuscator</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.getspout</groupId>
- <artifactId>spoutplugin</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>net.milkbowl.vault</groupId>
- <artifactId>Vault</artifactId>
- <version>1.2.32</version>
- <type>jar</type>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>com.destroystokyo.paper</groupId>
+ <artifactId>paper-api</artifactId>
+ <version>1.14.4-R0.1-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.bukkit</groupId>
+ <artifactId>bukkit</artifactId>
+ <version>1.14.4-R0.1-SNAPSHOT</version>
+ <type>jar</type>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>com.earth2me</groupId>
+ <artifactId>essentials</artifactId>
+ <version>2.11.1</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>net.milkbowl.vault</groupId>
+ <artifactId>Vault</artifactId>
+ <version>1.2.32</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
- <distributionManagement>
- <repository>
- <id>kittehReleases</id>
- <name>Kitteh Releases</name>
- <url>http://repo.kitteh.org/content/repositories/releases</url>
- </repository>
- <snapshotRepository>
- <id>kittehSnapshots</id>
- <name>Kitteh Snapshots</name>
- <url>http://repo.kitteh.org/content/repositories/snapshots</url>
- </snapshotRepository>
- </distributionManagement>
+ <distributionManagement>
+ <repository>
+ <id>kittehReleases</id>
+ <name>Kitteh Releases</name>
+ <url>http://repo.kitteh.org/content/repositories/releases</url>
+ </repository>
+ <snapshotRepository>
+ <id>kittehSnapshots</id>
+ <name>Kitteh Snapshots</name>
+ <url>http://repo.kitteh.org/content/repositories/snapshots</url>
+ </snapshotRepository>
+ </distributionManagement>
- <build>
- <finalName>${project.artifactId}</finalName>
- <directory>target</directory>
- <resources>
- <resource>
- <targetPath>.</targetPath>
- <filtering>true</filtering>
- <directory>src/main/resources</directory>
- <includes>
- <include>plugin.yml</include>
- <include>config.yml</include>
- <include>spoutcraft.yml</include>
- </includes>
- </resource>
- <resource>
- <targetPath>.</targetPath>
- <directory>${basedir}/</directory>
- <includes>
- <include>LICENSE</include>
- </includes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-deploy-plugin</artifactId>
- <version>2.7</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <directory>target</directory>
+ <resources>
+ <resource>
+ <targetPath>.</targetPath>
+ <filtering>true</filtering>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>plugin.yml</include>
+ <include>config.yml</include>
+ </includes>
+ </resource>
+ <resource>
+ <targetPath>.</targetPath>
+ <directory>${basedir}/</directory>
+ <includes>
+ <include>LICENSE</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.7</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
diff --git a/src/main/java/org/kitteh/vanish/VanishAnnounceManipulator.java b/src/main/java/org/kitteh/vanish/VanishAnnounceManipulator.java
index e83b3ca..9d29e12 100644
--- a/src/main/java/org/kitteh/vanish/VanishAnnounceManipulator.java
+++ b/src/main/java/org/kitteh/vanish/VanishAnnounceManipulator.java
@@ -8,8 +8,6 @@ import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.kitteh.vanish.hooks.HookManager.HookType;
-import org.kitteh.vanish.hooks.plugins.BPermissionsHook;
-import org.kitteh.vanish.hooks.plugins.GeoIPToolsHook;
import org.kitteh.vanish.hooks.plugins.VaultHook;
import org.kitteh.vanish.metrics.MetricsOverlord;
@@ -54,12 +52,13 @@ public final class VanishAnnounceManipulator {
* @param playerName name of the player to query
* @return true if player is considered online, false if not (or if not on server)
*/
- public boolean getFakeOnlineStatus(String playerName) {
- final Player player = this.plugin.getServer().getPlayerExact(playerName);
+ public boolean getFakeOnlineStatus(String name) {
+ @SuppressWarnings("deprecation")
+ final Player player = this.plugin.getServer().getPlayerExact(name);
if (player == null) {
return false;
}
- playerName = player.getName();
+ String playerName = player.getName();
if (this.playerOnlineStatus.containsKey(playerName)) {
return this.playerOnlineStatus.get(playerName);
} else {
@@ -82,23 +81,13 @@ public final class VanishAnnounceManipulator {
}
private String injectPlayerInformation(String message, Player player) {
- final GeoIPToolsHook geoip = (GeoIPToolsHook) this.plugin.getHookManager().getHook(HookType.GeoIPTools);
- final BPermissionsHook bperms = (BPermissionsHook) this.plugin.getHookManager().getHook(HookType.BPermissions);
final VaultHook vault = (VaultHook) this.plugin.getHookManager().getHook(HookType.Vault);
message = message.replace("%p", player.getName());
message = message.replace("%d", player.getDisplayName());
- String prefix = bperms.getPrefix(player);
- if (prefix.isEmpty()) {
- prefix = vault.getPrefix(player);
- }
+ String prefix = vault.getPrefix(player);
message = message.replace("%up", prefix);
- String suffix = bperms.getSuffix(player);
- if (suffix.isEmpty()) {
- suffix = vault.getSuffix(player);
- }
+ String suffix = vault.getSuffix(player);
message = message.replace("%us", suffix);
- message = message.replace("%city", geoip.getCity(player));
- message = message.replace("%country", geoip.getCountry(player));
return message;
}
diff --git a/src/main/java/org/kitteh/vanish/VanishManager.java b/src/main/java/org/kitteh/vanish/VanishManager.java
index d14484f..787011b 100644
--- a/src/main/java/org/kitteh/vanish/VanishManager.java
+++ b/src/main/java/org/kitteh/vanish/VanishManager.java
@@ -1,6 +1,7 @@
package org.kitteh.vanish;
-import com.google.common.collect.ImmutableSet;
+import java.util.*;
+
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location;
@@ -13,13 +14,7 @@ import org.bukkit.plugin.messaging.PluginMessageListener;
import org.kitteh.vanish.event.VanishStatusChangeEvent;
import org.kitteh.vanish.metrics.MetricsOverlord;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-import java.util.UUID;
+import com.google.common.collect.ImmutableSet;
public final class VanishManager {
private final class ShowPlayerEntry {
@@ -48,6 +43,7 @@ public final class VanishManager {
this.entries.add(player);
}
+ @SuppressWarnings("deprecation")
@Override
public void run() {
for (final ShowPlayerEntry entry : this.next) {
@@ -125,6 +121,7 @@ public final class VanishManager {
* @return if the named player is currently vanished
*/
public boolean isVanished(String playerName) {
+ @SuppressWarnings("deprecation")
final Player player = this.plugin.getServer().getPlayer(playerName);
if (player != null) {
Debuggle.log("Testing vanished status of " + player.getName() + ": " + this.isVanished(player));
@@ -149,6 +146,7 @@ public final class VanishManager {
*
* @param player the player who has quit
*/
+ @SuppressWarnings("deprecation")
public void playerQuit(Player player) {
Debuggle.log("Quitting: " + player.getName());
this.resetSleepingIgnored(player);
@@ -235,6 +233,7 @@ public final class VanishManager {
* @param vanishingPlayer
* @param effects if true, trigger effects
*/
+ @SuppressWarnings("deprecation")
public void toggleVanishQuiet(Player vanishingPlayer, boolean effects) {
final boolean vanishing = !this.isVanished(vanishingPlayer);
final String vanishingPlayerName = vanishingPlayer.getName();
@@ -410,6 +409,7 @@ public final class VanishManager {
}
}
+ @SuppressWarnings("deprecation")
private void hideVanished(Player player) {
for (final Player otherPlayer : this.plugin.getServer().getOnlinePlayers()) {
if (!player.equals(otherPlayer) && this.isVanished(otherPlayer) && player.canSee(otherPlayer)) {
@@ -430,6 +430,7 @@ public final class VanishManager {
}
}
+ @SuppressWarnings("deprecation")
void onPluginDisable() {
for (final Player player : this.plugin.getServer().getOnlinePlayers()) {
for (final Player player2 : this.plugin.getServer().getOnlinePlayers()) {
diff --git a/src/main/java/org/kitteh/vanish/VanishPlugin.java b/src/main/java/org/kitteh/vanish/VanishPlugin.java
index 3133ad7..bac9b95 100644
--- a/src/main/java/org/kitteh/vanish/VanishPlugin.java
+++ b/src/main/java/org/kitteh/vanish/VanishPlugin.java
@@ -1,110 +1,18 @@
package org.kitteh.vanish;
+import java.io.File;
+import java.util.HashSet;
+
import org.bukkit.ChatColor;
-import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.metadata.LazyMetadataValue;
import org.bukkit.metadata.LazyMetadataValue.CacheStrategy;
import org.bukkit.plugin.java.JavaPlugin;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.JSONValue;
import org.kitteh.vanish.hooks.HookManager;
import org.kitteh.vanish.hooks.HookManager.HookType;
-import org.kitteh.vanish.listeners.ListenEntity;
-import org.kitteh.vanish.listeners.ListenInventory;
-import org.kitteh.vanish.listeners.ListenPlayerJoin;
-import org.kitteh.vanish.listeners.ListenPlayerMessages;
-import org.kitteh.vanish.listeners.ListenPlayerOther;
-import org.kitteh.vanish.listeners.ListenServerPing;
-import org.kitteh.vanish.listeners.ListenToYourHeart;
-import org.kitteh.vanish.listeners.TagAPIListener;
-import org.kitteh.vanish.metrics.MetricsOverlord;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.HashSet;
+import org.kitteh.vanish.listeners.*;
public final class VanishPlugin extends JavaPlugin {
- final class UpdateCheck implements Runnable {
- private static final String CREDITS = "This updater code is based on the great work of Gravity";
-
- String getCredits() {
- return CREDITS;
- }
-
- private final VanishPlugin plugin;
-
- private UpdateCheck(VanishPlugin vanishPlugin) {
- this.plugin = vanishPlugin;
- }
-
- @Override
- public void run() {
- final File pluginsFolder = this.plugin.getDataFolder().getParentFile();
- final File updaterFolder = new File(pluginsFolder, "Updater");
- final File updaterConfigFile = new File(updaterFolder, "config.yml");
- String apiKey = null;
- String latest = null;
-
- if (updaterFolder.exists()) {
- if (updaterConfigFile.exists()) {
- final YamlConfiguration config = YamlConfiguration.loadConfiguration(updaterConfigFile);
- apiKey = config.getString("api-key");
- }
- }
-
- URL url;
- try {
- url = new URL("https://api.curseforge.com/servermods/files?projectIds=30949");
- } catch (final MalformedURLException e) {
- return;
- }
-
- URLConnection conn;
- IOException exceptional = null;
- try {
- conn = url.openConnection();
-
- conn.setConnectTimeout(5000);
- if (apiKey != null) {
- conn.addRequestProperty("X-API-Key", apiKey);
- }
- conn.addRequestProperty("User-Agent", "KittehUpdater (by mbaxter)");
- conn.setDoOutput(true);
-
- final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- final String response = reader.readLine();
-
- final JSONArray array = (JSONArray) JSONValue.parse(response);
- if (array.size() == 0) {
- return;
- }
-
- latest = (String) ((JSONObject) array.get(array.size() - 1)).get("name");
- } catch (final IOException e) {
- exceptional = e;
- }
- if (latest != null) {
- this.plugin.latestVersion = latest;
- if (!("v" + this.plugin.getCurrentVersion()).equals(latest)) {
- this.plugin.getLogger().info("Found a different version available: " + latest);
- this.plugin.getLogger().info("Check http://www.curse.com/server-mods/minecraft/vanish");
- this.plugin.versionDiff = true;
- }
- } else {
- this.plugin.getLogger().info("Error: Could not check if plugin was up to date. Will try later");
- if (exceptional != null) {
- this.plugin.getLogger().info("Exception message: " + exceptional.getMessage());
- }
- }
- }
- }
private final HashSet<String> haveInventoriesOpen = new HashSet<String>();
private String latestVersion = null;
@@ -268,9 +176,7 @@ public final class VanishPlugin extends JavaPlugin {
this.setInstance(this);
final File check = new File(this.getDataFolder(), "config.yml");
- boolean firstTimeStarting = false;
if (!check.exists()) {
- firstTimeStarting = true;
this.saveDefaultConfig();
this.reloadConfig();
if (this.getServer().getPluginManager().isPluginEnabled("Essentials")) {
@@ -282,51 +188,11 @@ public final class VanishPlugin extends JavaPlugin {
Settings.freshStart(this);
- dance:
- if (this.getConfig().getBoolean("colornametags", true)) {
- if (this.getServer().getPluginManager().isPluginEnabled("TagAPI")) {
- try {
- Class.forName("org.kitteh.tag.AsyncPlayerReceiveNameTagEvent");
- } catch (final ClassNotFoundException e) {
- this.getLogger().warning("Update to TagAPI 3.0 or later to use name coloring");
- break dance;
- }
- this.getServer().getPluginManager().registerEvents(new TagAPIListener(this), this);
- this.getLogger().info("Using color changing features of TagAPI.");
- } else {
- this.getLogger().info("Colored nametags enabled, but I couldn't find TagAPI");
- this.getLogger().info("For awesome colored nametags on vanish, visit");
- this.getLogger().info("http://dev.bukkit.org/server-mods/tag/ ");
- this.getLogger().info("and download TagAPI.jar");
- }
- }
-
if (this.getConfig().getBoolean("hooks.essentials", false)) {
this.hookManager.getHook(HookType.Essentials).onEnable();
}
- this.hookManager.getHook(HookType.GeoIPTools).onEnable();
- if (this.getConfig().getBoolean("hooks.dynmap", false)) {
- this.hookManager.getHook(HookType.Dynmap).onEnable();
- }
- //if (this.getServer().getPluginManager().getPlugin("ProtocolLib") != null) {
- // this.hookManager.getHook(HookType.ProtocolLib).onEnable();
- //}
-
- final VanishPlugin self = this;
+
//Post-load stuff
- this.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
- @Override
- public void run() {
- if (VanishPlugin.this.getConfig().getBoolean("hooks.JSONAPI", false)) {
- VanishPlugin.this.hookManager.getHook(HookType.JSONAPI).onEnable();
- }
- MetricsOverlord.init(self);
- }
- }, 1);
-
- if (this.getConfig().getBoolean("hooks.spoutcraft", false)) {
- this.hookManager.getHook(HookType.SpoutCraft).onEnable();
- }
this.manager = new VanishManager(this);
@@ -334,24 +200,6 @@ public final class VanishPlugin extends JavaPlugin {
player.setMetadata("vanished", new LazyMetadataValue(this, CacheStrategy.NEVER_CACHE, new VanishCheck(this.manager, player.getName())));
}
- boolean updateCheck = this.getConfig().getBoolean("checkupdates", true);
- if (firstTimeStarting) {
- updateCheck = false;
- this.getLogger().info("This is your first startup (or you wiped your config).");
- this.getLogger().info("In future startups, VanishNoPacket will check for updates");
- this.getLogger().info("If you dislike it, disable 'checkupdates' in the config file");
- this.getLogger().info("Note that this plugin also utilizes PluginMetrics with usage tracking");
- this.getLogger().info("If you do not want usage tracking (paranoid) disable in that config");
- }
-
- if (updateCheck) {
- if (this.getCurrentVersion().contains("SNAPSHOT") || this.getCurrentVersion().equals("${project.version}") || this.getCurrentVersion().endsWith("unofficial")) {
- this.getLogger().info("Not a release version. Update check disabled");
- } else {
- this.getServer().getScheduler().runTaskTimerAsynchronously(this, new UpdateCheck(this), 40, 432000);
- }
- }
-
this.getCommand("vanish").setExecutor(new VanishCommand(this));
this.getServer().getPluginManager().registerEvents(new ListenEntity(this), this);
this.getServer().getPluginManager().registerEvents(new ListenPlayerMessages(this), this);
diff --git a/src/main/java/org/kitteh/vanish/hooks/HookManager.java b/src/main/java/org/kitteh/vanish/hooks/HookManager.java
index cd3e6db..db178a1 100644
--- a/src/main/java/org/kitteh/vanish/hooks/HookManager.java
+++ b/src/main/java/org/kitteh/vanish/hooks/HookManager.java
@@ -8,26 +8,12 @@ import java.util.Map;
import org.bukkit.entity.Player;
import org.kitteh.vanish.Debuggle;
import org.kitteh.vanish.VanishPlugin;
-import org.kitteh.vanish.hooks.plugins.BPermissionsHook;
-import org.kitteh.vanish.hooks.plugins.DisguiseCraftHook;
-import org.kitteh.vanish.hooks.plugins.DynmapHook;
import org.kitteh.vanish.hooks.plugins.EssentialsHook;
-import org.kitteh.vanish.hooks.plugins.GeoIPToolsHook;
-import org.kitteh.vanish.hooks.plugins.JSONAPIHook;
-import org.kitteh.vanish.hooks.plugins.ProtocolLibHook;
-import org.kitteh.vanish.hooks.plugins.SpoutCraftHook;
import org.kitteh.vanish.hooks.plugins.VaultHook;
public final class HookManager {
public enum HookType {
- BPermissions(BPermissionsHook.class),
- DisguiseCraft(DisguiseCraftHook.class),
- Dynmap(DynmapHook.class),
Essentials(EssentialsHook.class),
- GeoIPTools(GeoIPToolsHook.class),
- JSONAPI(JSONAPIHook.class),
- ProtocolLib(ProtocolLibHook.class),
- SpoutCraft(SpoutCraftHook.class),
Vault(VaultHook.class);
private Class<? extends Hook> clazz;
diff --git a/src/main/java/org/kitteh/vanish/hooks/plugins/EssentialsHook.java b/src/main/java/org/kitteh/vanish/hooks/plugins/EssentialsHook.java
index fbb6089..490fab1 100644
--- a/src/main/java/org/kitteh/vanish/hooks/plugins/EssentialsHook.java
+++ b/src/main/java/org/kitteh/vanish/hooks/plugins/EssentialsHook.java
@@ -7,7 +7,6 @@ import org.kitteh.vanish.hooks.Hook;
import com.earth2me.essentials.IEssentials;
-@SuppressWarnings("deprecation")
public final class EssentialsHook extends Hook {
private final VanishPlugin plugin;
private IEssentials essentials;
diff --git a/src/main/java/org/kitteh/vanish/listeners/ListenPlayerMessages.java b/src/main/java/org/kitteh/vanish/listeners/ListenPlayerMessages.java
index 7df4bc3..1695b23 100644
--- a/src/main/java/org/kitteh/vanish/listeners/ListenPlayerMessages.java
+++ b/src/main/java/org/kitteh/vanish/listeners/ListenPlayerMessages.java
@@ -49,6 +49,7 @@ public final class ListenPlayerMessages implements Listener {
}
message.append(" have ");
} else if ((split.length == 3) && otherTest) {
+ @SuppressWarnings("deprecation")
final Player target = this.plugin.getServer().getPlayer(split[1]);
if (target == null) {
message.append("Cannot find player: " + ChatColor.AQUA + split[1]);
diff --git a/src/main/java/org/kitteh/vanish/listeners/ListenPlayerOther.java b/src/main/java/org/kitteh/vanish/listeners/ListenPlayerOther.java
index 608c4c1..eea6157 100644
--- a/src/main/java/org/kitteh/vanish/listeners/ListenPlayerOther.java
+++ b/src/main/java/org/kitteh/vanish/listeners/ListenPlayerOther.java
@@ -2,34 +2,24 @@ package org.kitteh.vanish.listeners;
import org.bukkit.ChatColor;
import org.bukkit.Material;
-import org.bukkit.block.Beacon;
-import org.bukkit.block.Block;
-import org.bukkit.block.BlockState;
-import org.bukkit.block.BrewingStand;
-import org.bukkit.block.Chest;
-import org.bukkit.block.Dispenser;
-import org.bukkit.block.Dropper;
-import org.bukkit.block.Furnace;
-import org.bukkit.block.Hopper;
+import org.bukkit.block.*;
+import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
+import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
-import org.bukkit.event.player.PlayerBucketFillEvent;
-import org.bukkit.event.player.PlayerChangedWorldEvent;
-import org.bukkit.event.player.PlayerDropItemEvent;
-import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.event.player.PlayerPickupItemEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-import org.bukkit.event.player.PlayerShearEntityEvent;
+import org.bukkit.event.player.*;
import org.bukkit.inventory.Inventory;
import org.kitteh.vanish.Settings;
import org.kitteh.vanish.VanishPerms;
import org.kitteh.vanish.VanishPlugin;
import org.kitteh.vanish.metrics.MetricsOverlord;
+import com.destroystokyo.paper.event.entity.ProjectileCollideEvent;
+
public final class ListenPlayerOther implements Listener {
private final VanishPlugin plugin;
@@ -60,6 +50,17 @@ public final class ListenPlayerOther implements Listener {
}
}
}
+
+ @EventHandler(priority = EventPriority.HIGHEST)
+ public void onProjectileCollide(ProjectileCollideEvent event) {
+ if(event.getCollidedWith().getType() != EntityType.PLAYER) return;
+
+ Player hit = (Player) event.getCollidedWith();
+ if(plugin.getManager().isVanished(hit)) {
+ hit.sendMessage(ChatColor.AQUA + "[VNP] Projectile was phased through you because you are vanished!");
+ event.setCancelled(true);
+ }
+ }
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event) {
@@ -68,20 +69,10 @@ public final class ListenPlayerOther implements Listener {
final Block block = event.getClickedBlock();
Inventory inventory = null;
final BlockState blockState = block.getState();
+
boolean fake = false;
switch (block.getType()) {
- case TRAPPED_CHEST:
- case CHEST:
- final Chest chest = (Chest) blockState;
- inventory = this.plugin.getServer().createInventory(player, chest.getInventory().getSize());
- inventory.setContents(chest.getInventory().getContents());
- fake = true;
- break;
case ENDER_CHEST:
- if (this.plugin.getServer().getPluginManager().isPluginEnabled("EnderChestPlus") && VanishPerms.canNotInteract(player)) {
- event.setCancelled(true);
- return;
- }
inventory = player.getEnderChest();
break;
case DISPENSER:
@@ -96,18 +87,37 @@ public final class ListenPlayerOther implements Listener {
case FURNACE:
inventory = ((Furnace) blockState).getInventory();
break;
+ case BLAST_FURNACE:
+ inventory = ((BlastFurnace) blockState).getInventory();
+ break;
+ case SMOKER:
+ inventory = ((Smoker) blockState).getInventory();
+ break;
+ case LECTERN:
+ inventory = ((Lectern) blockState).getInventory();
+ break;
case BREWING_STAND:
inventory = ((BrewingStand) blockState).getInventory();
break;
- case BEACON:
- inventory = ((Beacon) blockState).getInventory();
+ default:
+ Material mat = block.getType();
+ boolean isShulker = mat.name().contains("SHULKER_BOX");
+ if(isShulker || mat == Material.TRAPPED_CHEST || mat == Material.CHEST || mat == Material.BARREL) {
+ final Container chest = (Container) blockState;
+ inventory = this.plugin.getServer().createInventory(player, chest.getInventory().getSize());
+ inventory.setContents(chest.getInventory().getContents());
+ fake = true;
+ break;
+ }
+
break;
}
+
if (inventory != null) {
event.setCancelled(true);
if (fake) {
this.plugin.chestFakeOpen(player.getName());
- player.sendMessage(ChatColor.AQUA + "[VNP] Opening chest silently. Can not edit.");
+ player.sendMessage(ChatColor.AQUA + "[VNP] Opening container silently. Can not edit.");
}
player.openInventory(inventory);
return;
@@ -117,7 +127,7 @@ public final class ListenPlayerOther implements Listener {
event.setCancelled(true);
return;
}
- if ((event.getAction() == Action.PHYSICAL) && (event.getClickedBlock().getType() == Material.SOIL)) {
+ if ((event.getAction() == Action.PHYSICAL) && (event.getClickedBlock().getType() == Material.FARMLAND)) {
if (this.plugin.getManager().isVanished(player) && VanishPerms.canNotTrample(player)) {
event.setCancelled(true);
}
@@ -125,8 +135,11 @@ public final class ListenPlayerOther implements Listener {
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
- public void onPlayerPickupItem(PlayerPickupItemEvent event) {
- if (this.plugin.getManager().isVanished(event.getPlayer()) && VanishPerms.canNotPickUp(event.getPlayer())) {
+ public void onPlayerPickupItem(EntityPickupItemEvent event) {
+ if(event.getEntityType() != EntityType.PLAYER) return;
+ Player player = (Player)event.getEntity();
+
+ if (this.plugin.getManager().isVanished(player) && VanishPerms.canNotPickUp(player)) {
event.setCancelled(true);
}
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index d95554a..a956fe2 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -2,10 +2,10 @@ name: VanishNoPacket
main: org.kitteh.vanish.VanishPlugin
version: '${vnp-version}'
website: http://kitteh.org
-softdepend: [Essentials,dynmap,JSONAPI,bPermissions,Spout,GeoIPTools,TagAPI,ProtocolLib,Vault]
-author: mbaxter
-description: Vanish for the distinguished admin
-dev-url: http://dev.bukkit.org/server-mods/vanish/
+softdepend: [Essentials,Vault]
+authors: [mbaxter, Danny]
+description: Vanish for the distinguished admin. Updated to 1.14 by Danny
+api-version: 1.14
commands:
vanish:
description: poof
--
2.21.0.windows.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment