first commit

This commit is contained in:
Johannes Theiner 2016-08-03 00:03:09 +02:00
commit e1d93cf1b6
7 changed files with 406 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
Free4All.iml

96
pom.xml Normal file
View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>eu.univento</groupId>
<artifactId>ffa</artifactId>
<version>1.0-SNAPSHOT</version>
<name>univento.eu Free4All Secret Minigame</name>
<build>
<plugins>
<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>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<archive>
<manifest>
<mainClass>eu.univento.teamvento.TeamVento</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</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-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-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>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,46 @@
package eu.univento.free4all;
import eu.univento.core.Core;
import eu.univento.free4all.commands.Setloc;
import eu.univento.free4all.listeners.PlayerEvents;
import org.bukkit.Bukkit;
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);
}
@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");
}
@Override
public void onDisable() {
Core.getInstance().unregisterPlugin(this);
}
}

View File

@ -0,0 +1,50 @@
package eu.univento.free4all.commands;
import eu.univento.commons.player.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;
import org.bukkit.entity.Player;
import java.util.List;
/**
* @author joethei
* @version 1.0
*/
public class Setloc extends AutoCommand<Free4All>{
public Setloc(Free4All plugin, String command, String description, String... aliases) {
super(plugin, command, description, aliases);
}
@Override
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());
}else {
p.sendMessage(msgs.PREFIX() + msgs.Lobby_SET_LOCATION_USAGE());
}
}else {
p.sendMessage(msgs.NO_PERMS());
}
}else {
sender.sendMessage(Messages.Console.NOT_A_PLAYER);
}
return false;
}
@Override
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
return null;
}
}

View File

@ -0,0 +1,133 @@
package eu.univento.free4all.listeners;
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.Effect;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @author joethei
* @version 0.1
*/
public class PlayerEvents implements Listener{
private Map<CustomPlayer, LinkedHashMap<CustomPlayer, BukkitTask>> lastDamage = new LinkedHashMap<>();
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getEntity());
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);
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);
}
}else if(lastDamage.containsKey(p)){
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);
}
}else {
e.setDeathMessage(p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §cist nun tot.");
}
}
@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
RespawnHelper helper = new RespawnHelper(p);
e.setRespawnLocation(helper.getRespawnLocation());
helper.setRespawnInventory();
Effects.playEffect(e.getRespawnLocation(), EnumParticle.HEART, 5);
}
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
if(e.getEntity() instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
if(e.getDamager() instanceof Player) {
CustomPlayer damager = CustomPlayer.getPlayer((Player) e.getEntity());
BukkitTask task = new BukkitRunnable() {
@Override
public void run() {
if(lastDamage.containsKey(p)) lastDamage.remove(p);
}
}.runTaskLater(Free4All.getInstance(), 10 * 20L);
LinkedHashMap<CustomPlayer, BukkitTask> map = new LinkedHashMap<>();
map.put(damager, task);
lastDamage.put(p, map);
}
if(e.getDamager() instanceof Projectile) {
CustomPlayer damager = CustomPlayer.getPlayer((Player) ((Projectile) e.getDamager()).getShooter());
BukkitTask task = new BukkitRunnable() {
@Override
public void run() {
if(lastDamage.containsKey(p)) lastDamage.remove(p);
}
}.runTaskLater(Free4All.getInstance(), 10 * 20L);
LinkedHashMap<CustomPlayer, BukkitTask> map = new LinkedHashMap<>();
map.put(damager, task);
lastDamage.put(p, map);
}
}
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
e.setJoinMessage(p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §aist dem Spiel beigetreten.");
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
for(Map.Entry<CustomPlayer, LinkedHashMap<CustomPlayer, BukkitTask>> entry : lastDamage.entrySet()) {
entry.getValue().entrySet().stream().filter(mapEntry -> mapEntry.equals(p)).forEach(mapEntry -> lastDamage.remove(entry.getKey()));
}
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);
}
e.setQuitMessage(Free4All.prefix + "§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.");
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(e.getTo().getBlock().getRelative(BlockFace.UP).getType() == Material.STATIONARY_WATER) {
p.damage(0.5D);
}
}
}

View File

@ -0,0 +1,73 @@
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 org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.PlayerInventory;
import java.util.Random;
/**
* @author joethei
* @version 0.1
*/
public class RespawnHelper {
private CustomPlayer player;
public RespawnHelper(CustomPlayer player) {
this.player = player;
}
public Location getRespawnLocation() {
int spawn = new Random().nextInt(10);
return Config.readLocation("FFA.Spawn." + spawn);
}
public void setRespawnInventory() {
int inventory = new Random().nextInt(5);
PlayerInventory inv = player.getInventory();
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());
}
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());
}
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());
}
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());
}
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());
}
}
}

View File

@ -0,0 +1,6 @@
name: Free4All
main: eu.univento.free4All.Free4All
author: joethei
version: 0.1
description: univento.eu Secret Minigame
website: https://univento.eu