-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completley server-side, better message configuration
- Loading branch information
1 parent
44fa33f
commit 406b4d0
Showing
15 changed files
with
172 additions
and
125 deletions.
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
Binary file added
BIN
+1.47 KB
ProxyMessagesPaper/bin/main/dev/ogblackdiamond/proxymessages/ProxyMessages.class
Binary file not shown.
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,6 @@ | ||
name: ProxyMessages | ||
version: 1.1.0 | ||
main: dev.ogblackdiamond.proxymessages.ProxyMessages | ||
description: Paper plugin to interface with Velocity | ||
author: BlackDiamond | ||
api-version: '1.21' |
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
91 changes: 0 additions & 91 deletions
91
...essagesPaper/src/main/java/dev/ogblackdiamond/proxymessages/listener/MessageListener.java
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"id":"proxymessages","name":"Proxy Messages","version":"2.0.0","description":"A message system for servers to interact over a proxy.","authors":["BlackDiamond"],"dependencies":[],"main":"dev.ogblackdiamond.proxymessages.ProxyMessages"} |
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,27 @@ | ||
# enables a network-wide join message for when a player joins the network | ||
global-network-join: true | ||
|
||
# enables a network-wide leave message for when a player leaves the network | ||
global-network-leave: true | ||
|
||
# enables a network-wide message that notifies players when a player switches between servers when true | ||
global-network-switch: true | ||
|
||
# options from this list will be randomly chosen to be displayed when a player joins the network | ||
# {player} will be replaced by the player name | ||
join-message-options: | ||
- "{player} joined the network" | ||
|
||
# options from this list will be randomly chosen to be displayed when a player leaves the network | ||
# {player} will be replaced by the player name | ||
leave-message-options: | ||
- "{player} left the network" | ||
|
||
# options from this list will be randomly chosen to be displayed when a player changes between two servers on the network | ||
# {player} will be replaced by the player name | ||
# {prev} will be replaced by the server the player is connecting from | ||
# {cur} will be replaced by the server the player is connecting to | ||
switch-message-options: | ||
- "{player} left {prev} and joined {cur}" | ||
|
||
|
Binary file added
BIN
+7.55 KB
ProxyMessagesVelocity/bin/main/dev/ogblackdiamond/proxymessages/ProxyMessages.class
Binary file not shown.
Binary file added
BIN
+2.99 KB
ProxyMessagesVelocity/bin/main/dev/ogblackdiamond/proxymessages/util/MessageUtil.class
Binary file not shown.
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
73 changes: 73 additions & 0 deletions
73
ProxyMessagesVelocity/src/main/java/dev/ogblackdiamond/proxymessages/util/MessageUtil.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,73 @@ | ||
package dev.ogblackdiamond.proxymessages.util; | ||
|
||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.TextComponent; | ||
import net.kyori.adventure.text.format.NamedTextColor; | ||
import net.kyori.adventure.text.format.TextDecoration; | ||
|
||
public class MessageUtil { | ||
|
||
public Component compileFormattedMessage(String type, String playerName, String previousServer, String newServer, String chosenMessage) { | ||
|
||
TextComponent.Builder finalMessage = Component.text().color(NamedTextColor.YELLOW); | ||
|
||
int messageLength = chosenMessage.length(); | ||
int playerNameLength = "{player}".length(); | ||
int previousServerNameLength = "{prev}".length(); | ||
int newServerNameLength = "{cur}".length(); | ||
|
||
|
||
|
||
// builds the final component, interpolating the correct strings when need | ||
switch (type) { | ||
|
||
case "join": | ||
case "leave": { | ||
|
||
for (int i = 0; i < messageLength; i++) { | ||
|
||
boolean atLength = i + playerNameLength > messageLength; | ||
|
||
if (!atLength && chosenMessage.substring(i, i + playerNameLength).equals("{player}")) { | ||
finalMessage.append(Component.text(playerName).decoration(TextDecoration.BOLD, true)); | ||
i += playerNameLength - 1; | ||
} else { | ||
finalMessage.append(Component.text(chosenMessage.substring(i, i+1)).decoration(TextDecoration.BOLD, false)); | ||
} | ||
} | ||
break; | ||
} | ||
|
||
case "switch": { | ||
|
||
for (int i = 0; i < messageLength; i++) { | ||
|
||
boolean playerAtLength = i + playerNameLength > messageLength; | ||
boolean previousServerLength = i + previousServerNameLength > messageLength; | ||
boolean newServerLength = i + newServerNameLength > messageLength; | ||
|
||
if (!playerAtLength && chosenMessage.substring(i, i + playerNameLength).equals("{player}")) { | ||
finalMessage.append(Component.text(playerName).decoration(TextDecoration.BOLD, true)); | ||
i += playerNameLength - 1; | ||
} else if (!previousServerLength && chosenMessage.substring(i, i + previousServerNameLength).equals("{prev}")) { | ||
finalMessage.append(Component.text(previousServer).decoration(TextDecoration.BOLD, true)); | ||
i += previousServerNameLength - 1; | ||
} else if (!newServerLength && chosenMessage.substring(i, i + newServerNameLength).equals("{cur}")) { | ||
finalMessage.append(Component.text(newServer).decoration(TextDecoration.BOLD, true)); | ||
i += newServerNameLength - 1; | ||
} else { | ||
finalMessage.append(Component.text(chosenMessage.substring(i, i+1)).decoration(TextDecoration.BOLD, false)); | ||
} | ||
} | ||
break; | ||
} | ||
|
||
default: { | ||
return Component.text("[ProxyMessages] Invalid type passed! Cannot render message."); | ||
} | ||
|
||
} | ||
|
||
return finalMessage.build(); | ||
} | ||
} |
Oops, something went wrong.