Compare commits
5 Commits
f36e6b1aa0
...
131d131dfe
Author | SHA1 | Date | |
---|---|---|---|
131d131dfe | |||
c9dd268c14 | |||
a7a88bb619 | |||
d92a8c6125 | |||
30be45065f |
@ -24,5 +24,19 @@ 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,6 +67,7 @@ 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();
|
double brdSize = Bukkit.getWorld("world").getWorldBorder().getSize() - 1;
|
||||||
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, 100, z), EntityType.VILLAGER);
|
m = (Villager) Bukkit.getWorld("world").spawnEntity(center.add(x, 200, 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,10 +14,6 @@ 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();
|
||||||
@ -36,10 +32,13 @@ 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]);
|
||||||
@ -117,10 +116,13 @@ 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", "score"));
|
list.addAll(List.of("give","event"));
|
||||||
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,17 +5,18 @@ 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;
|
||||||
@ -25,26 +26,30 @@ 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){
|
||||||
TheVoidRoad.db.setVoids(ply.getUniqueId(), amount);
|
ply.getPersistentDataContainer().set(voids, PersistentDataType.INTEGER, amount);
|
||||||
UpdateVoids(ply);
|
UpdateVoids(ply);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void add(Player ply, int amount){
|
public static void add(Player ply, int amount){
|
||||||
int curr = DatabaseManager.getInstance().getVoids(ply.getUniqueId());
|
int curr = get(ply);
|
||||||
DatabaseManager.getInstance().setVoids(ply.getUniqueId(), curr + amount);
|
set(ply, 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 = TheVoidRoad.db.getVoids(ply.getUniqueId());
|
int curr = get(ply);
|
||||||
if(curr - amount < 0 && !force) return false;
|
if(curr - amount < 0 && !force) return false;
|
||||||
TheVoidRoad.db.setVoids(ply.getUniqueId(), curr - amount);
|
set(ply, curr - amount);
|
||||||
UpdateVoids(ply);
|
UpdateVoids(ply);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -59,7 +64,15 @@ 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();
|
||||||
@ -95,4 +108,9 @@ 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,6 +16,9 @@ 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