Skip to content

Commit

Permalink
Recoded Scoreboard System.
Browse files Browse the repository at this point in the history
  • Loading branch information
frafol committed Jan 20, 2024
1 parent 0e720d6 commit f359d12
Show file tree
Hide file tree
Showing 113 changed files with 2,564 additions and 1,384 deletions.
Binary file removed libs/limboapi-1.1.14.jar
Binary file not shown.
74 changes: 51 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

<groupId>it.frafol</groupId>
<artifactId>cleanscreenshare</artifactId>
<version>1.6.0</version>
<version>2.1.3</version>
<packaging>jar</packaging>

<name>CleanSS</name>
<name>CleanScreenShare</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -19,7 +19,6 @@

<build>
<defaultGoal>clean install</defaultGoal>
<finalName>CleanScreenShare</finalName>
<plugins>
<plugin>
<version>3.6.1</version>
Expand All @@ -41,6 +40,12 @@
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>net.byteflux.libby</pattern>
<shadedPattern>it.frafol.libs.net.byteflux.libby</shadedPattern>
</relocation>
</relocations>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
Expand Down Expand Up @@ -72,6 +77,10 @@
<id>AlessioDP</id>
<url>https://repo.alessiodp.com/releases/</url>
</repository>
<repository>
<id>elytrium-repo</id>
<url>https://maven.elytrium.net/repo/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
Expand All @@ -82,22 +91,22 @@
<dependency>
<groupId>net.byteflux</groupId>
<artifactId>libby-bukkit</artifactId>
<version>1.1.5</version>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>net.byteflux</groupId>
<artifactId>libby-velocity</artifactId>
<version>1.1.5</version>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>net.byteflux</groupId>
<artifactId>libby-bungee</artifactId>
<version>1.1.5</version>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.1.2-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -109,13 +118,19 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.12</version>
<version>5.0.0-beta.19</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.Anon8281</groupId>
<artifactId>UniversalScheduler</artifactId>
<version>0.1.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<version>1.18.26</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -125,21 +140,23 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.waterfallmc</groupId>
<artifactId>waterfall-api</artifactId>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.waterfallmc</groupId>
<artifactId>waterfall-proxy</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<type>javadoc</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.1-R0.1-SNAPSHOT</version>
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -152,25 +169,36 @@
<groupId>com.tchristofferson</groupId>
<artifactId>ConfigUpdater</artifactId>
<version>2.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.elytrium.limboapi</groupId>
<artifactId>api</artifactId>
<version>1.1.14</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/limboapi-1.1.14.jar</systemPath>
<version>1.1.16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.Stijn</groupId>
<artifactId>ScoreboardAPI</artifactId>
<version>0.0.1</version>
<groupId>ir.syrent.velocityvanish</groupId>
<artifactId>velocityvanish</artifactId>
<version>3.18.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/ScoreboardAPI.jar</systemPath>
<systemPath>${project.basedir}/libs/VelocityVanish.jar</systemPath>
</dependency>
<dependency>
<groupId>fr.mrmicky</groupId>
<artifactId>fastboard</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.2</version>
<version>2.11.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.LeonMangler</groupId>
<artifactId>PremiumVanishAPI</artifactId>
<version>2.9.0-4</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
83 changes: 52 additions & 31 deletions src/main/java/it/frafol/cleanss/bukkit/CleanSS.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package it.frafol.cleanss.bukkit;

import com.github.Anon8281.universalScheduler.UniversalScheduler;
import com.github.Anon8281.universalScheduler.scheduling.tasks.MyScheduledTask;
import com.tchristofferson.configupdater.ConfigUpdater;
import it.frafol.cleanss.bukkit.commands.MainCommand;
import it.frafol.cleanss.bukkit.enums.SpigotConfig;
Expand All @@ -14,11 +16,10 @@
import lombok.SneakyThrows;
import net.byteflux.libby.BukkitLibraryManager;
import net.byteflux.libby.Library;
import net.byteflux.libby.relocation.Relocation;
import org.apache.commons.lang.time.DurationFormatUtils;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

