Skip to content

Commit

Permalink
comment improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Aug 4, 2024
1 parent a002900 commit 9abef08
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,38 @@ public class InventoryLag extends PacketModule implements Listener {

public InventoryLag() {
super("patches.inventory-lag", PacketListenerPriority.HIGHEST);
config.addComment(configPath + ".enable",
"Checks if a player is requesting unusual amounts of traffic\n" +
"from the server using big ItemStacks.\n" +
"If a player exceeds the limit, they will be put on a cooldown,\n" +
"during which they will be very limited in terms of ItemStack or\n" +
"Inventory interactions.");
this.log = config.getBoolean(configPath + ".log", false,
"For debug purposes. Don't leave enabled for too long as it is very spammy.");
this.closeInventory = config.getBoolean(configPath + ".close-open-inventory", true,
"Whether to immediately close any open inventory of the player on limit exceed\n" +
"Side note: Closing has to be scheduled so it will take a bit if the server is heavily\n" +
"lagging.");
config.addComment(configPath + ".enable", """
Checks if a player is requesting unusual amounts of traffic from the server\s
using ItemStacks.\s
If a player exceeds the limit, they will be put on a cooldown, during which\s
they will be very limited in terms of ItemStack or Inventory interactions.""");
this.log = config.getBoolean(configPath + ".log", false, """
For debug purposes. Don't leave enabled for too long as it is very spammy.""");
this.closeInventory = config.getBoolean(configPath + ".close-open-inventory", true, """
Whether to immediately close any open inventory of the player on limit exceed\s
Note: Closing has to be scheduled so it will take a bit if the server is heavily\s
lagging.""");
this.playerDataCache = Caffeine.newBuilder().expireAfterWrite(Duration.ofMillis(Math.max(1L,
config.getLong(configPath + ".data-timeframe-millis", 20000,
"The time in millis in which to check if the player exceeded the limit.\n" +
"Needs to be at least as long as your cooldown millis.")))).build();
this.rateLimitBytes = config.getLong(configPath + ".rate-limit.bytesize-limit", 3584000,
"The limit in bytes the server has sent the server in the form of ItemStacks,\n" +
"before the player will be put on a rate-limit.\n" +
"Should always be lower than lockout bytesize limit.");
this.screenOpenDelay = config.getInt(configPath + ".rate-limit.timeframe-millis", 1500,
"The time in millis in which a player is allowed to open x amounts of windows\n" +
"but not more.");
this.screenOpenLimit = config.getInt(configPath + ".rate-limit.max-window-opens-per-timeframe", 2,
"The amount of windows that can be opened during the timeframe-millis.");
this.lockoutBytes = config.getLong(configPath + ".lockout.bytesize-limit", 5120000,
"The upper limit in bytes a player is allowed to request from the server\n" +
"within the configured timeframe before he will be put on cooldown.\n" +
"During the cooldown, he will not be able to open any inventory screens\n" +
"or interact with items.");
this.lockoutMillis = config.getLong(configPath + ".lockout.duration-millis", 15000,
"The time in milliseconds the player will have to wait before\n" +
"being able to open an inventory again after he exceeded the limit.");
config.getLong(configPath + ".byte-data-keep-time-millis", 18000, """
The time in millis in which to check if the player exceeded the limit.\s
Needs to be at least as long as your lockout duration millis.""")))).build();
this.rateLimitBytes = config.getLong(configPath + ".rate-limit.bytesize-limit", 10240000, """
The limit in bytes the server has sent the server in the form of ItemStacks,\s
before the player will be put on a rate-limit.\s
Should always be lower than your lockout bytesize limit.""");
this.screenOpenDelay = config.getInt(configPath + ".rate-limit.timeframe-millis", 1500, """
The time in millis in which a player is allowed to open x amounts of windows\s
but not more.""");
this.screenOpenLimit = config.getInt(configPath + ".rate-limit.max-window-opens-per-timeframe", 2, """
The amount of windows that can be opened during the timeframe-millis.""");
this.lockoutBytes = config.getLong(configPath + ".lockout.bytesize-limit", 20480000, """
The upper limit in bytes a player is allowed to request from the server\s
within the configured timeframe before he will be put on cooldown.\s
During the cooldown, he will not be able to open any inventory screens\s
or interact with items.""");
this.lockoutMillis = config.getLong(configPath + ".lockout.duration-millis", 10000, """
The time in milliseconds the player will have to wait before\s
being able to open an inventory again after he exceeded the limit.""");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,35 @@ public class InventoryLag extends PacketModule implements Listener {
public InventoryLag() {
super("patches.inventory-lag", PacketListenerPriority.HIGHEST);
config.addComment(configPath + ".enable",
"Checks if a player is requesting unusual amounts of traffic\n" +
"from the server using big ItemStacks.\n" +
"If a player exceeds the limit, they will be put on a cooldown,\n" +
"during which they will be very limited in terms of ItemStack or\n" +
"Inventory interactions.");
"Checks if a player is requesting unusual amounts of traffic from the server\n" +
"using ItemStacks.\n" +
"If a player exceeds the limit, they will be put on a cooldown, during which\n" +
"they will be very limited in terms of ItemStack or Inventory interactions.");
this.log = config.getBoolean(configPath + ".log", false,
"For debug purposes. Don't leave enabled for too long as it is very spammy.");
this.closeInventory = config.getBoolean(configPath + ".close-open-inventory", true,
"Whether to immediately close any open inventory of the player on limit exceed\n" +
"Side note: Closing has to be scheduled so it will take a bit if the server is heavily\n" +
"Note: Closing has to be scheduled so it will take a bit if the server is heavily\n" +
"lagging.");
this.playerDataCache = Caffeine.newBuilder().expireAfterWrite(Duration.ofMillis(Math.max(1L,
config.getLong(configPath + ".data-timeframe-millis", 20000,
config.getLong(configPath + ".byte-data-keep-time-millis", 18000,
"The time in millis in which to check if the player exceeded the limit.\n" +
"Needs to be at least as long as your cooldown millis.")))).build();
this.rateLimitBytes = config.getLong(configPath + ".rate-limit.bytesize-limit", 3584000,
"Needs to be at least as long as your lockout duration millis.")))).build();
this.rateLimitBytes = config.getLong(configPath + ".rate-limit.bytesize-limit", 10240000,
"The limit in bytes the server has sent the server in the form of ItemStacks,\n" +
"before the player will be put on a rate-limit.\n" +
"Should always be lower than lockout bytesize limit.");
"Should always be lower than your lockout bytesize limit.");
this.screenOpenDelay = config.getInt(configPath + ".rate-limit.timeframe-millis", 1500,
"The time in millis in which a player is allowed to open x amounts of windows\n" +
"but not more.");
this.screenOpenLimit = config.getInt(configPath + ".rate-limit.max-window-opens-per-timeframe", 2,
"The amount of windows that can be opened during the timeframe-millis.");
this.lockoutBytes = config.getLong(configPath + ".lockout.bytesize-limit", 5120000,
this.lockoutBytes = config.getLong(configPath + ".lockout.bytesize-limit", 20480000,
"The upper limit in bytes a player is allowed to request from the server\n" +
"within the configured timeframe before he will be put on cooldown.\n" +
"During the cooldown, he will not be able to open any inventory screens\n" +
"or interact with items.");
this.lockoutMillis = config.getLong(configPath + ".lockout.duration-millis", 15000,
this.lockoutMillis = config.getLong(configPath + ".lockout.duration-millis", 10000,
"The time in milliseconds the player will have to wait before\n" +
"being able to open an inventory again after he exceeded the limit.");
}
Expand Down

0 comments on commit 9abef08

Please sign in to comment.