auf meiner Festplatte

This commit is contained in:
BuildTools 2018-01-15 12:26:24 +01:00
parent 93cb20bdf8
commit ddcbb21254
20 changed files with 369 additions and 1405 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
/bin/
/target/
Lobby.iml

View File

@ -20,31 +20,35 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.11-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: eu.univento:commons:1.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.12-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.mojang:authlib:1.5.25" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-io:commons-io:2.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:17.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.2.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.17" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.10-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.18" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-all:5.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.11-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.11-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.11-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.12-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.10" level="project" />
<orderEntry type="module" module-name="Core" scope="PROVIDED" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.16.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: co.aikar:taskchain-bukkit:3.4.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: co.aikar:taskchain-core:3.4.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.dmulloy2:PacketWrapper:master-2b4bfddd12-1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: co.aikar:taskchain-bukkit:3.6.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: pl.kacperduras:tasket-core:1.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: pl.kacperduras:tasket-bukkit:1.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.github.lordakkarin:nbt:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-buffer:5.0.0.Alpha2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-common:5.0.0.Alpha2" level="project" />
<orderEntry type="module" module-name="Commons" scope="PROVIDED" />
<orderEntry type="library" scope="PROVIDED" name="Maven: ai.api:libai:1.4.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-core:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-transport:4.1.8.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-handler:4.1.8.Final" level="project" />
@ -65,6 +69,7 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: org.scala-lang:scala-library:2.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.mauricio:postgresql-async_2.12:0.2.21" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.mauricio:db-async-common_2.12:0.2.21" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: joda-time:joda-time:2.9.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.joda:joda-convert:1.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.mauricio:mysql-async_2.12:0.2.21" level="project" />
@ -74,17 +79,13 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mongodb:bson:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-rabbitmq-client:3.4.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.rabbitmq:amqp-client:3.6.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-web-client:3.4.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.vertx:vertx-web-common:3.4.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-io:commons-io:2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: joda-time:joda-time:2.9.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TheHolyWaffle:TeamSpeak-3-Java-API:v1.0.13" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.6.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.6.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.sentry:sentry:1.2.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.ben-manes.caffeine:caffeine:2.5.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.nsp:JSkills:master-0.9.0-g8b333ec-15" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ejml:simple:0.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ejml:core:0.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ejml:dense64:0.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.gitlab:java-gitlab-api:1.2.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.dagger:dagger:2.14.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.inject:javax.inject:1" level="project" />
</component>
</module>

30
pom.xml
View File

@ -48,38 +48,26 @@
</plugins>
</build>
<repositories>
<repository>
<id>univentoEU</id>
<url>http://dev.joethei.de:8081/repository/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.10</version>
</dependency>
<dependency>
<groupId>eu.univento</groupId>
<artifactId>Core</artifactId>

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="target" level="project" />
<orderEntry type="library" name="target1" level="project" />
<orderEntry type="library" name="Kartoffelsuppe" level="project" />
<orderEntry type="library" name="Core" level="project" />
<orderEntry type="library" name="FakeCore" level="project" />
<orderEntry type="library" name="test-1.0-SNAPSHOT-jar-with-dependencies" level="project" />
<orderEntry type="module" module-name="FakeCore" />
<orderEntry type="module" module-name="Core" />
</component>
</module>

View File

@ -1,10 +1,15 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby;
import eu.univento.commons.server.ServerType;
import eu.univento.core.api.server.ServerSettings;
import eu.univento.lobby.commands.DropItem;
import eu.univento.lobby.commands.Setloc;
import eu.univento.lobby.listeners.*;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
@ -19,42 +24,30 @@ import org.bukkit.plugin.java.JavaPlugin;
*/
public class Lobby extends JavaPlugin{
private static Lobby instance;
public static Lobby getInstance() {
return instance;
}
@Getter private static Lobby instance;
@Override
public void onEnable() {
instance = this;
PluginManager pm = Bukkit.getPluginManager();;
PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents(new Jumppads(), this);
pm.registerEvents(new JoinQuit(), this);
pm.registerEvents(new MenuEvents(), this);
pm.registerEvents(new Events(), this);
pm.registerEvents(new Menu(), this);
pm.registerEvents(new PlayerHider(), this);
pm.registerEvents(new ItemEvents(), this);
pm.registerEvents(new FoundItems(), this);
pm.registerEvents(new Parkour(), this);
pm.registerEvents(new PetInteract(), this);
pm.registerEvents(new PlayerInteract(), this);
pm.registerEvents(new FunStuff(), this);
//pm.registerEvents(new MenuEvents(), this);
new Setloc(this, "setloc", "Setzt Teleport Punkte");
new DropItem(this, "dropitem", "Setzt EasterEggs");
if(ServerSettings.isDebug()) System.out.println("Befehle registriert");
for(World w : Bukkit.getWorlds()) w.setDifficulty(Difficulty.PEACEFUL);
ServerSettings.setGameMode(GameMode.ADVENTURE);
ServerSettings.setLobby(true);
ServerSettings.setServerType(ServerType.LOBBY);
ServerSettings.setup(ServerType.LOBBY, GameMode.ADVENTURE);
System.out.println(" Plugin ver." + getDescription().getVersion() + " gestartet");
}
@Override

View File

@ -1,22 +1,16 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.core.api.Config;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.Lobby;
import eu.univento.lobby.story.missions.StartMission;
import eu.univento.lobby.utils.CustomMapRenderer;
import eu.univento.lobby.utils.PetManager;
import eu.univento.lobby.utils.Pets;
import eu.univento.lobby.utils.Scoreboards;
import net.minecraft.server.v1_11_R1.EnumParticle;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Skull;
import org.bukkit.entity.Creature;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
@ -33,7 +27,6 @@ import org.bukkit.event.server.MapInitializeEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.map.MapView;
import org.bukkit.util.Vector;
/**
* some short events
@ -137,30 +130,8 @@ public class Events implements Listener {
if (e.getClickedBlock().getType() == Material.SPRUCE_DOOR) e.setCancelled(true);
if (e.getClickedBlock().getType() == Material.WOOD_DOOR) e.setCancelled(true);
if (e.getClickedBlock().getType() == Material.WOODEN_DOOR) e.setCancelled(true);
if (e.getClickedBlock().getType() == Material.SKULL) {
Skull skull = (Skull) e.getClickedBlock().getState();
if (skull.getOwner().equals("MHF_Chest")) {
p.playSound(p.getEyeLocation(), Sound.BLOCK_PORTAL_TRAVEL, 5.0F, 1.0F);
p.playParticle(skull.getLocation().add(0.5D, 1.5D, 0.5D), EnumParticle.ENCHANTMENT_TABLE, 0.3F, 500);
Bukkit.getScheduler().scheduleAsyncDelayedTask(Lobby.getInstance(), () -> {
p.playParticle(skull.getLocation().add(0.5D, 0.0D, 0.5D), EnumParticle.SPELL_WITCH, 0.4F, 500);
p.sendTitle(10, 50, 10, "Versteck", "§eDu hast ein Versteck gefunden");
p.getDatabasePlayer().addCoins(100);
Scoreboards.updateScoreboard(p);
}, 3 * 20L);
}
}
if(e.getClickedBlock().getType() == Material.STONE_BUTTON) {
new StartMission(p);
}
}
}
@EventHandler
public void onItemDespawn(ItemDespawnEvent e) {
e.setCancelled(true);
}
@EventHandler
public void onHangingBreak(HangingBreakByEntityEvent e) {
@ -192,62 +163,24 @@ public class Events implements Listener {
if (PlayerHider.getSilentlobby().contains(p)) e.setCancelled(true);
}
@EventHandler
public void onMove(PlayerMoveEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if (PetManager.hasPet(p)) {
new Pets().followPlayer((Creature) PetManager.getPet(p), p, 1.4);
}
if ((p.getLocation().getBlock().getType() == Material.STATIONARY_WATER)
&& (p.getLocation().subtract(0.0D, 3.0D, 0.0D).getBlock().getType() == Material.STATIONARY_WATER)
&& (p.getVehicle() == null) && (p.getGameMode() != GameMode.CREATIVE)
&& (!p.isFlying())) {
p.setGliding(true);
}
if ((p.getLocation().getBlock().getType() != Material.STATIONARY_WATER)
&& (p.getLocation().subtract(0.0D, 3.0D, 0.0D).getBlock().getType() != Material.STATIONARY_WATER)
&& (p.getVehicle() == null)) {
p.setGliding(false);
}
//only for debugging purposes
if(p.getLocation().getY() >= 5.0D && p.getLocation().getBlock().getType() == Material.STATIONARY_WATER) {
Vector v = p.getLocation().getDirection().multiply(0D).setY(3D);
p.setVelocity(v);
}
}
@EventHandler
public void onEntityToggleGlideEvent(EntityToggleGlideEvent e) {
if(e.getEntity() instanceof Player) {
final CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() != Material.STATIONARY_WATER) {
p.setVelocity(new Vector(p.getLocation().getDirection().getX() * 1, 1 * -1.0, p.getLocation().getDirection().getZ() * 0.1));
e.setCancelled(true);
}
if(p.isSneaking()) {
e.setCancelled(true);
}
}
}
@EventHandler
public void onToogleSneak(PlayerToggleSneakEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(!p.isSneaking()) {
p.setGliding(true);
}
}
@EventHandler
public void onEntityBlockChange(EntityChangeBlockEvent e) {
e.setCancelled(true);
}
/*
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent e) {
if (e.getSpawnReason() != CreatureSpawnEvent.SpawnReason.CUSTOM) {
e.setCancelled(true);
}
}
*/
@EventHandler
public void onEntityInteract(EntityInteractEvent e) {
if (e.getBlock().getType() == Material.CROPS && e.getEntity() instanceof LivingEntity)
e.setCancelled(true);
}
}

