Compare commits

...

60 Commits
test ... 14.6

Author SHA1 Message Date
c4282817b0 14.6
Bugfix
T2CnameHistory API fix
2023-05-16 19:36:36 +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
47 changed files with 1629 additions and 477 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):**
---

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">

86
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>13.3</version>
<version>14.6</version>
<packaging>jar</packaging>
<name>T2CodeLib</name>
@@ -60,41 +60,49 @@
</build>
<repositories>
<repository>
<id>sonatype-oss-snapshots1</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</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>
@@ -103,26 +111,46 @@
<dependencies>
<!-- Mojang / Spigot-->
<!-- Spigot-->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<version>1.19.3-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.19-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<type>javadoc</type>
<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,33 +158,43 @@
<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.2</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.13.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.1.2</version>
<version>4.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bungeecord</artifactId>
<version>4.3.0</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
@@ -164,19 +202,21 @@
<version>1.18.24</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>
</dependencies>

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

@@ -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

@@ -4,110 +4,80 @@ 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.SPIGOT.system.config.config.SelectLibConfig;
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 UpdateName = obj.getString("name");
String tag_name = obj.getString("tag_name");
String body = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''");
String updateurl = obj.getString("html_url");
boolean prerelease = obj.getBoolean("prerelease");
String date = obj.getString("published_at");
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
Date parsedDate = inputFormat.parse(date);
String formattedDate = outputFormat.format(parsedDate);
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(UpdateName, tag_name, body, updateurl, formattedDate, 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,6 +5,7 @@ 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.api.bungeePlayers.T2CBbungeePlayers;
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;
@@ -13,7 +14,7 @@ import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.opSecurity.T2CapiOpSec
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 autor, 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("]", ""));
@@ -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,7 +1,9 @@
package net.t2code.t2codelib.BUNGEE.system;
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 {
@@ -16,6 +18,16 @@ public class T2CodeBMain extends Plugin {
private static String orgVersion;
private static String autor;
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() {
@@ -23,7 +35,14 @@ public class T2CodeBMain extends Plugin {
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());
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(), autor, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit());
String[] fv = orgVersion.split("_");
plugin.getDescription().setVersion(fv[0]);
version = plugin.getDescription().getVersion();
@@ -32,6 +51,13 @@ public class T2CodeBMain extends Plugin {
@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);
@@ -40,4 +66,7 @@ public class T2CodeBMain extends Plugin {
T2CBsend.console(Util.getPrefix() + " §4Plugin successfully disabled.");
T2CBsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4=============================");
}
public static Boolean getMmIsLoad() {
return mmIsLoad;
}
}

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

@@ -1,6 +1,6 @@
package net.t2code.t2codelib.BUNGEE.system.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;
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

@@ -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,24 +1,24 @@
package net.t2code.t2codelib.SPIGOT.api.commands;
import net.t2code.t2codelib.SPIGOT.system.BCommandSenderReciver;
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class T2Ccmd {
public static void console(String cmd) {
if (cmd.contains("!onBungee")){
BCommandSenderReciver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
T2CbungeeCommandSenderReciver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
}else Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
}
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);
T2CbungeeCommandSenderReciver.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);
T2CbungeeCommandSenderReciver.sendToBungee(player, cmd.replace("!onBungee", ""), false);
} else player.chat("/" + cmd);
}
}

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

