Added Networking API (#180)

* sent data to client

* send more data + debug + add docs + switch to handshake

* add diff between container and normal changes

* fix docs

* changes according guidelines

* make requested changes + cleanup

* correct documentation

* Improved Networking API documentation

* Moved networking API channel registration out of main class

* Cleanup

* Removed debug on chat/command lookups

* Optimized array merging

* Fixed ClassCastException when running console commands

* Skip preparing networking data if not a channel player

* Renamed "networking-debug" to "network-debug"

* Fixed failed handshake still registering players

* Adjusted networking phrases

* Renamed pluginchannel to channel

Co-authored-by: Intelli <contact@intelli.software>
This commit is contained in:
vacla 2022-03-24 01:49:46 +01:00 committed by GitHub
parent e848d65b93
commit 8cdf99429d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 554 additions and 3 deletions

View file

@ -154,6 +154,8 @@ public class Language {
phrases.put(Phrase.MISSING_ROLLBACK_RADIUS, "You did not specify a {rollback|restore} radius.");
phrases.put(Phrase.MISSING_ROLLBACK_USER, "You did not specify a {rollback|restore} user.");
phrases.put(Phrase.MYSQL_UNAVAILABLE, "Unable to connect to MySQL server.");
phrases.put(Phrase.NETWORK_CONNECTION, "Connection by {0} {successful|failed}. Using {1} {2}.");
phrases.put(Phrase.NETWORK_TEST, "Network test data has been successful sent.");
phrases.put(Phrase.NO_DATA, "No data found at {0}.");
phrases.put(Phrase.NO_DATA_LOCATION, "No {data|transactions|interactions|messages} found at this location.");
phrases.put(Phrase.NO_PERMISSION, "You do not have permission to do that.");

View file

@ -3,6 +3,8 @@ package net.coreprotect.language;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.coreprotect.utility.ChatMessage;
import net.coreprotect.utility.Color;
@ -135,6 +137,8 @@ public enum Phrase {
MISSING_ROLLBACK_RADIUS,
MISSING_ROLLBACK_USER,
MYSQL_UNAVAILABLE,
NETWORK_CONNECTION,
NETWORK_TEST,
NO_DATA,
NO_DATA_LOCATION,
NO_PERMISSION,
@ -287,4 +291,16 @@ public enum Phrase {
return output;
}
public static String getPhraseSelector(Phrase phrase, String selector) {
String translatedPhrase = phrase.getTranslatedPhrase();
Pattern phrasePattern = Pattern.compile("(\\{[a-zA-Z| ]+})");
Matcher patternMatch = phrasePattern.matcher(translatedPhrase);
String match = "";
if (patternMatch.find()) {
match = patternMatch.group(1);
match = Selector.processSelection(match, selector, "");
}
return match;
}
}