Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/RhysB/Project-Poseidon in…
Browse files Browse the repository at this point in the history
…to RhysB-master
  • Loading branch information
notdevcody committed Jun 29, 2024
2 parents 4c12af6 + 3dcd51c commit cd06a6b
Show file tree
Hide file tree
Showing 25 changed files with 697 additions and 85 deletions.
37 changes: 34 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,42 @@
A CraftBukkit CB1060 fork for Beta 1.7.3 fixing bugs and adding basic features.<br>
Discord (Project Poseidon): https://discord.gg/FwKg676

## Features (UberBukkit)

## Features (Poseidon)
- **UUID Support:** Settings to enable UUID-based inventories alongside methods for plugins to transition to UUID-based systems similar to modern Minecraft server implementations.
- **Poseidon Watchdog Implementation:** An automatic utility for detecting server hangs, ending the server process, and providing diagnostics to fix the underlying issues.
- **Packet Events:** Adds packet send and receive events for advanced plugin development without needing Spout or to use Reflections that are incompatible with modern Java versions.
- **Inventory Block Duplication Fixes:** Includes fixes for chest, furnace, inventory block duplication, and Minecart duplication issues.
- **Cross-World Duplication Fix:** Fixes a cross-world duplication glitch.
- **Duplication Glitch Fix:** Fix a bug with the Bukkit chunk cache which allowed users to duplicate and get unobtainable items.
- **Server Crash Fix:** Addresses multiple server crash issues.
- **Connection Pauses:** A powerful feature allowing developers to retrieve information asynchronously before a player connects.
- **Event Handlers:** Modern event handlers backported to facilitating easier coding, plugin backporting, and early release plugin support.
- **Vanish API Backport:** Backports the modern vanish API for easy vanish plugin creation and fixes issues with hacking players seeing vanished players.
- **Logging Enhancements:** Adds an option for daily log file creation and logs player commands to the console, with exceptions for Authme, XAuth, and similar plugins.
- **TPS API and Command:** Adds a TPS command and API for plugins to access historical TPS data.
- **Server Shutdown Improvements:** Enhances server shutdown procedures to ensure world/player data and plugin data are properly saved.
- **Release2Beta Support:** Added support for Release2Beta, including IP Forwarding.
- **Tree Growth Blockage Settings:** Allows server owners to block tree growth from replacing certain blocks to prevent griefing.
- **TCP NoDelay Option:** Improves netcode performance for compatible clients.
- **Ragequit/Ragejoin Fixes:** Prevents ragequit and ragejoin connection/chat spam.
- **Plugin Hiding:** Allows plugins to be hidden from the server list via an attribute in `plugin.yml`.
- **Improve Console Debug:** Make multiple common errors less verbose in the console.
- **Event Handling Improvements:** Ensures primed TNT fires the correct event and backports the explosion event from modern Bukkit.
- **Spawn Location Options:** Provides options to disable spawn location randomization and teleportation to the highest safe block on join.
- **Configurable Mob Spawner Area Limit:** Allows server owners to set a mob-cap for mob spawners to prevent mob farms from causing extreme lag.

## Want to use UberBukkit on your server?
Please read the following article before changing over to UberBukkit (From Project-Poseidon): https://github.com/RhysB/Project-Poseidon/wiki/Implementing-Project-Poseidon-In-Production