View File

@ -1,73 +0,0 @@
package eu.univento.lobby.listeners;
import org.bukkit.event.Listener;
/**
* handels all posible easter eggs
* @author joethei
* @version 0.1
*/
public class FoundItems implements Listener{
/*
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
Messages msgs = new Messages(p);
if(e.getItem().getItemStack().getType() == Material.RECORD_3) {
if(!hasFound("music_3")) {
setFound("music_3");
p.sendTitle(5, 5, 5, msgs.Lobby_FOUND_ITEM_PREFIX(), "Music_3");
p.addExperience(5);
}
}
if(e.getItem().getItemStack().getType() == Material.SUGAR) {
if(!hasFound("sugar")) {
setFound("su1gar");
p.sendTitle(5, 5, 5, msgs.Lobby_FOUND_ITEM_PREFIX(), "Sugar");
p.addExperience(5);
}
}
if(e.getItem().getItemStack().getType() == Material.RED_ROSE) {
if(!hasFound("hearts")) {
setFound("hearts");
p.sendTitle(5, 5, 5, msgs.Lobby_FOUND_ITEM_PREFIX(), "Hearts");
p.addExperience(3);
}
}
if(e.getItem().getItemStack().getType() == Material.FEATHER) {
if(!hasFound("feather")) {
setFound("feather");
p.sendTitle(5, 5, 5, msgs.Lobby_FOUND_ITEM_PREFIX(), "Feather");
}
}
e.setCancelled(true);
}
public static boolean hasFound(String item) {
int id = 8;
MySQL sql = Core.getCommons().getDatabaseManager().getMySQL();
try {
PreparedStatement st = sql.getConnection().prepareStatement("SELECT * FROM FoundItems WHERE ID='" + id + "';");
ResultSet rs = st.executeQuery();
return rs.next() && rs.getInt(item) == 1;
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
private void setFound(String item) {
int id = 8;
MySQL sql = Core.getCommons().getDatabaseManager().getMySQL();
try {
PreparedStatement st = sql.getConnection().prepareStatement("UPDATE FoundItems SET " + item + "='1' WHERE ID='" + id + "';");
st.execute();
} catch (SQLException e) {
e.printStackTrace();
}
}
*/
}

View File

@ -0,0 +1,84 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityToggleGlideEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
/**
* @author joethei
* @version 1.0
*/
public class FunStuff implements Listener{
@EventHandler
public void onMove(PlayerMoveEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if ((p.getLocation().getBlock().getType() == Material.STATIONARY_WATER)
&& (p.getLocation().subtract(0.0D, 3.0D, 0.0D).getBlock().getType() == Material.STATIONARY_WATER)
&& (p.getVehicle() == null) && (p.getGameMode() != GameMode.CREATIVE)
&& (!p.isFlying())) {
p.setGliding(true);
}
if ((p.getLocation().getBlock().getType() != Material.STATIONARY_WATER)
&& (p.getLocation().subtract(0.0D, 3.0D, 0.0D).getBlock().getType() != Material.STATIONARY_WATER)
&& (p.getVehicle() == null)) {
p.setGliding(false);
}
//only for debugging purposes
if(p.getLocation().getY() <= 5.0D && p.getLocation().getBlock().getType() == Material.STATIONARY_WATER) {
Vector v = p.getLocation().getDirection().multiply(0D).setY(3D);
p.setVelocity(v);
}
}
@EventHandler
public void onEntityToggleGlideEvent(EntityToggleGlideEvent e) {
if(e.getEntity() instanceof Player) {
final CustomPlayer p = CustomPlayer.getPlayer((Player) e.getEntity());
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() != Material.STATIONARY_WATER) {
p.setVelocity(new Vector(p.getLocation().getDirection().getX() * 1, 1 * -1.0, p.getLocation().getDirection().getZ() * 0.1));
e.setCancelled(true);
}
if(p.isSneaking()) {
e.setCancelled(true);
}
}
}
@EventHandler
public void onToogleSneak(PlayerToggleSneakEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
if(!p.isSneaking()) {
p.setGliding(true);
}
}
@EventHandler
public void onEntityHit(EntityDamageByEntityEvent e) {
if(e.getDamager() instanceof Player && e.getEntity() instanceof Creature) {
Creature creature = (Creature) e.getEntity();
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getDamager());
creature.setGlowing(true);
creature.setCustomName(p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + " §8hat mir das angetan");
creature.setCustomNameVisible(true);
creature.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, 60, 5, false));
}
}
}

View File

@ -1,7 +1,16 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.commons.player.rank.Rank;
import eu.univento.commons.server.ServerType;
import eu.univento.core.Core;
import eu.univento.core.api.Config;
import eu.univento.core.api.gui.inventory.InventoryGUI;
import eu.univento.core.api.items.ItemBuilder;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.Lobby;
import org.bukkit.*;
@ -53,6 +62,30 @@ public class ItemEvents implements Listener {
e.setCancelled(true);
}
if(item.getType() == Material.COMPASS) {
e.setCancelled(true);
InventoryGUI gui = new InventoryGUI(p, 9, "§aNavigator");
gui.addItem(2, new ItemBuilder(Material.ENCHANTMENT_TABLE).name("§cBalance").build(), player -> {
player.closeInventory();
//CloudProxy.getInstance().sendPlayer(p.getUniqueId(), CloudNetAPI.getInstance().getServerInfos("Free4All").get(0));
player.connectToServer(ServerType.SECRET_GAME_FREE4ALL);
player.teleport(Config.readLocation("Lobby.Locs.FFA"));
});
gui.addItem(4, new ItemBuilder(Material.FLOWER_POT_ITEM).name("§aBauserver").build(), player -> {
player.closeInventory();
//CloudProxy.getInstance().sendPlayer(p.getUniqueId(), Core.getCloudNetAPI().getServerInfos("TeamVento").get(0));
player.connectToServer(ServerType.TEAM_BUILD);
player.teleport(Config.readLocation("Lobby.Locs.Build"));
});
gui.addItem(6, new ItemBuilder(Material.BOOK).name("§bDevelopment").build(), player -> {
player.closeInventory();
//CloudProxy.getInstance().sendPlayer(p.getUniqueId(), Core.getCloudNetAPI().getServerInfos("TrashGames").get(0));
player.connectToServer(ServerType.SECRET_GAME_TRASHGAMES);
player.teleport(Config.readLocation("Lobby.Locs.TrashGames"));
});
gui.open();
}
}
}

View File

