Add Fly Command
Dieser Commit ist enthalten in:
Ursprung
70652aa6fe
Commit
4b6276f40a
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
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;
|
||||||
@ -33,7 +34,6 @@ public class LobbySystem extends JavaPlugin {
|
|||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
PluginManager pm = Bukkit.getPluginManager();
|
PluginManager pm = Bukkit.getPluginManager();
|
||||||
|
|
||||||
pm.registerEvents(new PlayerMoveListener(), instance);
|
pm.registerEvents(new PlayerMoveListener(), instance);
|
||||||
pm.registerEvents(new PlayerConnectionListener(), instance);
|
pm.registerEvents(new PlayerConnectionListener(), instance);
|
||||||
pm.registerEvents(new PlayerInventoryListener(), instance);
|
pm.registerEvents(new PlayerInventoryListener(), instance);
|
||||||
@ -42,6 +42,8 @@ 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);
|
||||||
|
|
||||||
|
getCommand("fly").setExecutor(new FlyCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
55
src/de/steamwar/lobby/commands/FlyCommand.java
Normale Datei
55
src/de/steamwar/lobby/commands/FlyCommand.java
Normale Datei
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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.Member) {
|
||||||
|
player.sendMessage("§cUnbekannter Befehl.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LobbyPlayer lobbyPlayer = LobbyPlayer.getLobbyPlayer(player);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.lobby.utils;
|
package de.steamwar.lobby.utils;
|
||||||
|
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -39,12 +40,21 @@ public class LobbyPlayer {
|
|||||||
private double particle_time = 0.001;
|
private double particle_time = 0.001;
|
||||||
|
|
||||||
private boolean enderPearlUsed;
|
private boolean enderPearlUsed;
|
||||||
|
private boolean fly;
|
||||||
|
|
||||||
private LobbyPlayer(UUID uuid) {
|
private LobbyPlayer(UUID uuid) {
|
||||||
this.hiderState = PlayerHiderState.SHOW_ALL;
|
this.hiderState = PlayerHiderState.SHOW_ALL;
|
||||||
cache.put(uuid, this);
|
cache.put(uuid, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFly() {
|
||||||
|
return fly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFly(boolean fly) {
|
||||||
|
this.fly = fly;
|
||||||
|
}
|
||||||
|
|
||||||
public PlayerHiderState getHiderState() {
|
public PlayerHiderState getHiderState() {
|
||||||
return hiderState;
|
return hiderState;
|
||||||
}
|
}
|
||||||
@ -135,4 +145,8 @@ public class LobbyPlayer {
|
|||||||
LobbyPlayer lobbyPlayer = cache.get(uuid);
|
LobbyPlayer lobbyPlayer = cache.get(uuid);
|
||||||
return lobbyPlayer == null ? new LobbyPlayer(uuid) : lobbyPlayer;
|
return lobbyPlayer == null ? new LobbyPlayer(uuid) : lobbyPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LobbyPlayer getLobbyPlayer(Player player) {
|
||||||
|
return getLobbyPlayer(player.getUniqueId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,7 @@ author: Yaruma3341
|
|||||||
depend:
|
depend:
|
||||||
- SpigotCore
|
- 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