Compare commits
No commits in common. "131d131dfebfe3a82ba884a0ce0cf08af072420f" and "f36e6b1aa03c318dfc98cc23dfe7b26c262e6fe3" have entirely different histories.
131d131dfe
...
f36e6b1aa0
@ -24,19 +24,5 @@ public class BanHourly implements Listener{
|
|||||||
e.setKeepLevel(false);
|
e.setKeepLevel(false);
|
||||||
e.getDrops().clear();
|
e.getDrops().clear();
|
||||||
e.getPlayer().kick(Component.text("Vous etes mort dans la dernière heure... Patientez la prochaine!"), Cause.BANNED);
|
e.getPlayer().kick(Component.text("Vous etes mort dans la dernière heure... Patientez la prochaine!"), Cause.BANNED);
|
||||||
|
|
||||||
// Send death
|
|
||||||
String link = DatabaseManager.getInstance().getConfig("discord-wh");
|
|
||||||
if(!link.equals("")){
|
|
||||||
DiscordWebhook discord = new DiscordWebhook(link);
|
|
||||||
discord.setUsername("Ange de la mort");
|
|
||||||
discord.setAvatarUrl("http://static.planetminecraft.com/files/banners/minecraft_banner_18d1g881yg5831c.png");
|
|
||||||
discord.setContent(e.getDeathMessage());
|
|
||||||
try {
|
|
||||||
discord.execute();
|
|
||||||
} catch(Exception ex){
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,6 @@ public class DatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setVoids(UUID uuid, int amount) {
|
public void setVoids(UUID uuid, int amount) {
|
||||||
Bukkit.getLogger().info("[VOIDS] -> " + uuid.toString() + " to " + amount);
|
|
||||||
try {
|
try {
|
||||||
Statement st = con.createStatement();
|
Statement st = con.createStatement();
|
||||||
String query = "INSERT OR REPLACE INTO voids (uuid, amount) VALUES (?, ?)";
|
String query = "INSERT OR REPLACE INTO voids (uuid, amount) VALUES (?, ?)";
|
||||||
|
@ -76,9 +76,9 @@ public class Merchand implements Listener{
|
|||||||
current = genTrade(System.currentTimeMillis() / (1000 * 60 * 60));
|
current = genTrade(System.currentTimeMillis() / (1000 * 60 * 60));
|
||||||
next = genTrade(1 + System.currentTimeMillis() / (1000 * 60 * 60));
|
next = genTrade(1 + System.currentTimeMillis() / (1000 * 60 * 60));
|
||||||
Location center = Bukkit.getWorld("world").getWorldBorder().getCenter();
|
Location center = Bukkit.getWorld("world").getWorldBorder().getCenter();
|
||||||
double brdSize = Bukkit.getWorld("world").getWorldBorder().getSize() - 1;
|
double brdSize = Bukkit.getWorld("world").getWorldBorder().getSize();
|
||||||
double x = new Random().nextDouble(brdSize) - brdSize/2, z = new Random().nextDouble(brdSize) - brdSize/2;
|
double x = new Random().nextDouble(brdSize) - brdSize/2, z = new Random().nextDouble(brdSize) - brdSize/2;
|
||||||
m = (Villager) Bukkit.getWorld("world").spawnEntity(center.add(x, 200, z), EntityType.VILLAGER);
|
m = (Villager) Bukkit.getWorld("world").spawnEntity(center.add(x, 100, z), EntityType.VILLAGER);
|
||||||
m.getPersistentDataContainer().set(tagger, PersistentDataType.BOOLEAN, true);
|
m.getPersistentDataContainer().set(tagger, PersistentDataType.BOOLEAN, true);
|
||||||
m.setGlowing(true);
|
m.setGlowing(true);
|
||||||
m.setInvulnerable(true);
|
m.setInvulnerable(true);
|
||||||
|
@ -14,6 +14,10 @@ import org.bukkit.command.TabCompleter;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import ovh.herisson.thevoidroad.DatabaseManager;
|
||||||
|
import ovh.herisson.thevoidroad.TheVoidRoad;
|
||||||
|
import ovh.herisson.thevoidroad.Voids;
|
||||||
|
import ovh.herisson.thevoidroad.Merchand;
|
||||||
|
|
||||||
public class VoidCommands implements CommandExecutor, TabCompleter{
|
public class VoidCommands implements CommandExecutor, TabCompleter{
|
||||||
private final Merchand m = Merchand.getInstance();
|
private final Merchand m = Merchand.getInstance();
|
||||||
@ -32,13 +36,10 @@ public class VoidCommands implements CommandExecutor, TabCompleter{
|
|||||||
}
|
}
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case "score":
|
case "score":
|
||||||
if(!sender.hasPermission("void.score")){
|
Voids.scoreboard().forEach((p, a) -> {
|
||||||
Voids.scoreboard().forEach((p, a) -> {
|
sender.sendMessage(p + " : " + a);
|
||||||
sender.sendMessage(p + " : " + a);
|
});
|
||||||
});
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case "give":
|
case "give":
|
||||||
if(args.length < 2) return false;
|
if(args.length < 2) return false;
|
||||||
Player target = Bukkit.getPlayer(args[1]);
|
Player target = Bukkit.getPlayer(args[1]);
|
||||||
@ -116,13 +117,10 @@ public class VoidCommands implements CommandExecutor, TabCompleter{
|
|||||||
ArrayList<String> list = new ArrayList<>();
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
|
||||||
if(args.length == 1){
|
if(args.length == 1){
|
||||||
list.addAll(List.of("give","event"));
|
list.addAll(List.of("give","event", "score"));
|
||||||
if(sender.hasPermission("void.manage")){
|
if(sender.hasPermission("void.manage")){
|
||||||
list.add("manage");
|
list.add("manage");
|
||||||
}
|
}
|
||||||
if(sender.hasPermission("void.score")){
|
|
||||||
list.add("score");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(args.length >= 2){
|
if(args.length >= 2){
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
|
@ -5,18 +5,17 @@ import java.util.HashMap;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
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;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
import org.bukkit.scoreboard.Criteria;
|
import org.bukkit.scoreboard.Criteria;
|
||||||
import org.bukkit.scoreboard.DisplaySlot;
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
import org.bukkit.scoreboard.Objective;
|
import org.bukkit.scoreboard.Objective;
|
||||||
|
import org.bukkit.scoreboard.RenderType;
|
||||||
import org.bukkit.scoreboard.Score;
|
import org.bukkit.scoreboard.Score;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
import org.bukkit.scoreboard.ScoreboardManager;
|
||||||
|
|
||||||
import net.kyori.adventure.bossbar.BossBar;
|
import net.kyori.adventure.bossbar.BossBar;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -26,30 +25,26 @@ import net.kyori.adventure.title.Title;
|
|||||||
public final class Voids implements Listener{
|
public final class Voids implements Listener{
|
||||||
|
|
||||||
private static HashMap<Player, BossBar> bossbars = new HashMap<>();
|
private static HashMap<Player, BossBar> bossbars = new HashMap<>();
|
||||||
private static final NamespacedKey voids = new NamespacedKey(TheVoidRoad.instance, "voids");
|
|
||||||
|
|
||||||
public static int get(Player ply){
|
public static int get(Player ply){
|
||||||
if(ply.getPersistentDataContainer().has(voids)){
|
|
||||||
return ply.getPersistentDataContainer().get(voids, PersistentDataType.INTEGER);
|
|
||||||
}
|
|
||||||
return TheVoidRoad.db.getVoids(ply.getUniqueId());
|
return TheVoidRoad.db.getVoids(ply.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void set(Player ply, int amount){
|
public static void set(Player ply, int amount){
|
||||||
ply.getPersistentDataContainer().set(voids, PersistentDataType.INTEGER, amount);
|
TheVoidRoad.db.setVoids(ply.getUniqueId(), amount);
|
||||||
UpdateVoids(ply);
|
UpdateVoids(ply);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void add(Player ply, int amount){
|
public static void add(Player ply, int amount){
|
||||||
int curr = get(ply);
|
int curr = DatabaseManager.getInstance().getVoids(ply.getUniqueId());
|
||||||
set(ply, curr + amount);
|
DatabaseManager.getInstance().setVoids(ply.getUniqueId(), curr + amount);
|
||||||
UpdateVoids(ply);
|
UpdateVoids(ply);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean subtract(Player ply, int amount, boolean force){
|
public static boolean subtract(Player ply, int amount, boolean force){
|
||||||
int curr = get(ply);
|
int curr = TheVoidRoad.db.getVoids(ply.getUniqueId());
|
||||||
if(curr - amount < 0 && !force) return false;
|
if(curr - amount < 0 && !force) return false;
|
||||||
set(ply, curr - amount);
|
TheVoidRoad.db.setVoids(ply.getUniqueId(), curr - amount);
|
||||||
UpdateVoids(ply);
|
UpdateVoids(ply);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -64,15 +59,7 @@ public final class Voids implements Listener{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void save(Player ply){
|
|
||||||
int curr = get(ply);
|
|
||||||
TheVoidRoad.db.setVoids(ply.getUniqueId(), curr);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HashMap<Player, Integer> scoreboard(){
|
public static HashMap<Player, Integer> scoreboard(){
|
||||||
Bukkit.getServer().forEachAudience(a -> {
|
|
||||||
if(a instanceof Player ply) save(ply);
|
|
||||||
});
|
|
||||||
HashMap<Player, Integer> ret = new HashMap<>();
|
HashMap<Player, Integer> ret = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
HashMap<UUID, Integer> scores_uuid = TheVoidRoad.db.getVoidsScoreboard();
|
HashMap<UUID, Integer> scores_uuid = TheVoidRoad.db.getVoidsScoreboard();
|
||||||
@ -108,9 +95,4 @@ public final class Voids implements Listener{
|
|||||||
public void UpdateVoids(PlayerJoinEvent e){
|
public void UpdateVoids(PlayerJoinEvent e){
|
||||||
UpdateVoids(e.getPlayer());
|
UpdateVoids(e.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void SaveToDbBeforeQuit(PlayerQuitEvent e){
|
|
||||||
save(e.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,6 @@ permissions:
|
|||||||
void.manage:
|
void.manage:
|
||||||
description: "GameMaster's command"
|
description: "GameMaster's command"
|
||||||
default: op
|
default: op
|
||||||
void.score:
|
|
||||||
description: "score the voids"
|
|
||||||
default: op
|
|
||||||
void.balance:
|
void.balance:
|
||||||
description: "User of thevoidroad"
|
description: "User of thevoidroad"
|
||||||
default: not op
|
default: not op
|
||||||
|
Loading…
Reference in New Issue
Block a user