From 12afb0385676311efb2d870ce6c8c7b50a598413 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Mon, 15 Jan 2018 12:32:49 +0100 Subject: [PATCH] weiter --- pom.xml | 45 +++----------- .../java/eu/univento/free4all/Free4All.java | 34 +++++------ .../eu/univento/free4all/commands/Setloc.java | 17 +++--- .../free4all/listeners/PlayerEvents.java | 33 +++++----- .../free4all/utils/RespawnHelper.java | 60 ++++++++++--------- src/main/resources/plugin.yml | 2 +- 6 files changed, 87 insertions(+), 104 deletions(-) diff --git a/pom.xml b/pom.xml index 7d0239a..a7a0f51 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,6 @@ org.apache.maven.plugins maven-compiler-plugin - 3.5.1 1.8 1.8 @@ -47,46 +46,20 @@ - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - + + com.destroystokyo.paper + paper-api + 1.12-R0.1-SNAPSHOT + provided + org.bukkit - bukkit - 1.10.2-R0.1-SNAPSHOT + craftbukkit + 1.12-R0.1-SNAPSHOT provided - - org.mongodb - mongo-java-driver - 3.2.2 - - - org.mongodb - mongodb-driver-async - 3.2.2 - - - io.netty - netty-all - 4.0.36.Final - - - org.spigotmc - spigot-api - 1.10.2-R0.1-SNAPSHOT - provided - - - com.google.code.gson - gson - 2.3.1 - + eu.univento Core diff --git a/src/main/java/eu/univento/free4all/Free4All.java b/src/main/java/eu/univento/free4all/Free4All.java index 3a665f3..af9f0c2 100644 --- a/src/main/java/eu/univento/free4all/Free4All.java +++ b/src/main/java/eu/univento/free4all/Free4All.java @@ -1,46 +1,44 @@ +/* + * Copyright (c) 2018 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + package eu.univento.free4all; -import eu.univento.core.Core; +import eu.univento.commons.server.ServerType; +import eu.univento.core.api.server.ServerSettings; import eu.univento.free4all.commands.Setloc; import eu.univento.free4all.listeners.PlayerEvents; +import lombok.Getter; import org.bukkit.Bukkit; +import org.bukkit.GameMode; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; -import java.util.logging.Level; -import java.util.logging.Logger; - /** * @author joethei * @version 0.1 */ public class Free4All extends JavaPlugin { - public static String prefix = " Free4All"; - - private static Free4All instance; - public static Free4All getInstance() { - return instance; - } - - private static Logger logger; - public static void log(Level level, String msg) { - logger.log(level, msg); - } + @Getter private static Free4All instance; @Override public void onEnable() { - Core.getInstance().registerPlugin(this); instance = this; - logger = Bukkit.getLogger(); PluginManager pm = Bukkit.getPluginManager(); pm.registerEvents(new PlayerEvents(), this); new Setloc(this, "setloc", "sets locations"); + + ServerSettings.setServerType(ServerType.SECRET_GAME_FREE4ALL); + ServerSettings.setGameMode(GameMode.ADVENTURE); + ServerSettings.setGame(true); + ServerSettings.setGameState("Running"); } @Override public void onDisable() { - Core.getInstance().unregisterPlugin(this); + } } \ No newline at end of file diff --git a/src/main/java/eu/univento/free4all/commands/Setloc.java b/src/main/java/eu/univento/free4all/commands/Setloc.java index 6a0a5d6..5bd4be5 100644 --- a/src/main/java/eu/univento/free4all/commands/Setloc.java +++ b/src/main/java/eu/univento/free4all/commands/Setloc.java @@ -1,9 +1,13 @@ +/* + * Copyright (c) 2018 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + package eu.univento.free4all.commands; -import eu.univento.commons.player.Rank; +import eu.univento.commons.player.rank.Rank; import eu.univento.core.api.AutoCommand; import eu.univento.core.api.Config; -import eu.univento.core.api.languages.Messages; import eu.univento.core.api.player.CustomPlayer; import eu.univento.free4all.Free4All; import org.bukkit.command.CommandSender; @@ -25,20 +29,19 @@ public class Setloc extends AutoCommand{ public boolean execute(CommandSender sender, String label, String[] args) { if(sender instanceof Player) { CustomPlayer p = CustomPlayer.getPlayer(sender.getName()); - Messages msgs = new Messages(p); assert p != null; if(p.getDatabasePlayer().isAllowed(Rank.SrDeveloper)) { if(args.length == 1) { Config.write("FFA.Spawn." + args[0], p.getLocation()); - p.sendMessage(msgs.PREFIX() + msgs.Lobby_SET_LOCATION()); + p.sendMessage("§ePosition gesetzt"); }else { - p.sendMessage(msgs.PREFIX() + msgs.Lobby_SET_LOCATION_USAGE()); + p.sendMessage("§c/setloc "); } }else { - p.sendMessage(msgs.NO_PERMS()); + p.sendMessage("§cDazu hast du keine Rechte"); } }else { - sender.sendMessage(Messages.Console.NOT_A_PLAYER); + sender.sendMessage(""); } return false; } diff --git a/src/main/java/eu/univento/free4all/listeners/PlayerEvents.java b/src/main/java/eu/univento/free4all/listeners/PlayerEvents.java index c98c6ea..2e87dfa 100644 --- a/src/main/java/eu/univento/free4all/listeners/PlayerEvents.java +++ b/src/main/java/eu/univento/free4all/listeners/PlayerEvents.java @@ -1,12 +1,16 @@ +/* + * Copyright (c) 2018 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + package eu.univento.free4all.listeners; +import eu.univento.commons.player.currency.CurrencyType; import eu.univento.core.Core; -import eu.univento.core.api.Hologram; -import eu.univento.core.api.effects.Effects; import eu.univento.core.api.player.CustomPlayer; import eu.univento.free4all.Free4All; import eu.univento.free4all.utils.RespawnHelper; -import net.minecraft.server.v1_10_R1.EnumParticle; +import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.block.BlockFace; @@ -32,6 +36,7 @@ import java.util.Map; */ public class PlayerEvents implements Listener{ private Map> lastDamage = new LinkedHashMap<>(); + private Map helpers = new LinkedHashMap<>(); @EventHandler public void onPlayerDeath(PlayerDeathEvent e) { @@ -39,9 +44,7 @@ public class PlayerEvents implements Listener{ if(p.getKiller() != null) { CustomPlayer killer = CustomPlayer.getPlayer(p.getKiller()); e.setDeathMessage(p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §awurde von " + killer.getDatabasePlayer().getRank().getColor() + killer.getDisplayName() + " §agetötet."); - Hologram holo = new Hologram(new String[]{"§6+1 Coins"}, p.getEyeLocation()); - killer.getDatabasePlayer().addCoins(1); - holo.showPlayerTemp(killer, 50); + killer.getDatabasePlayer().addCurrency(CurrencyType.Vents, 10); for(CustomPlayer players : Core.getOnlinePlayers()) { players.playEffect(killer.getLocation(), Effect.CHORUS_FLOWER_DEATH, 5, 2, 0.5F, 0.0F, 0.5F, 0.1F, 20, 5); } @@ -49,8 +52,7 @@ public class PlayerEvents implements Listener{ for(Map.Entry entry : lastDamage.get(p).entrySet()) { CustomPlayer killer = entry.getKey(); e.setDeathMessage(p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §a wurde von " + killer.getDatabasePlayer().getRank().getColor() + killer.getDisplayName() + " §cgetötet."); - Effects.playEffect(killer.getLocation(), EnumParticle.DRIP_LAVA, 10); - killer.getDatabasePlayer().addCoins(1); + killer.getDatabasePlayer().addCurrency(CurrencyType.Vents, 10); } }else { e.setDeathMessage(p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §cist nun tot."); @@ -60,10 +62,9 @@ public class PlayerEvents implements Listener{ @EventHandler public void onPlayerRespawn(PlayerRespawnEvent e) { CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); - RespawnHelper helper = new RespawnHelper(p); + RespawnHelper helper = helpers.get(p); e.setRespawnLocation(helper.getRespawnLocation()); helper.setRespawnInventory(); - Effects.playEffect(e.getRespawnLocation(), EnumParticle.HEART, 5); } @EventHandler @@ -101,7 +102,9 @@ public class PlayerEvents implements Listener{ @EventHandler public void onPlayerJoin(PlayerJoinEvent e) { CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); - e.setJoinMessage(p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §aist dem Spiel beigetreten."); + helpers.put(p, new RespawnHelper(p)); + e.setJoinMessage(null); + p.getDatabasePlayer().getRankAsync().whenComplete((rank, throwable) -> Bukkit.broadcastMessage(rank.getColor() + p.getDisplayName() + " §aist dem Spiel beigetreten.")); } @EventHandler @@ -113,13 +116,13 @@ public class PlayerEvents implements Listener{ if(lastDamage.containsKey(p)) { for(Map.Entry entry : lastDamage.get(p).entrySet()) { CustomPlayer killer = entry.getKey(); - killer.getDatabasePlayer().addCoins(1); - Effects.playEffect(p.getLocation(), EnumParticle.FLAME, 10); + killer.getDatabasePlayer().addCurrency(CurrencyType.Vents, 10); + } - e.setQuitMessage(Free4All.prefix + "§cDer Spieler " + p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §chat sich während eines Kampfes ausgeloggt."); + e.setQuitMessage("§cDer Spieler " + p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §chat sich während eines Kampfes ausgeloggt."); lastDamage.remove(p); } - e.setQuitMessage(Free4All.prefix + "§cDer Spieler " + p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §c hat das Spiel verlassen."); + e.setQuitMessage("§cDer Spieler " + p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §c hat das Spiel verlassen."); } @EventHandler diff --git a/src/main/java/eu/univento/free4all/utils/RespawnHelper.java b/src/main/java/eu/univento/free4all/utils/RespawnHelper.java index 1f8353a..f67a648 100644 --- a/src/main/java/eu/univento/free4all/utils/RespawnHelper.java +++ b/src/main/java/eu/univento/free4all/utils/RespawnHelper.java @@ -1,8 +1,14 @@ +/* + * Copyright (c) 2018 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + package eu.univento.free4all.utils; import eu.univento.core.api.Config; import eu.univento.core.api.items.ItemBuilder; import eu.univento.core.api.player.CustomPlayer; +import eu.univento.core.customitems.weapons.closecombat.ThiefsDagger; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -33,41 +39,41 @@ public class RespawnHelper { inv.clear(); if(inventory == 0) { - inv.setItem(0, new ItemBuilder(Material.WOOD_SWORD).name("§cEinfaches Schwert").make()); - inv.setItem(1, new ItemBuilder(Material.BOW).name("§cEinfacher Bogen").make()); - inv.setItem(8, new ItemBuilder(Material.ARROW).name("§cEinfacher Pfeil").amount(10).make()); - inv.setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).name("§cStarke Schuhe").make()); - inv.setLeggings(new ItemBuilder(Material.DIAMOND_LEGGINGS).name("§cStarke Hose").make()); - inv.setChestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).name("§cStarke Brustplatte").enchantment(Enchantment.THORNS).make()); - inv.setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).name("§cStarker Helm").make()); + inv.setItem(0, new ItemBuilder(Material.WOOD_SWORD).name("§cEinfaches Schwert").build()); + inv.setItem(1, new ItemBuilder(Material.BOW).name("§cEinfacher Bogen").build()); + inv.setItem(8, new ItemBuilder(Material.ARROW).name("§cEinfacher Pfeil").amount(10).build()); + inv.setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).name("§cStarke Schuhe").build()); + inv.setLeggings(new ItemBuilder(Material.DIAMOND_LEGGINGS).name("§cStarke Hose").build()); + inv.setChestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).name("§cStarke Brustplatte").enchantment(Enchantment.THORNS).build()); + inv.setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).name("§cStarker Helm").build()); } if(inventory == 1) { - inv.setItem(0, new ItemBuilder(Material.WOOD_SWORD).name("§cFliegendes Schwert").enchantment(Enchantment.KNOCKBACK).make()); - inv.setItem(1, new ItemBuilder(Material.BOW).name("§cFliegender Bogen").enchantment(Enchantment.ARROW_KNOCKBACK).make()); - inv.setItem(8, new ItemBuilder(Material.ARROW).name("§cFliegende Pfeil").amount(10).make()); - inv.setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).name("§cStarke Schuhe").make()); - inv.setLeggings(new ItemBuilder(Material.DIAMOND_LEGGINGS).name("§cStarke Hose").make()); - inv.setChestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).name("§cStarke Brustplatte").make()); - inv.setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).name("§cStarke Helm").make()); + inv.setItem(0, new ItemBuilder(Material.WOOD_SWORD).name("§cFliegendes Schwert").enchantment(Enchantment.KNOCKBACK).build()); + inv.setItem(1, new ItemBuilder(Material.BOW).name("§cFliegender Bogen").enchantment(Enchantment.ARROW_KNOCKBACK).build()); + inv.setItem(8, new ItemBuilder(Material.ARROW).name("§cFliegende Pfeil").amount(10).build()); + inv.setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).name("§cStarke Schuhe").build()); + inv.setLeggings(new ItemBuilder(Material.DIAMOND_LEGGINGS).name("§cStarke Hose").build()); + inv.setChestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).name("§cStarke Brustplatte").build()); + inv.setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).name("§cStarke Helm").build()); } if(inventory == 2) { - inv.setItem(0, new ItemBuilder(Material.WOOD_SWORD).name("§cFeuriges Schwert").enchantment(Enchantment.FIRE_ASPECT).make()); - inv.setItem(1, new ItemBuilder(Material.BOW).name("§cFeuriger Bogen").enchantment(Enchantment.ARROW_FIRE).make()); - inv.setItem(8, new ItemBuilder(Material.ARROW).name("§cFeuriger Pfeil").amount(10).make()); - inv.setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).name("§cStarke Schuhe").make()); - inv.setLeggings(new ItemBuilder(Material.DIAMOND_LEGGINGS).name("§cStarke Hose").make()); - inv.setChestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).name("§cStarke Brustplatte").enchantment(Enchantment.PROTECTION_FIRE).make()); - inv.setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).name("§cStarke Helm").make()); + inv.setItem(0, new ItemBuilder(Material.WOOD_SWORD).name("§cFeuriges Schwert").enchantment(Enchantment.FIRE_ASPECT).build()); + inv.setItem(1, new ItemBuilder(Material.BOW).name("§cFeuriger Bogen").enchantment(Enchantment.ARROW_FIRE).build()); + inv.setItem(8, new ItemBuilder(Material.ARROW).name("§cFeuriger Pfeil").amount(10).build()); + inv.setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).name("§cStarke Schuhe").build()); + inv.setLeggings(new ItemBuilder(Material.DIAMOND_LEGGINGS).name("§cStarke Hose").build()); + inv.setChestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).name("§cStarke Brustplatte").enchantment(Enchantment.PROTECTION_FIRE).build()); + inv.setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).name("§cStarke Helm").build()); } if(inventory == 3) { - inv.setItem(0, new ItemBuilder(Material.STONE_SWORD).name("§cEin Schwert").make()); - inv.setItem(1, new ItemBuilder(Material.BOW).name("§cEin Bogen").enchantment(Enchantment.ARROW_DAMAGE).make()); - inv.setItem(8, new ItemBuilder(Material.ARROW).amount(20).make()); + new ThiefsDagger(player).addItem(); + inv.setItem(1, new ItemBuilder(Material.BOW).name("§cEin Bogen").enchantment(Enchantment.ARROW_DAMAGE).build()); + inv.setItem(8, new ItemBuilder(Material.ARROW).amount(20).build()); } if(inventory == 4) { - inv.setItem(0, new ItemBuilder(Material.STONE_SWORD).name("§cStarkes Schwert").enchantment(Enchantment.DAMAGE_ALL).make()); - inv.setItem(1, new ItemBuilder(Material.BOW).name("§cUnendlicher Bogen").enchantment(Enchantment.ARROW_INFINITE).make()); - inv.setItem(8, new ItemBuilder(Material.SPECTRAL_ARROW).name("§cLeuchtender Pfeil").make()); + inv.setItem(0, new ItemBuilder(Material.STONE_SWORD).name("§cStarkes Schwert").enchantment(Enchantment.DAMAGE_ALL).build()); + inv.setItem(1, new ItemBuilder(Material.BOW).name("§cUnendlicher Bogen").enchantment(Enchantment.ARROW_INFINITE).build()); + inv.setItem(8, new ItemBuilder(Material.SPECTRAL_ARROW).name("§cLeuchtender Pfeil").build()); } } } \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 94a9fa4..c33c989 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: Free4All -main: eu.univento.free4All.Free4All +main: eu.univento.free4all.Free4All author: joethei version: 0.1 description: univento.eu Secret Minigame