Skip to content

Commit

Permalink
Modificado sistema de update, para maior velocidade
Browse files Browse the repository at this point in the history
Modificado plugin para rodar em versões altas
Modificado sistema de cache
Update em libs do plugin
Renomeado Limparchao para limparentidades
  • Loading branch information
GilbertoKPL committed Feb 14, 2024
1 parent 407f638 commit 5e05e3a
Show file tree
Hide file tree
Showing 34 changed files with 299 additions and 165 deletions.
11 changes: 8 additions & 3 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Codacy Badge](https://app.codacy.com/project/badge/Grade/5113aa86f46b45caa40bdfd8508bcd3e)](https://www.codacy.com/gh/GilbertoKPL/TotalEssentials/dashboard?utm_source=github.com&utm_medium=referral&utm_content=GilbertoKPL/TotalEssentials&utm_campaign=Badge_Grade)

* A core system for minecraft server that supports most versions (1.5.2 - 1.19.2), using only database as a storage
* A core system for minecraft server that supports most versions (1.5.2 - 1.20.2), using only database as a storage
medium and various built-in commands / systems, which can be disabled at any time.

# Bstats
Expand Down Expand Up @@ -58,7 +58,7 @@
| /changepass | change pass of account. | totalessentials.commands.changepass |
| /vip | vip system. | totalessentials.commands.vip |
| /shop and /loja | players shops. | totalessentials.commands.shop |
| /clearitems | clear all items in server (with config). | totalessentials.commands.clearitems |
| /clearentities | clear all items in server (with config). | totalessentials.commands.clearitems |

## Permission Color

Expand Down Expand Up @@ -144,7 +144,12 @@ To use in chat, commands, signs etc.

## TODO List

- [ ] Add support of version Checker for a Windows.
- [ X ] Add support of version Checker for a Windows.
- [ X ] Add Support to H2 DataBase.
- [ X ] Create CacheSQL to more powerful speed.
- [ X ] Create reload system.
- [ X ] Create auto config system with comments.
- [ X ] Create auto lang system with comments.

# Discord

Expand Down
29 changes: 19 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.9.21"
kotlin("jvm") version "1.9.22"
id("com.github.johnrengelman.shadow") version "8.1.1"
}

val base = "github.gilbertokpl.library"

version = "1.1.1"
version = "1.1.2"


