first commit
This commit is contained in:
commit
33de068972
8
.classpath
Normal file
8
.classpath
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="lib" path="F:/DevServer/Spigot/spigot.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Core"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/bin/
|
17
.project
Normal file
17
.project
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Lobby</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
2
.settings/org.eclipse.core.resources.prefs
Normal file
2
.settings/org.eclipse.core.resources.prefs
Normal file
@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/eu/univento/lobby/utils/StatusSignUtil.java=UTF-8
|
11
.settings/org.eclipse.jdt.core.prefs
Normal file
11
.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
124
src/eu/univento/lobby/Lobby.java
Normal file
124
src/eu/univento/lobby/Lobby.java
Normal file
@ -0,0 +1,124 @@
|
||||
package eu.univento.lobby;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import eu.univento.core.api.Messages;
|
||||
import eu.univento.core.api.Settings;
|
||||
import eu.univento.lobby.commands.SetNPC;
|
||||
import eu.univento.lobby.commands.Setloc;
|
||||
import eu.univento.lobby.commands.StatusSign;
|
||||
import eu.univento.lobby.listeners.Events;
|
||||
import eu.univento.lobby.listeners.ItemEvents;
|
||||
import eu.univento.lobby.listeners.JoinQuit;
|
||||
import eu.univento.lobby.listeners.Jumppads;
|
||||
import eu.univento.lobby.listeners.Menu;
|
||||
import eu.univento.lobby.listeners.PlayerHider;
|
||||
import eu.univento.lobby.listeners.StatusSigns;
|
||||
import eu.univento.lobby.listeners.Teleport;
|
||||
import eu.univento.lobby.utils.StatusSignUtil;
|
||||
|
||||
/**
|
||||
* main class...
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Lobby extends JavaPlugin{
|
||||
|
||||
/**
|
||||
* list of StatusSigns
|
||||
*/
|
||||
private static ArrayList<StatusSignUtil> signs = new ArrayList<StatusSignUtil>();
|
||||
/**
|
||||
* @return list of StatusSigns
|
||||
*/
|
||||
public static ArrayList<StatusSignUtil> returnSigns() {
|
||||
return signs;
|
||||
}
|
||||
|
||||
/**
|
||||
* opened Inventorys
|
||||
*/
|
||||
private static ArrayList<Player> openInventorys = new ArrayList<Player>();
|
||||
/**
|
||||
* @return list of players that have a inventory open
|
||||
*/
|
||||
public static ArrayList<Player> getOpenInventorys() {
|
||||
return openInventorys;
|
||||
}
|
||||
|
||||
/**
|
||||
* plugin instance
|
||||
*/
|
||||
public static Lobby instance;
|
||||
/**
|
||||
* @return instance of plugin
|
||||
*/
|
||||
public static Lobby getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logger to log to
|
||||
*/
|
||||
private static Logger log = Bukkit.getLogger();
|
||||
|
||||
/**
|
||||
* Prefix for messages
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param level Log level
|
||||
* @param string String
|
||||
*/
|
||||
public static void log(Level level, String string) {
|
||||
log.log(level, "[" + Messages.CONSOLE_PREFIX + Lobby.getInstance().getDescription().getName() + "] " + string);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
PluginManager pm = Bukkit.getPluginManager();
|
||||
pm.registerEvents(new Jumppads(), this);
|
||||
pm.registerEvents(new JoinQuit(), this);
|
||||
pm.registerEvents(new Teleport(), this);
|
||||
pm.registerEvents(new Events(), this);
|
||||
pm.registerEvents(new Menu(), this);
|
||||
pm.registerEvents(new PlayerHider(), this);
|
||||
pm.registerEvents(new StatusSigns(), this);
|
||||
pm.registerEvents(new ItemEvents(), this);
|
||||
if(Settings.isDebug()) log.log(Level.INFO, "Events registriert");
|
||||
|
||||
String[] setloc = {""};
|
||||
new Setloc(this, "setloc", "Setzt Teleport Punkte", setloc);
|
||||
|
||||
String[] statussign = {""};
|
||||
new StatusSign(this, "statussign", "Setzt Server Status Schilder", statussign);
|
||||
|
||||
String[] setnpc = {""};
|
||||
new SetNPC(this, "setnpc", "Setzt NPC für Server Auswahl", setnpc);
|
||||
|
||||
if(Settings.isDebug()) log.log(Level.INFO, "Befehle registriert");
|
||||
|
||||
for(World w : Bukkit.getWorlds()) {
|
||||
w.setDifficulty(Difficulty.PEACEFUL);
|
||||
}
|
||||
|
||||
log.log(Level.INFO, " Plugin ver." + getDescription().getVersion() + " gestartet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
log.log(Level.INFO, "[Lobby] Plugin beendet");
|
||||
}
|
||||
|
||||
}
|
118
src/eu/univento/lobby/commands/SetNPC.java
Normal file
118
src/eu/univento/lobby/commands/SetNPC.java
Normal file
@ -0,0 +1,118 @@
|
||||
package eu.univento.lobby.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.CustomPlayer;
|
||||
import eu.univento.core.api.Messages;
|
||||
import eu.univento.core.api.NPC;
|
||||
import eu.univento.core.api.Perms.Ranks;
|
||||
import eu.univento.lobby.Lobby;
|
||||
|
||||
/**
|
||||
* spawns NPCs
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SetNPC extends AutoCommand<Lobby>{
|
||||
|
||||
/**
|
||||
* configuration file
|
||||
*/
|
||||
static File file = new File("plugins/Lobby", "NPCs.yml");
|
||||
/**
|
||||
* configuration
|
||||
*/
|
||||
static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
/**
|
||||
* @param plugin main class
|
||||
* @param command command to execute
|
||||
* @param description describes the command
|
||||
* @param aliases aliases of command
|
||||
*/
|
||||
public SetNPC(Lobby 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());
|
||||
if(p.isAllowed(Ranks.Admin)) {
|
||||
if (args.length == 1) {
|
||||
cfg.set(args[0] + ".World", p.getWorld().getName());
|
||||
cfg.set(args[0] + ".X", Double.valueOf(p.getLocation().getX()));
|
||||
cfg.set(args[0] + ".Y", Double.valueOf(p.getLocation().getY()));
|
||||
cfg.set(args[0] + ".Z", Double.valueOf(p.getLocation().getY()));
|
||||
|
||||
try {
|
||||
cfg.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
spawnNPC(args[0], p.getLocation());
|
||||
}
|
||||
p.sendMessage("§cNutze /setnpc <Name>");
|
||||
}else {
|
||||
sender.sendMessage(Messages.NO_PERMS);
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Messages.NOT_A_PLAYER);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name name of npc
|
||||
* @param loc location to spawn
|
||||
*/
|
||||
static void spawnNPC(String name, Location loc) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Lobby.getInstance(), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
NPC npc = new NPC(name, loc, true);
|
||||
npc.setItemInHand(Material.IRON_SWORD);
|
||||
npc.spawn();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param what name of the npc
|
||||
*/
|
||||
public static void startNPCs(String what) {
|
||||
String world = cfg.getString(what + ".World");
|
||||
double x = cfg.getDouble(what + ".X");
|
||||
double y = cfg.getDouble(what + ".Y");
|
||||
double z = cfg.getDouble(what + ".Z");
|
||||
|
||||
World w = Bukkit.getWorld(world);
|
||||
|
||||
Location loc = new Location(w, x, y, z);
|
||||
Chunk chunk = loc.getChunk();
|
||||
chunk.load();
|
||||
spawnNPC(what, loc);
|
||||
}
|
||||
|
||||
}
|
58
src/eu/univento/lobby/commands/Setloc.java
Normal file
58
src/eu/univento/lobby/commands/Setloc.java
Normal file
@ -0,0 +1,58 @@
|
||||
package eu.univento.lobby.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.CustomPlayer;
|
||||
import eu.univento.core.api.Messages;
|
||||
import eu.univento.core.api.Perms.Ranks;
|
||||
import eu.univento.lobby.Lobby;
|
||||
|
||||
/**
|
||||
* sets teleport locations
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Setloc extends AutoCommand<Lobby>{
|
||||
|
||||
/**
|
||||
* @param plugin main class
|
||||
* @param command command to execute
|
||||
* @param description describes the command
|
||||
* @param aliases aliases of command
|
||||
*/
|
||||
public Setloc(Lobby 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());
|
||||
if(p.isAllowed(Ranks.Admin)) {
|
||||
if(args.length == 1) {
|
||||
Config.write("Lobby.Locs." + args[0], p.getLocation());
|
||||
p.sendMessage("§aLocation gesetzt");
|
||||
System.out.println("Location gesetzt " + args[0]);
|
||||
}else {
|
||||
p.sendMessage("§6Nutze /setloc <Spielmodus>");
|
||||
}
|
||||
}else {
|
||||
p.sendMessage(Messages.NO_PERMS);
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Messages.NOT_A_PLAYER);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
83
src/eu/univento/lobby/commands/StatusSign.java
Normal file
83
src/eu/univento/lobby/commands/StatusSign.java
Normal file
@ -0,0 +1,83 @@
|
||||
package eu.univento.lobby.commands;
|
||||
|
||||
import eu.univento.core.api.AutoCommand;
|
||||
import eu.univento.core.api.CustomPlayer;
|
||||
import eu.univento.core.api.Messages;
|
||||
import eu.univento.core.api.Servers;
|
||||
import eu.univento.core.api.Perms.Ranks;
|
||||
import eu.univento.lobby.Lobby;
|
||||
import eu.univento.lobby.utils.StatusSignUtil;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* sets status signs
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class StatusSign extends AutoCommand<Lobby> {
|
||||
|
||||
/**
|
||||
* @param plugin main class
|
||||
* @param command command to execute
|
||||
* @param description describes the command
|
||||
* @param aliases aliases of command
|
||||
*/
|
||||
public StatusSign(Lobby 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());
|
||||
if (p.isAllowed(Ranks.Admin)) {
|
||||
if (args.length < 1) {
|
||||
p.sendMessage("§4/statussign <Servername>");
|
||||
return true;
|
||||
}
|
||||
String ip = Servers.getServerIP(args[0]);
|
||||
|
||||
int port = Servers.getServerPort(args[1]);
|
||||
|
||||
String name = args[0];
|
||||
|
||||
HashSet<Byte> hash = new HashSet<Byte>();
|
||||
Block block = p.getTargetBlock(hash, 10);
|
||||
if (block == null) {
|
||||
p.sendMessage("§4Da ist ja gar kein Block :|:");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((block.getType() != Material.SIGN) && (block.getType() != Material.SIGN_POST) && (block.getType() != Material.WALL_SIGN)) {
|
||||
p.sendMessage("§4Du musst schon auf ein Schild schauen");
|
||||
return true;
|
||||
}
|
||||
|
||||
StatusSignUtil statusSign = new StatusSignUtil(block.getLocation(), name, ip, port);
|
||||
|
||||
p.sendMessage("§aDu hast erfolgreich ein Status Schild erstellt");
|
||||
|
||||
Lobby.returnSigns().add(statusSign);
|
||||
StatusSignUtil.save(statusSign);
|
||||
}
|
||||
p.sendMessage(Messages.NO_PERMS);
|
||||
} else {
|
||||
sender.sendMessage(Messages.NOT_A_PLAYER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String label, String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
118
src/eu/univento/lobby/listeners/Events.java
Normal file
118
src/eu/univento/lobby/listeners/Events.java
Normal file
@ -0,0 +1,118 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
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.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.InventoryCreativeEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import eu.univento.core.api.CustomPlayer;
|
||||
|
||||
/**
|
||||
* some short events
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Events implements Listener{
|
||||
|
||||
/**
|
||||
* cancels food level changes
|
||||
* @param e FoodLevelChangeEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels weather changes
|
||||
* @param e WeatherChangeEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onWeather(WeatherChangeEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels item consume
|
||||
* @param e PlayerItemConsumeEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onConsume(PlayerItemConsumeEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels death message and drops
|
||||
* @param e PlayerDeathEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
e.setDeathMessage(null);
|
||||
e.setKeepInventory(true);
|
||||
e.setKeepLevel(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets respawn location
|
||||
* @param e PlayerRespawnEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onRespawn(PlayerRespawnEvent e) {
|
||||
e.setRespawnLocation(Bukkit.getWorld("world").getSpawnLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels inventory dropping in creative
|
||||
* @param e InventoryCreativeEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onCreative(InventoryCreativeEvent e) {
|
||||
e.setCancelled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels item pickup
|
||||
* @param e PlayerPickupEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPickup(PlayerPickupItemEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels item drop
|
||||
* @param e PlayerDropItemEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onDrop(PlayerDropItemEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* some fun with player hitting
|
||||
* @param e EntityDamageByEntityEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onHit(EntityDamageByEntityEvent e) {
|
||||
if(e.getEntity() instanceof Player) {
|
||||
if(e.getDamager() instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getEntity().getName());
|
||||
CustomPlayer d = CustomPlayer.getPlayer(e.getDamager().getName());
|
||||
d.setHealthScale(0.5D);
|
||||
p.setMaxHealth(60.0D);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 5000, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
53
src/eu/univento/lobby/listeners/ItemEvents.java
Normal file
53
src/eu/univento/lobby/listeners/ItemEvents.java
Normal file
@ -0,0 +1,53 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import eu.univento.core.api.CustomPlayer;
|
||||
import eu.univento.core.api.Messages;
|
||||
import eu.univento.core.api.Perms.Ranks;
|
||||
|
||||
/**
|
||||
* some item events
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ItemEvents implements Listener{
|
||||
|
||||
/**
|
||||
* @param e PlayerInteractEvent
|
||||
*/
|
||||
@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) {
|
||||
if(e.getItem().getType() == Material.NAME_TAG) {
|
||||
if(p.isAllowed(Ranks.Youtuber)) {
|
||||
if(p.isNicked()) {
|
||||
p.setNick(false);
|
||||
p.sendMessage(Messages.PREFIX + "§cDu hast nun keinen Nicknamen mehr");
|
||||
}else {
|
||||
p.setNick(true);
|
||||
p.sendMessage(Messages.PREFIX + "§aDu hast ab jetzt einen Nicknamen");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(e.getItem().getType() == Material.TNT) {
|
||||
if(p.isAllowed(Ranks.Youtuber)) {
|
||||
if(Bukkit.getServerName() == "SilentLobby") {
|
||||
p.connectToServer("Lobby01");
|
||||
}else {
|
||||
p.connectToServer("SilentLobby");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(e.getItem().getType() == Material.EYE_OF_ENDER) {
|
||||
//TODO: add forcefield
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
64
src/eu/univento/lobby/listeners/JoinQuit.java
Normal file
64
src/eu/univento/lobby/listeners/JoinQuit.java
Normal file
@ -0,0 +1,64 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import eu.univento.core.api.CustomPlayer;
|
||||
import eu.univento.core.api.Title;
|
||||
import eu.univento.lobby.utils.Inventorys;
|
||||
|
||||
/**
|
||||
* some join / quit events
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class JoinQuit implements Listener{
|
||||
|
||||
/**
|
||||
* handles player joining
|
||||
* @param e PlayerJoinEvent
|
||||
* @throws ClassNotFoundException Class could not be found
|
||||
* @throws SQLException SQL server is not available or throws error
|
||||
*/
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) throws ClassNotFoundException, SQLException {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
|
||||
//NPC.injectNetty(p.getPLAYER());
|
||||
|
||||
p.setGameMode(GameMode.ADVENTURE);
|
||||
p.setFoodLevel(10);
|
||||
p.setMaxHealth(10.0D);
|
||||
p.setHealth(1.0D);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 2));
|
||||
p.teleport(Bukkit.getWorld("world").getSpawnLocation());
|
||||
for(int i = 0; i <= 100; i++) {
|
||||
p.sendMessage(" ");
|
||||
}
|
||||
p.sendMessage("§6Willkommen auf §3univento.eu");
|
||||
Title.sendTitle(p, 10, 50, 10, "§3univento.eu", "§6Das Netzwerk mit Style");
|
||||
Title.sendTabTitle(p, "§6" + Bukkit.getServerName(), "§3univento.eu");
|
||||
|
||||
Inventorys.openMainInventory(p);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* removes player from lists
|
||||
* @param e PlayerQuitEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
|
||||
p.getInventory().clear();
|
||||
//NPC.ejectNetty(p.getPLAYER());
|
||||
}
|
||||
|
||||
}
|
166
src/eu/univento/lobby/listeners/Jumppads.java
Normal file
166
src/eu/univento/lobby/listeners/Jumppads.java
Normal file
@ -0,0 +1,166 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.CustomPlayer;
|
||||
import eu.univento.core.api.Messages;
|
||||
import eu.univento.core.api.Perms.Ranks;
|
||||
import eu.univento.lobby.Lobby;
|
||||
|
||||
/**
|
||||
* fun for player
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Jumppads implements Listener{
|
||||
|
||||
/**
|
||||
* contains players flying from premium lobby
|
||||
*/
|
||||
private ArrayList<CustomPlayer> fly = new ArrayList<CustomPlayer>();
|
||||
|
||||
/**
|
||||
* lets players jump over pads
|
||||
* @param e PlayerMoveEvent
|
||||
* @throws InterruptedException thread closed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent e) throws InterruptedException {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
|
||||
|
||||
if(p.getLocation().getBlock().getType() == Material.STONE_PLATE) {
|
||||
|
||||
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.REDSTONE_BLOCK) {
|
||||
Vector v = p.getLocation().getDirection().multiply(3D).setY(1D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.BEDROCK) {
|
||||
Vector v = p.getLocation().getDirection().multiply(0D).setY(3D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.IRON_BLOCK) {
|
||||
Vector v = p.getLocation().getDirection().multiply(3D).setY(4D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.DIAMOND_BLOCK) {
|
||||
if(p.isAllowed(Ranks.Premium)) {
|
||||
Vector v = p.getLocation().getDirection().multiply(6D).setY(3D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
|
||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(Lobby.getInstance(), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
p.teleport(Config.readLocation("Lobby.Locs.PremiumHub"));
|
||||
}
|
||||
|
||||
}, 60L);
|
||||
}else {
|
||||
p.sendMessage(Messages.readString("Messages.Commands.NoPerms"));
|
||||
}
|
||||
}
|
||||
|
||||
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.OBSIDIAN) {
|
||||
Vector v = p.getLocation().getDirection().multiply(3D).setY(1D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.LAPIS_BLOCK) {
|
||||
Vector v = p.getLocation().getDirection().multiply(6D).setY(1D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.LEVEL_UP, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.EMERALD_BLOCK) {
|
||||
if(!fly.contains(p)) {
|
||||
Vector v = p.getLocation().getDirection().multiply(10.0D).setY(10.0D);
|
||||
p.setVelocity(v);
|
||||
fly.add(p);
|
||||
p.setHealth(1.0);
|
||||
p.setFoodLevel(20);
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
players.playSound(p.getEyeLocation(), Sound.EXPLODE, 5.0F, 1.0F);
|
||||
players.playEffect(p.getEyeLocation(), Effect.EXPLOSION_HUGE, 20);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.STATIONARY_WATER) {
|
||||
if(fly.contains(p)) {
|
||||
fly.remove(p);
|
||||
p.teleport(Bukkit.getWorld("world").getSpawnLocation());
|
||||
p.playSound(p.getEyeLocation(), Sound.ENDERMAN_TELEPORT, 5.0F, 1.0F);
|
||||
p.playEffect(p.getLocation(), Effect.ENDER_SIGNAL, 20);
|
||||
p.playEffect(p.getEyeLocation(), Effect.HEART, 20);
|
||||
p.setHealth(10.0);
|
||||
p.setFoodLevel(10);
|
||||
}
|
||||
}
|
||||
if(p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.SPONGE) {
|
||||
Vector v = p.getLocation().getDirection().multiply(0.0D).setY(1.0D);
|
||||
Block b = p.getLocation().subtract(0.0D, 1.0D, 0.0D).getBlock();
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.SPLASH, 5.0F, 1.0F);
|
||||
p.playEffect(p.getEyeLocation(), Effect.SPLASH, 200);
|
||||
Block block = p.getLocation().add(0.0D, 5.0D, 0.0D).getBlock();
|
||||
block.setType(Material.WATER);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Lobby.getInstance(), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
block.setType(Material.AIR);
|
||||
|
||||
}
|
||||
|
||||
}, 20L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Lobby.getInstance(), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
b.setType(Material.SPONGE);
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
players.playSound(b.getLocation(), Sound.PISTON_EXTEND, 1.0F, 1.0F);
|
||||
players.playEffect(b.getLocation(), Effect.LARGE_SMOKE, 10);
|
||||
}
|
||||
}
|
||||
|
||||
}, 60L);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* cancels fall damage
|
||||
* @param e EntityDamageEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onDamage(EntityDamageEvent e) {
|
||||
if(e.getEntity() instanceof Player) {
|
||||
if(e.getCause() == DamageCause.FALL) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
91
src/eu/univento/lobby/listeners/Menu.java
Normal file
91
src/eu/univento/lobby/listeners/Menu.java
Normal file
@ -0,0 +1,91 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
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.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import eu.univento.lobby.Lobby;
|
||||
|
||||
/**
|
||||
* opens menus
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Menu implements Listener{
|
||||
|
||||
/**
|
||||
* opens and creates menus
|
||||
* @param e PlayerInteractEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_AIR) {
|
||||
if(!Lobby.getOpenInventorys().contains(e.getPlayer())) {
|
||||
if(e.getItem().getType() == Material.COMPASS) {
|
||||
Inventory inv = Bukkit.createInventory(e.getPlayer(), 45, "§6Server-Menü");
|
||||
|
||||
ItemStack spawn = new ItemStack(Material.MAGMA_CREAM);
|
||||
ItemMeta spawnMeta = spawn.getItemMeta();
|
||||
spawnMeta.setDisplayName("§6Spawn");
|
||||
spawn.setItemMeta(spawnMeta);
|
||||
|
||||
ItemStack theblock = new ItemStack(Material.GOLD_BLOCK);
|
||||
ItemMeta theblockMeta = theblock.getItemMeta();
|
||||
theblockMeta.setDisplayName("§6TheBlock");
|
||||
theblock.setItemMeta(theblockMeta);
|
||||
|
||||
ItemStack flagattack = new ItemStack(Material.SNOW_BALL);
|
||||
ItemMeta flagattackMeta = flagattack.getItemMeta();
|
||||
flagattackMeta.setDisplayName("§6FlagAttack");
|
||||
flagattack.setItemMeta(flagattackMeta);
|
||||
|
||||
ItemStack trashgames = new ItemStack(Material.LEATHER_HELMET);
|
||||
ItemMeta trashgamesMeta = trashgames.getItemMeta();
|
||||
trashgamesMeta.setDisplayName("§6TrashGames");
|
||||
trashgames.setItemMeta(trashgamesMeta);
|
||||
|
||||
ItemStack settings = new ItemStack(Material.NAME_TAG);
|
||||
ItemMeta settingsMeta = settings.getItemMeta();
|
||||
settingsMeta.setDisplayName("§3Einstellungen");
|
||||
settings.setItemMeta(settingsMeta);
|
||||
|
||||
ItemStack filler = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short)15);
|
||||
ItemMeta fillerMeta = filler.getItemMeta();
|
||||
fillerMeta.setDisplayName("§0Nichts");
|
||||
filler.setItemMeta(fillerMeta);
|
||||
|
||||
inv.setItem(22, spawn);
|
||||
inv.setItem(4, theblock);
|
||||
inv.setItem(26, flagattack);
|
||||
inv.setItem(18, trashgames);
|
||||
inv.setItem(44, settings);
|
||||
|
||||
for(int i = 0; i <= 44; i++) {
|
||||
if(inv.getItem(i) == null) {
|
||||
inv.setItem(i, filler);
|
||||
}
|
||||
}
|
||||
|
||||
e.getPlayer().openInventory(inv);
|
||||
}
|
||||
|
||||
if(e.getItem().getType() == Material.CHEST) {
|
||||
Inventory inv = Bukkit.createInventory(e.getPlayer(), 45, "§6Fun-Chest");
|
||||
|
||||
|
||||
|
||||
e.getPlayer().openInventory(inv);
|
||||
e.getPlayer().playSound(e.getPlayer().getEyeLocation(), Sound.CHEST_OPEN, 10.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
127
src/eu/univento/lobby/listeners/PlayerHider.java
Normal file
127
src/eu/univento/lobby/listeners/PlayerHider.java
Normal file
@ -0,0 +1,127 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
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.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import eu.univento.core.api.CustomPlayer;
|
||||
import eu.univento.core.api.Perms.Ranks;
|
||||
|
||||
/**
|
||||
* lets players show/hide other players
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class PlayerHider implements Listener{
|
||||
|
||||
/**
|
||||
* contains all player witch hide other players from their view
|
||||
*/
|
||||
private ArrayList<CustomPlayer> hidden = new ArrayList<CustomPlayer>();
|
||||
|
||||
/**
|
||||
* item to hide
|
||||
* @return ItemStack
|
||||
*/
|
||||
private ItemStack getHide() {
|
||||
ItemStack hide = new ItemStack(Material.BLAZE_ROD);
|
||||
ItemMeta hideMeta = hide.getItemMeta();
|
||||
hideMeta.setDisplayName("§cSpieler verstecken");
|
||||
hide.setItemMeta(hideMeta);
|
||||
|
||||
return hide;
|
||||
}
|
||||
|
||||
/**
|
||||
* item to show
|
||||
* @return ItemStack
|
||||
*/
|
||||
private ItemStack getShow() {
|
||||
ItemStack show = new ItemStack(Material.STICK);
|
||||
ItemMeta showMeta = show.getItemMeta();
|
||||
showMeta.setDisplayName("§aSpieler anzeigen");
|
||||
show.setItemMeta(showMeta);
|
||||
|
||||
return show;
|
||||
}
|
||||
|
||||
/**
|
||||
* player interacts with item
|
||||
* @param e PlayerInteractEvent
|
||||
* @throws InterruptedException threads closed
|
||||
*/
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) throws InterruptedException {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
|
||||
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if(e.getItem().getType() == Material.STICK) {
|
||||
hidden.remove(p);
|
||||
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
p.showPlayer(players);
|
||||
}
|
||||
p.sendMessage("§aDu kannst nun alle Spieler sehen");
|
||||
|
||||
p.getInventory().remove(getShow());
|
||||
p.getInventory().addItem(getHide());
|
||||
|
||||
p.playSound(p.getEyeLocation(), Sound.ZOMBIE_WOODBREAK, 10.0F, 1.0F);
|
||||
}
|
||||
if(e.getItem().getType() == Material.BLAZE_ROD) {
|
||||
hidden.add(p);
|
||||
|
||||
for(Player players : Bukkit.getOnlinePlayers()) {
|
||||
if(!p.isAllowed(Ranks.Supporter)) {
|
||||
p.hidePlayer(players);
|
||||
}
|
||||
}
|
||||
p.sendMessage("§cDu kannst keine Spieler mehr sehen");
|
||||
|
||||
p.getInventory().remove(getHide());
|
||||
p.getInventory().addItem(getShow());
|
||||
|
||||
p.playSound(p.getEyeLocation(), Sound.ZOMBIE_WOODBREAK, 10.0F, 1.0F);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* hides player to other players
|
||||
* @param e PlayerJoinEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
|
||||
if(!p.isAllowed(Ranks.Supporter)) {
|
||||
for(CustomPlayer players : hidden) {
|
||||
players.hidePlayer(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* removes players from lists
|
||||
* @param e PlayerQuitEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName());
|
||||
if(hidden.contains(p)) {
|
||||
hidden.remove(p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
38
src/eu/univento/lobby/listeners/StatusSigns.java
Normal file
38
src/eu/univento/lobby/listeners/StatusSigns.java
Normal file
@ -0,0 +1,38 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import eu.univento.core.api.Servers;
|
||||
import eu.univento.lobby.Lobby;
|
||||
import eu.univento.lobby.utils.StatusSignUtil;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
/**
|
||||
* handles status sign clicking
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class StatusSigns implements Listener{
|
||||
|
||||
/**
|
||||
* clicking status signs
|
||||
* @param e PlayerInteractEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent e)
|
||||
{
|
||||
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||
|
||||
Block block = e.getClickedBlock();
|
||||
|
||||
if ((block.getType() != Material.SIGN) && (block.getType() != Material.SIGN_POST) && (block.getType() != Material.WALL_SIGN)) return;
|
||||
|
||||
for (StatusSignUtil s : Lobby.returnSigns())
|
||||
if (s.getLocation().equals(block.getLocation()))
|
||||
Servers.connectServer(e.getPlayer(), s.getName());
|
||||
}
|
||||
}
|
82
src/eu/univento/lobby/listeners/Teleport.java
Normal file
82
src/eu/univento/lobby/listeners/Teleport.java
Normal file
@ -0,0 +1,82 @@
|
||||
package eu.univento.lobby.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
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.SlotType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import eu.univento.core.api.Config;
|
||||
import eu.univento.core.api.CustomPlayer;
|
||||
import eu.univento.lobby.Lobby;
|
||||
|
||||
/**
|
||||
* handles teleport menus
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Teleport implements Listener {
|
||||
|
||||
/**
|
||||
* clicking items
|
||||
* @param e InventoryClickEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
if (e.getWhoClicked() instanceof Player) {
|
||||
CustomPlayer p = CustomPlayer.getPlayer(e.getWhoClicked().getName());
|
||||
if(e.getInventory().getName() == "§6Server-Menü") {
|
||||
if(!e.getSlotType().equals(SlotType.OUTSIDE)) {
|
||||
if(e.getCurrentItem().getType() == Material.GOLD_BLOCK) {
|
||||
teleport(p, "TheBlock");
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getCurrentItem().getType() == Material.SNOW_BALL) {
|
||||
teleport(p, "FlagAttack");
|
||||
p.closeInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* teleports player with effects to location
|
||||
* @param p CustomPlayer
|
||||
* @param location String
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private void teleport(CustomPlayer p, String location) {
|
||||
Vector v = p.getLocation().getDirection().multiply(0D).setY(4D);
|
||||
p.setVelocity(v);
|
||||
p.playSound(p.getEyeLocation(), Sound.EXPLODE, 5.0F, 1.0F);
|
||||
p.playEffect(p.getEyeLocation(), Effect.EXPLOSION_HUGE, 20);
|
||||
Location loc = Config.readLocation("Lobby.Locs." + location);
|
||||
Lobby.getOpenInventorys().add(p);
|
||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(Lobby.getInstance(), new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player players : Bukkit.getOnlinePlayers()) {
|
||||
players.playSound(p.getEyeLocation(), Sound.EXPLODE, 5.0F, 1.0F);
|
||||
players.playEffect(p.getEyeLocation(), Effect.EXPLOSION_HUGE, 20);
|
||||
}
|
||||
p.teleport(loc);
|
||||
for (Player players : Bukkit.getOnlinePlayers()) {
|
||||
players.playSound(p.getEyeLocation(), Sound.EXPLODE, 5.0F, 1.0F);
|
||||
players.playEffect(p.getEyeLocation(), Effect.EXPLOSION_HUGE, 20);
|
||||
}
|
||||
Lobby.getOpenInventorys().remove(p);
|
||||
|
||||
}
|
||||
|
||||
}, 80L);
|
||||
}
|
||||
|
||||
}
|
240
src/eu/univento/lobby/utils/Inventorys.java
Normal file
240
src/eu/univento/lobby/utils/Inventorys.java
Normal file
@ -0,0 +1,240 @@
|
||||
package eu.univento.lobby.utils;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import eu.univento.core.Core;
|
||||
import eu.univento.core.api.CustomPlayer;
|
||||
import eu.univento.core.api.MySQL;
|
||||
import eu.univento.core.api.ServerPinger;
|
||||
import eu.univento.core.api.Perms.Ranks;
|
||||
import eu.univento.lobby.Lobby;
|
||||
|
||||
/**
|
||||
* opens inventorys for players
|
||||
* @author joethei
|
||||
* @version 1.0
|
||||
*/
|
||||
public class Inventorys {
|
||||
|
||||
/**
|
||||
* opens inventory with servers of gamemode
|
||||
* @param p CustomPlayer
|
||||
* @param name name of gamemodes
|
||||
* @param lines lines of servers
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void getGameServers(CustomPlayer p, String name, int lines) {
|
||||
Inventory inv = Bukkit.createInventory(p, lines * 9, "§6" + name);
|
||||
p.openInventory(inv);
|
||||
|
||||
for (int i = 0; i < lines * 9; i++) {
|
||||
inv.setItem(i, getServer(name + (i + 1) + ".univento.eu", name + " " + (i + 1)));
|
||||
p.playSound(p.getEyeLocation(), Sound.CHICKEN_EGG_POP, 1.0F, 1.0F);
|
||||
p.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gets item for single server
|
||||
* @param ip ip of server
|
||||
* @param name name of server
|
||||
* @return ItemStack
|
||||
*/
|
||||
public static ItemStack getServer(String ip, String name) {
|
||||
ServerPinger server = new ServerPinger(ip, 25565);
|
||||
if ((server.parseData(ServerPinger.Connection.ONLINE_PLAYERS) == null) && (server.parseData(ServerPinger.Connection.MAX_PLAYERS) == null)) {
|
||||
ItemStack item = new ItemStack(Material.NETHER_BRICK_ITEM);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.AQUA + name);
|
||||
itemMeta.setLore(Arrays.asList(new String[] { "§8Offline", "§7--§e/§7--" }));
|
||||
item.setItemMeta(itemMeta);
|
||||
return item;
|
||||
}
|
||||
if (server.parseData(ServerPinger.Connection.ONLINE_PLAYERS) == server.parseData(ServerPinger.Connection.MAX_PLAYERS)) {
|
||||
ItemStack item = new ItemStack(Material.CLAY_BRICK);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.AQUA + name);
|
||||
itemMeta.setLore(Arrays.asList(new String[] { "§4Voll", "§7" + server.parseData(ServerPinger.Connection.ONLINE_PLAYERS) + "§e/§7" + server.parseData(ServerPinger.Connection.MAX_PLAYERS) }));
|
||||
item.setItemMeta(itemMeta);
|
||||
return item;
|
||||
}
|
||||
if (server.parseData(ServerPinger.Connection.ONLINE_PLAYERS) != server.parseData(ServerPinger.Connection.MAX_PLAYERS)) {
|
||||
ItemStack item = new ItemStack(Material.GOLD_INGOT);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.AQUA + name);
|
||||
itemMeta.setLore(Arrays.asList(new String[] { "§aOnline", "§7" + server.parseData(ServerPinger.Connection.ONLINE_PLAYERS) + "§e/§7" + server.parseData(ServerPinger.Connection.MAX_PLAYERS) }));
|
||||
item.setItemMeta(itemMeta);
|
||||
return item;
|
||||
}
|
||||
if (server.parseData(ServerPinger.Connection.ONLINE_PLAYERS) == null) {
|
||||
ItemStack item = new ItemStack(Material.NETHER_BRICK_ITEM);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.AQUA + name);
|
||||
itemMeta.setLore(Arrays.asList(new String[] { "§8Offline", "§7--§e/§7--" }));
|
||||
item.setItemMeta(itemMeta);
|
||||
return item;
|
||||
}
|
||||
ItemStack item = new ItemStack(Material.NETHER_BRICK_ITEM);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.AQUA + name);
|
||||
itemMeta.setLore(Arrays.asList(new String[] { "§8Offline", "§7--§e/§7--" }));
|
||||
item.setItemMeta(itemMeta);
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* open main inventory for player
|
||||
* @param p CustomPlayer
|
||||
* @throws ClassNotFoundException class could not be found
|
||||
* @throws SQLException SQL Server not available or throwing error
|
||||
*/
|
||||
public static void openMainInventory(CustomPlayer p) throws ClassNotFoundException, SQLException {
|
||||
Inventory inv = p.getInventory();
|
||||
|
||||
ItemStack nav = new ItemStack(Material.COMPASS);
|
||||
ItemMeta navMeta = nav.getItemMeta();
|
||||
navMeta.setDisplayName("§eNavigator");
|
||||
nav.setItemMeta(navMeta);
|
||||
|
||||
ItemStack hide = new ItemStack(Material.BLAZE_ROD);
|
||||
ItemMeta hideMeta = hide.getItemMeta();
|
||||
hideMeta.setDisplayName("§cSpieler verstecken");
|
||||
hide.setItemMeta(hideMeta);
|
||||
|
||||
ItemStack nick = new ItemStack(Material.NAME_TAG);
|
||||
ItemMeta nickMeta = nick.getItemMeta();
|
||||
nickMeta.setDisplayName("§5AutoNick");
|
||||
nick.setItemMeta(nickMeta);
|
||||
|
||||
ItemStack force = new ItemStack(Material.EYE_OF_ENDER);
|
||||
ItemMeta forceMeta = force.getItemMeta();
|
||||
forceMeta.setDisplayName("§aSchutzschild");
|
||||
force.setItemMeta(forceMeta);
|
||||
|
||||
ItemStack silent = new ItemStack(Material.TNT);
|
||||
ItemMeta silentMeta = silent.getItemMeta();
|
||||
silentMeta.setDisplayName("§cSilent-Lobby");
|
||||
silent.setItemMeta(silentMeta);
|
||||
|
||||
ItemStack fun = new ItemStack(Material.ENDER_CHEST);
|
||||
ItemMeta funMeta = fun.getItemMeta();
|
||||
funMeta.setDisplayName("§cF§aU§eN§3Chest");
|
||||
fun.setItemMeta(funMeta);
|
||||
|
||||
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
|
||||
SkullMeta meta = (SkullMeta) skull.getItemMeta();
|
||||
meta.setOwner(p.getName());
|
||||
meta.setDisplayName("§eDein Profil");
|
||||
skull.setItemMeta(meta);
|
||||
|
||||
timeItem(p, inv, 0, nav, Sound.CHICKEN_EGG_POP, 50L, false);
|
||||
timeItem(p, inv, 8, skull, Sound.CHICKEN_EGG_POP, 100L, false);
|
||||
timeItem(p, inv, 1, hide, Sound.CHICKEN_EGG_POP, 150L, false);
|
||||
timeItem(p, inv, 7, fun, Sound.CHICKEN_EGG_POP, 200L, false);
|
||||
if (p.isAllowed(Ranks.Youtuber)) {
|
||||
timeItem(p, inv, 3, nick, Sound.CHICKEN_EGG_POP, 250L, false);
|
||||
timeItem(p, inv, 5, force, Sound.CHICKEN_EGG_POP, 300L, false);
|
||||
timeItem(p, inv, 4, silent, Sound.CHICKEN_EGG_POP, 350L, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* returns if setting is set
|
||||
* @param p CustomPlayer
|
||||
* @param what what setting is set
|
||||
* @return boolean
|
||||
* @throws ClassNotFoundException class could not be found
|
||||
* @throws SQLException SQL Server not available or throwing error
|
||||
*/
|
||||
public static boolean isSet(CustomPlayer p, String what) throws SQLException, ClassNotFoundException {
|
||||
MySQL sql = Core.returnSQL();
|
||||
sql.openConnection();
|
||||
String uuid = p.getUniqueId().toString();
|
||||
ResultSet rs = Core.returnSQL().getConnection().createStatement().executeQuery("SELECT * FROM PlayerData WHERE player_uuid = '" + uuid + "';");
|
||||
if (rs.next()) {
|
||||
boolean is = rs.getInt(what) == 1;
|
||||
sql.closeConnection();
|
||||
return is;
|
||||
}
|
||||
sql.closeConnection();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets setting
|
||||
* @param p CustomPlayer
|
||||
* @param bool boolean to set to
|
||||
* @param what what to set
|
||||
* @throws ClassNotFoundException class could not be found
|
||||
* @throws SQLException SQL Server not available or throwing error
|
||||
*/
|
||||
public static void set(CustomPlayer p, boolean bool, String what) throws SQLException, ClassNotFoundException {
|
||||
MySQL sql = Core.returnSQL();
|
||||
sql.openConnection();
|
||||
String uuid = p.getUniqueId().toString();
|
||||
if (bool)
|
||||
Core.returnSQL().getConnection().createStatement().executeUpdate("UPDATE PlayerData SET " + what + " = '1' WHERE player_uuid = '" + uuid + "';");
|
||||
else
|
||||
Core.returnSQL().getConnection().createStatement().executeUpdate("UPDATE PlayerData SET " + what + " = '0' WHERE player_uuid = '" + uuid + "';");
|
||||
sql.closeConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* time item appearance of item
|
||||
* @param p CustomPlayer
|
||||
* @param inv inventory
|
||||
* @param slot Inventory slot
|
||||
* @param item ItemStack
|
||||
* @param sound Sound
|
||||
* @param time long
|
||||
* @param menu is menu ?
|
||||
* @throws ClassNotFoundException class could not be found
|
||||
* @throws SQLException SQL Server not available or throwing error
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void timeItem(CustomPlayer p, Inventory inv, int slot, ItemStack item, Sound sound, long time, boolean menu) throws ClassNotFoundException, SQLException {
|
||||
if (isSet(p, "FastMenu")) {
|
||||
addItem(p, inv, slot, item, null, menu);
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(Lobby.getInstance(), new Runnable() {
|
||||
public void run() {
|
||||
addItem(p, inv, slot, item, sound, menu);
|
||||
}
|
||||
}, time);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param p CustomPlayer
|
||||
* @param inv inventory
|
||||
* @param slot Inventory slot
|
||||
* @param item ItemStack
|
||||
* @param sound Sound
|
||||
* @param menu is menu ?
|
||||
*/
|
||||
private static void addItem(CustomPlayer p, Inventory inv, int slot, ItemStack item, Sound sound, boolean menu) {
|
||||
if (menu) {
|
||||
String name = inv.getTitle();
|
||||
if (p.getOpenInventory().getTitle().equals(name)) {
|
||||
inv.setItem(slot, item);
|
||||
p.playSound(p.getEyeLocation(), sound, 1.0F, 1.0F);
|
||||
}
|
||||
} else {
|
||||
inv.setItem(slot, item);
|
||||
p.playSound(p.getEyeLocation(), sound, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
109
src/eu/univento/lobby/utils/StatusSignUtil.java
Normal file
109
src/eu/univento/lobby/utils/StatusSignUtil.java
Normal file
@ -0,0 +1,109 @@
|
||||
package eu.univento.lobby.utils;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public class StatusSignUtil{
|
||||
|
||||
private Location location;
|
||||
private Sign sign;
|
||||
private String name;
|
||||
private String ip;
|
||||
private int port;
|
||||
|
||||
private static File file = new File("plugins/Lobby/signs.yml");
|
||||
private static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
public StatusSignUtil(Location location, String name, String ip, int port) {
|
||||
this.location = location;
|
||||
this.sign = ((Sign)location.getBlock().getState());
|
||||
this.name = name;
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getIP() {
|
||||
return this.ip;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return this.port;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
try {
|
||||
Socket socket = new Socket();
|
||||
socket.connect(new InetSocketAddress(this.ip, this.port), 1000);
|
||||
|
||||
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
|
||||
DataInputStream in = new DataInputStream(socket.getInputStream());
|
||||
|
||||
out.write(254);
|
||||
|
||||
StringBuilder str = new StringBuilder();
|
||||
int b;
|
||||
while ((b = in.read()) != -1)
|
||||
{
|
||||
if ((b != 1) && (b > 16) && (b != 255) && (b != 23) && (b != 24)) {
|
||||
str.append((char)b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String[] data = str.toString().split("§");
|
||||
String motd = data[0];
|
||||
int onlinePlayers = Integer.valueOf(data[1]).intValue();
|
||||
int maxPlayers = Integer.valueOf(data[2]).intValue();
|
||||
|
||||
socket.close();
|
||||
|
||||
this.sign.setLine(0, "§a[Beitreten]");
|
||||
this.sign.setLine(1, "§9" + this.name);
|
||||
this.sign.setLine(2, "§6" + motd);
|
||||
this.sign.setLine(3, "§1" + onlinePlayers + "/" + maxPlayers);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.sign.setLine(0, "§4████████");
|
||||
this.sign.setLine(1, "§4Neustart..");
|
||||
this.sign.setLine(2, "§9" + this.name);
|
||||
this.sign.setLine(3, "§4████████");
|
||||
}
|
||||
|
||||
this.sign.update();
|
||||
}
|
||||
public static void save(StatusSignUtil sign) {
|
||||
int size = cfg.getKeys(false).size() + 1;
|
||||
|
||||
cfg.set(size + ".loc.world", sign.getLocation().getWorld().getName());
|
||||
cfg.set(size + ".loc.x", Double.valueOf(sign.getLocation().getX()));
|
||||
cfg.set(size + ".loc.y", Double.valueOf(sign.getLocation().getY()));
|
||||
cfg.set(size + ".loc.z", Double.valueOf(sign.getLocation().getZ()));
|
||||
|
||||
cfg.set(size + ".name", sign.getName());
|
||||
cfg.set(size + ".ip", sign.getIP());
|
||||
cfg.set(size + ".port", Integer.valueOf(sign.getPort()));
|
||||
try
|
||||
{
|
||||
cfg.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
5
src/plugin.yml
Normal file
5
src/plugin.yml
Normal file
@ -0,0 +1,5 @@
|
||||
main: eu.univento.lobby.Lobby
|
||||
name: Lobby
|
||||
version: 0.1
|
||||
author: joethei
|
||||
website: http://joethei.de
|
Loading…
Reference in New Issue
Block a user