# Download
You can download the latest build [here](https://betacraft.uk/utilities).
## Releases
You can download the latest GitHub release [here](https://github.com/Moresteck/Project-Poseidon-Uberbukkit/releases/latest)

## Snapshots
You can download the latest build through [GitHub actions](https://github.com/Moresteck/Project-Poseidon-Uberbukkit/actions/workflows/build-and-test.yaml) (You need to be logged into GitHub)
or get it from [betacraft.uk](https://betacraft.uk/utilities) along with pre-made configuration files.

## Licensing
CraftBukkit and Bukkit are licensed under GNU General Public License v3.0<br>
Expand Down Expand Up @@ -47,5 +78,5 @@ We include files from the mc-dev GitHub repository. This code is automatically g

If Mojang Studios or someone on their behalf wants to have this repository removed due to including copyrighted Minecraft sources like bukkit/mc-dev, please contact me or make an issue.

## How to setup ModLoaderMP support (NOT WORKING)
Please read the following: https://github.com/RhysB/Project-Poseidon/wiki/Adding-ModLoaderMP
## How to setup ModLoaderMP support (NOT WORKING)
Please read the following: https://github.com/RhysB/Project-Poseidon/wiki/Adding-ModLoaderMP
39 changes: 34 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,50 @@
<id>bukkit-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
</repository>
<repository>
<id>chew-jenkins</id>
<url>https://jenkins.chew.pw/plugin/repository/everything</url>
</repository>
<!-- <repository>-->
<!-- <id>chew-jenkins</id>-->
<!-- <url>https://jenkins.chew.pw/plugin/repository/everything</url>-->
<!-- </repository>-->
<repository>
<id>jline</id>
<name>JLine Project Repository</name>
<url>http://jline.sourceforge.net/m2repo</url>
</repository>
<!-- Repository for resolving release dependencies -->
<repository>
<id>johnymuffin-nexus-releases</id>
<url>https://repository.johnymuffin.com/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- Repository for resolving snapshot dependencies -->
<repository>
<id>johnymuffin-nexus-snapshots</id>
<url>https://repository.johnymuffin.com/repository/maven-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<!-- <dependency>-->
<!-- <groupId>org.bukkit</groupId>-->
<!-- <artifactId>bukkit</artifactId>-->
<!-- <version>0.0.1-SNAPSHOT</version>-->
<!-- <type>jar</type>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.1-POSEIDON</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/com/legacyminecraft/poseidon/Poseidon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.legacyminecraft.poseidon;

import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.CraftServer;

import java.util.LinkedList;

public class Poseidon {

/**
* Returns a list of the server's TPS (Ticks Per Second) records for performance monitoring.
* The list contains Double values indicating the TPS at each second, ordered from most recent to oldest.
*
* @return LinkedList<Double> of TPS records.
*/
public static LinkedList<Double> getTpsRecords() {
return ((CraftServer) Bukkit.getServer()).getServer().getTpsRecords();
}


}
124 changes: 110 additions & 14 deletions src/main/java/com/legacyminecraft/poseidon/PoseidonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class PoseidonConfig extends Configuration {
private static PoseidonConfig singleton;
private final int configVersion = 3;
private final int configVersion = 5;
private Integer[] treeBlacklistIDs;

public Integer[] getTreeBlacklistIDs() {
Expand All @@ -24,6 +24,7 @@ private PoseidonConfig() {
public void reload() {
this.load();
this.write();
this.validation();
this.save();
}

Expand All @@ -36,28 +37,58 @@ public void resetConfig() {
this.write();
}

private void validation() {
//Confirm settings.uuid-fetcher.method.value is either POST or GET
if (!this.getConfigString("settings.uuid-fetcher.method.value").equalsIgnoreCase("POST") && !this.getConfigString("settings.uuid-fetcher.method.value").equalsIgnoreCase("GET")) {
System.out.println("[Poseidon] Config: settings.uuid-fetcher.method.value is not POST or GET. Changing to POST.");
this.setProperty("settings.uuid-fetcher.method.value", "POST");
}
}

private void write() {
if (this.getString("config-version") == null || Integer.valueOf(this.getString("config-version")) < configVersion) {
System.out.println("Converting to Config Version: " + configVersion);
System.out.println("[Poseidon] Converting from config version " + (this.getString("config-version") == null ? "0" : this.getString("config-version")) + " to " + configVersion);
convertToNewConfig();
this.setProperty("config-version", configVersion);
}
//Main
generateConfigOption("config-version", 3);
generateConfigOption("config-version", configVersion);
//Setting
generateConfigOption("settings.allow-graceful-uuids", true);
generateConfigOption("settings.uuids-source-port", -1);
// generateConfigOption("settings.allow-graceful-uuids", true);
generateConfigOption("settings.delete-duplicate-uuids", false);
generateConfigOption("settings.save-playerdata-by-uuid", true);
generateConfigOption("settings.per-day-logfile", false);
generateConfigOption("settings.fetch-uuids-from", "https://api.mojang.com/profiles/minecraft");
// Log management and rotation
generateConfigOption("settings.per-day-log-file.info", "This setting causes the server to create a new log file each day. This is useful for log rotation and log file management.");
generateConfigOption("settings.per-day-log-file.enabled", false);
generateConfigOption("settings.per-day-log-file.latest-log.info", "This setting causes the server to create a latest.log similar to modern Minecraft servers. This can be useful for certain control panels and log file management.");
generateConfigOption("settings.per-day-log-file.latest-log.enabled", true);

//generateConfigOption("settings.fetch-uuids-from", "https://api.mojang.com/profiles/minecraft");

// UUID Fetcher Settings
generateConfigOption("settings.uuid-fetcher.post.info", "This setting allows you to change the URL that the server fetches UUIDs from. This is useful if you have a custom UUID server or a proxy server that fetches UUIDs.");
generateConfigOption("settings.uuid-fetcher.post.value", "https://api.minecraftservices.com/minecraft/profile/lookup/bulk/byname");

generateConfigOption("settings.uuid-fetcher.get.info", "This setting allows you to change the URL that the server fetches UUIDs from. This is useful if you have a custom UUID server or a proxy server that fetches UUIDs.");
generateConfigOption("settings.uuid-fetcher.get.value", "https://api.minecraftservices.com/minecraft/profile/lookup/name/{username}");
generateConfigOption("settings.uuid-fetcher.get.enforce-case-sensitivity.enabled", true);
generateConfigOption("settings.uuid-fetcher.get.enforce-case-sensitivity.info", "The Mojang API is case-insensitive by default meaning usernames with different casing will return the same UUID. This setting checks the case of the username to prevent this issue. If the name is invalid, the player will be kicked.");


generateConfigOption("settings.uuid-fetcher.method.value", "POST");
generateConfigOption("settings.uuid-fetcher.method.info", "This setting allows for POST or GET method for fetching UUIDs. This is useful if you have a custom UUID server, Mojang API is down, or a proxy server that fetches UUIDs.");

generateConfigOption("settings.uuid-fetcher.allow-graceful-uuids.value", true);
generateConfigOption("settings.uuid-fetcher.allow-graceful-uuids.info", "This setting means offline UUIDs are generated for players who don't have a Mojang UUID. This is useful for cracked or semi-cracked servers.");

generateConfigOption("settings.remove-join-leave-debug", true);
generateConfigOption("settings.enable-tpc-nodelay", false);

generateConfigOption("settings.use-get-for-uuids.enabled", true);
generateConfigOption("settings.use-get-for-uuids.info", "This setting causes the server to use the GET method for Username to UUID conversion. This is useful incase the POST method goes offline.");
//generateConfigOption("settings.use-get-for-uuids.enabled", true);
//generateConfigOption("settings.use-get-for-uuids.info", "This setting causes the server to use the GET method for Username to UUID conversion. This is useful incase the POST method goes offline.");

generateConfigOption("settings.use-get-for-uuids.case-sensitive.enabled", true);
generateConfigOption("settings.use-get-for-uuids.case-sensitive.info", "This setting will verify sensitivity of the username as the GET method is case-insensitive.");
//generateConfigOption("settings.use-get-for-uuids.case-sensitive.enabled", true);
//generateConfigOption("settings.use-get-for-uuids.case-sensitive.info", "This setting will verify sensitivity of the username as the GET method is case-insensitive.");

generateConfigOption("settings.faster-packets.enabled", true);
generateConfigOption("settings.faster-packets.info", "This setting increases the speed of packets, a fix from newer Minecraft versions.");
Expand Down Expand Up @@ -109,6 +140,14 @@ private void write() {
generateConfigOption("world.settings.speed-hack-check.teleport", true);
generateConfigOption("world.settings.speed-hack-check.distance", 100.0D);
generateConfigOption("world.settings.speed-hack-check.info", "This setting allows you to configure the automatic speedhack detection.");
//Mob Spawner Area Limit (8 chunks)
generateConfigOption("world.settings.mob-spawner-area-limit.enable", true);
generateConfigOption("world.settings.mob-spawner-area-limit.limit", 150);
generateConfigOption("world.settings.mob-spawner-area-limit.chunk-radius", 8);
generateConfigOption("world.settings.mob-spawner-area-limit.info",
"This setting controls the maximum number of entities of a mob spawner type that can exist within the defined chunk radius around a mob spawner. If the number of entities exceeds this limit, the spawner will stop spawning additional entities of that type. This is useful to stop the extreme lag that can be caused by mob spawners.");


//generateConfigOption("world-settings.eject-from-vehicle-on-teleport.enabled", true);
//generateConfigOption("world-settings.eject-from-vehicle-on-teleport.info", "Eject the player from a boat or minecart before teleporting them preventing cross world coordinate exploits.");

Expand Down Expand Up @@ -210,6 +249,11 @@ private void write() {
generateConfigOption("message.player.join", "\u00A7e%player% joined the game.");
generateConfigOption("message.player.leave", "\u00A7e%player% left the game.");

//Optional Poseidon Commands
generateConfigOption("command.info", "This section allows you to enable or disable optional Poseidon commands. This is useful if you have a plugin that conflicts with a Poseidon command.");
generateConfigOption("command.tps.info", "Enables the /tps command to show the server's TPS for various intervals.");
generateConfigOption("command.tps.enabled", true);

//Tree Leave Destroy Blacklist
if (Boolean.valueOf(String.valueOf(getConfigOption("world.settings.block-tree-growth.enabled", true)))) {
if (String.valueOf(this.getConfigOption("world.settings.block-tree-growth.list", "")).trim().isEmpty()) {
Expand Down Expand Up @@ -284,25 +328,77 @@ public Boolean getConfigBoolean(String key) {
return Boolean.valueOf(getConfigString(key));
}

public Boolean getConfigBoolean(String key, Boolean defaultValue) {
Boolean value = getConfigBoolean(key);
if (value == null) {
System.out.println("[Poseidon] Config: " + key + " does not exist. Using default value: " + defaultValue);
System.out.println("[Poseidon] Config: This is likely the result of an error. Please report this to the developer.");
value = defaultValue;
}
return value;
}

//Getters End

private void convertToNewConfig() {
//Graceful UUIDS
// 1- 2/3 Conversion
convertToNewAddress("settings.statistics.enabled", "settings.enable-statistics");
convertToNewAddress("settings.allow-graceful-uuids", "allowGracefulUUID");
convertToNewAddress("settings.save-playerdata-by-uuid", "savePlayerdataByUUID");
convertToNewAddress("settings.watchdog.enable", "settings.enable-watchdog");
// 3-4 Conversion

// Don't automatically enable the latest log file for servers that have the per-day-logfile setting enabled as this is a change in behavior
if (this.getString("settings.per-day-logfile") != null && this.getConfigBoolean("settings.per-day-logfile")) {
this.setProperty("settings.per-day-log-file.latest-log.enabled", false);
}
convertToNewAddress("settings.per-day-log-file.enabled", "settings.per-day-logfile");

// 4-5 Conversion
convertToNewAddress("settings.uuid-fetcher.post.value", "settings.fetch-uuids-from");
if (this.getString("settings.uuid-fetcher.post.value", "https://api.minecraftservices.com/minecraft/profile/lookup/bulk/byname").equals("https://api.mojang.com/profiles/minecraft")) {
System.out.println("[Poseidon] Config: settings.fetch-uuids-from is set to the default value (" + this.getString("settings.uuid-fetcher.post.value") + "). Changing to the new default value (https://api.minecraftservices.com/minecraft/profile/lookup/bulk/byname)");
this.setProperty("settings.uuid-fetcher.post.value", "https://api.minecraftservices.com/minecraft/profile/lookup/bulk/byname");
}

boolean usePost = !this.getConfigBoolean("settings.use-get-for-uuids.enabled", false); // Is the server currently using POST?
if (usePost) {
this.setProperty("settings.uuid-fetcher.method.value", "POST");
} else {
this.setProperty("settings.uuid-fetcher.method.value", "GET");
}

removeDeprecatedConfig("settings.use-get-for-uuids.enabled", "settings.use-get-for-uuids.info");

convertToNewAddress("settings.uuid-fetcher.allow-graceful-uuids.value", "settings.allow-graceful-uuids");
convertToNewAddress("settings.uuid-fetcher.get.enforce-case-sensitivity.enabled", "settings.use-get-for-uuids.case-sensitive.enabled");
removeDeprecatedConfig("settings.use-get-for-uuids.case-sensitive.info");


convertToNewAddress("settings.enable-watchdog", "settings.watchdog.enable");
}

//Allow any number of string arguments to be passed to this method
private boolean removeDeprecatedConfig(String... keys) {
boolean removed = false;
for (String key : keys) {
if (this.getString(key) != null) {
System.out.println("[Poseidon] Config: " + key + " is deprecated. Removing.");
this.removeProperty(key);
removed = true;
}
}
return removed;
}

private boolean convertToNewAddress(String newKey, String oldKey) {
if (this.getString(newKey) != null) {
return false;
}
if (this.getString(oldKey) == null) {
System.out.println("[Poseidon] Config: " + oldKey + " does not exist. Skipping conversion.");
return false;
}
System.out.println("Converting Config: " + oldKey + " to " + newKey);
System.out.println("[Poseidon] Converting Config: " + oldKey + " to " + newKey);
Object value = this.getProperty(oldKey);
this.setProperty(newKey, value);
this.removeProperty(oldKey);
Expand Down
Loading

0 comments on commit cd06a6b

Please sign in to comment.