Disables shield and fly. Nobody needs that #8
@ -1,6 +1,5 @@
|
|||||||
package de.steamwar.lobby;
|
package de.steamwar.lobby;
|
||||||
|
|
||||||
import de.steamwar.lobby.commands.FlyCommand;
|
|
||||||
import de.steamwar.lobby.listener.*;
|
import de.steamwar.lobby.listener.*;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
@ -14,12 +13,6 @@ public class LobbySystem extends JavaPlugin {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
init();
|
|
||||||
|
|
||||||
getCommand("fly").setExecutor(new FlyCommand());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init() {
|
|
||||||
PluginManager pm = Bukkit.getPluginManager();
|
PluginManager pm = Bukkit.getPluginManager();
|
||||||
|
|
||||||
pm.registerEvents(new PlayerMoveListener(), instance);
|
pm.registerEvents(new PlayerMoveListener(), instance);
|
||||||
@ -30,12 +23,10 @@ public class LobbySystem extends JavaPlugin {
|
|||||||
pm.registerEvents(new ParticleListener(), instance);
|
pm.registerEvents(new ParticleListener(), instance);
|
||||||
pm.registerEvents(new PlayerHiderListener(), instance);
|
pm.registerEvents(new PlayerHiderListener(), instance);
|
||||||
pm.registerEvents(new EnderPearlListener(), instance);
|
pm.registerEvents(new EnderPearlListener(), instance);
|
||||||
pm.registerEvents(new ShieldListener(), instance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static LobbySystem getInstance() {
|
public static LobbySystem getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
package de.steamwar.lobby.commands;
|
|
||||||
|
|
||||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.sql.UserGroup;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class FlyCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if(!(sender instanceof Player))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Player player = (Player) sender;
|
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
|
||||||
UserGroup userGroup = steamwarUser.getUserGroup();
|
|
||||||
|
|
||||||
if(userGroup != UserGroup.Admin &&
|
|
||||||
userGroup != UserGroup.Moderator &&
|
|
||||||
userGroup != UserGroup.Developer &&
|
|
||||||
userGroup != UserGroup.Supporter &&
|
|
||||||
userGroup != UserGroup.Builder &&
|
|
||||||
userGroup != UserGroup.Youtuber) {
|
|
||||||
player.sendMessage("§cDu verfügst nicht über die benötigten Rechte!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
|
||||||
boolean newFlightState = !lobbyPlayer.isFly();
|
|
||||||
|
|
||||||
lobbyPlayer.setFly(newFlightState);
|
|
||||||
player.setAllowFlight(newFlightState);
|
|
||||||
player.setFlying(newFlightState);
|
|
||||||
player.sendMessage("§7Du kannst jetzt " + (newFlightState ? "§afliegen§7." : "§cnicht §7mehr fliegen."));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,8 +2,6 @@ package de.steamwar.lobby.inventories;
|
|||||||
|
|
||||||
import de.steamwar.lobby.utils.ItemBuilder;
|
import de.steamwar.lobby.utils.ItemBuilder;
|
||||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
import de.steamwar.lobby.utils.LobbyPlayer;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.sql.UserGroup;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -37,22 +35,6 @@ public class LobbyInventory {
|
|||||||
.setUnbreakable(true)
|
.setUnbreakable(true)
|
||||||
.removeAllAtributs()
|
.removeAllAtributs()
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
|
|
||||||
UserGroup userGroup = SteamwarUser.get(player.getUniqueId()).getUserGroup();
|
|
||||||
if(userGroup != UserGroup.Admin &&
|
|
||||||
userGroup != UserGroup.Moderator &&
|
|
||||||
userGroup != UserGroup.Developer &&
|
|
||||||
userGroup != UserGroup.Supporter &&
|
|
||||||
userGroup != UserGroup.Builder &&
|
|
||||||
userGroup != UserGroup.Youtuber) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.getInventory().setItem(8, new ItemBuilder(SHIELD)
|
|
||||||
.setDisplayName("§bSchild §8| " + (lobbyPlayer.isShield() ? "§aan" : "§caus"))
|
|
||||||
.setUnbreakable(true)
|
|
||||||
.removeAllAtributs()
|
|
||||||
.build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,8 +25,6 @@ public class DoubleJumpListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerToggleFlight(PlayerToggleFlightEvent event) {
|
public void handlePlayerToggleFlight(PlayerToggleFlightEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(LobbyPlayer.getLobbyPlayer(player.getUniqueId()).isFly())
|
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.setAllowFlight(false);
|
player.setAllowFlight(false);
|
||||||
@ -44,8 +42,6 @@ public class DoubleJumpListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void handlePlayerMove(PlayerMoveEvent event) {
|
public void handlePlayerMove(PlayerMoveEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(LobbyPlayer.getLobbyPlayer(player.getUniqueId()).isFly())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(player.getLocation().add(0, -1, 0).getBlock().getType() == Material.AIR)
|
if(player.getLocation().add(0, -1, 0).getBlock().getType() == Material.AIR)
|
||||||
return;
|
return;
|
||||||
|
@ -22,8 +22,7 @@ public class PlayerConnectionListener implements Listener {
|
|||||||
event.setJoinMessage(null);
|
event.setJoinMessage(null);
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
LobbyPlayer lp = LobbyPlayer.getLobbyPlayer(player.getUniqueId()); //initialisiert einen neuen LP falls nicht vorhanden
|
LobbyPlayer.getLobbyPlayer(player.getUniqueId()); //initialisiert einen neuen LP falls nicht vorhanden
|
||||||
lp.setShield(false);
|
|
||||||
|
|
||||||
player.teleport(new Location(Bukkit.getWorlds().get(0), Config.SpawnX, Config.SpawnY, Config.SpawnZ, Config.Yaw, Config.Pitch));
|
player.teleport(new Location(Bukkit.getWorlds().get(0), Config.SpawnX, Config.SpawnY, Config.SpawnZ, Config.Yaw, Config.Pitch));
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
|
@ -1,95 +0,0 @@
|
|||||||
package de.steamwar.lobby.listener;
|
|
||||||
|
|
||||||
import de.steamwar.lobby.inventories.LobbyInventory;
|
|
||||||
import de.steamwar.lobby.utils.LobbyPlayer;
|
|
||||||
import org.bukkit.Effect;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
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.PlayerMoveEvent;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
public class ShieldListener implements Listener {
|
|
||||||
|
|
||||||
double radius = 1.5D;
|
|
||||||
double multiplyer = 1.1D;
|
|
||||||
float height = 1.0F;
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void handlePlayerMove(PlayerMoveEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
|
||||||
World world = player.getWorld();
|
|
||||||
Location playerLocation = event.getTo();
|
|
||||||
|
|
||||||
Collection<Entity> nearbyEntities = world.getNearbyEntities(playerLocation, radius, radius, radius);
|
|
||||||
|
|
||||||
if(lobbyPlayer.isShield()) {
|
|
||||||
for(Entity entity : nearbyEntities) {
|
|
||||||
if(!(entity instanceof Player)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player entityPlayer = (Player) entity;
|
|
||||||
if(entityPlayer.getUniqueId() == player.getUniqueId()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(LobbyPlayer.getLobbyPlayer(entityPlayer.getUniqueId()).isShield()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
world.playEffect(playerLocation, Effect.ENDER_SIGNAL, 1);
|
|
||||||
Location location = entityPlayer.getLocation();
|
|
||||||
|
|
||||||
double x = location.getX() - playerLocation.getX();
|
|
||||||
double y = location.getY() - playerLocation.getY();
|
|
||||||
double z = location.getZ() - playerLocation.getZ();
|
|
||||||
|
|
||||||
entityPlayer.setVelocity(new Vector(x, y, z).multiply(multiplyer).add(new Vector(0.0F, height, 0.0F)));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for(Entity entity : nearbyEntities) {
|
|
||||||
if(!(entity instanceof Player)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player entityPlayer = (Player) entity;
|
|
||||||
LobbyPlayer entityPlayerLP = LobbyPlayer.getLobbyPlayer(entityPlayer.getUniqueId());
|
|
||||||
if(!entityPlayerLP.isShield())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
world.playEffect(entityPlayer.getLocation(), Effect.ENDER_SIGNAL, 1);
|
|
||||||
|
|
||||||
Location location = entityPlayer.getLocation();
|
|
||||||
|
|
||||||
double x = playerLocation.getX() - location.getX();
|
|
||||||
double y = playerLocation.getY() - location.getY();
|
|
||||||
double z = playerLocation.getZ() - location.getZ();
|
|
||||||
|
|
||||||
player.setVelocity(new Vector(x, y, z).multiply(multiplyer).add(new Vector(0.0F, height, 0.0F)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
|
||||||
if(event.getMaterial() != LobbyInventory.SHIELD) return;
|
|
||||||
Action action = event.getAction();
|
|
||||||
if(action != Action.RIGHT_CLICK_AIR && action != Action.RIGHT_CLICK_BLOCK) return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player.getUniqueId());
|
|
||||||
lobbyPlayer.setShield(!lobbyPlayer.isShield());
|
|
||||||
LobbyInventory.givePlayerLobbyItems(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -6,13 +6,11 @@ import java.util.*;
|
|||||||
|
|
||||||
public class LobbyPlayer {
|
public class LobbyPlayer {
|
||||||
|
|
||||||
private static Map<UUID, LobbyPlayer> cache = new HashMap();
|
private static Map<UUID, LobbyPlayer> cache = new HashMap<>();
|
||||||
|
|
||||||
private PlayerHiderState hiderState;
|
private PlayerHiderState hiderState;
|
||||||
private Particle particle;
|
private Particle particle;
|
||||||
private boolean fly;
|
|
||||||
private boolean enderPearlUsed;
|
private boolean enderPearlUsed;
|
||||||
private boolean shield;
|
|
||||||
|
|
||||||
private LobbyPlayer(UUID uuid) {
|
private LobbyPlayer(UUID uuid) {
|
||||||
this.hiderState = PlayerHiderState.SHOW_ALL;
|
this.hiderState = PlayerHiderState.SHOW_ALL;
|
||||||
@ -35,14 +33,6 @@ public class LobbyPlayer {
|
|||||||
this.particle = particle;
|
this.particle = particle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFly() {
|
|
||||||
return fly;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFly(boolean fly) {
|
|
||||||
this.fly = fly;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnderPearlUsed() {
|
public boolean isEnderPearlUsed() {
|
||||||
return enderPearlUsed;
|
return enderPearlUsed;
|
||||||
}
|
}
|
||||||
@ -51,14 +41,6 @@ public class LobbyPlayer {
|
|||||||
this.enderPearlUsed = enderPearlUsed;
|
this.enderPearlUsed = enderPearlUsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShield() {
|
|
||||||
return shield;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShield(boolean shield) {
|
|
||||||
this.shield = shield;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void nexthHiderState() {
|
public void nexthHiderState() {
|
||||||
if(this.hiderState == PlayerHiderState.SHOW_ALL) {
|
if(this.hiderState == PlayerHiderState.SHOW_ALL) {
|
||||||
this.hiderState = PlayerHiderState.SHOW_TEAM;
|
this.hiderState = PlayerHiderState.SHOW_TEAM;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
name: LobbySystem
|
name: LobbySystem
|
||||||
version: 1.0
|
version: "1.0"
|
||||||
author: Yaruma3341
|
author: Yaruma3341
|
||||||
depend: [SpigotCore]
|
depend:
|
||||||
|
- SpigotCore
|
||||||
main: de.steamwar.lobby.LobbySystem
|
main: de.steamwar.lobby.LobbySystem
|
||||||
api-version: 1.13
|
api-version: "1.13"
|
||||||
|
|
||||||
commands:
|
|
||||||
fly:
|
|
In neuem Issue referenzieren
Einen Benutzer sperren