Compare commits

...

104 Commits

Author SHA1 Message Date
17d3aed11f velocity 10% 2024-06-17 01:50:30 +02:00
a01b4b4330 input dev-01 2024-06-15 21:13:20 +02:00
b8c65cb537 16.7
Debug messages removed
2024-06-15 18:06:14 +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
b2ebce50ed 15.1 | Stable 1.20 support
Stable 1.20 support
2023-06-19 14:30:37 +02:00
1b8bedc4e6 Merge branch 'development' of https://git.t2code.net/JaTiTV/T2CodeLib into development 2023-06-08 06:57:15 +02:00
4b7d8539ea 15.0
- Update auf Minecraft Version 1.20
- Kyori MiniMessage API Update auf 4.14.0
2023-06-08 06:55:44 +02:00
JaTiTV
bb230fb3ea Merge pull request 'Update pom.xml' (#20) from 14.7 into development
Reviewed-on: #20
2023-05-17 18:53:58 +00:00
b01bf2d84f Update pom.xml 2023-05-17 20:48:09 +02:00
JaTiTV
32fe2ab579 Merge pull request '14.5' (#19) from 14.5 into development
Reviewed-on: #19
2023-05-17 18:44:01 +00:00
c4282817b0 14.6
Bugfix
T2CnameHistory API fix
2023-05-16 19:36:36 +02:00
JaTiTV
e9ee3e690c Merge pull request 'Update T2CnameHistory.java' (#18) from 14.5_FIX into 14.5
Reviewed-on: #18
2023-05-16 17:31:34 +00:00
Jkobs
c9ee80dd38 Update T2CnameHistory.java 2023-05-16 19:08:48 +02:00
JaTiTV
b00b201bce Merge pull request '14.5' (#17) from 14.5 into development
Reviewed-on: #17
2023-05-10 20:38:33 +00:00
709bd16317 [Bungee] Fixed a small performance bug: If the update check interval was set to 0, it could crash the server and cause spam in the console both to the update check server of T2Code. 2023-05-10 21:09:27 +02:00
66dc27483b new UpdateCheck option
Added an option to completely disable the UpdateCheck of all plugins that check via the T2CodeLib
2023-05-10 21:07:36 +02:00
623d6f8c12 14.5
Fixed a small performance bug: If the update check interval was set to 0, it could crash the server and cause spam in the console both to the update check server of T2Code.
2023-05-04 16:26:04 +02:00
b3adbe61e8 Improved Update Information 2023-04-23 14:33:42 +02:00
167b81f0df Improved update information 2023-04-23 13:50:53 +02:00
8bbdd7a818 Update T2Cdebug.java 2023-04-23 13:15:06 +02:00
3aee76ddb8 T2Csend.debug() -> T2Cdebug.debug() / add T2Cdebug.debugCode() 2023-04-23 12:30:56 +02:00
65ff4ee24a 14.4 / kiori update 2023-04-23 12:29:38 +02:00
ede7908721 Update pom.xml 2023-02-28 00:38:44 +01:00
dd4a5de2ab clean code 2023-02-27 23:36:53 +01:00
7243e403e1 change Bungee API
net.md_5.bungee.BungeeCord -> net.md_5.bungee.api.ProxyServer
2023-02-27 23:36:41 +01:00
63d80b9e5e Create T2CitemBuilder.java 2023-02-27 23:35:52 +01:00
74e05ff7c5 Update pom.xml 2023-02-27 23:35:46 +01:00
1708c4bf70 14.3 2023-01-25 13:52:19 +01:00
415e8dc24b Small improvement of the method addItem of the class T2Ceco 2023-01-25 11:58:57 +01:00
c4b5996256 14.3_DEV-1
Fix if Vault was disabled before T2CodeLib was loaded
2023-01-15 20:58:18 +01:00
37db515726 14.2
Changes:
- T2CLibConfig was added to the API to access the T2CodeLib config.yml
- Create ReportLog was slightly rewritten to make it easier to copy the T2CodePlugins into the zip and to improve performance
- added a feedback to the command /t2c reloadconfig
- change plugin info design
2023-01-05 19:27:11 +01:00
JaTiTV
6c412f5360 „.gitea/ISSUE_TEMPLATE/feature_request.md“ ändern 2022-12-31 20:28:25 +00:00
0fcf436dbf change plugin info design 2022-12-31 21:25:07 +01:00
1762afce07 add ISSUE TEMPLATE 2022-12-31 21:24:45 +01:00
9916040c63 bugfix by reloadconfig
'/t2c reloadconfig' did not give any feedback
2022-12-31 02:28:58 +01:00
1b589759fb Merge branch 'main' of https://git.t2code.net/JaTiTV/T2CodeLib 2022-12-29 22:03:32 +01:00
6ee14b4782 14.2 Dev 2022-12-29 22:02:05 +01:00
JaTiTV
2d916c7e0c Merge pull request '14.1' (#15) from 14.1 into main
Reviewed-on: #15
2022-12-29 20:58:13 +00:00
8567e6b3b2 Update pom.xml 2022-12-28 13:43:51 +01:00
b64c1e7c59 14.1 | API changes
- Methods with objects have been added to T2Csend
- Methods with objects have been added to T2Creplace
- Methods with objects have been added to T2Cconfig
2022-12-28 13:42:55 +01:00
1b12c2728b 14.0
add BungeePlayers List / Event for Spigot Server
2022-12-24 19:05:18 +01:00
eb7fd03650 13.9
Bugfix:
- The plugin messaging channel for T2C-Commendgui was not properly registered on the proxy
- Fixed a small bug in the Update Checker where a NullPointExeption appeared in the console when the UpdateCheck server was unreachable
2022-12-22 01:43:40 +01:00
deeedcd408 13.6 2022-11-20 20:17:43 +01:00
e4c4aee0f7 13.5
Change:
- If no new update was found from a plugin, then there is now no more console spam
- Support for the old update checker has been removed
2022-11-19 02:51:28 +01:00
1b7918f011 Merge branch '13.4' 2022-11-15 02:19:36 +01:00
9986f477b2 13.4 2022-11-15 02:17:26 +01:00
d27ef185e6 13.4_SNAPSHOT-2 2022-11-15 00:36:25 +01:00
8114035cd9 seePreReleaseUpdates #1 2022-11-14 22:59:17 +01:00
f0b5b2e65b 13.4_SNAPSHOT-2
- From now on a different temporary path is used to create the debug zip to avoid data garbage.
- The design of the update messages was changed
2022-11-14 22:37:36 +01:00
f9b0b512b9 13.4_SNAPSHOT-1 2022-11-14 18:45:54 +01:00
JaTiTV
f5460be3a1 „README.md“ ändern 2022-11-14 15:56:05 +00:00
JaTiTV
f65d277817 „README.md“ ändern 2022-11-14 15:55:53 +00:00
JaTiTV
c1b9de8b5a „README.md“ ändern 2022-11-14 15:03:21 +00:00
JaTiTV
03af0646a6 „README.md“ hinzufügen 2022-11-14 15:02:07 +00:00
Jkobs
f70767b361 New Bungee Updater 2022-11-14 14:41:45 +01:00
5857e02695 small fix 2022-11-14 14:16:46 +01:00
JaTiTV
ee07755493 Merge pull request 'Fixes and Changes' (#13) from Debug_Changes_and_Fixes into 13.4
Reviewed-on: #13
2022-11-14 13:05:04 +00:00
Jkobs
9d233ba5a6 Fixes and Changes 2022-11-14 10:04:53 +01:00
f1065ad5a1 small bugfix 2022-11-14 01:42:43 +01:00
a0e590a2c1 dev 2 2022-11-14 01:06:44 +01:00
564288c9ab fix minimessage 2022-11-13 17:50:23 +01:00
JaTiTV
ed16dc160b Merge pull request 'NewDebugZip' (#11) from NewDebugZip into 13.3
Reviewed-on: #11
2022-11-13 15:31:20 +00:00
a2e8a672fa Update CreateReportLog.java 2022-11-13 15:43:49 +01:00
55d7a4496c Update Util.java 2022-11-10 21:37:15 +01:00
Jkobs
8147a5a2b4 Update CreateReportLog.java 2022-11-10 19:29:44 +01:00
Jkobs
a15d667244 Update CmdExecuter.java 2022-11-10 19:13:54 +01:00
Jkobs
73d574adef Merge branch 'main' into NewDebugZip 2022-11-10 19:11:28 +01:00
Jkobs
855b0ee3cd Update CmdExecuter.java 2022-11-10 19:03:56 +01:00
Jkobs
eb466f0df1 Init 2022-11-10 18:27:55 +01:00
3bdbaacd64 uc 2022-11-10 14:00:59 +01:00
Jkobs
8034d8852a New Updater 2022-11-10 11:28:55 +01:00
Jkobs
14c520722a Merge branch '13.0' into NewUpdateChecker 2022-11-10 10:14:16 +01:00
92 changed files with 4377 additions and 770 deletions

View File

@@ -0,0 +1,37 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels:
- "bug report"
---
**Description of issue:**
---
**Plugin Version (using`/t2c info`):**
**Server Type (Spigot/Paperspigot/etc):**
**Server Version (using `/ver`):**
**Relevant plugins (Delete if this isn't needed):**
---
**ERROR (DELETE IF YOU HAVE NO ERROR):**
```
######################
## REPLACE WITH ERROR ##
######################
```
**CONFIG SECTION (DELETE IF NOT RELEVANT):**
```
#######################################
## REPLACE WITH RELEVANT CONFIG SECTION ##
#######################################
```

View File

@@ -0,0 +1,21 @@
---
name: Feature request
about: Suggest an idea/improvement
title: ''
labels:
- "feature request"
---
**Description of feature request:**
---
**Plugin Version (using`/t2c info`):**
**Server Type (Spigot/Paperspigot/etc):**
**Server Version (using `/ver`):**
**Relevant plugins (Delete if this isn't needed):**

View File

@@ -0,0 +1,22 @@
---
name: Question
about: Ask a question or get advice
title: ''
labels:
- question
---
**Share your question here:**
---
**Plugin Version (using`/t2c info`):**
**Server Type (Spigot/Paperspigot/etc):**
**Server Version (using `/ver`):**
**Relevant plugins (Delete if this isn't needed):**
---

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>

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

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

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

@@ -0,0 +1,65 @@
<?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>
<remote-repository>
<option name="id" value="papermc" />
<option name="name" value="papermc" />
<option name="url" value="https://repo.papermc.io/repository/maven-public/" />
</remote-repository>
</component>
</project>

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

@@ -0,0 +1,21 @@
<?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>
<writeAnnotations>
<writeAnnotation name="lombok.Getter" />
</writeAnnotations>
</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>

35
README.md Normal file
View File

@@ -0,0 +1,35 @@
<p align="center">
<img src="https://i.imgur.com/0pSf6jl.png" width="300">
</p>
---
# Links
* [Spigot](https://www.spigotmc.org/resources/t2codelib.96388/)
* [Discord](http://dc.T2Code.net)
---
T2CodeLib is a library for the plugins of T2Code.
Main library file to centralize the main functions for multiple plugins, allowing better maintenance capabilities and reducing the overall size of the plugins.
Maven:
```
<repositories>
<repository>
<id>T2Code</id>
<url>https://repo.t2code.net/repository/T2Code/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>VERSION</version>
</dependency>
</dependencies>
```
---
<img src="https://i.imgur.com/HoZSt7c.png" width="600">
<img src="https://bstats.org/signatures/bukkit/T2CodeLib.svg" width="600">

110
pom.xml
View File

@@ -6,13 +6,16 @@
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>13.3</version>
<version>16.7_dev-19</version>
<!--version>VERSION_snapshot-0</version-->
<!--version>VERSION_beta-0</version-->
<!--version>VERSION_dev-0</version-->
<packaging>jar</packaging>
<name>T2CodeLib</name>
<properties>
<java.version>1.8</java.version>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -61,68 +64,108 @@
<repositories>
<repository>
<id>sonatype-oss-snapshots1</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<!-- Mojang / Spigot -->
<!-- Spigot -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<!-- repo.t2code / T2Code -->
<!-- Mojang authlib -->
<repository>
<id>Builders-Paradise</id>
<url>https://repo.t2code.net/repository/Builders-Paradise/</url>
<id>minecraft-repo</id>
<url>https://libraries.minecraft.net/</url>
</repository>
<!-- Bungee -->
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<!-- repo.t2code / T2Code -->
<repository>
<id>T2Code</id>
<url>https://repo.t2code.net/repository/T2Code/</url>
</repository>
<!-- Vault-->
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<!-- placeholderapi -->
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<!-- votingplugin -->
<repository>
<id>BenCodez Repo</id>
<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>
<dependencies>
<!-- Mojang / Spigot-->
<!-- Spigot-->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- repo.t2code / T2Code -->
<!-- Mojang authlib -->
<dependency>
<groupId>net.t2code</groupId>
<artifactId>bungee</artifactId>
<version>1642</version>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.21</version>
<scope>provided</scope>
</dependency>
<!-- Bungee -->
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<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.21-R0.1-SNAPSHOT</version>
<type>javadoc</type>
<scope>provided</scope>
</dependency>
<!-- Velocity -->
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- repo.t2code / T2Code -->
<dependency>
<groupId>net.t2code</groupId>
<artifactId>LuckyBox-API</artifactId>
<version>4.2.7</version>
<scope>provided</scope>
</dependency>
<!-- Vault-->
<dependency>
<groupId>com.github.MilkBowl</groupId>
@@ -130,54 +173,73 @@
<version>1.7</version>
<scope>provided</scope>
</dependency>
<!-- placeholderapi -->
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.1</version>
<version>2.11.3</version>
<scope>provided</scope>
</dependency>
<!-- votingplugin -->
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>votingplugin</artifactId>
<version>LATEST</version>
<version>6.12.1</version>
<scope>provided</scope>
</dependency>
<!--Kyori MiniMessage-->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.11.0</version>
<version>4.18.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.1.2</version>
<version>4.3.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bungeecord</artifactId>
<version>4.3.3</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220924</version>
<scope>provided</scope>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3.1</version>
<scope>provided</scope>
<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

@@ -0,0 +1,99 @@
package net.t2code.t2codelib.BUNGEE.api.bungeePlayers;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
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.BUNGEE.system.T2CodeBMain;
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayersEnum;
import java.io.*;
import java.util.logging.Logger;
public class T2CBbungeePlayers implements Listener {
@EventHandler
public void onJoin(PostLoginEvent e) {
sendToSpigotPlayer(e.getPlayer().getName(), T2CbungeePlayersEnum.JOIN, "");
}
@EventHandler
public void onDisconnect(PlayerDisconnectEvent e) {
sendToSpigotPlayer(e.getPlayer().getName(), T2CbungeePlayersEnum.QUIT, "");
}
public static void sendToSpigotPlayer(String name, T2CbungeePlayersEnum value, String uuid) {
switch (value) {
case JOIN:
case QUIT:
sendToSpigotPlayerExecute(name, value, uuid);
break;
case GIVEALL:
StringBuilder input = new StringBuilder();
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
input.append(player.getName()).append(";");
}
sendToSpigotPlayerExecute(input.toString(), T2CbungeePlayersEnum.GIVEALL, uuid);
break;
}
}
private static void sendToSpigotPlayerExecute(String name, T2CbungeePlayersEnum value, String uuid) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream);
try {
output.writeUTF(value.name());
output.writeUTF(name);
output.writeUTF(uuid);
} catch (IOException e) {
Logger.getLogger(e.getMessage());
}
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received channel: t2c:bonlp");
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received subChannel: " + value.name());
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received input: " + name);
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received input2/uuid: " + uuid);
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
server.sendData("t2c:bonlp", stream.toByteArray());
});
}
public static void sendToSpigotDeleteAll() {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream);
try {
output.writeUTF(T2CbungeePlayersEnum.CLEAR.name());
output.writeUTF("");
output.writeUTF("");
} catch (IOException e) {
Logger.getLogger(e.getMessage());
}
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
server.sendData("t2c:bonlp", stream.toByteArray());
});
}
@EventHandler
public void onPluginMessage(PluginMessageEvent event) {
if (event.getTag().equalsIgnoreCase("t2c:bonlp")) {
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
event.setCancelled(true);
try {
T2CbungeePlayersEnum subChannel = T2CbungeePlayersEnum.valueOf(stream.readUTF());
String input = stream.readUTF();
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received channel: " + event.getTag());
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received subChannel: " + subChannel.name());
T2CBsend.debug(T2CodeBMain.getPlugin(), "PluginMessage received input/uuid: " + input);
sendToSpigotPlayer("", subChannel, input);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

View File

@@ -6,35 +6,58 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.ArrayList;
import java.util.HashMap;
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

@@ -0,0 +1,30 @@
package net.t2code.t2codelib.BUNGEE.api.messages;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
public class T2CBminiMessage {
private static final BungeeAudiences bungeeAudiences = T2CodeBMain.getAdventure();
public static void sendSenderMiniMessage(String msg, CommandSender sender) {
bungeeAudiences.sender(sender).sendMessage(replace(msg));
}
public static void sendConsoleMiniMessage(String msg) {
bungeeAudiences.console().sendMessage(replace(msg));
}
public static void sendPlayerMiniMessage(String msg, ProxiedPlayer player) {
bungeeAudiences.player(player).sendMessage(replace(msg));
}
protected static Component replace(String text) {
return MiniMessage.miniMessage().deserialize(T2Creplace.convertColorCode(text));
}
}

View File

@@ -5,16 +5,21 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.Title;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain;
import java.util.logging.Level;
public class T2CBsend {
public static void console(String msg) {
ProxyServer.getInstance().getConsole().sendMessage(msg);
if (T2CodeBMain.getMmIsLoad() && T2CodeBMain.getMmIsLoad()) {
T2CBminiMessage.sendConsoleMiniMessage(msg);
} else ProxyServer.getInstance().getConsole().sendMessage(msg);
}
public static void player(ProxiedPlayer player, String msg) {
player.sendMessage(msg);
if (T2CodeBMain.getMmIsLoad()&& T2CodeBMain.getMmIsLoad()) {
T2CBminiMessage.sendPlayerMiniMessage(msg, player);
} else player.sendMessage(msg);
}
public static void title(ProxiedPlayer player, Title msg) {
@@ -22,7 +27,9 @@ public class T2CBsend {
}
public static void sender(CommandSender sender, String msg) {
sender.sendMessage(msg);
if (T2CodeBMain.getMmIsLoad()&& T2CodeBMain.getMmIsLoad()) {
T2CBminiMessage.sendSenderMiniMessage(msg, sender);
} else sender.sendMessage(msg);
}
public static void debug(Plugin plugin, String msg) {
@@ -31,15 +38,15 @@ public class T2CBsend {
public static void debug(Plugin plugin, String msg, Integer stage) {
// if (!new File(Main.getPath(), "config.yml").exists()) return;
if (stage == null) {
//todo if (plugin.getConfig().getBoolean("Plugin.Debug")){
// ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg);
// }
return;
}
// todo if (plugin.getConfig().getInt("Plugin.Debug") >= stage) {
// ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg);
// }
// if (stage == null) {
// if (plugin.getConfig().getBoolean("Plugin.Debug")) {
// ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg);
// }
// return;
//}
//if (plugin.getConfig().getInt("Plugin.Debug") >= stage) {
// ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg);
//}
}
public static void debugmsg(Plugin plugin, String msg) {

View File

@@ -3,6 +3,7 @@ package net.t2code.t2codelib.BUNGEE.api.messages;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.t2codelib.BUNGEE.api.update.T2CBupdateAPI;
import net.t2code.t2codelib.T2CupdateWebData;
public class T2CBtemplate {
@@ -39,14 +40,14 @@ public class T2CBtemplate {
}
public static void sendInfo(CommandSender sender, Plugin plugin, String prefix, String spigot, String discord, String autor) {
String publicVersion = T2CBupdateAPI.bungeePluginVersins.get(plugin.getDescription().getName()).publicVersion;
T2CupdateWebData webData = T2CBupdateAPI.bungeePluginVersins.get(plugin.getDescription().getName()).webData;
String pluginVersion = plugin.getDescription().getVersion();
T2CBsend.sender(sender, prefix + "§4======= " + prefix + " §4=======");
T2CBsend.sender(sender, prefix + " §2Autor: §6" + autor);
if (publicVersion.equalsIgnoreCase(pluginVersion)) {
if (webData.getVersion().equalsIgnoreCase(pluginVersion)) {
T2CBsend.sender(sender, prefix + " §2Version: §6" + pluginVersion);
} else {
T2CBupdateAPI.sendUpdateMsg(prefix, spigot, discord, pluginVersion, publicVersion, sender);
T2CBupdateAPI.sendUpdateMsg(prefix, discord, webData, plugin, sender);
}
T2CBsend.sender(sender, prefix + " §2Spigot: §6" + spigot);
T2CBsend.sender(sender, prefix + " §2Discord: §6" + discord);

View File

@@ -1,10 +1,11 @@
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging;
package net.t2code.t2codelib.BUNGEE.api.pluginMessaging;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
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.Util;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
@@ -19,13 +20,20 @@ public class T2CplmsgBcmd implements Listener {
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

@@ -1,4 +1,4 @@
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.autoResponse;
package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.autoResponse;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;

View File

@@ -1,6 +1,6 @@
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.commandgui;
package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.commandgui;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
@@ -37,8 +37,7 @@ public class T2CapiCGUI implements Listener {
} catch (IOException e) {
Logger.getLogger(e.getMessage());
}
BungeeCord.getInstance().getServers().values().stream().forEach((server) -> {
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
server.sendData("t2c:cguiopl", stream.toByteArray());
});
}
@@ -52,7 +51,7 @@ public class T2CapiCGUI implements Listener {
} catch (IOException e) {
Logger.getLogger(e.getMessage());
}
BungeeCord.getInstance().getServers().values().stream().forEach((server) -> {
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
server.sendData("t2c:cguiopl", stream.toByteArray());
});
}

View File

@@ -1,12 +1,9 @@
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.opSecurity;
package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.opSecurity;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
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 java.io.*;
import java.util.logging.Logger;
@@ -41,7 +38,7 @@ public class T2CapiOpSecurity implements Listener {
} catch (IOException e) {
Logger.getLogger(e.getMessage());
}
BungeeCord.getInstance().getServers().values().stream().forEach((server) -> {
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
server.sendData("t2c:opsec", stream.toByteArray());
});
}

View File

@@ -4,110 +4,79 @@ import net.md_5.bungee.api.CommandSender;
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.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.UpdateType;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
public class T2CBupdateAPI {
public static HashMap<String, T2CBupdateObject> bungeePluginVersins = new HashMap<String, T2CBupdateObject>();
public static HashMap<String, T2CupdateObject> bungeePluginVersins = new HashMap<>();
public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Plugin plugin, CommandSender sender) {
String publicVersion = webData.getVersion();
String pluginVersion = plugin.getDescription().getVersion();
String value;
if (webData.isPreRelease()) {
value = UpdateType.PRERELEASE.text;
if (publicVersion.toLowerCase().contains("dev")) {
value = UpdateType.DEVELOPMENT.text;
}
if (publicVersion.toLowerCase().contains("beta")) {
value = UpdateType.BETA.text;
}
if (publicVersion.toLowerCase().contains("snapshot")) {
value = UpdateType.SNAPSHOT.text;
}
} else value = UpdateType.STABLE.text;
String h = "<br><dark_red>╔══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
String s1 = "<br><dark_red>║</dark_red> <gold>A new [value] version was found!</gold>".replace("[value]", value);
String s2 = "<br><dark_red>║</dark_red> <gold>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</gold> <green>" + webData.getVersion() + "</green>";
String s3 = "<br><dark_red>║</dark_red> <gold>You can download it here:</gold> <yellow>" + webData.getUpdateUrl() + "</yellow>";
String s4 = "<br><dark_red>║</dark_red> <gold>You can find more information on Discord:</gold> <yellow>" + discord + "</yellow>";
String f = "<br><dark_red>╚══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
String text = h + s1 + s2 + s3 + s4 + f;
if (sender == null) {
T2CBsend.console(text);
} else T2CBsend.sender(sender, text);
public static void sendUpdateMsg(String Prefix, String Spigot, String Discord, String foundVersion, String update_version) {
T2CBsend.console("§4=========== " + Prefix + " §4===========");
T2CBsend.console("§6A new version was found!");
T2CBsend.console("§6Your version: §c" + foundVersion + " §7- §6Current version: §a" + update_version);
T2CBsend.console("§6You can download it here: §e" + Spigot);
T2CBsend.console("§6You can find more information on Discord: §e" + Discord);
T2CBsend.console("§4=========== " + Prefix + " §4===========");
}
public static void sendUpdateMsg(String Prefix, String Spigot, String Discord, String foundVersion, String update_version, CommandSender sender) {
T2CBsend.sender(sender,"§4=========== " + Prefix + " §4===========");
T2CBsend.sender(sender,"§6A new version was found!");
T2CBsend.sender(sender,"§6Your version: §c" + foundVersion + " §7- §6Current version: §a" + update_version);
T2CBsend.sender(sender,"§6You can download it here: §e" + Spigot);
T2CBsend.sender(sender,"§6You can find more information on Discord: §e" + Discord);
T2CBsend.sender(sender,"§4=========== " + Prefix + " §4===========");
}
private static Boolean noUpdate = true;
private static String pluginVersion;
public static void onUpdateCheckTimer(Plugin plugin, String Prefix, String Spigot, String Discord, Integer SpigotID) {
public static void onUpdateCheckTimer(Plugin plugin, String prefix, String discord, Integer spigotID, String url) {
Integer finalInterval;
if (T2CBlibConfig.getUpdateTimer() < 1){
finalInterval = 1;
} else finalInterval = T2CBlibConfig.getUpdateTimer();
ProxyServer.getInstance().getScheduler().schedule(plugin, new Runnable() {
public void run() {
(new T2CBupdateAPI(plugin, SpigotID)).getVersion((update_version) -> {
if (T2CBlibConfig.getUpdateCheckFullDisable()) return;
(new T2CBupdateCheckerGit(plugin, spigotID)).getVersion((webData) -> {
pluginVersion = plugin.getDescription().getVersion();
T2CBupdateObject update = new T2CBupdateObject(
T2CupdateObject update = new T2CupdateObject(
plugin.getDescription().getName(),
pluginVersion,
update_version
plugin.getDescription().getVersion(),
webData,
false,
!plugin.getDescription().getVersion().equals(webData.getVersion()),
true
);
bungeePluginVersins.put(plugin.getDescription().getName(), update);
if (!pluginVersion.replace("_Bungee", "").equalsIgnoreCase(update_version)) {
sendUpdateMsg(Prefix, Spigot, Discord, pluginVersion, update_version);
if (!pluginVersion.replace("_Bungee", "").equalsIgnoreCase(webData.getVersion())) {
sendUpdateMsg(prefix, discord, webData, plugin, null);
noUpdate = true;
} else {
if (noUpdate) {
T2CBsend.console(Prefix + " §2No update found.");
T2CBsend.console(prefix + " §2No update found.");
noUpdate = false;
}
}
},Prefix, pluginVersion);
}, pluginVersion, spigotID, url);
}
}, 0, 20 * 60 * 60L, TimeUnit.SECONDS);
}
private Plugin plugin;
private int resourceId;
public T2CBupdateAPI(Plugin plugin, int resourceId) {
this.plugin = plugin;
this.resourceId = resourceId;
}
public void getVersion(Consumer<String> consumer, String Prefix, String pluginVersion) {
ProxyServer.getInstance().getScheduler().runAsync(this.plugin, () -> {
try {
InputStream inputStream = (new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId)).openStream();
try {
Scanner scanner = new Scanner(inputStream);
try {
if (scanner.hasNext()) {
consumer.accept(scanner.next());
}
} catch (Throwable var8) {
try {
scanner.close();
} catch (Throwable var7) {
var8.addSuppressed(var7);
}
throw var8;
}
scanner.close();
} catch (Throwable var9) {
if (inputStream != null) {
try {
inputStream.close();
} catch (Throwable var6) {
var9.addSuppressed(var6);
}
}
throw var9;
}
if (inputStream != null) {
inputStream.close();
}
} catch (IOException var10) {
T2CBupdateObject update = new T2CBupdateObject(
plugin.getDescription().getName(),
pluginVersion,
"§4No public version found!"
);
bungeePluginVersins.put(plugin.getDescription().getName(), update);
this.plugin.getLogger().severe(Prefix + "§4 Cannot look for updates: " + var10.getMessage());
}
});
}, 0, finalInterval * 60 * 20L, TimeUnit.SECONDS);
}
}

View File

@@ -0,0 +1,99 @@
package net.t2code.t2codelib.BUNGEE.api.update;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig;
import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.function.Consumer;
public class T2CBupdateCheckerGit {
private Plugin plugin;
private int resourceId;
public T2CBupdateCheckerGit(Plugin plugin, int resourceId) {
this.plugin = plugin;
this.resourceId = resourceId;
}
public void getVersion(Consumer<T2CupdateWebData> consumer, String pluginVersion, Integer spigotID, String gitKey) {
if (T2CBlibConfig.getUpdateCheckFullDisable()) return;
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
if (!T2CBlibConfig.getSeePreReleaseUpdates()) {
RepoURL = RepoURL + "&pre-release=false";
}
String finalRepoURL = RepoURL;
ProxyServer.getInstance().getScheduler().runAsync(this.plugin, () -> {
try {
URL url = new URL(finalRepoURL);
URLConnection yc = url.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
String data = "";
while ((inputLine = in.readLine()) != null)
data = inputLine;
in.close();
data = data.substring(1, data.length() - 1);
if (data.isEmpty()) {
consumer.accept(null);
return;
}
JSONObject obj = new JSONObject(data);
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 publishedAt = outputFormat.format(parsedDate);
JSONArray downloadArray = obj.getJSONArray("assets");
String gitURL = updateUrl;
String downloadURL;
if (downloadArray.isEmpty()) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
} else {
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
}
if (!preRelease) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
updateUrl = "https://www.spigotmc.org/resources/" + spigotID;
}
T2CupdateWebData webData = new T2CupdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease);
consumer.accept(webData);
} catch (Exception var10) {
Boolean load = false;
if (T2CBupdateAPI.bungeePluginVersins.containsKey(plugin.getDescription().getName())) {
load = T2CBupdateAPI.bungeePluginVersins.get(plugin.getDescription().getName()).load;
}
T2CupdateObject update = new T2CupdateObject(
plugin.getDescription().getName(),
pluginVersion,
null,
load,
false,
true
);
T2CBupdateAPI.bungeePluginVersins.put(plugin.getDescription().getName(), update);
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());
}
});
}
}

View File

@@ -1,12 +0,0 @@
package net.t2code.t2codelib.BUNGEE.api.update;
public class T2CBupdateObject {
public String pluginName;
public String pluginVersion;
public String publicVersion;
public T2CBupdateObject(String pluginName, String pluginVersion, String publicVersion){
this.pluginName = pluginName;
this.pluginVersion = pluginVersion;
this.publicVersion = publicVersion;
}
}

View File

@@ -5,18 +5,19 @@ import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
import net.t2code.t2codelib.BUNGEE.api.update.T2CBupdateAPI;
import net.t2code.t2codelib.BUNGEE.system.bstats.T2CBmetrics;
import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig;
import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.T2CplmsgBcmd;
import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.autoResponse.T2CapiAutoResponse;
import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.commandgui.T2CapiCGUI;
import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.opSecurity.T2CapiOpSecurity;
import net.t2code.t2codelib.BUNGEE.api.bungeePlayers.T2CBbungeePlayers;
import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.T2CplmsgBcmd;
import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.autoResponse.T2CapiAutoResponse;
import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.commandgui.T2CapiCGUI;
import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.opSecurity.T2CapiOpSecurity;
import java.io.IOException;
public class T2CBload {
public static void onLoad(Plugin plugin, String prefix, String autor, String version, String spigot, String discord, Integer spigotID, Integer bstatsID) {
public static void onLoad(Plugin plugin, String prefix, String author, String version, String spigot, String discord, Integer spigotID, Integer bstatsID, String url) {
long long_ = System.currentTimeMillis();
T2CBsend.console(prefix + "§4============================= " + prefix + " §4=============================");
T2CBsend.console(prefix + " §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
T2CBsend.console(prefix + " §2Author: §6" + String.valueOf(author).replace("[", "").replace("]", ""));
T2CBsend.console(prefix + " §2Version: §6" + version);
T2CBsend.console(prefix + " §2Spigot: §6" + spigot);
T2CBsend.console(prefix + " §2Discord: §6" + discord);
@@ -33,14 +34,18 @@ public class T2CBload {
throw new RuntimeException(e);
}
T2CBupdateAPI.onUpdateCheckTimer(plugin, prefix, spigot, discord, spigotID);
T2CBupdateAPI.onUpdateCheckTimer(plugin, prefix, discord, spigotID, url);
//API
plugin.getProxy().registerChannel("t2c:bcmd");
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CplmsgBcmd());
plugin.getProxy().registerChannel("t2c:bonlp");
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CBbungeePlayers());
T2CBbungeePlayers.sendToSpigotDeleteAll();
if (T2CBlibConfig.getApiCommandGUIEnable()) {
plugin.getProxy().registerChannel("t2c:cgui");
plugin.getProxy().registerChannel("t2c:cguiopl");
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiCGUI());
T2CapiCGUI.sendToSpigotDeleteAll();
}
@@ -48,7 +53,7 @@ public class T2CBload {
plugin.getProxy().registerChannel("t2c:aresp");
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiAutoResponse());
}
if (T2CBlibConfig.getApiAutoResponse()) {
if (T2CBlibConfig.getApiOpSecurity()) {
plugin.getProxy().registerChannel("t2c:t2c:opsec");
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiOpSecurity());
}

View File

@@ -1,37 +1,58 @@
package net.t2code.t2codelib.BUNGEE.system;
import lombok.Getter;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
import net.t2code.t2codelib.BUNGEE.api.bungeePlayers.T2CBbungeePlayers;
import net.t2code.t2codelib.Util;
public class T2CodeBMain extends Plugin {
@Getter
private static Plugin plugin;
public static Plugin getPlugin() {
return plugin;
}
private static String version;
private static String orgVersion;
private static String autor;
@Getter
private static Boolean mmIsLoad = true;
private static BungeeAudiences adventure;
public static BungeeAudiences getAdventure() {
if(adventure == null) {
throw new IllegalStateException("Cannot retrieve audience provider while plugin is not enabled");
}
return adventure;
}
@Override
public void onEnable() {
// Plugin startup logic
plugin = this;
orgVersion = plugin.getDescription().getVersion();
autor = plugin.getDescription().getAuthor();
T2CBload.onLoad(plugin, Util.getPrefix(), autor, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID());
String[] fv = orgVersion.split("_");
plugin.getDescription().setVersion(fv[0]);
String orgVersion = plugin.getDescription().getVersion();
String author = plugin.getDescription().getAuthor();
try {
adventure = BungeeAudiences.create(this);
T2CBsend.info(this,"Adventure load!");
} catch (Exception e){
T2CBsend.error(this,"Adventure can not be load!");
mmIsLoad = false;
}
T2CBload.onLoad(plugin, Util.getPrefix(), author, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit());
version = plugin.getDescription().getVersion();
}
@Override
public void onDisable() {
// Plugin shutdown logic
T2CBbungeePlayers.sendToSpigotDeleteAll();
if (mmIsLoad){
if(adventure != null) {
adventure.close();
adventure = null;
}
}
T2CBsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4=============================");
T2CBsend.console(Util.getPrefix() + " §2Autor: §6" + String.valueOf(plugin.getDescription().getAuthor()).replace("[", "").replace("]", ""));
T2CBsend.console(Util.getPrefix() + " §2Version: §6" + version);

View File

@@ -1,5 +1,6 @@
package net.t2code.t2codelib.BUNGEE.system.config;
import lombok.Getter;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
@@ -21,6 +22,10 @@ public class T2CBlibConfig {
config.createNewFile();
}
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config);
T2CBconfig.set("UpdateCheck.TimerInMin", 60, configuration);
T2CBconfig.set("UpdateCheck.SeePreReleaseUpdates", true, configuration);
T2CBconfig.set("Plugin.UpdateCheck.AllPlugins.FullDisable", false, configuration);
T2CBconfig.set("API.CommandGUI.Enable", false, configuration);
T2CBconfig.set("API.AutoResponse.Enable", false, configuration);
T2CBconfig.set("API.OPSecurity.Enable", false, configuration);
@@ -33,24 +38,26 @@ public class T2CBlibConfig {
File config = new File(T2CodeBMain.getPlugin().getDataFolder(), "config.yml");
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config);
updateTimer = configuration.getInt("UpdateCheck.TimerInMin");
seePreReleaseUpdates = configuration.getBoolean("UpdateCheck.SeePreReleaseUpdates");
updateCheckFullDisable = configuration.getBoolean("Plugin.UpdateCheck.AllPlugins.FullDisable");
apiCommandGUIEnable = configuration.getBoolean("API.CommandGUI.Enable");
apiAutoResponse = configuration.getBoolean("API.AutoResponse.Enable");
apiOpSecurity = configuration.getBoolean("API.OPSecurity.Enable");
}
@Getter
private static Integer updateTimer;
@Getter
private static Boolean seePreReleaseUpdates;
@Getter
private static Boolean updateCheckFullDisable;
@Getter
private static Boolean apiCommandGUIEnable;
@Getter
private static Boolean apiAutoResponse;
@Getter
private static Boolean apiOpSecurity;
public static Boolean getApiCommandGUIEnable() {
return apiCommandGUIEnable;
}
public static Boolean getApiAutoResponse() {
return apiAutoResponse;
}
public static Boolean getApiOpSecurity() {
return apiOpSecurity;
}
}

View File

@@ -0,0 +1,83 @@
package net.t2code.t2codelib.SPIGOT.api.bungeePlayers;
import lombok.Getter;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class T2CbungeePlayers implements PluginMessageListener {
@Getter
private static List<String> bungeePlayers = new ArrayList<>();
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(message));
T2Csend.debug(T2CodeLibMain.getPlugin(), "stream: " + stream.toString());
try {
T2CbungeePlayersEnum subChannel = T2CbungeePlayersEnum.valueOf(stream.readUTF());
String input = stream.readUTF();
String uuid = stream.readUTF();
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage received channel: " + channel);
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage received subChannel: " + subChannel.name());
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage received input: " + input);
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage received input2/uuid: " + uuid);
switch (subChannel) {
case JOIN:
bungeePlayers.add(input);
break;
case QUIT:
bungeePlayers.remove(input);
break;
case GIVEALL:
if (!Util.getServerUUID().toString().equals(uuid)) {
return;
}
bungeePlayers.clear();
String[] in = input.split(";");
bungeePlayers.addAll(Arrays.asList(in));
break;
case CLEAR:
bungeePlayers.clear();
break;
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static void callAllBungeePlayers() {
if (Bukkit.getOnlinePlayers().isEmpty()) {
Bukkit.getScheduler().runTaskLaterAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
@Override
public void run() {
callAllBungeePlayers();
}
}, 20L);
return;
}
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream);
try {
output.writeUTF(T2CbungeePlayersEnum.GIVEALL.name());
output.writeUTF(Util.getServerUUID().toString());
} catch (IOException e) {
e.printStackTrace();
}
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendPluginMessage(T2CodeLibMain.getPlugin(), "t2c:bonlp", stream.toByteArray());
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage received channel: t2c:bonlp");
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage send subChannel: " + T2CbungeePlayersEnum.GIVEALL.name());
T2Csend.debug(T2CodeLibMain.getPlugin(), "PluginMessage send output/uuid: " + Util.getServerUUID().toString());
return;
}
}
}

View File

@@ -0,0 +1,8 @@
package net.t2code.t2codelib.SPIGOT.api.bungeePlayers;
public enum T2CbungeePlayersEnum {
JOIN,
QUIT,
GIVEALL,
CLEAR
}

View File

@@ -1,25 +1,67 @@
package net.t2code.t2codelib.SPIGOT.api.commands;
import net.t2code.t2codelib.SPIGOT.system.BCommandSenderReciver;
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 java.util.Map;
public class T2Ccmd {
public static void console(String cmd) {
if (cmd.contains("!onBungee")){
BCommandSenderReciver.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")) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true);
} else console(cmd.replace("!asConsole", ""));
} else {
if (cmd.contains("!onBungee")) {
BCommandSenderReciver.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,37 @@
package net.t2code.t2codelib.SPIGOT.api.debug;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import java.util.UUID;
public class T2Cdebug {
public static void debug(Plugin plugin, String msg) {
debug(plugin, msg, null);
}
public static void debug(Plugin plugin, String msg, Integer stage) {
// if (!new File(Main.getPath(), "config.yml").exists()) return;
if (stage == null) {
if (plugin.getConfig().getBoolean("Plugin.Debug") || plugin.getConfig().getBoolean("plugin.debug") || plugin.getConfig().getBoolean("Debug") || plugin.getConfig().getBoolean("debug")){
T2Csend.info(plugin, "");
Bukkit.getConsoleSender().sendMessage(plugin.getDescription().getPrefix() + " §5DEBUG: §6" + msg);
}
return;
}
if (plugin.getConfig().getInt("Plugin.Debug") >= stage || plugin.getConfig().getInt("plugin.debug") >= stage || plugin.getConfig().getInt("Debug") >= stage || plugin.getConfig().getInt("debug") >= stage) {
T2Csend.info(plugin, "");
Bukkit.getConsoleSender().sendMessage(plugin.getDescription().getPrefix() + " §5DEBUG: §6" + msg);
}
}
public static void debugmsg(Plugin plugin, String msg) {
T2Csend.warning(plugin, "");
Bukkit.getConsoleSender().sendMessage("§e[" + plugin.getDescription().getPrefix() + "] §5DEBUG-MSG: §6" + msg);
}
public static String debugCode(){
return UUID.randomUUID().toString().substring(0, 7);
}
}

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

@@ -55,15 +55,8 @@ public class T2Ceco {
}
public static boolean itemAdd(Player player, ItemStack itemStack, int amount) {
boolean empty = false;
for (int i = 0; i < player.getInventory().getSize() - 5; i++) {
if (player.getInventory().getItem(i) == null) {
empty = true;
break;
}
}
for (int i = 0; i < amount; i++) {
if (empty) {
if (player.getInventory().firstEmpty() != -1) {
player.getInventory().addItem(itemStack);
} else {
player.getLocation().getWorld().dropItem(player.getLocation(), itemStack);

View File

@@ -0,0 +1,128 @@
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;
public class T2CitemBuilder {
public static final boolean getLegacy = T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12();
public static void fillItem(boolean enable, String item, Integer lines, Inventory inventory) {
if (!enable) return;
fillItem(item, lines, inventory);
}
public static void fillItem(String item, Integer lines, Inventory inventory) {
try {
ItemStack glass;
if (getLegacy) {
glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.parseShort(item));
} else glass = new ItemStack(Material.valueOf(item.toUpperCase().replace(".", "_")));
ItemMeta itemMetaglass = glass.getItemMeta();
assert itemMetaglass != null;
itemMetaglass.setDisplayName(" ");
glass.setItemMeta(itemMetaglass);
glass.setAmount(1);
for (int i = 0; i < 9 * lines; i++) {
inventory.setItem(i, glass);
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static ItemStack itemStack(Material material, Integer amount, String displayName, List<String> lore) {
ItemStack itemStack = new ItemStack(material);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(displayName);
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
itemStack.setAmount(amount);
return itemStack;
}
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();
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
profile.getProperties().put("textures", new Property("textures", base64Value));
Field profileField;
try {
profileField = itemMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(itemMeta, profile);
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
e.printStackTrace();
}
itemStack.setItemMeta(itemMeta);
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

@@ -18,16 +18,16 @@ public class T2ChoverModule {
t2cmodule(msg, player);
return;
}
T2CminiMessage.miniMessage(msg, player);
T2CminiMessage.sendPlayerMiniMessage(msg, player);
}
public static void moduleSender(String msg, CommandSender sender) {
T2CminiMessage.miniMessage(msg, sender);
T2CminiMessage.sendSenderMiniMessage(msg, sender);
}
public static void moduleConsole(String msg) {
if (T2CodeLibMain.getNmIsLoad()) {
T2CminiMessage.sendMiniMessage(msg);
if (T2CodeLibMain.getMmIsLoad()) {
T2CminiMessage.sendConsoleMiniMessage(msg);
return;
}
Bukkit.getConsoleSender().sendMessage(msg);

View File

@@ -1,24 +1,30 @@
package net.t2code.t2codelib.SPIGOT.api.messages;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class T2CminiMessage {
private static final BukkitAudiences bukkitAudiences = T2CodeLibMain.getPlugin().getAdventure();
public static void miniMessage(String msg, CommandSender sender) {
T2CodeLibMain.adventure().sender(sender).sendMessage(replace(msg));
public static void sendSenderMiniMessage(String msg, CommandSender sender) {
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 sendMiniMessage(String msg) {
T2CodeLibMain.adventure().console().sendMessage(replace(msg));
public static void sendConsoleMiniMessage(String msg) {
bukkitAudiences.console().sendMessage(replace(msg));
}
public static void miniMessage(String msg, Player player) {
T2CodeLibMain.adventure().player(player).sendMessage(replace(msg));
public static void sendPlayerMiniMessage(String msg, Player player) {
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,72 @@ 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) {
if (object instanceof String) {
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) || (object instanceof ArrayList)) {
List<String> in = (List<String>) object;
List<String> output = new ArrayList<>();
for (String input : in) {
output.add(replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n"));
}
object = output;
}
return object;
}
public static Object replaceObject(String prefix, Player player, Object object) {
if (object instanceof String) {
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) {
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;
}
return object;
}
public static List<String> replace(String prefix, List<String> Text) {
@@ -35,7 +98,7 @@ public class T2Creplace {
}
public static List<String> replace(String prefix, Player player, List<String> Text) {
List<String> output = new ArrayList();
List<String> output = new ArrayList<>();
if (player == null) {
return Collections.singletonList("player is null");
}
@@ -43,16 +106,24 @@ 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;
}
public static List<String> replacePrice(String prefix, List<String> Text, String price) {
List<String> rp = new ArrayList();
List<String> rp = new ArrayList<>();
for (String s : Text) {
rp.add(replaceLegacyColor(s).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
@@ -69,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();
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;
}
@@ -101,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) {
@@ -140,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

@@ -1,19 +1,17 @@
package net.t2code.t2codelib.SPIGOT.api.messages;
import org.bukkit.Bukkit;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import org.bukkit.command.CommandSender;
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);
@@ -24,6 +22,33 @@ public class T2Csend {
T2ChoverModule.modulePlayer(msg, player);
}
public static void sender(CommandSender sender, String msg) {
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleSender(msg, sender);
}
public static void console(Object object) {
for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) continue;
T2ChoverModule.moduleConsole(msg);
}
}
public static void player(Player player, Object object) {
for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) continue;
T2ChoverModule.modulePlayer(msg, player);
}
}
public static void sender(CommandSender sender, Object object) {
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) {
player.sendTitle(title, subtitle);
}
@@ -32,29 +57,17 @@ public class T2Csend {
player.sendTitle(title, subtitle, fadeIn, stay, fadeOut);
}
public static void sender(CommandSender sender, String msg) {
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleSender(msg, sender);
}
public static void debug(Plugin plugin, String msg) {
debug(plugin, msg, null);
}
public static void debug(Plugin plugin, String msg, Integer stage) {
// if (!new File(Main.getPath(), "config.yml").exists()) return;
if (stage == null) {
if (plugin.getConfig().getBoolean("Plugin.Debug"))
Bukkit.getConsoleSender().sendMessage(plugin.getDescription().getPrefix() + " §5DEBUG: §6" + msg);
return;
}
if (plugin.getConfig().getInt("Plugin.Debug") >= stage)
Bukkit.getConsoleSender().sendMessage(plugin.getDescription().getPrefix() + " §5DEBUG: §6" + msg);
T2Cdebug.debug(plugin, msg, stage);
}
public static void debugmsg(Plugin plugin, String msg) {
warning(plugin,"");
Bukkit.getConsoleSender().sendMessage("§e[" + plugin.getDescription().getPrefix() + "] §5DEBUG-MSG: §6" + msg);
T2Cdebug.debugmsg(plugin, msg);
}
public static void info(Plugin plugin, String msg) {
@@ -68,4 +81,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

@@ -1,22 +1,25 @@
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 org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class T2Ctemplate {
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord) {
return onLoadHeader(prefix, autor, version, spigot, discord, null, null);
public static Long onLoadHeader(String prefix, List<String> author, String version, String spigot, String discord) {
return onLoadHeader(prefix, author, version, spigot, discord, null, null);
}
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium) {
return onLoadHeader(prefix, autor, version, spigot, discord, isPremium, null);
public static Long onLoadHeader(String prefix, List<String> author, String version, String spigot, String discord, Boolean isPremium) {
return onLoadHeader(prefix, author, version, spigot, discord, isPremium, null);
}
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) {
public static Long onLoadHeader(String prefix, List<String> author, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) {
Long long_ = System.currentTimeMillis();
T2Csend.console(prefix + " <dark_red> _______ </dark_red><gray>___ </gray><dark_red>_____ </dark_red>");
T2Csend.console(prefix + " <dark_red> |__ __|</dark_red><gray>__ \\ </gray><dark_red>/ ____|</dark_red>");
@@ -24,31 +27,33 @@ public class T2Ctemplate {
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray> / /</gray><dark_red>| | </dark_red>");
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray>/ /_</gray><dark_red>| |____ </dark_red>");
T2Csend.console(prefix + " <dark_red> |_| </dark_red><gray>|____|</gray><dark_red>\\_____|</dark_red>");
T2Csend.console(prefix + " §4 §e------------------");
T2Csend.console(prefix + " §4 §e| §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
T2Csend.console(prefix + " §4 §e| §2Version: §6" + version);
T2Csend.console(prefix + " §4 §e| §2Spigot: §6" + spigot);
T2Csend.console(prefix + " §4 §e| §2Discord: §6" + discord);
T2Csend.console(prefix + " §4 §e╔══════════════════════════");
T2Csend.console(prefix + " §4 §e §2Author: §6" + String.valueOf(author).replace("[", "").replace("]", ""));
T2Csend.console(prefix + " §4 §e §2Version: §6" + version);
T2Csend.console(prefix + " §4 §e §2Spigot: §6" + spigot);
T2Csend.console(prefix + " §4 §e §2Discord: §6" + discord);
if (isPremium != null) {
if (isPremium) {
T2Csend.console(prefix + " §4 §e| §6Premium: §2true");
} else T2Csend.console(prefix + " §4 §e| §6Premium: §4false");
T2Csend.console(prefix + " §4 §e §6Premium: §2true");
} else T2Csend.console(prefix + " §4 §e §6Premium: §4false");
if (isVerify != null) {
if (isVerify) {
T2Csend.console(prefix + " §4 §e| §6Verify: §2true");
} else T2Csend.console(prefix + " §4 §e| §6Verify: §4false");
} else T2Csend.console(prefix + " §4 §e| §6Verify: §4false");
T2Csend.console(prefix + " §4 §e §6Verify: §2true");
} else T2Csend.console(prefix + " §4 §e §6Verify: §4false");
} else T2Csend.console(prefix + " §4 §e §6Verify: §4false");
}
T2Csend.console(prefix + " §4 §e-------------------");
T2Csend.console(prefix + " §4 §e╚══════════════════════════");
if (version.toLowerCase().contains("dev") || version.toLowerCase().contains("snapshot") || version.toLowerCase().contains("beta")) {
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!");
T2Csend.console(prefix + " §4 §e-------------------");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
onLoadSeparateStroke(prefix);
if (!SelectLibConfig.getT2cTestDevelopment()) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
@@ -65,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_) {
@@ -75,42 +79,88 @@ public class T2Ctemplate {
T2Csend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
public static void onDisable(String prefix, List<String> autor, String version, String spigot, String discord) {
/**
* @param prefix
* @param author
* @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> author, 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║ §2Authors: §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()).publicVersion;
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;
}
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 stLinkPlayer = "<dark_red>|</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> "
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 stAuthor = "<dark_red>║</dark_red> <yellow>Author(s):</yellow> <gold>[author]</gold>".replace("[author]", plugin.getDescription().getAuthors().toString());
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 stLink = getString(spigotID, discord, player);
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.isEmpty() ? "" : "<br><dark_red>║</dark_red> " + text;
T2Csend.sender(sender, "<br><dark_red>╔════════════════════════════════</dark_red>"
+ "<br>" + stPlugin
+ "<br>" + stVersion
+ stMSG
+ "<br>" + stAuthor
+ "<br>" + stUpdate
+ stNVersion
+ "<br>" + stLink
+ pr
+ "<br><dark_red>╚════════════════════════════════</dark_red>");
}
private static @NotNull String getString(int spigotID, String discord, boolean player) {
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>"
.replace("[dlink]", discord);
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 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 stMSG = text == null || text.equals("") ? "" : "<br><dark_red>|</dark_red> " + text + "<br>";
T2Csend.sender(sender, "<dark_red>---------------------</dark_red>"
+ "<br>" + stPlugin
+ stMSG
+ stVersion
+ "<br>" + stAutor
+ "<br>" + stNVersion
+ "<br>" + stStable
+ "<br>" + stLink
+ pr
+ "<br><dark_red>---------------------</dark_red>");
return stLink;
}
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, String text) {

View File

@@ -2,26 +2,34 @@ package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
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");
nms1_8_R1 = nms.contains("1_8_R1");
nms1_8_R2 = nms.contains("1_8_R2");
nms1_8_R3 = nms.contains("1_8_R3");
@@ -43,6 +51,10 @@ public class T2CmcVersion {
nms1_19_R1 = nms.contains("1_19_R1");
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");
}
private static String mcVersion;
@@ -60,6 +72,7 @@ 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 String nms;
private static boolean nms1_8_R1;
@@ -83,6 +96,10 @@ public class T2CmcVersion {
private static boolean nms1_19_R1;
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;
public static String getMcVersion() {
return mcVersion;
@@ -144,6 +161,10 @@ public class T2CmcVersion {
return mc1_20;
}
public static boolean isMc1_21() {
return mc1_21;
}
public static String getNms() {
return nms;
}
@@ -231,4 +252,74 @@ 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 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();
}
}

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,100 @@
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
import lombok.Getter;
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;
} else if (mc.contains("(MC: 1.8.3)")) {
t2CnmsEnum = T2CnmsEnum.v1_8_R2;
} 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;
} else if (mc.contains("(MC: 1.9)") || mc.contains("(MC: 1.9.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_9_R1;
} else if (mc.contains("(MC: 1.9.3)") || mc.contains("(MC: 1.9.4)")) {
t2CnmsEnum = T2CnmsEnum.v1_9_R2;
} else if (mc.contains("(MC: 1.10")) {
t2CnmsEnum = T2CnmsEnum.v1_10_R1;
} else if (mc.contains("(MC: 1.11")) {
t2CnmsEnum = T2CnmsEnum.v1_11_R1;
} else if (mc.contains("(MC: 1.12")) {
t2CnmsEnum = T2CnmsEnum.v1_12_R1;
} else if (mc.contains("(MC: 1.13)")) {
t2CnmsEnum = T2CnmsEnum.v1_13_R1;
} else if (mc.contains("(MC: 1.13.1)") || mc.contains("(MC: 1.13.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_13_R2;
} else if (mc.contains("(MC: 1.14")) {
t2CnmsEnum = T2CnmsEnum.v1_14_R1;
} else if (mc.contains("(MC: 1.15")) {
t2CnmsEnum = T2CnmsEnum.v1_15_R1;
} else if (mc.contains("(MC: 1.16)") || mc.contains("(MC: 1.16.1)")) {
t2CnmsEnum = T2CnmsEnum.v1_16_R1;
} else if (mc.contains("(MC: 1.16.2)") || mc.contains("(MC: 1.16.3)")) {
t2CnmsEnum = T2CnmsEnum.v1_16_R2;
} else if (mc.contains("(MC: 1.16.4)") || mc.contains("(MC: 1.16.5)")) {
t2CnmsEnum = T2CnmsEnum.v1_16_R3;
} else if (mc.contains("(MC: 1.17")) {
t2CnmsEnum = T2CnmsEnum.v1_17_R1;
} else if (mc.contains("(MC: 1.18)") || mc.contains("(MC: 1.18.1)")) {
t2CnmsEnum = T2CnmsEnum.v1_18_R1;
} else if (mc.contains("(MC: 1.18.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_18_R2;
} else if (mc.contains("(MC: 1.19)") || mc.contains("(MC: 1.19.1)") || mc.contains("(MC: 1.19.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_19_R1;
} else if (mc.contains("(MC: 1.19.3)")) {
t2CnmsEnum = T2CnmsEnum.v1_19_R2;
} else if (mc.contains("(MC: 1.19.4)")) {
t2CnmsEnum = T2CnmsEnum.v1_19_R3;
} else if (mc.contains("(MC: 1.20)") || mc.contains("(MC: 1.20.1)")) {
t2CnmsEnum = T2CnmsEnum.v1_20_R1;
} else if (mc.contains("(MC: 1.20.2)")) {
t2CnmsEnum = T2CnmsEnum.v1_20_R2;
} else if (mc.contains("(MC: 1.20.3)") || mc.contains("(MC: 1.20.4)")) {
t2CnmsEnum = T2CnmsEnum.v1_20_R3;
} else if (mc.contains("(MC: 1.20.6)")) {
t2CnmsEnum = T2CnmsEnum.v1_20_R4;
} else if (mc.contains("(MC: 1.21)")) {
t2CnmsEnum = T2CnmsEnum.v1_21_R1;
} else t2CnmsEnum = T2CnmsEnum.not_support;
}
//
// 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

@@ -5,7 +5,6 @@ import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -13,6 +12,7 @@ import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;
import java.util.UUID;
import java.util.stream.Collectors;
public class T2CnameHistory {
public static class NameLookup {
@@ -93,7 +93,7 @@ public class T2CnameHistory {
con.setReadTimeout(2000);
con.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String response = in.readLine();
String response = in.lines().collect(Collectors.joining());
in.close();
return response;
}

View File

@@ -3,6 +3,11 @@ package net.t2code.t2codelib.SPIGOT.api.update;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
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;
import org.bukkit.plugin.java.JavaPlugin;
@@ -14,7 +19,17 @@ public class T2CupdateAPI {
public static HashMap<String, T2CupdateObject> pluginVersions = new HashMap<>();
public static void join(Plugin plugin, String prefix, String perm, Player player, Integer spigotID, String discord) {
if (!SelectLibConfig.getUpdateCheckOnJoin()) {
if (pluginVersions.get(plugin.getName()) == null) {
Bukkit.getScheduler().runTaskLaterAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
@Override
public void run() {
join(plugin, prefix, perm, player, spigotID, discord);
}
}, 2 * 20L);
return;
}
if (!pluginVersions.get(plugin.getName()).updateCheckOnJoin) {
return;
}
if (!player.hasPermission(perm) && !player.isOp()) {
@@ -29,99 +44,149 @@ public class T2CupdateAPI {
}.runTaskLaterAsynchronously(plugin, 20L);
return;
}
String publicVersion = pluginVersions.get(plugin.getName()).publicVersion;
String pluginVersion = plugin.getDescription().getVersion();
if (pluginVersion.equals(publicVersion)) return;
T2CupdateWebData webData = pluginVersions.get(plugin.getName()).webData;
if (!pluginVersions.get(plugin.getName()).updateAvailable) return;
new BukkitRunnable() {
@Override
public void run() {
sendUpdateMsg(prefix, spigotID, discord, plugin, player);
sendUpdateMsg(prefix, webData, discord, plugin, player);
}
}.runTaskLaterAsynchronously(T2CodeLibMain.getPlugin(), 200L);
}
public static void sendUpdateMsg(String prefix, Integer spigotID, String discord, Plugin plugin, Player player) {
String publicVersion = pluginVersions.get(plugin.getName()).publicVersion;
public static void sendUpdateMsg(String prefix, T2CupdateWebData webData, String discord, Plugin plugin, Player player) {
String publicVersion = webData.getVersion();
String pluginVersion = plugin.getDescription().getVersion();
if (publicVersion.equals("§4No public version found!")) {
if (!pluginVersions.get(plugin.getName()).updateAvailable) {
return;
}
String st = "[prefix]<br>" +
"<click:open_url:'[link]'><hover:show_text:'<gold>You can download it here: <yellow>[link]</yellow></gold>'>[prefix] <gold>A new</gold> [value]<gold>version was found!</gold></hover></click><br>" +
"<click:open_url:'[link]'><hover:show_text:'<gold>You can download it here: <yellow>[link]</yellow></gold>'>[prefix] <red>[plv]</red> <gray>-></gray> <green>[puv]</green></hover></click><br>" +
"<click:open_url:'[dc]'><hover:show_text:'<yellow>[dc]</yellow>'>[prefix] <gold>You can find more information on Discord.</gold></hover></click><br>" +
"<click:open_url:'[link]'><hover:show_text:'<color:#6e90ff>You can download it here: <yellow>[link]</yellow></color>'>[prefix] <color:#6e90ff>A new</color> [value] <color:#6e90ff>version was" +
" found!</color></hover></click><br>" +
"<click:open_url:'[link]'><hover:show_text:'<color:#6e90ff>You can download it here: <yellow>[link]</yellow></color>'>[prefix] <red>[plv]</red> <gray>-></gray> " +
"<green>[puv]</green></hover></click><br>" +
"<click:open_url:'[dc]'><hover:show_text:'<yellow>[dc]</yellow>'>[prefix] <color:#6e90ff>You can find more information on Discord.</color></hover></click><br>" +
"[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 = "";
if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) {
String updateStatusVersion;
if (webData.isPreRelease()) {
//todo if (!SelectLibConfig.getSeePreReleaseUpdates()) return;
updateStatusVersion = UpdateType.PRERELEASE.text;
if (publicVersion.toLowerCase().contains("dev")) {
value = "<dark_red>DEV </dark_red>";
updateStatusVersion = UpdateType.DEVELOPMENT.text;
}
if (publicVersion.toLowerCase().contains("beta")) {
value = "<green>BETA </green>";
updateStatusVersion = UpdateType.BETA.text;
}
if (publicVersion.toLowerCase().contains("snapshot")) {
value = "<yellow>SNAPSHOT </yellow>";
updateStatusVersion = UpdateType.SNAPSHOT.text;
}
}
T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", value).replace("[link]", "https://www.spigotmc.org/resources/" + spigotID)
} else updateStatusVersion = UpdateType.STABLE.text;
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, Integer spigot, String discord, Plugin plugin) {
String publicVersion = pluginVersions.get(plugin.getName()).publicVersion;
public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Plugin plugin) {
String publicVersion = webData.getVersion();
String pluginVersion = plugin.getDescription().getVersion();
String h = "§4=========== " + prefix + " §4===========";
String s1 = "";
String s2 = "§6Your version: §c" + pluginVersion + " §7- §6Current version: §a" + publicVersion;
String s3 = "§6You can download it here: §ehttps://www.spigotmc.org/resources/" + spigot;
String s4 = "§6You can find more information on Discord: §e" + discord;
if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) {
String updateStatusVersion;
if (webData.isPreRelease()) {
updateStatusVersion = UpdateType.PRERELEASE.text;
if (publicVersion.toLowerCase().contains("dev")) {
s1 = "§6A new §4DEV§6 version was found!§r";
updateStatusVersion = UpdateType.DEVELOPMENT.text;
}
if (publicVersion.toLowerCase().contains("beta")) {
s1 = "§6A new §2BETA§6 version was found!§r";
updateStatusVersion = UpdateType.BETA.text;
}
if (publicVersion.toLowerCase().contains("snapshot")) {
s1 = "§6A new §eSNAPSHOT§6 version was found!§r";
updateStatusVersion = UpdateType.SNAPSHOT.text;
}
} else {
s1 = "§6A new version was found!§r";
}
String text = "<br>" + h + "<br>" + s1 + "<br>" + s2 + "<br>" + s3 + "<br>" + s4 + "<br>" + h;
} 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]", 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>";
String f = "<br><dark_red>╚══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
String text = h + s1 + s2 + s3 + s4 + f;
T2Csend.console(text);
}
public static void onUpdateCheck(Plugin plugin, String prefix, int spigotID, String discord) {
new BukkitRunnable() {
@Override
public void run() {
(new T2CupdateChecker((JavaPlugin) plugin, spigotID)).getVersion((update_version) -> {
T2CupdateObject update = new T2CupdateObject(
plugin.getName(),
plugin.getDescription().getVersion(),
update_version,
false
);
pluginVersions.put(plugin.getName(), update);
if (!plugin.getDescription().getVersion().equalsIgnoreCase(update_version)) {
if (!update.load) {
new BukkitRunnable() {
@Override
public void run() {
update.load = true;
sendUpdateMsg(prefix, spigotID, discord, plugin);
}
}.runTaskLaterAsynchronously(plugin, 600L);
} else sendUpdateMsg(prefix, spigotID, discord, plugin);
} else {
if (!update.load){
T2Csend.console(prefix + " §2No update found.");
update.load = true;
}
}
}, prefix, plugin.getDescription().getVersion());
public static String updateInfo(String[] args, Boolean player) {
T2CupdateObject object;
try {
object = T2CupdateAPI.pluginVersions.get(args[1]);
} catch (Exception e) {
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;
String updateTitle = webData.getUpdateTitle();
String updateVersion = webData.getVersion();
String updateType;
if (webData.isPreRelease()) {
updateType = UpdateType.PRERELEASE.text;
if (updateVersion.toLowerCase().contains("dev")) {
updateType = UpdateType.DEVELOPMENT.text;
}
}.runTaskTimerAsynchronously(plugin, 0L, SelectLibConfig.getUpdateCheckTimeInterval() * 60 * 20L);
if (updateVersion.toLowerCase().contains("beta")) {
updateType = UpdateType.BETA.text;
}
if (updateVersion.toLowerCase().contains("snapshot")) {
updateType = UpdateType.SNAPSHOT.text;
}
} else updateType = UpdateType.STABLE.text;
String updateAt = webData.getPublishedAt();
String updateUpdate = webData.getUpdateUrl();
String updateDescription = webData.getUpdateDescription();
String pluginNameString = "<br><dark_red>║</dark_red> <color:#6e90ff>Plugin:</color> <color:#5eff89>" + pluginName + "</color>";
String pluginVersionString = "<br><dark_red>║</dark_red> <color:#6e90ff>Your version:</color> <color:#5eff89>" + pluginVersion + "</color>";
String updateInfoString = "<br><dark_red>║</dark_red> <color:#09ff00>[value]:</color>";
String updateTitleString = "<br><dark_red>║</dark_red> <color:#6e90ff>Title:</color> <color:#5eff89>" + updateTitle + "</color>";
String updateVersionString = "<br><dark_red>║</dark_red> <color:#6e90ff>Version:</color> <color:#5eff89>" + updateVersion + "</color>";
String updateAtString = "<br><dark_red>║</dark_red> <color:#6e90ff>Published on:</color> <color:#5eff89>" + updateAt + "</color>";
String updateTypeString = "<br><dark_red>║</dark_red> <color:#6e90ff>Version type:</color> <color:#5eff89>" + updateType + "</color>";
String updateButton;
if (player) {
updateButton = "<br><dark_red>║</dark_red> <color:#5eff89><hover:show_text:'<gold>" + updateUpdate + "</gold>'><click:open_url:'" + updateUpdate
+ "'>Download</click></hover></color> <dark_gray>|</dark_gray> <color:#ff9499><hover:show_text:'" + updateDescription + "'><click:open_url:'" + webData.getGitURL() + "'>Update Description</click></hover></color>";
} else updateButton = "<br><dark_red>║</dark_red> <color:#5eff89>Download:</color> <gold>" + updateUpdate + "</gold>";
String text;
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");
if (!updateTitle.equals("OLD")) text = text + updateTitleString;
if (object.updateAvailable) text = text + updateVersionString;
if (!updateTitle.equals("OLD")) text = text + updateAtString;
if (!updateTitle.equals("OLD")) text = text + updateTypeString;
text = text + updateButton;
if (updateTitle.equals("OLD")) text = text + "<br><dark_gray>This plugin does not have the new update checker yet, so there is no exact update / " +
"version information available!</dark_gray>";
text = text + "<br><dark_red>╚══════════════════════</dark_red>";
return text;
}
public static void onUpdateCheck(Plugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
if (SelectLibConfig.getUpdateCheckFullDisable()) return;
new T2CupdateCheckerGit((JavaPlugin) plugin, prefix, gitKey, spigotID, discord, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
}
}

View File

@@ -1,72 +0,0 @@
package net.t2code.t2codelib.SPIGOT.api.update;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Scanner;
import java.util.function.Consumer;
public class T2CupdateChecker {
private JavaPlugin plugin;
private int resourceId;
public T2CupdateChecker(JavaPlugin plugin, int resourceId) {
this.plugin = plugin;
this.resourceId = resourceId;
}
public void getVersion(Consumer<String> consumer, String Prefix, String pluginVersion) {
if (!plugin.isEnabled()) {
return;
}
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
try {
InputStream inputStream = (new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId)).openStream();
try {
Scanner scanner = new Scanner(inputStream);
try {
if (scanner.hasNext()) {
consumer.accept(scanner.next());
}
} catch (Throwable var8) {
try {
scanner.close();
} catch (Throwable var7) {
var8.addSuppressed(var7);
}
throw var8;
}
scanner.close();
} catch (Throwable var9) {
if (inputStream != null) {
try {
inputStream.close();
} catch (Throwable var6) {
var9.addSuppressed(var6);
}
}
throw var9;
}
inputStream.close();
} catch (IOException var10) {
Boolean load = false;
if (T2CupdateAPI.pluginVersions.containsKey(plugin.getName())){
load = T2CupdateAPI.pluginVersions.get(plugin.getName()).load;
}
T2CupdateObject update = new T2CupdateObject(
plugin.getName(),
pluginVersion,
null,
load
);
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());
}
});
}
}

View File

@@ -0,0 +1,154 @@
package net.t2code.t2codelib.SPIGOT.api.update;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.function.Consumer;
public class T2CupdateCheckerGit {
private final JavaPlugin plugin;
private T2CupdateObject t2CupdateObject;
public T2CupdateCheckerGit(JavaPlugin plugin, String prefix, String gitKey, Integer spigotID, String discord, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
this.plugin = plugin;
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
if (!seePreReleaseUpdates) {
RepoURL = RepoURL + "&pre-release=false";
}
String finalRepoURL = RepoURL;
Integer finalInterval;
if (timeInterval < 1) {
finalInterval = 1;
} else finalInterval = timeInterval;
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
@Override
public void run() {
if (SelectLibConfig.getUpdateCheckFullDisable()) return;
getVersion((webData) -> {
T2CupdateObject update = new T2CupdateObject(
plugin.getName(),
plugin.getDescription().getVersion(),
webData,
t2CupdateObject != null && t2CupdateObject.load,
!plugin.getDescription().getVersion().equals(webData.getVersion()),
updateCheckOnJoin
);
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() {
@Override
public void run() {
update.load = true;
T2CupdateAPI.sendUpdateMsg(prefix, discord, webData, plugin);
}
}.runTaskLaterAsynchronously(plugin, 600L);
} else T2CupdateAPI.sendUpdateMsg(prefix, discord, webData, plugin);
} else {
if (!update.load) {
T2Csend.console(prefix + " §2No update found.");
update.load = true;
}
}
t2CupdateObject = update;
}, plugin.getDescription().getVersion(), spigotID, finalRepoURL, updateCheckOnJoin, seePreReleaseUpdates, timeInterval);
}
}, 10L, finalInterval * 60 * 20L);
}
public void getVersion(Consumer<T2CupdateWebData> consumer, String pluginVersion, Integer spigotID, String URL, Boolean updateCheckOnJoin, Boolean seePreReleaseUpdates, Integer timeInterval) {
if (!plugin.isEnabled()) {
return;
}
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
try {
URL url = new URL(URL);
URLConnection yc = url.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
String data = "";
while ((inputLine = in.readLine()) != null)
data = inputLine;
in.close();
data = data.substring(1, data.length() - 1);
if (data.isEmpty()) {
consumer.accept(null);
return;
}
JSONObject obj = new JSONObject(data);
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 publishedAt = outputFormat.format(parsedDate);
String gitURL = updateUrl;
JSONArray downloadArray = obj.getJSONArray("assets");
String downloadURL;
if (downloadArray.isEmpty()) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
} else {
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
}
if (!preRelease) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
updateUrl = "https://www.spigotmc.org/resources/" + spigotID;
}
T2CupdateWebData webData = new T2CupdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease);
consumer.accept(webData);
} catch (Exception exception) {
Boolean load = false;
if (T2CupdateAPI.pluginVersions.containsKey(plugin.getName())) {
load = T2CupdateAPI.pluginVersions.get(plugin.getName()).load;
}
T2CupdateObject update = new T2CupdateObject(
plugin.getName(),
pluginVersion,
null,
load,
false,
updateCheckOnJoin
);
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
T2Csend.error(this.plugin,"§4 Cannot look for updates: " + exception.getMessage());
exception.printStackTrace();
}
});
}
}

View File

@@ -1,20 +0,0 @@
package net.t2code.t2codelib.SPIGOT.api.update;
public class T2CupdateObject {
public String pluginName;
public String pluginVersion;
public String publicVersion;
public Boolean load;
public T2CupdateObject(String pluginName,
String pluginVersion,
String publicVersion,
Boolean load) {
this.pluginName = pluginName;
this.pluginVersion = pluginVersion;
this.publicVersion = publicVersion;
this.load = load;
}
}

View File

@@ -0,0 +1,37 @@
package net.t2code.t2codelib.SPIGOT.api.yaml;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
public class T2CLibConfig {
public static Boolean getUpdateCheckOnJoin() {
return SelectLibConfig.getUpdateCheckOnJoin();
}
public static Boolean getT2cTestDevelopment() {
return SelectLibConfig.getT2cTestDevelopment();
}
public static Integer getUpdateCheckTimeInterval() {
return SelectLibConfig.getUpdateCheckTimeInterval();
}
public static Boolean getSeePreReleaseUpdates() {
return SelectLibConfig.getSeePreReleaseUpdates();
}
public static Boolean getDebug() {
return SelectLibConfig.getDebug();
}
public static String getLanguage() {
return SelectLibConfig.getLanguage();
}
public static Boolean getBungee() {
return SelectLibConfig.getBungee();
}
public static Boolean getInventoriesCloseByServerStop() {
return SelectLibConfig.getInventoriesCloseByServerStop();
}
}

View File

@@ -17,6 +17,11 @@ public class T2Cconfig {
YamlConfiguration.set(path, value);
}
}
public static void set(String path, Object value, YamlConfiguration YamlConfiguration) {
if (!YamlConfiguration.contains(path)) {
YamlConfiguration.set(path, value);
}
}
public static void set(String path, YamlConfiguration YamlConfiguration) {
YamlConfiguration.set(path, null);
@@ -119,6 +124,9 @@ public class T2Cconfig {
return T2Creplace.replace(prefix, yamlConfiguration.getString(path));
}
public static Object selectObject(String prefix, String path, YamlConfiguration yamlConfiguration) {
return T2Creplace.replaceObject(prefix, yamlConfiguration.get(path));
}
public static Integer selectInt(String path, YamlConfiguration yamlConfiguration) {
return (yamlConfiguration.getInt(path));
@@ -140,7 +148,6 @@ public class T2Cconfig {
return (yamlConfiguration.getItemStack(path));
}
public static List<String> selectList(String prefix, String path, YamlConfiguration yamlConfiguration) {
List<String> output = new ArrayList<>();
List<String> input = yamlConfiguration.getStringList(path);

View File

@@ -1,121 +0,0 @@
package net.t2code.t2codelib.SPIGOT.system;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.system.CreateReportLog;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
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) {
T2Ctemplate.sendInfo(sender,T2CodeLibMain.getPlugin(), Util.getSpigotID(),Util.getDiscord(),null, Util.getInfoText());
return false;
}
switch (args[0].toLowerCase()) {
case "info":
case "plugin":
case "pl":
case "version":
case "ver":
T2Ctemplate.sendInfo(sender,T2CodeLibMain.getPlugin(), Util.getSpigotID(),Util.getDiscord(),null, Util.getInfoText());
return false;
case "reloadconfig":
SelectLibConfig.onSelect();
return false;
case "debug":
if (args.length != 2) {
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
return false;
}
if ("createreportlog".equals(args[1].toLowerCase())) {
Bukkit.getScheduler().runTaskAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
@Override
public void run() {
CreateReportLog.create(sender);
}
});
} else T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
return false;
default:
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
return false;
}
}
//TabCompleter
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
put("debug", "t2code.admin");
put("info", "t2code.admin");
put("reloadconfig", "t2code.admin");
}};
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
List<String> list = new ArrayList<>();
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length == 1) {
for (String command : arg1.keySet()) {
if (hasPermission(p, arg1.get(command)) && passend(command, args[0])) {
list.add(command);
}
}
}
if (args.length == 2 && args[0].equalsIgnoreCase("debug")) {
if (sender.hasPermission("t2code.admin")) {
if (hasPermission(p, arg1.get("debug")) && passend("debug", args[1])) {
list.add("createReportLog");
}
}
return list;
}
}
return list;
}
private static Boolean passend(String command, String arg) {
for (int i = 0; i < arg.toUpperCase().length(); i++) {
if (arg.toUpperCase().length() >= command.toUpperCase().length()) {
return false;
} else {
if (arg.toUpperCase().charAt(i) != command.toUpperCase().charAt(i)) {
return false;
}
}
}
return true;
}
public static boolean hasPermission(Player player, String permission) {
if (player.isOp()) {
return true;
}
String[] Permissions = permission.split(";");
for (String perm : Permissions) {
if (player.hasPermission(perm)) {
return true;
}
}
return false;
}
}

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,8 +9,9 @@ import org.bukkit.entity.Player;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Arrays;
public class BCommandSenderReciver {
public class T2CbungeeCommandSenderReciver {
public static void sendToBungee(CommandSender sender, String information, Boolean console) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
@@ -24,18 +27,22 @@ public class BCommandSenderReciver {
}
}
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

@@ -1,21 +1,29 @@
package net.t2code.t2codelib.SPIGOT.system;
import lombok.Getter;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayers;
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;
import net.t2code.t2codelib.SPIGOT.system.config.languages.LanguagesCreate;
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@@ -30,7 +38,8 @@ public final class T2CodeLibMain extends JavaPlugin {
private static List<String> autor;
private static String version;
private static Boolean nmIsLoad = true;
@Getter
private static Boolean mmIsLoad = true;
private static Boolean load = false;
@Override
@@ -39,8 +48,13 @@ public final class T2CodeLibMain extends JavaPlugin {
plugin = this;
autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion();
this.adventure = BukkitAudiences.create(this);
try {
adventure = BukkitAudiences.create(this);
} catch (Exception e) {
mmIsLoad = false;
}
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
checkIsBungee();
String prefix = Util.getPrefix();
try {
@@ -50,39 +64,68 @@ public final class T2CodeLibMain extends JavaPlugin {
}
T2CmcVersion.onCheck();
if (T2CmcVersion.isMc1_20()) {
if (T2CnmsVersions.getT2CnmsEnum() == T2CnmsEnum.not_support) {
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(prefix);
T2Csend.warning(plugin, "The 1.20.* 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!!!!!!!!!!!!!!!!!!!!");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
if (!SelectLibConfig.getT2cTestDevelopment()) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
T2Csend.console(prefix + " §3Server run on: §6" + T2CmcVersion.getMcVersion() + " / " + T2CmcVersion.getNms());
if (T2CmcVersion.isMc1_21()) {
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(prefix);
T2Csend.warning(plugin, "The 1.21 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");
plugin.getCommand("t2code").setExecutor(new CmdExecuter());
ConfigCreate.configCreate();
T2CitemVersion.scan();
@@ -90,13 +133,24 @@ public final class T2CodeLibMain extends JavaPlugin {
SelectLibConfig.onSelect();
SelectLibMsg.onSelect();
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getSpigotID(), Util.getDiscord());
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord(), SelectLibConfig.getUpdateCheckOnJoin(), SelectLibConfig.getSeePreReleaseUpdates(),
SelectLibConfig.getUpdateCheckTimeInterval());
Metrics.Bstats(plugin, Util.getBstatsID());
if (SelectLibConfig.getBungee()){
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")) {
T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:bonlp");
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "t2c:bonlp", new T2CbungeePlayers());
T2CbungeePlayers.callAllBungeePlayers();
}
}
ReportLogStorage.load();
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
Bukkit.getServer().getPluginManager().registerEvents(new Development(), plugin);
T2Ctemplate.onLoadFooter(prefix, long_);
load = true;
}
@@ -105,6 +159,7 @@ public final class T2CodeLibMain extends JavaPlugin {
public void onDisable() {
// Plugin shutdown logic
if (!load) return;
ReportLogStorage.save();
if (SelectLibConfig.getInventoriesCloseByServerStop()) {
for (Player player : Bukkit.getOnlinePlayers()) {
player.closeInventory();
@@ -112,8 +167,8 @@ public final class T2CodeLibMain extends JavaPlugin {
}
Vault.vaultDisable();
T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
if (nmIsLoad) {
T2Ctemplate.onDisable(Util.getPrefix(), this);
if (mmIsLoad) {
if (this.adventure != null) {
this.adventure.close();
this.adventure = null;
@@ -155,14 +210,27 @@ public final class T2CodeLibMain extends JavaPlugin {
private static BukkitAudiences adventure;
public static BukkitAudiences adventure() {
public BukkitAudiences getAdventure() {
if (adventure == null) {
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
}
return adventure;
}
public static Boolean getNmIsLoad() {
return nmIsLoad;
private static void checkIsBungee() {
File config = new File("spigot.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
isBungee = yamlConfiguration.getBoolean("settings.bungeecord");
}
private static Boolean isBungee;
public static Boolean getIsBungee() {
return isBungee;
}
public static Boolean getMmIsLoad() {
return mmIsLoad;
}
}

View File

@@ -6,6 +6,8 @@ import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.Util;
import org.bukkit.plugin.RegisteredServiceProvider;
import java.util.Objects;
public class Vault {
public static Boolean vaultEnable;
@@ -13,7 +15,7 @@ public class Vault {
public static void loadVault() throws InterruptedException {
long long_ = System.currentTimeMillis();
if (T2CodeLibMain.getPlugin().getServer().getPluginManager().getPlugin("Vault") != null) {
if (T2CodeLibMain.getPlugin().getServer().getPluginManager().getPlugin("Vault") != null && Objects.requireNonNull(T2CodeLibMain.getPlugin().getServer().getPluginManager().getPlugin("Vault")).isEnabled()) {
vaultEnable = true;
RegisteredServiceProvider<Economy> eco = T2CodeLibMain.getPlugin().getServer().getServicesManager().getRegistration(Economy.class);
if (eco != null) {

View File

@@ -0,0 +1,211 @@
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.update.T2CupdateAPI;
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;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CmdExecuter implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
Commands.info(sender);
return false;
}
switch (args[0].toLowerCase()) {
case "info":
case "plugin":
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 "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":
if (!sender.hasPermission("t2code.admin")) {
T2Csend.sender(sender, "§4No Permission §8t2code.admin");
return false;
}
Commands.debug(sender, args);
return false;
case "test":
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;
}
}
//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");
}};
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
List<String> list = new ArrayList<>();
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length == 1) {
for (String command : arg1.keySet()) {
if (hasPermission(p, arg1.get(command)) && passend(command, args[0])) {
list.add(command);
}
}
}
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");
}
}
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);
}
}
}
return list;
}
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);
}
}
}
return list;
}
}
return list;
}
private static Boolean passend(String command, String arg) {
for (int i = 0; i < arg.toUpperCase().length(); i++) {
if (arg.toUpperCase().length() >= command.toUpperCase().length()) {
return false;
} else {
if (arg.toUpperCase().charAt(i) != command.toUpperCase().charAt(i)) {
return false;
}
}
}
return true;
}
public static boolean hasPermission(Player player, String permission) {
if (player.isOp()) {
return true;
}
String[] Permissions = permission.split(";");
for (String perm : Permissions) {
if (player.hasPermission(perm)) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,105 @@
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 java.io.IOException;
public class Commands {
protected static void info(CommandSender sender) {
T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText());
}
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) {
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> " +
"after <red>14</red> days!<br>The file can also be deleted manually by you via command!</dark_red><br><dark_green><hover:show_text:'<yellow>Confirm the" +
" upload</yellow>'><click:run_command:'/t2c debug createReportLog confirmupload'>upload</click></hover></dark_green> <dark_gray>|</dark_gray> " +
"<gold><hover:show_text:'<red>Do not upload</red>'><click:run_command:'/t2c debug createReportLog noupload'>keep the file on your server</click></hover></gold>");
} else T2Csend.sender(sender, "<dark_red>The debug zip file is <red>automatically uploaded</red> to T2Code's servers</dark_red>" +
"<br><dark_red>and <red>automatically deleted</red> after <red>14</red> days!</dark_red>" +
"<br><dark_red>The file can also be deleted manually by you via command!</dark_red>" +
"<br><green>Confirm the upload with the command:</green>" +
"<br><yellow>/t2c debug createReportLog confirmupload</yellow>" +
"<br><red>Keep the file on your server and do not upload it with the command:</red>" +
"<br><yellow>/t2c debug createReportLog noupload</yellow>");
break;
case 3:
Boolean upload = args[2].equalsIgnoreCase("confirmupload");
Bukkit.getScheduler().runTaskAsynchronously(T2CodeLibMain.getPlugin(), new Runnable() {
@Override
public void run() {
try {
CreateReportLog.create(sender, upload);
} catch (IOException e) {
T2Csend.sender(sender, Util.getPrefix() + " <red>An error occurred while creating a report log! Please look in the console!</red>");
throw new RuntimeException(e);
}
}
});
break;
default:
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
return;
}
break;
case "deletereportlog":
if (args.length != 3) {
T2Csend.sender(sender, "§4Use: §7/t2code debug deleteReportLog [id]");
return;
}
try {
CreateReportLog.delete(args[2], sender);
} catch (IOException e) {
throw new RuntimeException(e);
}
break;
default:
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog/deleteReportLog");
break;
}
}
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

@@ -1,45 +1,68 @@
package net.t2code.t2codelib.SPIGOT.system;
package net.t2code.t2codelib.SPIGOT.system.cmd;
import net.t2code.luckyBox.api.LuckyBoxAPI;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.SPIGOT.system.Vault;
import net.t2code.t2codelib.Util;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.json.JSONObject;
import java.io.*;
import java.net.HttpURLConnection;
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;
public class CreateReportLog {
protected static void create(CommandSender sender) {
protected static void create(CommandSender sender, Boolean confirmUpload) throws IOException {
T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog is created...");
String timeStampFile = new SimpleDateFormat("HH_mm_ss-dd_MM_yyyy").format(Calendar.getInstance().getTime());
File directory = new File(T2CodeLibMain.getPath() + "/DebugLogs");
File directoryTemp = new File("T2CDebugLogsTemp");
if (!directory.exists()) {
directory.mkdir();
}
if (!directoryTemp.exists()) {
directoryTemp.mkdir();
}
File file = new File(T2CodeLibMain.getPath(), "/DebugLogs/T2CodeLog.txt");
File file = new File("T2CDebugLogsTemp/T2CodeLog.txt");
PrintWriter pWriter = null;
try {
pWriter = new PrintWriter(new FileWriter(file.getPath()));
String timeStamp = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy").format(Calendar.getInstance().getTime());
pWriter.println("Created on: " + timeStamp);
pWriter.println("Created on: " + timeStamp + " - from: " + sender.getName());
pWriter.println();
pWriter.println("Server Bukkit version: " + T2CmcVersion.getBukkitVersion());
pWriter.println("Server run on: " + T2CmcVersion.getMcVersion());
pWriter.println("Server NMS: " + T2CmcVersion.getNms());
pWriter.println();
pWriter.println("Online Mode: " + Bukkit.getOnlineMode());
pWriter.println("Bungee Mode: " + T2CodeLibMain.getIsBungee());
pWriter.println("Server Port: " + Bukkit.getServer().getPort());
pWriter.println();
pWriter.println("Worlds: " + Bukkit.getWorlds());
pWriter.println("OP-Player:");
for (OfflinePlayer player : Bukkit.getOperators()) {
@@ -80,18 +103,35 @@ public class CreateReportLog {
pWriter.println("T2C-LuckyBox isV: " + LuckyBoxAPI.isV());
pWriter.println();
}
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() + " - 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 {
@@ -101,9 +141,9 @@ public class CreateReportLog {
}
}
String filePath = T2CodeLibMain.getPath() + "/DebugLogs/T2CodeLog.txt";
String filePath = "T2CDebugLogsTemp/T2CodeLog.txt";
String log = "logs/latest.log";
String zipPath = "plugins/T2CodeLib/DebugLogs/T2CLog-" + timeStampFile + ".zip";
String zipPath = "T2CDebugLogsTemp/T2CLog-" + timeStampFile + ".zip";
try (ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(zipPath))) {
File fileToZip = new File(filePath);
zip.putNextEntry(new ZipEntry(fileToZip.getName()));
@@ -111,20 +151,63 @@ 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();
zip.close();
} catch (IOException e) {
e.printStackTrace();
}
file.delete();
if (sender instanceof Player) {
T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + zipPath);
T2Csend.console(Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + zipPath);
} else T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + zipPath);
File zipFile = new File(zipPath);
if (!confirmUpload) {
Files.move(Paths.get(zipPath), Paths.get(directory + "/" + zipFile.getName()));
zipFile.delete();
directoryTemp.delete();
if (sender instanceof Player) {
T2Csend.sender(sender, Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + directory + "/" + zipFile.getName());
}
T2Csend.console(Util.getPrefix() + " §6A DebugLog zip has been created. you can find it on in the files on your server under the path: §e" + directory + "/" + zipFile.getName());
return;
}
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://debug.t2code.net/uploadFile");
FileBody bin = new FileBody(zipFile);
MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("file", bin);
httppost.setEntity(reqEntity);
HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();
String responseString = EntityUtils.toString(resEntity, "UTF-8");
JSONObject obj = new JSONObject(responseString);
String downloadURL = obj.getString("fileDownloadUri");
String fileID = obj.getString("fileID");
String fileType = obj.getString("fileType");
Integer fileSize = obj.getInt("size");
zipFile.delete();
directoryTemp.delete();
if (sender instanceof Player) {
T2Csend.sender(sender, ("[prefix] <green>A DebugLog zip has been created." +
"<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>[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()));
}
T2Csend.console(Util.getPrefix() + (" <gold>A DebugLog zip has been created. You can download it here:</gold> <yellow>[url]</yellow>" +
"<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 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);
}
private static void pluginToDebug(String pluginName, ZipOutputStream zip) throws IOException {
@@ -145,6 +228,20 @@ public class CreateReportLog {
}
}
private static void pluginToDebug(ZipOutputStream zip) throws IOException {
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
String plName = plugin.getDescription().getName();
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);
}
}
}
private static void addFolderToZip(String path, String srcFolder, ZipOutputStream zip) throws IOException {
File folder = new File(srcFolder);
if (folder.list() == null) {
@@ -190,4 +287,18 @@ public class CreateReportLog {
}
}
}
public static void delete(String arg, CommandSender sender) throws IOException {
URL url = new URL("https://debug.t2code.net/delete/" + arg);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
int response = con.getResponseCode();
if (response == 200) {
ReportLogStorage.remove(arg);
T2Csend.sender(sender, "<green>Deleted report: <yellow>" + arg);
} else {
T2Csend.sender(sender, "<green>Error while deleting report: <yellow>" + arg);
}
con.disconnect();
}
}

View File

@@ -0,0 +1,70 @@
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.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

@@ -0,0 +1,42 @@
package net.t2code.t2codelib.SPIGOT.system.cmd;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class ReportLogStorage {
public static List<String> list = new ArrayList<>();
protected static File config = new File(T2CodeLibMain.getPath(), "/DebugLogs/T2CodeReportKeys.yml");
protected static YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
public static void add(String key) {
list.add(key);
save();
}
public static void remove(String key) {
list.remove(key);
save();
}
public static void save() {
if (list == null) return;
yamlConfiguration.set("Keys", list);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void load() {
if (!config.exists()) return;
list = yamlConfiguration.getStringList("Keys");
}
}

View File

@@ -22,13 +22,19 @@ public class ConfigCreate {
File config = new File(T2CodeLibMain.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
T2Cconfig.set("Plugin.UpdateCheck.OnJoin", true, yamlConfiguration);
T2Cconfig.set("Plugin.UpdateCheck.TimeInterval", 60, yamlConfiguration);
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", false, 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

@@ -1,5 +1,6 @@
package net.t2code.t2codelib.SPIGOT.system.config.config;
import lombok.Getter;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -7,53 +8,46 @@ import java.io.File;
public class SelectLibConfig {
private static Boolean UpdateCheckOnJoin;
private static Boolean t2cTestDevelopment;
private static Integer UpdateCheckTimeInterval;
private static Boolean Debug;
@Getter
private static Boolean updateCheckOnJoin;
@Getter
private static Boolean t2cTestDevelopment = false;
@Getter
private static Integer updateCheckTimeInterval;
@Getter
private static Boolean seePreReleaseUpdates;
@Getter
private static Boolean updateCheckFullDisable;
@Getter
private static Boolean debug;
@Getter
private static String language;
@Getter
private static Boolean developerTool;
@Getter
private static Boolean bungee;
private static Boolean InventoriesCloseByServerStop;
@Getter
private static Boolean inventoriesCloseByServerStop;
@Getter
private static String commandPermToggleCommand;
public static void onSelect() {
File config = new File(T2CodeLibMain.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheck.OnJoin");
t2cTestDevelopment = yamlConfiguration.getBoolean("t2cTestDevelopment");
UpdateCheckTimeInterval = yamlConfiguration.getInt("Plugin.UpdateCheck.TimeInterval");
Debug = yamlConfiguration.getBoolean("Plugin.Debug");
if (yamlConfiguration.contains("t2cTestDevelopment")) {
t2cTestDevelopment = yamlConfiguration.getBoolean("t2cTestDevelopment");
}
updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheck.OnJoin");
updateCheckTimeInterval = yamlConfiguration.getInt("Plugin.UpdateCheck.TimeInterval");
seePreReleaseUpdates = yamlConfiguration.getBoolean("Plugin.UpdateCheck.SeePreReleaseUpdates");
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");
inventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop");
commandPermToggleCommand = yamlConfiguration.getString("Command.PermToggle.PermissionSetCommand");
}
public static Boolean getUpdateCheckOnJoin() {
return UpdateCheckOnJoin;
}
public static Boolean getT2cTestDevelopment() {
return t2cTestDevelopment;
}
public static Integer getUpdateCheckTimeInterval() {
return UpdateCheckTimeInterval;
}
public static Boolean getDebug() {
return Debug;
}
public static String getLanguage() {
return language;
}
public static Boolean getBungee() {
return bungee;
}
public static Boolean getInventoriesCloseByServerStop() {
return InventoriesCloseByServerStop;
}
}

View File

@@ -0,0 +1,28 @@
package net.t2code.t2codelib;
import java.util.Optional;
public class T2CVupdateObject {
public Optional<String> pluginName;
public Optional<String> pluginVersion;
public T2CupdateWebData webData;
public Boolean load;
public Boolean updateAvailable;
public Boolean updateCheckOnJoin;
public T2CVupdateObject(Optional<String> pluginName,
Optional<String> pluginVersion,
T2CupdateWebData webData,
Boolean load,
Boolean updateAvailable,
Boolean updateCheckOnJoin) {
this.pluginName = pluginName;
this.pluginVersion = pluginVersion;
this.webData = webData;
this.load = load;
this.updateAvailable = updateAvailable;
this.updateCheckOnJoin = updateCheckOnJoin;
}
}

View File

@@ -0,0 +1,28 @@
package net.t2code.t2codelib;
import java.util.Optional;
public class T2CupdateObject {
public String pluginName;
public String pluginVersion;
public T2CupdateWebData webData;
public Boolean load;
public Boolean updateAvailable;
public Boolean updateCheckOnJoin;
public T2CupdateObject(String pluginName,
String pluginVersion,
T2CupdateWebData webData,
Boolean load,
Boolean updateAvailable,
Boolean updateCheckOnJoin) {
this.pluginName = pluginName;
this.pluginVersion = pluginVersion;
this.webData = webData;
this.load = load;
this.updateAvailable = updateAvailable;
this.updateCheckOnJoin = updateCheckOnJoin;
}
}

View File

@@ -0,0 +1,34 @@
package net.t2code.t2codelib;
import lombok.Getter;
public class T2CupdateWebData {
@Getter
private String updateTitle;
@Getter
private String version;
@Getter
private String updateDescription;
@Getter
private String updateUrl;
@Getter
private String publishedAt;
@Getter
private String downloadURL;
@Getter
private String gitURL;
@Getter
private boolean preRelease;
public T2CupdateWebData(String updateTitle, String version, String updateDescription, String updateUrl, String publishedAt, String downloadURL, String gitURL, boolean preRelease) {
this.updateTitle = updateTitle;
this.version = version;
this.updateDescription = updateDescription;
this.updateUrl = updateUrl;
this.publishedAt = publishedAt;
this.downloadURL = downloadURL;
this.gitURL = gitURL;
this.preRelease = preRelease;
}
}

View File

@@ -0,0 +1,15 @@
package net.t2code.t2codelib;
public enum UpdateType {
PRERELEASE("<light_purple>Pre-Release</light_purple>"),
DEVELOPMENT("<dark_red>DEV</dark_red>"),
BETA("<gold>BETA</gold>"),
SNAPSHOT("<yellow>SNAPSHOT</yellow>"),
STABLE("<dark_green>STABLE</dark_green>");
public String text;
UpdateType(String text) {
this.text = text;
}
}

View File

@@ -1,22 +1,34 @@
package net.t2code.t2codelib;
import lombok.Getter;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
public class Util {
@Getter
private static final UUID serverUUID = UUID.randomUUID();
public static String getInfoText() {
return "";
return "<yellow>Description:</yellow> <gold>"+T2CodeLibMain.getPlugin().getDescription().getDescription()+"</gold>" ;
}
public static String getPrefix() {
return "§8[§4T2Code§5Lib§8]";
return "<dark_gray>[<dark_red>T2Code</dark_red><dark_purple>Lib</dark_purple>]</dark_gray>";
}
public static Integer getSpigotID() {
return 96388;
}
public static String getGit() {
return "JaTiTV/T2CodeLib";
}
public static Integer getBstatsID() {
return 12518;
}
@@ -31,11 +43,11 @@ public class Util {
public static List<String> getT2cPlugins() {
return Arrays.asList(
//"T2CodeLib",
"T2CodeLib",
"T2C-LuckyBox",
"WonderBagShop",
"CommandGUI",
"T2C-OPSecurity",
// "T2C-OPSecurity",
"OPSecurity",
"PaPiTest",
"T2C-Alias",
@@ -43,7 +55,8 @@ public class Util {
"LoreEditor",
"Booster",
"AntiMapCopy",
"AntiCopy"
"AntiCopy",
"T2C-LoginPermissionAuth"
);
}
}

View File

@@ -0,0 +1,101 @@
package net.t2code.t2codelib.VELOCITY;
//@Plugin(id = "t2codelib", name = "T2CodeLib", version = "16.7_dev-01", authors = {"JaTiTV"})
public class VelocityMain {
//
// String prefix = "[T2CodeLib]";
//
// protected final ProxyServer server;
// protected final Logger logger;
// public static final MinecraftChannelIdentifier IDENTIFIER = MinecraftChannelIdentifier.from("t2c:bcmd");
// // public static final MinecraftChannelIdentifier IDENTIFIER2 = MinecraftChannelIdentifier.from("booster:activate");
//
// @Inject
// public VelocityMain(ProxyServer server, Logger logger) {
// long long_ = System.currentTimeMillis();
// this.server = server;
// this.logger = logger;
//
// logger.info("============================= {} =============================", prefix);
// logger.info("Autor: JaTiTV");
// logger.info("Version: 16.7_dev-01");
// logger.info("Plugin loaded successfully. - {}ms", System.currentTimeMillis() - long_);
// logger.info("============================= {} =============================", prefix);
//
// }
//
//
// @Subscribe
// public void onProxyInitialization(ProxyInitializeEvent event) {
// server.getChannelRegistrar().register(IDENTIFIER);
// // server.getChannelRegistrar().register(IDENTIFIER2);
// }
//
// @Subscribe
// public void onPluginMessageFromPlayer(PluginMessageEvent event) {
// if (event.getIdentifier() != IDENTIFIER) {
// return;
// }
// ByteArrayDataInput stream = ByteStreams.newDataInput(event.getData());
// 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")) {
// logger.info("{} [{}] T2C BCMD Command Console: {}", prefix, serverID, input);
// dispatchCommand(input);
// } else {
// Player player = server.getPlayer(channel).orElse(null);
// if (player != null) {
// logger.info("{} [{}] T2C BCMD Command {}: {}", prefix, serverID, player, input);
// executeCommand(player, input);
// }
// }
// event.setResult(PluginMessageEvent.ForwardResult.handled());
// }
//
//// public void sendToSpigot(String sender, String boostertype, String step, String starter, String starttime, String starteruuid) {
//// ByteArrayOutputStream stream = new ByteArrayOutputStream();
//// DataOutputStream output = new DataOutputStream(stream);
//// try {
//// output.writeUTF(boostertype);
//// output.writeUTF(step);
//// output.writeUTF(starter);
//// output.writeUTF(starttime);
//// output.writeUTF(starteruuid);
//// } catch (IOException e) {
//// java.util.logging.Logger.getLogger(e.getMessage());
//// }
//// Optional<Player> player = server.getPlayer(sender);
//// if (!player.isPresent()) {
//// return;
//// }
//// server.getAllServers().forEach((server) -> {
//// if (server != player.get().getCurrentServer().get().getServer()) {
//// server.sendPluginMessage(IDENTIFIER2, stream.toByteArray());
//// }
//// });
//// }
//
// public void dispatchCommand(String input) {
// // Get the console command source
// ConsoleCommandSource console = server.getConsoleCommandSource();
//
// // Dispatch the command
// server.getCommandManager().executeAsync(console, input).join();
// }
//
// public void executeCommand(Player player, String input) {
// CommandManager commandManager = server.getCommandManager();
//
// // Dispatch the command
// commandManager.executeImmediatelyAsync(player, input);
// }
}

View File

@@ -0,0 +1,30 @@
package net.t2code.t2codelib.VELOCITY.api.commands;
import com.velocitypowered.api.command.CommandManager;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.ConsoleCommandSource;
import com.velocitypowered.api.proxy.ProxyServer;
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
import org.slf4j.Logger;
public class T2CVcmd {
public static ProxyServer server = T2CodeVMain.server;
public static Logger logger = T2CodeVMain.logger;
public static void Console(String cmd) {
// Get the console command source
ConsoleCommandSource console = server.getConsoleCommandSource();
// Dispatch the command
server.getCommandManager().executeAsync(console, cmd).join();
}
public static void Player(CommandSource player, String cmd) {
CommandManager commandManager = server.getCommandManager();
// Dispatch the command
commandManager.executeImmediatelyAsync(player, cmd);
}
}

View File

@@ -0,0 +1,88 @@
package net.t2code.t2codelib.VELOCITY.api.commands;
//
//import net.md_5.bungee.api.CommandSender;
//import net.md_5.bungee.api.ProxyServer;
//import net.md_5.bungee.api.connection.ProxiedPlayer;
//
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//
public class T2CVtab {
//
//
// 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());
// }
// }
// }
//
// 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[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);
// }
// }
// }
//
// 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[arg])) {
// matches.add(command);
// }
// return matches;
// }
//
// public static Boolean passend(String command, String arg) {
// for (int i = 0; i < arg.toUpperCase().length(); i++) {
// if (arg.toUpperCase().length() >= command.toUpperCase().length()) {
// return false;
// } else {
// if (arg.toUpperCase().charAt(i) != command.toUpperCase().charAt(i)) {
// return false;
// }
// }
// }
// return true;
// }
//
// public static boolean hasPermission(CommandSender sender, String permission) {
// String[] Permissions = permission.split(";");
// for (String perm : Permissions) {
// if (sender.hasPermission(perm)) {
// return true;
// }
// }
// return false;
// }
}

View File

@@ -0,0 +1,58 @@
package net.t2code.t2codelib.VELOCITY.api.messages;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.plugin.PluginContainer;
import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.VELOCITY.api.update.T2CVupdateAPI;
import java.util.Optional;
public class T2CBtemplate {
public static Long onLoadHeader(String prefix, String autor, String version, String spigot, String discord) {
Long long_ = Long.valueOf(System.currentTimeMillis());
T2CVsend.console(prefix + "§4============================= " + prefix + " §4=============================");
T2CVsend.console(prefix + " §2Autor: §6" + autor.replace("[", "").replace("]", ""));
T2CVsend.console(prefix + " §2Version: §6" + version);
T2CVsend.console(prefix + " §2Spigot: §6" + spigot);
T2CVsend.console(prefix + " §2Discord: §6" + discord);
T2CVsend.console(prefix + " §8-------------------------------");
return long_;
}
public static void onLoadSeparateStroke(String prefix) {
T2CVsend.console(prefix + " §8-------------------------------");
}
public static void onLoadFooter(String prefix, Long long_) {
T2CVsend.console(prefix + " §8-------------------------------");
T2CVsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
T2CVsend.console(prefix + "§4============================= " + prefix + " §4=============================");
}
public static void onDisable(String prefix, String autor, String version, String spigot, String discord) {
T2CVsend.console(prefix + "§4============================= " + prefix + " §4=============================");
T2CVsend.console(prefix + " §2Autor: §6" + autor.replace("[", "").replace("]", ""));
T2CVsend.console(prefix + " §2Version: §6" + version);
T2CVsend.console(prefix + " §2Spigot: §6" + spigot);
T2CVsend.console(prefix + " §2Discord: §6" + discord);
T2CVsend.console(prefix + " §4Plugin successfully disabled.");
T2CVsend.console(prefix + "§4============================= " + prefix + " §4=============================");
}
public static void sendInfo(CommandSource sender, PluginContainer plugin, String prefix, String spigot, String discord, String autor) {
T2CupdateWebData webData = T2CVupdateAPI.bungeePluginVersins.get(plugin.getDescription().getName()).webData;
String pluginVersion = String.valueOf(plugin.getDescription().getVersion());
T2CVsend.sender(sender, prefix + "§4======= " + prefix + " §4=======");
T2CVsend.sender(sender, prefix + " §2Autor: §6" + autor);
if (webData.getVersion().equalsIgnoreCase(pluginVersion)) {
T2CVsend.sender(sender, prefix + " §2Version: §6" + pluginVersion);
} else {
T2CVupdateAPI.sendUpdateMsg(prefix, discord, webData, Optional.of(plugin), sender);
}
T2CVsend.sender(sender, prefix + " §2Spigot: §6" + spigot);
T2CVsend.sender(sender, prefix + " §2Discord: §6" + discord);
T2CVsend.sender(sender, prefix + "§4======= " + prefix + " §4=======");
}
}

View File

@@ -0,0 +1,34 @@
package net.t2code.t2codelib.VELOCITY.api.messages;
import java.util.ArrayList;
import java.util.List;
public class T2CVreplace {
public static String replace(String prefix, String Text) {
return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä");
}
public static List<String> replace(String prefix, List<String> Text) {
List<String> output = new ArrayList<>();
for (String input : Text) {
output.add(input.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä"));
}
return output;
}
public static List replacePrice(String prefix,List<String> Text, String price) {
List rp = new ArrayList();
for (String s : Text) {
rp.add(s.replace("[prefix]", prefix).replace("&", "§")
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[price]", String.valueOf(price)));
}
return rp;
}
}

View File

@@ -0,0 +1,67 @@
package net.t2code.t2codelib.VELOCITY.api.messages;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.title.Title;
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
import org.slf4j.Logger;
import java.util.Optional;
public class T2CVsend {
public static ProxyServer server = T2CodeVMain.server;
public static Logger logger = T2CodeVMain.logger;
public static void console(String msg) {
logger.info(msg);
}
public static void player(Player player, String msg) {
player.sendMessage(Component.text(msg));
}
public static void title(Player player, Title msg) {
player.showTitle(msg);
}
public static void sender(CommandSource sender, String msg) {
sender.sendMessage(Component.text( msg));
}
public static void debug(Optional<PluginContainer> plugin, String msg) {
debug(plugin, msg, null);
}
public static void debug(Optional<PluginContainer> plugin, String msg, Integer stage) {
// if (!new File(Main.getPath(), "config.yml").exists()) return;
// if (stage == null) {
// if (plugin.getConfig().getBoolean("Plugin.Debug")) {
// ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg);
// }
// return;
//}
//if (plugin.getConfig().getInt("Plugin.Debug") >= stage) {
// ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg);
//}
}
public static void debugmsg(PluginContainer plugin, String msg) {
logger.info("{} §5DEBUG-MSG: §6{}", plugin.getDescription().getName(), msg);
}
public static void info(PluginContainer plugin, String msg) {
logger.info("{} {}", plugin.getDescription().getName(), msg);
}
public static void warning(PluginContainer plugin, String msg) {
logger.warn("{} {}", plugin.getDescription().getName(), msg);
}
public static void error(PluginContainer plugin, String msg) {
logger.error("{} {}", plugin.getDescription().getName(), msg);
}
}

View File

@@ -0,0 +1,55 @@
package net.t2code.t2codelib.VELOCITY.api.pluginMessaging;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import net.t2code.t2codelib.VELOCITY.api.commands.T2CVcmd;
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
import org.slf4j.Logger;
public class T2CplmsgBcmd {
public static ProxyServer server = T2CodeVMain.server;
public static Logger logger = T2CodeVMain.logger;
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
server.getChannelRegistrar().register(T2CodeVMain.bcmd);
// server.getChannelRegistrar().register(IDENTIFIER2);
}
@Subscribe
public void onPluginMessageFromPlayer(PluginMessageEvent event) {
if (event.getIdentifier() != T2CodeVMain.bcmd) {
return;
}
ByteArrayDataInput stream = ByteStreams.newDataInput(event.getData());
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")) {
logger.info("{} [{}] T2C BCMD Command Console: {}", T2CodeVMain.prefix, serverID, input);
T2CVcmd.Console(input);
} else {
Player player = server.getPlayer(channel).orElse(null);
if (player != null) {
logger.info("{} [{}] T2C BCMD Command {}: {}", T2CodeVMain.prefix, serverID, player, input);
T2CVcmd.Player(player, input);
}
}
event.setResult(PluginMessageEvent.ForwardResult.handled());
}
}

View File

@@ -0,0 +1,55 @@
package net.t2code.t2codelib.VELOCITY.api.pluginMessaging.autoResponse;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import net.t2code.t2codelib.VELOCITY.api.commands.T2CVcmd;
import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend;
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
import org.slf4j.Logger;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
public class T2CapiAutoResponse {
public static ProxyServer server = T2CodeVMain.server;
public static Logger logger = T2CodeVMain.logger;
@Subscribe
public void onPluginmessage(PluginMessageEvent event) {
if (event.getIdentifier() != T2CodeVMain.aresp) {
return;
}
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
try {
String channel = stream.readUTF();
String input = stream.readUTF();
switch (channel) {
case "ConC":
logger.info("Command Console: {}", input);
T2CVcmd.Console(input);
break;
case "ALLPMSG":
for (Player player : server.getAllPlayers()) {
T2CVsend.player(player, input);
}
break;
default:
Player player = server.getPlayer(channel).orElse(null);
if (player != null) {
logger.info("Command Console: {}", input);
T2CVcmd.Player(player, input);
}
break;
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,68 @@
package net.t2code.t2codelib.VELOCITY.api.pluginMessaging.commandgui;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.event.connection.PostLoginEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
import org.slf4j.Logger;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class T2CVapiCGUI {
public static ProxyServer server = T2CodeVMain.server;
public static Logger logger = T2CodeVMain.logger;
@Subscribe
public void onJoin(PostLoginEvent event) {
Player player = event.getPlayer();
sendToSpigotPlayer(player.getUsername(), true);
}
@Subscribe
public void onDisconnect(DisconnectEvent event) {
Player player = event.getPlayer();
sendToSpigotPlayer(player.getUsername(), false);
}
public void sendToSpigotPlayer(String name, Boolean join) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream);
try {
if (join) {
output.writeUTF("join");
} else {
output.writeUTF("left");
}
output.writeUTF(name);
} catch (IOException e) {
logger.warn(e.getMessage());
}
byte[] data = stream.toByteArray();
for (RegisteredServer server : server.getAllServers()) {
server.sendPluginMessage(T2CodeVMain.cguiopl, data);
}
}
public static void sendToSpigotDeleteAll() {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream);
try {
output.writeUTF("clear");
output.writeUTF("");
} catch (IOException e) {
logger.warn(e.getMessage());
}
byte[] data = stream.toByteArray();
for (RegisteredServer server : server.getAllServers()) {
server.sendPluginMessage(T2CodeVMain.cguiopl, data);
}
}
}

View File

@@ -0,0 +1,50 @@
package net.t2code.t2codelib.VELOCITY.api.pluginMessaging.opSecurity;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
import java.io.*;
import java.util.logging.Logger;
public class T2CapiOpSecurity {
public static ProxyServer server = T2CodeVMain.server;
@Subscribe
public void onPluginmessage(PluginMessageEvent event) {
if (event.getIdentifier() != T2CodeVMain.opsec) {
return;
}
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
try {
String channel = stream.readUTF();
String mode = stream.readUTF();
String information = stream.readUTF();
if (channel.equals("T2Cconsole")) {
sendToSpigotPlayer(channel,mode,information);
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static void sendToSpigotPlayer(String channel,String mode,String information) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream);
try {
output.writeUTF(channel);
output.writeUTF(mode);
output.writeUTF(information);
} catch (IOException e) {
Logger.getLogger(e.getMessage());
}
for (RegisteredServer server : server.getAllServers()) {
server.sendPluginMessage(T2CodeVMain.opsec, stream.toByteArray());
}
}
}

View File

@@ -0,0 +1,107 @@
package net.t2code.t2codelib.VELOCITY.api.proxyPlayers;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.connection.PostLoginEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayersEnum;
import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend;
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
import java.io.*;
import java.util.logging.Logger;
public class T2CVPlayers {
public static ProxyServer server = T2CodeVMain.server;
public static org.slf4j.Logger logger = T2CodeVMain.logger;
@Subscribe
public void onJoin(PostLoginEvent e) {
sendToSpigotPlayer(e.getPlayer().getUsername(), T2CbungeePlayersEnum.JOIN, "");
}
@Subscribe
public void onDisconnect(DisconnectEvent e) {
sendToSpigotPlayer(e.getPlayer().getUsername(), T2CbungeePlayersEnum.QUIT, "");
}
public void sendToSpigotPlayer(String name, T2CbungeePlayersEnum value, String uuid) {
switch (value) {
case JOIN:
case QUIT:
sendToSpigotPlayerExecute(name, value, uuid);
break;
case GIVEALL:
StringBuilder input = new StringBuilder();
for (Player player : server.getAllPlayers()) {
input.append(player.getUsername()).append(";");
}
sendToSpigotPlayerExecute(input.toString(), T2CbungeePlayersEnum.GIVEALL, uuid);
break;
}
}
private void sendToSpigotPlayerExecute(String name, T2CbungeePlayersEnum value, String uuid) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream);
try {
output.writeUTF(value.name());
output.writeUTF(name);
output.writeUTF(uuid);
} catch (IOException e) {
Logger.getLogger(e.getMessage());
}
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received channel: t2c:bonlp");
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received subChannel: " + value.name());
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received input: " + name);
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received input2/uuid: " + uuid);
byte[] data = stream.toByteArray();
for (RegisteredServer server : server.getAllServers()) {
server.sendPluginMessage(T2CodeVMain.bonlp, data);
}
}
public static void sendToSpigotDeleteAll() {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream);
try {
output.writeUTF(T2CbungeePlayersEnum.CLEAR.name());
output.writeUTF("");
output.writeUTF("");
} catch (IOException e) {
Logger.getLogger(e.getMessage());
}
byte[] data = stream.toByteArray();
for (RegisteredServer server : server.getAllServers()) {
server.sendPluginMessage(T2CodeVMain.bonlp, data);
}
}
@Subscribe
public void onPluginMessage(PluginMessageEvent event) {
if (event.getIdentifier() != T2CodeVMain.bonlp) {
return;
}
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
try {
T2CbungeePlayersEnum subChannel = T2CbungeePlayersEnum.valueOf(stream.readUTF());
String input = stream.readUTF();
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received channel: " + T2CodeVMain.bonlp);
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received subChannel: " + subChannel.name());
T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received input/uuid: " + input);
sendToSpigotPlayer("", subChannel, input);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,79 @@
package net.t2code.t2codelib.VELOCITY.api.update;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.proxy.ProxyServer;
import net.t2code.t2codelib.T2CVupdateObject;
import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.UpdateType;
import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend;
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
import java.util.HashMap;
import java.util.Optional;
public class T2CVupdateAPI {
public static HashMap<Optional<String>, T2CVupdateObject> bungeePluginVersins = new HashMap<>();
public static ProxyServer server = T2CodeVMain.server;
public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Optional<PluginContainer> plugin, CommandSource sender) {
String publicVersion = webData.getVersion();
String pluginVersion = String.valueOf(plugin.get().getDescription().getVersion());
String value;
if (webData.isPreRelease()) {
value = UpdateType.PRERELEASE.text;
if (publicVersion.toLowerCase().contains("dev")) {
value = UpdateType.DEVELOPMENT.text;
}
if (publicVersion.toLowerCase().contains("beta")) {
value = UpdateType.BETA.text;
}
if (publicVersion.toLowerCase().contains("snapshot")) {
value = UpdateType.SNAPSHOT.text;
}
} else value = UpdateType.STABLE.text;
String h = "<br><dark_red>╔══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
String s1 = "<br><dark_red>║</dark_red> <gold>A new [value] version was found!</gold>".replace("[value]", value);
String s2 = "<br><dark_red>║</dark_red> <gold>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</gold> <green>" + webData.getVersion() + "</green>";
String s3 = "<br><dark_red>║</dark_red> <gold>You can download it here:</gold> <yellow>" + webData.getUpdateUrl() + "</yellow>";
String s4 = "<br><dark_red>║</dark_red> <gold>You can find more information on Discord:</gold> <yellow>" + discord + "</yellow>";
String f = "<br><dark_red>╚══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
String text = h + s1 + s2 + s3 + s4 + f;
if (sender == null) {
T2CVsend.console(text);
} else T2CVsend.sender(sender, text);
}
private static Boolean noUpdate = true;
private static String pluginVersion;
public static void checkForUpdates(Optional<PluginContainer> plugin, String prefix, String discord, Integer spigotID, String url) {
// if (T2CVlibConfig.getUpdateCheckFullDisable()) return;
(new T2CVupdateCheckerGit(plugin, spigotID)).getVersion((webData) -> {
pluginVersion = T2CodeVMain.version;
T2CVupdateObject update = new T2CVupdateObject(
plugin.get().getDescription().getName(),
plugin.get().getDescription().getVersion(),
webData,
false,
!plugin.get().getDescription().getVersion().equals(webData.getVersion()),
true
);
bungeePluginVersins.put(plugin.get().getDescription().getName(), update);
if (!pluginVersion.replace("_Bungee", "").equalsIgnoreCase(webData.getVersion())) {
sendUpdateMsg(prefix, discord, webData, plugin, null);
noUpdate = true;
} else {
if (noUpdate) {
T2CVsend.console(prefix + " §2No update found.");
noUpdate = false;
}
}
}, pluginVersion, spigotID, url);
}
}

View File

@@ -0,0 +1,102 @@
package net.t2code.t2codelib.VELOCITY.api.update;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.proxy.ProxyServer;
import net.t2code.t2codelib.T2CVupdateObject;
import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Optional;
import java.util.function.Consumer;
public class T2CVupdateCheckerGit {
private Optional<PluginContainer> plugin;
private int resourceId;
public static ProxyServer server = T2CodeVMain.server;
public static Logger logger = T2CodeVMain.logger;
public T2CVupdateCheckerGit(Optional<PluginContainer> plugin, int resourceId) {
this.plugin = plugin;
this.resourceId = resourceId;
}
public void getVersion(Consumer<T2CupdateWebData> consumer, String pluginVersion, Integer spigotID, String gitKey) {
// if (T2CVlibConfig.getUpdateCheckFullDisable()) return;
String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1";
// if (!T2CVlibConfig.getSeePreReleaseUpdates()) {
RepoURL = RepoURL + "&pre-release=false";
// }
String finalRepoURL = RepoURL;
try {
URL url = new URL(finalRepoURL);
URLConnection yc = url.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
String data = "";
while ((inputLine = in.readLine()) != null)
data = inputLine;
in.close();
data = data.substring(1, data.length() - 1);
if (data.isEmpty()) {
consumer.accept(null);
return;
}
JSONObject obj = new JSONObject(data);
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 publishedAt = outputFormat.format(parsedDate);
JSONArray downloadArray = obj.getJSONArray("assets");
String gitURL = updateUrl;
String downloadURL;
if (downloadArray.isEmpty()) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
} else {
downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url");
}
if (!preRelease) {
downloadURL = "https://www.spigotmc.org/resources/" + spigotID;
updateUrl = "https://www.spigotmc.org/resources/" + spigotID;
}
T2CupdateWebData webData = new T2CupdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease);
consumer.accept(webData);
} catch (Exception var10) {
Boolean load = false;
if (T2CVupdateAPI.bungeePluginVersins.containsKey(plugin.get().getDescription().getName())) {
load = T2CVupdateAPI.bungeePluginVersins.get(plugin.get().getDescription().getName()).load;
}
T2CVupdateObject update = new T2CVupdateObject(
plugin.get().getDescription().getName(),
Optional.ofNullable(pluginVersion),
null,
load,
false,
true
);
T2CVupdateAPI.bungeePluginVersins.put(plugin.get().getDescription().getName(), update);
logger.info("§4 Cannot look for updates: {}", var10.getMessage());
}
}
}

View File

@@ -0,0 +1,86 @@
package net.t2code.t2codelib.VELOCITY.api.yaml;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.plugin.PluginContainer;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.slf4j.Logger;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
public class T2CVconfig {
private final Path configPath;
private final @NonNull YAMLConfigurationLoader loader;
private CommentedConfigurationNode configNode;
public T2CVconfig(Path configPath, ProxyServer proxy, PluginContainer pluginContainer, Logger logger) {
this.configPath = configPath;
loader = YAMLConfigurationLoader.builder().setPath(configPath).build();
try {
this.configNode = (CommentedConfigurationNode) loader.load();
} catch (IOException e) {
logger.error("Error loading configuration file {}", configPath.getFileName(), e);
}
}
public void saveConfig() {
try {
loader.save(configNode);
} catch (IOException e) {
throw new RuntimeException("Error saving configuration file " + configPath.getFileName(), e);
}
}
public void set(String path, Object value) {
configNode.getNode((Object[]) path.split("\\.")).setValue(value);
}
public String select(String path) {
return configNode.getNode((Object[]) path.split("\\.")).getString();
}
public int selectInt(String path) {
return configNode.getNode((Object[]) path.split("\\.")).getInt();
}
public boolean selectBoolean(String path) {
return configNode.getNode((Object[]) path.split("\\.")).getBoolean();
}
public double selectDouble(String path) {
return configNode.getNode((Object[]) path.split("\\.")).getDouble();
}
public List<String> selectList(String path) {
List<String> list = new ArrayList<>();
ConfigurationNode node = configNode.getNode((Object[]) path.split("\\."));
if (node.hasListChildren()) {
for (ConfigurationNode child : node.getChildrenList()) {
list.add(child.getString(""));
}
}
return list;
}
public List<String> selectList(String prefix, String path) {
List<String> output = new ArrayList<>();
ConfigurationNode node = configNode.getNode((Object[]) path.split("\\."));
if (node.hasListChildren()) {
for (ConfigurationNode child : node.getChildrenList()) {
output.add(prefix + child.getString());
}
}
return output;
}
public void setList(List<String> value, String path) {
configNode.getNode((Object[]) path.split("\\.")).setValue(value);
}
}

View File

@@ -0,0 +1,65 @@
package net.t2code.t2codelib.VELOCITY.system;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.proxy.ProxyServer;
import net.t2code.t2codelib.VELOCITY.api.proxyPlayers.T2CVPlayers;
import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend;
import net.t2code.t2codelib.VELOCITY.system.config.VelocityConfig;
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.commandgui.T2CVapiCGUI;
import org.slf4j.Logger;
import java.util.Optional;
public class T2CVload {
public static ProxyServer server = T2CodeVMain.server;
public static Logger logger = T2CodeVMain.logger;
public static void onLoad(Optional<PluginContainer> plugin, String prefix, String version, String spigot, String discord, Integer spigotID, Integer bstatsID, String url) {
long long_ = System.currentTimeMillis();
T2CVsend.console(prefix + "§4============================= " + prefix + " §4=============================");
// T2CVsend.console(prefix + " §2Autor: §6" + String.valueOf(plugin.get().getDescription().getAuthors()).replace("[", "").replace("]", ""));
T2CVsend.console(prefix + " §2Version: §6" + version);
T2CVsend.console(prefix + " §2Spigot: §6" + spigot);
T2CVsend.console(prefix + " §2Discord: §6" + discord);
//T2CVlibConfig.create();
VelocityConfig.main();
// try {
// T2CVlibConfig.select();
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
//API
server.getChannelRegistrar().register(T2CodeVMain.bcmd);
server.getChannelRegistrar().register(T2CodeVMain.bonlp);
T2CVPlayers.sendToSpigotDeleteAll();
// if (T2CVlibConfig.getApiCommandGUIEnable()) {
server.getChannelRegistrar().register(T2CodeVMain.cguiopl);
T2CVapiCGUI.sendToSpigotDeleteAll();
// }
// if (T2CVlibConfig.getApiAutoResponse()) {
server.getChannelRegistrar().register(T2CodeVMain.aresp);
// }
// if (T2CVlibConfig.getApiOpSecurity()) {
server.getChannelRegistrar().register(T2CodeVMain.opsec);
//}
T2CVsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
T2CVsend.console(prefix + "§4============================= " + prefix + " §4=============================");
}
}

View File

@@ -0,0 +1,81 @@
package net.t2code.t2codelib.VELOCITY.system;
import com.google.inject.Inject;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import com.velocitypowered.api.scheduler.Scheduler;
import net.t2code.t2codelib.Util;
import net.t2code.t2codelib.VELOCITY.api.proxyPlayers.T2CVPlayers;
import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend;
import net.t2code.t2codelib.VELOCITY.api.update.T2CVupdateAPI;
import org.slf4j.Logger;
import java.io.IOException;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
public class T2CodeVMain {
public static Optional<PluginContainer> pluginContainer;
public static final String prefix = "[T2CodeLib]";
public static ProxyServer server;
public static Logger logger;
public static final MinecraftChannelIdentifier bcmd = MinecraftChannelIdentifier.from("t2c:bcmd");
public static final MinecraftChannelIdentifier bonlp = MinecraftChannelIdentifier.from("t2c:bonlp");
public static final MinecraftChannelIdentifier cguiopl = MinecraftChannelIdentifier.from("t2c:cguiopl");
public static final MinecraftChannelIdentifier aresp = MinecraftChannelIdentifier.from("t2c:aresp");
public static final MinecraftChannelIdentifier opsec = MinecraftChannelIdentifier.from("t2c:opsec");
@Inject
public T2CodeVMain(ProxyServer server, Logger logger) throws IOException {
// Plugin startup logic
T2CodeVMain.server = server;
T2CodeVMain.logger = logger;
pluginContainer = server.getPluginManager().getPlugin("t2codelib");
// orgVersion = plugin.getDescription().getVersion();
// autor = plugin.getDescription().getAuthor();
int pluginId = Util.getBstatsID();
// T2CVmetrics metrics = metricsFactory.make(this, pluginId);
}
@Subscribe
public void onProxyShutdown(ProxyShutdownEvent event) {
// Plugin shutdown logic
T2CVPlayers.sendToSpigotDeleteAll();
T2CVsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4=============================");
T2CVsend.console(Util.getPrefix() + " §2Autor: §6" + String.valueOf(pluginContainer.get().getDescription().getAuthors()).replace("[", "").replace("]", ""));
T2CVsend.console(Util.getPrefix() + " §2Spigot: §6" + Util.getSpigot());
T2CVsend.console(Util.getPrefix() + " §2Discord: §6" + Util.getDiscord());
T2CVsend.console(Util.getPrefix() + " §4Plugin successfully disabled.");
T2CVsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4=============================");
}
@Subscribe
public void onProxyInitialize(ProxyInitializeEvent event) {
// Schedule the task to check for updates every 60 minutes
Scheduler scheduler = server.getScheduler();
scheduler.buildTask(this, this:: checkForUpdates)
.repeat(60, TimeUnit.MINUTES)
.schedule();
}
private void checkForUpdates() {
T2CVupdateAPI.checkForUpdates(pluginContainer, prefix, Util.getDiscord(), Util.getSpigotID(), Util.getGit());
}
}

View File

@@ -0,0 +1,134 @@
package net.t2code.t2codelib.VELOCITY.system.bstats;
import com.google.inject.Inject;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.plugin.PluginDescription;
import com.velocitypowered.api.plugin.annotation.DataDirectory;
import com.velocitypowered.api.proxy.ProxyServer;
import org.bstats.MetricsBase;
import org.bstats.charts.CustomChart;
import org.bstats.config.MetricsConfig;
import org.bstats.json.JsonObjectBuilder;
import org.slf4j.Logger;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
public class T2CVmetrics {
/**
* A factory to create new Metrics classes.
*/
public static class Factory {
private final ProxyServer server;
private final Logger logger;
private final Path dataDirectory;
// The constructor is not meant to be called by the user.
// The instance is created using Dependency Injection
@Inject
private Factory(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
this.server = server;
this.logger = logger;
this.dataDirectory = dataDirectory;
}
/**
* Creates a new Metrics class.
*
* @param plugin The plugin instance.
* @param serviceId The id of the service.
* It can be found at <a href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
* <p>Not to be confused with Velocity's {@link PluginDescription#getId()} method!
* @return A Metrics instance that can be used to register custom charts.
* <p>The return value can be ignored, when you do not want to register custom charts.
*/
public T2CVmetrics make(Object plugin, int serviceId) {
return new T2CVmetrics(plugin, server, logger, dataDirectory, serviceId);
}
}
private final PluginContainer pluginContainer;
private final ProxyServer server;
private MetricsBase metricsBase;
private T2CVmetrics(Object plugin, ProxyServer server, Logger logger, Path dataDirectory, int serviceId) {
pluginContainer = server.getPluginManager().fromInstance(plugin)
.orElseThrow(() -> new IllegalArgumentException("The provided instance is not a plugin"));
this.server = server;
File configFile = dataDirectory.getParent().resolve("bStats").resolve("config.txt").toFile();
MetricsConfig config;
try {
config = new MetricsConfig(configFile, true);
} catch (IOException e) {
logger.error("Failed to create bStats config", e);
return;
}
metricsBase = new MetricsBase(
"velocity",
config.getServerUUID(),
serviceId,
config.isEnabled(),
this::appendPlatformData,
this::appendServiceData,
task -> server.getScheduler().buildTask(plugin, task).schedule(),
() -> true,
logger::warn,
logger::info,
config.isLogErrorsEnabled(),
config.isLogSentDataEnabled(),
config.isLogResponseStatusTextEnabled()
);
if (!config.didExistBefore()) {
// Send an info message when the bStats config file gets created for the first time
logger.info("Velocity and some of its plugins collect metrics and send them to bStats (https://bStats.org).");
logger.info("bStats collects some basic information for plugin authors, like how many people use");
logger.info("their plugin and their total player count. It's recommend to keep bStats enabled, but");
logger.info("if you're not comfortable with this, you can opt-out by editing the config.txt file in");
logger.info("the '/plugins/bStats/' folder and setting enabled to false.");
}
}
/**
* Shuts down the underlying scheduler service.
*/
public void shutdown() {
metricsBase.shutdown();
}
/**
* Adds a custom chart.
*
* @param chart The chart to add.
*/
public void addCustomChart(CustomChart chart) {
if (metricsBase != null) {
metricsBase.addCustomChart(chart);
}
}
private void appendPlatformData(JsonObjectBuilder builder) {
builder.appendField("playerAmount", server.getPlayerCount());
builder.appendField("managedServers", server.getAllServers().size());
builder.appendField("onlineMode", server.getConfiguration().isOnlineMode() ? 1 : 0);
builder.appendField("velocityVersionVersion", server.getVersion().getVersion());
builder.appendField("velocityVersionName", server.getVersion().getName());
builder.appendField("velocityVersionVendor", server.getVersion().getVendor());
builder.appendField("javaVersion", System.getProperty("java.version"));
builder.appendField("osName", System.getProperty("os.name"));
builder.appendField("osArch", System.getProperty("os.arch"));
builder.appendField("osVersion", System.getProperty("os.version"));
builder.appendField("coreCount", Runtime.getRuntime().availableProcessors());
}
private void appendServiceData(JsonObjectBuilder builder) {
builder.appendField("pluginVersion", pluginContainer.getDescription().getVersion().orElse("unknown"));
}
}

View File

@@ -0,0 +1,60 @@
package net.t2code.t2codelib.VELOCITY.system.config;
public class T2CVlibConfig {
// public static void create() throws IOException {
// long startTime = System.currentTimeMillis();
// Path configFile = Paths.get("config.yml");
//
// if (!T2CodeVMain.getPlugin().getDataFolder().exists()) {
// T2CodeVMain.getPlugin().getDataFolder().mkdir();
// }
//
// if (!configFile.exists()) {
// configFile.createNewFile();
// }
//
// Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
//
// configuration.set("UpdateCheck.TimerInMin", 60);
// configuration.set("UpdateCheck.SeePreReleaseUpdates", true);
// configuration.set("Plugin.UpdateCheck.AllPlugins.FullDisable", false);
//
// configuration.set("API.CommandGUI.Enable", false);
// configuration.set("API.AutoResponse.Enable", false);
// configuration.set("API.OPSecurity.Enable", false);
//
// ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, configFile);
//
// long elapsedTime = System.currentTimeMillis() - startTime;
// T2CVsend.console(Util.getPrefix() + " §2config.yml was successfully created / updated. §7- §e" + elapsedTime + "ms");
// }
//
// public static void select() throws IOException {
// File configFile = new File(T2CodeVMain.getPlugin().getDataFolder(), "config.yml");
// Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
//
// updateTimer = configuration.getInt("UpdateCheck.TimerInMin");
// seePreReleaseUpdates = configuration.getBoolean("UpdateCheck.SeePreReleaseUpdates");
// updateCheckFullDisable = configuration.getBoolean("Plugin.UpdateCheck.AllPlugins.FullDisable");
//
// apiCommandGUIEnable = configuration.getBoolean("API.CommandGUI.Enable");
// apiAutoResponse = configuration.getBoolean("API.AutoResponse.Enable");
// apiOpSecurity = configuration.getBoolean("API.OPSecurity.Enable");
// }
//
//
// @Getter
// private static Integer updateTimer;
// @Getter
// private static Boolean seePreReleaseUpdates;
// @Getter
// private static Boolean updateCheckFullDisable;
// @Getter
// private static Boolean apiCommandGUIEnable;
// @Getter
// private static Boolean apiAutoResponse;
// @Getter
// private static Boolean apiOpSecurity;
//
}

View File

@@ -0,0 +1,131 @@
package net.t2code.t2codelib.VELOCITY.system.config;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class VelocityConfig {
private static final String CONFIG_FILE = "plugin_config.yml";
private String pluginName;
private int maxConnections;
private boolean isEnabled;
private boolean debugMode;
private int timeoutSeconds;
public VelocityConfig(String pluginName, int maxConnections, boolean isEnabled, boolean debugMode, int timeoutSeconds) {
this.pluginName = pluginName;
this.maxConnections = maxConnections;
this.isEnabled = isEnabled;
this.debugMode = debugMode;
this.timeoutSeconds = timeoutSeconds;
}
public static VelocityConfig loadConfig() {
Path configFile = Paths.get(CONFIG_FILE);
if (!Files.exists(configFile)) {
// Default configuration if file doesn't exist
return new VelocityConfig("MyPlugin", 100, true, false, 30);
}
try {
// Read configuration from file
String content = Files.readString(configFile);
String[] lines = content.split("\\r?\\n");
// Parse the configuration
String pluginName = lines[0].split(":")[1].trim();
int maxConnections = Integer.parseInt(lines[1].split(":")[1].trim());
boolean isEnabled = Boolean.parseBoolean(lines[2].split(":")[1].trim());
boolean debugMode = Boolean.parseBoolean(lines[3].split(":")[1].trim());
int timeoutSeconds = Integer.parseInt(lines[4].split(":")[1].trim());
return new VelocityConfig(pluginName, maxConnections, isEnabled, debugMode, timeoutSeconds);
} catch (IOException | ArrayIndexOutOfBoundsException | NumberFormatException e) {
e.printStackTrace();
// Handle exception: default configuration or logging
return new VelocityConfig("MyPlugin", 100, true, false, 30);
}
}
public void saveConfig() {
Path configFile = Paths.get(CONFIG_FILE);
try {
// Write configuration to file
String configContent = "pluginName: " + pluginName + "\n"
+ "maxConnections: " + maxConnections + "\n"
+ "isEnabled: " + isEnabled + "\n"
+ "debugMode: " + debugMode + "\n"
+ "timeoutSeconds: " + timeoutSeconds + "\n";
Files.writeString(configFile, configContent);
} catch (IOException e) {
e.printStackTrace();
// Handle exception: logging or alerting
}
}
// Getters and setters
public String getPluginName() {
return pluginName;
}
public void setPluginName(String pluginName) {
this.pluginName = pluginName;
}
public int getMaxConnections() {
return maxConnections;
}
public void setMaxConnections(int maxConnections) {
this.maxConnections = maxConnections;
}
public boolean isEnabled() {
return isEnabled;
}
public void setEnabled(boolean enabled) {
isEnabled = enabled;
}
public boolean isDebugMode() {
return debugMode;
}
public void setDebugMode(boolean debugMode) {
this.debugMode = debugMode;
}
public int getTimeoutSeconds() {
return timeoutSeconds;
}
public void setTimeoutSeconds(int timeoutSeconds) {
this.timeoutSeconds = timeoutSeconds;
}
public static void main() {
// Example usage:
VelocityConfig config = VelocityConfig.loadConfig();
System.out.println("Loaded Configuration:");
System.out.println("Plugin Name: " + config.getPluginName());
System.out.println("Max Connections: " + config.getMaxConnections());
System.out.println("Is Enabled: " + config.isEnabled());
System.out.println("Debug Mode: " + config.isDebugMode());
System.out.println("Timeout Seconds: " + config.getTimeoutSeconds());
// Modify configuration
config.setMaxConnections(150);
config.setEnabled(false);
config.setDebugMode(true);
config.setTimeoutSeconds(60);
// Save configuration
config.saveConfig();
System.out.println("Configuration saved.");
}
}

View File

@@ -1,5 +1,18 @@
name: T2CodeLib
version: ${project.version}
main: net.t2code.t2codelib.BUNGEE.system.T2CodeBMain
main: net.t2code.t2codelib.bungee.system.T2CodeBMain
author: JaTiTV, Jkobs
description: Library from T2Code Plugins
description: Library from T2Code Plugins
_______ ___ _____ _ _
|__ __|__ \ / ____| | | | |
| | ) | | ___ __| | ___ _ __ ___| |_
| | / /| | / _ \ / _` |/ _ \ | '_ \ / _ \ __|
| | / /_| |___| (_) | (_| | __/_| | | | __/ |_
|_| |____|\_____\___/ \__,_|\___(_)_| |_|\___|\__|

View File

@@ -1,11 +1,11 @@
name: T2CodeLib
version: '${project.version}'
main: net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain
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

View File

@@ -0,0 +1 @@
{"id":"t2codelib","name":"T2CodeLib","version":"${project.version}","authors":["JaTiTV"],"dependencies":[],"main":"net.t2code.t2codelib.VELOCITY.system.T2CodeVMain"}