Browse Source

weiter

master
BuildTools 4 years ago
parent
commit
12afb03856
  1. 41
      pom.xml
  2. 34
      src/main/java/eu/univento/free4all/Free4All.java
  3. 17
      src/main/java/eu/univento/free4all/commands/Setloc.java
  4. 33
      src/main/java/eu/univento/free4all/listeners/PlayerEvents.java
  5. 60
      src/main/java/eu/univento/free4all/utils/RespawnHelper.java
  6. 2
      src/main/resources/plugin.yml

41
pom.xml

@ -14,7 +14,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
@ -47,46 +46,20 @@
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-async</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.36.Final</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>Core</artifactId>

34
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);
}
}

17
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<Free4All>{
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 <Zahl>");
}
}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;
}

33
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<CustomPlayer, LinkedHashMap<CustomPlayer, BukkitTask>> lastDamage = new LinkedHashMap<>();
private Map<CustomPlayer, RespawnHelper> 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<CustomPlayer, BukkitTask> 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<CustomPlayer, BukkitTask> 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

60
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());
}
}
}

2
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

Loading…
Cancel
Save