`, etc.)
299 | ///
300 |
301 | Sets the text to display in the Server's MOTD.
302 | Only the first two lines are considered and every additional one will be ignored.
303 |
304 | Set to an empty List (`#!yaml Motd: []`) to not modify the MOTD.
305 |
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | # Welcome to the OneVersionRemake Wiki
2 |
3 | OneVersionRemake is a plugin that allows you to allow/block specific Minecraft versions from joining your servers, displaying a custom MOTD, player count, hover text and kick message.
4 |
5 | ## Pages
6 |
7 |
8 |
9 | - ## [Config.yml](config.md)
10 |
11 | ----
12 |
13 | Page covering the different options available in the config.yml of OneVersionRemake
14 |
15 | - ## [Supported Protocols](protocols.md)
16 |
17 | ----
18 |
19 | A list of supported Protocol Versions that OneVersionRemake can translate into readable MC versions.
20 |
21 |
--------------------------------------------------------------------------------
/docs/protocols.md:
--------------------------------------------------------------------------------
1 | # Supported Protocols
2 |
3 | Due to BungeeCord not offering a way to convert a player's protocol version into a readable MC version, does OneVersionRemake have its own system in place to do so.
4 | This system is used to replace `{version}` and `{userVersion}` with readable MC versions. Former will display a comma-separated list of the configured Protocol Versions while the later will display the Player's MC version.
5 |
6 | To achieve this feature does OneVersionRemake pull from a JSON file which contains the necessary info. The source may differ depending on the version used:
7 |
8 | - `v3.11.0` and newer: https://andre601.ch/oneversionremake/protocol_versions.json ([Source](https://codeberg.org/Andre601/website/src/branch/main/docs/oneversionremake/protocol_versions.json))
9 | - `v3.9.0` through `v3.10.0`: https://andre601.ch/oneversionremake/versions.json ([Source](https://codeberg.org/Andre601/website/src/branch/main/docs/oneversionremake/versions.json))
10 | - `v3.8.2` and older: https://raw.githubusercontent.com/Andre601/OneVersionRemake/master/versions.json ([Source](https://github.com/Andre601/OneVersionRemake/blob/master/versions.json))
11 |
12 | You are free to customize the file to your liking by adding or removing entries from it and you can even [change the source URL to pull from](config.md#versionsurl), just keep the structure of the file in mind.
13 |
14 | /// note
15 | Any protocol version not listed in the JSON file will be displayed as `?`
16 | ///
17 |
18 | ## Versions
19 |
20 | Below is a table of supported Protocol Versions which will be translated into their respective MC version or Major MC Version for the `{version}` and `{userVersion}` placeholder.
21 |
22 | /// note
23 | The table is automatically created using the latest [`protocol_versions.json` file](https://andre601.ch/oneversionremake/protocol_versions.json) as source.
24 | If you're unable to see the Table, make sure you allow Javascript or otherwise check the above link for the JSON file.
25 | ///
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/mkdocs.yml:
--------------------------------------------------------------------------------
1 | site_name: 'OneVersionRemake'
2 | site_description: 'Wiki of the Plugin OneVersionRemake'
3 | site_author: 'Andre_601'
4 | site_url: 'https://ovr.andre601.ch'
5 |
6 | copyright: |
7 | Plugin and Wiki licensed under MIT License.
8 |
9 | docs_dir: 'docs/'
10 |
11 | repo_name: 'OneVersionRemake'
12 | repo_url: 'https://github.com/Andre601/OneVersionRemake'
13 |
14 | theme:
15 | name: 'material'
16 | favicon: 'assets/img/favicon.png'
17 | logo: 'assets/img/favicon.png'
18 | icon:
19 | admonition:
20 | note: octicons/pencil-16
21 | abstract: octicons/checklist-16
22 | info: octicons/info-16
23 | tip: octicons/squirrel-16
24 | success: octicons/check-16
25 | question: octicons/question-16
26 | warning: octicons/alert-16
27 | failure: octicons/x-circle-16
28 | danger: octicons/zap-16
29 | bug: octicons/bug-16
30 | example: octicons/beaker-16
31 | quote: octicons/comment-16
32 | palette:
33 | scheme: 'slate'
34 | primary: 'red'
35 | features:
36 | - navigation.tabs
37 | - navigation.tabs.sticky
38 |
39 | extra:
40 | social:
41 | - icon: 'simple/github'
42 | link: 'https://github.com/Andre601/OneVersionRemake'
43 | - icon: 'simple/modrinth'
44 | link: 'https://modrinth.com/plugin/oneversionremake'
45 |
46 | extra_css:
47 | - 'assets/css/custom.css'
48 |
49 | extra_javascript:
50 | - 'assets/js/version-table-gen.js'
51 |
52 | nav:
53 | - Home: index.md
54 | - Config.yml: config.md
55 | - Supported Protocols: protocols.md
56 |
57 | markdown_extensions:
58 | - md_in_html
59 | - toc:
60 | permalink: true
61 | - pymdownx.highlight
62 | - pymdownx.inlinehilite
63 | - pymdownx.superfences
64 | - pymdownx.magiclink
65 | - pymdownx.blocks.admonition:
66 | types:
67 | - note
68 | - abstract
69 | - info
70 | - tip
71 | - success
72 | - question
73 | - warning
74 | - failure
75 | - danger
76 | - bug
77 | - example
78 | - quote
79 | - pymdownx.blocks.details:
80 | - pymdownx.blocks.tab:
81 | alternate_style: true
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.andre601.oneversionremake
8 | parent
9 | pom
10 | parent
11 |
12 |
13 | UTF-8
14 |
15 | 3.12.0
16 | Only allow specific client versions on your Network.
17 |
18 | 11
19 | 11
20 |
21 |
22 |
23 | core
24 | bungeecord
25 | velocity
26 |
27 |
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "extends": [
4 | "config:recommended",
5 | "group:allNonMajor"
6 | ],
7 | "labels": ["Type: Update (Dependency)"],
8 | "packageRules": [
9 | {
10 | "description": "Apply label for GitHub Actions",
11 | "matchFileNames": [
12 | ".github/workflows/publish-artifacts.yml",
13 | ".github/workflows/wiki.yml"
14 | ],
15 | "addLabels": ["Target: GitHub Actions"]
16 | },
17 | {
18 | "description": "Apply label for BungeeCord",
19 | "matchFileNames": ["bungeecord/pom.xml"],
20 | "addLabels": ["Target: BungeeCord"]
21 | },
22 | {
23 | "description": "Apply label for Core",
24 | "matchFileNames": ["core/pom.xml"],
25 | "addLabels": ["Target: Core"]
26 | },
27 | {
28 | "description": "Apply label for Velocity",
29 | "matchFileNames": ["velocity/pom.xml"],
30 | "addLabels": ["Target: Velocity"]
31 | }
32 | ]
33 | }
34 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | mkdocs-material==9.6.14
--------------------------------------------------------------------------------
/velocity/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
23 | 4.0.0
24 |
25 | velocity
26 | jar
27 | ${plugin.version}
28 | ${plugin.description}
29 |
30 |
31 | parent
32 | com.andre601.oneversionremake
33 | parent
34 |
35 |
36 |
37 |
38 | velocity
39 | https://repo.papermc.io/repository/maven-public/
40 |
41 |
42 | sonatype
43 | https://oss.sonatype.org/content/repositories/snapshots/
44 |
45 |
46 |
47 |
48 |
49 | com.andre601.oneversionremake
50 | core
51 | ${project.version}
52 | compile
53 |
54 |
55 | com.velocitypowered
56 | velocity-api
57 | 3.1.2-SNAPSHOT
58 | provided
59 |
60 |
61 | org.bstats
62 | bstats-velocity
63 | 3.1.0
64 | compile
65 |
66 |
67 | org.spongepowered
68 | configurate-yaml
69 | 4.2.0
70 |
71 |
72 |
73 |
74 | OneVersionRemake-Velocity-${project.version}
75 |
76 |
77 | true
78 | ${project.basedir}/src/main/resources
79 |
80 |
81 |
82 |
83 | org.apache.maven.plugins
84 | maven-compiler-plugin
85 | 3.14.0
86 |
87 |
88 | org.apache.maven.plugins
89 | maven-shade-plugin
90 | 3.6.0
91 |
92 | true
93 |
94 |
95 | org.spongepowered.configurate
96 | com.andre601.oneversionremake.velocity.dependencies.configurate
97 |
98 |
99 | org.bstats
100 | com.andre601.oneversionremake.velocity.dependencies.bstats
101 |
102 |
103 |
104 |
105 | *:*
106 |
107 | META-INF/*.SF
108 | META-INF/*.RSA
109 | META-INF/versions/16/
110 |
111 |
112 |
113 |
114 |
115 |
116 | package
117 |
118 | shade
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/velocity/src/main/java/com/andre601/oneversionremake/velocity/VelocityCore.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 - 2021 Andre601
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
6 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial
10 | * portions of the Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
15 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
16 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 |
19 | package com.andre601.oneversionremake.velocity;
20 |
21 | import com.andre601.oneversionremake.core.OneVersionRemake;
22 | import com.andre601.oneversionremake.core.Parser;
23 | import com.andre601.oneversionremake.core.commands.CommandHandler;
24 | import com.andre601.oneversionremake.core.proxy.ProtocolVersionResolver;
25 | import com.andre601.oneversionremake.core.proxy.ProxyPlatform;
26 | import com.andre601.oneversionremake.core.files.ConfigHandler;
27 | import com.andre601.oneversionremake.core.interfaces.PluginCore;
28 | import com.andre601.oneversionremake.core.interfaces.ProxyLogger;
29 | import com.andre601.oneversionremake.velocity.commands.CmdOneVersionRemake;
30 | import com.andre601.oneversionremake.velocity.listener.VelocityLoginListener;
31 | import com.andre601.oneversionremake.velocity.listener.VelocityPingListener;
32 | import com.andre601.oneversionremake.velocity.logging.VelocityLogger;
33 | import com.google.inject.Inject;
34 | import com.velocitypowered.api.command.CommandMeta;
35 | import com.velocitypowered.api.event.Subscribe;
36 | import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
37 | import com.velocitypowered.api.plugin.annotation.DataDirectory;
38 | import com.velocitypowered.api.proxy.ProxyServer;
39 | import com.velocitypowered.api.proxy.server.ServerPing;
40 | import org.bstats.charts.DrilldownPie;
41 | import org.bstats.velocity.Metrics;
42 | import org.slf4j.LoggerFactory;
43 |
44 | import java.nio.file.Path;
45 | import java.util.List;
46 |
47 | public class VelocityCore implements PluginCore{
48 |
49 | private final ProxyLogger logger;
50 | private final ProxyServer proxy;
51 | private final Path path;
52 |
53 | private final Metrics.Factory factory;
54 |
55 | private OneVersionRemake core;
56 |
57 | @Inject
58 | public VelocityCore(ProxyServer proxy, @DataDirectory Path path, Metrics.Factory factory){
59 | this.logger = new VelocityLogger(LoggerFactory.getLogger("OneVersionRemake"));
60 |
61 | this.proxy = proxy;
62 | this.path = path;
63 | this.factory = factory;
64 | }
65 |
66 | @Subscribe
67 | public void initialize(ProxyInitializeEvent event){
68 | this.core = new OneVersionRemake(this);
69 | }
70 |
71 | // PluginCore stuff
72 |
73 | @Override
74 | public void loadCommands(){
75 | CommandMeta commandMeta = getProxy().getCommandManager()
76 | .metaBuilder("oneversionremake")
77 | .aliases("ovr")
78 | .build();
79 |
80 | getProxy().getCommandManager().register(commandMeta, new CmdOneVersionRemake(this));
81 | }
82 |
83 | @Override
84 | public void loadEventListeners(){
85 | new VelocityLoginListener(this);
86 | new VelocityPingListener(this);
87 | }
88 |
89 | @Override
90 | public void loadMetrics(){
91 | Metrics metrics = factory.make(this, 10341);
92 |
93 | metrics.addCustomChart(new DrilldownPie("allowed_protocols", () -> core.getPieMap()));
94 |
95 | }
96 |
97 | @Override
98 | public Path getPath(){
99 | return path;
100 | }
101 |
102 | @Override
103 | public ProxyPlatform getProxyPlatform(){
104 | return ProxyPlatform.VELOCITY;
105 | }
106 |
107 | @Override
108 | public ProxyLogger getProxyLogger(){
109 | return logger;
110 | }
111 |
112 | @Override
113 | public ConfigHandler getConfigHandler(){
114 | return core.getConfigHandler();
115 | }
116 |
117 | @Override
118 | public ProtocolVersionResolver getProtocolVersionResolver(){
119 | return core.getProtocolVersionResolver();
120 | }
121 |
122 | @Override
123 | public CommandHandler getCommandHandler(){
124 | return core.getCommandHandler();
125 | }
126 |
127 | @Override
128 | public Parser getComponentParser(){
129 | return core.getComponentParser();
130 | }
131 |
132 | @Override
133 | public String getVersion(){
134 | return core.getVersion();
135 | }
136 |
137 | @Override
138 | public String getProxyVersion(){
139 | return getProxy().getVersion().getVersion();
140 | }
141 |
142 | public ProxyServer getProxy(){
143 | return proxy;
144 | }
145 |
146 | public ServerPing.SamplePlayer[] getPlayers(List lines, List serverProtocols, int userProtocol, boolean majorOnly, boolean blacklist){
147 | return core.getPlayers(ServerPing.SamplePlayer.class, lines, serverProtocols, userProtocol, majorOnly, blacklist)
148 | .toArray(new ServerPing.SamplePlayer[0]);
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/velocity/src/main/java/com/andre601/oneversionremake/velocity/commands/CmdOneVersionRemake.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 - 2021 Andre601
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
6 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial
10 | * portions of the Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
15 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
16 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 |
19 | package com.andre601.oneversionremake.velocity.commands;
20 |
21 | import com.andre601.oneversionremake.velocity.VelocityCore;
22 | import com.velocitypowered.api.command.SimpleCommand;
23 |
24 | public class CmdOneVersionRemake implements SimpleCommand{
25 |
26 | private final VelocityCore plugin;
27 |
28 | public CmdOneVersionRemake(VelocityCore plugin){
29 | this.plugin = plugin;
30 | }
31 |
32 | @Override
33 | public void execute(Invocation invocation){
34 | VelocitySender sender = new VelocitySender(invocation.source());
35 | String[] args = invocation.arguments();
36 |
37 | plugin.getCommandHandler().handle(sender, args);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/velocity/src/main/java/com/andre601/oneversionremake/velocity/commands/VelocitySender.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 - 2021 Andre601
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
6 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial
10 | * portions of the Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
15 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
16 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 |
19 | package com.andre601.oneversionremake.velocity.commands;
20 |
21 | import com.andre601.oneversionremake.core.CommandPermissions;
22 | import com.andre601.oneversionremake.core.interfaces.CmdSender;
23 | import com.velocitypowered.api.command.CommandSource;
24 | import net.kyori.adventure.text.Component;
25 | import net.kyori.adventure.text.format.NamedTextColor;
26 |
27 | public class VelocitySender implements CmdSender{
28 |
29 | private final CommandSource sender;
30 |
31 | public VelocitySender(CommandSource sender){
32 | this.sender = sender;
33 | }
34 |
35 | @Override
36 | public boolean hasPermission(String permission){
37 | return sender.hasPermission(permission) || sender.hasPermission(CommandPermissions.ADMIN);
38 | }
39 |
40 | @Override
41 | public void sendMsg(){
42 | sendMsg("");
43 | }
44 |
45 | @Override
46 | public void sendMsg(String msg, Object... args){
47 | sendMsg(NamedTextColor.WHITE, msg, args);
48 | }
49 |
50 | @Override
51 | public void sendMsg(NamedTextColor color, String msg, Object... args){
52 | sender.sendMessage(Component.text(String.format(msg, args)).color(color));
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/velocity/src/main/java/com/andre601/oneversionremake/velocity/listener/VelocityLoginListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 - 2021 Andre601
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
6 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial
10 | * portions of the Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
15 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
16 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 |
19 | package com.andre601.oneversionremake.velocity.listener;
20 |
21 | import com.andre601.oneversionremake.velocity.VelocityCore;
22 | import com.velocitypowered.api.event.PostOrder;
23 | import com.velocitypowered.api.event.Subscribe;
24 | import com.velocitypowered.api.event.connection.PreLoginEvent;
25 |
26 | import java.util.Collections;
27 | import java.util.List;
28 |
29 | public class VelocityLoginListener{
30 |
31 | private final VelocityCore plugin;
32 |
33 | public VelocityLoginListener(VelocityCore plugin){
34 | this.plugin = plugin;
35 | plugin.getProxy().getEventManager().register(plugin, this);
36 | }
37 |
38 | @Subscribe(order = PostOrder.FIRST)
39 | public void onPreLogin(PreLoginEvent event){
40 | List serverProtocols = plugin.getConfigHandler().getIntList("Protocol", "Versions");
41 | List kickMessage = plugin.getConfigHandler().getStringList(false, "Messages", "Kick");
42 |
43 | boolean majorOnly = plugin.getConfigHandler().getBoolean(false, "Protocol", "MajorOnly");
44 | boolean blacklist = plugin.getConfigHandler().getBoolean(false, "Protocol", "Blacklist");
45 |
46 | int userProtocol = event.getConnection().getProtocolVersion().getProtocol();
47 | if(serverProtocols.isEmpty())
48 | return;
49 |
50 | if((blacklist && serverProtocols.contains(userProtocol)) || (!blacklist && !serverProtocols.contains(userProtocol))){
51 | if(kickMessage.isEmpty())
52 | kickMessage = Collections.singletonList("&cThis Server is running MC {version}! Please change your client version.");
53 |
54 | PreLoginEvent.PreLoginComponentResult result = PreLoginEvent.PreLoginComponentResult
55 | .denied(plugin.getComponentParser().toComponent(kickMessage, serverProtocols, userProtocol, majorOnly, blacklist));
56 |
57 | event.setResult(result);
58 |
59 | if(plugin.getConfigHandler().getBoolean(true, "Protocol", "LogDenial")){
60 | plugin.getProxyLogger().infoFormat(
61 | "Denied login for Player %s with MC version %s (Protocol version: %d)",
62 | event.getUsername(),
63 | plugin.getProtocolVersionResolver().getVersions().getFriendlyName(userProtocol),
64 | userProtocol
65 | );
66 | }
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/velocity/src/main/java/com/andre601/oneversionremake/velocity/listener/VelocityPingListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 - 2021 Andre601
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
6 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial
10 | * portions of the Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
15 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
16 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 |
19 | package com.andre601.oneversionremake.velocity.listener;
20 |
21 | import com.andre601.oneversionremake.velocity.VelocityCore;
22 | import com.velocitypowered.api.event.PostOrder;
23 | import com.velocitypowered.api.event.Subscribe;
24 | import com.velocitypowered.api.event.proxy.ProxyPingEvent;
25 | import com.velocitypowered.api.proxy.server.ServerPing;
26 |
27 | import java.util.Comparator;
28 | import java.util.List;
29 |
30 | public class VelocityPingListener{
31 |
32 | private final VelocityCore plugin;
33 |
34 | public VelocityPingListener(VelocityCore plugin){
35 | this.plugin = plugin;
36 | plugin.getProxy().getEventManager().register(plugin, this);
37 | }
38 |
39 | @Subscribe(order = PostOrder.FIRST)
40 | public void onProxyPing(ProxyPingEvent event){
41 | ServerPing ping = event.getPing();
42 | ServerPing.Version protocolVersion = ping.getVersion();
43 | if(protocolVersion == null)
44 | return;
45 |
46 | int userProtocol = protocolVersion.getProtocol();
47 |
48 | List serverProtocols = plugin.getConfigHandler().getIntList("Protocol", "Versions");
49 |
50 | if(serverProtocols.isEmpty())
51 | return;
52 |
53 | serverProtocols.sort(Comparator.reverseOrder());
54 |
55 | boolean majorOnly = plugin.getConfigHandler().getBoolean(false, "Protocol", "MajorOnly");
56 | boolean blacklist = plugin.getConfigHandler().getBoolean(false, "Protocol", "Blacklist");
57 |
58 | String playerCount = plugin.getConfigHandler().getString("", "Messages", "PlayerCount");
59 | List motd = plugin.getConfigHandler().getStringList(true, "Messages", "Motd");
60 | List hoverMessage = plugin.getConfigHandler().getStringList(false, "Messages", "Hover");
61 |
62 | if((blacklist && serverProtocols.contains(userProtocol)) || (!blacklist && !serverProtocols.contains(userProtocol))){
63 | ServerPing.Builder builder = ping.asBuilder();
64 |
65 | if(!hoverMessage.isEmpty()){
66 | ServerPing.SamplePlayer[] players = plugin.getPlayers(hoverMessage, serverProtocols, userProtocol, majorOnly, blacklist);
67 | if(players != null)
68 | builder.samplePlayers(players);
69 | }
70 |
71 | if(!playerCount.isEmpty()){
72 | playerCount = plugin.getComponentParser().toString(playerCount, serverProtocols, userProtocol, majorOnly, blacklist);
73 |
74 | builder.version(new ServerPing.Version(-1, playerCount));
75 | }
76 |
77 | if(!motd.isEmpty()){
78 | builder.description(plugin.getComponentParser().toComponent(motd, serverProtocols, userProtocol, majorOnly, blacklist));
79 | }
80 |
81 | event.setPing(builder.build());
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/velocity/src/main/java/com/andre601/oneversionremake/velocity/logging/VelocityLogger.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 - 2021 Andre601
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5 | * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
6 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
7 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all copies or substantial
10 | * portions of the Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
14 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
15 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
16 | * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 | */
18 |
19 | package com.andre601.oneversionremake.velocity.logging;
20 |
21 | import com.andre601.oneversionremake.core.interfaces.ProxyLogger;
22 | import org.slf4j.Logger;
23 |
24 | public class VelocityLogger implements ProxyLogger{
25 |
26 | private final Logger logger;
27 |
28 | public VelocityLogger(Logger logger){
29 | this.logger = logger;
30 | }
31 |
32 | @Override
33 | public void info(String msg){
34 | logger.info(msg);
35 | }
36 |
37 | @Override
38 | public void infoFormat(String msg, Object... args){
39 | info(String.format(msg, args));
40 | }
41 |
42 | @Override
43 | public void warn(String msg){
44 | logger.warn(msg);
45 | }
46 |
47 | @Override
48 | public void warnFormat(String msg, Object... args){
49 | warn(String.format(msg, args));
50 | }
51 |
52 | @Override
53 | public void warn(String msg, Throwable throwable){
54 | logger.warn(msg, throwable);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/velocity/src/main/resources/velocity-plugin.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "oneversionremake",
3 | "name": "OneVersionRemake",
4 | "version": "${project.version}",
5 | "description": "${project.description}",
6 | "authors": [
7 | "Andre_601"
8 | ],
9 | "main": "com.andre601.oneversionremake.velocity.VelocityCore"
10 | }
11 |
--------------------------------------------------------------------------------
/versions.json:
--------------------------------------------------------------------------------
1 | {
2 | "note": [
3 | "This file is no longer updated and used by the latest OneVersionRemake version.",
4 | "The latest version can be found at https://codeberg.org/Andre601/website under",
5 | "/docs/oneversionremake/protocol_versions.json",
6 | "",
7 | "This file will no longer receive updates."
8 | ],
9 | "759": {
10 | "name": "1.19",
11 | "major": "1.19.x"
12 | },
13 | "758": {
14 | "name": "1.18.2",
15 | "major": "1.18.x"
16 | },
17 | "757": {
18 | "name": "1.18.1",
19 | "major": "1.18.x"
20 | },
21 | "756": {
22 | "name": "1.17.1",
23 | "major": "1.17.x"
24 | },
25 | "755": {
26 | "name": "1.17",
27 | "major": "1.17.x"
28 | },
29 | "754": {
30 | "name": "1.16.5",
31 | "major": "1.16.x"
32 | },
33 | "753": {
34 | "name": "1.16.3",
35 | "major": "1.16.x"
36 | },
37 | "751": {
38 | "name": "1.16.2",
39 | "major": "1.16.x"
40 | },
41 | "736": {
42 | "name": "1.16.1",
43 | "major": "1.16.x"
44 | },
45 | "735": {
46 | "name": "1.16",
47 | "major": "1.16.x"
48 | },
49 | "578": {
50 | "name": "1.15.2",
51 | "major": "1.15.x"
52 | },
53 | "575": {
54 | "name": "1.15.1",
55 | "major": "1.15.x"
56 | },
57 | "573": {
58 | "name": "1.15",
59 | "major": "1.15.x"
60 | },
61 | "498": {
62 | "name": "1.14.4",
63 | "major": "1.14.x"
64 | },
65 | "490": {
66 | "name": "1.14.3",
67 | "major": "1.14.x"
68 | },
69 | "485": {
70 | "name": "1.14.2",
71 | "major": "1.14.x"
72 | },
73 | "480": {
74 | "name": "1.14.1",
75 | "major": "1.14.x"
76 | },
77 | "477": {
78 | "name": "1.14",
79 | "major": "1.14.x"
80 | },
81 | "404": {
82 | "name": "1.13.2",
83 | "major": "1.13.x"
84 | },
85 | "401": {
86 | "name": "1.13.1",
87 | "major": "1.13.x"
88 | },
89 | "393": {
90 | "name": "1.13",
91 | "major": "1.13.x"
92 | },
93 | "340": {
94 | "name": "1.12.2",
95 | "major": "1.12.x"
96 | },
97 | "338": {
98 | "name": "1.12.1",
99 | "major": "1.12.x"
100 | },
101 | "335": {
102 | "name": "1.12",
103 | "major": "1.12.x"
104 | },
105 | "316": {
106 | "name": "1.11.2",
107 | "major": "1.11.x"
108 | },
109 | "315": {
110 | "name": "1.11",
111 | "major": "1.11.x"
112 | },
113 | "210": {
114 | "name": "1.10.2",
115 | "major": "1.10.x"
116 | },
117 | "110": {
118 | "name": "1.9.4",
119 | "major": "1.9.x"
120 | },
121 | "109": {
122 | "name": "1.9.2",
123 | "major": "1.9.x"
124 | },
125 | "108": {
126 | "name": "1.9.1",
127 | "major": "1.9.x"
128 | },
129 | "107": {
130 | "name": "1.9",
131 | "major": "1.9.x"
132 | },
133 | "47": {
134 | "name": "1.8.4",
135 | "major": "1.8.x"
136 | }
137 | }
138 |
--------------------------------------------------------------------------------