@@ -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,77 @@
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.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.lang.reflect.Field;
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 ItemStack base64(String base64Value, Integer amount, String displayName, List<String> lore) {
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();
}
itemMeta.setDisplayName(displayName);
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
itemStack.setAmount(amount);
return itemStack;
}
}

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,25 @@
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) {
bukkitAudiences.sender(sender).sendMessage(replace(msg));
}
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(msg));
}
protected static Component replace(String text) {

View File

@@ -23,6 +23,47 @@ public class T2Creplace {
.replace("[nl]", "\n")));
}
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) {
object = PlaceholderAPI.setPlaceholders(player, replaceLegacyColor((String) object).replace("[prefix]", prefix).replace("[ue]", "ü")
.replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö")
.replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n"));
}
if (object instanceof List) {
List<String> in = (List<String>) object;
List<String> output = new ArrayList<>();
for (String input : in) {
output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")
.replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")
.replace("[nl]", "\n")));
}
object = output;
}
return object;
}
public static List<String> replace(String prefix, List<String> Text) {
List<String> output = new ArrayList<>();
for (String input : Text) {
@@ -35,7 +76,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");
}
@@ -52,7 +93,7 @@ public class T2Creplace {
}
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]", "ö")
@@ -82,7 +123,7 @@ public class T2Creplace {
}
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)
.replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö")

View File

@@ -1,5 +1,6 @@
package net.t2code.t2codelib.SPIGOT.api.messages;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -24,6 +25,29 @@ 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) {
String msg = String.valueOf(object);
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleConsole(msg);
}
public static void player(Player player, Object object) {
String msg = String.valueOf(object);
if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.modulePlayer(msg, player);
}
public static void sender(CommandSender sender, Object object) {
String msg = String.valueOf(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 +56,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) {

View File

@@ -1,6 +1,7 @@
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 org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@@ -24,31 +25,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 §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);
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();
}
}
}
@@ -82,26 +85,26 @@ public class T2Ctemplate {
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;
String publicVersion = T2CupdateAPI.pluginVersions.get(plugin.getName()).webData.getVersion();
boolean update = !publicVersion.equalsIgnoreCase(pluginVersion);
boolean player = sender instanceof Player;
String stPlugin = "<dark_red>|</dark_red> <yellow>Plugin:</yellow> <gold>[pl]</gold>".replace("[pl]", plugin.getName());
String stVersion = "<dark_red>|</dark_red> <yellow>Version:</yellow> <gold>[ver]</gold>".replace("[ver]", pluginVersion);
String stAutor = "<dark_red>|</dark_red> <yellow>Autor(s):</yellow> <gold>[autor]</gold>".replace("[autor]", plugin.getDescription().getAuthors().toString());
String stNVersion = "<dark_red>|</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]", publicVersion);
String stStable = "<dark_red>|</dark_red> <yellow>Stable version available:</yellow> [up]".replace("[up]", update ? "<dark_green>YES</dark_green>" : "<red>no</red>");
String stLinkPlayer = "<dark_red>|</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> "
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> "
.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 pr = premiumVerified != null ? "<br><dark_red></dark_red> <yellow>Premium verified:</yellow> [pr]".replace("[pr]", premiumVerified ? "<dark_green>YES</dark_green>" : "<red>NO</red>") : "";
String stMSG = text == null || text.equals("") ? "" : "<br><dark_red>|</dark_red> " + text + "<br>";
T2Csend.sender(sender, "<dark_red>---------------------</dark_red>"
String stMSG = text == null || text.equals("") ? "" : "<br><dark_red></dark_red> " + text + "<br>";
T2Csend.sender(sender, "<dark_red>╔════════════════════════════════</dark_red>"
+ "<br>" + stPlugin
+ stMSG
+ stVersion
@@ -110,7 +113,7 @@ public class T2Ctemplate {
+ "<br>" + stStable
+ "<br>" + stLink
+ pr
+ "<br><dark_red>---------------------</dark_red>");
+ "<br><dark_red>╚════════════════════════════════</dark_red>");
}
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, String text) {

View File

@@ -3,6 +3,10 @@ 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 org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
@@ -14,7 +18,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 +43,145 @@ 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 value;
if (webData.isPreRelease()) {
//todo if (!SelectLibConfig.getSeePreReleaseUpdates()) return;
value = UpdateType.PRERELEASE.text;
if (publicVersion.toLowerCase().contains("dev")) {
value = "<dark_red>DEV </dark_red>";
value = UpdateType.DEVELOPMENT.text;
}
if (publicVersion.toLowerCase().contains("beta")) {
value = "<green>BETA </green>";
value = UpdateType.BETA.text;
}
if (publicVersion.toLowerCase().contains("snapshot")) {
value = "<yellow>SNAPSHOT </yellow>";
value = UpdateType.SNAPSHOT.text;
}
}
T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", value).replace("[link]", "https://www.spigotmc.org/resources/" + spigotID)
} else value = UpdateType.STABLE.text;
T2Csend.player(player, st.replace("[prefix]", prefix).replace("[value]", value).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 value;
if (webData.isPreRelease()) {
value = UpdateType.PRERELEASE.text;
if (publicVersion.toLowerCase().contains("dev")) {
s1 = "§6A new §4DEV§6 version was found!§r";
value = UpdateType.DEVELOPMENT.text;
}
if (publicVersion.toLowerCase().contains("beta")) {
s1 = "§6A new §2BETA§6 version was found!§r";
value = UpdateType.BETA.text;
}
if (publicVersion.toLowerCase().contains("snapshot")) {
s1 = "§6A new §eSNAPSHOT§6 version was found!§r";
value = 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 value = UpdateType.STABLE.text;
String h = "<br><dark_red>╔══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
String s1 = "<br><dark_red>║</dark_red> <color:#6e90ff>A new [value] version was found!</color>".replace("[value]", value);
String 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 "Das Plugin " + args[1] + " gibts net"; // todo
}
T2CupdateWebData webData = object.webData;
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 = "<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,148 @@
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()).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);
}
}, 0L, 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 UpdateName = obj.getString("name");
String tag_name = obj.getString("tag_name");
String body = obj.getString("body").replace("\n", "<br>").replace("\r", "").replace("'", "''").replace("**", "");
String updateurl = obj.getString("html_url");
boolean prerelease = obj.getBoolean("prerelease");
String date = obj.getString("published_at");
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
Date parsedDate = inputFormat.parse(date);
String formattedDate = outputFormat.format(parsedDate);
String 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(UpdateName, tag_name, body, updateurl, formattedDate, downloadURL, gitURL, prerelease);
consumer.accept(webData);
} catch (Exception 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,
false,
updateCheckOnJoin
);
T2CupdateAPI.pluginVersions.put(plugin.getName(), update);
this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage());
}
});
}
}

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