@ -1,9 +1,14 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.commons.player.rank.Rank;
import eu.univento.core.api.Hologram;
import eu.univento.core.api.items.ItemBuilder;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.utils.PetManager;
import eu.univento.lobby.utils.Scoreboards;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -36,6 +41,8 @@ public class JoinQuit implements Listener {
p.setFoodLevel(20);
p.setExp(0F);
p.setLevel(0);
p.getInventory().clear();
p.getInventory().setItem(4, new ItemBuilder(Material.COMPASS).name("§aNavigator").glow().build());
//InventoryManager invs = new InventoryManager(p);
@ -55,16 +62,17 @@ public class JoinQuit implements Listener {
}
});
String[] text = {"§e@univentoEU"};
String[] text = {"§2univento§8.§aeu"};
Hologram holo = new Hologram(new ItemStack(Material.WOOD_AXE), text, p.getWorld().getSpawnLocation());
holo.showPlayer(p);
BossBar bar = Bukkit.createBossBar("§cAchtung, frisch gestrichen", BarColor.GREEN, BarStyle.SEGMENTED_6, BarFlag.CREATE_FOG);
BossBar bar = Bukkit.createBossBar("§7Nutze den §aNavigator§8!", BarColor.GREEN, BarStyle.SEGMENTED_6, BarFlag.CREATE_FOG);
bar.addPlayer(p);
//p.sendActionBar(p.getMessages().LobbyBoard_NEW() + " " + p.getMessages().LobbyBoard_NEWS());
Scoreboards.updateScoreboard(p);
p.getLastLocation().whenComplete((location, throwable) -> p.teleport(location));
}
@ -81,8 +89,6 @@ public class JoinQuit implements Listener {
e.setQuitMessage(null);
if (PlayerHider.getHidden().contains(p))
PlayerHider.getHidden().remove(p);
if (PetManager.hasPet(p))
PetManager.removePet(p);
}
}

View File

@ -1,54 +0,0 @@
package eu.univento.lobby.listeners;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.utils.InventoryManager;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
/**
* opens menus
* @author joethei
* @version 1.0
*/
public class Menu implements Listener{
@EventHandler
public void onInteract(PlayerInteractEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
ItemStack item = p.getItemInHand();
if(!p.hasOpenInventory()) {
InventoryManager invs = new InventoryManager(p);
if(item.getType() == Material.WORKBENCH) {
p.setOpenInventory(true);
p.openInventory(invs.getNavigatorInventory());
}
if(item.getType() == Material.CHEST) {
p.setOpenInventory(true);
p.openInventory(invs.getFunChestInventory());
e.getPlayer().playSound(p.getEyeLocation(), Sound.BLOCK_CHEST_OPEN, 10.0F, 1.0F);
}
if(item.getType() == Material.SKULL_ITEM) {
p.setOpenInventory(true);
p.openInventory(invs.getProfileInventory());
}
if(item.getType() == Material.EXP_BOTTLE) {
e.setCancelled(true);
invs.setYoutuberInventory();
}
if(item.getType() == Material.BARRIER) {
invs.setMainInventory(true);
}if(item.getType() == Material.BLAZE_ROD) {
p.setOpenInventory(true);
p.openInventory(invs.getLobbySwitcherInventory());
}
}
}
}
}

View File

@ -1,275 +1,75 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.commons.player.rank.Rank;
import eu.univento.commons.server.ServerType;
import eu.univento.core.Core;
import eu.univento.core.api.Config;
import eu.univento.core.api.effects.Effects;
import eu.univento.core.api.gui.inventory.InventoryGUI;
import eu.univento.core.api.items.ItemBuilder;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.Lobby;
import eu.univento.lobby.utils.InventoryManager;
import net.minecraft.server.v1_11_R1.EnumParticle;
import org.bukkit.*;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
/**
* handles teleport menus
* @author joethei
* @version 1.0
*/
public class MenuEvents implements Listener {
private ArrayList<CustomPlayer> heartPlayers = new ArrayList<>();
private ArrayList<CustomPlayer> lavaPlayers = new ArrayList<>();
private Inventory lobbySwitcher;
@EventHandler
public void onClick(InventoryClickEvent e) {
if (e.getWhoClicked() instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer(e.getWhoClicked().getName());
InventoryManager invs = new InventoryManager(p);
//Messages msgs = new Messages(p);
if(!e.getSlotType().equals(SlotType.OUTSIDE) && e.getInventory().getType() == InventoryType.CHEST) {
if (e.getInventory().getName().equals(invs.getNavigatorInventory().getName())) {
if (e.getCurrentItem().getType() == Material.GOLD_BLOCK) {
teleport(p, "TheBlock");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.SNOW_BALL) {
teleport(p, "FlagAttack");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.LEATHER_HELMET) {
teleport(p, "TrashGames");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.MAGMA_CREAM) {
teleport(p, "Spawn");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.EYE_OF_ENDER) {
teleport(p, "PremiumHub");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.LEATHER_BOOTS) {
teleport(p, "TempleRun");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.SLIME_BALL) {
teleport(p, "HulkFight");
p.closeInventory();
}
if (e.getCurrentItem().getType() == Material.FLOWER_POT_ITEM) {
p.closeInventory();
p.connectToServer("build");
} else {
e.setCancelled(true);
}
}
if (e.getInventory().getName().equals(invs.getProfileInventory().getName())) {
if (e.getCurrentItem().getType() == Material.COMPASS) {
p.closeInventory();
p.openInventory(invs.getStatsInventory());
}
if (e.getCurrentItem().getType() == Material.PUMPKIN) {
p.closeInventory();
p.openInventory(invs.getFriendsInventory());
}
if (e.getCurrentItem().getType() == Material.NAME_TAG) {
p.closeInventory();
p.openInventory(invs.getSettingsInventory());
} else {
e.setCancelled(true);
}
}
if (e.getInventory().getName().equals(invs.getSettingsInventory().getName())) {
if(e.getSlot() == 0) {
p.getDatabasePlayer().getSettings().setPartyRequests(!p.getDatabasePlayer().getSettings().hasPartyRequestsEnabled());
p.closeInventory();
p.openInventory(invs.getSettingsInventory());
}
}
if(e.getInventory().getName().equals(invs.getLanguagesInventory().getName())) {
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eDeutsch")) {
p.getDatabasePlayer().getSettings().setLanguage("DE");
p.closeInventory();
//p.sendMessage(msgs.PREFIX() + "§7Sprache auf §eDeutsch §7geändert");
invs.setMainInventory(true);
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eEnglish")) {
p.getDatabasePlayer().getSettings().setLanguage("EN");
p.closeInventory();
//p.sendMessage(msgs.PREFIX() + "§7Language changed to §eenglish");
invs.setMainInventory(true);
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("§eitaliano")) {
p.getDatabasePlayer().getSettings().setLanguage("IT");
p.closeInventory();
//p.sendMessage(msgs.PREFIX() + "§7Da fehlt doch noch was");
invs.setMainInventory(true);
}
}
if (e.getInventory().getName().equals(invs.getFunChestInventory().getName())) {
e.setCancelled(true);
if (e.getCurrentItem().getType() == Material.RECORD_3) {
p.closeInventory();
p.openInventory(invs.getMusicInventory());
}
if (e.getCurrentItem().getType() == Material.ARMOR_STAND) {
p.closeInventory();
p.openInventory(invs.getGadgetsInventory());
}
if (e.getCurrentItem().getType() == Material.NOTE_BLOCK) {
p.closeInventory();
p.openInventory(invs.getParticleInventory());
}
if(e.getCurrentItem().getType() == Material.MONSTER_EGG) {
p.closeInventory();
p.openInventory(invs.getPetsInventory());
}
}
if (e.getInventory().getName().equals(invs.getStatsInventory().getName())) {
e.setCancelled(true);
}
if (e.getInventory().getName().equals(invs.getFriendsInventory().getName())) {
e.setCancelled(true);
}
if (e.getInventory().getName().equals(invs.getMusicInventory().getName())) {
e.setCancelled(true);
if (e.getCurrentItem().getType() == Material.RECORD_3) {
p.closeInventory();
p.playSound(p.getEyeLocation(), "records.11", 100000000000.0F, 1.0F);
//p.sendActionBar(msgs.Lobby_PLAYING_MUSIC_PREFIX() + ": Milky Way Stars | Janji feat. TR");
}
}
if (e.getInventory().getName().equals(invs.getGadgetsInventory().getName())) {
e.setCancelled(true);
if (e.getCurrentItem().getType() == Material.SUGAR) {
p.closeInventory();
if (p.getWalkSpeed() == 0.2F) {
p.setWalkSpeed(0.5F);
} else {
p.setWalkSpeed(0.2F);
}
}
if (e.getCurrentItem().getType() == Material.FEATHER) {
p.closeInventory();
}
}
if (e.getInventory().getName().equals(invs.getParticleInventory().getName())) {
e.setCancelled(true);
if (e.getCurrentItem().getType() == Material.RED_ROSE) {
if (heartPlayers.contains(p)) {
heartPlayers.remove(p);
} else {
heartPlayers.add(p);
}
}else if(e.getCurrentItem().getType() == Material.LAVA_BUCKET) {
if(lavaPlayers.contains(p)) {
lavaPlayers.remove(p);
}else{
lavaPlayers.add(p);
}
}
/*
}if (e.getInventory().getName().equals(invs.getPetsInventory().getName())) {
e.setCancelled(true);
if(e.getCurrentItem().getItemMeta().getDisplayName().contains(msgs.LobbyItems_PETS_PIG())) {
p.closeInventory();
PetManager.setPet(p, EntityType.PIG);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getItemMeta().getDisplayName().contains(msgs.LobbyItems_PETS_COW())) {
p.closeInventory();
PetManager.setPet(p, EntityType.COW);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getItemMeta().getDisplayName().contains(msgs.LobbyItems_PETS_CHICKEN())) {
p.closeInventory();
PetManager.setPet(p, EntityType.CHICKEN);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getItemMeta().getDisplayName().contains(msgs.LobbyItems_PETS_RABBIT())) {
p.closeInventory();
PetManager.setPet(p, EntityType.RABBIT);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getItemMeta().getDisplayName().contains(msgs.LobbyItems_PETS_MUSHROM_COW())) {
p.closeInventory();
PetManager.setPet(p, EntityType.MUSHROOM_COW);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("Horse")) {
p.closeInventory();
PetManager.setPet(p, EntityType.HORSE);
Horse horse = (Horse) PetManager.getPet(p);
horse.setJumpStrength(20.0D);
horse.setVariant(Horse.Variant.UNDEAD_HORSE);
horse.setTamed(true);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getItemMeta().getDisplayName().equals("PolarBear")) {
p.closeInventory();
PetManager.setPet(p, EntityType.POLAR_BEAR);
PolarBear polarBear = (PolarBear) PetManager.getPet(p);
polarBear.setAI(false);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_ADD());
}
if(e.getCurrentItem().getType() == Material.BARRIER) {
p.closeInventory();
PetManager.removePet(p);
p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_REMOVE());
}
*/
}else {
e.setCancelled(true);
}
}
}
}
@EventHandler
public void onMove(PlayerMoveEvent e) {
public void onPlayerInteract(PlayerInteractEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
List<Player> players = new ArrayList<>();
players.addAll(Core.getOnlinePlayers());
if (e.getItem().getType() == Material.BUCKET) {
p.openInventory(lobbySwitcher);
p.playSound(p.getEyeLocation(), Sound.BLOCK_CHEST_OPEN, 1.0F, 1.0F);
}
if(e.getItem().getType() == Material.NETHER_STAR) {
InventoryGUI gui = new InventoryGUI(p, 27, "Lobby Navigator");
if(heartPlayers.contains(p))
Effects.playEffect(p.getLocation(), EnumParticle.HEART, 5);
if(lavaPlayers.contains(p))
Effects.playEffect(p.getLocation(), EnumParticle.DRIP_LAVA, 5);
//spawn teleport
gui.addItem(1, new ItemBuilder(p, Material.SLIME_BALL).name("Spawn").build(), player -> {
player.closeInventory();
player.teleport(player.getWorld().getSpawnLocation());
});
//build server teleport
if(p.getDatabasePlayer().isAllowed(Rank.Sound)) {
gui.addItem(0, new ItemBuilder(p, Material.GRASS).name("Bau Server").build(), player -> {
player.closeInventory();
player.connectToServer(ServerType.TEAM_BUILD);
});
}
private void teleport(CustomPlayer p, String location) {
Vector v = p.getLocation().getDirection().multiply(0D).setY(2D);
p.setVelocity(v);
p.playSound(p.getEyeLocation(), Sound.ENTITY_GENERIC_EXPLODE, 5.0F, 1.0F);
p.playEffect(p.getEyeLocation(), Effect.CHORUS_FLOWER_DEATH, 20);
Location loc = Config.readLocation("Lobby.Locs." + location);
Bukkit.getScheduler().scheduleAsyncDelayedTask(Lobby.getInstance(), () -> {
for (Player players : Bukkit.getOnlinePlayers()) {
players.playSound(p.getEyeLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 1.0F);
players.playEffect(p.getEyeLocation(), Effect.DRAGON_BREATH, 20);
p.teleport(loc);
players.playSound(p.getEyeLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 1.0F);
players.playEffect(p.getEyeLocation(), Effect.SMOKE, 20);
gui.open();
}
}
}, 40L);
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
CustomPlayer p = CustomPlayer.getPlayer((Player) e.getWhoClicked());
if (e.getClickedInventory() == null && e.getCurrentItem() == null) return;
if (e.getClickedInventory() == lobbySwitcher) {
e.setCancelled(true);
String server = ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName());
if (Core.getCloudAPI().getServerId().equals(server)) {
p.sendMessage("Nope, da bist du doch schon");
return;
}
p.connectToServer(server);
p.closeInventory();
}
}
}

