Skip to content
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.

Commit

Permalink
Added UseTPS + Few advices inside config.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Lxct committed Jan 1, 2019
1 parent f4f9d05 commit 8e335e8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ public int getScheduledViewDistance() {
}

public void setScheduledViewDistance(int scheduledViewDistance) {
scheduledViewDistance = Math.min(this.getCurrentMaxLimit(), Math.max(scheduledViewDistance, this.getCurrentMinLimit()));
scheduledViewDistance = Math.min(scheduledViewDistance, this.getSettingsViewDistance());
scheduledViewDistance = Math.min(scheduledViewDistance, this.getSupportedViewDistance());
this.scheduledViewDistance = scheduledViewDistance;
this.scheduledViewDistance = Math.min(this.getCurrentMaxLimit(), Math.max(scheduledViewDistance, this.getCurrentMinLimit()));
this.scheduledViewDistance = Math.min(this.scheduledViewDistance, this.getSettingsViewDistance());
this.scheduledViewDistance = Math.min(this.scheduledViewDistance, this.getSupportedViewDistance());
}

public int getCurrentViewDistance() {
Expand Down Expand Up @@ -193,7 +192,6 @@ public void setWaitingForTpUnset(final boolean waitingForTpUnset) {
public boolean isViewBypass() {
if (usePermissions) {
for (int i = 32; i >= 3; i--) { // Start at 32, to 3
// 3 4 5 6 7 8 9 10 ... 30 31 32
if (this.p.hasPermission("view.set." + i)) { // view.set.i is set
return true; // If he has permission, then return the number "after" the permission.
}
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/me/lxct/bestviewdistance/functions/BVDTimings.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import static me.lxct.bestviewdistance.functions.data.Variable.maxIndice;
import static me.lxct.bestviewdistance.functions.data.Variable.serverVersion;
import static me.lxct.bestviewdistance.functions.data.Variable.useTPS;

public class BVDTimings {

Expand Down Expand Up @@ -50,13 +51,15 @@ public double get1minTPS() {

// CALCULATE NEW REDUCTION INDICE
public void actualize() {
final double TPS = get1minTPS();
if (TPS > Variable.tpsLimit && TPS < 20) { // If tps > tps limit
this.reductionIndice = this.reductionIndice - Variable.tpsChange; // Decrease indice
} else if (TPS < Variable.tpsLimit) { // If tps < tps limit
this.reductionIndice = this.reductionIndice + Variable.tpsChange; // Increase indice
if (useTPS) {
final double TPS = get1minTPS();
if (TPS > Variable.tpsLimit && TPS < 20) { // If tps > tps limit
this.reductionIndice = this.reductionIndice - Variable.tpsChange; // Decrease indice
} else if (TPS < Variable.tpsLimit) { // If tps < tps limit
this.reductionIndice = this.reductionIndice + Variable.tpsChange; // Increase indice
}
this.reductionIndice = Math.max(0.0, Math.min(this.reductionIndice, maxIndice));
}
this.reductionIndice = Math.max(0.0, Math.min(this.reductionIndice, maxIndice));
}

public double getReductionIndice() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class Variable {
public static boolean useOnFlyingView;
public static boolean useTasks;
public static boolean usePing;
public static boolean useTPS;
public static boolean useAFKView;
public static boolean useLoginView;
public static boolean usePermissions;
Expand Down Expand Up @@ -124,6 +125,7 @@ public static void loadVariables() {
useOnFlyingView = configYml.getBoolean("Features.UseFlyingView", false);
useTasks = configYml.getBoolean("Features.UseTasks", true);
usePing = configYml.getBoolean("Features.UsePing", true);
useTPS = configYml.getBoolean("Features.UseTPS", true);
useLoginView = configYml.getBoolean("Features.UseLoginView", true);
usePermissions = configYml.getBoolean("Features.UsePermissions", false);
decimalsTPS = configYml.getInt("Misc.DecimalsTPS", 90);
Expand Down Expand Up @@ -199,6 +201,9 @@ public static void loadVariables() {
if (!configYml.isBoolean("Features.UseLoginView")) {
Bukkit.getConsoleSender().sendMessage(colorize("[BestViewDistance] &4&lWARNING! \"UseLoginView\" value is wrong!"));
}
if (!configYml.isBoolean("Features.UseTPS")) {
Bukkit.getConsoleSender().sendMessage(colorize("[BestViewDistance] &4&lWARNING! \"UseTPS\" value is wrong!"));
}
if (!configYml.isBoolean("Features.UsePing")) {
Bukkit.getConsoleSender().sendMessage(colorize("[BestViewDistance] &4&lWARNING! \"UsePing\" value is wrong!"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,14 @@ public static void updateConfig() {
Bukkit.getLogger().info("[BestViewDistance] Added: \"Custom region view\"");
Bukkit.getLogger().info("[BestViewDistance] More information here: https://www.spigotmc.org/resources/61963/updates");
}
if(ver < 2.5) {
Bukkit.getLogger().info("[BestViewDistance] Updating config.yml...");
config.set("Version", 2.5);
config.set("Features.UseTPS", true);
BestViewDistance.plugin.saveConfig();
Bukkit.getLogger().info("[BestViewDistance] Updated config.yml!");
Bukkit.getLogger().info("[BestViewDistance] Added: \"UseTPS\"");
Bukkit.getLogger().info("[BestViewDistance] More information here: https://www.spigotmc.org/resources/61963/updates");
}
}
}
25 changes: 13 additions & 12 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,43 @@
#
# Donate: https://paypal.me/lxct

Version: 2.4 # Version of the config file. Don't change this value.
Version: 2.5 # Version of the config file. Don't change this value.

Features:
Features: # UseTeleportView can increase lags.
UseTPS: true # Increase/Decrease view in function of server's TPS (Reduction Indice = 0)
UsePing: true # The plugin will give a custom view distance for each players
UseLoginView: true # Use a custom view on login
UseAFKView: true # Use a custom view if the player is AFK.
UsePing: true # The plugin will give a custom view distance for each players
UseTasks: true # Use tasks. Turn this off will reduce lags, but view distance will change slower.
UseFlyingView: false # Use a custom view if the player is flying.
UseTeleportView: false # Use a custom view on teleport. Can reduce freeze on teleport.
UsePermissions: false # Enable permissions (view.set.x) to bypass algorithm.

ViewDistance:
Min: 4 # Default minimum view distance (Minimum : 3)
Max: 16 # Default maximum view distance (Maximum : 32)
ViewDistance: # Adjust that according to your needs
Min: 4 # Default minimum view distance (Minimum: 3)
Max: 16 # Default maximum view distance (Maximum: 32)
OnLogin: 4 # View distance on login
OnAFK: 3 # AFK view distance (If UseAFKView is on true)
OnTeleport: 4 # View distance on teleport (If UseTeleportView is on true)
OnFlying: 12 # View distance if flying (If UseFlyingView is on true)
MoreThanSettings: 0 # Add x chunks more than player's settings.

Delay:
Delay: # Warning: A low value for SetViewDelay can increase lags and create ghost chunks!
CalculationsDelay: 1 # Delay in seconds to actualize calculations
SetViewDelay: 15 # Delay in seconds to actualize global view distance
UnsetTeleportViewDelay: 3 # Delay in seconds to unset the OnTeleport custom view
SetViewDelay: 20 # Delay in seconds to actualize global view distance (Impact performances)
UnsetTeleportViewDelay: 3 # Delay in seconds to unset the OnTeleport custom view (Impact performances)
CheckFlyingDelay: 5 # Delay in seconds before set the OnFlying view distance
AFKDelay: 90 # Delay in seconds before set the OnAFK view distance

Settings:
TpsLimit: 19.5 # Below: Decrease Reduction Indice // Over: Increase Reduction Indice.
Settings: # Calculations settings
TpsLimit: 19.5 # Below: Decrease Reduction Indice || Over: Increase Reduction Indice.
TpsChangeIndice: 0.01 # How much we had to increase/decrease the reduction indice. 0.01 = 1%
MaxReductionIndice: 0.75 # Maximum Reduction Indice (0.75 = 75%)
SafePing: 1 # Set this value to 0 for local hosting.
PingForReduction: 550 # Ping required to decrease view distance
PingForAugmentation: 90 # Ping required to increase view distance

Permissions:
Permissions: # Bypass settings
BypassAFKView: true # Player with permissions (view.set.x) can bypass the "OnAFK" view.
BypassTeleportView: true # Player with permissions (view.set.x) can bypass the "OnTeleport" view.
BypassFlyingView: true # Player with permissions (view.set.x) can bypass the "OnFlying" view.
Expand Down

0 comments on commit 8e335e8

Please sign in to comment.