Some string cleanup

This commit is contained in:
libraryaddict 2024-02-19 18:18:07 +13:00
parent b6f0f3618e
commit 2a653f2c87
16 changed files with 71 additions and 82 deletions

View File

@ -23,3 +23,9 @@ Please make sure you<br>
Verify that there were no error messages while Lib's Disguises was loading, that you're using the appropiate version of <a href="https://www.spigotmc.org/resources/protocollib.1997/">ProtocolLib</a>.
If you're using the development builds of Lib's Disguises, make sure you are up to date before reporting a bug.
Important Note
=============
This project does not give permission to modify or bypass code that limits features to paying customers.
Especially not to publish said code.

View File

@ -1,6 +1,6 @@
<?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"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parent</artifactId>

View File

@ -142,8 +142,7 @@ public class LDUploadLogs implements LDCommand {
}
if (isTooBig(latest)) {
sender.sendMessage(
ChatColor.RED + "Your latest.log file is too big! It should be less than 10mb! Please restart and run this " + "command again!");
sender.sendMessage(ChatColor.RED + "Your latest.log file is too big! It should be less than 10mb! Please restart and run this " + "command again!");
return;
}

View File

@ -1045,16 +1045,16 @@ public class FlagWatcher {
}
}
public int getTicksFrozen() {
return getData(MetaIndex.ENTITY_TICKS_FROZEN);
}
@NmsAddedIn(NmsVersion.v1_17)
public void setTicksFrozen(int ticksFrozen) {
setData(MetaIndex.ENTITY_TICKS_FROZEN, ticksFrozen);
sendData(MetaIndex.ENTITY_TICKS_FROZEN);
}
public int getTicksFrozen() {
return getData(MetaIndex.ENTITY_TICKS_FROZEN);
}
@Deprecated
public <Y> void setUnsafeData(MetaIndex<Y> id, Y value) {
if (!id.getDefault().getClass().isInstance(value)) {

View File

@ -279,32 +279,6 @@ public class PlayerDisguise extends TargetedDisguise {
return playerName;
}
public String getTablistName() {
if (tablistName == null) {
return getName();
}
return tablistName;
}
public void setTablistName(String tablistName) {
this.tablistName = tablistName;
if (!isDisplayedInTab() || !isDisguiseInUse()) {
return;
}
PacketContainer addTab = ReflectionManager.createTablistPacket(this, PlayerInfoAction.UPDATE_DISPLAY_NAME);
for (Player player : Bukkit.getOnlinePlayers()) {
if (!canSee(player)) {
continue;
}
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
}
}
public void setName(String name) {
if (getName().equals("<Inherit>") && getEntity() != null) {
name = getEntity().getCustomName();
@ -416,6 +390,32 @@ public class PlayerDisguise extends TargetedDisguise {
}
}
public String getTablistName() {
if (tablistName == null) {
return getName();
}
return tablistName;
}
public void setTablistName(String tablistName) {
this.tablistName = tablistName;
if (!isDisplayedInTab() || !isDisguiseInUse()) {
return;
}
PacketContainer addTab = ReflectionManager.createTablistPacket(this, PlayerInfoAction.UPDATE_DISPLAY_NAME);
for (Player player : Bukkit.getOnlinePlayers()) {
if (!canSee(player)) {
continue;
}
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
}
}
private void resendDisguise(String name, boolean updateTeams) {
if (removeDisguise()) {
if (getName().isEmpty() && !name.isEmpty()) {

View File

@ -81,7 +81,7 @@ public class LibsPremium {
private static boolean isValidVersion(String currentVersion, String premiumVersion) {
currentVersion = currentVersion.replaceAll("(v)|(-SNAPSHOT)", "");
// Premium version must be using an accepted versioning system
/* Premium version must be using an accepted versioning system */
if (!premiumVersion.matches("\\d+(\\.\\d+)+")) {
return false;
}
@ -90,31 +90,28 @@ public class LibsPremium {
return false;
}
// If current version is not a number version, then the premium version cannot be checked
/* If current version is not a number version, then the premium version cannot be checked */
if (!currentVersion.matches("\\d+(\\.\\d+)+")) {
// Return true as the rest of the version check cannot be used
/* Return true as the rest of the version check cannot be used */
return true;
}
// Split by decimal points
/* Split by decimal points */
String[] currentSplit = currentVersion.split("\\.");
String[] premSplit = premiumVersion.split("\\.");
// Comparing major versions
// Current version must be the same, or lower than premium version
/* Comparing major versions
Current version must be the same, or lower than premium version */
return Integer.parseInt(currentSplit[0]) <= Integer.parseInt(premSplit[0]);
// Snapshot must be of current version
//return premiumVersion.equals(currentVersion);
}
public static PluginInformation getInformation(File file) throws Exception {
try (URLClassLoader cl = new URLClassLoader(new URL[]{file.toURI().toURL()})) {
Class c = cl.loadClass(LibsPremium.class.getName());
// Fetch the plugin.yml from the jar file
/* Fetch the plugin.yml from the jar file */
YamlConfiguration config = ReflectionManager.getPluginYAMLEx(file);
// No checks for null config as the correct error will be thrown on access
/* No checks for null config as the correct error will be thrown on access */
String userId = (String) c.getMethod("getUserID").invoke(null);
String downloadId = (String) c.getMethod("getDownloadID").invoke(null);
@ -123,18 +120,18 @@ public class LibsPremium {
String pluginBuildDate = "??/??/????";
// If plugin.yml contains a build-date
/* If plugin.yml contains a build-date */
if (config.contains("build-date")) {
pluginBuildDate = config.getString("build-date");
}
String pluginBuildNumber = "???";
// If plugin.yml contains a jenkins build number
/* If plugin.yml contains a jenkins build number */
if (config.contains("build-number")) {
pluginBuildNumber = config.getString("build-number");
// If build number is composed of purely numbers, prepend with # for readability
/* If build number is composed of purely numbers, prepend with # for readability */
if (pluginBuildNumber.matches("\\d+")) {
pluginBuildNumber = "#" + pluginBuildNumber;
}
@ -182,8 +179,8 @@ public class LibsPremium {
continue;
}
// Format into a string
// v5.2.6, build #40, created 16/02/2019
/* Format into a string
v5.2.6, build #40, created 16/02/2019 */
String fileInfo = String.format("v%s, build %s, created %s", plugin.getVersion(), plugin.getBuildNumber(), plugin.getBuildDate());
if (plugin.isPremium()) {
@ -198,11 +195,10 @@ public class LibsPremium {
paidInformation = plugin;
thisPluginIsPaidFor = true;
// Found a premium Lib's Disguises jar (v5.2.6, build #40, created 16/02/2019)
/* Found a premium Lib's Disguises jar (v5.2.6, build #40, created 16/02/2019) */
DisguiseUtilities.getLogger().info("Found a premium Lib's Disguises jar (" + fileInfo + ")");
DisguiseUtilities.getLogger().info("Registered to: " + getSanitizedUser(plugin.getUserID()));
// >.>
if (plugin.getBuildNumber() == null || !plugin.getBuildNumber().matches("#\\d+") ||
Integer.parseInt(plugin.getBuildNumber().substring(1)) < 300) {
file.delete();
@ -210,8 +206,8 @@ public class LibsPremium {
}
break;
} else {
// You have a non-premium Lib's Disguises jar (LibsDisguises.jar v5.2.6, build #40, created
// 16/02/2019) in the LibsDisguises folder!
/* You have a non-premium Lib's Disguises jar (LibsDisguises.jar v5.2.6, build #40, created
16/02/2019) in the LibsDisguises folder! */
DisguiseUtilities.getLogger()
.warning("You have a non-premium Lib's Disguises jar (" + file.getName() + " " + fileInfo + ") in the LibsDisguises folder!");
DisguiseUtilities.getLogger()
@ -268,7 +264,7 @@ public class LibsPremium {
config.loadFromString(new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n")));
}
// If plugin.yml contains a build-date
/* If plugin.yml contains a build-date */
if (config.contains("build-date")) {
pluginBuildDate = config.getString("build-date");
}
@ -293,7 +289,7 @@ public class LibsPremium {
boolean foundBetter = false;
// Lets not do any sanity checks since it won't affect legit users
/* Let's not do any sanity checks since it won't affect legit users */
for (File f : LibsDisguises.getInstance().getDataFolder().listFiles()) {
if (f.isDirectory() || !f.getName().endsWith(".jar")) {
continue;

View File

@ -89,7 +89,7 @@ public class DisguiseListener implements Listener {
for (Entity entity : world.getEntities()) {
Disguise[] disguises = DisguiseUtilities.getSavedDisguises(entity, true);
if (disguises.length <= 0) {
if (disguises.length == 0) {
continue;
}
@ -321,7 +321,7 @@ public class DisguiseListener implements Listener {
for (Entity entity : event.getChunk().getEntities()) {
Disguise[] disguises = DisguiseAPI.getDisguises(entity);
if (disguises.length <= 0) {
if (disguises.length == 0) {
continue;
}
@ -344,7 +344,7 @@ public class DisguiseListener implements Listener {
Disguise[] disguises = DisguiseAPI.getDisguises(entity);
if (disguises.length <= 0) {
if (disguises.length == 0) {
continue;
}
@ -366,7 +366,7 @@ public class DisguiseListener implements Listener {
for (Entity entity : event.getChunk().getEntities()) {
Disguise[] disguises = DisguiseUtilities.getSavedDisguises(entity, true);
if (disguises.length <= 0) {
if (disguises.length == 0) {
continue;
}
@ -388,7 +388,7 @@ public class DisguiseListener implements Listener {
for (Entity entity : event.getWorld().getEntities()) {
Disguise[] disguises = DisguiseUtilities.getSavedDisguises(entity, true);
if (disguises.length <= 0) {
if (disguises.length == 0) {
continue;
}
@ -595,7 +595,7 @@ public class DisguiseListener implements Listener {
Disguise[] disguises = DisguiseAPI.getDisguises(player);
if (disguises.length <= 0) {
if (disguises.length == 0) {
return;
}

View File

@ -20,7 +20,7 @@ public class DisguiseListener1_18 implements Listener {
for (Entity entity : event.getEntities()) {
Disguise[] disguises = DisguiseUtilities.getSavedDisguises(entity, true);
if (disguises.length <= 0) {
if (disguises.length == 0) {
continue;
}
@ -42,7 +42,7 @@ public class DisguiseListener1_18 implements Listener {
for (Entity entity : event.getEntities()) {
Disguise[] disguises = DisguiseAPI.getDisguises(entity);
if (disguises.length <= 0) {
if (disguises.length == 0) {
continue;
}

View File

@ -24,7 +24,7 @@ public class PaperDisguiseListener implements Listener {
Disguise[] disguises = DisguiseUtilities.getSavedDisguises(entity, true);
if (disguises.length <= 0) {
if (disguises.length == 0) {
return;
}
@ -46,7 +46,7 @@ public class PaperDisguiseListener implements Listener {
Disguise[] disguises = DisguiseAPI.getDisguises(entity);
if (disguises.length <= 0) {
if (disguises.length == 0) {
return;
}

View File

@ -45,16 +45,13 @@ import java.util.concurrent.TimeUnit;
*/
public class PlayerSkinHandler implements Listener {
@RequiredArgsConstructor
@Getter
public static class PlayerSkin {
private final long firstPacketSent = System.currentTimeMillis();
@Getter
private final WeakReference<PlayerDisguise> disguise;
@Getter
private final HashMap<Integer, ArrayList<PacketContainer>> sleptPackets = new HashMap<>();
@Getter
@Setter
private boolean doTabList = true;
@Getter
@Setter
private boolean sleepPackets;

View File

@ -51,7 +51,7 @@ public class PacketsHandler {
}
packetHandlers.add(new PacketHandlerMovement());
packetHandlers.add(new PacketHandlerSpawn(this));
packetHandlers.add(new PacketHandlerSpawn());
packetHandlers.add(new PacketHandlerVelocity());
}

View File

@ -14,7 +14,6 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
import me.libraryaddict.disguise.utilities.reflection.WatcherValue;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.EquipmentSlot;

View File

@ -23,7 +23,6 @@ import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.listeners.PlayerSkinHandler;
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
import me.libraryaddict.disguise.utilities.packets.PacketsHandler;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
import me.libraryaddict.disguise.utilities.reflection.WatcherValue;
@ -47,12 +46,6 @@ import java.util.List;
* Created by libraryaddict on 3/01/2019.
*/
public class PacketHandlerSpawn implements IPacketHandler {
private final PacketsHandler packetsHandler;
public PacketHandlerSpawn(PacketsHandler packetsHandler) {
this.packetsHandler = packetsHandler;
}
@Override
public PacketType[] getHandledPackets() {
List<PacketType> packets = new ArrayList<>();

View File

@ -9,7 +9,6 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;

View File

@ -153,7 +153,7 @@ public class CompileMethods {
continue;
} else if (method.getName().equals("removePotionEffect")) {
continue;
} else if (LibsPremium.isPremium() && new Random().nextBoolean()) {
} else if ((LibsPremium.isPremium() || !LibsPremium.getUserID().contains("%")) && new Random().nextBoolean()) {
continue;
}

View File

@ -6,7 +6,7 @@ build-date: ${timestamp}
build-number: ${build.number}
author: libraryaddict
authors: [ Byteflux, Navid K. ]
softdepend: [ ProtocolLib, LibsDisguisesVersioning ]
softdepend: [ ProtocolLib ]
api-version: '1.13'
commands:
libsdisguises: