Add PortalCommand
Add LobbySystem.properties Add LobbySystem_en.properties
Dieser Commit ist enthalten in:
Ursprung
200e283a50
Commit
7d56c4ff59
6
pom.xml
6
pom.xml
@ -61,5 +61,11 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${main.basedir}/lib/SpigotCore.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.20</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.lobby;
|
||||
|
||||
import de.steamwar.lobby.command.PortalCommand;
|
||||
import de.steamwar.lobby.listener.Fightservers;
|
||||
import de.steamwar.lobby.listener.Join;
|
||||
import de.steamwar.lobby.listener.Portals;
|
||||
@ -45,6 +46,8 @@ public class LobbySystem extends JavaPlugin {
|
||||
new Fightservers();
|
||||
new Portals();
|
||||
config = new Config(getConfig());
|
||||
|
||||
new PortalCommand();
|
||||
}
|
||||
|
||||
public static LobbySystem getPlugin() {
|
||||
|
@ -7,3 +7,6 @@ COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
|
||||
PORTAL_COMMAND_LIST_HELP = §8/§7portal §elist §8- §7Listet alle Portale auf
|
||||
PORTAL_COMMAND_ADD_HELP = §8/§7portal §ecreate §8[§7PortalType§8] §8[§7PortalName§8] §8- §7Fügt ein Portal hinzu
|
||||
PORTAL_COMMAND_REMOVE_HELP = §8/§7portal §eremove §8[§7PortalName§8] §8- §7Entfernt ein Portal
|
||||
|
||||
PORTAL_COMMAND_LIST_SHORT_INFO = §e{0} §8- §7{1} §7Pos1§8(§7{2}§8) §7Pos2§8(§7{2}§8)
|
||||
PORTAL_NO_WORLDEDIT_SELECTION = §cKeine WorldEdit Selection
|
@ -1,14 +1,33 @@
|
||||
package de.steamwar.lobby.command;
|
||||
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.lobby.LobbySystem;
|
||||
import de.steamwar.lobby.listener.Portals;
|
||||
import de.steamwar.lobby.portal.CommandPortal;
|
||||
import de.steamwar.lobby.portal.Portal;
|
||||
import de.steamwar.lobby.portal.TeleportPortal;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import lombok.Data;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PortalCommand extends SWCommand {
|
||||
|
||||
protected PortalCommand(String command) {
|
||||
private static final WorldEditPlugin worldEditPlugin = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||
|
||||
public PortalCommand() {
|
||||
super("portal");
|
||||
}
|
||||
|
||||
@ -28,26 +47,90 @@ public class PortalCommand extends SWCommand {
|
||||
|
||||
@Register("list")
|
||||
public void portalList(Player player) {
|
||||
// TODO: implement
|
||||
if (noPermissions(player)) return;
|
||||
LobbySystem.MESSAGE.sendPrefixless("COMMAND_HELP_HEAD", player, "portal list");
|
||||
Portal.getPortals().forEach(portal -> {
|
||||
LobbySystem.MESSAGE.sendPrefixless("PORTAL_COMMAND_LIST_SHORT_INFO", player, portal.type().name(), portal.getId(), portal.getPos1().toVector().toString(), portal.getPos1().toVector().toString());
|
||||
});
|
||||
}
|
||||
|
||||
@Register({"create", "command"})
|
||||
public void portalAddCommand(Player player, String... command) {
|
||||
|
||||
public void portalAddCommand(Player player, String portalName, String... command) {
|
||||
if (noPermissions(player)) return;
|
||||
Tuple<Location, Location> tuple = getSelection(player);
|
||||
if (tuple == null) {
|
||||
LobbySystem.MESSAGE.send("PORTAL_NO_WORLDEDIT_SELECTION", player);
|
||||
return;
|
||||
}
|
||||
new Portal(portalName, tuple.k, tuple.v, portal -> new CommandPortal(portal, String.join(" ", command)));
|
||||
}
|
||||
|
||||
@Register({"create", "fightserver"})
|
||||
public void portalAddFightserver(Player player) {
|
||||
|
||||
public void portalAddFightserver(Player player, String portalName) {
|
||||
if (noPermissions(player)) return;
|
||||
Tuple<Location, Location> tuple = getSelection(player);
|
||||
if (tuple == null) {
|
||||
LobbySystem.MESSAGE.send("PORTAL_NO_WORLDEDIT_SELECTION", player);
|
||||
return;
|
||||
}
|
||||
// TODO: implement FightserverPortal
|
||||
// new Portal(portalName, tuple.k, tuple.v, portal -> new CommandPortal(portal, String.join(" ", command)));
|
||||
}
|
||||
|
||||
@Register({"create", "teleport"})
|
||||
public void portalAddTeleport(Player player, String portalName) {
|
||||
|
||||
public void portalAddTeleport(Player player, String portalName, String portalDestination) {
|
||||
if (noPermissions(player)) return;
|
||||
Tuple<Location, Location> tuple = getSelection(player);
|
||||
if (tuple == null) {
|
||||
LobbySystem.MESSAGE.send("PORTAL_NO_WORLDEDIT_SELECTION", player);
|
||||
return;
|
||||
}
|
||||
new Portal(portalName, tuple.k, tuple.v, portal -> new TeleportPortal(portal, portalDestination));
|
||||
}
|
||||
|
||||
@Register("remove")
|
||||
public void portalRemove(Player player, String portalName) {
|
||||
public void portalRemove(Player player, Portal portal) {
|
||||
if (noPermissions(player)) return;
|
||||
portal.delete();
|
||||
}
|
||||
|
||||
@ClassMapper(value = Portal.class, local = true)
|
||||
public TypeMapper<Portal> portalTypeMapper() {
|
||||
return new TypeMapper<Portal>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return new ArrayList<>(Portal.getPortalNames());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Portal map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return Portal.getPortal(s);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class Tuple<K, V> {
|
||||
private final K k;
|
||||
private final V v;
|
||||
}
|
||||
|
||||
private Tuple<Location, Location> getSelection(Player player) {
|
||||
RegionSelector regionSelector = WorldEdit.getInstance()
|
||||
.getSessionManager()
|
||||
.get(BukkitAdapter.adapt(player))
|
||||
.getRegionSelector(BukkitAdapter.adapt(player.getWorld()));
|
||||
|
||||
try {
|
||||
BlockVector3 min = regionSelector.getRegion().getMinimumPoint();
|
||||
BlockVector3 max = regionSelector.getRegion().getMaximumPoint();
|
||||
return new Tuple<>(adapt(player.getWorld(), min), adapt(player.getWorld(), max));
|
||||
} catch (IncompleteRegionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Location adapt(World world, BlockVector3 blockVector3) {
|
||||
return new Location(world, blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ());
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,7 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Portal implements PortalHandler, ConfigurationSerializable {
|
||||
@ -40,6 +37,10 @@ public class Portal implements PortalHandler, ConfigurationSerializable {
|
||||
return new ArrayList<>(portals.values());
|
||||
}
|
||||
|
||||
public static Set<String> getPortalNames() {
|
||||
return portals.keySet();
|
||||
}
|
||||
|
||||
public static Portal getPortal(Location loc) {
|
||||
return posMap.get(new Vector(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren