Blueprint Spesifikasi & Arsitektur Plugin: SigmaCore Informasi Proyek * Nama Plugin: SigmaCore * Pengembang (Author): vey * Target API: Spigot/Paper 1.20 - 1.21.x * Bahasa Pemrograman: Java 17 * Sistem Build: Maven * Ruang Lingkup: Core Hardcore & Leaderboard System terintegrasi penuh (100% Native Java) tanpa menggunakan Skript atau dependensi pihak ketiga.
- Struktur Direktori Proyek
Susunan repositori proyek mengikuti standar struktur Maven untuk memastikan kompabilitas kompilasi otomatis.
SigmaCore/ โโโ pom.xml โโโ src/ โโโ main/ โโโ java/ โ โโโ id/ โ โโโ sigmacommunity/ โ โโโ core/ โ โโโ SigmaCore.java โโโ resources/ โโโ plugin.yml โโโ config.yml
- Manajemen Dependensi Proyek (pom.xml)
File ini menangani dependensi Spigot API dan memastikan target kompilasi diatur pada Java 17. <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<groupId>id.sigmacommunity</groupId> <artifactId>SigmaCore</artifactId> <version>1.0.0</version> <packaging>jar</packaging>
<name>SigmaCore</name>
<properties> <java.version>17</java.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>
<repositories> <repository> <id>spigotmc-repo</id> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> </repository> </repositories>
<dependencies> <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.21-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency> </dependencies>
<build> <finalName>SigmaCore</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.11.0</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> </configuration> </plugin> </plugins> </build> </project>
- Konfigurasi Resources (src/main/resources/)
A. Konfigurasi Plugin (plugin.yml) Mendeklarasikan identitas plugin, kelas utama, daftar command internal, dan perizinan. name: SigmaCore version: 1.0.0 main: id.sigmacommunity.core.SigmaCore api-version: '1.20' author: vey description: Core Hardcore & Leaderboard System untuk Server SIGMA
commands: sigma: description: Panel kontrol utama sistem SIGMA permission: sigmacore.admin permission-message: "&cKamu tidak memiliki akses (Khusus OP)!" sigmalist: description: Menampilkan daftar lengkap command SIGMA aliases: [sigmahelp, sigmacmd, listcommand] permission: sigmacore.admin permission-message: "&cKamu tidak memiliki akses (Khusus OP)!" koordinat: description: Membuka atau menyembunyikan koordinat F3 aliases: [coord, coords, bukakoordinat] permission: sigmacore.admin permission-message: "&cKamu tidak memiliki akses (Khusus OP)!" bukaend: description: Membuka atau mengunci dimensi The End aliases: [openend, endlock] permission: sigmacore.admin permission-message: "&cKamu tidak memiliki akses (Khusus OP)!" playtime: description: Mengecek total waktu bermain pemain aliases: [pt, cekplaytime, waktu]
permissions: sigmacore.admin: description: Akses penuh ke seluruh command admin SIGMA default: op
B. Konfigurasi Default Server (config.yml) Menyimpan konfigurasi modul sistem yang dapat dimodifikasi oleh admin.
==========================================
KONFIGURASI SISTEM CORE SIGMA
Author: vey
==========================================
webhooks: admin: "MASUKKAN_URL_WEBHOOK_ADMIN_DISINI" public: "MASUKKAN_URL_WEBHOOK_PUBLIK_DISINI"
systems: deathban: true chatlock: true nametag: true nototem: true cooldown: true antixray: true endlock: true hidecoord: true hardlock: true banweapon: true autoleaderboard: true
- Implementasi Core Logic (src/main/java/id/sigmacommunity/core/SigmaCore.java)
Seluruh fungsi dirangkum secara modular (monolitik terstruktur) ke dalam kelas utama agar proses kompilasi efisien dan manajemen asinkronusnya optimal. package id.sigmacommunity.core;
import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.command.*; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.*; import org.bukkit.event.*; import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.entity.*; import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.event.player.*; import org.bukkit.event.world.WorldInitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin;
import java.io.File; import java.io.IOException; import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.time.Duration; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors;
public class SigmaCore extends JavaPlugin implements Listener, CommandExecutor, TabCompleter {
private File dataFile; private FileConfiguration dataConfig; private final HttpClient httpClient = HttpClient.newBuilder() .connectTimeout(Duration.ofSeconds(10)) .build();
// Cache Memori untuk Cooldown & Anti-Xray private final Map<UUID, Long> lastDamageMap = new ConcurrentHashMap<>(); private final Map<UUID, Long> pearlCooldown = new ConcurrentHashMap<>(); private final Map<UUID, Long> tridentCooldown = new ConcurrentHashMap<>(); private final Map<UUID, Long> endMsgCooldown = new ConcurrentHashMap<>(); private final Map<UUID, Long> xrayTimeMap = new ConcurrentHashMap<>(); private final Map<UUID, Integer> xrayCountMap = new ConcurrentHashMap<>(); private final Map<UUID, Long> xrayAlertCdMap = new ConcurrentHashMap<>();
private static final List<String> SYSTEM_KEYS = Arrays.asList( "deathban", "chatlock", "nametag", "nototem", "cooldown", "antixray", "endlock", "hidecoord", "hardlock", "banweapon", "autoleaderboard" );
@Override public void onEnable() { saveDefaultConfig(); initDataFile();
Bukkit.getPluginManager().registerEvents(this, this); registerCommands(); applyStartupRules(); startSchedulers();
getLogger().info("========================================"); getLogger().info(" SigmaCore v1.0.0 berhasil diaktifkan!"); getLogger().info(" Author: vey | Server: SIGMA Community"); getLogger().info("========================================"); }
@Override public void onDisable() { saveDataFile(); getLogger().info("SigmaCore telah dinonaktifkan dan seluruh data berhasil disimpan."); }
// ========================================== // MANAJEMEN DATA & INISIALISASI SERVER // ========================================== private void initDataFile() { dataFile = new File(getDataFolder(), "data.yml"); if (!dataFile.exists()) { try { getDataFolder().mkdirs(); dataFile.createNewFile(); } catch (IOException e) { getLogger().severe("Gagal membuat file data.yml: " + e.getMessage()); } } dataConfig = YamlConfiguration.loadConfiguration(dataFile); }
private void saveDataFile() { if (dataConfig == null || dataFile == null) return; try { dataConfig.save(dataFile); } catch (IOException e) { getLogger().severe("Gagal menyimpan file data.yml: " + e.getMessage()); } }
private boolean isSysEnabled(String key) { return getConfig().getBoolean("systems." + key, true); }
private void setSysEnabled(String key, boolean state) { getConfig().set("systems." + key, state); saveConfig(); }
private void applyStartupRules() { if (isSysEnabled("hardlock")) { for (World world : Bukkit.getWorlds()) { world.setDifficulty(Difficulty.HARD); } }
applyCoordRule(isSysEnabled("hidecoord"));
if (!dataConfig.getBoolean("server.team_created", false)) { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "team add SigmaHidden"); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "team modify SigmaHidden nametagVisibility never"); dataConfig.set("server.team_created", true); saveDataFile(); } }
private void applyCoordRule(boolean hide) { for (World world : Bukkit.getWorlds()) { world.setGameRule(GameRule.REDUCED_DEBUG_INFO, hide); } }
private void startSchedulers() { // 1. Timer Pencatat Playtime (Setiap 1 Menit = 1200 Ticks) Bukkit.getScheduler().runTaskTimer(this, () -> { for (Player p : Bukkit.getOnlinePlayers()) { UUID uuid = p.getUniqueId(); dataConfig.set("players." + uuid + ".name", p.getName()); int current = dataConfig.getInt("players." + uuid + ".playtime", 0); dataConfig.set("players." + uuid + ".playtime", current + 1); } saveDataFile(); }, 1200L, 1200L);
// 2. Timer Pengumuman Leaderboard (Setiap 1,5 Jam / 90 Menit = 108000 Ticks) Bukkit.getScheduler().runTaskTimer(this, () -> { if (isSysEnabled("autoleaderboard")) { broadcastSigmaLeaderboard(); } }, 108000L, 108000L); }
private void registerCommands() { String[] cmds = {"sigma", "sigmalist", "koordinat", "bukaend", "playtime"}; for (String cmd : cmds) { PluginCommand pc = getCommand(cmd); if (pc != null) { pc.setExecutor(this); pc.setTabCompleter(this); } } }
@EventHandler public void onWorldInit(WorldInitEvent event) { if (isSysEnabled("hardlock")) { event.getWorld().setDifficulty(Difficulty.HARD); } event.getWorld().setGameRule(GameRule.REDUCED_DEBUG_INFO, isSysEnabled("hidecoord")); }
// ========================================== // 0. FUNGSI PENGIRIMAN DISCORD WEBHOOK (ASYNC) // ========================================== public void sendSigmaWebhook(String url, String content) { if (url == null || url.isEmpty() || url.contains("MASUKKAN_URL") || !url.startsWith("http")) { return; }
String clean = content .replace("\\", "\\\\") .replace("\"", "\\\"") .replace("\n", "\\n");
String json = "{\"content\": \"" + clean + "\"}";
try { HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(url)) .header("Content-Type", "application/json") .POST(HttpRequest.BodyPublishers.ofString(json)) .build();
httpClient.sendAsync(request, HttpResponse.BodyHandlers.ofString()); } catch (Exception e) { getLogger().warning("Gagal mengirim Discord Webhook: " + e.getMessage()); } }
// ========================================== // 1. DEATH LISTENER & CUSTOM DEATH CHAT // ========================================== @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerDamage(EntityDamageEvent event) { if (event.getEntity() instanceof Player victim) { lastDamageMap.put(victim.getUniqueId(), System.currentTimeMillis()); } }
@EventHandler public void onPlayerDeath(PlayerDeathEvent event) { Player victim = event.getEntity(); UUID victimUuid = victim.getUniqueId(); dataConfig.set("players." + victimUuid + ".name", victim.getName());
Player killer = victim.getKiller(); Entity damager = null; if (victim.getLastDamageCause() instanceof EntityDamageByEntityEvent entityEvent) { damager = entityEvent.getDamager(); }
if (killer != null && !killer.equals(victim)) { UUID killerUuid = killer.getUniqueId(); dataConfig.set("players." + killerUuid + ".name", killer.getName()); int kills = dataConfig.getInt("players." + killerUuid + ".kill", 0); dataConfig.set("players." + killerUuid + ".kill", kills + 1); }
// Custom Death Message Bahasa Indonesia String deathMsg; EntityDamageEvent.DamageCause cause = victim.getLastDamageCause() != null ? victim.getLastDamageCause().getCause() : EntityDamageEvent.DamageCause.CUSTOM;
if (killer != null) { if (!killer.equals(victim)) { ItemStack tool = killer.getInventory().getItemInMainHand(); if (tool.getType() == Material.AIR) { deathMsg = "&4&l[SIGMA] &cโ &e" + victim.getName() + " &ftewas dipukul tangan kosong oleh &c" + killer.getName() + "&f!"; } else { String toolName = formatMaterialName(tool.getType()); deathMsg = "&4&l[SIGMA] &cโ &e" + victim.getName() + " &fdibantai oleh &c" + killer.getName() + " &fmenggunakan &6" + toolName + "&f!"; } } else { deathMsg = "&4&l[SIGMA] &cโ &e" + victim.getName() + " &ftewas akibat ulahnya sendiri!"; } } else if (damager != null) { String mobName = damager.getCustomName() != null ? damager.getCustomName() : formatEntityName(damager.getType()); deathMsg = "&4&l[SIGMA] &cโ &e" + victim.getName() + " &ftewas mengenaskan dimangsa oleh &c" + mobName + "&f!"; } else if (cause == EntityDamageEvent.DamageCause.FALL) { deathMsg = "&4&l[SIGMA] &cโ &e" + victim.getName() + " &flupa bawa air dan tewas terjatuh dari ketinggian!"; } else if (cause == EntityDamageEvent.DamageCause.LAVA || cause == EntityDamageEvent.DamageCause.FIRE || cause == EntityDamageEvent.DamageCause.FIRE_TICK) { deathMsg = "&4&l[SIGMA] &cโ &e" + victim.getName() + " &fhangus terbakar sampai gosong!"; } else if (cause == EntityDamageEvent.DamageCause.DROWNING) { deathMsg = "&4&l[SIGMA] &cโ &e" + victim.getName() + " &fkehabisan napas dan tenggelam di kedalaman air!"; } else if (cause == EntityDamageEvent.DamageCause.BLOCK_EXPLOSION || cause == EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) { deathMsg = "&4&l[SIGMA] &cโ &e" + victim.getName() + " &fmeledak berkeping-keping!"; } else if (cause == EntityDamageEvent.DamageCause.VOID) { deathMsg = "&4&l[SIGMA] &cโ &e" + victim.getName() + " &fditelan bulat-bulat oleh kehampaan Void!"; } else if (cause == EntityDamageEvent.DamageCause.STARVATION) { deathMsg = "&4&l[SIGMA] &cโ &e" + victim.getName() + " &fmati kelaparan karena lupa makan!"; } else if (cause == EntityDamageEvent.DamageCause.SUFFOCATION) { deathMsg = "&4&l[SIGMA] &cโ &e" + victim.getName() + " &ftewas terjepit di dalam blok!"; } else { deathMsg = "&4&l[SIGMA] &cโ &e" + victim.getName() + " &ftewas secara tragis di kerasnya dunia SIGMA!"; }
String coloredDeathMsg = color(deathMsg); event.setDeathMessage(coloredDeathMsg);
if (!isSysEnabled("deathban")) { saveDataFile(); return; }
if (!victim.isOnline()) return; Long lastDmg = lastDamageMap.get(victimUuid); if (lastDmg == null || (System.currentTimeMillis() - lastDmg) > 15000L) return; if (cause == EntityDamageEvent.DamageCause.CUSTOM) return;
// Jalankan 1 tick setelah kematian Bukkit.getScheduler().runTaskLater(this, () -> { if (!dataConfig.getBoolean("server.first_death", false)) { Bukkit.broadcastMessage(color("&4&lSIGMA &e&l/ &f" + victim.getName() + " mati pertama kali aowkwk cupu banget")); dataConfig.set("server.first_death", true); }
int deaths = dataConfig.getInt("players." + victimUuid + ".death", 0) + 1; dataConfig.set("players." + victimUuid + ".death", deaths); saveDataFile();
String uncoloredMsg = ChatColor.stripColor(coloredDeathMsg); String publicWebhook = getConfig().getString("webhooks.public", ""); sendSigmaWebhook(publicWebhook, "๐ [SIGMA DEATH] " + uncoloredMsg);
String reason = "&cpoke hangat dek, belajar lagi ke KEN ya"; Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tempban " + victim.getName() + " 30m " + reason); victim.kickPlayer(color("&cKamu telah tewas!\n\n&e" + reason)); }, 1L); }
// ========================================== // 2. SISTEM JOIN & RANK (TANPA RTP) // ========================================== @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); UUID uuid = player.getUniqueId();
dataConfig.set("players." + uuid + ".name", player.getName());
if (!dataConfig.contains("players." + uuid + ".playtime")) { dataConfig.set("players." + uuid + ".playtime", 0); }
String rank = dataConfig.getString("players." + uuid + ".rank"); if (rank == null || rank.isEmpty()) { rank = "Beginner"; dataConfig.set("players." + uuid + ".rank", rank); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "lp user " + player.getName() + " parent set beginner"); player.sendMessage(color("&4&l[SIGMA] &fSelamat datang! Kamu otomatis mendapatkan rank &a&lBeginner&f.")); }
player.setPlayerListName(color("&8[&a" + rank + "&8] &f" + player.getName()));
if (!dataConfig.getBoolean("players." + uuid + ".ulang", false)) { dataConfig.set("players." + uuid + ".death", 0); dataConfig.set("players." + uuid + ".ulang", true); }
if (!dataConfig.getBoolean("players." + uuid + ".first", false)) { dataConfig.set("players." + uuid + ".first", true); }
saveDataFile();
World mainWorld = Bukkit.getWorld("world"); if (mainWorld != null) { player.setCompassTarget(new Location(mainWorld, 100000, 100, 100000)); }
if (isSysEnabled("nametag")) { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "team join SigmaHidden " + player.getName()); } }
// ========================================== // 3. COOLDOWN ENDER PEARL & TRIDENT (5 DETIK) // ========================================== @EventHandler public void onInteractCooldownAndFeatures(PlayerInteractEvent event) { Player player = event.getPlayer(); UUID uuid = player.getUniqueId(); Action action = event.getAction(); ItemStack item = event.getItem();
boolean isRightClick = (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK);
// Ban Senjata Mace & Spear saat Klik Kanan if (isRightClick && item != null && isSysEnabled("banweapon")) { if (isBannedWeapon(item.getType())) { event.setCancelled(true); player.getInventory().removeItem(item); player.sendMessage(color("&4&l[SIGMA] &cSenjata Mace dan Spear telah dinonaktifkan di server ini!")); return; } }
// Target Kompas saat Klik Kanan Blok if (action == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null && item != null && item.getType() == Material.COMPASS) { player.setCompassTarget(new Location(player.getWorld(), 100000, 100, 100000)); }
// Penguncian End Portal Frame if (action == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.END_PORTAL_FRAME) { if (isSysEnabled("endlock") && item != null && item.getType() == Material.ENDER_EYE) { event.setCancelled(true); player.sendMessage(color("&4&l[SIGMA] &cDimensi The End masih dikunci! Kamu belum bisa memasang Eye of Ender.")); return; } }
// Cooldown Ender Pearl & Trident if (!isRightClick || item == null || !isSysEnabled("cooldown")) return;
long now = System.currentTimeMillis(); if (item.getType() == Material.ENDER_PEARL) { Long lastUse = pearlCooldown.get(uuid); if (lastUse != null && (now - lastUse) < 5000L) { event.setCancelled(true); double sisa = (5000L - (now - lastUse)) / 1000.0; player.sendMessage(color(String.format("&c[SIGMA] Ender Pearl masih cooldown! Tunggu &e%.1f detik &clagi.", sisa))); return; } pearlCooldown.put(uuid, now); } else if (item.getType() == Material.TRIDENT) { Long lastUse = tridentCooldown.get(uuid); if (lastUse != null && (now - lastUse) < 5000L) { event.setCancelled(true); double sisa = (5000L - (now - lastUse)) / 1000.0; player.sendMessage(color(String.format("&c[SIGMA] Trident masih cooldown! Tunggu &e%.1f detik &clagi.", sisa))); } } }
@EventHandler public void onTridentLaunch(ProjectileLaunchEvent event) { if (!isSysEnabled("cooldown")) return; if (event.getEntity() instanceof Trident && event.getEntity().getShooter() instanceof Player shooter) { UUID uuid = shooter.getUniqueId(); long now = System.currentTimeMillis(); Long lastUse = tridentCooldown.get(uuid); if (lastUse != null && (now - lastUse) < 5000L) { event.setCancelled(true); return; } tridentCooldown.put(uuid, now); } }
@EventHandler public void onPlayerRiptide(PlayerRiptideEvent event) { if (isSysEnabled("cooldown")) { tridentCooldown.put(event.getPlayer().getUniqueId(), System.currentTimeMillis()); } }
// ========================================== // 4. ANTI-XRAY ALERT (NOTIFIKASI OP & DISCORD) // ========================================== @EventHandler(ignoreCancelled = true) public void onOreBreak(BlockBreakEvent event) { if (!isSysEnabled("antixray")) return; Player player = event.getPlayer(); if (player.getGameMode() == GameMode.CREATIVE) return;
Block block = event.getBlock(); Material type = block.getType(); if (type != Material.DIAMOND_ORE && type != Material.DEEPSLATE_DIAMOND_ORE && type != Material.ANCIENT_DEBRIS && type != Material.EMERALD_ORE && type != Material.DEEPSLATE_EMERALD_ORE) { return; }
UUID uuid = player.getUniqueId(); long now = System.currentTimeMillis();
Long startTime = xrayTimeMap.get(uuid); if (startTime == null || (now - startTime) > 180000L) { // 3 Menit xrayTimeMap.put(uuid, now); xrayCountMap.put(uuid, 0); }
int count = xrayCountMap.getOrDefault(uuid, 0) + 1; xrayCountMap.put(uuid, count);
int limit = (type == Material.ANCIENT_DEBRIS) ? 4 : 9; if (count >= limit) { Long lastAlert = xrayAlertCdMap.get(uuid); if (lastAlert != null && (now - lastAlert) < 10000L) { // Cooldown 10 detik return; } xrayAlertCdMap.put(uuid, now);
Location loc = player.getLocation(); int x = loc.getBlockX(); int y = loc.getBlockY(); int z = loc.getBlockZ(); String blockName = formatMaterialName(type);
String inGameAlert = color("&4&l[SIGMA Anti-Xray] &e" + player.getName() + " &fmenambang &b" + count + "x " + blockName + " &fdalam 3 menit! &7(Lokasi: X:" + x + " Y:" + y + " Z:" + z + ")");
for (Player online : Bukkit.getOnlinePlayers()) { if (online.isOp()) { online.sendMessage(inGameAlert); } }
String discordAlert = "๐จ [ANTI-XRAY ALERT]\n" + "Player: " + player.getName() + "\n" + "Aktivitas: Menambang " + count + "x " + blockName + " dalam 3 menit.\n" + "Lokasi: X:" + x + " Y:" + y + " Z:" + z;
sendSigmaWebhook(getConfig().getString("webhooks.admin", ""), discordAlert); } }
// ========================================== // 5. SISTEM PENDUKUNG (CHAT, TOTEM, BAN MACE/SPEAR, END LOCK) // ========================================== @EventHandler public void onPlayerChat(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); if (isSysEnabled("chatlock") && !player.isOp()) { player.sendMessage(color("&cChat Disable")); event.setCancelled(true); return; } String rank = dataConfig.getString("players." + player.getUniqueId() + ".rank", "Beginner"); event.setFormat(color("&8[&a" + rank + "&8] &f") + "%1$s" + color("&7: &f") + "%2$s"); }
@EventHandler public void onEvokerDeath(EntityDeathEvent event) { if (event.getEntityType() == EntityType.EVOKER && isSysEnabled("nototem")) { event.getDrops().clear(); } }
@EventHandler(ignoreCancelled = true) public void onCraftBannedWeapon(CraftItemEvent event) { if (!isSysEnabled("banweapon")) return; ItemStack result = event.getRecipe().getResult(); if (isBannedWeapon(result.getType())) { event.setCancelled(true); if (event.getWhoClicked() instanceof Player player) { player.sendMessage(color("&4&l[SIGMA] &cPembuatan (Crafting) Mace dan Spear dilarang di server ini!")); } } }
@EventHandler(ignoreCancelled = true) public void onDamageWithBannedWeapon(EntityDamageByEntityEvent event) { if (!isSysEnabled("banweapon")) return; if (event.getDamager() instanceof Player attacker) { ItemStack tool = attacker.getInventory().getItemInMainHand(); if (isBannedWeapon(tool.getType())) { event.setCancelled(true); attacker.getInventory().removeItem(tool); attacker.sendMessage(color("&4&l[SIGMA] &cSenjata Mace dan Spear telah dinonaktifkan di server ini!")); } } }
@EventHandler(ignoreCancelled = true) public void onTeleportToEnd(PlayerTeleportEvent event) { if (!isSysEnabled("endlock")) return; if (event.getTo() == null || event.getTo().getWorld() == null) return;
World destWorld = event.getTo().getWorld(); if (destWorld.getEnvironment() == World.Environment.THE_END || destWorld.getName().equalsIgnoreCase("world_the_end")) { Player player = event.getPlayer(); if (!player.isOp()) { event.setCancelled(true); UUID uuid = player.getUniqueId(); long now = System.currentTimeMillis(); Long lastMsg = endMsgCooldown.get(uuid); if (lastMsg != null && (now - lastMsg) < 3000L) return; endMsgCooldown.put(uuid, now); player.sendMessage(color("&4&l[SIGMA] &cDimensi The End saat ini masih ditutup oleh Admin!")); } } }
private boolean isBannedWeapon(Material mat) { if (mat == null) return false; String name = mat.name().toLowerCase(); return name.contains("mace") || name.contains("spear"); }
// ========================================== // 6. LEADERBOARD OTOMATIS (TOP KILL, MATI, PLAYTIME) // ========================================== public void broadcastSigmaLeaderboard() { List> topKills = getTopStats("kill", 3); List> topDeaths = getTopStats("death", 3); List> topPlaytime = getTopStats("playtime", 3);
String nameKill1 = topKills.size() > 0 ? topKills.get(0).getKey() : "Belum Ada"; int valKill1 = topKills.size() > 0 ? topKills.get(0).getValue() : 0; String nameKill2 = topKills.size() > 1 ? topKills.get(1).getKey() : "Belum Ada"; int valKill2 = topKills.size() > 1 ? topKills.get(1).getValue() : 0; String nameKill3 = topKills.size() > 2 ? topKills.get(2).getKey() : "Belum Ada"; int valKill3 = topKills.size() > 2 ? topKills.get(2).getValue() : 0;
String nameDeath1 = topDeaths.size() > 0 ? topDeaths.get(0).getKey() : "Belum Ada"; int valDeath1 = topDeaths.size() > 0 ? topDeaths.get(0).getValue() : 0; String nameDeath2 = topDeaths.size() > 1 ? topDeaths.get(1).getKey() : "Belum Ada"; int valDeath2 = topDeaths.size() > 1 ? topDeaths.get(1).getValue() : 0; String nameDeath3 = topDeaths.size() > 2 ? topDeaths.get(2).getKey() : "Belum Ada"; int valDeath3 = topDeaths.size() > 2 ? topDeaths.get(2).getValue() : 0;
String nameTime1 = topPlaytime.size() > 0 ? topPlaytime.get(0).getKey() : "Belum Ada"; int valTime1 = topPlaytime.size() > 0 ? topPlaytime.get(0).getValue() : 0; String nameTime2 = topPlaytime.size() > 1 ? topPlaytime.get(1).getKey() : "Belum Ada"; int valTime2 = topPlaytime.size() > 1 ? topPlaytime.get(1).getValue() : 0; String nameTime3 = topPlaytime.size() > 2 ? topPlaytime.get(2).getKey() : "Belum Ada"; int valTime3 = topPlaytime.size() > 2 ? topPlaytime.get(2).getValue() : 0;
int jam1 = valTime1 / 60, mnt1 = valTime1 % 60; int jam2 = valTime2 / 60, mnt2 = valTime2 % 60; int jam3 = valTime3 / 60, mnt3 = valTime3 % 60;
// Broadcast In-Game Bukkit.broadcastMessage(color("&8&m========================================")); Bukkit.broadcastMessage(color("&4&l SIGMA LEADERBOARD (1.5 JAM) ")); Bukkit.broadcastMessage(""); Bukkit.broadcastMessage(color("&c&lโ TOP KILL (PEMBANTAI SERVER):")); Bukkit.broadcastMessage(color("&7 1. &e" + nameKill1 + " &8- &a" + valKill1 + " Kill")); Bukkit.broadcastMessage(color("&7 2. &e" + nameKill2 + " &8- &a" + valKill2 + " Kill")); Bukkit.broadcastMessage(color("&7 3. &e" + nameKill3 + " &8- &a" + valKill3 + " Kill")); Bukkit.broadcastMessage(""); Bukkit.broadcastMessage(color("&4&lโ TOP MATI (PALING SERING TUMBANG):")); Bukkit.broadcastMessage(color("&7 1. &e" + nameDeath1 + " &8- &c" + valDeath1 + "x Mati")); Bukkit.broadcastMessage(color("&7 2. &e" + nameDeath2 + " &8- &c" + valDeath2 + "x Mati")); Bukkit.broadcastMessage(color("&7 3. &e" + nameDeath3 + " &8- &c" + valDeath3 + "x Mati")); Bukkit.broadcastMessage(""); Bukkit.broadcastMessage(color("&6&lโณ TOP PLAYTIME (PALING AKTIF):")); Bukkit.broadcastMessage(color("&7 1. &e" + nameTime1 + " &8- &b" + jam1 + " Jam " + mnt1 + " Menit")); Bukkit.broadcastMessage(color("&7 2. &e" + nameTime2 + " &8- &b" + jam2 + " Jam " + mnt2 + " Menit")); Bukkit.broadcastMessage(color("&7 3. &e" + nameTime3 + " &8- &b" + jam3 + " Jam " + mnt3 + " Menit")); Bukkit.broadcastMessage(color("&8&m========================================"));
// Kirim ke Discord Webhook Publik String dcMsg = "๐ SIGMA LEADERBOARD (1.5 JAM) ๐\n\n" + "โ๏ธ TOP KILL (PEMBANTAI):\n" + "> 1. " + nameKill1 + " - " + valKill1 + " Kill\n" + "> 2. " + nameKill2 + " - " + valKill2 + " Kill\n" + "> 3. " + nameKill3 + " - " + valKill3 + " Kill\n\n" + "๐ TOP MATI (SERING TUMBANG):\n" + "> 1. " + nameDeath1 + " - " + valDeath1 + "x Mati\n" + "> 2. " + nameDeath2 + " - " + valDeath2 + "x Mati\n" + "> 3. " + nameDeath3 + " - " + valDeath3 + "x Mati\n\n" + "โณ TOP PLAYTIME (PALING AKTIF):\n" + "> 1. " + nameTime1 + " - " + jam1 + " Jam " + mnt1 + " Menit\n" + "> 2. " + nameTime2 + " - " + jam2 + " Jam " + mnt2 + " Menit\n" + "> 3. " + nameTime3 + " - " + jam3 + " Jam " + mnt3 + " Menit";
sendSigmaWebhook(getConfig().getString("webhooks.public", ""), dcMsg); }
private List> getTopStats(String statKey, int limit) { ConfigurationSection section = dataConfig.getConfigurationSection("players"); if (section == null) return Collections.emptyList();
List> list = new ArrayList<>(); for (String uuidStr : section.getKeys(false)) { int val = section.getInt(uuidStr + "." + statKey, 0); if (val > 0) { String name = section.getString(uuidStr + ".name", "Player"); list.add(new AbstractMap.SimpleEntry<>(name, val)); } } list.sort((a, b) -> Integer.compare(b.getValue(), a.getValue())); return list.stream().limit(limit).collect(Collectors.toList()); }
// ========================================== // 7. HANDLER SELURUH COMMAND & PANEL KONTROL // ========================================== @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { String cmd = command.getName().toLowerCase();
// A. Command /playtime if (cmd.equals("playtime")) { OfflinePlayer target; if (args.length > 0) { target = Bukkit.getOfflinePlayer(args[0]); } else if (sender instanceof Player p) { target = p; } else { sender.sendMessage(color("&cFormat: /playtime <nama_player>")); return true; }
int total = dataConfig.getInt("players." + target.getUniqueId() + ".playtime", 0); int jam = total / 60; int menit = total % 60;
if (sender instanceof Player p && p.getUniqueId().equals(target.getUniqueId())) { sender.sendMessage(color("&4&l[SIGMA] &fTotal waktu bermainmu: &b" + jam + " Jam " + menit + " Menit")); } else { String name = target.getName() != null ? target.getName() : args[0]; sender.sendMessage(color("&4&l[SIGMA] &fTotal waktu bermain &e" + name + "&f: &b" + jam + " Jam " + menit + " Menit")); } return true; }
// B. Command /sigmalist if (cmd.equals("sigmalist")) { sendSigmaCommandList(sender); return true; }
// C. Command /koordinat if (cmd.equals("koordinat")) { boolean hide; if (args.length > 0) { String sub = args[0].toLowerCase(); if (Arrays.asList("buka", "open", "on", "show").contains(sub)) { hide = false; } else if (Arrays.asList("tutup", "close", "off", "hide").contains(sub)) { hide = true; } else { hide = !isSysEnabled("hidecoord"); } } else { hide = !isSysEnabled("hidecoord"); }
setSysEnabled("hidecoord", hide); applyCoordRule(hide); if (hide) { Bukkit.broadcastMessage(color("&4&l[SIGMA] &fKoordinat server telah &c&lDISEMBUNYIKAN &foleh Admin!")); } else { Bukkit.broadcastMessage(color("&4&l[SIGMA] &fKoordinat server telah &a&lDIBUKA &foleh Admin!")); } return true; }
// D. Command /bukaend if (cmd.equals("bukaend")) { boolean locked; if (args.length > 0) { String sub = args[0].toLowerCase(); if (Arrays.asList("buka", "open", "on").contains(sub)) { locked = false; } else if (Arrays.asList("tutup", "close", "off").contains(sub)) { locked = true; } else { locked = !isSysEnabled("endlock"); } } else { locked = !isSysEnabled("endlock"); }
setSysEnabled("endlock", locked); Bukkit.broadcastMessage(color("&8&m----------------------------------------")); if (locked) { Bukkit.broadcastMessage(color("&4&l[SIGMA] &fGerbang menuju dimensi &5&lTHE END &ftelah &c&lDIKUNCI&f!")); } else { Bukkit.broadcastMessage(color("&4&l[SIGMA] &fGerbang menuju dimensi &5&lTHE END &ftelah &a&lDIBUKA&f!")); } Bukkit.broadcastMessage(color("&8&m----------------------------------------")); return true; }
// E. Command Utama /sigma if (cmd.equals("sigma")) { if (args.length == 0 || Arrays.asList("list", "help", "cmd").contains(args[0].toLowerCase())) { sendSigmaCommandList(sender); return true; }
String sub = args[0].toLowerCase();
if (sub.equals("status")) { sender.sendMessage(color("&8&m----------------------------------------")); sender.sendMessage(color("&4&lSTATUS SISTEM SIGMA:")); for (String key : SYSTEM_KEYS) { sender.sendMessage(color("&7- " + key + ": &e" + isSysEnabled(key))); } sender.sendMessage(color("&8&m----------------------------------------")); return true; }
if (Arrays.asList("top", "leaderboard", "announce").contains(sub)) { broadcastSigmaLeaderboard(); return true; }
if (sub.equals("testwebhook")) { sender.sendMessage(color("&4&l[SIGMA] &7Mengirim pesan uji coba ke Webhook Admin dan Publik...")); sendSigmaWebhook(getConfig().getString("webhooks.admin", ""), "โ
[SIGMA TEST] Webhook Admin berhasil terhubung!"); sendSigmaWebhook(getConfig().getString("webhooks.public", ""), "โ
[SIGMA TEST] Webhook Publik berhasil terhubung!"); return true; }
if (sub.equals("reload")) { reloadConfig(); applyStartupRules(); sender.sendMessage(color("&a[SIGMA] Konfigurasi config.yml dan URL Webhook berhasil dimuat ulang!")); return true; }
if (sub.equals("resetdeath")) { if (args.length < 2) { sender.sendMessage(color("&cFormat: /sigma resetdeath <nama_player>")); return true; } OfflinePlayer target = Bukkit.getOfflinePlayer(args[1]); dataConfig.set("players." + target.getUniqueId() + ".death", 0); dataConfig.set("players." + target.getUniqueId() + ".first", null); saveDataFile(); sender.sendMessage(color("&a[SIGMA] Data kematian dan status first-spawn milik &e" + args[1] + " &aberhasil di-reset!")); return true; }
if (sub.equals("resetplaytime")) { if (args.length < 2) { sender.sendMessage(color("&cFormat: /sigma resetplaytime <nama_player>")); return true; } OfflinePlayer target = Bukkit.getOfflinePlayer(args[1]); dataConfig.set("players." + target.getUniqueId() + ".playtime", 0); saveDataFile(); sender.sendMessage(color("&a[SIGMA] Data waktu bermain (playtime) milik &e" + args[1] + " &aberhasil di-reset ke 0!")); return true; }
if (SYSTEM_KEYS.contains(sub)) { boolean current = isSysEnabled(sub); boolean next = !current; setSysEnabled(sub, next);
if (next) { sender.sendMessage(color("&4[SIGMA] &fSistem &e" + sub + " &ftelah &a&lDIAKTIFKAN&f!")); } else { sender.sendMessage(color("&4[SIGMA] &fSistem &e" + sub + " &ftelah &c&lDINONAKTIFKAN&f!")); }
if (sub.equals("hidecoord")) { applyCoordRule(next); } else if (sub.equals("hardlock") && next) { for (World w : Bukkit.getWorlds()) { w.setDifficulty(Difficulty.HARD); } } return true; }
sender.sendMessage(color("&cSistem tidak dikenal! Ketik &e/sigmalist &catau &e/sigma &cuntuk melihat daftar lengkap command.")); return true; }
return false; }
private void sendSigmaCommandList(CommandSender p) { p.sendMessage(color("&8&m========================================")); p.sendMessage(color("&4&l DAFTAR LENGKAP COMMAND SIGMA ")); p.sendMessage(""); p.sendMessage(color("&6&lA. Command Utama & Informasi:")); p.sendMessage(color("&e/playtime [nama_player] &8(Alias: &7/pt, /waktu&8)")); p.sendMessage(color(" &7โ Mengecek total waktu bermain diri sendiri atau pemain lain")); p.sendMessage(color("&e/sigmalist &8(Alias: &7/sigmahelp, /sigmacmd&8)")); p.sendMessage(color(" &7โ Menampilkan daftar seluruh command yang ada di server SIGMA")); p.sendMessage(color("&e/sigma status")); p.sendMessage(color(" &7โ Mengecek status aktif/nonaktif semua sistem server")); p.sendMessage(color("&e/sigma top &8(Alias: &7/sigma leaderboard&8)")); p.sendMessage(color(" &7โ Menampilkan pengumuman Top Kill, Mati & Playtime secara langsung")); p.sendMessage(color("&e/sigma testwebhook")); p.sendMessage(color(" &7โ Mengirim pesan tes ke Webhook Admin dan Webhook Publik")); p.sendMessage(color("&e/sigma reload")); p.sendMessage(color(" &7โ Memuat ulang config.yml dan URL Webhook tanpa restart")); p.sendMessage(""); p.sendMessage(color("&6&lB. Command Kontrol Dunia & Pemain:")); p.sendMessage(color("&e/koordinat [buka|tutup] &8(Alias: &7/coord, /coords, /bukakoordinat&8)")); p.sendMessage(color(" &7โ Membuka atau menyembunyikan koordinat F3 seluruh pemain")); p.sendMessage(color("&e/bukaend [buka|tutup] &8(Alias: &7/openend, /endlock&8)")); p.sendMessage(color(" &7โ Membuka atau mengunci akses ke dimensi The End")); p.sendMessage(color("&e/sigma resetdeath <nama_player>")); p.sendMessage(color(" &7โ Mereset jumlah kematian dan status first-spawn milik pemain")); p.sendMessage(color("&e/sigma resetplaytime <nama_player>")); p.sendMessage(color(" &7โ Mereset total waktu bermain (playtime) milik pemain")); p.sendMessage(""); p.sendMessage(color("&6&lC. Command Toggle Sistem (/sigma <nama_sistem>):")); p.sendMessage(color("&e/sigma deathban &7- Aktif/nonaktifkan ban 30 menit saat mati")); p.sendMessage(color("&e/sigma chatlock &7- Aktif/nonaktifkan penguncian chat publik")); p.sendMessage(color("&e/sigma nametag &7- Aktif/nonaktifkan penyembunyian nametag pemain")); p.sendMessage(color("&e/sigma nototem &7- Aktif/nonaktifkan penghapusan drop Totem dari Evoker")); p.sendMessage(color("&e/sigma cooldown &7- Aktif/nonaktifkan cooldown 5 detik Ender Pearl & Trident")); p.sendMessage(color("&e/sigma antixray &7- Aktif/nonaktifkan notifikasi Anti-Xray untuk OP")); p.sendMessage(color("&e/sigma endlock &7- Aktif/nonaktifkan penguncian dimensi The End")); p.sendMessage(color("&e/sigma hidecoord &7- Aktif/nonaktifkan penyembunyian koordinat F3")); p.sendMessage(color("&e/sigma hardlock &7- Aktif/nonaktifkan penguncian difficulty Hard")); p.sendMessage(color("&e/sigma banweapon &7- Aktif/nonaktifkan larangan crafting/pakai Mace & Spear")); p.sendMessage(color("&e/sigma autoleaderboard &7- Aktif/nonaktifkan pengumuman Leaderboard tiap 1.5 Jam")); p.sendMessage(color("&8&m========================================")); }
@Override public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { String cmd = command.getName().toLowerCase(); if (cmd.equals("koordinat") || cmd.equals("bukaend")) { if (args.length == 1) { return filterSuggestions(Arrays.asList("buka", "tutup"), args[0]); } } else if (cmd.equals("sigma")) { if (args.length == 1) { List<String> options = new ArrayList<>(SYSTEM_KEYS); options.addAll(Arrays.asList("status", "top", "leaderboard", "testwebhook", "reload", "resetdeath", "resetplaytime", "list")); return filterSuggestions(options, args[0]); } else if (args.length == 2 && (args[0].equalsIgnoreCase("resetdeath") || args[0].equalsIgnoreCase("resetplaytime"))) { return null; // Menampilkan daftar nama pemain online } } return Collections.emptyList(); }
private List<String> filterSuggestions(List<String> list, String input) { return list.stream() .filter(s -> s.toLowerCase().startsWith(input.toLowerCase())) .collect(Collectors.toList()); }
// ========================================== // UTILITAS TEKS & FORMATTER // ========================================== private String color(String text) { return ChatColor.translateAlternateColorCodes('&', text); }
private String formatMaterialName(Material mat) { return Arrays.stream(mat.name().toLowerCase().split("_")) .map(w -> w.isEmpty() ? w : Character.toUpperCase(w.charAt(0)) + w.substring(1)) .collect(Collectors.joining(" ")); }
private String formatEntityName(EntityType type) { return Arrays.stream(type.name().toLowerCase().split("_")) .map(w -> w.isEmpty() ? w : Character.toUpperCase(w.charAt(0)) + w.substring(1)) .collect(Collectors.joining(" ")); } }
- Prosedur Build & Deployment (Panduan Instalasi)
* Kompilasi Maven (.jar) * Buka direktori root proyek menggunakan terminal atau IDE (seperti IntelliJ IDEA). * Jalankan perintah kompilasi berikut untuk mem-build source code menjadi file eksekusi: mvn clean package
* File hasil kompilasi SigmaCore.jar akan di-generate secara otomatis di dalam direktori target/. * Pemasangan ke Server * Pindahkan file SigmaCore.jar ke dalam direktori plugins/ pada server kamu. * Penting: Pastikan untuk menghapus atau menonaktifkan file sigma.sk (sistem versi lama) yang sebelumnya terpasang di folder Skript agar tidak terjadi bentrok sistem (conflict). * Lakukan restart server untuk memuat plugin secara perdana. * Konfigurasi Webhook Discord * Setelah restart, buka file plugins/SigmaCore/config.yml. * Masukkan URL Discord Webhook server pada bagian webhooks.admin dan webhooks.public. * Di dalam konsol atau in-game (sebagai OP), ketik command berikut untuk memuat ulang konfigurasi tanpa restart server: /sigma reload
* Ketik command berikut untuk menguji koneksi Webhook: /sigma testwebhook