SteamWar/MissileWars
Archiviert
13
0

Add CommandInvite

Add CommandSpectate disable while challenge
Add openInvitation HashSet
Dieser Commit ist enthalten in:
jojo 2020-12-18 23:33:29 +01:00
Ursprung 7dd543dab5
Commit e7d27fc133
6 geänderte Dateien mit 63 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -100,7 +100,7 @@ public class Config {
RedLeader = null; RedLeader = null;
} }
public boolean isChallenge() { public static boolean isChallenge() {
return BlueLeader != null && RedLeader != null; return BlueLeader != null && RedLeader != null;
} }

Datei anzeigen

@ -19,9 +19,10 @@
package de.steamwar.misslewars; package de.steamwar.misslewars;
import de.steamwar.comms.packets.TablistNamePacket; import org.bukkit.ChatColor;
import de.steamwar.sql.SteamwarUser; import org.bukkit.GameMode;
import org.bukkit.*; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
@ -30,8 +31,10 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Team; import org.bukkit.scoreboard.Team;
import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
public class MWTeam { public class MWTeam {
private static final ItemStack bow = new ItemStack(Material.BOW); private static final ItemStack bow = new ItemStack(Material.BOW);
@ -52,7 +55,8 @@ public class MWTeam {
private final Location spawn; private final Location spawn;
private final int portalZ; private final int portalZ;
private LinkedList<Player> players = new LinkedList<>(); private final LinkedList<Player> players = new LinkedList<>();
private final Set<Player> openInvitations = new HashSet<>();
MWTeam(ChatColor color, Location spawn, String teamName, int portalZ) { MWTeam(ChatColor color, Location spawn, String teamName, int portalZ) {
this.teamName = teamName; this.teamName = teamName;

Datei anzeigen

@ -62,6 +62,7 @@ public class MissileWars extends JavaPlugin {
new FightListener(); new FightListener();
new ChatListener(); new ChatListener();
getCommand("spectate").setExecutor(new CommandSpectate()); getCommand("spectate").setExecutor(new CommandSpectate());
getCommand("invite").setExecutor(new CommandSpectate());
new WaitingCountdown(); new WaitingCountdown();
new ItemCountdown(); new ItemCountdown();

Datei anzeigen

@ -0,0 +1,43 @@
/*
*
* 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.misslewars.commands;
import de.steamwar.misslewars.Config;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CommandInvite implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) return false;
Player player = (Player) sender;
if (!Config.isChallenge()) {
player.sendMessage("§cDieser Command ist deaktiviert.");
return false;
}
return false;
}
}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.misslewars.commands; package de.steamwar.misslewars.commands;
import de.steamwar.misslewars.Config;
import de.steamwar.misslewars.MWTeam; import de.steamwar.misslewars.MWTeam;
import de.steamwar.misslewars.MissileWars; import de.steamwar.misslewars.MissileWars;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -31,8 +32,12 @@ public class CommandSpectate implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) return false; if (!(sender instanceof Player)) return false;
Player player = (Player) sender; Player player = (Player) sender;
if (Config.isChallenge()) {
player.sendMessage("§cDieser Command ist deaktiviert.");
return false;
}
MWTeam mwTeam = MissileWars.getTeam(player); MWTeam mwTeam = MissileWars.getTeam(player);
if (mwTeam == null) return false; if (mwTeam == null) return false;
@ -42,6 +47,8 @@ public class CommandSpectate implements CommandExecutor {
} }
MissileWars.leave(player); MissileWars.leave(player);
player.setGameMode(GameMode.SPECTATOR); player.setGameMode(GameMode.SPECTATOR);
player.getInventory().clear();
player.updateInventory();
return true; return true;
} }

Datei anzeigen

@ -12,3 +12,4 @@ depend:
- SpigotCore - SpigotCore
commands: commands:
spectate: spectate:
invite: