Compare commits

..

No commits in common. "e59b95e2ef4e11dae173ed8c96546a760faf1d3f" and "81fa6440a0bde25812ea55a971875e1371dbf70c" have entirely different histories.

8 changed files with 22 additions and 126 deletions

View file

@ -66,8 +66,6 @@ Sleeping doesn't skip night, but speeds it up. The more players, the faster it g
One can instantly skip, but only a part of the night. \ One can instantly skip, but only a part of the night. \
There's 5 players on the server. A night is 10 minutes long. \ There's 5 players on the server. A night is 10 minutes long. \
Each player can instantly skip 2 minutes of the night at any time, even if others aren't sleeping Each player can instantly skip 2 minutes of the night at any time, even if others aren't sleeping
- Heal \
Sleeping heals
### Authentication ### Authentication
Players are given a unique subdomain like "\<key>.example.com" and they must use it to join \ Players are given a unique subdomain like "\<key>.example.com" and they must use it to join \
@ -94,9 +92,6 @@ Control knockback dealt by entities
Quickly kills (terminates) the server on trigger, via command or HTTP request. Quickly kills (terminates) the server on trigger, via command or HTTP request.
[KILLSWITCH.md for more info](/Minecon724/tweaks724/src/branch/master/docs/KILLSWITCH.md) [KILLSWITCH.md for more info](/Minecon724/tweaks724/src/branch/master/docs/KILLSWITCH.md)
### Swing through grass
### Utility commands ### Utility commands

View file

@ -167,7 +167,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.21.1-R0.1-SNAPSHOT</version> <version>${project.spigot.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View file

@ -49,7 +49,6 @@ public record TweaksConfig(
boolean sleepEnabled, boolean sleepEnabled,
boolean sleepInstant, boolean sleepInstant,
double sleepHeal,
boolean authEnabled, boolean authEnabled,
boolean authForce, boolean authForce,
@ -61,9 +60,7 @@ public record TweaksConfig(
Map<String, Object> knockbackModifiers, Map<String, Object> knockbackModifiers,
boolean killswitchEnabled, boolean killswitchEnabled,
String killswitchListen, String killswitchListen
boolean swingEnabled
) { ) {
public static final int CONFIG_VERSION = 2; public static final int CONFIG_VERSION = 2;
private static TweaksConfig config; private static TweaksConfig config;
@ -124,7 +121,6 @@ public record TweaksConfig(
boolean sleepEnabled = config.getBoolean("sleep.enabled"); boolean sleepEnabled = config.getBoolean("sleep.enabled");
boolean sleepInstant = config.getBoolean("sleep.instant"); boolean sleepInstant = config.getBoolean("sleep.instant");
double sleepHeal = config.getDouble("sleep.heal");
boolean authEnabled = config.getBoolean("auth.enabled"); boolean authEnabled = config.getBoolean("auth.enabled");
boolean authForce = config.getBoolean("auth.force"); boolean authForce = config.getBoolean("auth.force");
@ -139,8 +135,6 @@ public record TweaksConfig(
boolean killswitchEnabled = config.getBoolean("killswitch.enabled"); boolean killswitchEnabled = config.getBoolean("killswitch.enabled");
String killswitchListen = config.getString("killswitch.listen"); String killswitchListen = config.getString("killswitch.listen");
boolean swingEnabled = config.getBoolean("swing.enabled");
TweaksConfig.config = new TweaksConfig( TweaksConfig.config = new TweaksConfig(
debug, metrics, locale, debug, metrics, locale,
worldborderExpand, worldborderHide, worldborderExpand, worldborderHide,
@ -152,12 +146,11 @@ public record TweaksConfig(
pomodoroEnabled, pomodoroForce, pomodoroEnabled, pomodoroForce,
updaterEnabled, updaterEnabled,
hardcoreEnabled, hardcoreChance, hardcoreEnabled, hardcoreChance,
sleepEnabled, sleepInstant, sleepHeal, sleepEnabled, sleepInstant,
authEnabled, authForce, authHostname, authEnabled, authForce, authHostname,
redstoneEnabled, redstoneListen, redstoneEnabled, redstoneListen,
knockbackModifiers, knockbackModifiers,
killswitchEnabled, killswitchListen, killswitchEnabled, killswitchListen
swingEnabled
); );
return TweaksConfig.config; return TweaksConfig.config;

View file

@ -22,7 +22,6 @@ import eu.m724.tweaks.ping.PingChecker;
import eu.m724.tweaks.pomodoro.PomodoroManager; import eu.m724.tweaks.pomodoro.PomodoroManager;
import eu.m724.tweaks.redstone.RedstoneManager; import eu.m724.tweaks.redstone.RedstoneManager;
import eu.m724.tweaks.sleep.SleepManager; import eu.m724.tweaks.sleep.SleepManager;
import eu.m724.tweaks.swing.SwingManager;
import eu.m724.tweaks.updater.UpdaterManager; import eu.m724.tweaks.updater.UpdaterManager;
import eu.m724.tweaks.worldborder.WorldBorderExpander; import eu.m724.tweaks.worldborder.WorldBorderExpander;
import eu.m724.tweaks.worldborder.WorldBorderHider; import eu.m724.tweaks.worldborder.WorldBorderHider;
@ -136,11 +135,6 @@ public class TweaksPlugin extends MStatsPlugin {
new KillswitchManager(this).init(getCommand("servkill")); new KillswitchManager(this).init(getCommand("servkill"));
} }
if (config.swingEnabled()) {
DebugLogger.fine("Enabling Swing");
new SwingManager(this).init();
}
/* end modules */ /* end modules */
if (config.metrics()) { if (config.metrics()) {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2025 Minecon724 * Copyright (C) 2024 Minecon724
* Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file * Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file
* in the project root for the full license text. * in the project root for the full license text.
*/ */
@ -13,13 +13,12 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityKnockbackByEntityEvent; import org.bukkit.event.entity.EntityKnockbackByEntityEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class KnockbackListener implements Listener { public class KnockbackListener implements Listener {
private final Map<EntityType, Vector> modifiers = new HashMap<>(); private final Map<EntityType, Double> modifiers = new HashMap<>();
public KnockbackListener(Plugin plugin) { public KnockbackListener(Plugin plugin) {
TweaksConfig.getConfig().knockbackModifiers().forEach((k, v) -> { TweaksConfig.getConfig().knockbackModifiers().forEach((k, v) -> {
@ -46,7 +45,7 @@ public class KnockbackListener implements Listener {
} }
if (mod == 1) return; if (mod == 1) return;
modifiers.put(type, new Vector(mod, mod >= 1 ? mod : 1, mod)); // don't touch vertical modifiers.put(type, mod);
}); });
if (!modifiers.isEmpty()) if (!modifiers.isEmpty())

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2025 Minecon724 * Copyright (C) 2024 Minecon724
* Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file * Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file
* in the project root for the full license text. * in the project root for the full license text.
*/ */
@ -21,7 +21,6 @@ import java.util.Set;
public class SleepListener implements Listener { public class SleepListener implements Listener {
private final boolean instant = TweaksConfig.getConfig().sleepInstant(); private final boolean instant = TweaksConfig.getConfig().sleepInstant();
private final double heal = TweaksConfig.getConfig().sleepHeal() * 2; // hearts to half hearts
private final Set<Player> skippedCurrentNight = new HashSet<>(); private final Set<Player> skippedCurrentNight = new HashSet<>();
private long lastDay = 0; private long lastDay = 0;
@ -31,6 +30,7 @@ public class SleepListener implements Listener {
if (event.getBedEnterResult() == PlayerBedEnterEvent.BedEnterResult.OK) { if (event.getBedEnterResult() == PlayerBedEnterEvent.BedEnterResult.OK) {
SleepState.playersSleeping++; SleepState.playersSleeping++;
if (instant) {
World world = event.getPlayer().getWorld(); World world = event.getPlayer().getWorld();
long day = world.getFullTime() / 24000; long day = world.getFullTime() / 24000;
@ -38,13 +38,10 @@ public class SleepListener implements Listener {
lastDay = day; lastDay = day;
if (!skippedCurrentNight.contains(event.getPlayer())) { if (!skippedCurrentNight.contains(event.getPlayer())) {
if (instant) {
double onePlayerRatio = 1 / (event.getPlayer().getServer().getOnlinePlayers().size() * (world.getGameRuleValue(GameRule.PLAYERS_SLEEPING_PERCENTAGE) / 100.0)); double onePlayerRatio = 1 / (event.getPlayer().getServer().getOnlinePlayers().size() * (world.getGameRuleValue(GameRule.PLAYERS_SLEEPING_PERCENTAGE) / 100.0));
world.setTime(Math.min(world.getTime() + (long) (10917 * onePlayerRatio), 23459)); world.setTime(Math.min(world.getTime() + (long) (10917 * onePlayerRatio), 23459));
skippedCurrentNight.add(event.getPlayer()); skippedCurrentNight.add(event.getPlayer());
} }
event.getPlayer().setHealth(event.getPlayer().getHealth() + heal);
} }
} }
@ -56,9 +53,8 @@ public class SleepListener implements Listener {
} }
@EventHandler @EventHandler
public void onTimeSkip(TimeSkipEvent event) { public void onPlayerBedLeave(TimeSkipEvent event) {
if (event.getSkipReason() == TimeSkipEvent.SkipReason.NIGHT_SKIP) { if (event.getSkipReason() == TimeSkipEvent.SkipReason.NIGHT_SKIP)
event.setCancelled(true); event.setCancelled(true);
} }
} }
}

View file

@ -1,73 +0,0 @@
/*
* Copyright (C) 2025 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.swing;
import eu.m724.tweaks.DebugLogger;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.plugin.Plugin;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class SwingManager implements Listener {
private final Plugin plugin;
private final Set<Material> tools = new HashSet<>();
public SwingManager(Plugin plugin) {
this.plugin = plugin;
Arrays.stream(Material.values())
.filter(m -> m.name().contains("SWORD"))
.forEach(tools::add);
DebugLogger.fine("Tools: " + tools.size());
}
public void init() {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onBreak(BlockBreakEvent event) {
var type = event.getBlock().getType();
if (type.isOccluding()) return;
var player = event.getPlayer();
var tool = player.getInventory().getItemInMainHand().getType();
Entity entity = null;
if (tools.contains(tool)) { // if sword, raycast to hit farther
var result = player.getWorld().rayTraceEntities(
player.getEyeLocation(),
player.getEyeLocation().getDirection(),
player.getAttribute(Attribute.PLAYER_ENTITY_INTERACTION_RANGE).getValue(),
e -> e != player
);
if (result != null)
entity = result.getHitEntity();
} else {
entity = event.getBlock().getWorld()
.getNearbyEntities(event.getBlock().getLocation().add(0.5, 0.5, 0.5), 0.5, 0.5, 0.5)
.stream().filter(e -> (e instanceof LivingEntity && e != player))
.findFirst().orElse(null);
}
if (entity != null) {
player.attack(entity);
DebugLogger.fine("Swing " + player.getName() + " hit " + entity.getName());
}
}
}

View file

@ -83,9 +83,6 @@ hardcore:
# Makes sleeping # Makes sleeping
# And adds a nice animation # And adds a nice animation
# Percentage: playersSleepingPercentage gamerule
# If instant: how much % of players to skip the night
# If not: how much % make skipping full speed
sleep: sleep:
enabled: true enabled: true
# This gives every player a "share" of the night # This gives every player a "share" of the night
@ -93,8 +90,9 @@ sleep:
# For example, if 5 players online and night is 5 minutes, one can go to sleep and skip 1 minute of the night # For example, if 5 players online and night is 5 minutes, one can go to sleep and skip 1 minute of the night
# Leaving the bed and reentering it does nothing # Leaving the bed and reentering it does nothing
instant: false instant: false
# How many hearts to heal after sleeping # Percentage: playersSleepingPercentage gamerule
heal: 2.0 # If instant: how much % of players to skip the night
# If not: how much % make skipping full speed
# "Hostname" authentication # "Hostname" authentication
# This makes a player need to join a unique hostname like "asd123.example.com" where "asd123" is the key # This makes a player need to join a unique hostname like "asd123.example.com" where "asd123" is the key
@ -128,12 +126,6 @@ killswitch:
# To disable HTTP server, set to null # To disable HTTP server, set to null
listen: 127.0.0.1:57932 listen: 127.0.0.1:57932
# Swing through grass (and alike)
# If using sword, you can also hit behind the grass
# If not, you can only hit the entity in the grass
swing:
enabled: true
# Finally, thank you for downloading Tweaks724, I hope you enjoy! # Finally, thank you for downloading Tweaks724, I hope you enjoy!