Compare commits
4 Commits
56b7ae97ef
...
105d564ec0
Author | SHA1 | Date | |
---|---|---|---|
105d564ec0 | |||
a7fdff2dd9 | |||
2b2683b22b | |||
402b94a797 |
11
TODO.md
11
TODO.md
@ -1,8 +1,13 @@
|
|||||||
# TODO list
|
# TODO list
|
||||||
|
|
||||||
- [ ] i18n
|
- [ ] i18n
|
||||||
- [-] Make Discord Webhoook for item changes
|
- [+] Make Discord Webhoook for item changes
|
||||||
- [x] deathBan reset
|
- [x] deathBan reset
|
||||||
- [ ] voids exchanges
|
- [x] voids exchanges
|
||||||
- [ ] chest name
|
- [x] /void give négatives values
|
||||||
|
- [+] chest name
|
||||||
|
- [+] Show next Item
|
||||||
- [ ] /void manage bring
|
- [ ] /void manage bring
|
||||||
|
- [ ] Dupe bug (respawn) -> Gamerule
|
||||||
|
- [+] /void give afficher title
|
||||||
|
- subtitle + chat
|
||||||
|
@ -15,7 +15,6 @@ 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.DatabaseManager;
|
||||||
import ovh.herisson.thevoidroad.DiscordWebhook;
|
|
||||||
import ovh.herisson.thevoidroad.TheVoidRoad;
|
import ovh.herisson.thevoidroad.TheVoidRoad;
|
||||||
import ovh.herisson.thevoidroad.Voids;
|
import ovh.herisson.thevoidroad.Voids;
|
||||||
import ovh.herisson.thevoidroad.Entity.Merchand;
|
import ovh.herisson.thevoidroad.Entity.Merchand;
|
||||||
@ -44,7 +43,7 @@ public class VoidCommands implements CommandExecutor, TabCompleter{
|
|||||||
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]);
|
||||||
if(target != null && sender instanceof Player ply)
|
if(target != null && sender instanceof Player ply && Integer.parseInt(args[2]) > 0)
|
||||||
Voids.give(ply,target, Integer.parseInt(args[2]));
|
Voids.give(ply,target, Integer.parseInt(args[2]));
|
||||||
break;
|
break;
|
||||||
case "event":
|
case "event":
|
||||||
@ -69,19 +68,6 @@ public class VoidCommands implements CommandExecutor, TabCompleter{
|
|||||||
return true;
|
return true;
|
||||||
case "skip":
|
case "skip":
|
||||||
//TODO(Merchand): Skip trade
|
//TODO(Merchand): Skip trade
|
||||||
break;
|
|
||||||
case "discord":
|
|
||||||
String link = DatabaseManager.getInstance().getConfig("discord-wh");
|
|
||||||
if(!link.equals("")){
|
|
||||||
DiscordWebhook discord = new DiscordWebhook(link);
|
|
||||||
discord.setContent("Item mis en vente pendant une heure: " + Merchand.current.x + " au prix de " + Merchand.current.y + TheVoidRoad.CoinGlyph);
|
|
||||||
try {
|
|
||||||
discord.execute();
|
|
||||||
} catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "goto":
|
case "goto":
|
||||||
if(sender instanceof Player ply && m.getLocation() != null){
|
if(sender instanceof Player ply && m.getLocation() != null){
|
||||||
|
@ -37,7 +37,7 @@ public class Merchand implements Listener{
|
|||||||
private static Merchand instance;
|
private static Merchand instance;
|
||||||
private static final ArrayList<Material> mat = new ArrayList<>();
|
private static final ArrayList<Material> mat = new ArrayList<>();
|
||||||
private static final ArrayList<String> names = new ArrayList<>();
|
private static final ArrayList<String> names = new ArrayList<>();
|
||||||
private final Inventory inv;
|
private static Inventory inv;
|
||||||
private Villager m ;
|
private Villager m ;
|
||||||
|
|
||||||
private static final NamespacedKey tagger = new NamespacedKey(TheVoidRoad.instance, "merchand") ;
|
private static final NamespacedKey tagger = new NamespacedKey(TheVoidRoad.instance, "merchand") ;
|
||||||
@ -49,7 +49,6 @@ public class Merchand implements Listener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Merchand() {
|
private Merchand() {
|
||||||
inv = Bukkit.createInventory(null, 9);
|
|
||||||
|
|
||||||
//Get file materials
|
//Get file materials
|
||||||
File f = new File(TheVoidRoad.instance.getDataFolder(), "materials.txt");
|
File f = new File(TheVoidRoad.instance.getDataFolder(), "materials.txt");
|
||||||
@ -81,6 +80,7 @@ public class Merchand implements Listener{
|
|||||||
public void regenerate(){
|
public void regenerate(){
|
||||||
if(m != null){ m.remove(); }
|
if(m != null){ m.remove(); }
|
||||||
current = genTrade(System.currentTimeMillis() / (1000 * 60 * 60));
|
current = genTrade(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();
|
||||||
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;
|
||||||
@ -89,6 +89,7 @@ public class Merchand implements Listener{
|
|||||||
m.setGlowing(true);
|
m.setGlowing(true);
|
||||||
m.setInvulnerable(true);
|
m.setInvulnerable(true);
|
||||||
m.customName(Component.text(names.get(new Random().nextInt(names.size()))));
|
m.customName(Component.text(names.get(new Random().nextInt(names.size()))));
|
||||||
|
inv = Bukkit.createInventory(null, 9, Component.text(m.getName()));
|
||||||
Bukkit.getServer().forEachAudience((a) -> {
|
Bukkit.getServer().forEachAudience((a) -> {
|
||||||
if(a instanceof Player ply){
|
if(a instanceof Player ply){
|
||||||
ply.setCompassTarget(m.getLocation());
|
ply.setCompassTarget(m.getLocation());
|
||||||
@ -120,12 +121,18 @@ public class Merchand implements Listener{
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onHour(HourEvent e){
|
public void onHour(HourEvent e){
|
||||||
current = genTrade(e.unixhour);
|
current = genTrade(e.unixhour);
|
||||||
|
next = genTrade(e.unixhour + 1);
|
||||||
String link = DatabaseManager.getInstance().getConfig("discord-wh");
|
String link = DatabaseManager.getInstance().getConfig("discord-wh");
|
||||||
if(!link.equals("")){
|
if(!link.equals("")){
|
||||||
DiscordWebhook discord = new DiscordWebhook(link);
|
DiscordWebhook discord = new DiscordWebhook(link);
|
||||||
discord.setContent("Item mis en vente pendant une heure: " + current.x + " au prix de " + current.y + TheVoidRoad.CoinGlyph);
|
discord.setUsername(m.getName());
|
||||||
|
discord.setContent("Salut, Je vend actuellement `" + current.x + "` au prix de " + current.y + TheVoidRoad.CoinGlyph);
|
||||||
|
try {
|
||||||
|
discord.execute();
|
||||||
|
} catch(Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
next = genTrade(e.unixhour + 1);
|
|
||||||
regenerate();
|
regenerate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,6 +142,9 @@ public class Merchand implements Listener{
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
inv.clear();
|
inv.clear();
|
||||||
inv.setItem(4, new ItemStack(current.x, current.y));
|
inv.setItem(4, new ItemStack(current.x, current.y));
|
||||||
|
ItemStack nextItem = new ItemStack(next.x,next.y);
|
||||||
|
nextItem.editMeta(m ->{ m.setDisplayName("Prochain item en vente"); });
|
||||||
|
inv.setItem(8, nextItem);
|
||||||
e.getPlayer().openInventory(inv);
|
e.getPlayer().openInventory(inv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ 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;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.title.Title;
|
||||||
|
|
||||||
public final class Voids implements Listener{
|
public final class Voids implements Listener{
|
||||||
|
|
||||||
@ -48,11 +50,13 @@ public final class Voids implements Listener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean give(Player giver, Player receiver, int amount){
|
public static boolean give(Player giver, Player receiver, int amount){
|
||||||
if(subtract(giver, amount, false)){
|
if( amount < 0 || !subtract(giver, amount, false))
|
||||||
add(receiver, amount);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
|
add(receiver, amount);
|
||||||
|
giver.sendMessage("Vous avez donné " + amount + TheVoidRoad.CoinGlyph + " à " + receiver.getName());
|
||||||
|
receiver.sendMessage("Vous avez reçu " + amount + TheVoidRoad.CoinGlyph + " de " + giver.getName());
|
||||||
|
receiver.showTitle(Title.title(Component.empty(), Component.text("+" + amount + TheVoidRoad.CoinGlyph + " from " + giver.getName()).color(NamedTextColor.GREEN)));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<Player, Integer> scoreboard(){
|
public static HashMap<Player, Integer> scoreboard(){
|
||||||
|
Loading…
Reference in New Issue
Block a user