Skip to content

Commit

Permalink
Modification of PacketEvents settings is now marked as internal API b…
Browse files Browse the repository at this point in the history
…ehavior. Generally, you are not advised to change the settings.

Unnecessary static in PacketEventsAPI fixed.
  • Loading branch information
retrooper committed Jul 19, 2024
1 parent 4524b42 commit 7dd2434
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@
import java.util.logging.Logger;

public abstract class PacketEventsAPI<T> {
private static final EventManager EVENT_MANAGER = new EventManager();
private static final PacketEventsSettings SETTINGS = new PacketEventsSettings();
private static final UpdateChecker UPDATE_CHECKER = new UpdateChecker();
private static final LogManager LOG_MANAGER = new LogManager();
private final EventManager eventManager = new EventManager();
private final PacketEventsSettings settings = new PacketEventsSettings();
private final UpdateChecker updateChecker = new UpdateChecker();
private final LogManager logManager = new LogManager();
private static final Logger LOGGER = Logger.getLogger(PacketEventsAPI.class.getName());

public EventManager getEventManager() {
return EVENT_MANAGER;
return eventManager;
}

public PacketEventsSettings getSettings() {
return SETTINGS;
return settings;
}

public UpdateChecker getUpdateChecker() {
return UPDATE_CHECKER;
return updateChecker;
}

public PEVersion getVersion() {
Expand All @@ -62,7 +62,7 @@ public Logger getLogger() {
}

public LogManager getLogManager() {
return LOG_MANAGER;
return logManager;
}

public abstract void load();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.github.retrooper.packetevents.settings;

import com.github.retrooper.packetevents.util.TimeStampMode;
import org.jetbrains.annotations.ApiStatus;

import java.io.InputStream;
import java.util.function.Function;
Expand All @@ -44,27 +45,23 @@ public class PacketEventsSettings {

/**
* Time stamp mode. How precise should the timestamps in the events be.
*
* @param timeStampMode Time Stamp mode
* @return Settings instance
*/
@ApiStatus.Internal
public PacketEventsSettings timeStampMode(TimeStampMode timeStampMode) {
this.timestampMode = timeStampMode;
return this;
}

/**
* Get the timestamp mode
* @return Time Stamp Mode
*/
public TimeStampMode getTimeStampMode() {
return timestampMode;
}

/**
* Do we re-encode all packets by default?
*
* @param reEncodeByDefault Value
* @return Settings instance
*/
@ApiStatus.Internal
public PacketEventsSettings reEncodeByDefault(boolean reEncodeByDefault) {
this.defaultReencode = reEncodeByDefault;
return this;
Expand All @@ -76,6 +73,7 @@ public PacketEventsSettings reEncodeByDefault(boolean reEncodeByDefault) {
* @param checkForUpdates Value
* @return Settings instance.
*/
@ApiStatus.Internal
public PacketEventsSettings checkForUpdates(boolean checkForUpdates) {
this.checkForUpdates = checkForUpdates;
return this;
Expand All @@ -87,13 +85,14 @@ public PacketEventsSettings checkForUpdates(boolean checkForUpdates) {
* @param downsampleColors Value
* @return Settings instance.
*/
@ApiStatus.Internal
public PacketEventsSettings downsampleColors(boolean downsampleColors) {
this.downsampleColors = downsampleColors;
return this;
}

/**
* This decides if PacketEvents should collect data anonymously and report to bStats.
* This used to decide if PacketEvents should collect data anonymously and report to bStats.
*
* @param bStatsEnabled Value
* @return Settings instance.
Expand All @@ -110,6 +109,7 @@ public PacketEventsSettings bStats(boolean bStatsEnabled) {
* @param debugEnabled Value
* @return Settings instance.
*/
@ApiStatus.Internal
public PacketEventsSettings debug(boolean debugEnabled) {
this.debugEnabled = debugEnabled;
return this;
Expand All @@ -121,6 +121,7 @@ public PacketEventsSettings debug(boolean debugEnabled) {
* @param fullStackTraceEnabled Value
* @return Settings instance.
*/
@ApiStatus.Internal
public PacketEventsSettings fullStackTrace(boolean fullStackTraceEnabled) {
this.fullStackTraceEnabled = fullStackTraceEnabled;
return this;
Expand All @@ -132,6 +133,7 @@ public PacketEventsSettings fullStackTrace(boolean fullStackTraceEnabled) {
* @param kickOnPacketExceptionEnabled Value
* @return Settings instance.
*/
@ApiStatus.Internal
public PacketEventsSettings kickOnPacketException(boolean kickOnPacketExceptionEnabled) {
this.kickOnPacketExceptionEnabled = kickOnPacketExceptionEnabled;
return this;
Expand All @@ -144,13 +146,15 @@ public PacketEventsSettings kickOnPacketException(boolean kickOnPacketExceptionE
* @param resourceProvider Function
* @return Settings instance.
*/
@ApiStatus.Internal
public PacketEventsSettings customResourceProvider(Function<String, InputStream> resourceProvider) {
this.resourceProvider = resourceProvider;
return this;
}

/**
* Should the packet listeners be read only?
*
* @return Getter for {@link #defaultReencode}
*/
public boolean reEncodeByDefault() {
Expand Down Expand Up @@ -218,9 +222,19 @@ public boolean isKickOnPacketExceptionEnabled() {
/**
* As described above, this method retrieves the function that acquires the InputStream
* of a desired resource by its path.
*
* @return Getter for {@link #resourceProvider}
*/
public Function<String, InputStream> getResourceProvider() {
return resourceProvider;
}

/**
* Get the timestamp mode
*
* @return Time Stamp Mode
*/
public TimeStampMode getTimeStampMode() {
return timestampMode;
}
}

0 comments on commit 7dd2434

Please sign in to comment.