View File

@ -1,11 +1,18 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.core.Core;
import eu.univento.core.api.events.MoveEventFilter;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.Lobby;
import eu.univento.lobby.utils.PetManager;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -29,16 +36,15 @@ public class Parkour implements Listener{
public void onBlockMove(MoveEventFilter.PlayerBlockMoveEvent e) {
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
//Messages msgs = new Messages(p);
Block block = p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();
Block block = e.getTo().subtract(0.0D, 1.0D, 0.0D).getBlock();
if (block.getType() == Material.STAINED_CLAY) {
if (players.contains(p)) {
spawnRandomBlock(block.getLocation());
}else if(p.getLocation().getBlock().getType() == Material.IRON_PLATE) {
}else if(e.getTo().getBlock().getType() == Material.IRON_PLATE) {
players.add(p);
//p.sendMessage(msgs.PREFIX() + msgs.Lobby_PARKOUR_ON());
spawnRandomBlock(block.getLocation());
p.setWalkSpeed(0.2F);
if(PetManager.hasPet(p)) PetManager.removePet(p);
}
} else {
if (block.getType() != Material.AIR && players.contains(p) && block.getType() != Material.IRON_PLATE) {

View File

@ -1,124 +0,0 @@
package eu.univento.lobby.listeners;
import eu.univento.core.api.gui.AnvilGUI;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.utils.PetManager;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
/**
* @author joethei
* @version 1.0
*/
public class PetInteract implements Listener {
@EventHandler
public void onEntityInteract(PlayerInteractEntityEvent e) {
e.setCancelled(true);
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer());
Entity entity = e.getRightClicked();
if (PetManager.getPet(p) == entity) {
p.openInventory(getInventory(p));
}
}
Inventory getInventory(CustomPlayer p) {
//Messages msgs = new Messages(p);
Inventory inv = Bukkit.createInventory(p, 9,"Nachricht");
ItemStack name = new ItemStack(Material.NAME_TAG);
ItemMeta nameMeta = name.getItemMeta();
//nameMeta.setDisplayName(msgs.LobbyItems_PETS_NAME());
name.setItemMeta(nameMeta);
ItemStack baby = new ItemStack(Material.SUGAR);
ItemMeta babyMeta = baby.getItemMeta();
//babyMeta.setDisplayName(msgs.LobbyItems_PETS_AGE());
baby.setItemMeta(babyMeta);
ItemStack mount = new ItemStack(Material.SADDLE);
ItemMeta mountMeta = mount.getItemMeta();
//mountMeta.setDisplayName(msgs.LobbyItems_PETS_RIDE());
mount.setItemMeta(mountMeta);
ItemStack delete = new ItemStack(Material.BARRIER);
ItemMeta deleteMeta = delete.getItemMeta();
//deleteMeta.setDisplayName(msgs.LobbyItems_PETS_REMOVE());
delete.setItemMeta(deleteMeta);
inv.setItem(0, name);
inv.setItem(1, baby);
inv.setItem(2, mount);
inv.setItem(8, delete);
return inv;
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
if (e.getWhoClicked() instanceof Player) {
CustomPlayer p = CustomPlayer.getPlayer(e.getWhoClicked().getName());
//Messages msgs = new Messages(p);
if (e.getInventory().getName().equals(getInventory(p).getName())) {
if (e.getCurrentItem().getType() == Material.NAME_TAG) {
assert p != null;
p.closeInventory();
AnvilGUI gui = new AnvilGUI(p, event -> {
if(event.getSlot() == AnvilGUI.AnvilSlot.OUTPUT) {
event.setWillClose(true);
event.setWillDestroy(true);
PetManager.setName(p, p.getDatabasePlayer().getRank().getColor() + event.getName());
}else{
event.setWillDestroy(true);
event.setWillClose(true);
}
});
ItemStack name = new ItemStack(Material.NAME_TAG);
ItemMeta nameMeta = name.getItemMeta();
nameMeta.setDisplayName(PetManager.getName(p));
name.setItemMeta(nameMeta);
gui.setSlot(AnvilGUI.AnvilSlot.INPUT_LEFT, name);
gui.open();
}
if(e.getCurrentItem().getType() == Material.SUGAR) {
p.closeInventory();
Entity pet = PetManager.getPet(p);
Ageable age = (Ageable) pet;
if(age.isAdult()) {
age.setBaby();
}else {
age.setAdult();
}
}
if(e.getCurrentItem().getType() == Material.SADDLE) {
p.closeInventory();
Entity pet = PetManager.getPet(p);
if(pet.getPassenger() != null) {
pet.setPassenger(null);
}else {
pet.setPassenger(p);
}
}
if (e.getCurrentItem().getType() == Material.BARRIER) {
p.closeInventory();
PetManager.removePet(p);
//p.sendMessage(msgs.PREFIX() + msgs.Lobby_PET_REMOVE());
}
}
}
}
}

View File

@ -1,8 +1,13 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.listeners;
import eu.univento.commons.player.rank.Rank;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.lobby.utils.InventoryManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -24,15 +29,9 @@ import java.util.ArrayList;
public class PlayerHider implements Listener{
private static ArrayList<CustomPlayer> hidden = new ArrayList<>();
public static ArrayList<CustomPlayer> getHidden() {
return hidden;
}
@Getter private static ArrayList<CustomPlayer> hidden = new ArrayList<>();
private static ArrayList<CustomPlayer> silentlobby = new ArrayList<>();
public static ArrayList<CustomPlayer> getSilentlobby() {
return silentlobby;
}
@Getter private static ArrayList<CustomPlayer> silentlobby = new ArrayList<>();
private ItemStack getHide(CustomPlayer p) {
//Messages msgs = new Messages(p);
@ -92,9 +91,8 @@ public class PlayerHider implements Listener{
if(p.getDatabasePlayer().isAllowed(Rank.VIP)) {
if(silentlobby.contains(p)) {
silentlobby.remove(p);
InventoryManager invs = new InventoryManager(p);
p.getInventory().clear();
invs.setMainInventory(true);
//p.sendMessage(msgs.PREFIX() + msgs.Lobby_SILENT_LOBBY_OFF());
for(Player players : Bukkit.getOnlinePlayers()) {
p.showPlayer(players);

View File

@ -1,3 +1,8 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.utils;
import eu.univento.core.api.player.CustomPlayer;
@ -17,8 +22,7 @@ public class CustomMapRenderer extends MapRenderer{
public void render(MapView mapView, MapCanvas mapCanvas, Player player) {
CustomPlayer p = CustomPlayer.getPlayer(player);
mapCanvas.drawText(1, 10, MinecraftFont.Font, "Hallo " + p.getName());
mapCanvas.drawText(1, 20, MinecraftFont.Font, "Du bist ein " + p.getDatabasePlayer().getRank().name());
mapCanvas.drawText(1, 30, MinecraftFont.Font, p.getDatabasePlayer().getFirstLogin().toString());
mapCanvas.drawText(1, 40, MinecraftFont.Font, "Sprache " + p.getDatabasePlayer().getLanguage());
mapCanvas.drawText(1, 20, MinecraftFont.Font, "Du bist ein " + p.getDatabasePlayer().getRank().getColor() + p.getDatabasePlayer().getRank().name());
mapCanvas.drawText(1, 40, MinecraftFont.Font, "Sprache " + p.getDatabasePlayer().getLanguage().getLocale().getLanguage());
}
}

View File

@ -1,555 +0,0 @@
package eu.univento.lobby.utils;
import eu.univento.commons.player.language.Language;
import eu.univento.commons.player.rank.Rank;
import eu.univento.core.api.items.ItemBuilder;
import eu.univento.core.api.player.CustomPlayer;
import eu.univento.commons.server.ServerInfo;
import eu.univento.lobby.Lobby;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.material.Dye;
import java.util.ArrayList;
import java.util.List;
/**
* opens inventorys for players
*
* @author joethei
* @version 1.0
*/
public class InventoryManager {
private CustomPlayer player;
private Language language;
private ItemStack empty = new ItemStack(Material.AIR);
public InventoryManager(CustomPlayer player) {
this.player = player;
this.language = player.getDatabasePlayer().getLanguage();
}
public void setMainInventory(boolean forcetime) {
Inventory inv = player.getInventory();
ItemStack nav = new ItemStack(Material.WORKBENCH);
ItemMeta navMeta = nav.getItemMeta();
navMeta.setDisplayName(player.getDatabasePlayer().getLanguage().getWord("Lobby.Item.Navigator"));
nav.setItemMeta(navMeta);
ItemStack lobby = new ItemStack(Material.BLAZE_POWDER);
ItemMeta lobbyMeta = lobby.getItemMeta();
lobbyMeta.setDisplayName(player.getDatabasePlayer().getLanguage().getWord("Lobby.Item.LobbySwitcher"));
lobby.setItemMeta(lobbyMeta);
ItemStack adventure = new ItemStack(Material.GLOWSTONE_DUST);
ItemMeta adventureMeta = adventure.getItemMeta();
adventureMeta.setDisplayName(player.getDatabasePlayer().getLanguage().getWord("Lobby.Item.Adventure"));
adventure.setItemMeta(adventureMeta);
ItemStack fun = new ItemStack(Material.CHEST);
ItemMeta funMeta = fun.getItemMeta();
funMeta.setDisplayName(player.getDatabasePlayer().getLanguage().getWord("Lobby.Item.FunChest"));
fun.setItemMeta(funMeta);
ItemStack youtube = new ItemStack(Material.EXP_BOTTLE);
ItemMeta youtubeMeta = youtube.getItemMeta();
youtubeMeta.setDisplayName(player.getDatabasePlayer().getLanguage().getWord("Lobby.Item.Youtuber"));
youtube.setItemMeta(youtubeMeta);
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta meta = (SkullMeta) skull.getItemMeta();
meta.setOwner(player.getName());
meta.setDisplayName(player.getDatabasePlayer().getLanguage().getWord("Lobby.Item.Profile"));
skull.setItemMeta(meta);
inv.setItem(2, empty);
inv.setItem(3, empty);
inv.setItem(4, empty);
inv.setItem(6, empty);
timeItem(inv, 0, nav, Sound.ENTITY_CHICKEN_EGG, 20L, false, forcetime);
timeItem(inv, 8, skull, Sound.ENTITY_CHICKEN_EGG, 40L, false, forcetime);
timeItem(inv, 1, lobby, Sound.ENTITY_CHICKEN_EGG, 60L, false, forcetime);
timeItem(inv, 7, fun, Sound.ENTITY_CHICKEN_EGG, 80L, false, forcetime);
if (player.getDatabasePlayer().isAllowed(Rank.VIP)) {
timeItem(inv, 5, youtube, Sound.ENTITY_CHICKEN_EGG, 120L, false, forcetime);
timeItem(inv, 3, adventure, Sound.ENTITY_CHICKEN_DEATH, 140L, false, forcetime);
} else {
timeItem(inv, 5, adventure, Sound.ENTITY_CHICKEN_EGG, 120L, false, forcetime);
}
}
/**
* gets inventory for navigation
*
* @return Inventory
*/
public Inventory getNavigatorInventory() {
Inventory inv = Bukkit.createInventory(player, 45, "Navigator");
inv.setItem(31, new ItemBuilder(Material.FIREWORK_CHARGE).name(language.getWord("Lobby.Menu.Nav.Spawn")).make());
if(player.getDatabasePlayer().isAllowed(Rank.Supporter)) {
ServerInfo.getServerInfo("build").whenComplete((serverInfo, throwable) ->
inv.setItem(26, new ItemBuilder(Material.FLOWER_POT_ITEM).name(language.getWord("Lobby.Menu.Nav.Build")).lore(serverInfo.getPlayers() + "Spieler online").make()));
}
return inv;
}
public Inventory getLobbySwitcherInventory() {
Inventory inv = Bukkit.createInventory(player, 18, "Lobbys");
return inv;
}
public void setYoutuberInventory() {
Inventory inv = player.getInventory();
String nickState;
if(player.getDatabasePlayer().getSettings().isNicked()) nickState = "on"; else nickState = "off";
ItemStack nick = new ItemStack(Material.NAME_TAG);
ItemMeta nickMeta = nick.getItemMeta();
nickMeta.setDisplayName(player.getDatabasePlayer().getLanguage().getWord("Lobby.Item.YT.Nick." + nickState));
nick.setItemMeta(nickMeta);
ItemStack silent = new ItemStack(Material.TNT);
ItemMeta silentMeta = silent.getItemMeta();
silentMeta.setDisplayName(player.getDatabasePlayer().getLanguage().getWord("Lobby.Item.YT.SilentLobby"));
silent.setItemMeta(silentMeta);
ItemStack force = new ItemStack(Material.EYE_OF_ENDER);
ItemMeta forceMeta = force.getItemMeta();
forceMeta.setDisplayName(player.getDatabasePlayer().getLanguage().getWord("Lobby.Item.YT.Forcefield"));
force.setItemMeta(forceMeta);
ItemStack extras = new ItemStack(Material.MILK_BUCKET);
ItemMeta extrasMeta = extras.getItemMeta();
extrasMeta.setDisplayName(player.getDatabasePlayer().getLanguage().getWord("Lobby.Item.YT.Extras"));
extras.setItemMeta(extrasMeta);
Dye dye = new Dye();
dye.setColor(DyeColor.RED);
ItemStack back = dye.toItemStack();
ItemMeta backMeta = back.getItemMeta();
backMeta.setDisplayName(player.getDatabasePlayer().getLanguage().getWord("Lobby.Item.YT.Back"));
back.setItemMeta(backMeta);
inv.setItem(0, force);
inv.setItem(1, empty);
inv.setItem(2, nick);
inv.setItem(3, empty);
inv.setItem(4, silent);
inv.setItem(5, empty);
inv.setItem(6, extras);
inv.setItem(7, empty);
inv.setItem(8, back);
}
/**
* gets inventory for funchest
*
* @return Inventory
*/
public Inventory getFunChestInventory() {
Inventory inv = Bukkit.createInventory(player, 45, "FunChest");
ItemStack music = new ItemStack(Material.RECORD_3);
ItemMeta musicMeta = music.getItemMeta();
musicMeta.setLore(null);
//musicMeta.setDisplayName(player.getMessages().LobbyItems_MUSIC());
music.setItemMeta(musicMeta);
ItemStack gadgets = new ItemStack(Material.ARMOR_STAND);
ItemMeta gadgetsMeta = gadgets.getItemMeta();
//gadgetsMeta.setDisplayName(player.getMessages().LobbyItems_GADGETS());
gadgets.setItemMeta(gadgetsMeta);
ItemStack particle = new ItemStack(Material.NOTE_BLOCK);
ItemMeta particleMeta = particle.getItemMeta();
//particleMeta.setDisplayName(player.getMessages().LobbyItems_PARTICLE());
particle.setItemMeta(particleMeta);
ItemStack pets = new ItemStack(Material.MONSTER_EGG);
ItemMeta petsMeta = pets.getItemMeta();
//petsMeta.setDisplayName(player.getMessages().LobbyItems_PETS());
pets.setItemMeta(petsMeta);
inv.setItem(11, music);
inv.setItem(15, gadgets);
inv.setItem(29, particle);
inv.setItem(33, pets);
return inv;
}
/**
* gets inventory for music
*
* @return Inventory
*/
public Inventory getMusicInventory() {
Inventory inv = Bukkit.createInventory(player, 45, "Music");
ItemStack music_3 = new ItemStack(Material.RECORD_3);
ItemMeta music_3Meta = music_3.getItemMeta();
List<String> music_3Lore = new ArrayList<>();
music_3Lore.add("§6Jetzt abspielen");
music_3Meta.setDisplayName("§5Milky Way Stars | Janji feat. TR");
music_3Meta.setLore(music_3Lore);
music_3.setItemMeta(music_3Meta);
//if (FoundItems.hasFound("music_3")) inv.setItem(2, music_3);
return inv;
}
/**
* gets inventory for gadgets
*
* @return Inventory
*/
public Inventory getGadgetsInventory() {
Inventory inv = Bukkit.createInventory(player, 45, "Gadgets");
ItemStack sugar = new ItemStack(Material.SUGAR);
ItemMeta sugarMeta = sugar.getItemMeta();
sugarMeta.setDisplayName("§6Einen Teelöffel Zucker");
sugar.setItemMeta(sugarMeta);
ItemStack feather = new ItemStack(Material.FEATHER);
ItemMeta featherMeta = feather.getItemMeta();
featherMeta.setDisplayName("§6Federleicht");
feather.setItemMeta(featherMeta);
//if (FoundItems.hasFound("sugar")) inv.setItem(0, sugar);
//if (FoundItems.hasFound("feather")) inv.setItem(1, feather);
return inv;
}
/**
* gets inventory for particle effects
*
* @return Inventory
*/
public Inventory getParticleInventory() {
Inventory inv = Bukkit.createInventory(player, 45, "Particle");
ItemStack hearts = new ItemStack(Material.RED_ROSE);
ItemMeta heartsMeta = hearts.getItemMeta();
heartsMeta.setDisplayName("§6Herzen");
hearts.setItemMeta(heartsMeta);
ItemStack lava = new ItemStack(Material.LAVA_BUCKET);
ItemMeta lavaMeta = lava.getItemMeta();
lavaMeta.setDisplayName("§6Lava");
lava.setItemMeta(lavaMeta);
//if (FoundItems.hasFound("hearts")) inv.setItem(0, hearts);
//if(FoundItems.hasFound("lava", player)) inv.setItem(1, lava);
return inv;
}
public Inventory getPetsInventory() {
Inventory inv = Bukkit.createInventory(player, 45, "Pets");
ItemStack pig = new ItemStack(Material.MONSTER_EGG, 1, (short) 90);
ItemMeta pigMeta = pig.getItemMeta();
//pigMeta.setDisplayName(player.getMessages().LobbyItems_PETS_PIG());
pig.setItemMeta(pigMeta);
ItemStack cow = new ItemStack(Material.MONSTER_EGG, 1, (short) 92);
ItemMeta cowMeta = cow.getItemMeta();
//cowMeta.setDisplayName(player.getMessages().LobbyItems_PETS_COW());
cow.setItemMeta(cowMeta);
ItemStack chicken = new ItemStack(Material.MONSTER_EGG, 1, (short) 93);
ItemMeta chickenMeta = chicken.getItemMeta();
//chickenMeta.setDisplayName(player.getMessages().LobbyItems_PETS_CHICKEN());
chicken.setItemMeta(chickenMeta);
ItemStack rabbit = new ItemStack(Material.MONSTER_EGG, 1, (short) 101);
ItemMeta rabbitMeta = rabbit.getItemMeta();
//rabbitMeta.setDisplayName(player.getMessages().LobbyItems_PETS_RABBIT());
rabbit.setItemMeta(rabbitMeta);
ItemStack mushroom = new ItemStack(Material.MONSTER_EGG, 1, (short) 96);
ItemMeta mushroomMeta = mushroom.getItemMeta();
//mushroomMeta.setDisplayName(player.getMessages().LobbyItems_PETS_MUSHROM_COW());
mushroom.setItemMeta(mushroomMeta);
ItemStack horse = new ItemStack(Material.MONSTER_EGG, 1, (short) 101);
ItemMeta horseMeta = horse.getItemMeta();
horseMeta.setDisplayName("Horse");
horse.setItemMeta(horseMeta);
ItemStack polar = new ItemStack(Material.MONSTER_EGG, 1, (short) 101);
ItemMeta polarMeta = polar.getItemMeta();
polarMeta.setDisplayName("PolarBear");
polar.setItemMeta(polarMeta);
ItemStack delete = new ItemStack(Material.BARRIER);
ItemMeta deleteMeta = delete.getItemMeta();
//deleteMeta.setDisplayName(player.getMessages().LobbyItems_PETS_REMOVE());
delete.setItemMeta(deleteMeta);
inv.setItem(0, pig);
inv.setItem(1, cow);
inv.setItem(2, chicken);
inv.setItem(3, rabbit);
inv.setItem(4, mushroom);
inv.setItem(5, horse);
inv.setItem(6, polar);
inv.setItem(44, delete);
return inv;
}
/**
* gets inventory for profile
*
* @return Inventory
*/
public Inventory getProfileInventory() {
Inventory inv = Bukkit.createInventory(player, 9, "Profil");
ItemStack stats = new ItemStack(Material.COMPASS);
ItemMeta statsMeta = stats.getItemMeta();
//statsMeta.setDisplayName(player.getMessages().LobbyItems_STATS());
stats.setItemMeta(statsMeta);
ItemStack quests = new ItemStack(Material.PRISMARINE_SHARD);
ItemStack secrets = new ItemStack(Material.CHEST);
ItemStack friends = new ItemStack(Material.PUMPKIN);
ItemMeta friendsMeta = friends.getItemMeta();
//friendsMeta.setDisplayName(player.getMessages().LobbyItems_FRIENDS());
friends.setItemMeta(friendsMeta);
ItemStack settings = new ItemStack(Material.NAME_TAG);
ItemMeta settingsMeta = settings.getItemMeta();
//settingsMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS());
settings.setItemMeta(settingsMeta);
inv.setItem(0, stats);
inv.setItem(1, friends);
inv.setItem(2, quests);
inv.setItem(3, secrets);
inv.setItem(8, settings);
return inv;
}
/**
* gets inventory for settings
*
* @return Inventory
*/
public Inventory getSettingsInventory() {
Inventory inv = Bukkit.createInventory(player, 18, "Settings");
ArrayList<String> on = new ArrayList<>();
//on.add(player.getMessages().LobbyItems_SETTINGS_ON());
ArrayList<String> off = new ArrayList<>();
//off.add(player.getMessages().LobbyItems_SETTINGS_OFF());
ItemStack fastMenu = new ItemStack(Material.ANVIL);
ItemMeta fastMenuMeta = fastMenu.getItemMeta();
//fastMenuMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_FASTMENU());
if (player.getDatabasePlayer().getSettings().hasInventoryAnimationEnabled()) fastMenuMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
if (player.getDatabasePlayer().getSettings().hasInventoryAnimationEnabled()) fastMenuMeta.setLore(on);
else fastMenuMeta.setLore(off);
fastMenu.setItemMeta(fastMenuMeta);
ItemStack teleport = new ItemStack(Material.ENDER_PEARL);
ItemMeta teleportMeta = teleport.getItemMeta();
//teleportMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_SERVER_TELEPORT());
if (player.getDatabasePlayer().getSettings().hasTeleportAnimationEnabled()) teleportMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
if (player.getDatabasePlayer().getSettings().hasTeleportAnimationEnabled()) teleportMeta.setLore(on);
else fastMenuMeta.setLore(off);
teleport.setItemMeta(teleportMeta);
ItemStack requestsParty = new ItemStack(Material.FIREWORK);
ItemMeta requestsPartyMeta = requestsParty.getItemMeta();
//requestsPartyMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_PARTY_REQUESTS());
if (player.getDatabasePlayer().getSettings().hasPartyRequestsEnabled()) requestsPartyMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
if (player.getDatabasePlayer().getSettings().hasPartyRequestsEnabled()) requestsPartyMeta.setLore(on);
else requestsPartyMeta.setLore(off);
requestsParty.setItemMeta(requestsPartyMeta);
ItemStack requestsFriends = new ItemStack(Material.PUMPKIN);
ItemMeta requestsFriendsMeta = requestsFriends.getItemMeta();
//requestsFriendsMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_FRIEND_REQUESTS());
if (player.getDatabasePlayer().getSettings().hasFriendRequestsEnabled()) requestsFriendsMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
if (player.getDatabasePlayer().getSettings().hasFriendRequestsEnabled()) requestsFriendsMeta.setLore(on);
else requestsFriendsMeta.setLore(off);
requestsFriends.setItemMeta(requestsFriendsMeta);
ItemStack friendJump = new ItemStack(Material.ELYTRA);
ItemMeta friendJumpMeta = friendJump.getItemMeta();
friendJumpMeta.setDisplayName("Freunde springen nicht gerne");
if (player.getDatabasePlayer().getSettings().hasFriendJumpEnabled()) friendJumpMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
if (player.getDatabasePlayer().getSettings().hasFriendJumpEnabled()) friendJumpMeta.setLore(on);
else friendJumpMeta.setLore(off);
friendJump.setItemMeta(friendJumpMeta);
ItemStack chat = new ItemStack(Material.SIGN);
ItemMeta chatMeta = chat.getItemMeta();
//chatMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_CHATSOUNDS());
if (player.getDatabasePlayer().getSettings().hasChatSoundsEnabled()) chatMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
if (player.getDatabasePlayer().getSettings().hasChatSoundsEnabled()) chatMeta.setLore(on);
else chatMeta.setLore(off);
chat.setItemMeta(chatMeta);
ItemStack effects = new ItemStack(Material.BLAZE_POWDER);
ItemMeta effectsMeta = effects.getItemMeta();
//effectsMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_EFFECTS());
if (player.getDatabasePlayer().getSettings().hasEffectsEnabled()) effectsMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
if (player.getDatabasePlayer().getSettings().hasEffectsEnabled()) effectsMeta.setLore(on);
else effectsMeta.setLore(off);
effects.setItemMeta(effectsMeta);
ItemStack storyMode = new ItemStack(Material.BOOK_AND_QUILL);
ItemMeta storyModeMeta = storyMode.getItemMeta();
storyModeMeta.setDisplayName("Geschichtsmodus ist auch noch da");
if (player.getDatabasePlayer().getSettings().hasStoryModeEnabled()) storyModeMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
if (player.getDatabasePlayer().getSettings().hasStoryModeEnabled()) storyModeMeta.setLore(on);
else storyModeMeta.setLore(off);
storyMode.setItemMeta(storyModeMeta);
ItemStack languages = new ItemStack(Material.BOOK);
ItemMeta languagesMeta = languages.getItemMeta();
//languagesMeta.setDisplayName(player.getMessages().LobbyItems_SETTINGS_LANGUAGES());
languages.setItemMeta(languagesMeta);
inv.setItem(0, fastMenu);
inv.setItem(1, teleport);
inv.setItem(2, requestsParty);
inv.setItem(3, requestsFriends);
inv.setItem(4, friendJump);
inv.setItem(5, chat);
inv.setItem(6, effects);
inv.setItem(7, storyMode);
inv.setItem(17, languages);
return inv;
}
public Inventory getLanguagesInventory() {
Inventory inv = Bukkit.createInventory(player, 9, "Languages");
ItemStack de = new ItemStack(Material.PAPER);
ItemMeta deMeta = de.getItemMeta();
deMeta.setDisplayName("§eDeutsch");
if (player.getDatabasePlayer().getSettings().getLanguage().equals("DE")) deMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
de.setItemMeta(deMeta);
ItemStack en = new ItemStack(Material.PAPER);
ItemMeta enMeta = en.getItemMeta();
enMeta.setDisplayName("§eEnglish");
if (player.getDatabasePlayer().getSettings().getLanguage().equals("EN")) enMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
en.setItemMeta(enMeta);
ItemStack it = new ItemStack(Material.PAPER);
ItemMeta itMeta = it.getItemMeta();
itMeta.setDisplayName("§eitaliano");
if (player.getDatabasePlayer().getSettings().getLanguage().equals("IT")) itMeta.addEnchant(Enchantment.ARROW_DAMAGE, 10, false);
it.setItemMeta(itMeta);
inv.setItem(0, de);
inv.setItem(1, en);
inv.setItem(2, it);
return inv;
}
/**
* gets friends inventory
*
* @return Inventory
*/
public Inventory getFriendsInventory() {
Inventory inv = Bukkit.createInventory(player, 45, "Friens");
/**
ArrayList<UUID> list = player.getFriends();
for(int i = 0; i >= list.size(); i++) {
OfflinePlayer p = Bukkit.getOfflinePlayer(list.get(i));
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta meta = (SkullMeta) skull.getItemMeta();
meta.setOwner(p.getName());
meta.setDisplayName(p.getName());
skull.setItemMeta(meta);
inv.addItem(skull);
}
*/
return inv;
}
public Inventory getStatsInventory() {
Inventory inv = Bukkit.createInventory(player, 45, "stats");
return inv;
}
/**
* time item appearance of item
*
* @param inv inventory
* @param slot Inventory slot
* @param item ItemStack
* @param sound Sound
* @param time long
* @param menu is menu ?
* @param forcedtime if true settings will be ignored
*/
private void timeItem(Inventory inv, int slot, ItemStack item, Sound sound, long time, boolean menu, boolean forcedtime) {
if (!player.getDatabasePlayer().getSettings().hasInventoryAnimationEnabled() || forcedtime) {
addItem(inv, slot, item, null, menu);
} else {
Bukkit.getScheduler().scheduleAsyncDelayedTask(Lobby.getInstance(), () -> addItem(inv, slot, item, sound, menu), time);
}
}
/**
* add item to inventory
*
* @param inv inventory
* @param slot Inventory slot
* @param item ItemStack
* @param sound Sound
* @param menu is menu ?
*/
public void addItem(Inventory inv, int slot, ItemStack item, Sound sound, boolean menu) {
if (menu) {
String name = inv.getTitle();
if (player.getOpenInventory().getTitle().equals(name)) {
inv.setItem(slot, item);
player.playSound(player.getEyeLocation(), sound, 1.0F, 1.0F);
}
} else {
inv.setItem(slot, item);
player.playSound(player.getEyeLocation(), sound, 1.0F, 1.0F);
}
}
}

View File

@ -1,57 +0,0 @@
package eu.univento.lobby.utils;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import java.util.HashMap;
/**
* @author joethei
* @version 1.0
*/
public class PetManager {
private static HashMap<CustomPlayer, Entity> pets = new HashMap<>();
public static HashMap<CustomPlayer, Entity> getPets() {
return pets;
}
public static boolean hasPet(CustomPlayer p) {
return pets.containsKey(p);
}
public static Entity getPet(CustomPlayer p) {
return pets.get(p);
}
public static void removePet(CustomPlayer p) {
pets.get(p).remove();
}
public static void setPet(CustomPlayer p, EntityType e) {
if(hasPet(p)) {
removePet(p);
}
new Pets().createPet(p, e);
}
public static void setName(CustomPlayer p, String name) {
if(hasPet(p)) {
getPet(p).setCustomName(name);
}
}
public static String getName(CustomPlayer p) {
if(hasPet(p)) {
return getPet(p).getCustomName();
}else {
return null;
}
}
public static void clearPets() {
pets.values().forEach(Entity::remove);
}
}

View File

@ -1,69 +0,0 @@
package eu.univento.lobby.utils;
import eu.univento.core.api.pet.NMSHandler;
import eu.univento.core.api.player.CustomPlayer;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftCreature;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import java.util.Random;
/**
* @author joethei
* @version 1.0
*/
public class Pets {
public Pets(){
}
void createPet(CustomPlayer p, EntityType type){
Entity entity = NMSHandler.spawn(type, p.getLocation());
assert entity != null;
entity.setCustomName(p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + "'s");
entity.setCustomNameVisible(true);
PetManager.getPets().put(p, entity);
}
public void followPlayer(Creature creature, Player player, double speed){
Location location = player.getLocation();
Random rnd = new Random();
int rand = rnd.nextInt(6);
switch(rand){
case 0:
location.add(1.5,0,1.5);
break;
case 1:
location.add(0,0,1.5);
break;
case 2:
location.add(1.5,0,0);
break;
case 3:
location.subtract(1.5,0,1.5);
break;
case 4:
location.subtract(0,0,1.5);
break;
case 5:
location.subtract(1.5,0,0);
break;
}
if(location.distanceSquared(creature.getLocation()) > 100){
if(player.isFlying()){
return;
}
creature.teleport(location);
}else{
((CraftCreature)creature).getHandle().getNavigation().a(location.getX(),location.getY(),location.getZ(),speed);
}
}
}

View File

@ -1,61 +1,128 @@
/*
* Copyright (c) 2018 univento.eu - All rights reserved
* You are not allowed to use, distribute or modify this code
*/
package eu.univento.lobby.utils;
import eu.univento.core.Core;
import eu.univento.core.api.player.CustomPlayer;
import io.vertx.core.json.JsonObject;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard;
import java.util.ArrayList;
import java.util.List;
/**
* @author joethei
* @version 1.0
* @version 2.0
*/
public class Scoreboards {
public static void updateScoreboard(CustomPlayer p) {
//Messages msgs = p.getMessages();
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
List<String> general = new ArrayList<>();
List<String> dev = new ArrayList<>();
List<String> build = new ArrayList<>();
List<String> team = new ArrayList<>();
Core.getCommons().getDatabaseManager().getMongoDB().getClient().findOne("updates", new JsonObject().put("category", "general"), null, event -> {
if(event.failed()) return;
event.result().getJsonArray("news").forEach(o -> general.add((String) o));
});
Core.getCommons().getDatabaseManager().getMongoDB().getClient().findOne("updates", new JsonObject().put("category", "development"), null, event -> {
if(event.failed()) return;
event.result().getJsonArray("news").forEach(o -> dev.add((String) o));
});
Core.getCommons().getDatabaseManager().getMongoDB().getClient().findOne("updates", new JsonObject().put("category", "build"), null, event -> {
if(event.failed()) return;
event.result().getJsonArray("news").forEach(o -> build.add((String) o));
});
Core.getCommons().getDatabaseManager().getMongoDB().getClient().findOne("updates", new JsonObject().put("category", "team"), null, event -> {
if(event.failed()) return;
event.result().getJsonArray("news").forEach(o -> team.add((String) o));
});
Bukkit.getScheduler().scheduleSyncDelayedTask(Core.getInstance(), new BukkitRunnable() {
@Override
public void run() {
int size = general.size() + dev.size() + build.size() + team.size() + 8;
Scoreboard board = p.getScoreboard();
if(board.getObjective("Lobby") != null) board.getObjective("Lobby").unregister();
Objective obj = board.registerNewObjective("Lobby", "dummy");
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
//obj.setDisplayName(msgs.TAB_PREFIX());
obj.setDisplayName("§8§l♣ §2updates");
Score empty = obj.getScore(" ");
empty.setScore(13);
Score generalSpace = obj.getScore("§8§l");
generalSpace.setScore(size);
size--;
//Score coinsMsg = obj.getScore(msgs.LobbyBoard_COINS());
//coinsMsg.setScore(12);
Score generalHead = obj.getScore("§7§l✸ §aAllgemeines");
generalHead.setScore(size);
size--;
//Score coins = obj.getScore("§7" + p.getDatabasePlayer().getCoins());
//coins.setScore(11);
for(String news : general) {
Score score = obj.getScore(news);
score.setScore(size);
size--;
}
Score empty1 = obj.getScore(" ");
empty1.setScore(10);
Score devSpace = obj.getScore("§5§l");
devSpace.setScore(size);
size--;
Score empty2 = obj.getScore(" ");
empty2.setScore(7);
Score devHead = obj.getScore("§7§l⚡ §aEntwicklung");
devHead.setScore(size);
size--;
//Score forumMsg = obj.getScore(msgs.LobbyBoard_FORUM());
//forumMsg.setScore(6);
for(String news : dev) {
Score score = obj.getScore(news);
score.setScore(size);
size--;
}
Score forum = obj.getScore("§7forum.univento.eu");
forum.setScore(5);
Score buildSpace = obj.getScore("§3§l");
buildSpace.setScore(size);
size--;
Score empty3 = obj.getScore(" ");
empty3.setScore(4);
Score buildHead = obj.getScore("§7§l⚒ §aBuilding");
buildHead.setScore(size);
size--;
//Score tsMsg = obj.getScore(msgs.LobbyBoard_TS());
//tsMsg.setScore(3);
for(String news : build) {
Score score = obj.getScore(news);
score.setScore(size);
size--;
}
Score ts = obj.getScore("§7ts.univento.eu");
ts.setScore(2);
Score teamSpace = obj.getScore("§6§l");
teamSpace.setScore(size);
size--;
Score empty4 = obj.getScore(" ");
empty4.setScore(1);
Score teamHead = obj.getScore("§7§l☯ §aTeam");
teamHead.setScore(size);
size--;
for(String news : team) {
Score score = obj.getScore(news);
score.setScore(size);
size--;
}
}
}, 2 * 20L);
Score end = obj.getScore(" §8-*-");
end.setScore(0);
}
}