Skip to content

Commit

Permalink
rename modules and change path
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Aug 5, 2024
1 parent 8a5dd99 commit 83c2df3
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockSpreadEvent;

public class BlockFormOrGrow extends PhysicsModule {
public class BlockFormOrGrow extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockPhysicsEvent;

public class BlockPhysics extends PhysicsModule {
public class BlockPhysics extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Map;
import java.util.TreeMap;

public class EntityTargeting extends PhysicsModule implements Listener {
public class EntityTargeting extends RegionalActivityModule implements Listener {

private final Map<EntityType, Double> limitedTypes = new EnumMap<>(EntityType.class);
private final double globalMaxDistanceSquared;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;

public class Explosions extends PhysicsModule {
public class Explosions extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockFromToEvent;

public class LiquidSpread extends PhysicsModule {
public class LiquidSpread extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.NotePlayEvent;

public class Noteblocks extends PhysicsModule {
public class Noteblocks extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.Map;
import java.util.TreeMap;

public class Pathfinding extends PhysicsModule implements Listener {
public class Pathfinding extends RegionalActivityModule implements Listener {

private final Map<EntityType, Double> limitedTypes = new EnumMap<>(EntityType.class);
private final double globalMaxDistanceSquared;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;

public class Pistons extends PhysicsModule {
public class Pistons extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockRedstoneEvent;

public class Redstone extends PhysicsModule {
public class Redstone extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,23 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

public abstract class PhysicsModule extends AEFModule implements Listener {
/**
* Credits to the initial idea of measuring burst activity within a certain region
* of the world go to kumori (Soft1k) of 3b3t.org.
*/
public abstract class RegionalActivityModule extends AEFModule implements Listener {

protected final Cache<BlockRegion2D, RegionData> regionDataCache;
protected final long pauseTimeMillis;
protected final double checkRadius, pauseTPS, pauseMSPT;
protected final boolean logIsEnabled;

public PhysicsModule(
public RegionalActivityModule(
String subConfigPath, boolean deflogEnabled, double defCheckRadius,
int defPauseMillis, int defCacheMillis, double defPauseTPS, double defPauseMSPT
) {
super("lag-preventions.physics."+subConfigPath);
String configPath = "lag-preventions.physics."+subConfigPath;
super("lag-preventions.regional-activity."+subConfigPath);
String configPath = "lag-preventions.regional-activity."+subConfigPath;
this.logIsEnabled = config.getBoolean(configPath + ".log", deflogEnabled);
this.checkRadius = config.getDouble(configPath + ".check-radius-blocks", defCheckRadius,
"The radius in blocks in which activity will be grouped together and measured.");
Expand Down Expand Up @@ -62,7 +66,7 @@ public void disable() {
regionDataCache.invalidateAll();
}

protected @NotNull PhysicsModule.RegionData getRegionData(Location location) {
protected @NotNull RegionalActivityModule.RegionData getRegionData(Location location) {
return regionDataCache.get(getRegion(location), RegionData::new);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class SculkActivity extends PhysicsModule {
public class SculkActivity extends RegionalActivityModule {

private final Set<Material> sculkBlocks;
private final int limit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.SculkBloomEvent;

public class SculkBloom extends PhysicsModule {
public class SculkBloom extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockSpreadEvent;

public class BlockFormOrGrow extends PhysicsModule {
public class BlockFormOrGrow extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockPhysicsEvent;

public class BlockPhysics extends PhysicsModule {
public class BlockPhysics extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.Map;
import java.util.TreeMap;

public class EntityTargeting extends PhysicsModule implements Listener {
public class EntityTargeting extends RegionalActivityModule implements Listener {

private final Map<EntityType, Double> limitedTypes = new EnumMap<>(EntityType.class);
private final double globalMaxDistanceSquared;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;

public class Explosions extends PhysicsModule {
public class Explosions extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockFromToEvent;

public class LiquidSpread extends PhysicsModule {
public class LiquidSpread extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.NotePlayEvent;

public class Noteblocks extends PhysicsModule {
public class Noteblocks extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.Map;
import java.util.TreeMap;

public class Pathfinding extends PhysicsModule implements Listener {
public class Pathfinding extends RegionalActivityModule implements Listener {

private final Map<EntityType, Double> limitedTypes = new EnumMap<>(EntityType.class);
private final double globalMaxDistanceSquared;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;

public class Pistons extends PhysicsModule {
public class Pistons extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockRedstoneEvent;

public class Redstone extends PhysicsModule {
public class Redstone extends RegionalActivityModule {

private final int limit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,23 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

public abstract class PhysicsModule extends AEFModule implements Listener {
/**
* Credits to the initial idea of measuring burst activity within a certain region
* of the world go to kumori (Soft1k) of 3b3t.org.
*/
public abstract class RegionalActivityModule extends AEFModule implements Listener {

protected final Cache<BlockRegion2D, RegionData> regionDataCache;
protected final long pauseTimeMillis;
protected final double checkRadius, pauseTPS, pauseMSPT;
protected final boolean logIsEnabled;

public PhysicsModule(
public RegionalActivityModule(
String subConfigPath, boolean deflogEnabled, double defCheckRadius,
int defPauseMillis, int defCacheMillis, double defPauseTPS, double defPauseMSPT
) {
super("lag-preventions.physics."+subConfigPath);
String configPath = "lag-preventions.physics."+subConfigPath;
super("lag-preventions.regional-activity."+subConfigPath);
String configPath = "lag-preventions.regional-activity."+subConfigPath;
this.logIsEnabled = config.getBoolean(configPath + ".log", deflogEnabled);
this.checkRadius = config.getDouble(configPath + ".check-radius-blocks", defCheckRadius,
"The radius in blocks in which activity will be grouped together and measured.");
Expand Down Expand Up @@ -63,7 +67,7 @@ public void disable() {
}

@SuppressWarnings("DataFlowIssue")
protected @NotNull PhysicsModule.RegionData getRegionData(Location location) {
protected @NotNull RegionalActivityModule.RegionData getRegionData(Location location) {
return regionDataCache.get(getRegion(location), RegionData::new);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class SculkActivity extends PhysicsModule {
public class SculkActivity extends RegionalActivityModule {

private final Set<Material> sculkBlocks;
private final int limit;
Expand Down

0 comments on commit 83c2df3

Please sign in to comment.