1.5 | Multiversion (1.16.3-26.2)
This commit is contained in:
+5
-4
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'de.winniepat'
|
group = 'de.winniepat'
|
||||||
version = '1.4'
|
version = '1.5'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -12,12 +12,13 @@ repositories {
|
|||||||
maven { url = 'https://jitpack.io' }
|
maven { url = 'https://jitpack.io' }
|
||||||
}
|
}
|
||||||
|
|
||||||
def mcVersion = project.findProperty('mcVersion') ?: '1.21.4-R0.1-SNAPSHOT'
|
def mcApiGroup = project.findProperty('mcApiGroup') ?: 'com.destroystokyo.paper'
|
||||||
|
def mcVersion = project.findProperty('mcVersion') ?: '1.16.5-R0.1-SNAPSHOT'
|
||||||
def deployDir = project.findProperty('deployDir') ?: 'C:/Users/winnie/Documents/lunaris/server/plugins'
|
def deployDir = project.findProperty('deployDir') ?: 'C:/Users/winnie/Documents/lunaris/server/plugins'
|
||||||
def minJavaVersion = 21
|
def minJavaVersion = 11
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("io.papermc.paper:paper-api:${mcVersion}")
|
compileOnly("${mcApiGroup}:paper-api:${mcVersion}")
|
||||||
|
|
||||||
compileOnly('com.github.MilkBowl:VaultAPI:1.7') {
|
compileOnly('com.github.MilkBowl:VaultAPI:1.7') {
|
||||||
exclude group: 'org.bukkit', module: 'bukkit'
|
exclude group: 'org.bukkit', module: 'bukkit'
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ public final class GamblingPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
String serverVersion = ServerVersion.current();
|
String serverVersion = ServerVersion.current();
|
||||||
if (ServerVersion.isSupported(serverVersion)) {
|
if (ServerVersion.isSupported(serverVersion)) {
|
||||||
getLogger().info("GamblingPlugin enabled on Minecraft " + serverVersion
|
getLogger().info("GamblingPlugin enabled on Minecraft " + serverVersion + ".");
|
||||||
+ " (supported: " + ServerVersion.MIN_SUPPORTED + " - " + ServerVersion.MAX_SUPPORTED + ").");
|
|
||||||
} else {
|
} else {
|
||||||
getLogger().warning("Running on unsupported Minecraft version " + serverVersion
|
getLogger().warning("Running on unsupported Minecraft version " + serverVersion
|
||||||
+ "! Supported range: " + ServerVersion.MIN_SUPPORTED + " - " + ServerVersion.MAX_SUPPORTED
|
+ "! Supported range: " + ServerVersion.MIN_SUPPORTED + " - " + ServerVersion.MAX_SUPPORTED
|
||||||
|
|||||||
@@ -13,10 +13,11 @@ public class CaseCommand implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!(sender instanceof Player player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Only players can use this command.");
|
sender.sendMessage("Only players can use this command.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (GamblingPlugin.getInstance().getEconomy().getBalance(player) < COST) {
|
if (GamblingPlugin.getInstance().getEconomy().getBalance(player) < COST) {
|
||||||
player.sendMessage("§cYou don't have enough money to open a case! §7(Required: $" + (int) COST + ")");
|
player.sendMessage("§cYou don't have enough money to open a case! §7(Required: $" + (int) COST + ")");
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ public class DoubleCommand implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (!(sender instanceof Player player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Only players can use this.");
|
sender.sendMessage("Only players can use this.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DoubleGUI.open(player);
|
DoubleGUI.open((Player) sender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,12 @@ public class RouletteCommand implements CommandExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!(sender instanceof Player player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Only players can use this command.");
|
sender.sendMessage("Only players can use this command.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
player.openInventory(RouletteGUI.createBettingGUI());
|
player.openInventory(RouletteGUI.createBettingGUI());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package de.winniepat.gamblingPlugin.gui;
|
package de.winniepat.gamblingPlugin.gui;
|
||||||
|
|
||||||
import de.winniepat.gamblingPlugin.GamblingPlugin;
|
import de.winniepat.gamblingPlugin.GamblingPlugin;
|
||||||
|
import de.winniepat.gamblingPlugin.util.Particles;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -143,11 +144,17 @@ public class SlotGUI implements Listener {
|
|||||||
GamblingPlugin.getInstance().getEconomy().depositPlayer(player, reward);
|
GamblingPlugin.getInstance().getEconomy().depositPlayer(player, reward);
|
||||||
player.sendMessage("§aYou won $" + reward + "! (x" + multiplier + ")");
|
player.sendMessage("§aYou won $" + reward + "! (x" + multiplier + ")");
|
||||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1f, 1f);
|
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1f, 1f);
|
||||||
player.getWorld().spawnParticle(Particle.ELECTRIC_SPARK, player.getLocation().add(0, 1.5, 0), 30, 0.3, 0.5, 0.3);
|
Particle spark = Particles.byName("ELECTRIC_SPARK", "CRIT");
|
||||||
|
if (spark != null) {
|
||||||
|
player.getWorld().spawnParticle(spark, player.getLocation().add(0, 1.5, 0), 30, 0.3, 0.5, 0.3);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage("§cYou lost! Better luck next time.");
|
player.sendMessage("§cYou lost! Better luck next time.");
|
||||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 0.5f);
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 0.5f);
|
||||||
player.getWorld().spawnParticle(Particle.SMOKE, player.getLocation().add(0, 1.0, 0), 10, 0.2, 0.2, 0.2);
|
Particle smoke = Particles.byName("SMOKE", "SMOKE_NORMAL");
|
||||||
|
if (smoke != null) {
|
||||||
|
player.getWorld().spawnParticle(smoke, player.getLocation().add(0, 1.0, 0), 10, 0.2, 0.2, 0.2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package de.winniepat.gamblingPlugin.listeners;
|
package de.winniepat.gamblingPlugin.listeners;
|
||||||
|
|
||||||
import de.winniepat.gamblingPlugin.animations.CaseAnimation;
|
import de.winniepat.gamblingPlugin.animations.CaseAnimation;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -13,21 +14,25 @@ public class CaseListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
if (isCaseView(e.getView(), e.getWhoClicked() instanceof Player player ? player : null)) {
|
if (isCaseView(e.getView(), playerOf(e.getWhoClicked()))) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryDrag(InventoryDragEvent e) {
|
public void onInventoryDrag(InventoryDragEvent e) {
|
||||||
if (isCaseView(e.getView(), e.getWhoClicked() instanceof Player player ? player : null)) {
|
if (isCaseView(e.getView(), playerOf(e.getWhoClicked()))) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClose(InventoryCloseEvent e) {
|
public void onInventoryClose(InventoryCloseEvent e) {
|
||||||
CaseAnimation.onCaseClosed(e.getPlayer() instanceof Player player ? player : null, e.getView().getTopInventory());
|
CaseAnimation.onCaseClosed(playerOf(e.getPlayer()), e.getView().getTopInventory());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Player playerOf(HumanEntity entity) {
|
||||||
|
return entity instanceof Player ? (Player) entity : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCaseView(InventoryView view, Player player) {
|
private boolean isCaseView(InventoryView view, Player player) {
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ public class RouletteListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
if (!(event.getWhoClicked() instanceof Player player)) return;
|
if (!(event.getWhoClicked() instanceof Player)) return;
|
||||||
|
Player player = (Player) event.getWhoClicked();
|
||||||
if (event.getClickedInventory() == null || event.getCurrentItem() == null) return;
|
if (event.getClickedInventory() == null || event.getCurrentItem() == null) return;
|
||||||
|
|
||||||
String title = event.getView().getTitle();
|
String title = event.getView().getTitle();
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package de.winniepat.gamblingPlugin.util;
|
||||||
|
|
||||||
|
import org.bukkit.Particle;
|
||||||
|
|
||||||
|
public final class Particles {
|
||||||
|
|
||||||
|
private Particles() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Particle byName(String name, String... fallbacks) {
|
||||||
|
Particle particle = valueOf(name);
|
||||||
|
if (particle != null) {
|
||||||
|
return particle;
|
||||||
|
}
|
||||||
|
for (String fallback : fallbacks) {
|
||||||
|
particle = valueOf(fallback);
|
||||||
|
if (particle != null) {
|
||||||
|
return particle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Particle valueOf(String name) {
|
||||||
|
try {
|
||||||
|
return Particle.valueOf(name);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,14 +4,18 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
public final class ServerVersion {
|
public final class ServerVersion {
|
||||||
|
|
||||||
public static final String MIN_SUPPORTED = "1.21.4";
|
public static final String MIN_SUPPORTED = "1.16.3";
|
||||||
public static final String MAX_SUPPORTED = "26.1.2";
|
public static final String MAX_SUPPORTED = "26.2";
|
||||||
|
|
||||||
private ServerVersion() {
|
private ServerVersion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String current() {
|
public static String current() {
|
||||||
return Bukkit.getMinecraftVersion();
|
try {
|
||||||
|
return Bukkit.getMinecraftVersion();
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
return Bukkit.getBukkitVersion().split("-")[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSupported() {
|
public static boolean isSupported() {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: GamblingPlugin
|
name: GamblingPlugin
|
||||||
version: '${version}'
|
version: '${version}'
|
||||||
main: de.winniepat.gamblingPlugin.GamblingPlugin
|
main: de.winniepat.gamblingPlugin.GamblingPlugin
|
||||||
api-version: '1.21'
|
api-version: '1.16'
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
authors: [ WinniePat ]
|
authors: [ WinniePat ]
|
||||||
description: KekClient
|
description: KekClient
|
||||||
|
|||||||
Reference in New Issue
Block a user