parent
					
						
							
								740fab869e
							
						
					
				
			
			
				commit
				
					
						6c1e0da6b6
					
				
			
		
					 15 changed files with 144 additions and 97 deletions
				
			
		| 
						 | 
				
			
			@ -9,10 +9,10 @@ jobs:
 | 
			
		|||
      - name: Install JDK
 | 
			
		||||
        run: apt install --no-install-recommends -y openjdk-21-jdk-headless maven git nodejs
 | 
			
		||||
      - 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
 | 
			
		||||
        run: mvn clean package
 | 
			
		||||
      - name: Upload artifacts
 | 
			
		||||
        uses: https://github.com/actions/upload-artifact@v3
 | 
			
		||||
        with:
 | 
			
		||||
          path: target/mutils-*.jar
 | 
			
		||||
          path: target/tweaks-*.jar
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +37,10 @@ public record TweaksConfig(
 | 
			
		|||
        boolean pomodoroEnabled,
 | 
			
		||||
        boolean pomodoroForce,
 | 
			
		||||
 | 
			
		||||
        boolean updaterEnabled
 | 
			
		||||
        boolean updaterEnabled,
 | 
			
		||||
 | 
			
		||||
        boolean hardcoreEnabled,
 | 
			
		||||
        float hardcoreChance
 | 
			
		||||
) {
 | 
			
		||||
    public static final int CONFIG_VERSION = 1;
 | 
			
		||||
    private static TweaksConfig config;
 | 
			
		||||
| 
						 | 
				
			
			@ -87,6 +90,11 @@ public record TweaksConfig(
 | 
			
		|||
        boolean pomodoroEnabled = config.getBoolean("pomodoro.enabled");
 | 
			
		||||
        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(
 | 
			
		||||
                isProtocolLib,
 | 
			
		||||
                hideWorldBorder,
 | 
			
		||||
| 
						 | 
				
			
			@ -96,7 +104,8 @@ public record TweaksConfig(
 | 
			
		|||
                chatEnabled, chatLocalEvents, chatDefaultName,
 | 
			
		||||
                compassEnabled, compassWidth, compassPrecision,
 | 
			
		||||
                pomodoroEnabled, pomodoroForce,
 | 
			
		||||
                true // TODO
 | 
			
		||||
                updaterEnabled,
 | 
			
		||||
                hardcoreEnabled, hardcoreChance
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        return TweaksConfig.config;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,8 @@ package eu.m724.tweaks;
 | 
			
		|||
import eu.m724.tweaks.chat.ChatCommands;
 | 
			
		||||
import eu.m724.tweaks.chat.ChatManager;
 | 
			
		||||
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.PingChecker;
 | 
			
		||||
import eu.m724.tweaks.ping.PingCommands;
 | 
			
		||||
| 
						 | 
				
			
			@ -56,7 +57,7 @@ public class TweaksPlugin extends JavaPlugin {
 | 
			
		|||
 | 
			
		||||
        if (config.motdEnabled()) {
 | 
			
		||||
            try {
 | 
			
		||||
                new MotdListener(this).init();
 | 
			
		||||
                new MotdManager(this).init();
 | 
			
		||||
            } catch (IOException e) {
 | 
			
		||||
                getLogger().severe("Failed to initialize MOTD extension");
 | 
			
		||||
                throw new RuntimeException(e);
 | 
			
		||||
| 
						 | 
				
			
			@ -79,5 +80,7 @@ public class TweaksPlugin extends JavaPlugin {
 | 
			
		|||
                throw new RuntimeException(e);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        new HardcoreManager().init(this);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -174,9 +174,7 @@ public class ChatManager {
 | 
			
		|||
    public void deleteChatRoom(ChatRoom chatRoom) {
 | 
			
		||||
        roomIdMap.remove(chatRoom.id);
 | 
			
		||||
        ChatRoomLoader.getFile(plugin, chatRoom.id).delete();
 | 
			
		||||
        chatRoom.players.forEach(player -> {
 | 
			
		||||
            setPlayerChatRoom(getById(defaultRoom), player);
 | 
			
		||||
        });
 | 
			
		||||
        chatRoom.players.forEach(player -> setPlayerChatRoom(getById(defaultRoom), player));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -102,7 +102,7 @@ public class CompassListener implements Listener {
 | 
			
		|||
        //
 | 
			
		||||
 | 
			
		||||
        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);
 | 
			
		||||
 | 
			
		||||
            if (index >= 0 && index < width) {
 | 
			
		||||
| 
						 | 
				
			
			@ -122,10 +122,8 @@ public class CompassListener implements Listener {
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private double wrapModRange(double value, double start, double stop) {
 | 
			
		||||
        double range = stop - start;
 | 
			
		||||
        double result = start + (value - start - Math.floor((value - start) / range) * range);
 | 
			
		||||
        return result == stop ? start : result;
 | 
			
		||||
    private double wrapYawRange(double value) {
 | 
			
		||||
        return wrapMod(value, 360) - 180;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private double wrapMod(double value, double stop) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										35
									
								
								src/main/java/eu/m724/tweaks/hardcore/HardcoreManager.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/main/java/eu/m724/tweaks/hardcore/HardcoreManager.java
									
										
									
									
									
										Normal 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);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -27,12 +27,12 @@ import java.util.Arrays;
 | 
			
		|||
import java.util.Optional;
 | 
			
		||||
import java.util.concurrent.ThreadLocalRandom;
 | 
			
		||||
 | 
			
		||||
public class MotdListener {
 | 
			
		||||
public class MotdManager {
 | 
			
		||||
    private final Plugin plugin;
 | 
			
		||||
 | 
			
		||||
    private Component[] motds;
 | 
			
		||||
 | 
			
		||||
    public MotdListener(Plugin plugin) {
 | 
			
		||||
    public MotdManager(Plugin plugin) {
 | 
			
		||||
        this.plugin = plugin;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -63,9 +63,7 @@ public class MusicPlayer {
 | 
			
		|||
            for (int i=0; i<audio.available(); i++) {
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        } catch (UnsupportedAudioFileException e) {
 | 
			
		||||
            throw new RuntimeException(e);
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
        } catch (UnsupportedAudioFileException | IOException e) {
 | 
			
		||||
            throw new RuntimeException(e);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,7 +30,7 @@ public class UpdateChecker extends BukkitRunnable {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    private void checkAll() {
 | 
			
		||||
        logger.info("Now checking all plugins");
 | 
			
		||||
        logger.info("Checking for updates");
 | 
			
		||||
        for (VersionedResource versionedResource : Set.copyOf(resources)) {
 | 
			
		||||
            logger.info(versionedResource.resource().resourceId() + " " + versionedResource.resource().plugin().getName());
 | 
			
		||||
            int page = versionedResource.running() != null ? versionedResource.running().page() : 1;
 | 
			
		||||
| 
						 | 
				
			
			@ -38,6 +38,13 @@ public class UpdateChecker extends BukkitRunnable {
 | 
			
		|||
            try {
 | 
			
		||||
                VersionedResource newResource = new VersionFinder(versionedResource.resource(), page).join(); // this runs async so it's ok
 | 
			
		||||
                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.add(newResource);
 | 
			
		||||
                    // TODO notify and all
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,7 +13,9 @@ import org.bukkit.plugin.Plugin;
 | 
			
		|||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.FileInputStream;
 | 
			
		||||
import java.io.FileNotFoundException;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
import java.util.stream.Collectors;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -33,13 +35,14 @@ public class UpdaterManager {
 | 
			
		|||
        Set<ResourceVersion> installedVersions;
 | 
			
		||||
        try (FileInputStream inputStream = new FileInputStream(cacheFile)) {
 | 
			
		||||
            installedVersions = VersionCheckCache.loadAll(inputStream);
 | 
			
		||||
        } catch (FileNotFoundException e) {
 | 
			
		||||
            installedVersions = new HashSet<>();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Set<VersionedResource> versionedResources = installedVersions.stream()
 | 
			
		||||
                .map(rv -> new VersionedResource(
 | 
			
		||||
                        resources.stream().filter(r -> r.resourceId() == rv.resourceId()).findFirst().get(),
 | 
			
		||||
                        rv,
 | 
			
		||||
                        null
 | 
			
		||||
        final Set<ResourceVersion> ivf = installedVersions;
 | 
			
		||||
        Set<VersionedResource> versionedResources = resources.stream()
 | 
			
		||||
                .map(res -> new VersionedResource(
 | 
			
		||||
                        res, ivf.stream().filter(iv -> iv.resourceId() == res.resourceId()).findFirst().orElse(null), null
 | 
			
		||||
                )).collect(Collectors.toSet());
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
  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!
 | 
			
		||||
 | 
			
		||||
# Don't modify unless told to
 | 
			
		||||
magic number dont modify this: 1
 | 
			
		||||
magic number don't modify this: 1
 | 
			
		||||
							
								
								
									
										53
									
								
								src/main/resources/motd sets/2006.txt
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								src/main/resources/motd sets/2006.txt
									
										
									
									
									
										Normal 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.
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue