Compare commits

...

36 Commits

Author SHA1 Message Date
JaTiTV
fccf878b81 Critical vulnerability has been closed - exploit has been fixed
This version fixes an extremely critical bug!
Please update to Bungee/Waterfall!

This update fixes a security vulnerability that allowed the Voxel Hack Client to execute any command on the proxy if the T2CodeLib was installed on it (https://github.com/Renovsk/VoxelClient-SRC/blob/main/me/nullnet/voxelclient/exploits/T2CExploit.java). This has been fixed.

This has been fixed and all games that try to use this exploit are now displayed in the console.

Translated with www.DeepL.com/Translator (free version)
2025-03-31 07:19:25 +02:00
JaTiTV
afb6fc3c66 fix beta 1 2025-03-31 06:29:00 +02:00
f034567aec 16.9
Important!

If you have downloaded and are using version 16.8, please make sure to upgrade to 16.9! The 16.8 is not compatible with my plugins, as this is already a revised version but all my plugins have not yet been adapted.
I apologize for this mistake on my part.
2024-09-30 18:04:33 +02:00
32b57de55c 16.6
1.21 support
minor code changes / bug fixes
2024-06-15 02:34:34 +02:00
cb4a81a3c1 16.5 | 1.20.5/1.20.6 Support 2024-05-17 01:12:12 +02:00
JaTiTV
76862db7c9 pom.xml aktualisiert 2024-04-12 14:14:35 +00:00
e5cba7fe6d Update Kyori MiniMessage
API Updates:
adventure-text-minimessage - 4.16.0
adventure-platform-bukkit - 4.3.2
adventure-platform-bungeecord - 4.3.2
2024-03-31 13:32:00 +02:00
770b7daa94 1.20.4 Update / Remove debug Message
- A pointless debug message has been removed
- 1.20.4 native Suport
2024-03-30 19:41:31 +01:00
0f645300f4 1.20r2 Support 2023-12-07 18:29:51 +01:00
65e0082322 16.1 2023-12-07 16:58:39 +01:00
150d9f4933 15.9
- In MiniMessage messages placeholders were erroneously not supported by PlaceholderAPI
- Smaller API changes in T2Csend
2023-08-04 16:29:38 +02:00
f40c47e6ab 15.8
Innovation:
Commands can now be provided with delays (in ticks)

Example:
/say hi !delay:20
This command is now executed with a delay of one second
20 ticks are one second
2023-07-31 21:09:46 +02:00
de6ecdf7a8 15.8_dev 2023-07-16 08:22:30 +02:00
cdd375a673 change gitignore 2023-07-10 03:59:53 +02:00
1cfaf32ee1 Update .gitignore 2023-07-10 03:59:06 +02:00
c72edafd0a 15.7
- Bugfix: If a t2code plugin could not be checked for an update, it was not possible to use the info command of the respective plugin and the command '/t2c updateinfo <plugin>'.

- The message at the command '/t2code updatinfo <plugin>' was slightly adjusted
2023-07-10 03:35:06 +02:00
610cb74868 Update T2CitemBuilder.java 2023-07-09 17:01:07 +02:00
JaTiTV
3a3c9b3208 Merge pull request 'Update T2CitemBuilder.java' (#21) from 15.6 into development
Reviewed-on: #21
2023-07-09 14:35:52 +00:00
a834adc8c9 Update T2CitemBuilder.java 2023-07-09 16:35:17 +02:00
290b9264f3 final 15.6 2023-07-09 16:19:05 +02:00
eb991d01e3 15.6_beta-1 2023-07-08 22:48:02 +02:00
ec7714c9fe Update T2CitemBuilder.java 2023-07-08 21:30:09 +02:00
260dae2aa0 Update pom.xml 2023-07-08 21:29:36 +02:00
addc485ca8 Update T2Creplace.java
Fixed error when PlaceholderAPI is not installed
2023-07-08 21:29:30 +02:00
f8619e4802 Update pom.xml 2023-07-08 19:42:52 +02:00
e97fadfbec Update T2Creplace.java
add  public static Object replace(Object object,String placeholder,String replacement)
2023-07-08 19:42:48 +02:00
567b0a2442 fix ItemStack names 2023-07-08 19:42:33 +02:00
7b04697895 15.6_dev-1 2023-07-08 19:03:29 +02:00
59133a36f9 15.4 2023-06-30 17:59:37 +02:00
c2adf6957d Code reordered and methods rebat / removal announced via @Deprecated 2023-06-30 17:59:29 +02:00
2e1ef9c46d Create T2CdevelopmentTool.java 2023-06-30 17:58:14 +02:00
a7c7877ac6 Development tool added 2023-06-30 17:57:59 +02:00
71c746b752 Spigot website changed in the plugin.yml 2023-06-30 17:57:21 +02:00
6f054a8993 Update T2CBtab.java 2023-06-27 18:01:55 +02:00
a3ec7117dd 15.3
add minMcVersion (public static boolean minMc1_13() etc.) to net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion
2023-06-26 11:14:11 +02:00
034bf241e5 15.2
Changes:
Commands:
- The command '/t2code serverid' has been added to display the server ID assigned by the T2CodeLib.
- The command '/t2code bcmd <command>' was added to execute a bungee command from a spigot plugin

DebugLog:
- The number of offline players is now displayed in T2CoderLog.txt
- The offline players as well as the plugins in the T2CoderLog.txt are now listed in alphabetical order

- Smaller code changes
2023-06-19 21:17:49 +02:00
43 changed files with 1293 additions and 275 deletions

2
.gitignore vendored
View File

@@ -1,6 +1,4 @@
# User-specific stuff
.idea/
.idea
*.iml
*.ipr
*.iws

3
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

13
.idea/compiler.xml generated Normal file
View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="T2CodeLib" />
</profile>
</annotationProcessing>
</component>
</project>

7
.idea/discord.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="ASK" />
<option name="description" value="" />
</component>
</project>

7
.idea/encodings.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

3
.idea/icon.svg generated Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 295 KiB

60
.idea/jarRepositories.xml generated Normal file
View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jitpack.io" />
<option name="name" value="jitpack.io" />
<option name="url" value="https://jitpack.io" />
</remote-repository>
<remote-repository>
<option name="id" value="T2Code" />
<option name="name" value="T2Code" />
<option name="url" value="https://repo.t2code.net/repository/T2Code/" />
</remote-repository>
<remote-repository>
<option name="id" value="spigot-repo" />
<option name="name" value="spigot-repo" />
<option name="url" value="https://hub.spigotmc.org/nexus/content/repositories/snapshots/" />
</remote-repository>
<remote-repository>
<option name="id" value="sonatype-oss-snapshots1" />
<option name="name" value="sonatype-oss-snapshots1" />
<option name="url" value="https://s01.oss.sonatype.org/content/repositories/snapshots/" />
</remote-repository>
<remote-repository>
<option name="id" value="placeholderapi" />
<option name="name" value="placeholderapi" />
<option name="url" value="https://repo.extendedclip.com/content/repositories/placeholderapi/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="minecraft-repo" />
<option name="name" value="minecraft-repo" />
<option name="url" value="https://libraries.minecraft.net/" />
</remote-repository>
<remote-repository>
<option name="id" value="bungeecord-repo" />
<option name="name" value="bungeecord-repo" />
<option name="url" value="https://oss.sonatype.org/content/repositories/snapshots" />
</remote-repository>
<remote-repository>
<option name="id" value="BenCodez Repo" />
<option name="name" value="BenCodez Repo" />
<option name="url" value="https://nexus.bencodez.com/repository/maven-public/" />
</remote-repository>
</component>
</project>

18
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<list size="2">
<item index="0" class="java.lang.String" itemvalue="net.md_5.bungee.event.EventHandler" />
<item index="1" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
</list>
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK" />
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/T2CodeLib.iml" filepath="$PROJECT_DIR$/T2CodeLib.iml" />
</modules>
</component>
</project>

124
.idea/uiDesigner.xml generated Normal file
View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

32
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>15.1</version>
<version>17.0</version>
<!--version>VERSION_snapshot-0</version-->
<!--version>VERSION_beta-0</version-->
<!--version>VERSION_dev-0</version-->
@@ -27,8 +27,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
<plugin>
@@ -105,11 +105,11 @@
<url>https://nexus.bencodez.com/repository/maven-public/</url>
</repository>
<!--Kyori MiniMessage
<!--Kyori MiniMessage-->
<repository>
<id>sonatype-oss-snapshots1</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
</repository>-->
</repository>
</repositories>
@@ -118,7 +118,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
@@ -134,14 +134,14 @@
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<type>javadoc</type>
<scope>provided</scope>
</dependency>
@@ -166,7 +166,7 @@
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.3</version>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>
@@ -174,7 +174,7 @@
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>votingplugin</artifactId>
<version>6.12.1</version>
<version>6.18.3</version>
<scope>provided</scope>
</dependency>
@@ -182,19 +182,19 @@
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.14.0</version>
<version>4.19.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.3.0</version>
<version>4.3.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bungeecord</artifactId>
<version>4.3.0</version>
<version>4.3.3</version>
<scope>compile</scope>
</dependency>
@@ -221,6 +221,12 @@
<version>4.5.14</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230227</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@@ -10,31 +10,55 @@ import java.util.Iterator;
import java.util.List;
public class T2CBtab {
public static Iterable<String> tab(CommandSender sender, String[] args, String perm,Boolean onlinePlayer){
List<String> matches = new ArrayList<>();
Iterator var6 = ProxyServer.getInstance().getPlayers().iterator();
while (var6.hasNext()) {
ProxiedPlayer player1 = (ProxiedPlayer) var6.next();
if (passend(player1.getName(), args[0]) && hasPermission(sender, perm)){
matches.add(player1.getName());
}
public static void tab(List<String> matches, CommandSender sender, int arg, String[] args, String perm, Boolean onlinePlayer) {
if (args.length != arg + 1) return;
for (ProxiedPlayer player1 : ProxyServer.getInstance().getPlayers()) {
if (passend(player1.getName(), args[arg]) && hasPermission(sender, perm)) {
matches.add(player1.getName());
}
return matches;
}
}
public static Iterable<String> tab(CommandSender sender, String[] args, HashMap<String, String> permMap) {
List<String> matches = new ArrayList<>();
public static void tab(List<String> matches, CommandSender sender, int argEquals, String equalsValue, int arg, String[] args, String perm, Boolean onlinePlayer) {
if (args.length != arg + 1) return;
if (!args[argEquals].toLowerCase().equals(equalsValue)) return;
for (ProxiedPlayer player1 : ProxyServer.getInstance().getPlayers()) {
if (passend(player1.getName(), args[arg]) && hasPermission(sender, perm)) {
matches.add(player1.getName());
}
}
}
public static void tab(List<String> matches, CommandSender sender, int arg, String[] args, HashMap<String, String> permMap, Boolean onlinePlayer, String permForPlayer) {
if (args.length != arg + 1) return;
for (String command : permMap.keySet()) {
if (hasPermission(sender, permMap.get(command)) && passend(command, args[0])) {
if (hasPermission(sender, permMap.get(command)) && passend(command, args[arg])) {
matches.add(command);
} else if (onlinePlayer != null && permForPlayer != null) {
tab(matches, sender, arg, args, permForPlayer, onlinePlayer);
}
}
}
public static void tab(List<String> matches, CommandSender sender, int arg, String[] args, HashMap<String, String> permMap) {
tab(matches, sender, arg, args, permMap, null, null);
}
public static void tab(List<String> matches, CommandSender sender, int argEquals, String equalsValue, int arg, String[] args, HashMap<String, String> permMap) {
if (args.length != arg + 1) return;
if (!args[argEquals].toLowerCase().equals(equalsValue)) return;
for (String command : permMap.keySet()) {
if (hasPermission(sender, permMap.get(command)) && passend(command, args[arg])) {
matches.add(command);
}
}
return matches;
}
public static Iterable<String> tab(CommandSender sender, String[] args, String perm, String command) {
public static List<String> tab(CommandSender sender, int arg, String[] args, String perm, String command) {
List<String> matches = new ArrayList<>();
if (hasPermission(sender, perm) && passend(command, args[0])) {
if (hasPermission(sender, perm) && passend(command, args[arg])) {
matches.add(command);
}
return matches;

View File

@@ -5,7 +5,6 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.UpdateType;

View File

@@ -50,20 +50,20 @@ public class T2CBupdateCheckerGit {
return;
}
JSONObject obj = new JSONObject(data);
String UpdateName = obj.getString("name");
String tag_name = obj.getString("tag_name");
String body = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''");
String updateurl = obj.getString("html_url");
boolean prerelease = obj.getBoolean("prerelease");
String updateTitle = obj.getString("name");
String version = obj.getString("tag_name");
String updateDescription = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''");
String updateUrl = obj.getString("html_url");
boolean preRelease = obj.getBoolean("prerelease");
String date = obj.getString("published_at");
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
Date parsedDate = inputFormat.parse(date);
String formattedDate = outputFormat.format(parsedDate);
String publishedAt = outputFormat.format(parsedDate);
JSONArray downloadArray = obj.getJSONArray("assets");
String gitURL = updateurl;
String gitURL = updateUrl;
String downloadURL;
if (downloadArray.isEmpty()) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
@@ -71,12 +71,12 @@ public class T2CBupdateCheckerGit {
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
}
if (!prerelease) {
if (!preRelease) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
updateurl = "https://www.spigotmc.org/resources/" + spigotID;
updateUrl = "https://www.spigotmc.org/resources/" + spigotID;
}
T2CupdateWebData webData = new T2CupdateWebData(UpdateName, tag_name, body, updateurl, formattedDate, downloadURL, gitURL, prerelease);
T2CupdateWebData webData = new T2CupdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease);
consumer.accept(webData);
} catch (Exception var10) {
Boolean load = false;

View File

@@ -34,7 +34,7 @@ public class T2CBload {
throw new RuntimeException(e);
}
T2CBupdateAPI.onUpdateCheckTimer(plugin, prefix, discord, spigotID,url);
T2CBupdateAPI.onUpdateCheckTimer(plugin, prefix, discord, spigotID, url);
//API
plugin.getProxy().registerChannel("t2c:bcmd");

View File

@@ -43,8 +43,6 @@ public class T2CodeBMain extends Plugin {
mmIsLoad = false;
}
T2CBload.onLoad(plugin, Util.getPrefix(), autor, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit());
String[] fv = orgVersion.split("_");
plugin.getDescription().setVersion(fv[0]);
version = plugin.getDescription().getVersion();
}

View File

@@ -2,9 +2,13 @@ package net.t2code.t2codelib.BUNGEE.system.pluginMessaging;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
import net.t2code.t2codelib.Util;
import org.junit.Ignore;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
@@ -14,18 +18,31 @@ public class T2CplmsgBcmd implements Listener {
@EventHandler
public void onPluginmessage(PluginMessageEvent event) {
if (event.getTag().equalsIgnoreCase("t2c:bcmd")) {
if (!(event.getSender() instanceof Server)) {
T2CBsend.console(Util.getPrefix() +" <dark_gray>[<gold>Exploit-protection</gold>]</dark_gray> <red>Blocked unauthorized plugin message from a player ("+ event.getSender().toString() +")!");
return;
}
event.setCancelled(true);
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
try {
String channel = stream.readUTF();
String input = stream.readUTF();
String serverID;
try {
serverID = stream.readUTF();
} catch (Exception i){
serverID = "not Found";
}
if (channel.equals("T2Code-Console")) {
ProxyServer.getInstance().getConsole().sendMessage("Command Console: "+ input);
ProxyServer.getInstance().getConsole().sendMessage(Util.getPrefix()+" [§6"+serverID+"§r] §cT2C BCMD Command Console: §r"+ input);
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), input);
} else {
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(channel);
if (player != null) {
ProxyServer.getInstance().getConsole().sendMessage("Command " + player +": "+ input);
ProxyServer.getInstance().getConsole().sendMessage(Util.getPrefix()+" [§6"+serverID+"§r] §cT2C BCMD Command §r" + player +": "+ input);
ProxyServer.getInstance().getPluginManager().dispatchCommand(player, input);
}
}

View File

@@ -2,10 +2,12 @@ package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.autoResponse;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
import net.t2code.t2codelib.Util;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
@@ -16,6 +18,12 @@ public class T2CapiAutoResponse implements Listener {
@EventHandler
public void onPluginmessage(PluginMessageEvent event) {
if (event.getTag().equalsIgnoreCase("t2c:aresp")) {
if (!(event.getSender() instanceof Server)) {
T2CBsend.console(Util.getPrefix() +" <dark_gray>[<gold>Exploit-protection</gold>]</dark_gray> <red>Blocked unauthorized plugin message from a player ("+ event.getSender().toString() +")!");
return;
}
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
event.setCancelled(true);
try {

View File

@@ -1,9 +1,12 @@
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.opSecurity;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
import net.t2code.t2codelib.Util;
import java.io.*;
import java.util.logging.Logger;
@@ -13,6 +16,12 @@ public class T2CapiOpSecurity implements Listener {
@EventHandler
public void onPluginmessage(PluginMessageEvent event) {
if (event.getTag().equalsIgnoreCase("t2c:opsec")) {
if (!(event.getSender() instanceof Server)) {
T2CBsend.console(Util.getPrefix() +" <dark_gray>[<gold>Exploit-protection</gold>]</dark_gray> <red>Blocked unauthorized plugin message from a player ("+ event.getSender().toString() +")!");
return;
}
event.setCancelled(true);
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
try {

View File

@@ -1,25 +1,70 @@
package net.t2code.t2codelib.SPIGOT.api.commands;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.rmi.MarshalledObject;
import java.util.Map;
public class T2Ccmd {
public static void console(String cmd) {
if (cmd.contains("!onBungee")){
T2CbungeeCommandSenderReciver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
}else Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
public static void console(String cmdInput) {
Map.Entry<String,Integer> map = delay(cmdInput);
int delay = map.getValue();
String cmd = map.getKey();
Bukkit.getScheduler().runTaskLater(T2CodeLibMain.getPlugin(), new Runnable() {
@Override
public void run() {
if (cmd.contains("!onBungee")) {
T2CbungeeCommandSenderReciver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
} else Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
}
}, delay);
}
public static void player(Player player, String cmd) {
if (cmd.contains("!asConsole")) {
if (cmd.contains("!onBungee")) {
T2CbungeeCommandSenderReciver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true);
} else console(cmd.replace("!asConsole", ""));
} else {
if (cmd.contains("!onBungee")) {
T2CbungeeCommandSenderReciver.sendToBungee(player, cmd.replace("!onBungee", ""), false);
} else player.chat("/" + cmd);
}
public static void player(Player player, String cmdInput) {
Map.Entry<String,Integer> map = delay(cmdInput);
int delay = map.getValue();
String cmd = map.getKey();
Bukkit.getScheduler().runTaskLater(T2CodeLibMain.getPlugin(), new Runnable() {
@Override
public void run() {
if (cmd.contains("!asConsole")) {
if (cmd.contains("!onBungee")) {
T2CbungeeCommandSenderReciver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true);
} else console(cmd.replace("!asConsole", ""));
} else {
if (cmd.contains("!onBungee")) {
T2CbungeeCommandSenderReciver.sendToBungee(player, cmd.replace("!onBungee", ""), false);
} else player.chat("/" + cmd);
}
}
}, delay);
}
private static Map.Entry<String, Integer> delay(@NotNull String cmdInput) {
int delay = 0;
String cmd;
if (cmdInput.contains("!delay:")) {
int i = cmdInput.indexOf("!delay:") + 7;
String s2 = cmdInput.substring(i);
int i2 = 1;
if(s2.contains(" ")) {
i2 = s2.indexOf(" ");
}else{
i2 = s2.length();
}
delay = Integer.parseInt(cmdInput.substring(i, i + i2));
cmd = cmdInput.replace("!delay:" + delay, "");
} else cmd = cmdInput;
return Map.entry(cmd, delay);
}
}

View File

@@ -0,0 +1,9 @@
package net.t2code.t2codelib.SPIGOT.api.dev;
public class T2CdevelopmentTool {
public static String removeLastChar(String s, int amount) {
return (s == null || s.length() == 0)
? null
: (s.substring(0, s.length() - amount));
}
}

View File

@@ -3,13 +3,22 @@ package net.t2code.t2codelib.SPIGOT.api.items;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.profile.PlayerProfile;
import org.bukkit.profile.PlayerTextures;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Base64;
import org.json.JSONObject;
import java.util.List;
import java.util.UUID;
@@ -52,7 +61,27 @@ public class T2CitemBuilder {
return itemStack;
}
public static ItemStack base64(String base64Value, Integer amount, String displayName, List<String> lore) {
public static void setItem(Integer slot, Integer amount, String material, String displayName, List<String> lore, Inventory inventory) {
ItemStack item;
if (getLegacy && material.contains(",")) {
String[] split = material.split(",");
item = new ItemStack(Material.valueOf(split[0]), 1, Short.parseShort(split[1]));
} else item = new ItemStack(Material.valueOf(material));
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(displayName);
itemMeta.setLore(lore);
item.setItemMeta(itemMeta);
item.setAmount(amount);
inventory.setItem(slot, item);
}
public static ItemStack base64(String base64Value) {
if (!T2CmcVersion.minMc1_20() || T2CmcVersion.isNms1_20_R1()|| T2CmcVersion.isNms1_20_R2()|| T2CmcVersion.isNms1_20_R3()) {
return base64Old(base64Value);
} else return base64New(base64Value);
}
private static ItemStack base64Old(String base64Value) {
ItemStack itemStack = new ItemStack(T2CitemVersion.getHead());
SkullMeta itemMeta = (SkullMeta) itemStack.getItemMeta();
@@ -67,11 +96,33 @@ public class T2CitemBuilder {
e.printStackTrace();
}
itemMeta.setDisplayName(displayName);
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
itemStack.setAmount(amount);
return itemStack;
}
private static ItemStack base64New(String base64Value) {
ItemStack itemStack = new ItemStack(T2CitemVersion.getHead());
SkullMeta itemMeta = (SkullMeta) itemStack.getItemMeta();
PlayerProfile profile = Bukkit.createPlayerProfile(UUID.randomUUID());
PlayerTextures textures = profile.getTextures();
try {
textures.setSkin(new URL(base64Convert(base64Value)));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
profile.setTextures(textures);
itemMeta.setOwnerProfile(profile);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
private static String base64Convert(String base64Value) {
String jsonString = new String(Base64.getDecoder().decode(base64Value));
JSONObject obj = new JSONObject(jsonString);
String output = obj.getJSONObject("textures").getJSONObject("SKIN").getString("url");
if (output.startsWith("http://textures.minecraft.net/texture/")){
return output;
} else return "http://textures.minecraft.net/texture/d5d20330da59c207d78352838e91a48ea1e42b45a9893226144b251fe9b9d535";
}
}

View File

@@ -1,76 +1,54 @@
package net.t2code.t2codelib.SPIGOT.api.items;
import lombok.Getter;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class T2CitemVersion {
@Getter
private static Material Head;
@Getter
private static ItemStack HeadIS;
private static ItemStack CRAFTING_TABLE;
private static ItemStack YELLOW_WOOL;
private static ItemStack ORANGE_WOOL;
private static ItemStack GREEN_WOOL;
private static ItemStack GRAY_WOOL;
private static ItemStack RED_WOOL;
private static ItemStack RED_STAINED_GLASS_PANE;
@Getter
private static ItemStack CraftingTable;
@Getter
private static ItemStack YellowWool;
@Getter
private static ItemStack OrangeWool;
@Getter
private static ItemStack GreenWool;
@Getter
private static ItemStack GrayWool;
@Getter
private static ItemStack RedWool;
@Getter
private static ItemStack RedStainedGlassPane;
@Getter
private static ItemStack BlackStainedGlassPane;
public static void scan() {
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
Head = Material.valueOf("SKULL_ITEM");
YELLOW_WOOL = new ItemStack(Material.valueOf("WOOL"), 1, (short) 4);
ORANGE_WOOL = new ItemStack(Material.valueOf("WOOL"), 1, (short) 1);
GREEN_WOOL = new ItemStack(Material.valueOf("WOOL"), 1, (short) 5);
GRAY_WOOL = new ItemStack(Material.valueOf("WOOL"), 1, (short) 8);
RED_WOOL = new ItemStack(Material.valueOf("WOOL"), 1, (short) 14);
RED_STAINED_GLASS_PANE = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 14);
CRAFTING_TABLE = new ItemStack(Material.valueOf("WORKBENCH"));
YellowWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 4);
OrangeWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 1);
GreenWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 5);
GrayWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 8);
RedWool = new ItemStack(Material.valueOf("WOOL"), 1, (short) 14);
RedStainedGlassPane = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 14);
BlackStainedGlassPane = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 15);
CraftingTable = new ItemStack(Material.valueOf("WORKBENCH"));
} else {
Head = Material.valueOf("PLAYER_HEAD");
CRAFTING_TABLE = new ItemStack(Material.CRAFTING_TABLE);
YELLOW_WOOL = new ItemStack(Material.YELLOW_WOOL);
ORANGE_WOOL = new ItemStack(Material.ORANGE_WOOL);
GREEN_WOOL = new ItemStack(Material.GREEN_WOOL);
GRAY_WOOL = new ItemStack(Material.GRAY_WOOL);
RED_WOOL = new ItemStack(Material.RED_WOOL);
RED_STAINED_GLASS_PANE = new ItemStack(Material.RED_STAINED_GLASS_PANE);
CraftingTable = new ItemStack(Material.CRAFTING_TABLE);
YellowWool = new ItemStack(Material.YELLOW_WOOL);
OrangeWool = new ItemStack(Material.ORANGE_WOOL);
GreenWool = new ItemStack(Material.GREEN_WOOL);
GrayWool = new ItemStack(Material.GRAY_WOOL);
RedWool = new ItemStack(Material.RED_WOOL);
RedStainedGlassPane = new ItemStack(Material.RED_STAINED_GLASS_PANE);
BlackStainedGlassPane = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
}
HeadIS = new ItemStack(Head, 1, (byte) 3);
}
public static Material getHead() {
return Head;
}
public static ItemStack getHeadIS() {
return HeadIS;
}
public static ItemStack getCraftingTable() {
return CRAFTING_TABLE;
}
public static ItemStack getYellowWool() {
return YELLOW_WOOL;
}
public static ItemStack getOrangeWool() {
return ORANGE_WOOL;
}
public static ItemStack getGreenWool() {
return GREEN_WOOL;
}
public static ItemStack getGrayWool() {
return GRAY_WOOL;
}
public static ItemStack getRedWool() {
return RED_WOOL;
}
public static ItemStack getRedStainedGlassPane() {
return RED_STAINED_GLASS_PANE;
}
}

View File

@@ -11,7 +11,12 @@ public class T2CminiMessage {
private static final BukkitAudiences bukkitAudiences = T2CodeLibMain.getPlugin().getAdventure();
public static void sendSenderMiniMessage(String msg, CommandSender sender) {
bukkitAudiences.sender(sender).sendMessage(replace(msg));
String string = "";
if (sender instanceof Player) {
Player player = (Player) sender;
string =T2Creplace.replace("",player,msg);
} else string = msg;
bukkitAudiences.sender(sender).sendMessage(replace(string));
}
public static void sendConsoleMiniMessage(String msg) {
@@ -19,7 +24,7 @@ public class T2CminiMessage {
}
public static void sendPlayerMiniMessage(String msg, Player player) {
bukkitAudiences.player(player).sendMessage(replace(msg));
bukkitAudiences.player(player).sendMessage(replace(T2Creplace.replace("", player, msg)));
}
protected static Component replace(String text) {

View File

@@ -1,6 +1,7 @@
package net.t2code.t2codelib.SPIGOT.api.messages;
import me.clip.placeholderapi.PlaceholderAPI;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import org.bukkit.entity.Player;
import java.util.ArrayList;
@@ -17,10 +18,16 @@ public class T2Creplace {
}
public static String replace(String prefix, Player player, String Text) {
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix)
String input = Text.replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")));
.replace("[nl]", "\n");
if (T2CpluginCheck.papi()) {
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input));
} else {
return replaceLegacyColor(input);
}
}
public static Object replaceObject(String prefix, Object object) {
@@ -46,18 +53,33 @@ public class T2Creplace {
public static Object replaceObject(String prefix, Player player, Object object) {
if (object instanceof String) {
object = PlaceholderAPI.setPlaceholders(player, replaceLegacyColor((String) object).replace("[prefix]", prefix).replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n"));
if (T2CpluginCheck.papi()) {
object = PlaceholderAPI.setPlaceholders(player, replaceLegacyColor((String) object).replace("[prefix]", prefix).replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n"));
} else {
object = replaceLegacyColor((String) object).replace("[prefix]", prefix).replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n");
}
}
if (object instanceof List) {
List<String> in = (List<String>) object;
List<String> output = new ArrayList<>();
for (String input : in) {
output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")));
if (T2CpluginCheck.papi()) {
output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")));
} else {
output.add(replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n"));
}
}
object = output;
}
@@ -84,10 +106,18 @@ public class T2Creplace {
return Collections.singletonList("Text is null");
}
for (String input : Text) {
output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")));
if (T2CpluginCheck.papi()) {
output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")));
} else {
output.add(replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n"));
}
}
return output;
}
@@ -110,25 +140,20 @@ public class T2Creplace {
.replace("&c", "").replace("&d", "").replace("&e", "").replace("&f", "")
.replace("&k", "").replace("&l", "").replace("&m", "").replace("&n", "")
.replace("&o", "").replace("&r", "");
// String text = value.replace("&", "§");
// while (text.contains("§")) {
// int stelle = text.indexOf("§");
// if (text.length() >= stelle + 2) {
// text = text.substring(0, stelle) + text.substring(stelle + 2);
// } else {
// text = text.substring(0, stelle) + text.substring(stelle + 1);
// }
// }
// return (text);
}
public static List<String> replacePrice(String prefix, Player player, List<String> Text, String price) {
List<String> rp = new ArrayList<>();
for (String s : Text) {
rp.add(replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, s.replace("[prefix]", prefix)
String input = s.replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n")
.replace("[price]", String.valueOf(price)))));
.replace("[price]", String.valueOf(price));
if (T2CpluginCheck.papi()) {
rp.add(replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input)));
} else {
rp.add(replaceLegacyColor(input));
}
}
return rp;
}
@@ -142,10 +167,16 @@ public class T2Creplace {
}
public static String replacePrice(String prefix, Player player, String Text, String price) {
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix)
String input = Text.replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[price]", String.valueOf(price)).replace("[nl]", "\n")));
.replace("[price]", String.valueOf(price)).replace("[nl]", "\n");
if (T2CpluginCheck.papi()) {
return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, input));
} else {
return replaceLegacyColor(input);
}
}
public static String replaceLegacyColor(String text) {
@@ -181,4 +212,19 @@ public class T2Creplace {
.replace("&o", "<italic>").replace("§o", "<italic>")
.replace("&r", "<reset>").replace("§r", "<reset>");
}
public static Object replace(Object object, String placeholder, String replacement) {
if (object instanceof String) {
object = ((String) object).replace(placeholder, replacement);
}
if ((object instanceof List) || (object instanceof ArrayList)) {
List<String> in = (List<String>) object;
List<String> output = new ArrayList<>();
for (String input : in) {
output.add(input.replace(placeholder, replacement));
}
object = output;
}
return object;
}
}

View File

@@ -7,14 +7,12 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
public class T2Csend {
/**
* Spigot
*/
public static void console(String msg) {
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleConsole(msg);
@@ -31,21 +29,25 @@ public class T2Csend {
}
public static void console(Object object) {
String msg = String.valueOf(object);
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleConsole(msg);
for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) continue;
T2ChoverModule.moduleConsole(msg);
}
}
public static void player(Player player, Object object) {
String msg = String.valueOf(object);
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.modulePlayer(msg, player);
for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) continue;
T2ChoverModule.modulePlayer(msg, player);
}
}
public static void sender(CommandSender sender, Object object) {
String msg = String.valueOf(object);
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleSender(msg, sender);
for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleSender(msg, sender);
}
}
public static void title(Player player, @Nullable String title, @Nullable String subtitle) {
@@ -80,4 +82,16 @@ public class T2Csend {
public static void error(Plugin plugin, String msg) {
plugin.getLogger().log(Level.SEVERE, msg);
}
private static ArrayList<String> list(Object object){
ArrayList<String> list = new ArrayList<>();
if (object instanceof List){
list= (ArrayList<String>) object;
}
if (object instanceof String){
list.add((String) object);
}
return list;
}
}

View File

@@ -2,6 +2,8 @@ package net.t2code.t2codelib.SPIGOT.api.messages;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.UpdateType;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@@ -46,7 +48,7 @@ public class T2Ctemplate {
T2Csend.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! Some features may not be working as expected. Please report all" +
" bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!");
onLoadSeparateStroke(prefix);
if (!SelectLibConfig.getT2cTestDevelopment()){
if (!SelectLibConfig.getT2cTestDevelopment()) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
@@ -68,9 +70,8 @@ public class T2Ctemplate {
T2Csend.console(prefix + " §8-------------------------------");
}
public static void onLoadFooter(String prefix, Long long_, String version) {
onLoadSeparateStroke(prefix);
T2Csend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
public static void onLoadFooter(String prefix, Long long_, String v) {
onLoadFooter(prefix, long_);
}
public static void onLoadFooter(String prefix, Long long_) {
@@ -78,22 +79,62 @@ public class T2Ctemplate {
T2Csend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
/**
* @param prefix
* @param autor
* @param spigot
* @param discord
* @deprecated reason this method is deprecated <br/>
* {will be removed in next version} <br/>
* use {@link #onDisable(String, Plugin)} instead like this:
*
*
* <blockquote><pre>
* onDisable(getPlugin())
* </pre></blockquote>
*/
@Deprecated
public static void onDisable(String prefix, List<String> autor, String version, String spigot, String discord) {
T2Csend.console(prefix + " §2Version: §6" + version);
T2Csend.console(prefix + " §4Plugin successfully disabled.");
}
public static void onDisable(String prefix, Plugin plugin) {
T2Csend.console(prefix + " §4 §e╔══════════════════════════");
T2Csend.console(prefix + " §4 §e║ §2Version: §6" + plugin.getDescription().getVersion());
T2Csend.console(prefix + " §4 §e║ §2Autors: §6" + plugin.getDescription().getAuthors());
T2Csend.console(prefix + " §4 §e║ §4Plugin successfully disabled.");
T2Csend.console(prefix + " §4 §e╚══════════════════════════");
}
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, Boolean premiumVerified, String text) {
String pluginVersion = plugin.getDescription().getVersion();
String publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData.getVersion();
boolean update = !publicVersion.equalsIgnoreCase(pluginVersion);
boolean player = sender instanceof Player;
String publicVersion = "";
boolean update;
String stNVersion;
T2CupdateWebData webData;
try {
webData = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData;
} catch (Exception ex) {
webData = null;
}
if (webData != null) {
publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData.getVersion();
update = !publicVersion.equalsIgnoreCase(pluginVersion);
} else {
update = false;
}
boolean player = sender instanceof Player;
String stPlugin = "<dark_red>║</dark_red> <yellow>Plugin:</yellow> <gold>[pl]</gold>".replace("[pl]", plugin.getName());
String stVersion = "<dark_red>║</dark_red> <yellow>Version:</yellow> <gold>[ver]</gold>".replace("[ver]", pluginVersion);
String stAutor = "<dark_red>║</dark_red> <yellow>Autor(s):</yellow> <gold>[autor]</gold>".replace("[autor]", plugin.getDescription().getAuthors().toString());
String stNVersion = "<dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]", publicVersion);
String stStable = "<dark_red>║</dark_red> <yellow>Stable version available:</yellow> [up]".replace("[up]", update ? "<dark_green>YES</dark_green>" : "<red>no</red>");
String stUpdate = "<dark_red>║</dark_red> <yellow>New version available:</yellow> [up]".replace("[up]", webData != null ? update ?
"<dark_green>YES</dark_green>" : "<red>no</red>" : "<b><dark_red>It could not be checked for updates!</dark_red></b>");
stNVersion = update ? "<br><dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]",player ? "<hover:show_text:'<yellow>Click for the update information</yellow>'><click:run_command:'/t2code updateinfo "+plugin.getName()+"'>"+publicVersion+"</click></hover>":publicVersion) : "";
String stLinkPlayer = "<dark_red>║</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> "
.replace("[slink]", "https://www.spigotmc.org/resources/" + spigotID)
+ "<dark_red>-</dark_red> <dark_purple><hover:show_text:'<green>Go to the T2Code Support Discord</green>'><click:open_url:'[dlink]'>Discord</click></hover></dark_purple>"
@@ -101,16 +142,17 @@ public class T2Ctemplate {
String stLinkConsole = "<dark_red>║</dark_red> <yellow>Spigot:</yellow> <gold>https://www.spigotmc.org/resources/" + spigotID + "</gold>"
+ "<br><dark_red>║</dark_red> <yellow>Discord:</yellow> <gold>" + discord + "</gold>";
String stLink = player ? stLinkPlayer : stLinkConsole;
String pr = premiumVerified != null ? "<br><dark_red>║</dark_red> <yellow>Premium verified:</yellow> [pr]".replace("[pr]", premiumVerified ? "<dark_green>YES</dark_green>" : "<red>NO</red>") : "";
String pr = premiumVerified != null ? "<br><dark_red>║</dark_red> <yellow>Premium verified:</yellow> [pr]".replace("[pr]",
premiumVerified ? "<dark_green>YES</dark_green>" : "<red>NO</red>") : "";
String stMSG = text == null || text.equals("") ? "" : "<br><dark_red>║</dark_red> " + text + "<br>";
T2Csend.sender(sender, "<dark_red>╔════════════════════════════════</dark_red>"
String stMSG = text == null || text.equals("") ? "" : "<br><dark_red>║</dark_red> " + text;
T2Csend.sender(sender, "<br><dark_red>╔════════════════════════════════</dark_red>"
+ "<br>" + stPlugin
+ "<br>" + stVersion
+ stMSG
+ stVersion
+ "<br>" + stAutor
+ "<br>" + stNVersion
+ "<br>" + stStable
+ "<br>" + stUpdate
+ stNVersion
+ "<br>" + stLink
+ pr
+ "<br><dark_red>╚════════════════════════════════</dark_red>");

View File

@@ -1,27 +1,38 @@
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.Bukkit;
public class T2CmcVersion {
public static void onCheck() {
mcVersion = Bukkit.getServer().getVersion();
bukkitVersion = Bukkit.getServer().getBukkitVersion();
nms = Bukkit.getServer().getClass().getPackage().getName();
mc1_8 = nms.contains("1_8");
mc1_9 = nms.contains("1_9");
mc1_10 = nms.contains("1_10");
mc1_11 = nms.contains("1_11");
mc1_12 = nms.contains("1_12");
mc1_13 = nms.contains("1_13");
mc1_14 = nms.contains("1_14");
mc1_15 = nms.contains("1_15");
mc1_16 = nms.contains("1_16");
mc1_17 = nms.contains("1_17");
mc1_18 = nms.contains("1_18");
mc1_19 = nms.contains("1_19");
mc1_20 = nms.contains("1_20");
T2CnmsVersions.init();
nms = String.valueOf(T2CnmsVersions.getT2CnmsEnum());
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "mcVersion: " + mcVersion);
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "bukkitVersion: " + bukkitVersion);
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "nms: " + nms);
mc1_8 = mcVersion.contains("MC: 1.8");
mc1_9 = mcVersion.contains("MC: 1.9");
mc1_10 = mcVersion.contains("MC: 1.10");
mc1_11 = mcVersion.contains("MC: 1.11");
mc1_12 = mcVersion.contains("MC: 1.12");
mc1_13 = mcVersion.contains("MC: 1.13");
mc1_14 = mcVersion.contains("MC: 1.14");
mc1_15 = mcVersion.contains("MC: 1.15");
mc1_16 = mcVersion.contains("MC: 1.16");
mc1_17 = mcVersion.contains("MC: 1.17");
mc1_18 = mcVersion.contains("MC: 1.18");
mc1_19 = mcVersion.contains("MC: 1.19");
mc1_20 = mcVersion.contains("MC: 1.20");
mc1_21 = mcVersion.contains("MC: 1.21");
mc1_22 = mcVersion.contains("MC: 1.22");
nms1_8_R1 = nms.contains("1_8_R1");
nms1_8_R2 = nms.contains("1_8_R2");
nms1_8_R3 = nms.contains("1_8_R3");
@@ -44,6 +55,11 @@ public class T2CmcVersion {
nms1_19_R2 = nms.contains("1_19_R2");
nms1_20_R1 = nms.contains("1_20_R1");
nms1_20_R2 = nms.contains("1_20_R2");
nms1_20_R3 = nms.contains("1_20_R3");
nms1_20_R4 = nms.contains("1_20_R4");
nms1_21_R1 = nms.contains("1_21_R1");
nms1_21_R2 = nms.contains("1_21_R2");
nms1_22_R1 = nms.contains("1_22_R1");
}
private static String mcVersion;
@@ -61,6 +77,8 @@ public class T2CmcVersion {
private static boolean mc1_18;
private static boolean mc1_19;
private static boolean mc1_20;
private static boolean mc1_21;
private static boolean mc1_22;
private static String nms;
private static boolean nms1_8_R1;
@@ -85,6 +103,11 @@ public class T2CmcVersion {
private static boolean nms1_19_R2;
private static boolean nms1_20_R1;
private static boolean nms1_20_R2;
private static boolean nms1_20_R3;
private static boolean nms1_20_R4;
private static boolean nms1_21_R1;
private static boolean nms1_21_R2;
private static boolean nms1_22_R1;
public static String getMcVersion() {
return mcVersion;
@@ -146,6 +169,15 @@ public class T2CmcVersion {
return mc1_20;
}
public static boolean isMc1_21() {
return mc1_21;
}
public static boolean isMc1_22() {
return mc1_22;
}
public static String getNms() {
return nms;
}
@@ -233,7 +265,84 @@ public class T2CmcVersion {
public static boolean isNms1_20_R1() {
return nms1_20_R1;
}
public static boolean isNms1_20_R2() {
return nms1_20_R2;
}
public static boolean isNms1_20_R3() {
return nms1_20_R3;
}
public static boolean isNms1_20_R4() {
return nms1_20_R4;
}
public static boolean isNms1_21_R1() {
return nms1_21_R1;
}
public static boolean isNms1_21_R2() {
return nms1_21_R2;
}
public static boolean isNms1_22_R1() {
return nms1_22_R1;
}
public static boolean minMc1_8() {
return isMc1_8();
}
public static boolean minMc1_9() {
return !isMc1_8();
}
public static boolean minMc1_10() {
return !isMc1_8() && !isMc1_9();
}
public static boolean minMc1_11() {
return !isMc1_8() && !isMc1_9() && !isMc1_10();
}
public static boolean minMc1_12() {
return !isMc1_8() && !isMc1_9() && !isMc1_10() && !isMc1_11();
}
public static boolean minMc1_13() {
return !isMc1_8() && !isMc1_9() && !isMc1_10() && !isMc1_11() && !isMc1_12();
}
public static boolean minMc1_14() {
return !isMc1_8() && !isMc1_9() && !isMc1_10() && !isMc1_11() && !isMc1_12() && !isMc1_13();
}
public static boolean minMc1_15() {
return !isMc1_8() && !isMc1_9() && !isMc1_10() && !isMc1_11() && !isMc1_12() && !isMc1_13() && !isMc1_14();
}
public static boolean minMc1_16() {
return !isMc1_8() && !isMc1_9() && !isMc1_10() && !isMc1_11() && !isMc1_12() && !isMc1_13() && !isMc1_14() && !isMc1_15();
}
public static boolean minMc1_17() {
return !isMc1_8() && !isMc1_9() && !isMc1_10() && !isMc1_11() && !isMc1_12() && !isMc1_13() && !isMc1_14() && !isMc1_15() && !isMc1_16();
}
public static boolean minMc1_18() {
return !isMc1_8() && !isMc1_9() && !isMc1_10() && !isMc1_11() && !isMc1_12() && !isMc1_13() && !isMc1_14() && !isMc1_15() && !isMc1_16() && !isMc1_17();
}
public static boolean minMc1_19() {
return !isMc1_8() && !isMc1_9() && !isMc1_10() && !isMc1_11() && !isMc1_12() && !isMc1_13() && !isMc1_14() && !isMc1_15() && !isMc1_16() && !isMc1_17() && !isMc1_18();
}
public static boolean minMc1_20() {
return !isMc1_8() && !isMc1_9() && !isMc1_10() && !isMc1_11() && !isMc1_12() && !isMc1_13() && !isMc1_14() && !isMc1_15() && !isMc1_16() && !isMc1_17()
&& !isMc1_18() && !isMc1_19();
}
public static boolean minMc1_21() {
return !isMc1_8() && !isMc1_9() && !isMc1_10() && !isMc1_11() && !isMc1_12() && !isMc1_13() && !isMc1_14() && !isMc1_15() && !isMc1_16() && !isMc1_17()
&& !isMc1_18() && !isMc1_19()&& !isMc1_20();
}
}

View File

@@ -0,0 +1,31 @@
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
public enum T2CnmsEnum {
not_support,
v1_8_R1,
v1_8_R2,
v1_8_R3,
v1_9_R1,
v1_9_R2,
v1_10_R1,
v1_11_R1,
v1_12_R1,
v1_13_R1,
v1_13_R2,
v1_14_R1,
v1_15_R1,
v1_16_R1,
v1_16_R2,
v1_16_R3,
v1_17_R1,
v1_18_R1,
v1_18_R2,
v1_19_R1,
v1_19_R2,
v1_19_R3,
v1_20_R1,
v1_20_R2,
v1_20_R3,
v1_20_R4,
v1_21_R1,
}

View File

@@ -0,0 +1,129 @@
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
import lombok.Getter;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
public class T2CnmsVersions {
public static Class minecraftServerClass;
@Getter
private static T2CnmsEnum t2CnmsEnum;
public static void init() {
String mc = T2CmcVersion.getMcVersion();
if (mc.contains("(MC: 1.8)") || mc.contains("(MC: 1.8.1)")) {
t2CnmsEnum = T2CnmsEnum.v1_8_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.8.3)")) {
t2CnmsEnum = T2CnmsEnum.v1_8_R2;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.8.4)") || mc.contains("(MC: 1.8.5)") || mc.contains("(MC: 1.8.6)") || mc.contains("(MC: 1.8.7)") || mc.contains("(MC: 1.8.8)")) {
t2CnmsEnum = T2CnmsEnum.v1_8_R3;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.9)") || mc.contains("(MC: 1.9.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_9_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.9.3)") || mc.contains("(MC: 1.9.4)")) {
t2CnmsEnum = T2CnmsEnum.v1_9_R2;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.10")) {
t2CnmsEnum = T2CnmsEnum.v1_10_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.11")) {
t2CnmsEnum = T2CnmsEnum.v1_11_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.12")) {
t2CnmsEnum = T2CnmsEnum.v1_12_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.13)")) {
t2CnmsEnum = T2CnmsEnum.v1_13_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.13.1)") || mc.contains("(MC: 1.13.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_13_R2;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.14")) {
t2CnmsEnum = T2CnmsEnum.v1_14_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.15")) {
t2CnmsEnum = T2CnmsEnum.v1_15_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.16)") || mc.contains("(MC: 1.16.1)")) {
t2CnmsEnum = T2CnmsEnum.v1_16_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.16.2)") || mc.contains("(MC: 1.16.3)")) {
t2CnmsEnum = T2CnmsEnum.v1_16_R2;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.16.4)") || mc.contains("(MC: 1.16.5)")) {
t2CnmsEnum = T2CnmsEnum.v1_16_R3;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.17")) {
t2CnmsEnum = T2CnmsEnum.v1_17_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.18)") || mc.contains("(MC: 1.18.1)")) {
t2CnmsEnum = T2CnmsEnum.v1_18_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.18.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_18_R2;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.19)") || mc.contains("(MC: 1.19.1)") || mc.contains("(MC: 1.19.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_19_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.19.3)")) {
t2CnmsEnum = T2CnmsEnum.v1_19_R2;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.19.4)")) {
t2CnmsEnum = T2CnmsEnum.v1_19_R3;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.20)") || mc.contains("(MC: 1.20.1)")) {
t2CnmsEnum = T2CnmsEnum.v1_20_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.20.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_20_R2;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.20.3)") || mc.contains("(MC: 1.20.4)")) {
t2CnmsEnum = T2CnmsEnum.v1_20_R3;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.20.6)")) {
t2CnmsEnum = T2CnmsEnum.v1_20_R4;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else if (mc.contains("(MC: 1.21)") || mc.contains("(MC: 1.21.1)")) {
t2CnmsEnum = T2CnmsEnum.v1_21_R1;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
} else t2CnmsEnum = T2CnmsEnum.not_support;
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), String.valueOf(t2CnmsEnum));
}
//
// public static void init() {
//
//
// // List<String> list= Arrays.stream(Class .getPackages()).map(Package::getName).filter(n -> n.startsWith("net.minecraft.server")).collect(Collectors.toList());
//
// // for (String s : list){
// // T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(),s);
// //}
//
//
// for (T2CnmsEnum nmsEnum : T2CnmsEnum.values()) {
// try {
// minecraftServerClass = Class.forName("net.minecraft.server." + nmsEnum + ".MinecraftServer");
// } catch (ClassNotFoundException ignored) {
//
// }
//
// if (minecraftServerClass != null) {
// return;
// }
//
// }
// // todo nicht kompatiebel
// T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "nicht kompa");
//
// }
}

View File

@@ -6,6 +6,7 @@ import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.UpdateType;
import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@@ -68,44 +69,44 @@ public class T2CupdateAPI {
"[prefix] <color:#ff9499><hover:show_text:'<red>Click for more information</red>'><click:run_command:'/t2c updateinfo " + plugin.getName() + "'>Update information</click></hover></color><br>" +
"[prefix]";
String value;
String updateStatusVersion;
if (webData.isPreRelease()) {
//todo if (!SelectLibConfig.getSeePreReleaseUpdates()) return;
value = UpdateType.PRERELEASE.text;
updateStatusVersion = UpdateType.PRERELEASE.text;
if (publicVersion.toLowerCase().contains("dev")) {
value = UpdateType.DEVELOPMENT.text;
updateStatusVersion = UpdateType.DEVELOPMENT.text;
}
if (publicVersion.toLowerCase().contains("beta")) {
value = UpdateType.BETA.text;
updateStatusVersion = UpdateType.BETA.text;
}
if (publicVersion.toLowerCase().contains("snapshot")) {
value = UpdateType.SNAPSHOT.text;
updateStatusVersion = UpdateType.SNAPSHOT.text;
}
} else value = UpdateType.STABLE.text;
} else updateStatusVersion = UpdateType.STABLE.text;
T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", value).replace("[link]", webData.getUpdateUrl())
T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", updateStatusVersion).replace("[link]", webData.getUpdateUrl())
.replace("[plv]", pluginVersion).replace("[puv]", publicVersion).replace("[dc]", discord));
}
public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Plugin plugin) {
String publicVersion = webData.getVersion();
String pluginVersion = plugin.getDescription().getVersion();
String value;
String updateStatusVersion;
if (webData.isPreRelease()) {
value = UpdateType.PRERELEASE.text;
updateStatusVersion = UpdateType.PRERELEASE.text;
if (publicVersion.toLowerCase().contains("dev")) {
value = UpdateType.DEVELOPMENT.text;
updateStatusVersion = UpdateType.DEVELOPMENT.text;
}
if (publicVersion.toLowerCase().contains("beta")) {
value = UpdateType.BETA.text;
updateStatusVersion = UpdateType.BETA.text;
}
if (publicVersion.toLowerCase().contains("snapshot")) {
value = UpdateType.SNAPSHOT.text;
updateStatusVersion = UpdateType.SNAPSHOT.text;
}
} else value = UpdateType.STABLE.text;
} else updateStatusVersion = UpdateType.STABLE.text;
String h = "<br><dark_red>╔══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
String s1 = "<br><dark_red>║</dark_red> <color:#6e90ff>A new [value] version was found!</color>".replace("[value]", value);
String s1 = "<br><dark_red>║</dark_red> <color:#6e90ff>A new [value] version was found!</color>".replace("[value]", updateStatusVersion);
String s2 = "<br><dark_red>║</dark_red> <color:#6e90ff>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</color> <green>" + webData.getVersion() + "</green>";
String s3 = "<br><dark_red>║</dark_red> <color:#6e90ff>You can download it here:</color> <yellow>" + webData.getUpdateUrl() + "</yellow>";
String s4 = "<br><dark_red>║</dark_red> <color:#6e90ff>You can find more information on Discord:</color> <yellow>" + discord + "</yellow>";
@@ -119,9 +120,13 @@ public class T2CupdateAPI {
try {
object = T2CupdateAPI.pluginVersions.get(args[1]);
} catch (Exception e) {
return "Das Plugin " + args[1] + " gibts net"; // todo
return Util.getPrefix() + " <red>The plugin <yellow>" + args[1] + "</yellow> is not registered in the update checker of T2Code!</red>";
}
if (object == null) return Util.getPrefix() + " <red>The plugin <yellow>" + args[1] + "</yellow> is not registered in the update checker of T2Code!</red>";
T2CupdateWebData webData = object.webData;
if (webData == null) {
return Util.getPrefix() + " <b><dark_red>It could not be checked for updates with the plugin <yellow>" + args[1] + "</yellow>!</dark_red></b>";
}
String pluginName = T2CupdateAPI.pluginVersions.get(args[1]).pluginName;
String pluginVersion = T2CupdateAPI.pluginVersions.get(args[1]).pluginVersion;
@@ -162,7 +167,7 @@ public class T2CupdateAPI {
String text;
text = "<dark_red>╔══════════════════════</dark_red>";
text = "<br><dark_red>╔══════════════════════</dark_red>";
text = text + pluginNameString;
text = text + pluginVersionString;
text = text + updateInfoString.replace("[value]", object.updateAvailable ? "Update available" : "Info about your version");

View File

@@ -15,6 +15,7 @@ import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.function.Consumer;
@@ -33,7 +34,7 @@ public class T2CupdateCheckerGit {
String finalRepoURL = RepoURL;
Integer finalInterval;
if (timeInterval < 1){
if (timeInterval < 1) {
finalInterval = 1;
} else finalInterval = timeInterval;
@@ -52,6 +53,10 @@ public class T2CupdateCheckerGit {
);
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
if (T2CupdateAPI.pluginVersions.get(plugin.getName()) == null){
T2Csend.debugmsg(T2CodeLibMain.getPlugin(),"'"+plugin.getName() + "' UpdateAPI T2CupdateAPI.pluginVersions.get(plugin.getName()) == null");
return;
}
if (T2CupdateAPI.pluginVersions.get(plugin.getName()).updateAvailable) {
if (!update.load) {
new BukkitRunnable() {
@@ -73,7 +78,7 @@ public class T2CupdateCheckerGit {
}, plugin.getDescription().getVersion(), spigotID, finalRepoURL, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
}
}, 0L, finalInterval * 60 * 20L);
}, 10L, finalInterval * 60 * 20L);
}
public void getVersion(Consumer<T2CupdateWebData> consumer, String pluginVersion, Integer spigotID, String URL, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
@@ -98,19 +103,19 @@ public class T2CupdateCheckerGit {
return;
}
JSONObject obj = new JSONObject(data);
String UpdateName = obj.getString("name");
String tag_name = obj.getString("tag_name");
String body = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''").replace("**", "");
String updateurl = obj.getString("html_url");
boolean prerelease = obj.getBoolean("prerelease");
String updateTitle = obj.getString("name");
String version = obj.getString("tag_name");
String updateDescription = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''").replace("**", "");
String updateUrl = obj.getString("html_url");
boolean preRelease = obj.getBoolean("prerelease");
String date = obj.getString("published_at");
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
Date parsedDate = inputFormat.parse(date);
String formattedDate = outputFormat.format(parsedDate);
String publishedAt = outputFormat.format(parsedDate);
String gitURL = updateurl;
String gitURL = updateUrl;
JSONArray downloadArray = obj.getJSONArray("assets");
String downloadURL;
if (downloadArray.isEmpty()) {
@@ -119,14 +124,14 @@ public class T2CupdateCheckerGit {
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
}
if (!prerelease) {
if (!preRelease) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
updateurl = "https://www.spigotmc.org/resources/" + spigotID;
updateUrl = "https://www.spigotmc.org/resources/" + spigotID;
}
T2CupdateWebData webData = new T2CupdateWebData(UpdateName, tag_name, body, updateurl, formattedDate, downloadURL, gitURL, prerelease);
T2CupdateWebData webData = new T2CupdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease);
consumer.accept(webData);
} catch (Exception var10) {
} catch (Exception exception) {
Boolean load = false;
if (T2CupdateAPI.pluginVersions.containsKey(plugin.getName())) {
load = T2CupdateAPI.pluginVersions.get(plugin.getName()).load;
@@ -140,7 +145,9 @@ public class T2CupdateCheckerGit {
updateCheckOnJoin
);
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());
T2Csend.error(this.plugin,"§4 Cannot look for updates: " + exception.getMessage());
exception.printStackTrace();
}
});
}

View File

@@ -1,5 +1,7 @@
package net.t2code.t2codelib.SPIGOT.system;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -7,6 +9,7 @@ import org.bukkit.entity.Player;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Arrays;
public class T2CbungeeCommandSenderReciver {
@@ -24,18 +27,22 @@ public class T2CbungeeCommandSenderReciver {
}
}
output.writeUTF(information);
output.writeUTF(String.valueOf(Util.getServerUUID()));
} catch (IOException e) {
e.printStackTrace();
}
if (sender instanceof Player) {
Player player = (Player) sender;
player.sendPluginMessage(T2CodeLibMain.getPlugin(), "t2c:bcmd", stream.toByteArray());
}else {
for(Player player : Bukkit.getOnlinePlayers()){
player.sendPluginMessage(T2CodeLibMain.getPlugin(), "t2c:bcmd", stream.toByteArray());
return;
}
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received T2CbungeeCommandSenderReciver: t2c:bcmd - " + Arrays.toString(stream.toByteArray()) + " Player: " + player.getName());
} else {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendPluginMessage(T2CodeLibMain.getPlugin(), "t2c:bcmd", stream.toByteArray());
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received T2CbungeeCommandSenderReciver: t2c:bcmd - " + Arrays.toString(stream.toByteArray()) + " Player: " + player.getName());
return;
}
//todo
}
}
}

