Add CommandSpectate
Dieser Commit ist enthalten in:
Ursprung
2a0b316608
Commit
a2296dac4b
@ -4,6 +4,9 @@ ShieldFlyTime: 100
|
|||||||
PlatformTime: 30
|
PlatformTime: 30
|
||||||
EndTime: 600
|
EndTime: 600
|
||||||
|
|
||||||
|
MissileCount: 4
|
||||||
|
MissileChance: 0.6
|
||||||
|
|
||||||
Arena:
|
Arena:
|
||||||
MinX: 0
|
MinX: 0
|
||||||
MaxX: 0
|
MaxX: 0
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.misslewars;
|
package de.steamwar.misslewars;
|
||||||
|
|
||||||
|
import de.steamwar.misslewars.commands.CommandSpectate;
|
||||||
import de.steamwar.misslewars.countdowns.EndCountdown;
|
import de.steamwar.misslewars.countdowns.EndCountdown;
|
||||||
import de.steamwar.misslewars.countdowns.ItemCountdown;
|
import de.steamwar.misslewars.countdowns.ItemCountdown;
|
||||||
import de.steamwar.misslewars.countdowns.WaitingCountdown;
|
import de.steamwar.misslewars.countdowns.WaitingCountdown;
|
||||||
@ -60,6 +61,8 @@ public class MissileWars extends JavaPlugin {
|
|||||||
new WaitingListener();
|
new WaitingListener();
|
||||||
new FightListener();
|
new FightListener();
|
||||||
new ChatListener();
|
new ChatListener();
|
||||||
|
new GamemodeListener();
|
||||||
|
getCommand("spectate").setExecutor(new CommandSpectate());
|
||||||
|
|
||||||
new WaitingCountdown();
|
new WaitingCountdown();
|
||||||
new ItemCountdown();
|
new ItemCountdown();
|
||||||
@ -139,4 +142,18 @@ public class MissileWars extends JavaPlugin {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void join(Player p) {
|
||||||
|
if (MissileWars.getTeam(p) != null) return;
|
||||||
|
if (MissileWars.getRedTeam().getPlayers().size() < MissileWars.getBlueTeam().getPlayers().size()) {
|
||||||
|
MissileWars.getRedTeam().join(p);
|
||||||
|
} else {
|
||||||
|
MissileWars.getBlueTeam().join(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void leave(Player p) {
|
||||||
|
MissileWars.getBlueTeam().leave(p);
|
||||||
|
MissileWars.getRedTeam().leave(p);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
39
src/de/steamwar/misslewars/commands/CommandSpectate.java
Normale Datei
39
src/de/steamwar/misslewars/commands/CommandSpectate.java
Normale Datei
@ -0,0 +1,39 @@
|
|||||||
|
package de.steamwar.misslewars.commands;
|
||||||
|
|
||||||
|
import de.steamwar.misslewars.MWTeam;
|
||||||
|
import de.steamwar.misslewars.MissileWars;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CommandSpectate implements CommandExecutor {
|
||||||
|
|
||||||
|
public boolean hasPermissions(Player p) {
|
||||||
|
if (p.hasPermission("bungeecore.group.admin")) return true;
|
||||||
|
if (p.hasPermission("bungeecore.group.developer")) return true;
|
||||||
|
if (p.hasPermission("bungeecore.group.moderator")) return true;
|
||||||
|
if (p.hasPermission("bungeecore.group.supporter")) return true;
|
||||||
|
if (p.hasPermission("bungeecore.group.builder")) return true;
|
||||||
|
if (p.hasPermission("bungeecore.group.youtuber")) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if(!(sender instanceof Player))
|
||||||
|
return false;
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (!hasPermissions(player)) return false;
|
||||||
|
|
||||||
|
MWTeam mwTeam = MissileWars.getTeam(player);
|
||||||
|
if (mwTeam == null) return false;
|
||||||
|
if (mwTeam.getPlayers().size() == 1) return false;
|
||||||
|
MissileWars.leave(player);
|
||||||
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -22,7 +22,6 @@ package de.steamwar.misslewars.listener;
|
|||||||
import de.steamwar.misslewars.FightState;
|
import de.steamwar.misslewars.FightState;
|
||||||
import de.steamwar.misslewars.MissileWars;
|
import de.steamwar.misslewars.MissileWars;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
@ -43,9 +42,7 @@ public class ConnectionListener extends BasicListener{
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLeave(PlayerQuitEvent e) {
|
public void onLeave(PlayerQuitEvent e) {
|
||||||
Player p = e.getPlayer();
|
MissileWars.leave(e.getPlayer());
|
||||||
|
|
||||||
MissileWars.getBlueTeam().leave(p);
|
|
||||||
MissileWars.getRedTeam().leave(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,8 @@ public class JoinListener extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onJoin(PlayerJoinEvent e){
|
public void onJoin(PlayerJoinEvent e){
|
||||||
if(MissileWars.getRedTeam().getPlayers().size() < MissileWars.getBlueTeam().getPlayers().size())
|
MissileWars.join(e.getPlayer());
|
||||||
MissileWars.getRedTeam().join(e.getPlayer());
|
|
||||||
else
|
|
||||||
MissileWars.getBlueTeam().join(e.getPlayer());
|
|
||||||
e.setJoinMessage("§a» " + e.getPlayer().getDisplayName());
|
e.setJoinMessage("§a» " + e.getPlayer().getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,11 @@ main: de.steamwar.misslewars.MissileWars
|
|||||||
authors:
|
authors:
|
||||||
- Jan9103
|
- Jan9103
|
||||||
- Lixfel
|
- Lixfel
|
||||||
|
- YoyoNow
|
||||||
version: "1.0"
|
version: "1.0"
|
||||||
api-version: "1.13"
|
api-version: "1.13"
|
||||||
depend:
|
depend:
|
||||||
- WorldEdit
|
- WorldEdit
|
||||||
- SpigotCore
|
- SpigotCore
|
||||||
|
commands:
|
||||||
|
spectate:
|
In neuem Issue referenzieren
Einen Benutzer sperren