import java.io.File;
import java.io.IOException;
Expand All @@ -34,7 +35,7 @@ public class CleanSS extends JavaPlugin {

public boolean updated = false;

private final HashMap<UUID, BukkitTask> timerTask = new HashMap<>();
private final HashMap<UUID, MyScheduledTask> timerTask = new HashMap<>();
private final HashMap<UUID, Integer> seconds = new HashMap<>();

@Getter
Expand All @@ -51,24 +52,35 @@ public class CleanSS extends JavaPlugin {

@SneakyThrows
@Override
@SuppressWarnings("deprecation")
public void onEnable() {

instance = this;

BukkitLibraryManager bukkitLibraryManager = new BukkitLibraryManager(this);

final Relocation yamlrelocation = new Relocation("yaml", "it{}frafol{}libs{}yaml");
Library yaml = Library.builder()
.groupId("me{}carleslc{}Simple-YAML")
.artifactId("Simple-Yaml")
.version("1.8.4")
.relocate(yamlrelocation)
.build();

Library scoreboard = Library.builder()
.groupId("me{}Stijn{}ScoreboardAPI")
.artifactId("ScoreboardAPI")
.version("0.0.1")
.url("https://github.com/frafol/CleanScreenShare/raw/main/libs/ScoreboardAPI.jar")
final Relocation updaterrelocation = new Relocation("updater", "it{}frafol{}libs{}updater");
Library updater = Library.builder()
.groupId("com{}tchristofferson")
.artifactId("ConfigUpdater")
.version("2.1-SNAPSHOT")
.relocate(updaterrelocation)
.url("https://github.com/frafol/Config-Updater/releases/download/compile/ConfigUpdater-2.1-SNAPSHOT.jar")
.build();

final Relocation schedulerrelocation = new Relocation("scheduler", "it{}frafol{}libs{}scheduler");
Library scheduler = Library.builder()
.groupId("com{}github{}Anon8281")
.artifactId("UniversalScheduler")
.version("0.1.6")
.relocate(schedulerrelocation)
.build();

try {
Expand All @@ -80,30 +92,34 @@ public void onEnable() {
.artifactId("Simple-Yaml")
.version("1.8.4")
.url("https://github.com/Carleslc/Simple-YAML/releases/download/1.8.4/Simple-Yaml-1.8.4.jar")
.relocate(yamlrelocation)
.build();
}

bukkitLibraryManager.addJitPack();
bukkitLibraryManager.loadLibrary(updater);
bukkitLibraryManager.loadLibrary(yaml);
bukkitLibraryManager.loadLibrary(scoreboard);
bukkitLibraryManager.loadLibrary(scheduler);

getLogger().info("\n ___ __ ____ __ _ _ ___ ___\n" +
" / __)( ) ( ___) /__\\ ( \\( ) / __)/ __)\n" +
" ( (__ )(__ )__) /(__)\\ ) ( \\__ \\\\__ \\\n" +
" \\___)(____)(____)(__)(__)(_)\\_) (___/(___/\n");

getLogger().info("Server version: " + Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3] + ".");
getLogger().info("Server version: " + getServer().getClass().getPackage().getName().split("\\.")[3] + ".");

if (isSuperLegacy()) {
getLogger().severe("Support for your version was declined.");
Bukkit.getPluginManager().disablePlugin(this);
getServer().getPluginManager().disablePlugin(this);
return;
}

getLogger().info("Loading configuration...");
configTextFile = new TextFile(getDataFolder().toPath(), "settings.yml");
cacheTextFile = new TextFile(getDataFolder().toPath(), "cache_do_not_touch.yml");
versionTextFile = new TextFile(getDataFolder().toPath(), "version.yml");
File configFile = new File(getDataFolder(), "settings.yml");
File cacheFile = new File(getDataFolder(), "cache_do_not_touch.yml");

if (!getDescription().getVersion().equals(SpigotVersion.VERSION.get(String.class))) {

Expand All @@ -114,14 +130,18 @@ public void onEnable() {
getLogger().severe("Unable to update configuration file, please remove the settings.yml!");
}

try {
ConfigUpdater.update(this, "cache_do_not_touch.yml", cacheFile, Collections.emptyList());
} catch (IOException ignored) {
getLogger().severe("Unable to update cache file, please remove the cache_do_not_touch.yml!");
}

versionTextFile.getConfig().set("version", getDescription().getVersion());
versionTextFile.getConfig().save();
configTextFile = new TextFile(getDataFolder().toPath(), "settings.yml");

cacheTextFile = new TextFile(getDataFolder().toPath(), "cache_do_not_touch.yml");
}

cacheTextFile = new TextFile(getDataFolder().toPath(), "cache_do_not_touch.yml");

getLogger().info("Loading channels...");
getServer().getMessenger().registerIncomingPluginChannel(this, "cleanss:join", new PluginMessageReceiver());

Expand Down Expand Up @@ -176,15 +196,14 @@ public static boolean isFolia() {
return true;
}


public boolean isSuperLegacy() {
return Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_6_R")
|| Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_5_R")
|| Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_4_R")
|| Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_3_R")
|| Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_2_R")
|| Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_1_R")
|| Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_0_R");
return getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_6_R")
|| getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_5_R")
|| getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_4_R")
|| getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_3_R")
|| getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_2_R")
|| getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_1_R")
|| getServer().getClass().getPackage().getName().split("\\.")[3].contains("1_0_R");
}

private void UpdateChecker() {
Expand Down Expand Up @@ -226,20 +245,22 @@ public void autoUpdate() {
return;
}

try {
String fileUrl = "https://github.com/frafol/CleanScreenShare/releases/download/release/CleanScreenShare.jar";
new UpdateCheck(this).getVersion(version -> {
String fileUrl = "https://github.com/frafol/CleanScreenShare/releases/download/release/cleanscreenshare-"+ version + " .jar";
String destination = "./plugins/";

String fileName = getFileNameFromUrl(fileUrl);
File outputFile = new File(destination, fileName);

downloadFile(fileUrl, outputFile);
try {
downloadFile(fileUrl, outputFile);
} catch (IOException ignored) {
getLogger().warning("An error occurred while downloading the update, please download it manually from SpigotMC.");
}

updated = true;
getLogger().warning("CleanScreenShare successfully updated, a restart is required.");

} catch (IOException ignored) {
getLogger().severe("Unable to update CleanScreenShare, please download it manually from SpigotMC.");
}
});
}

private String getFileNameFromUrl(String fileUrl) {
Expand All @@ -262,7 +283,7 @@ public boolean isPAPI() {
}

public void startTimer(UUID uuid) {
timerTask.put(uuid, instance.getServer().getScheduler().runTaskTimer(instance, () -> {
timerTask.put(uuid, UniversalScheduler.getScheduler(instance).runTaskTimer(() -> {
seconds.putIfAbsent(uuid, 1);
seconds.put(uuid, seconds.get(uuid) + 1);
}, 20L, 20L));
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/it/frafol/cleanss/bukkit/commands/MainCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.jetbrains.annotations.NotNull;
import org.simpleyaml.configuration.file.YamlFile;

import java.io.IOException;

public class MainCommand implements Listener {

@EventHandler
public void onCommand(@NotNull PlayerCommandPreprocessEvent event) throws IOException {
public void onCommand(PlayerCommandPreprocessEvent event) throws IOException {

final Player player = event.getPlayer();
final String message = event.getMessage();
Expand Down Expand Up @@ -44,5 +43,14 @@ public void onCommand(@NotNull PlayerCommandPreprocessEvent event) throws IOExce
cache.save();

}

if (message.equalsIgnoreCase("/setotherspawn")) {

event.setCancelled(true);

player.sendMessage(SpigotConfig.SPAWN_SET.color());
cache.set("spawns.other", PlayerCache.LocationToString(player.getLocation()));
cache.save();
}
}
}
Loading

0 comments on commit f359d12

Please sign in to comment.