Skip to content

Commit

Permalink
QoL
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghosty920 committed Oct 25, 2024
1 parent 8b2cf6a commit 7034a45
Show file tree
Hide file tree
Showing 13 changed files with 176 additions and 62 deletions.
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
<br>

Plugin *non officiel, mais identique* recréé à partir des vidéos et lives du KamoofSMP Saison 2, pour la version 1.21 de Minecraft.
Plugin *non officiel, mais identique/meilleur* recréé à partir des vidéos et lives du KamoofSMP Saison 2, pour la version 1.21 de Minecraft.

Lorsqu'un joueur meurt, il fait tomber sa tête, qui, quand utilisée permet au joueur de voler son apparence et son nom temporairement. En plus de ça, avec 9 têtes il est possible de faire un rituel donnant accès à 2 pactes ayant leur avantage et désavantage opposés.

Expand All @@ -21,3 +21,39 @@ Lorsqu'un joueur meurt, il fait tomber sa tête, qui, quand utilisée permet au
> [!CAUTION]
> Le plugin distribué par Sohran **ne** comporte **aucun** élément de la saison 2, *en + de **2 bugs majeurs**, donc **ATTENTION à vous !***

## Installation

1. Ayez un serveur [Paper](https://papermc.io/downloads/paper) (Spigot ou n'importe quel fork)
2. [Téléchargez les 2 fichiers .jar de la dernière version disponible](https://github.com/Ghosty920/KamoofSMP-S2/releases/latest)

<img src="images/install_download.png" alt="Download" style="max-height: 400px">

3. Placez ces 2 fichiers dans le dossier `plugins` directement dans votre serveur.
4. (Re) Démarrez votre serveur.
5. Vérifiez la console et faites `/plugins` pour voir s'il n'y a aucune erreur, sinon vérifiez l'étape 3


## Modifier
```https://github.com/Ghosty920/KamoofSMP-S2.git```

### Pour ouvrir dans Intellij Idea
<img src="images/edit_clone_intellij.png" alt="Clone Intellij" style="max-height: 350px">

### Pour ouvrir n'importe où d'autre
<img src="images/edit_download_zip.png" alt="Download Zip" style="max-height: 350px">

Et ensuite extrayez le contenu où vous voulez, et ouvrez-le dans votre IDE comme à votre habitude.

### Compiler

Utiliser la commande `gradlew shadowJar`

## Contribuer

Merci de **Reformater** votre code avec de mettre toute contribution.

Une fois tout terminé et **testé**, [ouvrez un pull request](https://github.com/Ghosty920/KamoofSMP-S2/compare).

N'hésitez pas à venir nous voir sur Discord pour toute question.
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "cc.ghosty"
version = "1.3.0"
version = "1.3.1"

repositories {
mavenCentral()
Expand Down Expand Up @@ -41,6 +41,10 @@ tasks {
dependsOn(shadowJar)
}

shadowJar {
archiveFileName.set("${project.name}-${project.version}.jar")
}

processResources {
inputs.property("version", version)

Expand Down
Binary file added images/edit_clone_intellij.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/edit_download_zip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/install_download.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 13 additions & 11 deletions src/main/java/cc/ghosty/kamoof/KamoofSMP.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package cc.ghosty.kamoof;

import cc.ghosty.kamoof.commands.*;
import cc.ghosty.kamoof.features.ritual.*;
import lombok.Getter;
import lombok.SneakyThrows;
import cc.ghosty.kamoof.commands.*;
import cc.ghosty.kamoof.features.autoupdate.UpdateChecker;
import cc.ghosty.kamoof.features.disguise.DisguiseListener;
import cc.ghosty.kamoof.features.disguise.DisguiseRestaurer;
import cc.ghosty.kamoof.features.drophead.HeadDropper;
import cc.ghosty.kamoof.features.macelimiter.MaceLimiter;
import cc.ghosty.kamoof.features.other.*;
import cc.ghosty.kamoof.features.ritual.*;
import cc.ghosty.kamoof.utils.Lang;
import cc.ghosty.kamoof.utils.Metrics;
import lombok.Getter;
import lombok.SneakyThrows;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.TabCompleter;
Expand All @@ -26,17 +23,21 @@
public final class KamoofSMP extends JavaPlugin {

public static final String PREFIX = "§a§l[KamoofSMP] §r";
public static final String PREFIX_MM = "<green><b>[KamoofSMP] <reset>";

@Getter
private static KamoofSMP instance;
@Getter
private static YamlConfiguration data;
private static File dataFile;

public static FileConfiguration config() {
return instance.getConfig();
}

public static YamlConfiguration data() {
return data;
}

@SneakyThrows
public static void saveData() {
if (data == null)
Expand All @@ -45,6 +46,10 @@ public static void saveData() {
data = YamlConfiguration.loadConfiguration(dataFile);
}

public static void log(String msg, Object... args) {
Bukkit.getConsoleSender().sendMessage(String.format(msg, args));
}

@Override
public void onEnable() {
super.onEnable();
Expand Down Expand Up @@ -88,6 +93,7 @@ public void onEnable() {
registerCommand("undisguise", new UndisguiseCMD());

DisguiseRestaurer.onEnable();
pm.registerEvents(new JoinMessages(), this);

if (getConfig().getBoolean("metrics"))
new Metrics(this, 23302);
Expand All @@ -106,8 +112,4 @@ private void registerCommand(String name, CommandExecutor cmd) {
getCommand(name).setTabCompleter(tc);
}

public static void log(String msg, Object... args) {
Bukkit.getConsoleSender().sendMessage(String.format(msg, args));
}

}
10 changes: 7 additions & 3 deletions src/main/java/cc/ghosty/kamoof/commands/KamoofCMD.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import java.util.*;

import static cc.ghosty.kamoof.KamoofSMP.PREFIX;
import static cc.ghosty.kamoof.KamoofSMP.*;

public final class KamoofCMD implements CommandExecutor, TabCompleter {

Expand Down Expand Up @@ -69,7 +69,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
case "reload": {
KamoofSMP.getInstance().reloadConfig();
Lang.init();
Lang.CONFIG_RELOADED.send(player);
Lang.CONFIG_RELOADED.sendMM(player);
return true;
}
case "test": {
Expand All @@ -81,8 +81,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return true;
}
case "setup": {
if(!config().getBoolean("ritual.enabled")) {
Lang.RITUAL_DISABLED.send(player);
return true;
}
if (player.getInventory().addItem(RitualSetup.getItems()).isEmpty())
Lang.SETUP_GIVEN.send(player);
Lang.SETUP_GIVEN.sendMM(player);
else
Lang.INVENTORY_FULL.send(player);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import java.util.Map;
import java.util.UUID;

import static cc.ghosty.kamoof.KamoofSMP.*;

public final class DisguiseRestaurer implements Listener {

private static boolean enabled = false;
Expand All @@ -23,12 +25,12 @@ public DisguiseRestaurer() {
}

public static String get(UUID uuid) {
return KamoofSMP.getData().getString("restaurer." + uuid);
return data().getString("restaurer." + uuid);
}

public static void set(UUID uuid, String disguise) {
KamoofSMP.getData().set("restaurer." + uuid, disguise);
KamoofSMP.saveData();
data().set("restaurer." + uuid, disguise);
saveData();
}

public static void onEnable() {
Expand All @@ -45,7 +47,7 @@ public static void onEnable() {
DisguiseManager.disguise(player, disguise);
}
});
KamoofSMP.saveData();
saveData();
}, 1L);

}
Expand All @@ -59,7 +61,7 @@ public static void onDisable() {
set(player.getUniqueId(), NickAPI.getName(player));
});

KamoofSMP.saveData();
saveData();
}

@EventHandler
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/cc/ghosty/kamoof/features/other/JoinMessages.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cc.ghosty.kamoof.features.other;

import cc.ghosty.kamoof.features.ritual.RitualHandler;
import cc.ghosty.kamoof.utils.Lang;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

import static cc.ghosty.kamoof.KamoofSMP.*;

public final class JoinMessages implements Listener {

public boolean done = data().getBoolean("firstJoinMsg", false);
public final boolean ritual = config().getBoolean("ritual.enabled");

@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (!player.hasPermission("kamoofsmp.admin") && !player.isOp())
return;

if(!done) {

Lang.FIRST_JOIN.sendMM(player);

done = true;
data().set("firstJoinMsg", true);
saveData();

} else if(ritual && !RitualHandler.setup) {

Lang.NOT_PLACED.sendMM(player);

}
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cc.ghosty.kamoof.features.macelimiter;
package cc.ghosty.kamoof.features.other;

import cc.ghosty.kamoof.KamoofSMP;
import cc.ghosty.kamoof.utils.Message;
Expand All @@ -15,6 +15,8 @@

import java.util.Map;

import static cc.ghosty.kamoof.KamoofSMP.*;

public final class MaceLimiter implements Listener {

// fix un bug avec certaines versions spigot
Expand All @@ -37,12 +39,12 @@ public void onCrafter(CrafterCraftEvent event) {
}

public static void add() {
KamoofSMP.getData().set("maces", KamoofSMP.getData().getInt("maces", 0) + 1);
KamoofSMP.saveData();
data().set("maces", data().getInt("maces", 0) + 1);
saveData();
}

public static boolean canCraft() {
return KamoofSMP.getData().getInt("maces", 0) < KamoofSMP.config().getInt("macelimiter.limit");
return data().getInt("maces", 0) < KamoofSMP.config().getInt("macelimiter.limit");
}

@EventHandler(priority = EventPriority.HIGHEST)
Expand Down Expand Up @@ -76,7 +78,7 @@ public void onCraft(CraftItemEvent event) {
}

if (canCraft()) {
int old = KamoofSMP.getData().getInt("maces", 0);
int old = data().getInt("maces", 0);
int limit = KamoofSMP.config().getInt("macelimiter.limit");
add();
HumanEntity player = event.getView().getPlayer();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package cc.ghosty.kamoof.features.autoupdate;
package cc.ghosty.kamoof.features.other;

import cc.ghosty.kamoof.utils.*;
import com.google.gson.*;
import cc.ghosty.kamoof.KamoofSMP;
import cc.ghosty.kamoof.utils.*;
import com.google.gson.*;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -32,13 +31,15 @@ public final class UpdateChecker implements Listener {

public UpdateChecker() {
currentVersion = KamoofSMP.getInstance().getDescription().getVersion().trim().toLowerCase();
boolean download = KamoofSMP.config().getBoolean("autoupdate.download");
Bukkit.getScheduler().runTaskAsynchronously(KamoofSMP.getInstance(), () -> {
if (checkForUpdate() && (!download || !downloadUpdate(updateLink))) {
final boolean[] shouldRestart = {true};
Bukkit.getScheduler().runTaskTimerAsynchronously(KamoofSMP.getInstance(), () -> {
boolean download = KamoofSMP.config().getBoolean("autoupdate.download");
if (checkForUpdate() && (!download || !downloadUpdate(updateLink, shouldRestart[0]))) {
hasUpdate = true;
Bukkit.getConsoleSender().spigot().sendMessage(this.message);
}
});
shouldRestart[0] = false;
}, 1L, /*24 * 60 * 60 * 20L*/ 200L);
}

public boolean checkForUpdate() {
Expand All @@ -52,7 +53,6 @@ public boolean checkForUpdate() {
newVersion = object.get("version_number").getAsString().trim().toLowerCase();

if (Arrays.compare(currentVersion.getBytes(), newVersion.getBytes()) != 0) {
// if (currentVersion.equalsIgnoreCase(newVersion)) {

int downloadsCount = object.get("downloads").getAsInt();
if (downloadsCount < 1_000)
Expand Down Expand Up @@ -84,7 +84,7 @@ else if (downloadsCount < 1_000_000)
return false;
}

public boolean downloadUpdate(String url) {
public boolean downloadUpdate(String url, boolean restart) {
if (url == null)
return false;
try {
Expand All @@ -97,16 +97,22 @@ public boolean downloadUpdate(String url) {
Files.write(Path.of(location.toURI()), response.response());

Bukkit.getConsoleSender().sendMessage(Lang.UPDATE_DOWNLOADED.get());
Bukkit.getScheduler().runTask(KamoofSMP.getInstance(),
() -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "restart"));

/*String hover = String.format(Lang.NEW_VERSION_HOVER.get(), newVersion, downloads, changelog);
String uUrl = "https://modrinth.com/plugin/camouf2/version/" + newVersion;
String message = String.format(Lang.NEW_VERSION_DOWNLOADED.get(), hover, uUrl, currentVersion, newVersion);
this.message = Message.toBaseComponent(message);
if (!restart) {

String hover = String.format(Lang.NEW_VERSION_HOVER.get(), newVersion, downloads, changelog);
String uUrl = "https://modrinth.com/plugin/camouf2/version/" + newVersion;
String message = String.format(Lang.NEW_VERSION_DOWNLOADED.get(), hover, uUrl, currentVersion, newVersion);
this.message = Message.toBaseComponent(message);

hasUpdate = true;
Bukkit.getConsoleSender().spigot().sendMessage(this.message);

} else {
Bukkit.getScheduler().runTask(KamoofSMP.getInstance(),
() -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "restart"));
}

hasUpdate = true;
Bukkit.getConsoleSender().spigot().sendMessage(this.message);*/

return true;
} catch (Throwable exc) {
Expand Down
Loading

0 comments on commit 7034a45

Please sign in to comment.