@@ -8,7 +8,7 @@ import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class BCommandSenderReciver {
public class T2CbungeeCommandSenderReciver {
public static void sendToBungee(CommandSender sender, String information, Boolean console) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();

View File

@@ -1,8 +1,10 @@
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;
@@ -10,12 +12,15 @@ import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
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.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 +35,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 +45,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 {
@@ -56,10 +67,12 @@ public final class T2CodeLibMain extends JavaPlugin {
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.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());
@@ -90,13 +103,23 @@ 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");
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);
T2Ctemplate.onLoadFooter(prefix, long_);
load = true;
}
@@ -105,6 +128,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();
@@ -113,7 +137,7 @@ public final class T2CodeLibMain extends JavaPlugin {
Vault.vaultDisable();
T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
if (nmIsLoad) {
if (mmIsLoad) {
if (this.adventure != null) {
this.adventure.close();
this.adventure = null;
@@ -155,14 +179,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

@@ -1,11 +1,11 @@
package net.t2code.t2codelib.SPIGOT.system;
package net.t2code.t2codelib.SPIGOT.system.cmd;
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.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayers;
import net.t2code.t2codelib.T2CupdateObject;
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;
@@ -15,6 +15,7 @@ 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 {
@@ -25,7 +26,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
return false;
}
if (args.length == 0) {
T2Ctemplate.sendInfo(sender,T2CodeLibMain.getPlugin(), Util.getSpigotID(),Util.getDiscord(),null, Util.getInfoText());
Commands.info(sender);
return false;
}
switch (args[0].toLowerCase()) {
@@ -34,24 +35,20 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
case "pl":
case "version":
case "ver":
T2Ctemplate.sendInfo(sender,T2CodeLibMain.getPlugin(), Util.getSpigotID(),Util.getDiscord(),null, Util.getInfoText());
Commands.info(sender);
return false;
case "updateinfo":
Commands.updateInfo(sender,args);
return false;
case "reloadconfig":
SelectLibConfig.onSelect();
T2Csend.sender(sender, Util.getPrefix() + " §2Config successfully reloaded");
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");
Commands.debug(sender,args);
return false;
case "test":
T2Csend.sender(sender, T2CbungeePlayers.getBungeePlayers().toString());
return false;
default:
@@ -65,6 +62,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
put("debug", "t2code.admin");
put("info", "t2code.admin");
put("reloadconfig", "t2code.admin");
put("updateinfo", "t2code.admin");
}};
@Override
@@ -82,8 +80,31 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
if (args.length == 2 && args[0].equalsIgnoreCase("debug")) {
if (sender.hasPermission("t2code.admin")) {
if (hasPermission(p, arg1.get("debug")) && passend("debug", args[1])) {
list.add("createReportLog");
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("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;

View File

@@ -0,0 +1,80 @@
package net.t2code.t2codelib.SPIGOT.system.cmd;
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.Util;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.io.IOException;
public class Commands {
public static void info(CommandSender sender) {
T2Ctemplate.sendInfo(sender, T2CodeLibMain.getPlugin(), Util.getSpigotID(), Util.getDiscord(), null, Util.getInfoText());
}
public static void debug(CommandSender sender, String[] args) {
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;
}
}
public static void updateInfo(CommandSender sender, String[] args) {
T2Csend.sender(sender, T2CupdateAPI.updateInfo(args, sender instanceof Player));
}
}

View File

@@ -1,45 +1,66 @@
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.Server;
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.Calendar;
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,7 +101,6 @@ public class CreateReportLog {
pWriter.println("T2C-LuckyBox isV: " + LuckyBoxAPI.isV());
pWriter.println();
}
pWriter.println();
pWriter.println("OfflinePlayers: ");
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
pWriter.println(" - " + player.getName() + " - " + player.getUniqueId());
@@ -89,8 +109,9 @@ public class CreateReportLog {
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());
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();
@@ -101,9 +122,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 +132,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><hover:show_text:'<yellow>Click to delete</yellow>'><click:run_command:'/t2code debug deleteReportLog [key]'>[prefix] <green>You can <b>delte</b> yor Debug-File by clicking me.</green>" +
"<br>[prefix] <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 delte yor 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 {
@@ -144,6 +208,19 @@ 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)){
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);
@@ -190,4 +267,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,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,11 +22,14 @@ 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("BungeeCord.Enable", false, yamlConfiguration);
T2Cconfig.set("BungeeCord.Enable", T2CodeLibMain.getIsBungee(), yamlConfiguration);
T2Cconfig.set("Player.Inventories.CloseByServerStop", true, yamlConfiguration);
try {

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,40 @@ 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 bungee;
private static Boolean InventoriesCloseByServerStop;
@Getter
private static Boolean inventoriesCloseByServerStop;
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");
bungee = yamlConfiguration.getBoolean("BungeeCord.Enable");
InventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop");
inventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop");
}
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,26 @@
package net.t2code.t2codelib;
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,33 @@
package net.t2code.t2codelib;
import lombok.Getter;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
public class Util {
@Getter
private static final UUID serverUUID = UUID.randomUUID();
public static String getInfoText() {
return "";
}
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 +42,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 +54,8 @@ public class Util {
"LoreEditor",
"Booster",
"AntiMapCopy",
"AntiCopy"
"AntiCopy",
"T2C-LoginPermissionAuth"
);
}
}