This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
178 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project-shared-configuration> | ||
<!-- | ||
This file contains additional configuration written by modules in the NetBeans IDE. | ||
The configuration is intended to be shared among all the users of project and | ||
therefore it is assumed to be part of version control checkout. | ||
Without this configuration present, some functionality in the IDE may be limited or fail altogether. | ||
--> | ||
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1"> | ||
<!-- | ||
Properties that influence various parts of the IDE, especially code formatting and the like. | ||
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up. | ||
That way multiple projects can share the same settings (useful for formatting rules for example). | ||
Any value defined here will override the pom.xml file value but is only applicable to the current project. | ||
--> | ||
<org-netbeans-modules-editor-indent.CodeStyle.usedProfile>project</org-netbeans-modules-editor-indent.CodeStyle.usedProfile> | ||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement> | ||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement> | ||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement> | ||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinMethodCallParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinMethodCallParens> | ||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSwitchParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSwitchParens> | ||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinCatchParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinCatchParens> | ||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinTryParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinTryParens> | ||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSynchronizedParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSynchronizedParens> | ||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinArrayInitBrackets>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinArrayInitBrackets> | ||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinParens> | ||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinWhileParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinWhileParens> | ||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinIfParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinIfParens> | ||
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinForParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinForParens> | ||
</properties> | ||
</project-shared-configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>net.md-5</groupId> | ||
<artifactId>bungeecord-module</artifactId> | ||
<version>1.20-R0.1-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<groupId>net.md-5</groupId> | ||
<artifactId>bungeecord-module-cmd-bungee</artifactId> | ||
<version>1.20-R0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>cmd_bungee</name> | ||
<description>Provides the bungee command</description> | ||
</project> |
106 changes: 106 additions & 0 deletions
106
module/cmd-bungee/src/main/java/net/md_5/bungee/module/cmd/bungee/CommandBungee.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package net.md_5.bungee.module.cmd.bungee; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.InputStreamReader; | ||
import java.net.URL; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.stream.Collectors; | ||
import javax.net.ssl.HttpsURLConnection; | ||
import net.md_5.bungee.api.ChatColor; | ||
import net.md_5.bungee.api.CommandSender; | ||
import net.md_5.bungee.api.ProxyServer; | ||
import net.md_5.bungee.api.chat.ClickEvent; | ||
import net.md_5.bungee.api.chat.HoverEvent; | ||
import net.md_5.bungee.api.chat.TextComponent; | ||
import net.md_5.bungee.api.chat.hover.content.Text; | ||
import net.md_5.bungee.api.plugin.Command; | ||
|
||
public class CommandBungee extends Command | ||
{ | ||
private PluginBungee plugin; | ||
|
||
public CommandBungee(PluginBungee plugin) | ||
{ | ||
super( "bungee", "bungeecord.command.bungee" ); | ||
|
||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public void execute(CommandSender sender, String[] args) | ||
{ | ||
TextComponent bungee = new TextComponent( ChatColor.BLUE + "This server is running HexaCord version " + ProxyServer.getInstance().getVersion() + " by md_5" ); | ||
bungee.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( "Click to copy to clipboard" ) ) ); | ||
bungee.setClickEvent( new ClickEvent( ClickEvent.Action.COPY_TO_CLIPBOARD, ChatColor.stripColor( bungee.getText() ) ) ); | ||
|
||
sender.sendMessage( bungee ); | ||
|
||
TextComponent protocol = new TextComponent( ChatColor.BLUE + "Protocol support for 1.7.x by Zartec, ghac and I9hdkill" ); | ||
protocol.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( "Click to copy to clipboard" ) ) ); | ||
protocol.setClickEvent( new ClickEvent( ClickEvent.Action.COPY_TO_CLIPBOARD, ChatColor.stripColor( protocol.getText() ) ) ); | ||
|
||
sender.sendMessage( protocol ); | ||
|
||
sender.sendMessage( "Checking version. please wait..." ); | ||
|
||
String version = ProxyServer.getInstance().getVersion(); | ||
int lastColon = version.lastIndexOf( ':' ); | ||
String buildNumber = version.substring( lastColon + 1, version.length() ); | ||
|
||
if ( "unknown".equals( buildNumber ) ) | ||
{ | ||
sender.sendMessage( "Couldn't detect bungee version. Custom build?" ); | ||
return; | ||
} | ||
|
||
int currentBuildNumber = Integer.valueOf( buildNumber ).intValue(); | ||
|
||
ProxyServer.getInstance().getScheduler().runAsync( this.plugin, () -> | ||
{ | ||
try | ||
{ | ||
HttpsURLConnection connection = (HttpsURLConnection) new URL( "https://ci.simplyrin.net/job/HexaCord/lastStableBuild/buildNumber" ).openConnection(); | ||
connection.addRequestProperty( "user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36" ); | ||
|
||
// 5 second timeout at various stages | ||
connection.setConnectTimeout( 5000 ); | ||
connection.setReadTimeout( 5000 ); | ||
|
||
String result = new BufferedReader( new InputStreamReader( connection.getInputStream(), StandardCharsets.UTF_8 ) ).lines().collect( Collectors.joining() ); | ||
|
||
int lastStableBuild = Integer.valueOf( result ).intValue(); | ||
|
||
if ( lastStableBuild == currentBuildNumber ) | ||
{ | ||
TextComponent latest = new TextComponent( ChatColor.GREEN + "You are running the latest version" ); | ||
latest.setHoverEvent( bungee.getHoverEvent() ); | ||
latest.setClickEvent( bungee.getClickEvent() ); | ||
|
||
sender.sendMessage( latest ); | ||
} else | ||
{ | ||
TextComponent behind = new TextComponent( ChatColor.YELLOW + String.format( "You are %d version(s) behind", lastStableBuild - currentBuildNumber ) ); | ||
behind.setHoverEvent( bungee.getHoverEvent() ); | ||
behind.setClickEvent( bungee.getClickEvent() ); | ||
|
||
sender.sendMessage( behind ); | ||
|
||
TextComponent text = new TextComponent( ChatColor.YELLOW + "Download the new version at: " ); | ||
text.setHoverEvent( bungee.getHoverEvent() ); | ||
text.setClickEvent( bungee.getClickEvent() ); | ||
|
||
TextComponent url = new TextComponent( ChatColor.GOLD + "https://ci.simplyrin.net/job/HexaCord/" ); | ||
url.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( "Click to open" ) ) ); | ||
url.setClickEvent( new ClickEvent( ClickEvent.Action.OPEN_URL, "https://ci.simplyrin.net/job/HexaCord/" ) ); | ||
|
||
text.addExtra( url ); | ||
|
||
sender.sendMessage( text ); | ||
} | ||
} catch ( Exception e ) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
} ); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
module/cmd-bungee/src/main/java/net/md_5/bungee/module/cmd/bungee/PluginBungee.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package net.md_5.bungee.module.cmd.bungee; | ||
|
||
import net.md_5.bungee.api.plugin.Plugin; | ||
|
||
public class PluginBungee extends Plugin | ||
{ | ||
|
||
@Override | ||
public void onEnable() | ||
{ | ||
getProxy().getPluginManager().registerCommand( this, new CommandBungee( this ) ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: ${project.name} | ||
main: net.md_5.bungee.module.cmd.bungee.PluginBungee | ||
version: ${describe} | ||
description: ${project.description} | ||
author: ${module.author} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters