Expand or hide or ideally both
This commit is contained in:
parent
b23f773198
commit
6f0dae932b
6 changed files with 123 additions and 66 deletions
|
@ -10,6 +10,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public record TweaksConfig(
|
public record TweaksConfig(
|
||||||
|
boolean worldborderExpand,
|
||||||
boolean worldborderHide,
|
boolean worldborderHide,
|
||||||
|
|
||||||
boolean brandEnabled,
|
boolean brandEnabled,
|
||||||
|
@ -64,7 +65,8 @@ public record TweaksConfig(
|
||||||
throw new RuntimeException("Did you downgrade the plugin? Remove config.yml and let the plugin re-create it", exception);
|
throw new RuntimeException("Did you downgrade the plugin? Remove config.yml and let the plugin re-create it", exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hideWorldBorder = config.getBoolean("worldborder.hide");
|
boolean worldborderExpand = config.getBoolean("worldborder.expand");
|
||||||
|
boolean worldborderHide = config.getBoolean("worldborder.hide");
|
||||||
|
|
||||||
boolean brandEnabled = config.getBoolean("brand.enabled");
|
boolean brandEnabled = config.getBoolean("brand.enabled");
|
||||||
String brandText = config.getString("brand.text");
|
String brandText = config.getString("brand.text");
|
||||||
|
@ -98,7 +100,7 @@ public record TweaksConfig(
|
||||||
boolean sleepInstant = config.getBoolean("sleep.instant");
|
boolean sleepInstant = config.getBoolean("sleep.instant");
|
||||||
|
|
||||||
TweaksConfig.config = new TweaksConfig(
|
TweaksConfig.config = new TweaksConfig(
|
||||||
hideWorldBorder,
|
worldborderExpand, worldborderHide,
|
||||||
brandEnabled, brandText, brandShowPing, brandShowMspt,
|
brandEnabled, brandText, brandShowPing, brandShowMspt,
|
||||||
doorEnabled, doorDoubleOpen, doorKnocking,
|
doorEnabled, doorDoubleOpen, doorKnocking,
|
||||||
motdEnabled, motdSet,
|
motdEnabled, motdSet,
|
||||||
|
|
|
@ -33,6 +33,9 @@ public class TweaksPlugin extends JavaPlugin {
|
||||||
TweaksConfig config = TweaksConfig.load(this);
|
TweaksConfig config = TweaksConfig.load(this);
|
||||||
new Language(Locale.US); // TODO
|
new Language(Locale.US); // TODO
|
||||||
|
|
||||||
|
// whether enabled is handled inside
|
||||||
|
new WorldBorderManager().init(this);
|
||||||
|
|
||||||
if (config.chatEnabled()) {
|
if (config.chatEnabled()) {
|
||||||
ChatManager chatManager = new ChatManager(this);
|
ChatManager chatManager = new ChatManager(this);
|
||||||
chatManager.init();
|
chatManager.init();
|
||||||
|
@ -68,10 +71,6 @@ public class TweaksPlugin extends JavaPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.worldborderHide()) {
|
|
||||||
new WorldBorderManager().init(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.pomodoroEnabled()) {
|
if (config.pomodoroEnabled()) {
|
||||||
new PomodoroManager(this).init();
|
new PomodoroManager(this).init();
|
||||||
getCommand("pomodoro").setExecutor(new PomodoroCommands());
|
getCommand("pomodoro").setExecutor(new PomodoroCommands());
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Minecon724
|
||||||
|
* Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file
|
||||||
|
* in the project root for the full license text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package eu.m724.tweaks.worldborder;
|
||||||
|
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import org.bukkit.craftbukkit.v1_21_R1.CraftWorld;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
|
|
||||||
|
public class WorldBorderExpanderListener implements Listener {
|
||||||
|
@EventHandler
|
||||||
|
public void onWorldLoad(WorldLoadEvent event) {
|
||||||
|
ServerLevel level = ((CraftWorld) event.getWorld()).getHandle();
|
||||||
|
|
||||||
|
level.getWorldBorder().setAbsoluteMaxSize(30000000);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2024 Minecon724
|
||||||
|
* Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file
|
||||||
|
* in the project root for the full license text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package eu.m724.tweaks.worldborder;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.events.ListenerPriority;
|
||||||
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
public class WorldBorderHider {
|
||||||
|
private static final int EXTENSION_RADIUS = 512;
|
||||||
|
|
||||||
|
public void init(Plugin plugin) {
|
||||||
|
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "tweaks724:worldborder");
|
||||||
|
byte[] infoArray = ByteBuffer.allocate(4).putInt(EXTENSION_RADIUS).array();
|
||||||
|
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(
|
||||||
|
plugin,
|
||||||
|
ListenerPriority.NORMAL,
|
||||||
|
PacketType.Play.Server.INITIALIZE_BORDER
|
||||||
|
) {
|
||||||
|
@Override
|
||||||
|
public void onPacketSending(PacketEvent event) {
|
||||||
|
PacketContainer packet = event.getPacket();
|
||||||
|
// old diameter
|
||||||
|
packet.getDoubles().write(2, packet.getDoubles().read(2) + EXTENSION_RADIUS * 2);
|
||||||
|
// new diameter
|
||||||
|
packet.getDoubles().write(3, packet.getDoubles().read(3) + EXTENSION_RADIUS * 2);
|
||||||
|
|
||||||
|
// border radius
|
||||||
|
packet.getIntegers().write(0, packet.getIntegers().read(0) + EXTENSION_RADIUS);
|
||||||
|
// warning distance
|
||||||
|
packet.getIntegers().write(1, packet.getIntegers().read(1) + EXTENSION_RADIUS);
|
||||||
|
|
||||||
|
event.getPlayer().sendPluginMessage(plugin, "tweaks724:worldborder", infoArray);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(
|
||||||
|
plugin,
|
||||||
|
ListenerPriority.NORMAL,
|
||||||
|
PacketType.Play.Server.SET_BORDER_SIZE
|
||||||
|
) {
|
||||||
|
@Override
|
||||||
|
public void onPacketSending(PacketEvent event) {
|
||||||
|
PacketContainer packet = event.getPacket();
|
||||||
|
// diameter
|
||||||
|
packet.getDoubles().write(0, packet.getDoubles().read(0) + EXTENSION_RADIUS * 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(
|
||||||
|
plugin,
|
||||||
|
ListenerPriority.NORMAL,
|
||||||
|
PacketType.Play.Server.SET_BORDER_WARNING_DISTANCE
|
||||||
|
) {
|
||||||
|
@Override
|
||||||
|
public void onPacketSending(PacketEvent event) {
|
||||||
|
PacketContainer packet = event.getPacket();
|
||||||
|
// warning distance
|
||||||
|
packet.getIntegers().write(0, packet.getIntegers().read(0) + EXTENSION_RADIUS);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,69 +6,24 @@
|
||||||
|
|
||||||
package eu.m724.tweaks.worldborder;
|
package eu.m724.tweaks.worldborder;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import eu.m724.tweaks.TweaksConfig;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
import com.comphenix.protocol.events.ListenerPriority;
|
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
|
|
||||||
public class WorldBorderManager {
|
public class WorldBorderManager {
|
||||||
private static final int EXTENSION_RADIUS = 512;
|
|
||||||
|
|
||||||
public void init(Plugin plugin) {
|
public void init(Plugin plugin) {
|
||||||
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "tweaks724:worldborder");
|
if (TweaksConfig.getConfig().worldborderExpand()) {
|
||||||
byte[] infoArray = ByteBuffer.allocate(4).putInt(EXTENSION_RADIUS).array();
|
WorldBorderExpanderListener wbrl = new WorldBorderExpanderListener();
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(wbrl, plugin);
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(
|
// because the plugin loads "post world"
|
||||||
plugin,
|
plugin.getServer().getWorlds().forEach(w -> {
|
||||||
ListenerPriority.NORMAL,
|
wbrl.onWorldLoad(new WorldLoadEvent(w));
|
||||||
PacketType.Play.Server.INITIALIZE_BORDER
|
});
|
||||||
) {
|
}
|
||||||
@Override
|
|
||||||
public void onPacketSending(PacketEvent event) {
|
|
||||||
PacketContainer packet = event.getPacket();
|
|
||||||
// old diameter
|
|
||||||
packet.getDoubles().write(2, packet.getDoubles().read(2) + EXTENSION_RADIUS * 2);
|
|
||||||
// new diameter
|
|
||||||
packet.getDoubles().write(3, packet.getDoubles().read(3) + EXTENSION_RADIUS * 2);
|
|
||||||
|
|
||||||
// border radius
|
if (TweaksConfig.getConfig().worldborderHide()) {
|
||||||
// packet.getIntegers().write(0, packet.getIntegers().read(0) + EXTENSION_RADIUS);
|
new WorldBorderHider().init(plugin);
|
||||||
// warning distance
|
}
|
||||||
packet.getIntegers().write(1, packet.getIntegers().read(1) + EXTENSION_RADIUS);
|
|
||||||
|
|
||||||
event.getPlayer().sendPluginMessage(plugin, "tweaks724:worldborder", infoArray);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(
|
|
||||||
plugin,
|
|
||||||
ListenerPriority.NORMAL,
|
|
||||||
PacketType.Play.Server.SET_BORDER_SIZE
|
|
||||||
) {
|
|
||||||
@Override
|
|
||||||
public void onPacketSending(PacketEvent event) {
|
|
||||||
PacketContainer packet = event.getPacket();
|
|
||||||
// diameter
|
|
||||||
packet.getDoubles().write(0, packet.getDoubles().read(0) + EXTENSION_RADIUS * 2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(
|
|
||||||
plugin,
|
|
||||||
ListenerPriority.NORMAL,
|
|
||||||
PacketType.Play.Server.SET_BORDER_WARNING_DISTANCE
|
|
||||||
) {
|
|
||||||
@Override
|
|
||||||
public void onPacketSending(PacketEvent event) {
|
|
||||||
PacketContainer packet = event.getPacket();
|
|
||||||
// warning distance
|
|
||||||
packet.getIntegers().write(0, packet.getIntegers().read(0) + EXTENSION_RADIUS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,15 @@
|
||||||
# - https://discord.gg/86X4Z5JUeq
|
# - https://discord.gg/86X4Z5JUeq
|
||||||
# - https://www.spigotmc.org/threads/tweaks724.670906/
|
# - https://www.spigotmc.org/threads/tweaks724.670906/
|
||||||
|
|
||||||
|
# Warning: Don't use /worldborder while this is on
|
||||||
worldborder:
|
worldborder:
|
||||||
# Hides the world border at 30 mil
|
# Expands the worldborder to 30,000,000
|
||||||
|
# It's not possible to go beyond that without client and server mods. (Though I have a prototype)
|
||||||
|
# Enjoy 307,199,918,080 more usable blocks
|
||||||
|
expand: true
|
||||||
|
# Hides the world border
|
||||||
# Client side so it won't make the world bigger or anything
|
# Client side so it won't make the world bigger or anything
|
||||||
# Warning: Don't use /worldborder while this is on
|
# Also enable expand if you don't want to glitch at 29,999,984. (this is because you can only go beyond with a pearl)
|
||||||
hide: true
|
hide: true
|
||||||
|
|
||||||
# "Server brand" (second line of F3)
|
# "Server brand" (second line of F3)
|
||||||
|
|
Loading…
Reference in a new issue