SteamWar/BauSystem
Archiviert
13
0

Update BauSystem to new CommandFramework #217

Manuell gemergt
YoyoNow hat 63 Commits von CommandFramework nach master 2021-04-02 18:08:26 +02:00 zusammengeführt
2 geänderte Dateien mit 10 neuen und 64 gelöschten Zeilen
Nur Änderungen aus Commit e025a4e0c1 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -65,14 +65,6 @@ public class BauSystem extends JavaPlugin implements Listener {
Mapper.init();
try {
CommandRemover.removeAll("tp");
CommandInjector.injectCommand(new CommandTeleport());
} catch (Exception e) {
getLogger().log(Level.SEVERE, "Failed to replace commands", e);
Bukkit.shutdown();
return;
}
new CommandTrace();
new CommandTPSLimiter();
@ -84,6 +76,7 @@ public class BauSystem extends JavaPlugin implements Listener {
new CommandGamemode();
new CommandClear();
new CommandTime();
new CommandTeleport();
getCommand("fire").setExecutor(new CommandFire());
getCommand("freeze").setExecutor(new CommandFreeze());
new CommandTestblock();

Datei anzeigen

@ -1,81 +1,34 @@
/*
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.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.command.SWCommand;
import de.steamwar.sql.BauweltMember;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
import java.util.List;
public class CommandTeleport extends BukkitCommand {
public class CommandTeleport extends SWCommand {
public CommandTeleport() {
super("tp");
description = "Teleportiert dich zu einem genannten Spieler.";
usageMessage = "/tp [Spieler]";
super("teleport");
}
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!(sender instanceof Player))
return false;
else if (args.length != 1) {
sender.sendMessage(BauSystem.PREFIX + usageMessage);
return false;
}
Player p = (Player) sender;
Player target = Bukkit.getPlayerExact(args[0]);
if (target == null) {
p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist derzeit offline.");
return true;
}
@Register
public void genericCommand(Player p, Player target) {
if (p.getUniqueId().equals(target.getUniqueId())) {
p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!");
return false;
return;
}
if (!BauSystem.getOwner().equals(p.getUniqueId())) {
BauweltMember member = BauweltMember.getBauMember(BauSystem.getOwner(), p.getUniqueId());
if (member == null || !member.isBuild()) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst dich auf dieser Welt nicht teleportieren!");
return false;
return;
}
}
p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
return true;
}
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
Validate.notNull(sender, "Sender cannot be null");
Validate.notNull(args, "Arguments cannot be null");
Validate.notNull(alias, "Alias cannot be null");
return super.tabComplete(sender, alias, args);
}
}