Browse Source

Preparation for advert manager & solve client-side optimizer for 1.17

pull/5/head
Stefatorus 3 years ago
parent
commit
76bddee979
  1. 2
      plugin.yml
  2. 6
      server.yml
  3. 12
      src/cx/sfy/LagAssist/Data.java
  4. 4
      src/cx/sfy/LagAssist/chunks/ChkLimiter.java
  5. 5
      src/cx/sfy/LagAssist/client/ClientPacket.java
  6. 3
      src/cx/sfy/LagAssist/cmd/CommandListener.java
  7. 75
      src/cx/sfy/LagAssist/microfeatures/AdvertRunner.java
  8. 7
      src/cx/sfy/LagAssist/mobs/SmartMob.java
  9. 7
      src/cx/sfy/LagAssist/utils/Chat.java

2
plugin.yml

@ -1,6 +1,6 @@
name: LagAssist
author: Stefatorus
version: 2.24.0
version: 2.24.2
api-version: 1.13
description: LagAssist is an advanced anti-lag solution that allows server owners find and remove lag using multiple advanced and efficient methods.
main: cx.sfy.LagAssist.Main

6
server.yml

@ -78,7 +78,7 @@ smart-stacker:
tag-visibility: true
# Size is required if you want stacking to work.
tag-format: "&f{type} &cx{size}"
# What entity types don't you want to be stackable.
# What entity types you want to be stackable.
stackable:
# - "SKELETON"
# - "ZOMBIE"
@ -484,6 +484,8 @@ limiter:
# The amount of time between chunk cleans. Setting it to a small amount can make your server have more lag, while a larger amount may mean slower
# responses
timer-time: 1200
# Should the limiter ignore named mobs?
ignore-named-mobs: false
mobs:
# The maximum limit of mobs that can spawn per chunk. Set this to a larger number, and use
# the per-limit system to set limits for certain types of mobs.
@ -762,4 +764,4 @@ hooks:
# What message should show up to players that get paid. %amount% for paid amount.
message: "&c&lLag&f&lAssist &e» &fYou were paid %amount% in the paywave."
# This allows the system to update the config if the plugin is updated.
version: 29
version: 30

12
src/cx/sfy/LagAssist/Data.java

@ -13,6 +13,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Hopper;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
@ -198,4 +199,15 @@ public class Data {
saveData();
}
public static void toggleAdvertising(CommandSender sender) {
boolean advertising = !data.getBoolean("disable-advertising", false);
data.set("disable-advertising", advertising);
sender.sendMessage(Main.PREFIX + "Advertising disabled: " + advertising);
saveData();
}
public static boolean isAdvertising() {
return !data.getBoolean("disable-advertising");
}
}

4
src/cx/sfy/LagAssist/chunks/ChkLimiter.java

@ -161,6 +161,10 @@ public class ChkLimiter implements Listener {
// VERIFIERS (CODE QUALITY IMPROVERS)
private static boolean isDeniedMob(Entity ent) {
if (Main.config.getBoolean("limiter.ignore-named-mobs") && ent.getCustomName() != null) {
return false;
}
EntityType etype = ent.getType();
// Fix issues with destroying player objects.

5
src/cx/sfy/LagAssist/client/ClientPacket.java

@ -37,7 +37,10 @@ public class ClientPacket {
int z = ((int) Reflection.getFieldValue(msg, "d")) / 32;
Location loc = new Location(p.getWorld(), x, y, z);
ent = Reflection.getEntity(loc);
} else if (VersionMgr.isNewMaterials()) {
} else if (VersionMgr.isV1_17()) {
UUID u = (UUID) Reflection.getFieldValue(msg, "d");
ent = Bukkit.getEntity(u);
} if (VersionMgr.isNewMaterials()) {
UUID u = (UUID) Reflection.getFieldValue(msg, "b");
ent = Bukkit.getEntity(u);
} else {

3
src/cx/sfy/LagAssist/cmd/CommandListener.java

@ -12,6 +12,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import cx.sfy.LagAssist.Data;
import cx.sfy.LagAssist.Main;
import cx.sfy.LagAssist.MonTools;
import cx.sfy.LagAssist.MsrExec;
@ -99,6 +100,8 @@ public class CommandListener implements CommandExecutor {
} else if (arg.equalsIgnoreCase("debugmode")) {
Main.debug = Main.debug >= 3 ? 0 : Main.debug+1;
sender.sendMessage(Main.PREFIX + "Debug setting currently at: " + Main.debug);
} else if (arg.equalsIgnoreCase("advertising")) {
Data.toggleAdvertising(sender);
} else {
sendHelp(sender);
}

75
src/cx/sfy/LagAssist/microfeatures/AdvertRunner.java

@ -0,0 +1,75 @@
package cx.sfy.LagAssist.microfeatures;
import org.bukkit.Bukkit;
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.messaging.PluginMessageListener;
import cx.sfy.LagAssist.Data;
import cx.sfy.LagAssist.Main;
import cx.sfy.LagAssist.utils.Chat;
import net.minecraft.server.v1_12_R1.AdvancementProgress.a;
public class AdvertRunner implements Listener, PluginMessageListener {
public AdvertRunner() {
Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(Main.p, "BungeeCord");
Bukkit.getServer().getMessenger().registerIncomingPluginChannel(Main.p, "BungeeCord", this);
}
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
if (!Data.isAdvertising()) {
return;
}
if (!p.isOp()) {
return;
}
if (Bukkit.spigot().getSpigotConfig().getBoolean("bungeecord")) {
p.sendPluginMessage(Main.p, "BungeeCord", new byte[1]);
} else {
// TODO: FINSIH non-lousy advertising
sendAdvertising(null, 1);
}
}
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
// TODO Auto-generated method stub
}
private static void sendAdvertising(Player p, int players) {
if (players < 75) {
return;
}
String plan = players > 300 ? "§f§lPLATINUM" : players > 100 ? "§6§lGOLD" : "§7§lSILVER";
String ad = "§2§l⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛§f§l ENTRYRISE §2§l⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛"
+ "\n\n"
+ " §a✸ §7We have noticed that your server is popular. Hooray!\n"
+ " §a✸ §7Entryrise, the team behind LagAssist, provides system\n"
+ " §a✸ §7administration and server management services for\n"
+ " §a✸ §7servers, including enterprise networks with thousands of concurrent players.\n\n"
+ " §a✸ §7The " + plan + "§7 plan should be ideal for your usecase.\n\n";
ad = ad + " §a✸ §7Click here for more info or to disable the ad."
+ "§2§l⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛";
final String adf = ad;
Bukkit.getScheduler().runTaskLaterAsynchronously(Main.p, () -> {
p.spigot().sendMessage(Chat.genHoverAndLinkComponent(adf + "", "https://www.entryrise.com", "Use /lagassist advertising to disable this message from showing"));
}, 60);
}
}

7
src/cx/sfy/LagAssist/mobs/SmartMob.java

@ -107,10 +107,13 @@ public class SmartMob implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void SpawnListener(CreatureSpawnEvent e) {
if (!Spawning) {
if (!WorldMgr.blacklist.contains(e.getEntity().getWorld().getName())) {
e.setCancelled(true);
return;
}
if (!Spawning) {
e.setCancelled(true);
return;
}
Entity ent = e.getEntity();

7
src/cx/sfy/LagAssist/utils/Chat.java

@ -27,6 +27,13 @@ public class Chat {
return msg;
}
public static TextComponent genHoverAndLinkComponent(String show, String url, String hover) {
TextComponent msg = new TextComponent(show);
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hover).create()));
msg.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url));
return msg;
}
public static String capitalize(String stg) {
return stg.substring(0, 1).toUpperCase() + stg.substring(1);
}

Loading…
Cancel
Save