View File

@@ -9,10 +9,13 @@ import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CnmsEnum;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CnmsVersions;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.system.bstats.Metrics;
import net.t2code.t2codelib.SPIGOT.system.cmd.CmdExecuter;
import net.t2code.t2codelib.SPIGOT.system.cmd.Development;
import net.t2code.t2codelib.SPIGOT.system.cmd.ReportLogStorage;
import net.t2code.t2codelib.SPIGOT.system.config.config.ConfigCreate;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
@@ -61,10 +64,11 @@ public final class T2CodeLibMain extends JavaPlugin {
}
T2CmcVersion.onCheck();
if (T2CmcVersion.isNms1_20_R2()) {
if (T2CnmsVersions.getT2CnmsEnum() == T2CnmsEnum.not_support) {
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(prefix);
T2Csend.warning(plugin, "The 1.20.* (R2) is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net");
T2Csend.warning(plugin, "The " + T2CmcVersion.getMcVersion() + " is a very fresh / new version.");
T2Csend.warning(plugin, "The plugin may not yet be supported on this server! If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net");
T2Csend.console(prefix);
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
if (!SelectLibConfig.getT2cTestDevelopment()) {
@@ -75,28 +79,51 @@ public final class T2CodeLibMain extends JavaPlugin {
}
}
}
T2Csend.console(prefix + " §3Server run on: §6" + T2CmcVersion.getMcVersion() + " / " + T2CmcVersion.getNms());
if (T2CmcVersion.isMc1_22()) {
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(prefix);
T2Csend.warning(plugin, "The 1.22 is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net");
T2Csend.console(prefix);
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
if (!SelectLibConfig.getT2cTestDevelopment()) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
T2Ctemplate.onLoadSeparateStroke(prefix);
T2Csend.console(prefix + " §2Server run on:");
T2Csend.console(prefix + " §3mcVersion: §6" + T2CmcVersion.getMcVersion());
T2Csend.console(prefix + " §3bukkitVersion: §6" + T2CmcVersion.getBukkitVersion());
T2Csend.console(prefix + " §3nms: §6" + T2CmcVersion.getNms());
T2Ctemplate.onLoadSeparateStroke(prefix);
if (eco != null) {
String st = eco.getName();
if (eco.getName().equals("CMIEconomy")) st = "CMI";
if (Bukkit.getPluginManager().getPlugin(st) != null) {
T2Csend.console(prefix + " §3Economy: §6" + eco.getName() + " - " + Bukkit.getPluginManager().getPlugin(st).getDescription().getVersion() + " §7- §e" +
(System.currentTimeMillis() - long_) + "ms");
} else T2Csend.console(prefix + " §3Economy: §6" + eco.getName() + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} else T2Csend.console(prefix + " §3Economy: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} else
T2Csend.console(prefix + " §3Economy: §6" + eco.getName() + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} else
T2Csend.console(prefix + " §3Economy: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
if (perm != null) {
if (Bukkit.getPluginManager().getPlugin(perm.getName()) != null) {
T2Csend.console(prefix + " §3Permission plugin: §6" + perm.getName() + " - " + Bukkit.getPluginManager().getPlugin(perm.getName()).getDescription().getVersion()
+ " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} else T2Csend.console(prefix + " §3Permission plugin: §6" + perm.getName() + " - §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} else T2Csend.console(prefix + " §3Permission plugin: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} else
T2Csend.console(prefix + " §3Permission plugin: §6" + perm.getName() + " - §7- §e" + (System.currentTimeMillis() - long_) + "ms");
} else
T2Csend.console(prefix + " §3Permission plugin: §4not connected via vault!" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
if (T2CpluginCheck.papi()) {
T2Csend.console(prefix + " §3PlaceholderAPI: §6connected" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
T2Csend.console(prefix + " §3Kyori MiniMessage Support: "+ (getMmIsLoad() ? "§2load" : "§4not load") + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2Csend.console(prefix + " §3Kyori MiniMessage Support: " + (getMmIsLoad() ? "§2load" : "§4not load") + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
plugin.getCommand("t2code").setExecutor(new CmdExecuter());
@@ -111,6 +138,7 @@ public final class T2CodeLibMain extends JavaPlugin {
Metrics.Bstats(plugin, Util.getBstatsID());
if (SelectLibConfig.getBungee()) {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:bcmd");
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bonlp");
if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, "t2c:bonlp")) {
@@ -122,7 +150,7 @@ public final class T2CodeLibMain extends JavaPlugin {
ReportLogStorage.load();
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new Development(), plugin);
T2Ctemplate.onLoadFooter(prefix, long_);
load = true;
}
@@ -139,7 +167,7 @@ public final class T2CodeLibMain extends JavaPlugin {
}
Vault.vaultDisable();
T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
T2Ctemplate.onDisable(Util.getPrefix(), this);
if (mmIsLoad) {
if (this.adventure != null) {
this.adventure.close();

View File

@@ -1,8 +1,12 @@
package net.t2code.t2codelib.SPIGOT.system.cmd;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayers;
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.Util;
@@ -21,11 +25,11 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
if (args.length == 0) {
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
Commands.info(sender);
return false;
}
@@ -35,23 +39,82 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
case "pl":
case "version":
case "ver":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
Commands.info(sender);
return false;
case "updateinfo":
Commands.updateInfo(sender,args);
case "permtoggle":
if (!sender.hasPermission("t2code.permtoggle.use")) {
T2Csend.sender(sender, "§4No Permission §8t2code.permtoggle.use");
return false;
}
Commands.permtoggle(sender, args);
return false;
case "updateinfo":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
Commands.updateInfo(sender, args);
return false;
// case "plugininfo": todo
// if (!sender.hasPermission("t2code.admin")) {
// T2Csend.sender(sender, "§4No Permission §8t2code.admin");
// return false;
// }
// Commands.updateInfo(sender, args);
// return false;
case "reloadconfig":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
SelectLibConfig.onSelect();
T2Csend.sender(sender, Util.getPrefix() + " §2Config successfully reloaded");
return false;
case "debug":
Commands.debug(sender,args);
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
Commands.debug(sender, args);
return false;
case "test":
T2Csend.sender(sender, T2CbungeePlayers.getBungeePlayers().toString());
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
Commands.test(sender, args);
return false;
case "serverid":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
T2Csend.sender(sender, ("[prefix] <red>T2C ServerID:</red> <gold><hover:show_text:'<yellow>copy</yellow>'>" +
"<click:copy_to_clipboard:[id]>[id]</click></hover></gold>").replace("[prefix]", Util.getPrefix()).replace("[id]", String.valueOf(Util.getServerUUID())));
return false;
case "bcmd":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
String cmd = "";
for (String s : args) {
cmd = cmd + s + " ";
}
cmd = cmd.replace("bcmd ", "");
T2CbungeeCommandSenderReciver.sendToBungee(null, cmd, true);
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage BCMD: " + cmd);
return false;
default:
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
return false;
}
@@ -61,6 +124,8 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
put("debug", "t2code.admin");
put("info", "t2code.admin");
put("serverid", "t2code.admin");
put("bcmd", "t2code.admin");
put("reloadconfig", "t2code.admin");
put("updateinfo", "t2code.admin");
}};
@@ -81,17 +146,23 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
if (args.length == 2 && args[0].equalsIgnoreCase("debug")) {
if (sender.hasPermission("t2code.admin")) {
if (hasPermission(p, arg1.get("debug"))) {
if (passend("createReportLog",args[1])) list.add("createReportLog");
if (passend("deleteReportLog",args[1])) list.add("deleteReportLog");
if (passend("createReportLog", args[1])) list.add("createReportLog");
if (passend("deleteReportLog", args[1])) list.add("deleteReportLog");
}
}
return list;
}
if (args.length == 2 && args[0].equalsIgnoreCase("bcmd")) {
if (sender.hasPermission("t2code.admin")) {
list.add("<command>");
}
return list;
}
if (args.length == 2 && args[0].equalsIgnoreCase("updateinfo")) {
if (sender.hasPermission("t2code.admin")) {
if (hasPermission(p, arg1.get("updateinfo"))) {
for (Map.Entry<String, T2CupdateObject> pl : T2CupdateAPI.pluginVersions.entrySet()){
if (passend(pl.getValue().pluginName,args[1])) list.add(pl.getValue().pluginName);
for (Map.Entry<String, T2CupdateObject> pl : T2CupdateAPI.pluginVersions.entrySet()) {
if (passend(pl.getValue().pluginName, args[1])) list.add(pl.getValue().pluginName);
}
}
}
@@ -99,11 +170,11 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
}
if (args.length == 3 && args[0].equalsIgnoreCase("debug")&& args[1].equalsIgnoreCase("deleteReportLog")) {
if (args.length == 3 && args[0].equalsIgnoreCase("debug") && args[1].equalsIgnoreCase("deleteReportLog")) {
if (sender.hasPermission("t2code.admin")) {
if (hasPermission(p, arg1.get("debug"))) {
for (String st : ReportLogStorage.list){
if (passend(st,args[2])) list.add(st);
for (String st : ReportLogStorage.list) {
if (passend(st, args[2])) list.add(st);
}
}
}

View File

@@ -1,29 +1,37 @@
package net.t2code.t2codelib.SPIGOT.system.cmd;
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ccmd;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.IOException;
public class Commands {
public static void info(CommandSender sender) {
protected static void info(CommandSender sender) {
T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText());
}
public static void debug(CommandSender sender, String[] args) {
protected static void test(CommandSender sender, String[] args) {
T2Csend.sender(sender, Util.getPrefix() + " &4Currently there is no development test command");
}
protected static void debug(CommandSender sender, String[] args) {
if (args.length < 2) {
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
return;
}
switch (args[1].toLowerCase()) {
case "createreportlog":
switch (args.length){
switch (args.length) {
case 2:
if (sender instanceof Player) {
T2Csend.sender(sender, "<dark_red>The debug zip file is <red>automatically uploaded</red> to T2Code's servers<br>and <red>automatically deleted</red> " +
@@ -74,7 +82,26 @@ public class Commands {
}
}
public static void updateInfo(CommandSender sender, String[] args) {
protected static void updateInfo(CommandSender sender, String[] args) {
T2Csend.sender(sender, T2CupdateAPI.updateInfo(args, sender instanceof Player));
}
public static void permtoggle(CommandSender sender, String[] args) {
Player player = (Player) Bukkit.getOfflinePlayer(args[1]);
if (player == null) {
T2Csend.sender(sender, "§4Player §6" + args[1] + " §4not exist!");
return;
}
String permission = args[2];
if (player.hasPermission(permission)) {
T2Ccmd.console(SelectLibConfig.getCommandPermToggleCommand().replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "false"));
T2Csend.sender(sender, "§2Permission §8'§6" + permission + "§8' §2was set to §6false §2for the player §6" + player.getName() + "§2.");
} else {
T2Ccmd.console(SelectLibConfig.getCommandPermToggleCommand().replace("[player]",player.getName()).replace("[perm]",permission).replace("[value]", "true"));
T2Csend.sender(sender, "§2Permission §8'§6" + permission + "§8' §2was set to §6true §2for the player §6" + player.getName() + "§2.");
}
}
}

View File

@@ -29,7 +29,10 @@ import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@@ -101,18 +104,35 @@ public class CreateReportLog {
pWriter.println("T2C-LuckyBox isV: " + LuckyBoxAPI.isV());
pWriter.println();
}
pWriter.println("OfflinePlayers amount: " + Bukkit.getOfflinePlayers().length);
pWriter.println("OfflinePlayers: ");
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
ArrayList<OfflinePlayer> players = new ArrayList<>();
Collections.addAll(players, Bukkit.getOfflinePlayers());
players.sort(Comparator.comparing(OfflinePlayer::getName));
for (OfflinePlayer player : players) {
pWriter.println(" - " + player.getName() + " - " + player.getUniqueId());
}
pWriter.println();
pWriter.println("Plugins amount: " + Bukkit.getPluginManager().getPlugins().length);
pWriter.println("Plugins: ");
for (Plugin pl : Bukkit.getPluginManager().getPlugins()) {
pWriter.println(" - " + pl.getName() + " - " + pl.getDescription().getVersion() + " - Enabled: " + pl.isEnabled() + " - Autors: "
+ pl.getDescription().getAuthors() + " - SoftDepend: " + pl.getDescription().getSoftDepend() + " - Depend: " + pl.getDescription().getDepend()
+ " LoadBefore: " + pl.getDescription().getLoadBefore() + " - Website: " + pl.getDescription().getWebsite());
ArrayList<Plugin> plugins = new ArrayList<>();
Collections.addAll(plugins, Bukkit.getPluginManager().getPlugins());
plugins.sort(Comparator.comparing(Plugin::getName));
for (Plugin pl : plugins) {
pWriter.println(" - " + pl.getName() +
" - " + pl.getDescription().getVersion() +
" - Enabled: " + pl.isEnabled() +
" - Autors: " + pl.getDescription().getAuthors() +
" - SoftDepend: " + pl.getDescription().getSoftDepend() +
" - Depend: " + pl.getDescription().getDepend() +
" - LoadBefore: " + pl.getDescription().getLoadBefore() +
" - Website: " + pl.getDescription().getWebsite());
}
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
@@ -132,9 +152,9 @@ public class CreateReportLog {
addFileToZip("", "logs/latest.log", zip, false);
// for (String pl : Util.getT2cPlugins()) {
// pluginToDebug(pl, zip);
// }
// for (String pl : Util.getT2cPlugins()) {
// pluginToDebug(pl, zip);
// }
pluginToDebug(zip); //todo überprüfen
zip.closeEntry();
@@ -178,7 +198,7 @@ public class CreateReportLog {
"<br>[prefix] <green>You can download it <click:open_url:'[url]'><gold><hover:show_text:'<yellow>Download the debug file</yellow>'>here</hover></gold></click>." +
"<br>[prefix] <green>Please enter the following key in the ticket: <gold><click:copy_to_clipboard:[key]><hover:show_text:'<yellow>Copy to clipboard</yellow>'>[key]</hover></click></gold></green>" +
"<br>[prefix] <dark_red>Do not share the download URL with anyone!</dark_red>" +
"<br><hover:show_text:'<yellow>Click to delete</yellow>'><click:run_command:'/t2code debug deleteReportLog [key]'>[prefix] <green>You can <b>delte</b> yor Debug-File by clicking me.</green>" +
"<br>[prefix] <click:run_command:'/t2code debug deleteReportLog [key]'><hover:show_text:'<yellow>Click to delete</yellow>'><green>You can <b>delete</b> your Debug-File by clicking me.</green>" +
"<br>[prefix] <color:#910d06>(If you do not delete the debug file, it will be deleted automatically after <red>14</red> days!)</color></click></hover>")
.replace("[key]", fileID).replace("[url]", downloadURL).replace("[prefix]", Util.getPrefix()));
}
@@ -186,7 +206,7 @@ public class CreateReportLog {
"<br><gold>Please enter the following key in the ticket:</gold> <yellow>[key]</yellow>." +
"<br><dark_red>Do not share the download URL with anyone!</dark_red>" +
"<br><color:#910d06>(If you do not delete the debug file, it will be deleted automatically after <red>14</red> days!)</color>" +
"<br><dark_red>You can delte yor Debug-File with the following command:</dark_red> <red>/t2code debug deleteReportLog [key]</red>.")
"<br><dark_red>You can delete your Debug-File with the following command:</dark_red> <red>/t2code debug deleteReportLog [key]</red>.")
.replace("[key]", fileID).replace("[url]", downloadURL));
ReportLogStorage.add(fileID);
}
@@ -208,16 +228,17 @@ public class CreateReportLog {
}
}
}
private static void pluginToDebug(ZipOutputStream zip) throws IOException {
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()){
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
String plName = plugin.getDescription().getName();
if (plName.contains("T2C-") || Util.getT2cPlugins().contains(plName)){
if (plName.contains("T2C-") || Util.getT2cPlugins().contains(plName) || plugin.getDescription().getAuthors().contains("JaTiTV")) {
File plConfigs = new File(plugin.getDataFolder().getPath());
if (plConfigs.exists()) {
addFolderToZip("T2Code-Plugins", plugin.getDataFolder().getPath(), zip);
}
File f = new File(plugin.getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
addFileToZip("T2Code-Plugins", f.getPath(), zip, false);
addFileToZip("T2Code-Plugins", f.getPath(), zip, false);
}
}
}

View File

@@ -0,0 +1,71 @@
package net.t2code.t2codelib.SPIGOT.system.cmd;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import static net.t2code.t2codelib.SPIGOT.api.dev.T2CdevelopmentTool.removeLastChar;
public class Development implements Listener {
@EventHandler
public void onChat(AsyncPlayerChatEvent e) {
String[] args = e.getMessage().split(" ");
if (args.length == 0) {
return;
}
if (!args[0].equals("_t2code_")) {
return;
}
if (!SelectLibConfig.getDeveloperTool()) {
T2Csend.player(e.getPlayer(), Util.getPrefix() + " The Development Tool is disabled.");
}
e.setCancelled(true);
t2cPls(e.getPlayer());
}
protected static void t2cPls(Player player) {
String msg = "<red>T<gray>2</gray>Code</red> <dark_purple>Development</dark_purple><br>"
+ T2CmcVersion.getMcVersion() + "<br>(" + Bukkit.getPluginManager().getPlugins().length + ") ";
ArrayList<Plugin> plugins = new ArrayList<>();
Collections.addAll(plugins, Bukkit.getPluginManager().getPlugins());
plugins.sort(Comparator.comparing(Plugin::getName));
for (Plugin plugin : plugins) {
String plName = plugin.getDescription().getName();
String hover = "<blue>" + plugin.getDescription().getName() + "</blue><br>" +
"<green>Version:</green> <gold>" + plugin.getDescription().getVersion() + "</gold><br>" +
"<green>APIVersion:</green> <gold>" + plugin.getDescription().getAPIVersion() + "</gold><br>" +
"<green>Authors:</green> <gold>" + plugin.getDescription().getAuthors() + "</gold><br>" +
"<green>SoftDepend:</green> <gold>" + plugin.getDescription().getSoftDepend() + "</gold><br>" +
"<green>Depend:</green> <gold>" + plugin.getDescription().getDepend() + "</gold><br>" +
"<green>LoadBefore:</green> <gold>" + plugin.getDescription().getLoadBefore() + "</gold><br>" +
"<green>Website:</green> <gold>" + plugin.getDescription().getWebsite() + "</gold>";
String plSt = "<hover:show_text:'" + hover + "'>" + plugin.getName() + "</hover>";
if (plugin.getDescription().getWebsite() != null && !plugin.getDescription().getWebsite().equalsIgnoreCase("null")) {
plSt = "<click:open_url:'" + plugin.getDescription().getWebsite() + "'>" + plSt + "</click>";
}
if (plugin.isEnabled()) {
if (plName.contains("T2C-") || Util.getT2cPlugins().contains(plName)) {
msg = msg + "<dark_green>" + plSt + "</dark_green>, ";
} else msg = msg + "<green>" + plSt + "</green>, ";
} else if (plName.contains("T2C-") || Util.getT2cPlugins().contains(plName)) {
msg = msg + "<dark_red>" + plSt + "</dark_red>, ";
} else msg = msg + "<red>" + plSt + "</red>, ";
}
T2Csend.player(player, removeLastChar(msg, 2));
}
}

View File

@@ -28,10 +28,13 @@ public class ConfigCreate {
T2Cconfig.set("Plugin.UpdateCheck.SeePreReleaseUpdates", true, yamlConfiguration);
T2Cconfig.set("Plugin.UpdateCheck.AllPlugins.FullDisable", false, yamlConfiguration);
T2Cconfig.set("Plugin.language", "english", yamlConfiguration);
T2Cconfig.set("Plugin.Not recommended to disable.developerTool", true, yamlConfiguration);
T2Cconfig.set("BungeeCord.Enable", T2CodeLibMain.getIsBungee(), yamlConfiguration);
T2Cconfig.set("Player.Inventories.CloseByServerStop", true, yamlConfiguration);
T2Cconfig.set("Command.PermToggle.PermissionSetCommand","lp user [player] permission set [perm] [value]",yamlConfiguration);
try {
yamlConfiguration.save(config);
} catch (IOException e) {

View File

@@ -23,9 +23,13 @@ public class SelectLibConfig {
@Getter
private static String language;
@Getter
private static Boolean developerTool;
@Getter
private static Boolean bungee;
@Getter
private static Boolean inventoriesCloseByServerStop;
@Getter
private static String commandPermToggleCommand;
public static void onSelect() {
File config = new File(T2CodeLibMain.getPath(), "config.yml");
@@ -41,7 +45,9 @@ public class SelectLibConfig {
updateCheckFullDisable = yamlConfiguration.getBoolean("Plugin.UpdateCheck.AllPlugins.FullDisable");
debug = yamlConfiguration.getBoolean("Plugin.Debug");
language = yamlConfiguration.getString("Plugin.language");
developerTool = yamlConfiguration.getBoolean("Plugin.Not recommended to disable.developerTool");
bungee = yamlConfiguration.getBoolean("BungeeCord.Enable");
inventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop");
commandPermToggleCommand = yamlConfiguration.getString("Command.PermToggle.PermissionSetCommand");
}
}

View File

@@ -1,6 +1,7 @@
package net.t2code.t2codelib;
import lombok.Getter;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import java.util.Arrays;
import java.util.List;
@@ -13,7 +14,7 @@ public class Util {
public static String getInfoText() {
return "";
return "<yellow>Description:</yellow> <gold>"+T2CodeLibMain.getPlugin().getDescription().getDescription()+"</gold>" ;
}
public static String getPrefix() {

View File

@@ -3,9 +3,9 @@ version: '${project.version}'
main: net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain
api-version: 1.13
prefix: T2CodeLib
authors: [ JaTiTV, Jkobs ]
authors: [ JaTiTV ]
description: Library from T2Code Plugins
website: T2Code.net
website: https://spigotmc.org/resources/96388/
load: STARTUP
softdepend:
@@ -29,3 +29,7 @@ commands:
permissions:
t2code.admin:
default: op
children:
t2code.permtoggle.use: true
t2code.permtoggle.use:
default: op