repositories {
Expand All @@ -29,7 +29,7 @@ dependencies {
compileOnly(fileTree(mapOf("dir" to "$buildDir\\..\\localjar", "include" to listOf("*.jar"))))

//spigot
compileOnly("org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT") {
compileOnly("org.spigotmc:spigot-api:1.19.2-R0.1-SNAPSHOT") {
exclude("commons-lang", "commons-lang")
exclude("commons-io", "commons-io")
exclude("org.yaml", "snakeyaml")
Expand All @@ -39,17 +39,17 @@ dependencies {


//exposed
compileOnly("org.jetbrains.exposed:exposed-core:0.45.0") {
compileOnly("org.jetbrains.exposed:exposed-core:0.47.0") {
exclude("org.slf4j", "slf4j-api")
exclude("org.slf4j", "jcl-over-slf4j")
}

compileOnly("org.jetbrains.exposed:exposed-dao:0.45.0") {
compileOnly("org.jetbrains.exposed:exposed-dao:0.47.0") {
exclude("org.slf4j", "slf4j-api")
exclude("org.slf4j", "jcl-over-slf4j")
}

compileOnly("org.jetbrains.exposed:exposed-jdbc:0.45.0") {
compileOnly("org.jetbrains.exposed:exposed-jdbc:0.47.0") {
exclude("org.slf4j", "slf4j-api")
exclude("org.slf4j", "jcl-over-slf4j")
}
Expand Down Expand Up @@ -82,23 +82,23 @@ dependencies {
}

//host info
compileOnly("com.github.oshi:oshi-core:6.4.8") {
compileOnly("com.github.oshi:oshi-core:6.4.12") {
exclude("org.slf4j", "slf4j-api")
exclude("org.slf4j", "jcl-over-slf4j")
}

compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.21") {
compileOnly("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.22") {
exclude("org.slf4j", "slf4j-api")
exclude("org.slf4j", "jcl-over-slf4j")
}

compileOnly("net.dv8tion:JDA:5.0.0-beta.18") {
compileOnly("net.dv8tion:JDA:5.0.0-beta.20") {
exclude("club.minnced","opus-java")
exclude("org.slf4j", "slf4j-api")
exclude("org.slf4j", "jcl-over-slf4j")
}

compileOnly("org.json:json:20231013") {
compileOnly("org.json:json:20240205") {
exclude("org.slf4j", "slf4j-api")
exclude("org.slf4j", "jcl-over-slf4j")
}
Expand All @@ -109,6 +109,15 @@ tasks.shadowJar {
archiveFileName.set(rootProject.name + "-" + project.version.toString() + ".jar")
destinationDirectory.set(File("$projectDir/jar/plugins"))

manifest {
attributes(
"Plugin-Version" to project.version.toString(),
"Plugin-Creator" to "Gilberto",
"Plugin-Name" to "EssentialsK",
"Plugin-Github" to "https://github.com/GilbertoKPL/TotalEssentials",
"Class-Path" to "TotalEssentials/lib/TotalEssentials-lib-1.1.1.jar"
)
}


//relocate all libs
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
42 changes: 25 additions & 17 deletions src/main/java/github/gilbertokpl/total/TotalEssentialsJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import github.gilbertokpl.core.external.CorePlugin;
import github.gilbertokpl.total.cache.internal.InternalLoader;
import github.gilbertokpl.total.cache.local.PlayerData;
import github.gilbertokpl.total.cache.loop.ClearItemsLoop;
import github.gilbertokpl.total.cache.loop.ClearEntitiesLoop;
import github.gilbertokpl.total.cache.loop.PluginLoop;
import github.gilbertokpl.total.cache.sql.*;
import github.gilbertokpl.total.config.files.LangConfig;
Expand All @@ -25,6 +25,7 @@
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.security.CodeSource;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Objects;
import java.util.jar.*;
Expand Down Expand Up @@ -93,6 +94,7 @@ public void onLoad() {

File file = new File(newPath);


classPath = newPath.replace("plugins/", "");

if (!file.exists()) {
Expand All @@ -107,7 +109,7 @@ public void onLoad() {
update = true;
}
} catch (IOException e) {
throw new RuntimeException(e);
Bukkit.getServer().getLogger().severe("Você está utilizando Windowns Algumas funcionalidades do plugin não irão funcionar!");
}

if (update || libModify) {
Expand Down Expand Up @@ -151,7 +153,12 @@ public void onEnable() {
)
);

permission = Bukkit.getServer().getServicesManager().getRegistration(Permission.class).getProvider();
try {
permission = Bukkit.getServer().getServicesManager().getRegistration(Permission.class).getProvider();
}
catch (NoClassDefFoundError e) {
instance.getLogger().severe("Falta instalar VAULT, o addon de VIP não ira funcionar direito!");
}

InternalLoader.INSTANCE.start(
MainConfig.announcementsListAnnounce,
Expand All @@ -171,7 +178,7 @@ public void onEnable() {
Discord.INSTANCE.sendDiscordMessage(LangConfig.discordchatServerStart, true);
}

ClearItemsLoop.INSTANCE.start();
ClearEntitiesLoop.INSTANCE.start();

PluginLoop.INSTANCE.start();

Expand All @@ -185,24 +192,25 @@ public void onDisable() {

for (Player p : basePlugin.getReflection().getPlayers()) {
if (MainConfig.playtimeActivated) {
if (PlayerData.INSTANCE.getPlayTimeCache().get(p) != null) {
long time = PlayerData.INSTANCE.getPlayTimeCache().get(p) != null ? PlayerData.INSTANCE.getPlayTimeCache().get(p) : 0L;
long timePlayed = PlayerData.INSTANCE.getPlaytimeLocal().get(p) != null ? PlayerData.INSTANCE.getPlayTimeCache().get(p) : 0L;
long currentTimeMillis = System.currentTimeMillis();

long newTime = time + (System.currentTimeMillis() - timePlayed);
Long playTimeCacheValue = PlayerData.INSTANCE.getPlayTimeCache().get(p);
long time = (playTimeCacheValue != null) ? playTimeCacheValue : 0L;

if (time > 94608000000L) {
newTime = time;
}
Long playtimeLocalValue = PlayerData.INSTANCE.getPlaytimeLocal().get(p);
long timePlayed = (playtimeLocalValue != null) ? playtimeLocalValue : 0L;

if (newTime > 94608000000L) {
newTime = 518400000L;
}
long newTime = time + (currentTimeMillis - timePlayed);

if (time > 94608000000L) {
newTime = time;
}

PlayerData.INSTANCE.getPlayTimeCache().set(p, newTime);
} else {
PlayerData.INSTANCE.getPlayTimeCache().set(p, 0L);
if (newTime > 94608000000L) {
newTime = 518400000L;
}

PlayerData.INSTANCE.getPlayTimeCache().set(p, newTime);
PlayerData.INSTANCE.getPlaytimeLocal().set(p, 0L);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ public class MainConfig implements DefaultConfig {
)
public static Boolean craftActivated = true;

//clearItemsCommand
//clearEntitiesCommand
@PrimaryComments(
{
@PrimaryComment(primaryAnnotations = "Configurações dos comandos kits", lang = LangTypes.PT_BR),
@PrimaryComment(primaryAnnotations = "Configurações dos comando clear items", lang = LangTypes.PT_BR),
@PrimaryComment(primaryAnnotations = "Kit command settings", lang = LangTypes.EN_US)
}
)
Expand All @@ -299,28 +299,28 @@ public class MainConfig implements DefaultConfig {
@Comment(annotations = "If enabled (true), The command will be actived.", lang = LangTypes.EN_US)
}
)
public static Boolean clearitemsActivated = true;
public static Boolean clearentitiesActivated = true;
@Comments(
{
@Comment(annotations = "Lista de mundos para limpar o chão.", lang = LangTypes.PT_BR),
@Comment(annotations = "", lang = LangTypes.EN_US)
}
)
public static List<String> clearitemsWorlds = Collections.singletonList("world");
public static List<String> clearentitiesWorlds = Collections.singletonList("world");
@Comments(
{
@Comment(annotations = "Lista de items para não excluir em material, para pegar o material > /material.", lang = LangTypes.PT_BR),
@Comment(annotations = "", lang = LangTypes.EN_US)
}
)
public static List<String> clearitemsItemsNotClear = Collections.singletonList("dirt");
public static List<String> clearentitiesItemsNotClear = Collections.singletonList("dirt");
@Comments(
{
@Comment(annotations = "Tempo em minutos para executar um limpar chão", lang = LangTypes.PT_BR),
@Comment(annotations = "", lang = LangTypes.EN_US)
}
)
public static Integer clearitemsTime = 10;
public static Integer clearentitiesTime = 10;

//kitCommand
@PrimaryComments(
Expand Down Expand Up @@ -365,6 +365,14 @@ public class MainConfig implements DefaultConfig {
)
public static Boolean kitsEquipArmorInCatch = true;

@Comments(
{
@Comment(annotations = "Se estiver ativado (true), será enviado ao player os kits disponiveis para pegar ao logar.", lang = LangTypes.PT_BR),
@Comment(annotations = "jkl", lang = LangTypes.EN_US)
}
)
public static Boolean kitsSendAvailableKitsOnLogin = true;

//homeCommand
@PrimaryComments(
{
Expand Down
34 changes: 19 additions & 15 deletions src/main/kotlin/github/gilbertokpl/core/external/cache/Cache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,28 @@ class Cache(core: CorePlugin) {
}
}
Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay({
try {
transaction(corePlugin.sql) {
for (i in toByteUpdate) {
try {
i.update()
} catch (e: Exception) {
Bukkit.getServer().shutdown()
e.printStackTrace()
}
}
}
} catch (e: Exception) {
Bukkit.getServer().shutdown()
e.printStackTrace()
}
save()
}, 5, 5, TimeUnit.MINUTES)
}

val toByteUpdate = ArrayList<CacheBuilder<*>>()

fun save() {
try {
transaction(corePlugin.sql) {
for (i in toByteUpdate) {
try {
i.update()
} catch (e: Exception) {
Bukkit.getServer().shutdown()
e.printStackTrace()
}
}
}
} catch (e: Exception) {
Bukkit.getServer().shutdown()
e.printStackTrace()
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package github.gilbertokpl.core.external.command
import github.gilbertokpl.core.external.CorePlugin
import github.gilbertokpl.core.external.command.interfaces.CommandBase
import github.gilbertokpl.core.internal.command.InternalCommand
import org.bukkit.command.Command
import org.bukkit.command.CommandSender
import org.bukkit.command.defaults.BukkitCommand
import org.bukkit.entity.Player

abstract class CommandCreator(name: String) : Command(name), CommandBase {
abstract class CommandCreator(name: String) : BukkitCommand(name), CommandBase {

private val internalCommand: InternalCommand = InternalCommand(this)

Expand Down
Loading

0 comments on commit 5e05e3a

Please sign in to comment.