├── .github └── FUNDING.yml ├── .gitignore ├── Empty.zip ├── LICENSE ├── README.md ├── bukkit-v1_10_R1 ├── pom.xml └── src │ └── main │ └── java │ └── de │ └── themoep │ └── resourcepacksplugin │ └── bukkit │ └── internal │ └── InternalHelper_v1_10_R1.java ├── bukkit-v1_11_R1 ├── pom.xml └── src │ └── main │ └── java │ └── de │ └── themoep │ └── resourcepacksplugin │ └── bukkit │ └── internal │ └── InternalHelper_v1_11_R1.java ├── bukkit-v1_20_R3 ├── pom.xml └── src │ └── main │ └── java │ └── de │ └── themoep │ └── resourcepacksplugin │ └── bukkit │ └── internal │ └── InternalHelper_v1_20_R3.java ├── bukkit-v1_8_R3 ├── pom.xml └── src │ └── main │ └── java │ └── de │ └── themoep │ └── resourcepacksplugin │ └── bukkit │ └── internal │ └── InternalHelper_v1_8_R3.java ├── bukkit-v1_9_R1 ├── pom.xml └── src │ └── main │ └── java │ └── de │ └── themoep │ └── resourcepacksplugin │ └── bukkit │ └── internal │ └── InternalHelper_v1_9_R1.java ├── bukkit-v1_9_R2 ├── pom.xml └── src │ └── main │ └── java │ └── de │ └── themoep │ └── resourcepacksplugin │ └── bukkit │ └── internal │ └── InternalHelper_v1_9_R2.java ├── bukkit ├── pom.xml └── src │ └── main │ ├── java │ └── de │ │ └── themoep │ │ └── resourcepacksplugin │ │ └── bukkit │ │ ├── ConfigAccessor.java │ │ ├── ForwardingCommand.java │ │ ├── WorldResourcepacks.java │ │ ├── events │ │ ├── ResourcePackSelectEvent.java │ │ └── ResourcePackSendEvent.java │ │ ├── internal │ │ ├── InternalHelper.java │ │ └── InternalHelper_fallback.java │ │ └── listeners │ │ ├── AuthHandler.java │ │ ├── AuthmeLoginListener.java │ │ ├── ConnectListener.java │ │ ├── DisconnectListener.java │ │ ├── LibreLoginListener.java │ │ ├── NLoginListener.java │ │ ├── OpeNLoginListener.java │ │ ├── ProxyPackListener.java │ │ └── WorldSwitchListener.java │ └── resources │ └── config.yml ├── bungee ├── pom.xml └── src │ └── main │ ├── java │ └── de │ │ └── themoep │ │ └── resourcepacksplugin │ │ └── bungee │ │ ├── BungeeResourcepacks.java │ │ ├── ForwardingCommand.java │ │ ├── events │ │ ├── ResourcePackSelectEvent.java │ │ └── ResourcePackSendEvent.java │ │ ├── listeners │ │ ├── AuthHandler.java │ │ ├── ConnectListener.java │ │ ├── DisconnectListener.java │ │ ├── JPremiumListener.java │ │ ├── LibreLoginListener.java │ │ ├── LibrePremiumListener.java │ │ ├── NLoginListener.java │ │ ├── PluginMessageListener.java │ │ └── ServerSwitchListener.java │ │ └── packets │ │ ├── IdMapping.java │ │ ├── ResourcePackRemovePacket.java │ │ └── ResourcePackSendPacket.java │ └── resources │ ├── bungee-config.yml │ ├── bungee.yml │ └── packetmap.yml ├── core ├── pom.xml └── src │ └── main │ ├── java │ └── de │ │ └── themoep │ │ └── resourcepacksplugin │ │ └── core │ │ ├── ChatColor.java │ │ ├── ClientType.java │ │ ├── MinecraftVersion.java │ │ ├── PackAssignment.java │ │ ├── PackManager.java │ │ ├── PluginLogger.java │ │ ├── ResourcePack.java │ │ ├── ResourcepacksPlayer.java │ │ ├── ResourcepacksPlugin.java │ │ ├── SubChannelHandler.java │ │ ├── UserManager.java │ │ ├── commands │ │ ├── PluginCommandExecutor.java │ │ ├── ResetPackCommandExecutor.java │ │ ├── ResourcepacksPluginCommandExecutor.java │ │ └── UsePackCommandExecutor.java │ │ └── events │ │ ├── IResourcePackSelectEvent.java │ │ └── IResourcePackSendEvent.java │ └── resources │ └── languages │ └── lang.en.yml ├── pom.xml ├── sponge ├── pom.xml └── src │ └── main │ ├── java │ └── de │ │ └── themoep │ │ └── resourcepacksplugin │ │ └── sponge │ │ ├── ForwardingCommand.java │ │ ├── PluginConfig.java │ │ ├── SpongePluginLogger.java │ │ ├── SpongeResourcepacks.java │ │ ├── events │ │ ├── ResourcePackSelectEvent.java │ │ └── ResourcePackSendEvent.java │ │ └── listeners │ │ ├── DisconnectListener.java │ │ ├── ProxyPackListener.java │ │ ├── ProxyPackReaction.java │ │ └── WorldSwitchListener.java │ └── resources │ └── sponge-config.yml ├── velocity ├── pom.xml └── src │ └── main │ ├── java │ └── de │ │ └── themoep │ │ └── resourcepacksplugin │ │ └── velocity │ │ ├── ForwardingCommand.java │ │ ├── PluginConfig.java │ │ ├── VelocityPluginLogger.java │ │ ├── VelocityResourcepacks.java │ │ ├── events │ │ ├── ResourcePackSelectEvent.java │ │ └── ResourcePackSendEvent.java │ │ ├── integrations │ │ ├── FloodgateIntegration.java │ │ ├── GeyserIntegration.java │ │ └── ViaVersionIntegration.java │ │ └── listeners │ │ ├── AuthHandler.java │ │ ├── AuthMeVelocityListener.java │ │ ├── ConnectListener.java │ │ ├── CurrentServerTracker.java │ │ ├── DisconnectListener.java │ │ ├── JPremiumListener.java │ │ ├── LibreLoginListener.java │ │ ├── LibrePremiumListener.java │ │ ├── NLoginListener.java │ │ ├── PluginMessageListener.java │ │ └── ServerSwitchListener.java │ └── resources │ ├── velocity-config.yml │ └── velocity-plugin.json └── worldresourcepacks ├── pom.xml └── src └── main └── resources ├── mcmod.info └── plugin.yml /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [Phoenix616] 2 | patreon: Phoenix616 3 | custom: https://phoenix616.dev/tip 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IntelliJ project files 2 | /.idea 3 | *.iml 4 | out 5 | gen 6 | target -------------------------------------------------------------------------------- /Empty.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Phoenix616/ResourcepacksPlugins/dea57f34c6ac0ee1941fa5bd3997c47bc85e1d6f/Empty.zip -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ResourcepacksPlugins 2 | [![Total downloads](https://img.shields.io/github/downloads/Phoenix616/ResourcepacksPlugins/total.svg)](https://github.com/Phoenix616/ResourcepacksPlugins/releases) ![Work time](https://buttons.phoenix616.dev//ResourcepacksPluginsWork.svg) 3 | 4 | Repository for the different resourcepacks plugins by Phoenix616: [BungeeResourcepacks](https://www.spigotmc.org/resources/bungee-resourcepacks.6137/), [WorldResourcepacks](https://www.spigotmc.org/resources/world-resourcepacks.18950/) and [VelocityResourcepacks](https://forums.papermc.io/threads/velocityresourcepacks-manage-resourcepacks-for-servers-and-whole-proxy.30/). 5 | 6 | ## Development 7 | 8 | Dev builds: https://ci.minebench.de/job/ResourcepacksPlugins/ 9 | 10 | ### Integrating 11 | 12 | Javadocs: https://docs.phoenix616.dev/resourcepacksplugins/ 13 | 14 | You can easily depend on it via maven (or gradle). The core contains all the management and the bukkit/bungee artifacts the platform depended code. 15 | 16 | #### Repository 17 | ```xml 18 | 19 | 20 | minebench-repo 21 | https://repo.minebench.de/ 22 | 23 | 24 | ``` 25 | 26 | #### Artifacts 27 | ```xml 28 | 29 | 30 | de.themoep.resourcepacksplugin 31 | bukkit 32 | 1.8.1-SNAPSHOT 33 | provided 34 | 35 | 36 | de.themoep.resourcepacksplugin 37 | bungee 38 | 1.8.1-SNAPSHOT 39 | provided 40 | 41 | 42 | de.themoep.resourcepacksplugin 43 | velocity 44 | 1.8.1-SNAPSHOT 45 | provided 46 | 47 | 48 | de.themoep.resourcepacksplugin 49 | core 50 | 1.8.1-SNAPSHOT 51 | provided 52 | 53 | 54 | ``` 55 | 56 | ## [License](LICENSE) 57 | 58 | The plugin is licensed under the GPLv3: 59 | 60 | ``` 61 | ResourcepacksPlugins 62 | Copyright (C) 2020 Max Lee aka Phoenix616 (mail@moep.tv) 63 | 64 | This program is free software: you can redistribute it and/or modify 65 | it under the terms of the GNU General Public License as published by 66 | the Free Software Foundation, either version 3 of the License, or 67 | (at your option) any later version. 68 | 69 | This program is distributed in the hope that it will be useful, 70 | but WITHOUT ANY WARRANTY; without even the implied warranty of 71 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 72 | GNU General Public License for more details. 73 | 74 | You should have received a copy of the GNU General Public License 75 | along with this program. If not, see . 76 | ``` -------------------------------------------------------------------------------- /bukkit-v1_10_R1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | bukkit-v1_10_R1 8 | ${plugin.version} 9 | jar 10 | 11 | 12 | de.themoep.resourcepacksplugin 13 | parent 14 | parent 15 | 16 | 17 | 18 | 19 | 20 | org.spigotmc 21 | spigot 22 | 1.10.2-R0.1-SNAPSHOT 23 | provided 24 | 25 | 26 | de.themoep.resourcepacksplugin 27 | bukkit 28 | ${project.version} 29 | provided 30 | 31 | 32 | de.themoep.resourcepacksplugin 33 | core 34 | ${project.version} 35 | provided 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /bukkit-v1_10_R1/src/main/java/de/themoep/resourcepacksplugin/bukkit/internal/InternalHelper_v1_10_R1.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.internal; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit-v1_10_R1 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 22 | import de.themoep.resourcepacksplugin.core.ResourcePack; 23 | import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; 24 | import org.bukkit.entity.Player; 25 | 26 | /** 27 | * Created by Phoenix616 on 22.07.2016. 28 | */ 29 | public class InternalHelper_v1_10_R1 implements InternalHelper { 30 | 31 | private WorldResourcepacks plugin; 32 | 33 | public InternalHelper_v1_10_R1(WorldResourcepacks plugin) { 34 | this.plugin = plugin; 35 | } 36 | 37 | @Override 38 | public void setResourcePack(Player player, ResourcePack pack) { 39 | ((CraftPlayer) player).getHandle().setResourcePack(plugin.getPackManager().getPackUrl(pack), pack.getHash()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bukkit-v1_11_R1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | bukkit-v1_11_R1 8 | ${plugin.version} 9 | jar 10 | 11 | 12 | de.themoep.resourcepacksplugin 13 | parent 14 | parent 15 | 16 | 17 | 18 | 19 | org.spigotmc 20 | spigot 21 | 1.11-R0.1-SNAPSHOT 22 | provided 23 | 24 | 25 | de.themoep.resourcepacksplugin 26 | bukkit 27 | ${project.version} 28 | provided 29 | 30 | 31 | de.themoep.resourcepacksplugin 32 | core 33 | ${project.version} 34 | provided 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /bukkit-v1_11_R1/src/main/java/de/themoep/resourcepacksplugin/bukkit/internal/InternalHelper_v1_11_R1.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.internal; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit-v1_11_R1 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 22 | import de.themoep.resourcepacksplugin.core.ResourcePack; 23 | import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer; 24 | import org.bukkit.entity.Player; 25 | 26 | /** 27 | * Created by Phoenix616 on 22.07.2016. 28 | */ 29 | public class InternalHelper_v1_11_R1 implements InternalHelper { 30 | 31 | private WorldResourcepacks plugin; 32 | 33 | public InternalHelper_v1_11_R1(WorldResourcepacks plugin) { 34 | this.plugin = plugin; 35 | } 36 | 37 | @Override 38 | public void setResourcePack(Player player, ResourcePack pack) { 39 | ((CraftPlayer) player).getHandle().setResourcePack(plugin.getPackManager().getPackUrl(pack), pack.getHash()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bukkit-v1_20_R3/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | bukkit-v1_20_R3 8 | ${plugin.version} 9 | jar 10 | 11 | 12 | de.themoep.resourcepacksplugin 13 | parent 14 | parent 15 | 16 | 17 | 18 | 1.20.4-R0.1-SNAPSHOT 19 | 20 | 21 | 22 | 23 | org.spigotmc 24 | spigot 25 | ${spigot.dependency.version} 26 | remapped-mojang 27 | provided 28 | 29 | 30 | de.themoep.resourcepacksplugin 31 | bukkit 32 | ${project.version} 33 | provided 34 | 35 | 36 | de.themoep.resourcepacksplugin 37 | core 38 | ${project.version} 39 | provided 40 | 41 | 42 | 43 | 44 | 45 | 46 | net.md-5 47 | specialsource-maven-plugin 48 | 1.2.5 49 | 50 | 51 | package 52 | 53 | remap 54 | 55 | remap-obf 56 | 57 | org.spigotmc:minecraft-server:${spigot.dependency.version}:txt:maps-mojang 58 | true 59 | org.spigotmc:spigot:${spigot.dependency.version}:jar:remapped-mojang 60 | true 61 | remapped-obf 62 | 63 | 64 | 65 | package 66 | 67 | remap 68 | 69 | remap-spigot 70 | 71 | ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar 72 | org.spigotmc:minecraft-server:${spigot.dependency.version}:csrg:maps-spigot 73 | org.spigotmc:spigot:${spigot.dependency.version}:jar:remapped-obf 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /bukkit-v1_20_R3/src/main/java/de/themoep/resourcepacksplugin/bukkit/internal/InternalHelper_v1_20_R3.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.internal; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit-v1_11_R1 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 22 | import de.themoep.resourcepacksplugin.core.ResourcePack; 23 | import net.minecraft.network.protocol.common.ClientboundResourcePackPopPacket; 24 | import net.minecraft.network.protocol.common.ClientboundResourcePackPushPacket; 25 | import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; 26 | import org.bukkit.entity.Player; 27 | 28 | import java.util.Optional; 29 | 30 | /** 31 | * Created by Phoenix616 on 22.07.2016. 32 | */ 33 | public class InternalHelper_v1_20_R3 implements InternalHelper { 34 | 35 | private WorldResourcepacks plugin; 36 | 37 | public InternalHelper_v1_20_R3(WorldResourcepacks plugin) { 38 | this.plugin = plugin; 39 | } 40 | 41 | @Override 42 | public void setResourcePack(Player player, ResourcePack pack) { 43 | ((CraftPlayer) player).getHandle().connection.send(new ClientboundResourcePackPushPacket( 44 | pack.getUuid(), pack.getUrl(), pack.getHash(), false, null 45 | )); 46 | } 47 | 48 | @Override 49 | public void removeResourcePack(Player player, ResourcePack pack) { 50 | if (pack == null || pack.getUuid() == null) 51 | return; 52 | 53 | ((CraftPlayer) player).getHandle().connection.send(new ClientboundResourcePackPopPacket(Optional.of(pack.getUuid()))); 54 | } 55 | 56 | @Override 57 | public void removeResourcePacks(Player player) { 58 | ((CraftPlayer) player).getHandle().connection.send(new ClientboundResourcePackPopPacket(Optional.empty())); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /bukkit-v1_8_R3/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | bukkit-v1_8_R3 8 | ${plugin.version} 9 | jar 10 | 11 | 12 | de.themoep.resourcepacksplugin 13 | parent 14 | parent 15 | 16 | 17 | 18 | 19 | 20 | org.spigotmc 21 | spigot 22 | 1.8.8-R0.1-SNAPSHOT 23 | provided 24 | 25 | 26 | de.themoep.resourcepacksplugin 27 | bukkit 28 | ${project.version} 29 | provided 30 | 31 | 32 | de.themoep.resourcepacksplugin 33 | core 34 | ${project.version} 35 | provided 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /bukkit-v1_8_R3/src/main/java/de/themoep/resourcepacksplugin/bukkit/internal/InternalHelper_v1_8_R3.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.internal; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit-v1_8_R3 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 22 | import de.themoep.resourcepacksplugin.core.ResourcePack; 23 | import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; 24 | import org.bukkit.entity.Player; 25 | 26 | /** 27 | * Created by Phoenix616 on 22.07.2016. 28 | */ 29 | public class InternalHelper_v1_8_R3 implements InternalHelper { 30 | 31 | private WorldResourcepacks plugin; 32 | 33 | public InternalHelper_v1_8_R3(WorldResourcepacks plugin) { 34 | this.plugin = plugin; 35 | } 36 | 37 | @Override 38 | public void setResourcePack(Player player, ResourcePack pack) { 39 | ((CraftPlayer) player).getHandle().setResourcePack(plugin.getPackManager().getPackUrl(pack), pack.getHash()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bukkit-v1_9_R1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | bukkit-v1_9_R1 8 | ${plugin.version} 9 | jar 10 | 11 | 12 | de.themoep.resourcepacksplugin 13 | parent 14 | parent 15 | 16 | 17 | 18 | 19 | 20 | org.spigotmc 21 | spigot 22 | 1.9-R0.1-SNAPSHOT 23 | provided 24 | 25 | 26 | de.themoep.resourcepacksplugin 27 | bukkit 28 | ${project.version} 29 | provided 30 | 31 | 32 | de.themoep.resourcepacksplugin 33 | core 34 | ${project.version} 35 | provided 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /bukkit-v1_9_R1/src/main/java/de/themoep/resourcepacksplugin/bukkit/internal/InternalHelper_v1_9_R1.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.internal; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit-v1_9_R1 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 22 | import de.themoep.resourcepacksplugin.core.ResourcePack; 23 | import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer; 24 | import org.bukkit.entity.Player; 25 | 26 | /** 27 | * Created by Phoenix616 on 22.07.2016. 28 | */ 29 | public class InternalHelper_v1_9_R1 implements InternalHelper { 30 | 31 | private WorldResourcepacks plugin; 32 | 33 | public InternalHelper_v1_9_R1(WorldResourcepacks plugin) { 34 | this.plugin = plugin; 35 | } 36 | 37 | @Override 38 | public void setResourcePack(Player player, ResourcePack pack) { 39 | ((CraftPlayer) player).getHandle().setResourcePack(plugin.getPackManager().getPackUrl(pack), pack.getHash()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bukkit-v1_9_R2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | bukkit-v1_9_R2 8 | ${plugin.version} 9 | jar 10 | 11 | 12 | de.themoep.resourcepacksplugin 13 | parent 14 | parent 15 | 16 | 17 | 18 | 19 | 20 | org.spigotmc 21 | spigot 22 | 1.9.4-R0.1-SNAPSHOT 23 | provided 24 | 25 | 26 | de.themoep.resourcepacksplugin 27 | bukkit 28 | ${project.version} 29 | provided 30 | 31 | 32 | de.themoep.resourcepacksplugin 33 | core 34 | ${project.version} 35 | provided 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /bukkit-v1_9_R2/src/main/java/de/themoep/resourcepacksplugin/bukkit/internal/InternalHelper_v1_9_R2.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.internal; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit-v1_9_R2 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 22 | import de.themoep.resourcepacksplugin.core.ResourcePack; 23 | import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; 24 | import org.bukkit.entity.Player; 25 | 26 | /** 27 | * Created by Phoenix616 on 22.07.2016. 28 | */ 29 | public class InternalHelper_v1_9_R2 implements InternalHelper { 30 | 31 | private WorldResourcepacks plugin; 32 | 33 | public InternalHelper_v1_9_R2(WorldResourcepacks plugin) { 34 | this.plugin = plugin; 35 | } 36 | 37 | @Override 38 | public void setResourcePack(Player player, ResourcePack pack) { 39 | ((CraftPlayer) player).getHandle().setResourcePack(plugin.getPackManager().getPackUrl(pack), pack.getHash()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bukkit/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | bukkit 8 | ${plugin.version} 9 | jar 10 | 11 | 12 | de.themoep.resourcepacksplugin 13 | parent 14 | parent 15 | 16 | 17 | 18 | 19 | spigot-repo 20 | https://hub.spigotmc.org/nexus/content/groups/public/ 21 | 22 | 23 | authme-repo 24 | https://repo.codemc.org/repository/maven-public/ 25 | 26 | 27 | viaversion-repo 28 | https://repo.viaversion.com/everything/ 29 | 30 | 31 | geyser-repo 32 | https://repo.opencollab.dev/maven-snapshots/ 33 | 34 | 35 | nickuc-repo 36 | https://repo.nickuc.com/maven2/ 37 | 38 | 39 | jitpack.io 40 | https://jitpack.io 41 | 42 | 43 | kyngs-repo 44 | https://repo.kyngs.xyz/public 45 | 46 | 47 | 48 | 49 | 50 | org.spigotmc 51 | spigot-api 52 | 1.20.4-R0.1-SNAPSHOT 53 | provided 54 | 55 | 56 | de.themoep.resourcepacksplugin 57 | core 58 | 59 | 60 | de.themoep.utils 61 | lang-bukkit 62 | ${lang.version} 63 | compile 64 | 65 | 66 | de.themoep 67 | minedown 68 | compile 69 | 70 | 71 | com.viaversion 72 | viaversion-common 73 | 74 | 75 | com.github.ProtocolSupport 76 | ProtocolSupport 77 | 6d46fc5164 78 | provided 79 | 80 | 81 | org.geysermc.geyser 82 | api 83 | 84 | 85 | org.geysermc.floodgate 86 | api 87 | 88 | 89 | fr.xephi 90 | authme 91 | 5.6.0-SNAPSHOT 92 | provided 93 | 94 | 95 | com.nickuc.openlogin 96 | openlogin-universal 97 | 98 | 99 | com.nickuc.login 100 | nlogin-api 101 | 102 | 103 | xyz.kyngs.librelogin 104 | API 105 | 106 | 107 | org.bstats 108 | bstats-bukkit-lite 109 | 1.1 110 | compile 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/ConfigAccessor.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit; 2 | 3 | /* 4 | * Copyright (C) 2012 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | import java.io.File; 25 | import java.io.IOException; 26 | import java.io.InputStream; 27 | import java.io.InputStreamReader; 28 | import java.util.logging.Level; 29 | 30 | import org.bukkit.configuration.file.FileConfiguration; 31 | import org.bukkit.configuration.file.YamlConfiguration; 32 | import org.bukkit.plugin.Plugin; 33 | 34 | public class ConfigAccessor { 35 | 36 | private final String fileName; 37 | protected final Plugin plugin; 38 | 39 | private File configFile; 40 | private FileConfiguration fileConfiguration; 41 | private FileConfiguration defaults; 42 | 43 | public ConfigAccessor(Plugin plugin, String fileName) { 44 | if (plugin == null) 45 | throw new IllegalArgumentException("plugin cannot be null"); 46 | this.plugin = plugin; 47 | this.fileName = fileName; 48 | File dataFolder = plugin.getDataFolder(); 49 | if (dataFolder == null) 50 | throw new IllegalStateException(); 51 | this.configFile = new File(plugin.getDataFolder(), fileName); 52 | this.defaults = getDefaults(); 53 | } 54 | 55 | public void reloadConfig() { 56 | fileConfiguration = YamlConfiguration.loadConfiguration(configFile); 57 | 58 | if (defaults != null) { 59 | fileConfiguration.setDefaults(defaults); 60 | } 61 | } 62 | 63 | public FileConfiguration getConfig() { 64 | if (fileConfiguration == null) { 65 | if (defaults != null) { 66 | return defaults; 67 | } else { 68 | reloadConfig(); 69 | } 70 | } 71 | return fileConfiguration; 72 | } 73 | 74 | public FileConfiguration getDefaults() { 75 | if (defaults == null) { 76 | // Look for defaults in the jar 77 | InputStream defConfigStream = plugin.getResource(fileName); 78 | if (defConfigStream != null) { 79 | return YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream)); 80 | } 81 | } 82 | return defaults; 83 | } 84 | 85 | public void saveConfig() { 86 | if (fileConfiguration != null && configFile != null) { 87 | try { 88 | getConfig().save(configFile); 89 | } catch (IOException ex) { 90 | plugin.getLogger().log(Level.SEVERE, "Could not save config to " + configFile, ex); 91 | } 92 | } 93 | } 94 | 95 | public void saveDefaultConfig() { 96 | if (!configFile.exists()) { 97 | this.plugin.saveResource(fileName, false); 98 | } 99 | } 100 | 101 | } 102 | 103 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/ForwardingCommand.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.ResourcepacksPlayer; 22 | import de.themoep.resourcepacksplugin.core.commands.PluginCommandExecutor; 23 | import org.bukkit.command.Command; 24 | import org.bukkit.command.CommandExecutor; 25 | import org.bukkit.command.CommandSender; 26 | import org.bukkit.entity.Player; 27 | 28 | /** 29 | * Created by Phoenix616 on 20.06.2015. 30 | */ 31 | public class ForwardingCommand implements CommandExecutor { 32 | 33 | private final PluginCommandExecutor executor; 34 | 35 | public ForwardingCommand(PluginCommandExecutor executor) { 36 | this.executor = executor; 37 | } 38 | 39 | @Override 40 | public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { 41 | ResourcepacksPlayer s = null; 42 | if (sender instanceof Player) { 43 | s = ((WorldResourcepacks) executor.getPlugin()).getPlayer((Player) sender); 44 | } 45 | executor.execute(s, args); 46 | return true; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/events/ResourcePackSelectEvent.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.events; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.ResourcePack; 22 | import de.themoep.resourcepacksplugin.core.events.IResourcePackSelectEvent; 23 | import org.bukkit.event.Event; 24 | import org.bukkit.event.HandlerList; 25 | 26 | import java.util.List; 27 | import java.util.UUID; 28 | 29 | /** 30 | * Created by Phoenix616 on 18.04.2015. 31 | */ 32 | public class ResourcePackSelectEvent extends Event implements IResourcePackSelectEvent { 33 | private static final HandlerList handlers = new HandlerList(); 34 | 35 | private final UUID playerId; 36 | private List packs; 37 | private Status status; 38 | 39 | public ResourcePackSelectEvent(UUID playerId, List packs) { 40 | this(playerId, packs, packs.isEmpty() ? Status.UNKNOWN : Status.SUCCESS); 41 | } 42 | 43 | public ResourcePackSelectEvent(UUID playerId, List packs, Status status) { 44 | this.playerId = playerId; 45 | this.packs = packs; 46 | this.status = status; 47 | } 48 | 49 | @Override 50 | public UUID getPlayerId() { 51 | return playerId; 52 | } 53 | 54 | @Override 55 | public List getPacks() { 56 | return packs; 57 | } 58 | 59 | @Override 60 | public Status getStatus() { 61 | return status; 62 | } 63 | 64 | @Override 65 | public void setStatus(Status status) { 66 | this.status = status; 67 | if (status != Status.SUCCESS) { 68 | packs.clear(); 69 | } 70 | } 71 | 72 | @Override 73 | public HandlerList getHandlers() { 74 | return handlers; 75 | } 76 | 77 | public static HandlerList getHandlerList() { 78 | return handlers; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/events/ResourcePackSendEvent.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.events; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.ResourcePack; 22 | import de.themoep.resourcepacksplugin.core.events.IResourcePackSendEvent; 23 | import org.bukkit.event.Cancellable; 24 | import org.bukkit.event.Event; 25 | import org.bukkit.event.HandlerList; 26 | 27 | import java.util.UUID; 28 | 29 | /** 30 | * Created by Phoenix616 on 18.04.2015. 31 | */ 32 | public class ResourcePackSendEvent extends Event implements IResourcePackSendEvent, Cancellable { 33 | private static final HandlerList handlers = new HandlerList(); 34 | 35 | private boolean cancelled = false; 36 | private final UUID playerId; 37 | private ResourcePack pack; 38 | 39 | public ResourcePackSendEvent(UUID playerId, ResourcePack pack) { 40 | this.playerId = playerId; 41 | this.pack = pack; 42 | } 43 | 44 | public UUID getPlayerId() { 45 | return playerId; 46 | } 47 | 48 | public ResourcePack getPack() { 49 | return pack; 50 | } 51 | 52 | public void setPack(ResourcePack pack) { 53 | this.pack = pack; 54 | } 55 | 56 | public boolean isCancelled() { 57 | return cancelled; 58 | } 59 | 60 | public void setCancelled(boolean cancelled) { 61 | this.cancelled = cancelled; 62 | } 63 | 64 | @Override 65 | public HandlerList getHandlers() { 66 | return handlers; 67 | } 68 | 69 | public static HandlerList getHandlerList() { 70 | return handlers; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/internal/InternalHelper.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.internal; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.ResourcePack; 22 | import org.bukkit.entity.Player; 23 | 24 | /** 25 | * Created by Phoenix616 on 22.07.2016. 26 | */ 27 | public interface InternalHelper { 28 | 29 | void setResourcePack(Player player, ResourcePack pack); 30 | 31 | default void removeResourcePack(Player player, ResourcePack pack) { 32 | throw new UnsupportedOperationException("This version does not support removing resourcepacks!"); 33 | } 34 | 35 | default void removeResourcePacks(Player player) { 36 | throw new UnsupportedOperationException("This version does not support removing resourcepacks!"); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/internal/InternalHelper_fallback.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.internal; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 22 | import de.themoep.resourcepacksplugin.core.ResourcePack; 23 | import org.bukkit.Bukkit; 24 | import org.bukkit.entity.Player; 25 | 26 | import java.lang.reflect.InvocationTargetException; 27 | import java.lang.reflect.Method; 28 | import java.util.UUID; 29 | import java.util.logging.Level; 30 | 31 | /** 32 | * Created by Phoenix616 on 22.07.2016. 33 | */ 34 | public class InternalHelper_fallback implements InternalHelper { 35 | 36 | private final WorldResourcepacks plugin; 37 | 38 | private Method getHandle = null; 39 | private Method setResourcePack = null; 40 | private boolean hasAddResourcePack = false; 41 | private boolean hasSetIdResourcePack = false; 42 | private boolean hasSetResourcePack = false; 43 | private boolean hasRemoveResourcepacks = true; 44 | 45 | public InternalHelper_fallback(WorldResourcepacks plugin) { 46 | this.plugin = plugin; 47 | try { 48 | hasAddResourcePack = Player.class.getMethod("addResourcePack", UUID.class, String.class, byte[].class, String.class, boolean.class) != null; 49 | } catch (NoSuchMethodException ignored) {} 50 | try { 51 | hasSetIdResourcePack = Player.class.getMethod("setResourcePack", UUID.class, String.class, byte[].class) != null; 52 | } catch (NoSuchMethodException ignored) {} 53 | try { 54 | hasSetResourcePack = Player.class.getMethod("setResourcePack", String.class, byte[].class) != null; 55 | } catch (NoSuchMethodException ignored) {} 56 | 57 | if (!hasAddResourcePack && !hasSetIdResourcePack && !hasSetResourcePack) { 58 | // Old version, methods still not there 59 | String packageName = Bukkit.getServer().getClass().getPackage().getName(); 60 | 61 | try { 62 | Class craftPlayer = Class.forName(packageName + ".entity.CraftPlayer"); 63 | getHandle = craftPlayer.getDeclaredMethod("getHandle"); 64 | 65 | Class entityPlayer = getHandle.getReturnType(); 66 | setResourcePack = entityPlayer.getDeclaredMethod("setResourcePack", String.class, String.class); 67 | 68 | } catch (ClassNotFoundException | NoSuchMethodException e) { 69 | plugin.log(Level.SEVERE, "Unable to find method which enables us to efficiently send a resource pack!", e); 70 | } 71 | } 72 | } 73 | 74 | @Override 75 | public void setResourcePack(Player player, ResourcePack pack) { 76 | if (hasAddResourcePack) { 77 | player.addResourcePack(pack.getUuid(), plugin.getPackManager().getPackUrl(pack), pack.getRawHash(), null, false); 78 | return; 79 | } 80 | 81 | if (hasSetIdResourcePack) { 82 | player.setResourcePack(pack.getUuid(), plugin.getPackManager().getPackUrl(pack), pack.getRawHash(), null, false); 83 | return; 84 | } 85 | 86 | if (hasSetResourcePack) { 87 | player.setResourcePack(plugin.getPackManager().getPackUrl(pack), pack.getRawHash()); 88 | return; 89 | } 90 | 91 | try { 92 | if (getHandle != null && setResourcePack != null) { 93 | Object entityPlayer = getHandle.invoke(player); 94 | setResourcePack.invoke(entityPlayer, plugin.getPackManager().getPackUrl(pack), pack.getHash()); 95 | return; 96 | } 97 | } catch (InvocationTargetException | IllegalAccessException ignored) {} 98 | 99 | player.setResourcePack(plugin.getPackManager().getPackUrl(pack)); 100 | } 101 | 102 | @Override 103 | public void removeResourcePack(Player player, ResourcePack pack) { 104 | try { 105 | if (hasRemoveResourcepacks) { 106 | player.removeResourcePack(pack.getUuid()); 107 | } 108 | } catch (NoSuchMethodError e) { 109 | // Method not found, fallback to old method 110 | hasRemoveResourcepacks = false; 111 | throw new UnsupportedOperationException("This version does not support removing resourcepacks!"); 112 | } 113 | } 114 | 115 | @Override 116 | public void removeResourcePacks(Player player) { 117 | try { 118 | if (hasRemoveResourcepacks) { 119 | player.removeResourcePacks(); 120 | } 121 | } catch (NoSuchMethodError e) { 122 | // Method not found, fallback to old method 123 | hasRemoveResourcepacks = false; 124 | throw new UnsupportedOperationException("This version does not support removing resourcepacks!"); 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/listeners/AuthHandler.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2022 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 22 | import de.themoep.resourcepacksplugin.core.ResourcepacksPlayer; 23 | import org.bukkit.entity.Player; 24 | 25 | public class AuthHandler { 26 | private final WorldResourcepacks plugin; 27 | 28 | public AuthHandler(WorldResourcepacks plugin) { 29 | this.plugin = plugin; 30 | } 31 | 32 | public void onAuth(Player player, boolean sendToProxy) { 33 | if (!plugin.isEnabled() || player == null) 34 | return; 35 | 36 | if (plugin.getConfig().getBoolean("use-auth-plugin", plugin.getConfig().getBoolean("useauth", false))) { 37 | long sendDelay = plugin.getPackManager().getAssignment(player.getWorld().getName()).getSendDelay(); 38 | if (sendDelay < 0) { 39 | sendDelay = plugin.getPackManager().getGlobalAssignment().getSendDelay(); 40 | } 41 | plugin.logDebug(player.getName() + " authenticated! Sending pack in " + sendDelay + " ticks..."); 42 | ResourcepacksPlayer rpPlayer = plugin.getPlayer(player); 43 | if (sendDelay > 0) { 44 | plugin.getServer().getScheduler().runTaskLater(plugin, () -> plugin.getPackManager().applyPack(rpPlayer, player.getWorld().getName()), sendDelay); 45 | } else { 46 | plugin.getPackManager().applyPack(rpPlayer, player.getWorld().getName()); 47 | } 48 | } 49 | 50 | if (sendToProxy) { 51 | plugin.getMessageChannelHandler().sendMessage(player, "authLogin", out -> { 52 | out.writeUTF(player.getName()); 53 | out.writeUTF(player.getUniqueId().toString()); 54 | }); 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/listeners/AuthmeLoginListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 22 | import fr.xephi.authme.events.LoginEvent; 23 | import fr.xephi.authme.events.RegisterEvent; 24 | import org.bukkit.event.EventHandler; 25 | import org.bukkit.event.Listener; 26 | 27 | /** 28 | * Created by Phoenix616 on 24.04.2016. 29 | */ 30 | public class AuthmeLoginListener extends AuthHandler implements Listener { 31 | 32 | public AuthmeLoginListener(WorldResourcepacks plugin) { 33 | super(plugin); 34 | } 35 | 36 | /** 37 | * Send a plugin message to the Bungee when a player logged into AuthMe 38 | * @param event AuthMe's LoginEvent 39 | */ 40 | @EventHandler 41 | public void onAuthMeLogin(LoginEvent event) { 42 | onAuth(event.getPlayer(), true); 43 | } 44 | 45 | /** 46 | * Send a plugin message to the Bungee when a player registered with AuthMe. 47 | * This just auto-logins the player so treat it the same way. 48 | * For some reason that doesn't call the login event... 49 | * @param event AuthMe's RegisterEvent 50 | */ 51 | @EventHandler 52 | public void onAuthMeLogin(RegisterEvent event) { 53 | onAuth(event.getPlayer(), true); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/listeners/ConnectListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2024 Max Lee aka Phoenix616 (max@themoep.de) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 22 | import org.bukkit.event.EventHandler; 23 | import org.bukkit.event.EventPriority; 24 | import org.bukkit.event.Listener; 25 | import org.bukkit.event.player.PlayerLoginEvent; 26 | 27 | /** 28 | * Created by Phoenix616 on 14.05.2015. 29 | */ 30 | public class ConnectListener implements Listener { 31 | 32 | private final WorldResourcepacks plugin; 33 | 34 | public ConnectListener(WorldResourcepacks plugin) { 35 | this.plugin = plugin; 36 | } 37 | 38 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) 39 | public void onPlayerConnect(PlayerLoginEvent event) { 40 | if (plugin.isEnabled()) { 41 | plugin.getUserManager().onConnect(event.getPlayer().getUniqueId()); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/listeners/DisconnectListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 22 | import org.bukkit.event.EventHandler; 23 | import org.bukkit.event.Listener; 24 | import org.bukkit.event.player.PlayerQuitEvent; 25 | 26 | /** 27 | * Created by Phoenix616 on 14.05.2015. 28 | */ 29 | public class DisconnectListener implements Listener { 30 | 31 | private WorldResourcepacks plugin; 32 | 33 | public DisconnectListener(WorldResourcepacks plugin) { 34 | this.plugin = plugin; 35 | } 36 | 37 | @EventHandler 38 | public void onPlayerDisconnect(PlayerQuitEvent event) { 39 | if(plugin.isEnabled()) { 40 | plugin.getUserManager().onDisconnect(event.getPlayer().getUniqueId()); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/listeners/LibreLoginListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2023 Max Lee aka Phoenix616 (max@themoep.de) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 22 | import org.bukkit.World; 23 | import org.bukkit.entity.Player; 24 | import org.bukkit.event.Listener; 25 | import xyz.kyngs.librelogin.api.LibreLoginPlugin; 26 | 27 | /** 28 | * Created by Phoenix616 on 24.04.2016. 29 | */ 30 | public class LibreLoginListener extends AuthHandler implements Listener { 31 | 32 | public LibreLoginListener(WorldResourcepacks plugin, LibreLoginPlugin libreLogin) { 33 | super(plugin); 34 | libreLogin.getEventProvider() 35 | .subscribe(libreLogin.getEventProvider().getTypes().authenticated, event -> onAuth(event.getPlayer(), false)); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/listeners/NLoginListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2021 Max Lee aka Phoenix616 (max@themoep.de) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.nickuc.login.api.event.bukkit.auth.AuthenticateEvent;; 22 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 23 | import org.bukkit.event.EventHandler; 24 | import org.bukkit.event.Listener; 25 | 26 | /** 27 | * Created by Phoenix616 on 24.04.2016. 28 | */ 29 | public class NLoginListener extends AuthHandler implements Listener { 30 | 31 | public NLoginListener(WorldResourcepacks plugin) { 32 | super(plugin); 33 | } 34 | 35 | /** 36 | * Doesn't send message to Bungee as NLogin supports it natively 37 | * @param event nLogin's auth event 38 | */ 39 | @EventHandler 40 | public void onNLoginAuth(AuthenticateEvent event) { 41 | onAuth(event.getPlayer(), false); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/listeners/OpeNLoginListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2021 Max Lee aka Phoenix616 (max@themoep.de) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.nickuc.openlogin.bukkit.api.events.AsyncAuthenticateEvent; 22 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 23 | import org.bukkit.event.EventHandler; 24 | import org.bukkit.event.Listener; 25 | 26 | /** 27 | * Created by Phoenix616 on 24.04.2016. 28 | */ 29 | public class OpeNLoginListener extends AuthHandler implements Listener { 30 | 31 | public OpeNLoginListener(WorldResourcepacks plugin) { 32 | super(plugin); 33 | } 34 | 35 | /** 36 | * Send a plugin message to the Bungee when a player logged into OpeNLogin on subchannel authMeLogin with the name and UUID 37 | * @param event OpeNLogin's auth event 38 | */ 39 | @EventHandler 40 | public void onOpeNLoginAuth(AsyncAuthenticateEvent event) { 41 | onAuth(event.getPlayer(), true); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/listeners/ProxyPackListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.ConfigAccessor; 22 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 23 | import de.themoep.resourcepacksplugin.core.ResourcePack; 24 | import de.themoep.resourcepacksplugin.core.SubChannelHandler; 25 | import org.bukkit.entity.Player; 26 | import org.bukkit.event.EventHandler; 27 | import org.bukkit.event.Listener; 28 | import org.bukkit.event.player.PlayerJoinEvent; 29 | import org.bukkit.plugin.messaging.PluginMessageListener; 30 | 31 | import java.util.UUID; 32 | import java.util.logging.Level; 33 | 34 | /** 35 | * Created by Phoenix616 on 02.02.2016. 36 | */ 37 | public class ProxyPackListener extends SubChannelHandler implements PluginMessageListener, Listener { 38 | 39 | private final WorldResourcepacks plugin; 40 | 41 | private final ConfigAccessor keyConfig; 42 | 43 | private boolean playerJoined = false; 44 | 45 | public ProxyPackListener(WorldResourcepacks plugin) { 46 | super(plugin); 47 | this.plugin = plugin; 48 | plugin.getServer().getPluginManager().registerEvents(this, plugin); 49 | keyConfig = new ConfigAccessor(plugin, "key.yml"); 50 | registerSubChannel("removePackRequest", (p, in) -> { 51 | String playerName = in.readUTF(); 52 | UUID playerUuid = new UUID(in.readLong(), in.readLong()); 53 | 54 | ResourcePack pack = readPack(in); 55 | if (pack == null) { 56 | plugin.logDebug("Proxy sent command to send a pack removal request for an unknown pack for player " + playerName + "?"); 57 | return; 58 | } 59 | 60 | Player player = plugin.getServer().getPlayer(playerUuid); 61 | if (player == null || !player.isOnline()) { 62 | plugin.logDebug("Proxy sent command to send a pack removal request for pack " + pack.getName() + "/" + pack.getUuid() + " of player " + playerName + " but they aren't online?"); 63 | return; 64 | } 65 | if (pack.equals(plugin.getPackManager().getEmptyPack())) { 66 | plugin.logDebug("Proxy sent command to send a pack removal request for all packs for player " + playerName); 67 | plugin.removePacks(playerUuid); 68 | return; 69 | } 70 | plugin.logDebug("Proxy send command to send a pack removal request for pack " + pack.getName() + "/" + pack.getUuid() + " for player " + playerName); 71 | try { 72 | plugin.removePack(player, pack); 73 | } catch (UnsupportedOperationException unsupported) { 74 | plugin.logDebug("Proxy sent command to send a pack removal request for pack " + pack.getName() + "/" + pack.getUuid() + " for player " + playerName + " but the server doesn't support it?"); 75 | } 76 | }); 77 | } 78 | 79 | @Override 80 | public void onPluginMessageReceived(String channel, Player p, byte[] message) { 81 | if (!plugin.isEnabled() || !channel.equals("rp:plugin")) { 82 | return; 83 | } 84 | 85 | handleMessage(p, message); 86 | } 87 | 88 | @EventHandler 89 | public void onPlayerJoin(PlayerJoinEvent event) { 90 | if (playerJoined) { 91 | if (acceptsNewKey()) { 92 | setKey(""); 93 | } 94 | } else { 95 | playerJoined = true; 96 | } 97 | } 98 | 99 | @Override 100 | protected void sendPluginMessage(Player target, byte[] data) { 101 | try { 102 | target.sendPluginMessage(plugin, MESSAGING_CHANNEL, data); 103 | } catch (Exception e) { 104 | plugin.log(Level.WARNING, "Failed to send plugin message to " + getTargetType() + " (via " + target.getName() + " connection)!" + 105 | " This is most likely because the player connection timed out. " + e.getMessage()); 106 | plugin.logDebug("Plugin message sending error:", e); 107 | } 108 | } 109 | 110 | @Override 111 | protected void saveKey(String key) { 112 | keyConfig.getConfig().set("key", key); 113 | keyConfig.saveConfig(); 114 | } 115 | 116 | @Override 117 | protected String loadKey() { 118 | keyConfig.reloadConfig(); 119 | return keyConfig.getConfig().getString("key", null); 120 | } 121 | 122 | @Override 123 | protected String getTargetType() { 124 | return "proxy"; 125 | } 126 | 127 | @Override 128 | protected boolean trustsSender() { 129 | return false; 130 | } 131 | } -------------------------------------------------------------------------------- /bukkit/src/main/java/de/themoep/resourcepacksplugin/bukkit/listeners/WorldSwitchListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bukkit.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bukkit 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks; 22 | import org.bukkit.entity.Player; 23 | import org.bukkit.event.EventHandler; 24 | import org.bukkit.event.Listener; 25 | import org.bukkit.event.player.PlayerChangedWorldEvent; 26 | import org.bukkit.event.player.PlayerJoinEvent; 27 | import org.bukkit.scheduler.BukkitRunnable; 28 | 29 | import java.util.UUID; 30 | 31 | /** 32 | * Created by Phoenix616 on 14.05.2015. 33 | */ 34 | public class WorldSwitchListener implements Listener { 35 | 36 | private final WorldResourcepacks plugin; 37 | 38 | public WorldSwitchListener(WorldResourcepacks plugin) { 39 | this.plugin = plugin; 40 | } 41 | 42 | @EventHandler 43 | public void onWorldSwitch(PlayerChangedWorldEvent event) { 44 | handleEvent(event.getPlayer()); 45 | } 46 | 47 | @EventHandler 48 | public void onPlayerJoin(PlayerJoinEvent event) { 49 | handleEvent(event.getPlayer()); 50 | } 51 | 52 | private void handleEvent(Player player) { 53 | final UUID playerId = player.getUniqueId(); 54 | 55 | long sendDelay = -1; 56 | if (player.getWorld() != null) { 57 | sendDelay = plugin.getPackManager().getAssignment(player.getWorld().getName()).getSendDelay(); 58 | } 59 | if (sendDelay < 0) { 60 | sendDelay = plugin.getPackManager().getGlobalAssignment().getSendDelay(); 61 | } 62 | 63 | if (sendDelay > 0) { 64 | plugin.getServer().getScheduler().runTaskLater(plugin, () -> calculatePack(playerId), sendDelay); 65 | } else { 66 | calculatePack(playerId); 67 | } 68 | } 69 | 70 | private void calculatePack(UUID playerId) { 71 | if (plugin.isEnabled()) { 72 | if (!plugin.isAuthenticated(playerId)) { 73 | plugin.logDebug("Player " + playerId + " is not authenticated, not attempting to send a pack yet."); 74 | return; 75 | } 76 | Player player = plugin.getServer().getPlayer(playerId); 77 | if(player != null) { 78 | String worldName = ""; 79 | if(player.getWorld() != null) { 80 | worldName = player.getWorld().getName(); 81 | } 82 | plugin.getPackManager().applyPack(plugin.getPlayer(player), worldName); 83 | } 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /bukkit/src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | debug: true 2 | # Default language 3 | default-language: en 4 | # Disable all metrics included in this plugin. 5 | disable-metrics: false 6 | # Whether or not resourcepack file hashes should be generated on startup: 7 | autogeneratehashes: true 8 | # Whether to append the pack hash to the end of the URL of the pack like url#hash. 9 | # This is necessary to work around a Vanilla bug which prevents changed packs from being downloaded 10 | # properly again: https://bugs.mojang.com/browse/MC-164316 11 | append-hash-to-url: true 12 | # Whether /usepack should apply packs temporary or permanent when run without any argument: 13 | usepack-is-temporary: true 14 | # Whether packs that a player has stored will override a matched assignments 15 | stored-packs-override-assignments: false 16 | # When manually setting a permanent pack then it will be reset if the user disconnects in under x amount of seconds. 17 | # 0 or anything below will disable this functionality 18 | permanent-pack-remove-time: 30 19 | # Whether to hook into authentication plugins 20 | # Currently supported: AuthMe, OpeNLogin and nLogin 21 | use-auth-plugin: true 22 | # Different packs can be defined in this section 23 | packs: 24 | examplepack: 25 | # The url the client should download the resourcepack from. 26 | # Has to be a direct download link! No mediafire/mega/other oneclick-hoster! 27 | url: http://example.com/lobbyresourcepack.zip 28 | # The sha1 hash of the resourcepack's zip file, 29 | # Not supported by bukkit so it currently does not matter what you write here! 30 | hash: abcdef012345678abcdef012345678abcdef0123 31 | # The format version of this resourcepack 32 | format: 1 33 | # Directly define the Minecraft version instead of the format 34 | # Supports string representation of the versions and protocol numbers 35 | # You don't need to define both the version and the format (if so then the highest one will take effect) 36 | version: "1.8" 37 | # Whether or not this pack will only be send to players with a certain permission 38 | # permission: worldresourcepacks.pack. 39 | restricted: false 40 | # If you want you can define a specific permission for this pack if you don't want 41 | # the default worldresourcepacks.pack. permission! 42 | permission: worldresourcepacks.pack.examplepack 43 | globalpack: 44 | url: http://example.com/globalpack.zip 45 | hash: abcdef012345678abcdef012345678abcdef0123 46 | gamepack: 47 | # Set different variants e.g. for different versions or permissions 48 | # This list supports all normal pack settings and is checked top to bottom. 49 | # The first one that matches the player will be used. 50 | variants: 51 | - url: http://example.com/minigameresourcepack_1_15.zip 52 | hash: 012345678abcdef012345678abcdef012345678a 53 | version: '1.15' 54 | - url: http://example.com/minigameresourcepack_1_12.zip 55 | hash: 012345678abcdef01234567dddcdef012345678a 56 | version: '1.12' 57 | # Define as many packs as you want 58 | another_example_pack: 59 | url: http://example.com/another.zip 60 | hash: abcdef012345678abcdef012345678abcdef0123 61 | # Empty pack to reset the pack to the default one 62 | empty: 63 | url: http://cdn.moep.tv/files/Empty.zip 64 | hash: 01517226212d27586ea0c5d6aff1aa5492dd2484 65 | global: 66 | pack: globalpack 67 | # List of packs to not replace if the user already has them 68 | # If no main pack is set the first one also gets used to reset 69 | # the pack if the user has a non-optional one 70 | # Also this list will be used to select a pack if a user does not have the permission 71 | # or the right version to use that pack. (From top to bottom) 72 | #optional-packs: 73 | #- examplepack2 74 | # Delay in ticks before sending the pack to a player after he logs in/switches to the world 75 | send-delay: 10 76 | # Different worlds with different packs can be defined here 77 | worlds: 78 | # Config for a world named "your_example_world" 79 | your_example_world: 80 | # You can define multiple packs starting with 1.20.3 81 | # On versions prior to it only the first pack will be used 82 | packs: 83 | - examplepack 84 | - globalpack 85 | #optional-packs: 86 | #- examplepack2 87 | your_example_nether: 88 | pack: examplepack2 89 | # Use a regex to target all worlds with a certain name 90 | regex: 'example_nether_.*' 91 | # Define as many worlds as you want. 92 | # The name of the section is the world name unless a regex is specified. 93 | another_example_world: 94 | pack: another_example_pack 95 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/ForwardingCommand.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.ResourcepacksPlayer; 22 | import de.themoep.resourcepacksplugin.core.commands.PluginCommandExecutor; 23 | import net.md_5.bungee.api.CommandSender; 24 | import net.md_5.bungee.api.connection.ProxiedPlayer; 25 | import net.md_5.bungee.api.plugin.Command; 26 | 27 | public class ForwardingCommand extends Command { 28 | private final PluginCommandExecutor executor; 29 | 30 | public ForwardingCommand(PluginCommandExecutor executor) { 31 | super(executor.getName(), executor.getPermission(), executor.getAliases()); 32 | this.executor = executor; 33 | } 34 | 35 | @Override 36 | public void execute(CommandSender sender, String[] args) { 37 | ResourcepacksPlayer s = null; 38 | if(sender instanceof ProxiedPlayer) { 39 | s = ((BungeeResourcepacks) executor.getPlugin()).getPlayer((ProxiedPlayer) sender); 40 | } 41 | executor.execute(s, args); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/events/ResourcePackSelectEvent.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee.events; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.ResourcePack; 22 | import de.themoep.resourcepacksplugin.core.events.IResourcePackSelectEvent; 23 | import net.md_5.bungee.api.plugin.Event; 24 | 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | import java.util.UUID; 28 | 29 | /** 30 | * Created by Phoenix616 on 18.04.2015. 31 | */ 32 | public class ResourcePackSelectEvent extends Event implements IResourcePackSelectEvent { 33 | private final UUID playerId; 34 | private List packs; 35 | private Status status; 36 | 37 | public ResourcePackSelectEvent(UUID playerId, ResourcePack pack) { 38 | this.playerId = playerId; 39 | setPack(pack); 40 | } 41 | 42 | public ResourcePackSelectEvent(UUID playerId, List packs, Status status) { 43 | this.playerId = playerId; 44 | this.packs = new ArrayList<>(packs); 45 | this.status = status; 46 | } 47 | 48 | @Override 49 | public UUID getPlayerId() { 50 | return playerId; 51 | } 52 | 53 | @Override 54 | public List getPacks() { 55 | return packs; 56 | } 57 | 58 | @Override 59 | public Status getStatus() { 60 | return status; 61 | } 62 | 63 | @Override 64 | public void setStatus(Status status) { 65 | this.status = status; 66 | if (status != Status.SUCCESS) { 67 | packs.clear(); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/events/ResourcePackSendEvent.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee.events; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.ResourcePack; 22 | import de.themoep.resourcepacksplugin.core.events.IResourcePackSendEvent; 23 | import net.md_5.bungee.api.plugin.Cancellable; 24 | import net.md_5.bungee.api.plugin.Event; 25 | 26 | import java.util.UUID; 27 | 28 | 29 | /** 30 | * Created by Phoenix616 on 18.04.2015. 31 | */ 32 | public class ResourcePackSendEvent extends Event implements IResourcePackSendEvent, Cancellable { 33 | 34 | private boolean cancelled = false; 35 | private final UUID playerId; 36 | private ResourcePack pack; 37 | 38 | public ResourcePackSendEvent(UUID playerId, ResourcePack pack) { 39 | this.playerId = playerId; 40 | this.pack = pack; 41 | } 42 | 43 | public UUID getPlayerId() { 44 | return playerId; 45 | } 46 | 47 | public ResourcePack getPack() { 48 | return pack; 49 | } 50 | 51 | public void setPack(ResourcePack pack) { 52 | this.pack = pack; 53 | } 54 | 55 | public boolean isCancelled() { 56 | return cancelled; 57 | } 58 | 59 | public void setCancelled(boolean cancelled) { 60 | this.cancelled = cancelled; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/listeners/AuthHandler.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2022 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bungee.BungeeResourcepacks; 22 | import de.themoep.resourcepacksplugin.core.ResourcepacksPlayer; 23 | import net.md_5.bungee.api.connection.ProxiedPlayer; 24 | 25 | import java.util.concurrent.TimeUnit; 26 | 27 | public class AuthHandler { 28 | protected final BungeeResourcepacks plugin; 29 | 30 | public AuthHandler(BungeeResourcepacks plugin) { 31 | this.plugin = plugin; 32 | } 33 | 34 | public void onAuth(ProxiedPlayer player) { 35 | if (!plugin.isEnabled() || player == null) 36 | return; 37 | 38 | plugin.setAuthenticated(player.getUniqueId(), true); 39 | if (!plugin.hasBackend(player.getUniqueId()) && plugin.getConfig().getBoolean("use-auth-plugin", plugin.getConfig().getBoolean("useauth", false))) { 40 | String serverName = ""; 41 | if (player.getServer() != null) { 42 | serverName = player.getServer().getInfo().getName(); 43 | } 44 | long sendDelay = plugin.getPackManager().getAssignment(serverName).getSendDelay(); 45 | if (sendDelay < 0) { 46 | sendDelay = plugin.getPackManager().getGlobalAssignment().getSendDelay(); 47 | } 48 | plugin.logDebug(player.getName() + " authenticated on the backend server " + serverName + "! Sending pack in " + sendDelay + " ticks..."); 49 | ResourcepacksPlayer rpPlayer = plugin.getPlayer(player); 50 | if (sendDelay > 0) { 51 | String finalServerName = serverName; 52 | plugin.getProxy().getScheduler().schedule(plugin, () -> plugin.getPackManager().applyPack(rpPlayer, finalServerName), sendDelay * 20, TimeUnit.MILLISECONDS); 53 | } else { 54 | plugin.getPackManager().applyPack(rpPlayer, serverName); 55 | } 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/listeners/ConnectListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2024 Max Lee aka Phoenix616 (max@themoep.de) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bungee.BungeeResourcepacks; 22 | import net.md_5.bungee.api.event.LoginEvent; 23 | import net.md_5.bungee.api.plugin.Listener; 24 | import net.md_5.bungee.event.EventHandler; 25 | import net.md_5.bungee.event.EventPriority; 26 | 27 | public class ConnectListener implements Listener { 28 | 29 | private final BungeeResourcepacks plugin; 30 | 31 | public ConnectListener(BungeeResourcepacks plugin) { 32 | this.plugin = plugin; 33 | } 34 | 35 | @EventHandler(priority = EventPriority.HIGHEST) 36 | public void onPlayerConnect(LoginEvent event) { 37 | if (plugin.isEnabled() && !event.isCancelled()) { 38 | plugin.getUserManager().onConnect(event.getConnection().getUniqueId()); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/listeners/DisconnectListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bungee.BungeeResourcepacks; 22 | import net.md_5.bungee.api.event.PlayerDisconnectEvent; 23 | import net.md_5.bungee.api.plugin.Listener; 24 | import net.md_5.bungee.event.EventHandler; 25 | 26 | /** 27 | * Created by Phoenix616 on 14.05.2015. 28 | */ 29 | public class DisconnectListener implements Listener { 30 | 31 | private BungeeResourcepacks plugin; 32 | 33 | public DisconnectListener(BungeeResourcepacks plugin) { 34 | this.plugin = plugin; 35 | } 36 | 37 | @EventHandler 38 | public void onPlayerDisconnect(PlayerDisconnectEvent event) { 39 | if(plugin.isEnabled()) { 40 | plugin.getUserManager().onDisconnect(event.getPlayer().getUniqueId()); 41 | plugin.setAuthenticated(event.getPlayer().getUniqueId(), false); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/listeners/JPremiumListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2022 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.jakub.premium.api.event.UserEvent; 22 | import de.themoep.resourcepacksplugin.bungee.BungeeResourcepacks; 23 | import net.md_5.bungee.api.plugin.Listener; 24 | import net.md_5.bungee.event.EventHandler; 25 | 26 | public class JPremiumListener extends AuthHandler implements Listener { 27 | 28 | public JPremiumListener(BungeeResourcepacks plugin) { 29 | super(plugin); 30 | } 31 | 32 | @EventHandler 33 | public void onAuth(UserEvent.Login event) { 34 | onAuth(event.getUserProfile().getProxiedPlayer()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/listeners/LibreLoginListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2022 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bungee.BungeeResourcepacks; 22 | import net.md_5.bungee.api.config.ServerInfo; 23 | import net.md_5.bungee.api.connection.ProxiedPlayer; 24 | import net.md_5.bungee.api.plugin.Plugin; 25 | import xyz.kyngs.librelogin.api.event.EventProvider; 26 | import xyz.kyngs.librelogin.api.provider.LibreLoginProvider; 27 | 28 | public class LibreLoginListener extends AuthHandler { 29 | 30 | public LibreLoginListener(BungeeResourcepacks plugin, Plugin libreLogin) { 31 | super(plugin); 32 | EventProvider eventProvider = ((LibreLoginProvider) libreLogin).getLibreLogin().getEventProvider(); 33 | eventProvider.subscribe(eventProvider.getTypes().authenticated, event -> onAuth(event.getPlayer())); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/listeners/LibrePremiumListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2022 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bungee.BungeeResourcepacks; 22 | import net.md_5.bungee.api.config.ServerInfo; 23 | import net.md_5.bungee.api.connection.ProxiedPlayer; 24 | import net.md_5.bungee.api.plugin.Plugin; 25 | import xyz.kyngs.librepremium.api.event.events.AuthenticatedEvent; 26 | import xyz.kyngs.librepremium.api.provider.LibrePremiumProvider; 27 | 28 | public class LibrePremiumListener extends AuthHandler { 29 | 30 | public LibrePremiumListener(BungeeResourcepacks plugin, Plugin librePremium) { 31 | super(plugin); 32 | ((LibrePremiumProvider) librePremium).getLibrePremium().getEventProvider() 33 | .subscribe(AuthenticatedEvent.class, event -> onAuth((ProxiedPlayer) event.getPlayer())); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/listeners/NLoginListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2022 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.nickuc.login.api.event.bungee.auth.AuthenticateEvent; 22 | import de.themoep.resourcepacksplugin.bungee.BungeeResourcepacks; 23 | import net.md_5.bungee.api.plugin.Listener; 24 | import net.md_5.bungee.event.EventHandler; 25 | 26 | public class NLoginListener extends AuthHandler implements Listener { 27 | 28 | public NLoginListener(BungeeResourcepacks plugin) { 29 | super(plugin); 30 | } 31 | 32 | @EventHandler 33 | public void onAuth(AuthenticateEvent event) { 34 | onAuth(event.getPlayer()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/listeners/PluginMessageListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.bungeeplugin.FileConfiguration; 22 | import de.themoep.resourcepacksplugin.bungee.BungeeResourcepacks; 23 | import de.themoep.resourcepacksplugin.core.SubChannelHandler; 24 | import net.md_5.bungee.api.connection.ProxiedPlayer; 25 | import net.md_5.bungee.api.connection.Server; 26 | import net.md_5.bungee.api.event.PluginMessageEvent; 27 | import net.md_5.bungee.api.event.ServerConnectedEvent; 28 | import net.md_5.bungee.api.plugin.Listener; 29 | import net.md_5.bungee.event.EventHandler; 30 | import net.md_5.bungee.event.EventPriority; 31 | 32 | import java.io.File; 33 | import java.io.IOException; 34 | import java.util.UUID; 35 | import java.util.logging.Level; 36 | 37 | public class PluginMessageListener extends SubChannelHandler implements Listener { 38 | private final BungeeResourcepacks plugin; 39 | private FileConfiguration keyConfig; 40 | private final AuthHandler authHandler; 41 | 42 | public PluginMessageListener(BungeeResourcepacks plugin) { 43 | super(plugin); 44 | this.plugin = plugin; 45 | File keyFile = new File(plugin.getDataFolder(), "key.yml"); 46 | try { 47 | keyConfig = new FileConfiguration(plugin, keyFile); 48 | } catch (IOException e) { 49 | plugin.log(Level.SEVERE, "Unable to create key.yml! " + e.getMessage()); 50 | } 51 | authHandler = new AuthHandler(plugin); 52 | registerSubChannel("authLogin", (s, in) -> { 53 | String playerName = in.readUTF(); 54 | UUID playerId = UUID.fromString(in.readUTF()); 55 | ProxiedPlayer player = plugin.getProxy().getPlayer(playerId); 56 | if (player != null && !plugin.isAuthenticated(playerId)) { 57 | authHandler.onAuth(player); 58 | } 59 | }); 60 | } 61 | 62 | @EventHandler 63 | public void pluginMessageReceived(PluginMessageEvent event) { 64 | if (!plugin.isEnabled() || !event.getTag().equals(MESSAGING_CHANNEL)) 65 | return; 66 | 67 | event.setCancelled(true); 68 | if (event.getSender() instanceof Server) { 69 | handleMessage((Server) event.getSender(), event.getData()); 70 | } else { 71 | plugin.logDebug("Received plugin message from " + event.getSender() + " which is not a ServerConnection!"); 72 | } 73 | } 74 | 75 | @EventHandler(priority = EventPriority.LOWEST) 76 | public void onServerSwitch(ServerConnectedEvent event) { 77 | if (plugin.isEnabled()) { 78 | sendKey(event.getServer()); 79 | } 80 | } 81 | 82 | @Override 83 | protected void sendPluginMessage(Server target, byte[] data) { 84 | try { 85 | target.sendData(MESSAGING_CHANNEL, data); 86 | } catch (Exception e) { 87 | plugin.log(Level.WARNING, "Failed to send plugin message to server " + target.getInfo().getName() + "! This is most likely because the player connection timed out. " + e.getMessage()); 88 | plugin.logDebug("Plugin message sending error:", e); 89 | } 90 | } 91 | 92 | @Override 93 | protected void saveKey(String key) { 94 | if (keyConfig != null) { 95 | keyConfig.set("key", key); 96 | keyConfig.saveConfig(); 97 | } 98 | } 99 | 100 | @Override 101 | protected String loadKey() { 102 | String key = null; 103 | if (keyConfig != null) { 104 | try { 105 | if (keyConfig.loadConfig()) { 106 | key = keyConfig.getString("key", null); 107 | } 108 | } catch (IOException e) { 109 | plugin.log(Level.SEVERE, "Error while loading key.yml! " + e.getMessage()); 110 | } 111 | if (key == null) { 112 | key = generateKey(); 113 | saveKey(key); 114 | } 115 | } 116 | return key; 117 | } 118 | 119 | @Override 120 | protected String getTargetType() { 121 | return "Minecraft server"; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/listeners/ServerSwitchListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bungee.BungeeResourcepacks; 22 | import de.themoep.resourcepacksplugin.core.MinecraftVersion; 23 | import de.themoep.resourcepacksplugin.core.ResourcePack; 24 | import net.md_5.bungee.api.connection.ProxiedPlayer; 25 | import net.md_5.bungee.api.event.ServerSwitchEvent; 26 | import net.md_5.bungee.api.plugin.Listener; 27 | import net.md_5.bungee.event.EventHandler; 28 | 29 | import java.util.List; 30 | import java.util.UUID; 31 | import java.util.concurrent.TimeUnit; 32 | 33 | /** 34 | * Created by Phoenix616 on 14.05.2015. 35 | */ 36 | public class ServerSwitchListener implements Listener { 37 | 38 | private final BungeeResourcepacks plugin; 39 | 40 | public ServerSwitchListener(BungeeResourcepacks plugin) { 41 | this.plugin = plugin; 42 | } 43 | 44 | @EventHandler 45 | public void onServerSwitch(ServerSwitchEvent event) { 46 | if (plugin.isEnabled()) { 47 | final UUID playerId = event.getPlayer().getUniqueId(); 48 | plugin.unsetBackend(playerId); 49 | 50 | plugin.sendPackInfo(playerId); 51 | 52 | if (plugin.getPlayerProtocol(playerId) == MinecraftVersion.MINECRAFT_1_20_2.getProtocolNumber()) { 53 | // In 1.20.2 the pack needs to be resent on server switch -> we remove the user pack which forces a resend 54 | plugin.getUserManager().clearUserPacks(playerId); 55 | } 56 | 57 | long sendDelay = -1; 58 | if (event.getPlayer().getServer() != null) { 59 | sendDelay = plugin.getPackManager().getAssignment(event.getPlayer().getServer().getInfo().getName()).getSendDelay(); 60 | } 61 | if (sendDelay < 0) { 62 | sendDelay = plugin.getPackManager().getGlobalAssignment().getSendDelay(); 63 | } 64 | 65 | if (sendDelay > 0) { 66 | plugin.getProxy().getScheduler().schedule(plugin, () -> calculatePack(playerId), sendDelay * 50, TimeUnit.MILLISECONDS); 67 | } else { 68 | calculatePack(playerId); 69 | } 70 | } 71 | } 72 | 73 | private void calculatePack(UUID playerId) { 74 | if (plugin.hasBackend(playerId)) { 75 | plugin.logDebug("Player " + playerId + " has backend pack, not attempting to send a new one."); 76 | return; 77 | } 78 | if (!plugin.isAuthenticated(playerId)) { 79 | plugin.logDebug("Player " + playerId + " is not authenticated, not attempting to send a pack yet."); 80 | return; 81 | } 82 | ProxiedPlayer player = plugin.getProxy().getPlayer(playerId); 83 | if(player != null) { 84 | String serverName = ""; 85 | if(player.getServer() != null) { 86 | serverName = player.getServer().getInfo().getName(); 87 | } 88 | plugin.getPackManager().applyPack(plugin.getPlayer(player), serverName); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/packets/IdMapping.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee.packets; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | public class IdMapping { 22 | private final String name; 23 | private final int protocolVersion; 24 | private final int packetId; 25 | 26 | public IdMapping(String name, int protocolVersion, int packetId) { 27 | this.name = name; 28 | this.protocolVersion = protocolVersion; 29 | this.packetId = packetId; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public int getProtocolVersion() { 37 | return protocolVersion; 38 | } 39 | 40 | public int getPacketId() { 41 | return packetId; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bungee/src/main/java/de/themoep/resourcepacksplugin/bungee/packets/ResourcePackRemovePacket.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.bungee.packets; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.bungee.BungeeResourcepacks; 22 | import de.themoep.resourcepacksplugin.core.ResourcePack; 23 | import io.netty.buffer.ByteBuf; 24 | import io.netty.buffer.Unpooled; 25 | import net.md_5.bungee.UserConnection; 26 | import net.md_5.bungee.connection.DownstreamBridge; 27 | import net.md_5.bungee.netty.PacketHandler; 28 | import net.md_5.bungee.protocol.AbstractPacketHandler; 29 | import net.md_5.bungee.protocol.DefinedPacket; 30 | import net.md_5.bungee.protocol.PacketWrapper; 31 | import net.md_5.bungee.protocol.Protocol; 32 | import net.md_5.bungee.protocol.ProtocolConstants; 33 | 34 | import java.beans.ConstructorProperties; 35 | import java.lang.reflect.Field; 36 | import java.nio.ByteBuffer; 37 | import java.util.Objects; 38 | import java.util.Optional; 39 | import java.util.UUID; 40 | import java.util.logging.Level; 41 | 42 | /** 43 | * Created by Phoenix616 on 24.03.2015. 44 | */ 45 | public class ResourcePackRemovePacket extends DefinedPacket { 46 | 47 | private Optional uuid = Optional.empty(); 48 | 49 | public ResourcePackRemovePacket() {}; 50 | 51 | private static Field conField = null; 52 | 53 | static { 54 | try { 55 | conField = DownstreamBridge.class.getDeclaredField("con"); 56 | conField.setAccessible(true); 57 | } catch (NoSuchFieldException e) { 58 | BungeeResourcepacks.getInstance().getLogger().log(Level.SEVERE, "Error while trying to get the UserConnection field from the DownstreamBridge object. Is the plugin up to date?"); 59 | } 60 | } 61 | 62 | @ConstructorProperties({"uuid"}) 63 | public ResourcePackRemovePacket(UUID uuid) { 64 | this.uuid = Optional.of(uuid); 65 | } 66 | 67 | @Override 68 | public void handle(AbstractPacketHandler handler) throws Exception { 69 | if (handler instanceof DownstreamBridge) { 70 | if (conField != null) { 71 | DownstreamBridge bridge = (DownstreamBridge) handler; 72 | try { 73 | UserConnection userConnection = (UserConnection) conField.get(bridge); 74 | updatePlayer(userConnection); 75 | PacketWrapper packetWrapper = new PacketWrapper(this, Unpooled.copiedBuffer(ByteBuffer.allocate(Short.MAX_VALUE)), userConnection.getCh().getEncodeProtocol()); 76 | userConnection.getPendingConnection().handle(packetWrapper); 77 | } catch (IllegalAccessException e) { 78 | BungeeResourcepacks.getInstance().getLogger().log(Level.WARNING, "Sorry but you are not allowed to do this.", e); 79 | } 80 | } 81 | } else { 82 | BungeeResourcepacks.getInstance().logDebug("Sending ResourcePackSend packets to " + handler.getClass().getName() + " is not properly supported by this plugin! (Only players) Trying to handle anyways..."); 83 | if (handler instanceof PacketHandler) { 84 | ((PacketHandler) handler).handle(new PacketWrapper(this, Unpooled.copiedBuffer(ByteBuffer.allocate(Short.MAX_VALUE)), Protocol.GAME)); 85 | } else if (BungeeResourcepacks.getInstance().getLogLevel().intValue() >= Level.INFO.intValue()) { 86 | new UnsupportedOperationException("Unsupported handler type " + handler.getClass().getName()).fillInStackTrace().printStackTrace(); 87 | } 88 | } 89 | } 90 | 91 | private void updatePlayer(UserConnection usercon) { 92 | BungeeResourcepacks plugin = BungeeResourcepacks.getInstance(); 93 | if (plugin.isEnabled()) { 94 | if (uuid.isPresent()) { 95 | ResourcePack pack = plugin.getPackManager().getByUuid(uuid.get()); 96 | if (pack != null) { 97 | plugin.getUserManager().removeUserPack(usercon.getUniqueId(), pack); 98 | plugin.logDebug("Backend mc server removed pack " + pack.getName() + " (" + pack.getUrl() + ") from player " + usercon.getName()); 99 | } else { 100 | plugin.logDebug("Backend mc server removed pack " + uuid.get() + " that we don't know about from player " + usercon.getName()); 101 | } 102 | } else { 103 | plugin.getUserManager().clearUserPacks(usercon.getUniqueId()); 104 | } 105 | } 106 | } 107 | 108 | public void read(ByteBuf buf) { 109 | boolean hasUuid = buf.readBoolean(); 110 | if (hasUuid) { 111 | this.uuid = Optional.of(readUUID(buf)); 112 | } 113 | } 114 | 115 | public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { 116 | read(buf); 117 | } 118 | 119 | public void write(ByteBuf buf) { 120 | buf.writeBoolean(this.uuid.isPresent()); 121 | this.uuid.ifPresent(u -> writeUUID(u, buf)); 122 | } 123 | 124 | public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) { 125 | write(buf); 126 | } 127 | 128 | public UUID getUuid() { 129 | return this.uuid.orElse(null); 130 | } 131 | 132 | @Override 133 | public String toString() { 134 | return "ResourcePackRemovePacket{" + 135 | "uuid=" + uuid + 136 | '}'; 137 | } 138 | 139 | @Override 140 | public boolean equals(Object o) { 141 | if (this == o) return true; 142 | if (o == null || getClass() != o.getClass()) return false; 143 | ResourcePackRemovePacket that = (ResourcePackRemovePacket) o; 144 | return Objects.equals(uuid, that.uuid); 145 | } 146 | 147 | @Override 148 | public int hashCode() { 149 | return Objects.hash(uuid); 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /bungee/src/main/resources/bungee-config.yml: -------------------------------------------------------------------------------- 1 | debug: true 2 | # Default language 3 | default-language: en 4 | # Disable all metrics included in this plugin. 5 | disable-metrics: false 6 | # Whether or not resourcepack file hashes should be generated on startup: 7 | autogeneratehashes: true 8 | # Whether to append the pack hash to the end of the URL of the pack like url#hash. 9 | # This is necessary to work around a Vanilla bug which prevents changed packs from being downloaded 10 | # properly again: https://bugs.mojang.com/browse/MC-164316 11 | append-hash-to-url: true 12 | # Whether /usepack should apply packs temporary or permanent when run without any argument: 13 | usepack-is-temporary: true 14 | # Whether packs that a player has stored will override a matched assignments 15 | stored-packs-override-assignments: false 16 | # When manually setting a permanent pack then it will be reset if the user disconnects in under x amount of seconds. 17 | # 0 or anything below will disable this functionality 18 | permanent-pack-remove-time: 30 19 | # Whether to only send packs if authenticated on the Minecraft server 20 | # Requires WorldResourcepacks to be installed on the Minecraft server too 21 | use-auth-plugin: false 22 | # Different packs can be defined in this section 23 | packs: 24 | lobbypack: 25 | # The url the client should download the resourcepack from. 26 | # Has to be a direct download link! No mediafire/mega/other oneclick-hoster! 27 | url: http://example.com/lobbyresourcepack.zip 28 | # The sha1 hash of the resourcepack's zip file, 29 | # if not correct the client will waste bandwidth but it will still work! 30 | # At least that's what the Minecraft wiki says... (Site: Server.properties#Minecraft_server_properties) 31 | hash: abcdef012345678abcdef012345678abcdef0123 32 | # The UUID of the pack, if not set then it will be generated from the name 33 | uuid: 01234567-89ab-cdef-0123-456789abcdef 34 | # The format version of this resourcepack 35 | format: 1 36 | # Directly define the Minecraft version instead of the format 37 | # Supports string representation of the versions and protocol numbers 38 | # You don't need to define both the version and the format (if so then the highest one will take effect) 39 | version: "1.8" 40 | # Whether or not this pack will only be send to players with a certain permission 41 | # permission: bungeeresourcepacks.pack. 42 | restricted: false 43 | # If you want you can define a specific permission for this pack if you don't want 44 | # the default bungeeresourcepacks.pack. permission! 45 | permission: bungeeresourcepacks.pack.lobbypack 46 | globalpack: 47 | url: http://example.com/globalpack.zip 48 | hash: abcdef012345678abcdef012345678abcdef0123 49 | gamepack: 50 | # Set different variants e.g. for different versions or permissions 51 | # This list supports all normal pack settings and is checked top to bottom. 52 | # The first one that matches the player will be used. 53 | variants: 54 | - url: http://example.com/minigameresourcepack_1_15.zip 55 | hash: 012345678abcdef012345678abcdef012345678a 56 | version: '1.15' 57 | - url: http://example.com/minigameresourcepack_1_12.zip 58 | hash: 012345678abcdef01234567dddcdef012345678a 59 | version: '1.12' 60 | # Define as many packs as you want 61 | another_example_pack: 62 | url: http://example.com/another.zip 63 | hash: abcdef012345678abcdef012345678abcdef0123 64 | # Empty pack to reset the pack to the default one 65 | empty: 66 | url: http://cdn.moep.tv/files/Empty.zip 67 | hash: 01517226212d27586ea0c5d6aff1aa5492dd2484 68 | global: 69 | # Define a global pack: 70 | pack: globalpack 71 | # List of packs to not replace if the user already has them 72 | # If no main pack is set the first one also gets used to reset 73 | # the pack if the user has a non-optional one 74 | # Also this list will be used to select a pack if a user does not have the permission 75 | # or the right version to use that pack. (From top to bottom) 76 | optional-packs: 77 | - lobbypack 78 | # Delay in ticks before sending the pack to a player after he logs in/switches to the server 79 | send-delay: 20 80 | # Different servers with different packs can be defined here 81 | servers: 82 | # Config for a server named "lobby" 83 | lobby: 84 | # You can define multiple packs starting with 1.20.3 85 | # On versions prior to it only the first pack will be used 86 | packs: 87 | - lobbypack 88 | - globalpack 89 | optional-packs: 90 | - gamepack 91 | minigame: 92 | pack: gamepack 93 | # Use a regex to target all servers with a certain name 94 | regex: 'minigame_.*' 95 | # Define as many servers as you want. 96 | # The name of the section is the server name unless a regex is specified. 97 | another_example_server: 98 | pack: another_example_pack 99 | -------------------------------------------------------------------------------- /bungee/src/main/resources/bungee.yml: -------------------------------------------------------------------------------- 1 | name: ${project.name} 2 | main: de.themoep.resourcepacksplugin.bungee.BungeeResourcepacks 3 | version: '${minecraft.plugin.version}' 4 | author: Phoenix616 5 | softDepends: [ViaVersion, Geyser-BungeeCord, floodgate, nLogin, JPremium, LibrePremium, LibreLogin] -------------------------------------------------------------------------------- /bungee/src/main/resources/packetmap.yml: -------------------------------------------------------------------------------- 1 | GAME: 2 | ResourcePackSendPacket: 3 | '1_8': 0x48 4 | '1_9': 0x32 5 | '1_12': 0x33 6 | '1_12_1': 0x34 7 | '1_13': 0x37 8 | '1_14': 0x39 9 | '1_15': 0x3A 10 | '1_16': 0x39 11 | '1_16_2': 0x38 12 | '1_17': 0x3C 13 | '1_19': 0x3A 14 | '1_19_1': 0x3D 15 | '1_19_3': 0x3C 16 | '1_19_4': 0x40 17 | '1_20_2': 0x42 18 | '1_20_3': 0x44 19 | '1_20_5': 0x46 20 | '1_21_2': 0x4B 21 | '1_21_5': 0x4A 22 | ResourcePackRemovePacket: 23 | '1_20_3': 0x43 24 | '1_20_5': 0x45 25 | '1_21_2': 0x4A 26 | '1_21_5': 0x49 27 | CONFIGURATION: 28 | ResourcePackSendPacket: 29 | '1_20_2': 0x06 30 | '1_20_3': 0x07 31 | '1_20_5': 0x09 32 | ResourcePackRemovePacket: 33 | '1_20_3': 0x06 34 | '1_20_5': 0x08 -------------------------------------------------------------------------------- /core/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | core 8 | jar 9 | ${plugin.version} 10 | 11 | 12 | de.themoep.resourcepacksplugin 13 | parent 14 | parent 15 | 16 | 17 | 18 | 19 | com.google.guava 20 | guava 21 | 31.0.1-jre 22 | provided 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /core/src/main/java/de/themoep/resourcepacksplugin/core/ChatColor.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.core; 2 | 3 | /* 4 | * ResourcepacksPlugins - core 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import java.util.regex.Pattern; 22 | 23 | public enum ChatColor { 24 | BLACK('0'), 25 | DARK_BLUE('1'), 26 | DARK_GREEN('2'), 27 | DARK_AQUA('3'), 28 | DARK_RED('4'), 29 | DARK_PURPLE('5'), 30 | GOLD('6'), 31 | GRAY('7'), 32 | DARK_GRAY('8'), 33 | BLUE('9'), 34 | GREEN('a'), 35 | AQUA('b'), 36 | RED('c'), 37 | LIGHT_PURPLE('d'), 38 | YELLOW('e'), 39 | WHITE('f'), 40 | MAGIC('k'), 41 | BOLD('l'), 42 | STRIKETHROUGH('m'), 43 | UNDERLINE('n'), 44 | ITALIC('o'), 45 | RESET('r'); 46 | 47 | private static final Pattern USAGE_COLORING = Pattern.compile("([|><\\[\\]]+)"); 48 | 49 | private final String toString; 50 | 51 | private ChatColor(char code) { 52 | this.toString = new String(new char[]{'§', code}); 53 | } 54 | 55 | public String toString() { 56 | return toString; 57 | } 58 | 59 | public static String usage(String string) { 60 | return USAGE_COLORING.matcher(string).replaceAll(ChatColor.GRAY + "$1" + ChatColor.RESET); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /core/src/main/java/de/themoep/resourcepacksplugin/core/ClientType.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.core; 2 | 3 | /* 4 | * ResourcepacksPlugins - core 5 | * Copyright (C) 2021 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import java.util.Locale; 22 | 23 | public enum ClientType { 24 | ORIGINAL, 25 | BEDROCK; 26 | 27 | public String humanName() { 28 | return name().toUpperCase(Locale.ROOT); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/de/themoep/resourcepacksplugin/core/MinecraftVersion.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.core; 2 | 3 | import java.util.LinkedHashMap; 4 | import java.util.Locale; 5 | import java.util.Map; 6 | 7 | /* 8 | * ResourcepacksPlugins - core 9 | * Copyright (C) 2020 Max Lee aka Phoenix616 (mail@moep.tv) 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | public enum MinecraftVersion { 26 | MINECRAFT_1_21_5(770), 27 | MINECRAFT_1_21_4(769), 28 | MINECRAFT_1_21_3(768), 29 | MINECRAFT_1_21_2(768), 30 | MINECRAFT_1_21_1(767), 31 | MINECRAFT_1_21(767), 32 | MINECRAFT_1_20_6(766), 33 | MINECRAFT_1_20_5(766), 34 | MINECRAFT_1_20_4(765), 35 | MINECRAFT_1_20_3(765), 36 | MINECRAFT_1_20_2(764), 37 | MINECRAFT_1_20(763), 38 | MINECRAFT_1_19_4(762), 39 | MINECRAFT_1_19_3(761), 40 | MINECRAFT_1_19_2(760), 41 | MINECRAFT_1_19_1(760), 42 | MINECRAFT_1_19(759), 43 | MINECRAFT_1_18_2(758), 44 | MINECRAFT_1_18_1(757), 45 | MINECRAFT_1_18(757), 46 | MINECRAFT_1_17_1(756), 47 | MINECRAFT_1_17(755), 48 | MINECRAFT_1_16_5(754), 49 | MINECRAFT_1_16_4(754), 50 | MINECRAFT_1_16_3(753), 51 | MINECRAFT_1_16_2(751), 52 | MINECRAFT_1_16_1(736), 53 | MINECRAFT_1_16(735), 54 | MINECRAFT_1_15_2(578), 55 | MINECRAFT_1_15_1(575), 56 | MINECRAFT_1_15(573), 57 | MINECRAFT_1_14_4(498), 58 | MINECRAFT_1_14_3(490), 59 | MINECRAFT_1_14_2(485), 60 | MINECRAFT_1_14_1(480), 61 | MINECRAFT_1_14(477), 62 | MINECRAFT_1_13_2(404), 63 | MINECRAFT_1_13_1(401), 64 | MINECRAFT_1_13(393), 65 | MINECRAFT_1_12_2(340), 66 | MINECRAFT_1_12_1(338), 67 | MINECRAFT_1_12(335), 68 | MINECRAFT_1_11_2(316), 69 | MINECRAFT_1_11_1(316), 70 | MINECRAFT_1_11(315), 71 | MINECRAFT_1_10(210), 72 | MINECRAFT_1_9_4(110), 73 | MINECRAFT_1_9_2(109), 74 | MINECRAFT_1_9_1(108), 75 | MINECRAFT_1_9(107), 76 | MINECRAFT_1_8_8(47), 77 | MINECRAFT_1_8(47), 78 | MINECRAFT_1_7_6(5), 79 | MINECRAFT_1_7_2(4), 80 | UNKNOWN(0); 81 | 82 | private final int number; 83 | private static Map numbers; 84 | 85 | static { 86 | numbers = new LinkedHashMap<>(); 87 | for(MinecraftVersion version : values()) { 88 | numbers.put(version.number, version); 89 | } 90 | } 91 | 92 | MinecraftVersion(int versionNumber) { 93 | this.number = versionNumber; 94 | } 95 | 96 | /** 97 | * Parse the version from a string. The string can either be a string representation of the version or the protocol number 98 | * @param versionString The string representation of the version or the protocol number 99 | * @return The MinecraftVersion 100 | * @throws IllegalArgumentException If no version can be parsed from the string 101 | */ 102 | public static MinecraftVersion parseVersion(String versionString) throws IllegalArgumentException { 103 | try { 104 | int parsedVersion = Integer.parseInt(versionString); 105 | MinecraftVersion version = getVersion(parsedVersion); 106 | if (parsedVersion == 0 || version != UNKNOWN) { 107 | return version; 108 | } 109 | } catch (NumberFormatException ignored) {} 110 | String getVersion = versionString.toUpperCase().replace('.', '_'); 111 | if (!getVersion.startsWith("MINECRAFT_")) { 112 | getVersion = "MINECRAFT_" + getVersion; 113 | } 114 | try { 115 | return valueOf(getVersion); 116 | } catch (IllegalArgumentException ignored) {} 117 | 118 | throw new IllegalArgumentException(versionString + " is not a valid MinecraftVersion definition!"); 119 | } 120 | 121 | /** 122 | * Get the Minecraft version from the protocol version 123 | * @param protocolVersion The protocol version 124 | * @return The Minecraft version or {@link MinecraftVersion#UNKNOWN} if not known 125 | */ 126 | public static MinecraftVersion getVersion(int protocolVersion) { 127 | MinecraftVersion minecraftVersion = numbers.get(protocolVersion); 128 | if (minecraftVersion != null) { 129 | return minecraftVersion; 130 | } 131 | return UNKNOWN; 132 | } 133 | 134 | /** 135 | * Gets the Minecraft version that matches the protocol version exactly 136 | * @param protocolVersion The protocol version 137 | * @return The Minecraft version or null if not known 138 | */ 139 | public static MinecraftVersion getExactVersion(int protocolVersion) { 140 | return numbers.get(protocolVersion); 141 | } 142 | 143 | /** 144 | * Get the human readable config string for this version which can be parsed by parseVersion 145 | * @return The human readable config string 146 | */ 147 | public String toConfigString() { 148 | return this == UNKNOWN ? name() : name().toLowerCase(Locale.ROOT).substring("MINECRAFT_".length()).replace('_', '.'); 149 | } 150 | 151 | public int getProtocolNumber() { 152 | return number; 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /core/src/main/java/de/themoep/resourcepacksplugin/core/PluginLogger.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.core; 2 | 3 | /* 4 | * ResourcepacksPlugins - core 5 | * Copyright (C) 2020 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import java.util.logging.Level; 22 | 23 | public interface PluginLogger { 24 | 25 | void log(Level info, String message); 26 | 27 | void log(Level info, String message, Throwable e); 28 | } 29 | -------------------------------------------------------------------------------- /core/src/main/java/de/themoep/resourcepacksplugin/core/ResourcepacksPlayer.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.core; 2 | 3 | /* 4 | * ResourcepacksPlugins - core 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import java.util.UUID; 22 | 23 | /** 24 | * Created by Phoenix616 on 03.02.2016. 25 | */ 26 | public class ResourcepacksPlayer { 27 | private String name; 28 | private UUID uniqueId; 29 | 30 | public ResourcepacksPlayer(String name, UUID uniqueId) { 31 | this.name = name; 32 | this.uniqueId = uniqueId; 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public UUID getUniqueId() { 40 | return uniqueId; 41 | } 42 | 43 | 44 | public boolean equals(Object obj) { 45 | if(obj == this) { 46 | return true; 47 | } 48 | if(obj instanceof ResourcepacksPlayer) { 49 | ResourcepacksPlayer other = (ResourcepacksPlayer) obj; 50 | return other.getUniqueId().equals(getUniqueId()) && other.getName().equals(getName()); 51 | } 52 | return false; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /core/src/main/java/de/themoep/resourcepacksplugin/core/commands/ResetPackCommandExecutor.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.core.commands; 2 | 3 | /* 4 | * ResourcepacksPlugins - core 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.ClientType; 22 | import de.themoep.resourcepacksplugin.core.ResourcepacksPlayer; 23 | import de.themoep.resourcepacksplugin.core.ResourcepacksPlugin; 24 | import de.themoep.resourcepacksplugin.core.events.IResourcePackSelectEvent.Status; 25 | 26 | import java.util.logging.Level; 27 | 28 | /** 29 | * Created by Phoenix616 on 03.02.2016. 30 | */ 31 | public class ResetPackCommandExecutor extends PluginCommandExecutor { 32 | 33 | public ResetPackCommandExecutor(ResourcepacksPlugin plugin) { 34 | super(plugin, "resetpack [] []"); 35 | } 36 | 37 | public boolean run(ResourcepacksPlayer sender, String[] args) { 38 | String tempStr = null; 39 | if (args.length > 0 && plugin.checkPermission(sender, permission + ".temporary")) { 40 | tempStr = args[args.length - 1]; 41 | } 42 | boolean temp = plugin.isUsepackTemporary(); 43 | if ("false".equalsIgnoreCase(tempStr)) { 44 | temp = false; 45 | } else if ("true".equalsIgnoreCase(tempStr)) { 46 | temp = true; 47 | } else if (tempStr != null && args.length > 1) { 48 | sendMessage(sender, "invalid-temporary", "input", tempStr); 49 | return true; 50 | } else { 51 | // temporary value is not true or false 52 | tempStr = null; 53 | } 54 | 55 | ResourcepacksPlayer player = null; 56 | if ((args.length > 1 || (tempStr == null && args.length > 0)) && plugin.checkPermission(sender, permission + ".others")) { 57 | player = plugin.getPlayer(args[0]); 58 | if (player == null) { 59 | sendMessage(sender, "player-not-online", "input", args[0]); 60 | return true; 61 | } 62 | } else if (sender != null) { 63 | player = sender; 64 | } else { 65 | plugin.log(Level.WARNING, "You have to specify a player if you want to run this command from the console! /resetpack []"); 66 | return true; 67 | } 68 | 69 | if (plugin.getPlayerClientType(player.getUniqueId()) == ClientType.BEDROCK) { 70 | sendMessage(sender, "bedrock-not-supported"); 71 | return true; 72 | } 73 | 74 | if (!temp) { 75 | String storedPack = plugin.getStoredPack(player.getUniqueId()); 76 | if (storedPack == null) { 77 | sendMessage(sender, "no-pack-stored"); 78 | } else { 79 | sendMessage(sender, "had-stored-pack", "pack", storedPack); 80 | } 81 | } 82 | 83 | if (plugin.getPackManager().setPack(player.getUniqueId(), null, temp, true).getStatus() == Status.SUCCESS) { 84 | if (!player.equals(sender)) { 85 | sendMessage(sender, "success-other", "player", player.getName()); 86 | } 87 | sendMessage(player, "success"); 88 | String senderName = sender != null ? sender.getName() : "CONSOLE"; 89 | plugin.logDebug(senderName + " reset the pack of " + player.getName()); 90 | plugin.sendPackInfo(player.getUniqueId()); 91 | } else { 92 | if (player.equals(sender)) { 93 | sendMessage(sender, "no-pack"); 94 | } else { 95 | sendMessage(sender, "no-pack-other", "player", player.getName()); 96 | } 97 | } 98 | return true; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /core/src/main/java/de/themoep/resourcepacksplugin/core/events/IResourcePackSelectEvent.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.core.events; 2 | 3 | /* 4 | * ResourcepacksPlugins - core 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.ResourcePack; 22 | 23 | import java.util.List; 24 | import java.util.UUID; 25 | 26 | /** 27 | * Created by Phoenix616 on 18.04.2015. 28 | */ 29 | public interface IResourcePackSelectEvent { 30 | 31 | UUID getPlayerId(); 32 | 33 | /** 34 | * Get the pack that was selected 35 | * @return The selected pack; null if the selection failed 36 | * @deprecated Use {@link #getPacks()} 37 | */ 38 | @Deprecated 39 | default ResourcePack getPack() { 40 | return !getPacks().isEmpty() ? getPacks().get(0) : null; 41 | } 42 | 43 | /** 44 | * Get the packs that were selected 45 | * @return The selected packs; null if the selection failed 46 | */ 47 | List getPacks(); 48 | 49 | /** 50 | * Set the pack. If it isn't null the status will be set to success. Otherwise you have to set the status yourself 51 | * @param pack The pack that was selected 52 | * @deprecated Directly add to or remove from {@link #getPacks()} 53 | */ 54 | @Deprecated 55 | default void setPack(ResourcePack pack) { 56 | getPacks().clear(); 57 | if (pack != null) { 58 | getPacks().add(pack); 59 | } 60 | } 61 | 62 | /** 63 | * The status of the select event
64 | * SUCCESS - Pack found and is not null
65 | * NO_PERMISSION - Selection failed because the player does not have the permission for the pack
66 | * WRONG_VERSION - Selection failed because there is not compatible pack
67 | * NO_PERM_AND_WRONG_VERSION - Both failures happened
68 | * UNKNOWN - We don't know why it failed
69 | * @return The status of the event 70 | */ 71 | Status getStatus(); 72 | 73 | /** 74 | * Set the status. If it isn't SUCCESS the pack will be set to null 75 | * @param status The status of the select event 76 | */ 77 | void setStatus(Status status); 78 | 79 | /** 80 | * The status of the select event
81 | * SUCCESS - Pack found and is not null
82 | * NO_PERMISSION - Selection failed because the player does not have the permission for the pack
83 | * WRONG_VERSION - Selection failed because there is not compatible pack
84 | * NO_PERM_AND_WRONG_VERSION - Both failures happened
85 | * ALREADY_APPLIED - The player already had that pack applied 86 | * IS_EMPTY - The player already had the empty pack applied 87 | * UNKNOWN - We don't know why it failed
88 | */ 89 | public enum Status { 90 | SUCCESS, 91 | NO_PERMISSION, 92 | WRONG_VERSION, 93 | NO_PERM_AND_WRONG_VERSION, 94 | ALREADY_APPLIED, 95 | IS_EMPTY, 96 | UNKNOWN; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /core/src/main/java/de/themoep/resourcepacksplugin/core/events/IResourcePackSendEvent.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.core.events; 2 | 3 | /* 4 | * ResourcepacksPlugins - core 5 | * Copyright (C) 2018 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.ResourcePack; 22 | 23 | import java.util.UUID; 24 | 25 | /** 26 | * Created by Phoenix616 on 18.04.2015. 27 | */ 28 | public interface IResourcePackSendEvent { 29 | 30 | UUID getPlayerId(); 31 | 32 | ResourcePack getPack(); 33 | 34 | /** 35 | * Set the pack that should be send. Set to null if you want to remove all packs/send the empty one 36 | * @param pack The pack to send, if it is null it will reset the pack to the empty one 37 | */ 38 | void setPack(ResourcePack pack); 39 | 40 | boolean isCancelled(); 41 | 42 | void setCancelled(boolean cancelled); 43 | } 44 | -------------------------------------------------------------------------------- /core/src/main/resources/languages/lang.en.yml: -------------------------------------------------------------------------------- 1 | command: 2 | usage: "Usage: /%command% %usage%" 3 | reloaded: "&aReloaded %plugin% config!%optional-resend%" 4 | optional-resend: " Resend packs to all online players!" 5 | version: "&a%plugin% version: %version%" 6 | not-enabled: "&c%plugin% is not enabled!" 7 | invalid-input: "&f%input%&c is not a valid %expected%" 8 | no-permission: "&cYou don't have the permission &f%permission%&c!" 9 | unknown-pack: "&cNo pack with the name &e%input%&c found!" 10 | addpack: 11 | name-already-used: "&cA pack with the name of &f%name%&c already exists!" 12 | url-already-used: "&cThe pack &f%name%&c is already using the url &f%url%&c!" 13 | added: "&eAdded new pack &f%name%&e with url &f%url%" 14 | removepack: 15 | removed: "&eRemoved pack &f%name%&e with url &f%url%" 16 | pack: 17 | updated: "&eSet &f%type%&e of pack &f%pack%&e to &f%value%" 18 | info: |- 19 | &7----- &ePack &f%name%&e Info: &7----- 20 | &eUrl: &f%url% 21 | &eHash: &f%hash% 22 | &eFormat: &f%format% 23 | &eVersion: &f%version% 24 | &eRestricted: &f%restricted% 25 | &ePermission: &f%permission% 26 | &eVariants: &f%variants% 27 | info-variants: |- 28 | &7----- &ePack &f%name%&e Info: &7----- 29 | &eFormat: &f%format% 30 | &eVersion: &f%version% 31 | &eRestricted: &f%restricted% 32 | &ePermission: &f%permission% 33 | &e%variants% Variants: 34 | assignment: 35 | new-assignment: "&cNo assignment with the name &e%input%&c found! Creating new one!" 36 | updated: "&eSet &f%type%&e of assignment &f%assignment%&e to &f%value%" 37 | optional-pack: 38 | added: "&eAdded pack &f%pack%&e to the optional pack list of assignment &f%assignment%&e!" 39 | already-added: "&cPack &f%pack%&c is already on the optional pack list of assignment &f%assignment%&c?" 40 | removed: "&eRemoved pack &f%pack%&e from the optional pack list of assignment &f%assignment%&e!" 41 | not-added: "&cPack &f%pack%&c is not on the optional pack list of assignment &f%assignment%&c?" 42 | info: |- 43 | &7----- &eAssignment &f%name%&e Info: &7----- 44 | &ePack: &f%pack% 45 | &eOptional Packs: &f%optional-packs% 46 | &eRegex: &f%regex% 47 | &eSend Delay: &f%send-delay% 48 | deleteassignment: 49 | unknown-assignment: "&cNo assignment with the name &e%input%&c found!" 50 | deleted: "&eAssignment &f%name%&e was deleted!" 51 | listassignments: 52 | head: "&aAssignments configured:" 53 | entry: "&e%name%" 54 | usepack: 55 | invalid-temporary: "&f%input%&c is not a valid Boolean temporary value! (true/false)" 56 | player-not-online: "&cThe player &f%input%&c is not online" 57 | bedrock-not-supported: "&cChanging the pack of Bedrock players is not supported!" 58 | already-in-use: "&f%player%&c already uses the pack '&f%pack%&c'!" 59 | unknown-error: "&cCould not apply pack '&f%pack%&c' for unknown reasons!" 60 | no-variant-found: 61 | permission: "&f%player%&c can't use any variant of the pack '&f%pack%&c' due to their permissions!" 62 | version: "&f%player%&c can't use any variant of the pack '&f%pack%&c' due to their version!" 63 | perm-and-version: "&f%player%&c can't use any variant of the pack '&f%pack%&c' due to their version and permissions!" 64 | restricted: "&cYou don't have the permission &f%permission%%c to set the restricted pack '&f%pack%&c'!" 65 | unknown-pack: "&cError: There is no pack with the name '&f%input%&c'!" 66 | success-other: "&f%player% &anow uses the pack '&f%pack%&a'!" 67 | success: "&aYou now use the pack %pack%!" 68 | pack-list: 69 | head: "&aPacks available to you:" 70 | entry: " [&e%pack%](/usepack %pack%)%optional-format%%optional-version%" 71 | entry-selected: "> [%pack%](/resetpack)%optional-format%%optional-version%" 72 | optional-format: "&7 (Format: %format%)" 73 | optional-version: "&7 (Version: %version%)" 74 | no-packs: "&cNo packs found!" 75 | resetpack: 76 | player-not-online: "&cThe player &f%input%&c is not online" 77 | bedrock-not-supported: "&cChanging the pack of Bedrock players is not supported!" 78 | no-pack-stored: "&cNo pack stored." 79 | had-stored-pack: "&aHad pack '&f%pack%&a' stored." 80 | success-other: "&aReset the pack of &f%player%&a!" 81 | success: "&aReset your pack!" 82 | no-pack: "&cYou have no pack (or the empty one) applied?" 83 | no-pack-other: "&f%player% &chas no pack (or the empty one) applied?" 84 | 85 | 86 | generate-hashes: 87 | generating: "&eGenerating hashes..." 88 | downloading: "&eDownloading &f%pack%&e..." 89 | hash-sum: "&eSHA 1 hash of &f%pack%&e: &f%hash%" 90 | invalid-url: "&e%url%&c is not a valid url!" 91 | failed-to-load-pack: "&cCould not load %pack%! %error%" 92 | changed: "&aHashes of %amount% packs changed! Saving to config." 93 | none-changed: "&aNo hash changed!" -------------------------------------------------------------------------------- /sponge/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | sponge 8 | ${plugin.version} 9 | jar 10 | 11 | 12 | de.themoep.resourcepacksplugin 13 | parent 14 | parent 15 | 16 | 17 | 18 | 19 | sponge-repo 20 | Sponge Maven Repository 21 | https://repo.spongepowered.org/maven 22 | 23 | 24 | viaversion-repo 25 | https://repo.viaversion.com/everything/ 26 | 27 | 28 | sonatype-oss 29 | https://oss.sonatype.org/content/repositories/snapshots/ 30 | 31 | 32 | geyser-repo 33 | https://repo.opencollab.dev/maven-snapshots/ 34 | 35 | 36 | 37 | 38 | 39 | org.spongepowered 40 | spongeapi 41 | 7.2.0 42 | jar 43 | provided 44 | 45 | 46 | de.themoep.resourcepacksplugin 47 | core 48 | 49 | 50 | de.themoep.utils 51 | lang-sponge 52 | ${lang.version} 53 | provided 54 | 55 | 56 | de.themoep 57 | minedown-adventure 58 | compile 59 | 60 | 61 | net.kyori 62 | adventure-platform-spongeapi 63 | 4.0.0-SNAPSHOT 64 | provided 65 | 66 | 67 | net.kyori 68 | adventure-text-serializer-legacy 69 | 4.4.0 70 | provided 71 | 72 | 73 | com.viaversion 74 | viaversion-common 75 | 76 | 77 | org.geysermc.geyser 78 | api 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /sponge/src/main/java/de/themoep/resourcepacksplugin/sponge/ForwardingCommand.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.sponge; 2 | 3 | /* 4 | * ResourcepacksPlugins - sponge 5 | * Copyright (C) 2021 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.minedown.adventure.MineDown; 22 | import de.themoep.resourcepacksplugin.core.ResourcepacksPlayer; 23 | import de.themoep.resourcepacksplugin.core.commands.PluginCommandExecutor; 24 | import net.kyori.adventure.text.serializer.spongeapi.SpongeComponentSerializer; 25 | import org.spongepowered.api.command.CommandCallable; 26 | import org.spongepowered.api.command.CommandException; 27 | import org.spongepowered.api.command.CommandResult; 28 | import org.spongepowered.api.command.CommandSource; 29 | import org.spongepowered.api.entity.living.player.Player; 30 | import org.spongepowered.api.text.Text; 31 | import org.spongepowered.api.world.Location; 32 | import org.spongepowered.api.world.World; 33 | 34 | import javax.annotation.Nullable; 35 | import java.util.Collections; 36 | import java.util.List; 37 | import java.util.Optional; 38 | import java.util.stream.Collectors; 39 | 40 | /** 41 | * Created by Phoenix616 on 20.06.2015. 42 | */ 43 | public class ForwardingCommand implements CommandCallable { 44 | 45 | private final PluginCommandExecutor executor; 46 | 47 | public ForwardingCommand(PluginCommandExecutor executor) { 48 | this.executor = executor; 49 | } 50 | 51 | @Override 52 | public CommandResult process(CommandSource sender, String args) throws CommandException { 53 | ResourcepacksPlayer s = null; 54 | if (sender instanceof Player) { 55 | s = ((SpongeResourcepacks) executor.getPlugin()).getPlayer((Player) sender); 56 | } 57 | executor.execute(s, args.split(" ")); 58 | return CommandResult.success(); 59 | } 60 | 61 | @Override 62 | public List getSuggestions(CommandSource source, String arguments, @Nullable Location targetPosition) throws CommandException { 63 | PluginCommandExecutor last = executor; 64 | for (String a : arguments.split(" ")) { 65 | last = last.getSubCommand(a); 66 | if (last == null) { 67 | return Collections.emptyList(); 68 | } 69 | } 70 | return last.getSubCommands().values().stream() 71 | .filter(c -> c.getPermission() == null || source.hasPermission(c.getPermission())) 72 | .map(PluginCommandExecutor::getName) 73 | .collect(Collectors.toList()); 74 | } 75 | 76 | @Override 77 | public boolean testPermission(CommandSource source) { 78 | return executor.getPermission() == null || source.hasPermission(executor.getPermission()); 79 | } 80 | 81 | @Override 82 | public Optional getShortDescription(CommandSource source) { 83 | return Optional.of(getUsage(source)); 84 | } 85 | 86 | @Override 87 | public Optional getHelp(CommandSource source) { 88 | return Optional.of(getUsage(source)); 89 | } 90 | 91 | @Override 92 | public Text getUsage(CommandSource source) { 93 | return SpongeComponentSerializer.get().serialize(MineDown.parse(executor.getUsage())); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /sponge/src/main/java/de/themoep/resourcepacksplugin/sponge/SpongePluginLogger.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.sponge; 2 | 3 | /* 4 | * ResourcepacksPlugins - sponge 5 | * Copyright (C) 2021 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.PluginLogger; 22 | import de.themoep.utils.lang.LangLogger; 23 | import org.slf4j.Logger; 24 | 25 | import java.util.logging.Level; 26 | 27 | public class SpongePluginLogger implements LangLogger, PluginLogger { 28 | private final Logger logger; 29 | 30 | public SpongePluginLogger(Logger logger) { 31 | this.logger = logger; 32 | } 33 | 34 | @Override 35 | public void log(Level level, String message) { 36 | log(level, message, null); 37 | } 38 | 39 | @Override 40 | public void log(Level level, String message, Throwable throwable) { 41 | if (level.intValue() < Level.FINER.intValue()) { 42 | logger.trace(message, throwable); 43 | } else if (level.intValue() < Level.INFO.intValue()) { 44 | logger.debug(message, throwable); 45 | } else if (level.intValue() < Level.WARNING.intValue()) { 46 | logger.info(message, throwable); 47 | } else if (level.intValue() < Level.SEVERE.intValue()) { 48 | logger.warn(message, throwable); 49 | } else { 50 | logger.error(message, throwable); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /sponge/src/main/java/de/themoep/resourcepacksplugin/sponge/events/ResourcePackSelectEvent.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.sponge.events; 2 | 3 | /* 4 | * ResourcepacksPlugins - sponge 5 | * Copyright (C) 2021 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.ResourcePack; 22 | import de.themoep.resourcepacksplugin.core.events.IResourcePackSelectEvent; 23 | import org.spongepowered.api.entity.living.player.Player; 24 | import org.spongepowered.api.event.cause.Cause; 25 | import org.spongepowered.api.event.entity.living.humanoid.player.TargetPlayerEvent; 26 | import org.spongepowered.api.event.impl.AbstractEvent; 27 | 28 | import java.util.ArrayList; 29 | import java.util.List; 30 | import java.util.UUID; 31 | 32 | /** 33 | * Created by Phoenix616 on 18.04.2015. 34 | */ 35 | public class ResourcePackSelectEvent extends AbstractEvent implements IResourcePackSelectEvent, TargetPlayerEvent { 36 | private final Player player; 37 | private final Cause cause; 38 | private List packs; 39 | private Status status; 40 | 41 | public ResourcePackSelectEvent(Player player, List packs, Cause cause) { 42 | this(player, packs, packs.isEmpty() ? Status.UNKNOWN : Status.SUCCESS, cause); 43 | } 44 | 45 | public ResourcePackSelectEvent(Player player, List packs, Status status, Cause cause) { 46 | this.player = player; 47 | this.packs = new ArrayList<>(packs); 48 | this.status = status; 49 | this.cause = cause; 50 | } 51 | 52 | @Override 53 | public UUID getPlayerId() { 54 | return player.getUniqueId(); 55 | } 56 | 57 | @Override 58 | public List getPacks() { 59 | return null; 60 | } 61 | 62 | @Override 63 | public Status getStatus() { 64 | return status; 65 | } 66 | 67 | @Override 68 | public void setStatus(Status status) { 69 | this.status = status; 70 | if (status != Status.SUCCESS) { 71 | packs.clear(); 72 | } 73 | } 74 | 75 | @Override 76 | public Player getTargetEntity() { 77 | return player; 78 | } 79 | 80 | @Override 81 | public Cause getCause() { 82 | return cause; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /sponge/src/main/java/de/themoep/resourcepacksplugin/sponge/events/ResourcePackSendEvent.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.sponge.events; 2 | 3 | /* 4 | * ResourcepacksPlugins - sponge 5 | * Copyright (C) 2021 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.ResourcePack; 22 | import de.themoep.resourcepacksplugin.core.events.IResourcePackSendEvent; 23 | import org.spongepowered.api.entity.living.player.Player; 24 | import org.spongepowered.api.event.Cancellable; 25 | import org.spongepowered.api.event.cause.Cause; 26 | import org.spongepowered.api.event.entity.living.humanoid.player.TargetPlayerEvent; 27 | import org.spongepowered.api.event.impl.AbstractEvent; 28 | 29 | import java.util.UUID; 30 | 31 | /** 32 | * Created by Phoenix616 on 18.04.2015. 33 | */ 34 | public class ResourcePackSendEvent extends AbstractEvent implements IResourcePackSendEvent, TargetPlayerEvent, Cancellable { 35 | 36 | private boolean cancelled = false; 37 | private final Player player; 38 | private ResourcePack pack; 39 | private final Cause cause; 40 | 41 | public ResourcePackSendEvent(Player player, ResourcePack pack, Cause cause) { 42 | this.player = player; 43 | this.pack = pack; 44 | this.cause = cause; 45 | } 46 | 47 | public UUID getPlayerId() { 48 | return player.getUniqueId(); 49 | } 50 | 51 | public ResourcePack getPack() { 52 | return pack; 53 | } 54 | 55 | public void setPack(ResourcePack pack) { 56 | this.pack = pack; 57 | } 58 | 59 | public boolean isCancelled() { 60 | return cancelled; 61 | } 62 | 63 | public void setCancelled(boolean cancelled) { 64 | this.cancelled = cancelled; 65 | } 66 | 67 | @Override 68 | public Player getTargetEntity() { 69 | return player; 70 | } 71 | 72 | @Override 73 | public Cause getCause() { 74 | return cause; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /sponge/src/main/java/de/themoep/resourcepacksplugin/sponge/listeners/DisconnectListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.sponge.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - sponge 5 | * Copyright (C) 2021 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.sponge.SpongeResourcepacks; 22 | import org.spongepowered.api.event.Listener; 23 | import org.spongepowered.api.event.network.ClientConnectionEvent; 24 | 25 | /** 26 | * Created by Phoenix616 on 14.05.2015. 27 | */ 28 | public class DisconnectListener { 29 | 30 | private SpongeResourcepacks plugin; 31 | 32 | public DisconnectListener(SpongeResourcepacks plugin) { 33 | this.plugin = plugin; 34 | } 35 | 36 | @Listener 37 | public void onPlayerDisconnect(ClientConnectionEvent.Disconnect event) { 38 | if (plugin.isEnabled()) { 39 | plugin.getUserManager().onDisconnect(event.getTargetEntity().getUniqueId()); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sponge/src/main/java/de/themoep/resourcepacksplugin/sponge/listeners/ProxyPackReaction.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.sponge.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - sponge 5 | * Copyright (C) 2021 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.google.common.io.ByteArrayDataInput; 22 | import org.spongepowered.api.entity.living.player.Player; 23 | 24 | /** 25 | * A reaction onto a message on a certain sub channel 26 | */ 27 | public abstract class ProxyPackReaction { 28 | 29 | /** 30 | * Execute this action 31 | * @param player The player that received the plugin message 32 | * @param data The data as an input stream that you can read from 33 | */ 34 | public abstract void execute(Player player, ByteArrayDataInput data); 35 | } 36 | -------------------------------------------------------------------------------- /sponge/src/main/java/de/themoep/resourcepacksplugin/sponge/listeners/WorldSwitchListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.sponge.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - sponge 5 | * Copyright (C) 2021 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.sponge.SpongeResourcepacks; 22 | import org.spongepowered.api.Sponge; 23 | import org.spongepowered.api.entity.living.player.Player; 24 | import org.spongepowered.api.event.Listener; 25 | import org.spongepowered.api.event.entity.MoveEntityEvent; 26 | import org.spongepowered.api.event.filter.IsCancelled; 27 | import org.spongepowered.api.event.filter.cause.First; 28 | import org.spongepowered.api.event.network.ClientConnectionEvent; 29 | 30 | import java.util.UUID; 31 | 32 | /** 33 | * Created by Phoenix616 on 14.05.2015. 34 | */ 35 | public class WorldSwitchListener { 36 | 37 | private final SpongeResourcepacks plugin; 38 | 39 | public WorldSwitchListener(SpongeResourcepacks plugin) { 40 | this.plugin = plugin; 41 | } 42 | 43 | @Listener 44 | public void onWorldSwitch(MoveEntityEvent.Teleport event, @First Player player) { 45 | handleEvent(player); 46 | } 47 | 48 | @Listener 49 | public void onPlayerJoin(ClientConnectionEvent.Join event) { 50 | handleEvent(event.getTargetEntity()); 51 | } 52 | 53 | private void handleEvent(Player player) { 54 | final UUID playerId = player.getUniqueId(); 55 | 56 | long sendDelay = plugin.getPackManager().getAssignment(player.getWorld().getName()).getSendDelay(); 57 | if (sendDelay < 0) { 58 | sendDelay = plugin.getPackManager().getGlobalAssignment().getSendDelay(); 59 | } 60 | 61 | if (sendDelay > 0) { 62 | Sponge.getScheduler().createTaskBuilder().delayTicks(sendDelay).execute(() -> calculatePack(playerId)).submit(plugin); 63 | } else { 64 | calculatePack(playerId); 65 | } 66 | } 67 | 68 | private void calculatePack(UUID playerId) { 69 | if (plugin.isEnabled()) { 70 | if (!plugin.isAuthenticated(playerId)) { 71 | plugin.logDebug("Player " + playerId + " is not authenticated, not attempting to send a pack yet."); 72 | return; 73 | } 74 | Sponge.getServer().getPlayer(playerId) 75 | .ifPresent(p -> plugin.getPackManager().applyPack(plugin.getPlayer(p), p.getWorld().getName())); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /sponge/src/main/resources/sponge-config.yml: -------------------------------------------------------------------------------- 1 | debug: true 2 | # Default language 3 | default-language: en 4 | # Whether or not resourcepack file hashes should be generated on startup: 5 | autogeneratehashes: true 6 | # Whether to append the pack hash to the end of the URL of the pack like url#hash. 7 | # This is necessary to work around a Vanilla bug which prevents changed packs from being downloaded 8 | # properly again: https://bugs.mojang.com/browse/MC-164316 9 | append-hash-to-url: true 10 | # Whether /usepack should apply packs temporary or permanent when run without any argument: 11 | usepack-is-temporary: true 12 | # Whether packs that a player has stored will override a matched assignments 13 | stored-packs-override-assignments: false 14 | # When manually setting a permanent pack then it will be reset if the user disconnects in under x amount of seconds. 15 | # 0 or anything below will disable this functionality 16 | permanent-pack-remove-time: 30 17 | # Different packs can be defined in this section 18 | packs: 19 | examplepack: 20 | # The url the client should download the resourcepack from. 21 | # Has to be a direct download link! No mediafire/mega/other oneclick-hoster! 22 | url: http://example.com/lobbyresourcepack.zip 23 | # The sha1 hash of the resourcepack's zip file, 24 | # Not supported by bukkit so it currently does not matter what you write here! 25 | hash: abcdef012345678abcdef012345678abcdef0123 26 | # The UUID of the pack, if not set then it will be generated from the name 27 | uuid: 01234567-89ab-cdef-0123-456789abcdef 28 | # The format version of this resourcepack 29 | format: 1 30 | # Directly define the Minecraft version instead of the format 31 | # Supports string representation of the versions and protocol numbers 32 | # You don't need to define both the version and the format (if so then the highest one will take effect) 33 | version: "1.8" 34 | # Whether or not this pack will only be send to players with a certain permission 35 | # permission: worldresourcepacks.pack. 36 | restricted: false 37 | # If you want you can define a specific permission for this pack if you don't want 38 | # the default worldresourcepacks.pack. permission! 39 | permission: worldresourcepacks.pack.examplepack 40 | globalpack: 41 | url: http://example.com/globalpack.zip 42 | hash: abcdef012345678abcdef012345678abcdef0123 43 | examplepack2: 44 | # Set different variants e.g. for different versions or permissions 45 | # This list supports all normal pack settings and is checked top to bottom. 46 | # The first one that matches the player will be used. 47 | variants: 48 | - url: http://example.com/minigameresourcepack_1_15.zip 49 | hash: 012345678abcdef012345678abcdef012345678a 50 | version: '1.15' 51 | - url: http://example.com/minigameresourcepack_1_12.zip 52 | hash: 012345678abcdef01234567dddcdef012345678a 53 | version: '1.12' 54 | # Define as many packs as you want 55 | another_example_pack: 56 | url: http://example.com/another.zip 57 | hash: abcdef012345678abcdef012345678abcdef0123 58 | # Empty pack to reset the pack to the default one 59 | empty: 60 | url: http://cdn.moep.tv/files/Empty.zip 61 | hash: 01517226212d27586ea0c5d6aff1aa5492dd2484 62 | global: 63 | pack: globalpack 64 | # List of packs to not replace if the user already has them 65 | # If no main pack is set the first one also gets used to reset 66 | # the pack if the user has a non-optional one 67 | # Also this list will be used to select a pack if a user does not have the permission 68 | # or the right version to use that pack. (From top to bottom) 69 | #optional-packs: 70 | #- lobbypack 71 | # Delay in ticks before sending the pack to a player after he logs in/switches to the world 72 | send-delay: 10 73 | # Different worlds with different packs can be defined here 74 | worlds: 75 | # Config for a world named "your_example_world" 76 | your_example_world: 77 | # You can define multiple packs starting with 1.20.3 78 | # On versions prior to it only the first pack will be used 79 | packs: 80 | - examplepack 81 | - globalpack 82 | #optional-packs: 83 | #- examplepack2 84 | your_example_nether: 85 | pack: examplepack2 86 | # Use a regex to target all worlds with a certain name 87 | regex: 'example_nether_.*' 88 | # Define as many worlds as you want. 89 | # The name of the section is the world name unless a regex is specified. 90 | another_example_world: 91 | pack: another_example_pack 92 | -------------------------------------------------------------------------------- /velocity/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | velocity 8 | ${plugin.version} 9 | jar 10 | VelocityResourcepacks 11 | Plugin to set Resource Packs on whole Velocity proxy and per server 12 | 13 | 14 | de.themoep.resourcepacksplugin 15 | parent 16 | parent 17 | 18 | 19 | 20 | 17 21 | 17 22 | 23 | 24 | 25 | 26 | velocity-repo 27 | https://repo.papermc.io/repository/maven-public/ 28 | 29 | 30 | viaversion-repo 31 | https://repo.viaversion.com/everything/ 32 | 33 | 34 | geyser-repo 35 | https://repo.opencollab.dev/maven-snapshots/ 36 | 37 | 38 | nickuc-repo 39 | https://repo.nickuc.com/maven2/ 40 | 41 | 42 | kyngs-repo 43 | https://repo.kyngs.xyz/releases 44 | 45 | 46 | 47 | 48 | 49 | com.velocitypowered 50 | velocity-api 51 | 3.3.0-SNAPSHOT 52 | provided 53 | 54 | 55 | de.themoep.resourcepacksplugin 56 | core 57 | compile 58 | 59 | 60 | com.viaversion 61 | viaversion-common 62 | 63 | 64 | org.geysermc.geyser 65 | api 66 | 67 | 68 | org.geysermc.floodgate 69 | api 70 | 71 | 72 | com.nickuc.login 73 | nlogin-api 74 | 75 | 76 | com.jakub.premium 77 | jpremium-api 78 | 79 | 80 | com.github.kyngs 81 | LibrePremium 82 | 83 | 84 | xyz.kyngs.librelogin 85 | API 86 | 87 | 88 | io.github.4drian3d 89 | authmevelocity-api-velocity 90 | 4.0.0 91 | provided 92 | 93 | 94 | de.themoep.utils 95 | lang-velocity 96 | ${lang.version} 97 | compile 98 | 99 | 100 | de.themoep 101 | minedown-adventure 102 | compile 103 | 104 | 105 | 106 | 107 | ${project.name} 108 | 109 | 110 | true 111 | ${project.basedir}/src/main/resources/ 112 | 113 | 114 | ${project.basedir}/../ 115 | 116 | LICENSE 117 | 118 | 119 | 120 | 121 | 122 | org.apache.maven.plugins 123 | maven-compiler-plugin 124 | 125 | none 126 | 127 | 128 | 129 | org.apache.maven.plugins 130 | maven-shade-plugin 131 | 132 | true 133 | 134 | 135 | de.themoep.utils.lang 136 | de.themoep.resourcepacksplugin.velocity.libs.lang 137 | 138 | 139 | de.themoep.minedown 140 | de.themoep.resourcepacksplugin.libs.minedown 141 | 142 | 143 | 144 | 145 | 146 | package 147 | 148 | shade 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/ForwardingCommand.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity; 2 | 3 | /* 4 | * ResourcepacksPlugins - velocity 5 | * Copyright (C) 2020 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.velocitypowered.api.command.SimpleCommand; 22 | import com.velocitypowered.api.proxy.Player; 23 | import de.themoep.resourcepacksplugin.core.ResourcepacksPlayer; 24 | import de.themoep.resourcepacksplugin.core.commands.PluginCommandExecutor; 25 | 26 | import java.util.Collections; 27 | import java.util.List; 28 | import java.util.stream.Collectors; 29 | 30 | public class ForwardingCommand implements SimpleCommand { 31 | private final PluginCommandExecutor executor; 32 | 33 | public ForwardingCommand(PluginCommandExecutor executor) { 34 | this.executor = executor; 35 | } 36 | 37 | @Override 38 | public void execute(Invocation i) { 39 | ResourcepacksPlayer s = null; 40 | if (i.source() instanceof Player) { 41 | s = ((VelocityResourcepacks) executor.getPlugin()).getPlayer((Player) i.source()); 42 | } 43 | executor.execute(s, i.arguments()); 44 | } 45 | 46 | @Override 47 | public boolean hasPermission(Invocation i) { 48 | return i.source().hasPermission(executor.getPermission()); 49 | } 50 | 51 | @Override 52 | public List suggest(Invocation i) { 53 | PluginCommandExecutor last = executor; 54 | for (String a : i.arguments()) { 55 | last = last.getSubCommand(a); 56 | if (last == null) { 57 | return Collections.emptyList(); 58 | } 59 | } 60 | return last.getSubCommands().values().stream() 61 | .filter(c -> c.getPermission() == null || i.source().hasPermission(c.getPermission())) 62 | .map(PluginCommandExecutor::getName) 63 | .collect(Collectors.toList()); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/VelocityPluginLogger.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity; 2 | 3 | /* 4 | * ResourcepacksPlugins - velocity 5 | * Copyright (C) 2020 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.PluginLogger; 22 | import de.themoep.utils.lang.LangLogger; 23 | import org.slf4j.Logger; 24 | 25 | import java.util.logging.Level; 26 | 27 | public class VelocityPluginLogger implements LangLogger, PluginLogger { 28 | private final Logger logger; 29 | 30 | public VelocityPluginLogger(Logger logger) { 31 | this.logger = logger; 32 | } 33 | 34 | @Override 35 | public void log(Level level, String message) { 36 | log(level, message, null); 37 | } 38 | 39 | @Override 40 | public void log(Level level, String message, Throwable throwable) { 41 | if (level.intValue() < Level.FINER.intValue()) { 42 | logger.trace(message, throwable); 43 | } else if (level.intValue() < Level.INFO.intValue()) { 44 | logger.debug(message, throwable); 45 | } else if (level.intValue() < Level.WARNING.intValue()) { 46 | logger.info(message, throwable); 47 | } else if (level.intValue() < Level.SEVERE.intValue()) { 48 | logger.warn(message, throwable); 49 | } else { 50 | logger.error(message, throwable); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/events/ResourcePackSelectEvent.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.events; 2 | 3 | /* 4 | * ResourcepacksPlugins - velocity 5 | * Copyright (C) 2020 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import de.themoep.resourcepacksplugin.core.ResourcePack; 22 | import de.themoep.resourcepacksplugin.core.events.IResourcePackSelectEvent; 23 | 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | import java.util.UUID; 27 | 28 | /** 29 | * Created by Phoenix616 on 18.04.2015. 30 | */ 31 | public class ResourcePackSelectEvent implements IResourcePackSelectEvent { 32 | private final UUID playerId; 33 | private List packs; 34 | private Status status; 35 | 36 | public ResourcePackSelectEvent(UUID playerId, List packs) { 37 | this(playerId, packs, packs.isEmpty() ? Status.UNKNOWN : Status.SUCCESS); 38 | } 39 | 40 | public ResourcePackSelectEvent(UUID playerId, List packs, Status status) { 41 | this.playerId = playerId; 42 | this.packs = new ArrayList<>(packs); 43 | this.status = status; 44 | } 45 | 46 | @Override 47 | public UUID getPlayerId() { 48 | return playerId; 49 | } 50 | 51 | @Override 52 | public List getPacks() { 53 | return packs; 54 | } 55 | 56 | @Override 57 | public Status getStatus() { 58 | return status; 59 | } 60 | 61 | @Override 62 | public void setStatus(Status status) { 63 | this.status = status; 64 | if (status != Status.SUCCESS) { 65 | packs.clear(); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/events/ResourcePackSendEvent.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.events; 2 | 3 | /* 4 | * ResourcepacksPlugins - velocity 5 | * Copyright (C) 2020 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.velocitypowered.api.event.ResultedEvent; 22 | import de.themoep.resourcepacksplugin.core.ResourcePack; 23 | import de.themoep.resourcepacksplugin.core.events.IResourcePackSendEvent; 24 | 25 | import java.util.UUID; 26 | 27 | 28 | /** 29 | * Created by Phoenix616 on 18.04.2015. 30 | */ 31 | public class ResourcePackSendEvent implements IResourcePackSendEvent, ResultedEvent { 32 | 33 | private final UUID playerId; 34 | private ResourcePack pack; 35 | private GenericResult result = GenericResult.allowed(); 36 | 37 | public ResourcePackSendEvent(UUID playerId, ResourcePack pack) { 38 | this.playerId = playerId; 39 | this.pack = pack; 40 | } 41 | 42 | public UUID getPlayerId() { 43 | return playerId; 44 | } 45 | 46 | public ResourcePack getPack() { 47 | return pack; 48 | } 49 | 50 | public void setPack(ResourcePack pack) { 51 | this.pack = pack; 52 | } 53 | 54 | public boolean isCancelled() { 55 | return !result.isAllowed(); 56 | } 57 | 58 | public void setCancelled(boolean cancelled) { 59 | this.result = cancelled ? GenericResult.denied() : GenericResult.allowed(); 60 | } 61 | 62 | @Override 63 | public GenericResult getResult() { 64 | return result; 65 | } 66 | 67 | @Override 68 | public void setResult(GenericResult result) { 69 | this.result = result; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/integrations/FloodgateIntegration.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.integrations; 2 | 3 | /* 4 | * ResourcepacksPlugins - VelocityResourcepacks 5 | * Copyright (C) 2021 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.velocitypowered.api.plugin.PluginContainer; 22 | import de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks; 23 | import org.geysermc.floodgate.api.FloodgateApi; 24 | 25 | import java.util.UUID; 26 | import java.util.logging.Level; 27 | 28 | public class FloodgateIntegration { 29 | 30 | public FloodgateIntegration(VelocityResourcepacks plugin, PluginContainer floodgatePlugin) { 31 | plugin.log(Level.INFO, "Detected " + floodgatePlugin.getDescription().getName().orElse(floodgatePlugin.getDescription().getId()) + " " + floodgatePlugin.getDescription().getVersion().orElse("")); 32 | } 33 | 34 | public boolean hasPlayer(UUID playerId) { 35 | return FloodgateApi.getInstance().isFloodgatePlayer(playerId); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/integrations/GeyserIntegration.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.integrations; 2 | 3 | /* 4 | * ResourcepacksPlugins - VelocityResourcepacks 5 | * Copyright (C) 2021 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.velocitypowered.api.plugin.PluginContainer; 22 | import de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks; 23 | import org.geysermc.geyser.api.GeyserApi; 24 | 25 | import java.util.UUID; 26 | import java.util.logging.Level; 27 | 28 | public class GeyserIntegration { 29 | 30 | public GeyserIntegration(VelocityResourcepacks plugin, PluginContainer geyserPlugin) { 31 | plugin.log(Level.INFO, "Detected " + geyserPlugin.getDescription().getName().orElse(geyserPlugin.getDescription().getId()) + " " + geyserPlugin.getDescription().getVersion().orElse("")); 32 | } 33 | 34 | public boolean hasPlayer(UUID playerId) { 35 | return GeyserApi.api().isBedrockPlayer(playerId); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/integrations/ViaVersionIntegration.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.integrations; 2 | 3 | /* 4 | * ResourcepacksPlugins - VelocityResourcepacks 5 | * Copyright (C) 2021 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.velocitypowered.api.plugin.PluginContainer; 22 | import com.viaversion.viaversion.api.Via; 23 | import com.viaversion.viaversion.api.ViaAPI; 24 | import de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks; 25 | 26 | import java.util.UUID; 27 | import java.util.logging.Level; 28 | 29 | public class ViaVersionIntegration { 30 | private final ViaAPI viaApi; 31 | 32 | public ViaVersionIntegration(VelocityResourcepacks plugin, PluginContainer viaPlugin) { 33 | viaApi = Via.getAPI(); 34 | plugin.log(Level.INFO, "Detected " + viaPlugin.getDescription().getName().orElse(viaPlugin.getDescription().getId()) + " " + viaPlugin.getDescription().getVersion().orElse("")); 35 | } 36 | 37 | public int getPlayerVersion(UUID playerId) { 38 | return viaApi.getPlayerVersion(playerId); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/listeners/AuthHandler.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - velocity 5 | * Copyright (C) 2022 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.velocitypowered.api.proxy.Player; 22 | import de.themoep.resourcepacksplugin.core.ResourcepacksPlayer; 23 | import de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks; 24 | 25 | import java.util.concurrent.TimeUnit; 26 | 27 | public class AuthHandler { 28 | protected final VelocityResourcepacks plugin; 29 | 30 | public AuthHandler(VelocityResourcepacks plugin) { 31 | this.plugin = plugin; 32 | } 33 | 34 | public void onAuth(Player player) { 35 | if (!plugin.isEnabled() || player == null) 36 | return; 37 | 38 | plugin.setAuthenticated(player.getUniqueId(), true); 39 | if (!plugin.hasBackend(player.getUniqueId()) && plugin.getConfig().getBoolean("use-auth-plugin", plugin.getConfig().getBoolean("useauth", false))) { 40 | String serverName = ""; 41 | if (player.getCurrentServer().isPresent()) { 42 | serverName = player.getCurrentServer().get().getServerInfo().getName(); 43 | } 44 | long sendDelay = plugin.getPackManager().getAssignment(serverName).getSendDelay(); 45 | if (sendDelay < 0) { 46 | sendDelay = plugin.getPackManager().getGlobalAssignment().getSendDelay(); 47 | } 48 | plugin.logDebug(player.getUsername() + " authenticated on the backend server " + serverName + "! Sending pack in " + sendDelay + " ticks..."); 49 | ResourcepacksPlayer rpPlayer = plugin.getPlayer(player); 50 | if (sendDelay > 0) { 51 | String finalServerName = serverName; 52 | plugin.getProxy().getScheduler() 53 | .buildTask(plugin, () -> plugin.getPackManager().applyPack(rpPlayer, finalServerName)) 54 | .delay(sendDelay * 20, TimeUnit.MILLISECONDS) 55 | .schedule(); 56 | } else { 57 | plugin.getPackManager().applyPack(rpPlayer, serverName); 58 | } 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/listeners/AuthMeVelocityListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - velocity 5 | * Copyright (C) 2022 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.velocitypowered.api.event.Subscribe; 22 | import de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks; 23 | import io.github._4drian3d.authmevelocity.api.velocity.event.ProxyLoginEvent; 24 | import io.github._4drian3d.authmevelocity.api.velocity.event.ProxyRegisterEvent; 25 | 26 | public class AuthMeVelocityListener extends AuthHandler { 27 | 28 | public AuthMeVelocityListener(VelocityResourcepacks plugin) { 29 | super(plugin); 30 | } 31 | 32 | @Subscribe 33 | public void onAuth(ProxyLoginEvent event) { 34 | onAuth(event.player()); 35 | } 36 | 37 | @Subscribe 38 | public void onAuth(ProxyRegisterEvent event) { 39 | onAuth(event.player()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/listeners/ConnectListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - velocity 5 | * Copyright (C) 2024 Max Lee aka Phoenix616 (max@themoep.de) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.velocitypowered.api.event.Subscribe; 22 | import com.velocitypowered.api.event.connection.PostLoginEvent; 23 | import de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks; 24 | 25 | /** 26 | * Created by Phoenix616 on 14.05.2015. 27 | */ 28 | public class ConnectListener { 29 | 30 | private final VelocityResourcepacks plugin; 31 | 32 | public ConnectListener(VelocityResourcepacks plugin) { 33 | this.plugin = plugin; 34 | } 35 | 36 | @Subscribe 37 | public void onPlayerConnect(PostLoginEvent event) { 38 | if (plugin.isEnabled()) { 39 | plugin.getUserManager().onConnect(event.getPlayer().getUniqueId()); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/listeners/CurrentServerTracker.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - VelocityResourcepacks 5 | * Copyright (C) 2024 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.velocitypowered.api.event.PostOrder; 22 | import com.velocitypowered.api.event.Subscribe; 23 | import com.velocitypowered.api.event.connection.DisconnectEvent; 24 | import com.velocitypowered.api.event.player.ServerPostConnectEvent; 25 | import com.velocitypowered.api.event.player.ServerPreConnectEvent; 26 | import com.velocitypowered.api.proxy.Player; 27 | import de.themoep.resourcepacksplugin.core.ResourcepacksPlugin; 28 | 29 | import java.util.Map; 30 | import java.util.UUID; 31 | import java.util.concurrent.ConcurrentHashMap; 32 | 33 | public class CurrentServerTracker { 34 | 35 | private final ResourcepacksPlugin plugin; 36 | 37 | private final Map currentServer = new ConcurrentHashMap<>(); 38 | 39 | public CurrentServerTracker(ResourcepacksPlugin plugin) { 40 | this.plugin = plugin; 41 | } 42 | 43 | @Subscribe(order = PostOrder.LAST) 44 | public void onServerConnect(ServerPreConnectEvent event) { 45 | if (plugin.isEnabled() && event.getResult().getServer().isPresent()) { 46 | plugin.logDebug("Player " + event.getPlayer().getUsername() + " is connecting to server " + event.getResult().getServer().get().getServerInfo().getName()); 47 | currentServer.put(event.getPlayer().getUniqueId(), event.getResult().getServer().get().getServerInfo().getName()); 48 | } 49 | } 50 | 51 | @Subscribe 52 | public void onPlayerDisconnect(DisconnectEvent event) { 53 | currentServer.remove(event.getPlayer().getUniqueId()); 54 | } 55 | 56 | @Subscribe 57 | public void onServerSwitch(ServerPostConnectEvent event) { 58 | if (plugin.isEnabled()) { 59 | currentServer.remove(event.getPlayer().getUniqueId()); 60 | } 61 | } 62 | 63 | /** 64 | * Get the server the player is currently on or connecting to 65 | * @param player The player 66 | * @return The name of the server 67 | */ 68 | public String getCurrentServer(Player player) { 69 | if (player.getCurrentServer().isPresent()) { 70 | return player.getCurrentServer().get().getServerInfo().getName(); 71 | } 72 | return currentServer.get(player.getUniqueId()); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/listeners/DisconnectListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - velocity 5 | * Copyright (C) 2020 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.velocitypowered.api.event.Subscribe; 22 | import com.velocitypowered.api.event.connection.DisconnectEvent; 23 | import de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks; 24 | 25 | /** 26 | * Created by Phoenix616 on 14.05.2015. 27 | */ 28 | public class DisconnectListener { 29 | 30 | private VelocityResourcepacks plugin; 31 | 32 | public DisconnectListener(VelocityResourcepacks plugin) { 33 | this.plugin = plugin; 34 | } 35 | 36 | @Subscribe 37 | public void onPlayerDisconnect(DisconnectEvent event) { 38 | if (plugin.isEnabled()) { 39 | plugin.getUserManager().onDisconnect(event.getPlayer().getUniqueId()); 40 | plugin.setAuthenticated(event.getPlayer().getUniqueId(), false); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/listeners/JPremiumListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - velocity 5 | * Copyright (C) 2022 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.jakub.jpremium.velocity.api.event.UserEvent; 22 | import com.velocitypowered.api.event.Subscribe; 23 | import com.velocitypowered.api.proxy.Player; 24 | import de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks; 25 | 26 | public class JPremiumListener extends AuthHandler { 27 | 28 | public JPremiumListener(VelocityResourcepacks plugin) { 29 | super(plugin); 30 | } 31 | 32 | @Subscribe 33 | public void onAuth(UserEvent.Login event) { 34 | if (event.getCommandSource().isPresent() && event.getCommandSource().get() instanceof Player) { 35 | onAuth((Player) event.getCommandSource().get()); 36 | } else { 37 | plugin.getProxy().getPlayer(event.getUserProfile().getUniqueId()).ifPresent(this::onAuth); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/listeners/LibreLoginListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - velocity 5 | * Copyright (C) 2022 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.velocitypowered.api.plugin.PluginContainer; 22 | import com.velocitypowered.api.proxy.Player; 23 | import com.velocitypowered.api.proxy.server.RegisteredServer; 24 | import de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks; 25 | import xyz.kyngs.librelogin.api.event.EventProvider; 26 | import xyz.kyngs.librelogin.api.provider.LibreLoginProvider; 27 | 28 | public class LibreLoginListener extends AuthHandler { 29 | 30 | public LibreLoginListener(VelocityResourcepacks plugin, PluginContainer libreLogin) { 31 | super(plugin); 32 | EventProvider eventProvider = ((LibreLoginProvider) libreLogin.getInstance().get()).getLibreLogin().getEventProvider(); 33 | eventProvider.subscribe(eventProvider.getTypes().authenticated, event -> onAuth(event.getPlayer())); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/listeners/LibrePremiumListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - velocity 5 | * Copyright (C) 2022 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.velocitypowered.api.plugin.PluginContainer; 22 | import com.velocitypowered.api.proxy.Player; 23 | import com.velocitypowered.api.proxy.server.RegisteredServer; 24 | import de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks; 25 | import xyz.kyngs.librepremium.api.event.events.AuthenticatedEvent; 26 | import xyz.kyngs.librepremium.api.provider.LibrePremiumProvider; 27 | 28 | public class LibrePremiumListener extends AuthHandler { 29 | 30 | public LibrePremiumListener(VelocityResourcepacks plugin, PluginContainer librePremium) { 31 | super(plugin); 32 | ((LibrePremiumProvider) librePremium.getInstance().get()).getLibrePremium().getEventProvider() 33 | .subscribe(AuthenticatedEvent.class, event -> onAuth((Player) event.getPlayer())); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/listeners/NLoginListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - bungee 5 | * Copyright (C) 2022 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.nickuc.login.api.event.velocity.auth.AuthenticateEvent; 22 | import com.velocitypowered.api.event.Subscribe; 23 | import de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks; 24 | 25 | public class NLoginListener extends AuthHandler { 26 | 27 | public NLoginListener(VelocityResourcepacks plugin) { 28 | super(plugin); 29 | } 30 | 31 | @Subscribe 32 | public void onAuth(AuthenticateEvent event) { 33 | onAuth(event.getPlayer()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /velocity/src/main/java/de/themoep/resourcepacksplugin/velocity/listeners/PluginMessageListener.java: -------------------------------------------------------------------------------- 1 | package de.themoep.resourcepacksplugin.velocity.listeners; 2 | 3 | /* 4 | * ResourcepacksPlugins - velocity 5 | * Copyright (C) 2020 Max Lee aka Phoenix616 (mail@moep.tv) 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | import com.velocitypowered.api.event.PostOrder; 22 | import com.velocitypowered.api.event.Subscribe; 23 | import com.velocitypowered.api.event.connection.PluginMessageEvent; 24 | import com.velocitypowered.api.event.player.ServerPostConnectEvent; 25 | import com.velocitypowered.api.proxy.ServerConnection; 26 | import com.velocitypowered.api.proxy.messages.ChannelIdentifier; 27 | import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; 28 | import com.velocitypowered.api.proxy.server.RegisteredServer; 29 | import de.themoep.resourcepacksplugin.core.SubChannelHandler; 30 | import de.themoep.resourcepacksplugin.velocity.PluginConfig; 31 | import de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks; 32 | 33 | import java.io.File; 34 | import java.util.UUID; 35 | import java.util.logging.Level; 36 | 37 | public class PluginMessageListener extends SubChannelHandler { 38 | private static final ChannelIdentifier CHANNEL_IDENTIFIER = MinecraftChannelIdentifier.from(MESSAGING_CHANNEL); 39 | 40 | private final VelocityResourcepacks plugin; 41 | 42 | private final PluginConfig keyConfig; 43 | 44 | private final AuthHandler authHandler; 45 | 46 | public PluginMessageListener(VelocityResourcepacks plugin) { 47 | super(plugin); 48 | this.plugin = plugin; 49 | authHandler = new AuthHandler(plugin); 50 | keyConfig = new PluginConfig(plugin, new File(plugin.getDataFolder(), "key.yml"), null); 51 | registerSubChannel("authLogin", (s, in) -> { 52 | String playerName = in.readUTF(); 53 | UUID playerId = UUID.fromString(in.readUTF()); 54 | if (!plugin.isAuthenticated(playerId)) { 55 | plugin.getProxy().getPlayer(playerId).ifPresent(authHandler::onAuth); 56 | } 57 | }); 58 | } 59 | 60 | @Subscribe(order = PostOrder.FIRST) 61 | public void pluginMessageReceived(PluginMessageEvent event) { 62 | if (!plugin.isEnabled() || !event.getIdentifier().equals(CHANNEL_IDENTIFIER)) 63 | return; 64 | 65 | event.setResult(PluginMessageEvent.ForwardResult.handled()); 66 | if (event.getSource() instanceof ServerConnection) { 67 | handleMessage(((ServerConnection) event.getSource()).getServer(), event.getData()); 68 | } else { 69 | plugin.logDebug("Received plugin message from " + event.getSource() + " which is not a ServerConnection!"); 70 | } 71 | } 72 | 73 | @Subscribe 74 | public void onServerSwitch(ServerPostConnectEvent event) { 75 | if (plugin.isEnabled()) { 76 | event.getPlayer().getCurrentServer().ifPresent(serverConnection -> sendKey(serverConnection.getServer())); 77 | } 78 | } 79 | 80 | @Override 81 | protected void sendPluginMessage(RegisteredServer target, byte[] data) { 82 | try { 83 | target.sendPluginMessage(CHANNEL_IDENTIFIER, data); 84 | } catch (Exception e) { 85 | plugin.log(Level.WARNING, "Failed to send plugin message to server " + target.getServerInfo().getName() + "!" + 86 | " This is most likely because the player connection timed out. " + e.getMessage()); 87 | plugin.logDebug("Plugin message sending error:", e); 88 | } 89 | } 90 | 91 | @Override 92 | protected void saveKey(String key) { 93 | keyConfig.set("key", key); 94 | keyConfig.save(); 95 | } 96 | 97 | @Override 98 | protected String loadKey() { 99 | String key = null; 100 | if (keyConfig.load()) { 101 | key = keyConfig.getString("key", null); 102 | } else { 103 | plugin.log(Level.SEVERE, "Unable to load key.yml! Forwarding info to the plugin on the Minecraft server will not work!"); 104 | } 105 | if (key == null) { 106 | key = generateKey(); 107 | saveKey(key); 108 | } 109 | return key; 110 | } 111 | 112 | @Override 113 | protected String getTargetType() { 114 | return "Minecraft server"; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /velocity/src/main/resources/velocity-config.yml: -------------------------------------------------------------------------------- 1 | debug: true 2 | # Default language 3 | default-language: en 4 | # Disable all metrics included in this plugin. 5 | disable-metrics: false 6 | # Whether or not resourcepack file hashes should be generated on startup: 7 | autogeneratehashes: true 8 | # Whether to append the pack hash to the end of the URL of the pack like url#hash. 9 | # This is necessary to work around a Vanilla bug which prevents changed packs from being downloaded 10 | # properly again: https://bugs.mojang.com/browse/MC-164316 11 | append-hash-to-url: true 12 | # Whether /usepack should apply packs temporary or permanent when run without any argument: 13 | usepack-is-temporary: true 14 | # Whether packs that a player has stored will override a matched assignments 15 | stored-packs-override-assignments: false 16 | # When manually setting a permanent pack then it will be reset if the user disconnects in under x amount of seconds. 17 | # 0 or anything below will disable this functionality 18 | permanent-pack-remove-time: 30 19 | # Whether to only send packs if authenticated on the Minecraft server 20 | # Requires WorldResourcepacks to be installed on the Minecraft server too 21 | use-auth-plugin: false 22 | # Different packs can be defined in this section 23 | packs: 24 | lobbypack: 25 | # The url the client should download the resourcepack from. 26 | # Has to be a direct download link! No mediafire/mega/other oneclick-hoster! 27 | url: http://example.com/lobbyresourcepack.zip 28 | # The sha1 hash of the resourcepack's zip file, 29 | # if not correct the client will waste bandwidth but it will still work! 30 | # At least that's what the Minecraft wiki says... (Site: Server.properties#Minecraft_server_properties) 31 | hash: abcdef012345678abcdef012345678abcdef0123 32 | # The UUID of the pack, if not set then it will be generated from the name 33 | uuid: 01234567-89ab-cdef-0123-456789abcdef 34 | # The format version of this resourcepack 35 | format: 1 36 | # Directly define the Minecraft version instead of the format 37 | # Supports string representation of the versions and protocol numbers 38 | # You don't need to define both the version and the format (if so then the highest one will take effect) 39 | version: "1.8" 40 | # Whether or not this pack will only be send to players with a certain permission 41 | # permission: velocityresourcepacks.pack. 42 | restricted: false 43 | # If you want you can define a specific permission for this pack if you don't want 44 | # the default velocityresourcepacks.pack. permission! 45 | permission: velocityresourcepacks.pack.lobbypack 46 | globalpack: 47 | url: http://example.com/globalpack.zip 48 | hash: abcdef012345678abcdef012345678abcdef0123 49 | gamepack: 50 | # Set different variants e.g. for different versions or permissions 51 | # This list supports all normal pack settings and is checked top to bottom. 52 | # The first one that matches the player will be used. 53 | variants: 54 | - url: http://example.com/minigameresourcepack_1_15.zip 55 | hash: 012345678abcdef012345678abcdef012345678a 56 | version: '1.15' 57 | - url: http://example.com/minigameresourcepack_1_12.zip 58 | hash: 012345678abcdef01234567dddcdef012345678a 59 | version: '1.12' 60 | # Define as many packs as you want 61 | another_example_pack: 62 | url: http://example.com/another.zip 63 | hash: abcdef012345678abcdef012345678abcdef0123 64 | # Empty pack to reset the pack to the default one 65 | empty: 66 | url: http://cdn.moep.tv/files/Empty.zip 67 | hash: 01517226212d27586ea0c5d6aff1aa5492dd2484 68 | global: 69 | # Define a global pack: 70 | pack: globalpack 71 | # List of packs to not replace if the user already has them 72 | # If no main pack is set the first one also gets used to reset 73 | # the pack if the user has a non-optional one 74 | # Also this list will be used to select a pack if a user does not have the permission 75 | # or the right version to use that pack. (From top to bottom) 76 | optional-packs: 77 | - lobbypack 78 | # Delay in ticks before sending the pack to a player after he logs in/switches to the server 79 | send-delay: 20 80 | # Different servers with different packs can be defined here 81 | servers: 82 | # Config for a server named "lobby" 83 | lobby: 84 | # You can define multiple packs starting with 1.20.3 85 | # On versions prior to it only the first pack will be used 86 | packs: 87 | - lobbypack 88 | - globalpack 89 | optional-packs: 90 | - gamepack 91 | minigame: 92 | pack: gamepack 93 | # Use a regex to target all servers with a certain name 94 | regex: 'minigame_.*' 95 | # Define as many servers as you want. 96 | # The name of the section is the server name unless a regex is specified. 97 | another_example_server: 98 | pack: another_example_pack 99 | -------------------------------------------------------------------------------- /velocity/src/main/resources/velocity-plugin.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "velocityresourcepacks", 3 | "name": "VelocityResourcepacks", 4 | "version": "${minecraft.plugin.version}", 5 | "main": "de.themoep.resourcepacksplugin.velocity.VelocityResourcepacks", 6 | "authors": ["Phoenix616"], 7 | "dependencies": [ 8 | { 9 | "id": "viaversion", 10 | "optional": true 11 | }, 12 | { 13 | "id": "geyser", 14 | "optional": true 15 | }, 16 | { 17 | "id": "floodgate", 18 | "optional": true 19 | }, 20 | { 21 | "id": "authmevelocity", 22 | "optional": true 23 | }, 24 | { 25 | "id": "nlogin", 26 | "optional": true 27 | }, 28 | { 29 | "id": "librepremium", 30 | "optional": true 31 | }, 32 | { 33 | "id": "librelogin", 34 | "optional": true 35 | } 36 | ] 37 | } -------------------------------------------------------------------------------- /worldresourcepacks/src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [{ 2 | "modid": "worldresourcepacks", 3 | "name": "WorldResourcepacks", 4 | "version": "${minecraft.plugin.version}", 5 | "description": "Send different server resource packs to players per world.", 6 | "authorList": [ 7 | "Phoenix616" 8 | ], 9 | "dependencies": [ 10 | {"id":"viaversion", "optional": true}, 11 | {"id":"geyser", "optional": true}, 12 | {"id":"floodgate", "optional": true} 13 | ] 14 | }] -------------------------------------------------------------------------------- /worldresourcepacks/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: ${project.name} 2 | main: de.themoep.resourcepacksplugin.bukkit.WorldResourcepacks 3 | version: '${minecraft.plugin.version}' 4 | author: Phoenix616 5 | softdepend: [ViaVersion, ProtocolSupport, Geyser-Spigot, floodgate, AuthMe, OpeNLogin, nLogin, LibreLogin] 6 | api-version: 1.13 7 | commands: 8 | wrp: 9 | aliases: [worldresourcepacks] 10 | description: Main plugin command. 11 | usage: / [addpack|pack|listassignments|assignment|deleteassignment|globalassignment|generatehashes|reload [resend]|version] 12 | permission: worldresourcepacks.command 13 | permission-message: You don't have the permission 14 | usepack: 15 | description: Command for setting the pack of a player. 16 | usage: / [] [] 17 | permission: worldresourcepacks.command.usepack 18 | permission-message: You don't have the permission 19 | resetpack: 20 | description: Command for resetting the pack of a player. 21 | usage: / [] [] 22 | permission: worldresourcepacks.command.resetpack 23 | permission-message: You don't have the permission 24 | permissions: 25 | worldresourcepacks.command: 26 | description: Gives permission to use the command 27 | default: op 28 | worldresourcepacks.command.usepack: 29 | description: Gives permission to set ones pack 30 | default: op 31 | worldresourcepacks.command.usepack.others: 32 | description: Gives permission to set the pack of other players 33 | default: op 34 | worldresourcepacks.command.usepack.temporary: 35 | description: Gives permission to set whether or not the pack should only be temporary set and not stored 36 | default: op 37 | worldresourcepacks.command.resetpack: 38 | description: Gives permission to reset ones pack 39 | default: op 40 | worldresourcepacks.command.resetpack.others: 41 | description: Gives permission to reset the pack of other players 42 | default: op 43 | worldresourcepacks.command.resetpack.temporary: 44 | description: Gives permission to reset whether or not the pack should only be temporary reset and not stored 45 | default: op 46 | worldresourcepacks.command.generatehashes: 47 | description: Gives permission to (re-)generate the sha1 hashes of the packs 48 | default: op 49 | worldresourcepacks.command.version: 50 | description: Gives permission to see the plugin's version 51 | default: op 52 | worldresourcepacks.command.reload: 53 | description: Gives permission to reload the plugin 54 | default: op --------------------------------------------------------------------------------