yes
Some checks failed
/ deploy (push) Failing after 2m8s

This commit is contained in:
Minecon724 2024-11-28 18:43:37 +01:00
parent 740fab869e
commit 6c1e0da6b6
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
15 changed files with 144 additions and 97 deletions

View file

@ -9,10 +9,10 @@ jobs:
- name: Install JDK - name: Install JDK
run: apt install --no-install-recommends -y openjdk-21-jdk-headless maven git nodejs run: apt install --no-install-recommends -y openjdk-21-jdk-headless maven git nodejs
- name: Clone repository - name: Clone repository
run: git clone https://git.m724.eu/Minecon724/mutils.git . run: git clone https://git.m724.eu/Minecon724/tweaks724.git .
- name: Build - name: Build
run: mvn clean package run: mvn clean package
- name: Upload artifacts - name: Upload artifacts
uses: https://github.com/actions/upload-artifact@v3 uses: https://github.com/actions/upload-artifact@v3
with: with:
path: target/mutils-*.jar path: target/tweaks-*.jar

View file

@ -37,7 +37,10 @@ public record TweaksConfig(
boolean pomodoroEnabled, boolean pomodoroEnabled,
boolean pomodoroForce, boolean pomodoroForce,
boolean updaterEnabled boolean updaterEnabled,
boolean hardcoreEnabled,
float hardcoreChance
) { ) {
public static final int CONFIG_VERSION = 1; public static final int CONFIG_VERSION = 1;
private static TweaksConfig config; private static TweaksConfig config;
@ -87,6 +90,11 @@ public record TweaksConfig(
boolean pomodoroEnabled = config.getBoolean("pomodoro.enabled"); boolean pomodoroEnabled = config.getBoolean("pomodoro.enabled");
boolean pomodoroForce = config.getBoolean("pomodoro.force"); boolean pomodoroForce = config.getBoolean("pomodoro.force");
boolean updaterEnabled = config.getBoolean("updater.enabled");
boolean hardcoreEnabled = config.getBoolean("hardcore.enabled");
float hardcoreChance = (float) config.getDouble("hardcore.chance");
TweaksConfig.config = new TweaksConfig( TweaksConfig.config = new TweaksConfig(
isProtocolLib, isProtocolLib,
hideWorldBorder, hideWorldBorder,
@ -96,7 +104,8 @@ public record TweaksConfig(
chatEnabled, chatLocalEvents, chatDefaultName, chatEnabled, chatLocalEvents, chatDefaultName,
compassEnabled, compassWidth, compassPrecision, compassEnabled, compassWidth, compassPrecision,
pomodoroEnabled, pomodoroForce, pomodoroEnabled, pomodoroForce,
true // TODO updaterEnabled,
hardcoreEnabled, hardcoreChance
); );
return TweaksConfig.config; return TweaksConfig.config;

View file

@ -9,7 +9,8 @@ package eu.m724.tweaks;
import eu.m724.tweaks.chat.ChatCommands; import eu.m724.tweaks.chat.ChatCommands;
import eu.m724.tweaks.chat.ChatManager; import eu.m724.tweaks.chat.ChatManager;
import eu.m724.tweaks.door.DoorManager; import eu.m724.tweaks.door.DoorManager;
import eu.m724.tweaks.motd.MotdListener; import eu.m724.tweaks.hardcore.HardcoreManager;
import eu.m724.tweaks.motd.MotdManager;
import eu.m724.tweaks.ping.F3NameListener; import eu.m724.tweaks.ping.F3NameListener;
import eu.m724.tweaks.ping.PingChecker; import eu.m724.tweaks.ping.PingChecker;
import eu.m724.tweaks.ping.PingCommands; import eu.m724.tweaks.ping.PingCommands;
@ -56,7 +57,7 @@ public class TweaksPlugin extends JavaPlugin {
if (config.motdEnabled()) { if (config.motdEnabled()) {
try { try {
new MotdListener(this).init(); new MotdManager(this).init();
} catch (IOException e) { } catch (IOException e) {
getLogger().severe("Failed to initialize MOTD extension"); getLogger().severe("Failed to initialize MOTD extension");
throw new RuntimeException(e); throw new RuntimeException(e);
@ -79,5 +80,7 @@ public class TweaksPlugin extends JavaPlugin {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
new HardcoreManager().init(this);
} }
} }

View file

@ -1,26 +0,0 @@
/*
* 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.auth;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerLoginEvent;
public class AuthListener implements Listener {
private final AuthManager authManager;
public AuthListener(AuthManager authManager) {
this.authManager = authManager;
}
@EventHandler
public void onPlayerLogin(PlayerLoginEvent event) {
Player player = event.getPlayer();
String hostname = event.getHostname();
}
}

View file

@ -1,17 +0,0 @@
/*
* 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.auth;
import org.bukkit.plugin.Plugin;
public class AuthManager {
private final Plugin plugin;
public AuthManager(Plugin plugin) {
this.plugin = plugin;
}
}

View file

@ -174,9 +174,7 @@ public class ChatManager {
public void deleteChatRoom(ChatRoom chatRoom) { public void deleteChatRoom(ChatRoom chatRoom) {
roomIdMap.remove(chatRoom.id); roomIdMap.remove(chatRoom.id);
ChatRoomLoader.getFile(plugin, chatRoom.id).delete(); ChatRoomLoader.getFile(plugin, chatRoom.id).delete();
chatRoom.players.forEach(player -> { chatRoom.players.forEach(player -> setPlayerChatRoom(getById(defaultRoom), player));
setPlayerChatRoom(getById(defaultRoom), player);
});
} }
/** /**

View file

@ -102,7 +102,7 @@ public class CompassListener implements Listener {
// //
for (Map.Entry<Integer, String> entry : currentPoints.entrySet()) { for (Map.Entry<Integer, String> entry : currentPoints.entrySet()) {
double distance = -wrapModRange(yaw - entry.getKey(), -180, 180); double distance = -wrapYawRange(yaw - entry.getKey());
int index = (int) (distance / precision + width / 2.0); int index = (int) (distance / precision + width / 2.0);
if (index >= 0 && index < width) { if (index >= 0 && index < width) {
@ -122,10 +122,8 @@ public class CompassListener implements Listener {
} }
} }
private double wrapModRange(double value, double start, double stop) { private double wrapYawRange(double value) {
double range = stop - start; return wrapMod(value, 360) - 180;
double result = start + (value - start - Math.floor((value - start) / range) * range);
return result == stop ? start : result;
} }
private double wrapMod(double value, double stop) { private double wrapMod(double value, double stop) {

View file

@ -0,0 +1,35 @@
/*
* 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.hardcore;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.*;
import eu.m724.tweaks.TweaksConfig;
import org.bukkit.plugin.Plugin;
public class HardcoreManager {
private final float chance = TweaksConfig.getConfig().hardcoreChance();
public void init(Plugin plugin) {
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(
plugin,
ListenerPriority.NORMAL,
PacketType.Play.Server.LOGIN
) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket();
int entityId = packet.getIntegers().read(0);
if (chance > ((48271 * entityId) % 65537) / 65537f) // gotta be fast
// the "is hardcore" boolean https://wiki.vg/Protocol#Login_.28play.29
packet.getBooleans().write(0, true);
}
});
}
}

View file

@ -27,12 +27,12 @@ import java.util.Arrays;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
public class MotdListener { public class MotdManager {
private final Plugin plugin; private final Plugin plugin;
private Component[] motds; private Component[] motds;
public MotdListener(Plugin plugin) { public MotdManager(Plugin plugin) {
this.plugin = plugin; this.plugin = plugin;
} }

View file

@ -63,9 +63,7 @@ public class MusicPlayer {
for (int i=0; i<audio.available(); i++) { for (int i=0; i<audio.available(); i++) {
} }
} catch (UnsupportedAudioFileException e) { } catch (UnsupportedAudioFileException | IOException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View file

@ -30,7 +30,7 @@ public class UpdateChecker extends BukkitRunnable {
} }
private void checkAll() { private void checkAll() {
logger.info("Now checking all plugins"); logger.info("Checking for updates");
for (VersionedResource versionedResource : Set.copyOf(resources)) { for (VersionedResource versionedResource : Set.copyOf(resources)) {
logger.info(versionedResource.resource().resourceId() + " " + versionedResource.resource().plugin().getName()); logger.info(versionedResource.resource().resourceId() + " " + versionedResource.resource().plugin().getName());
int page = versionedResource.running() != null ? versionedResource.running().page() : 1; int page = versionedResource.running() != null ? versionedResource.running().page() : 1;
@ -38,6 +38,13 @@ public class UpdateChecker extends BukkitRunnable {
try { try {
VersionedResource newResource = new VersionFinder(versionedResource.resource(), page).join(); // this runs async so it's ok VersionedResource newResource = new VersionFinder(versionedResource.resource(), page).join(); // this runs async so it's ok
if (!versionedResource.equals(newResource)) { if (!versionedResource.equals(newResource)) {
resources.remove(versionedResource);
if (newResource.running() == null) {
if (versionedResource.running() != null) {
logger.info("Did you downgrade %s? If so, clear cache");
newResource = null;
}
}
resources.remove(versionedResource); resources.remove(versionedResource);
resources.add(newResource); resources.add(newResource);
// TODO notify and all // TODO notify and all

View file

@ -13,7 +13,9 @@ import org.bukkit.plugin.Plugin;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -33,13 +35,14 @@ public class UpdaterManager {
Set<ResourceVersion> installedVersions; Set<ResourceVersion> installedVersions;
try (FileInputStream inputStream = new FileInputStream(cacheFile)) { try (FileInputStream inputStream = new FileInputStream(cacheFile)) {
installedVersions = VersionCheckCache.loadAll(inputStream); installedVersions = VersionCheckCache.loadAll(inputStream);
} catch (FileNotFoundException e) {
installedVersions = new HashSet<>();
} }
Set<VersionedResource> versionedResources = installedVersions.stream() final Set<ResourceVersion> ivf = installedVersions;
.map(rv -> new VersionedResource( Set<VersionedResource> versionedResources = resources.stream()
resources.stream().filter(r -> r.resourceId() == rv.resourceId()).findFirst().get(), .map(res -> new VersionedResource(
rv, res, ivf.stream().filter(iv -> iv.resourceId() == res.resourceId()).findFirst().orElse(null), null
null
)).collect(Collectors.toSet()); )).collect(Collectors.toSet());

View file

@ -1,28 +0,0 @@
package eu.m724.tweaks.worldborder;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
// TODO I could do this with API but yeah I'm more comfortable with this
public record WorldBorderInfoPayload(int extensionRadius) implements CustomPacketPayload {
private static final Type<WorldBorderInfoPayload> TYPE =
new Type<>(ResourceLocation.tryBuild("tweaks724", "worldborder"));
public static final StreamCodec<FriendlyByteBuf, WorldBorderInfoPayload> STREAM_CODEC =
CustomPacketPayload.codec(WorldBorderInfoPayload::write, WorldBorderInfoPayload::new);
public Type<? extends CustomPacketPayload> type() {
return TYPE;
}
private WorldBorderInfoPayload(FriendlyByteBuf byteBuf) {
this(byteBuf.readVarInt());
}
private void write(FriendlyByteBuf byteBuf) {
byteBuf.writeVarInt(extensionRadius);
}
}

View file

@ -49,7 +49,21 @@ pomodoro:
# Players will be unable to join the server during break and will be kicked a short time after pomodoro ends # Players will be unable to join the server during break and will be kicked a short time after pomodoro ends
force: true force: true
# Updates your plugins
# The plugin must be from SpigotMC and its versioning should match that on SpigotMC
# Allow "api.spigotmc.org" on your firewall if you have one
# Watch the console for setup instructions
updater:
enabled: true
# Hardcore hearts. It just makes hearts with the eyes like on hardcore, nothing more.
# WARNING: "Respawn" label will be "spectate world". The button still respawns though
hardcore:
enabled: true
# 0.0 - 1.0 decimal. This is if you want to make it like an Easter egg
chance: 1.0
# Finally, thank you for downloading Tweaks724, I hope you enjoy! # Finally, thank you for downloading Tweaks724, I hope you enjoy!
# Don't modify unless told to # Don't modify unless told to
magic number dont modify this: 1 magic number don't modify this: 1

View file

@ -0,0 +1,53 @@
Zlikwidować całkowicie dla młodzieży alkohol, papierosy i narkotyki
Usprawnić w naszym Białymstoku komunikację miejską.
Miejską i dalekobieżną.
Tak, bo nasza komunikacja jest bardzo, bardzo słaba, bardzo zła
Otworzyć zakłady, miejsca pracy dla młodzieży i dla ludzi. Tak. I chcę bardzo, bardzo to zrobić.
Usprawnić w naszym mieście… w całym… na całym Podlasiu.
Żeby nie było bandyctwa, żeby nie było złodziejstwa, żeby nie było niczego.
Żeby starsi ludzie mogli przejść.
Bo nawet teraz dochodzi do mnie skargi, postulaty.
Apelują starszy ludzie w podeszłym wieku, że młodzież zaczepia.
A ja się nie dziwię się, że młodzież starszych ludzi zaczepia, napada… napadają i tak dalej.
Bo młodzież nie ma pracy, nie ma pracy.
Zakłady nasze w Białymstoku są rozwalane.
Zamiast budowane, zamiast usprawnić Białystok, żeby miejsca pracy.
Tak jak mleczarnie tu w Białymstoku, tak jak Spomasz w Starosielcach, tak jak… i inne zakłady są rozwalane.
Żeby policja pilnowała całego naszego porządku.
Bo od tego jest policja i straż miejska.
Od tego oni są. Od tego są oni. Od tego są!
A w urzędzie u mnie miejskim będzie ład i porządek.
Nie będzie biurokractwa, nie będzie łachmaństwa.
W zimową porą będą szykować architekci plany budowy dróg. Plany budowy dróg.
Podkreślam jeszcze raz plany budowy dróg.
A na wiosnę wyjdziemy z budową ulic i… ulic.
Bo jakie mamy drogi? Jakie mamy?
Co się stało się pod Jeżewem?
Co się stało się?
A kierowcy też będą przez policję surowo karani za alkohol, za papierosy, za wszystko!
I jeszcze też usprawnię granicę w Kuźnicy i w Bobrownikach.
Że granica między Białorusią a nami będzie naprawdę.
Naprawdę będzie granica.
Że nie będzie przemytu ani papierosów, ani narkotyków, ani alkoholu.