Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
3b5be809dd
Commit
a188ce2c6f
@ -27,10 +27,8 @@ import de.steamwar.bungeecore.mods.ServerListPing;
|
|||||||
import de.steamwar.bungeecore.mods.*;
|
import de.steamwar.bungeecore.mods.*;
|
||||||
import de.steamwar.bungeecore.network.BungeeNetworkHandler;
|
import de.steamwar.bungeecore.network.BungeeNetworkHandler;
|
||||||
import de.steamwar.bungeecore.tablist.TablistManager;
|
import de.steamwar.bungeecore.tablist.TablistManager;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.*;
|
||||||
import de.steamwar.command.SWTypeMapperCreator;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.command.TabCompletionCache;
|
|
||||||
import de.steamwar.command.TypeMapper;
|
|
||||||
import de.steamwar.sql.Punishment;
|
import de.steamwar.sql.Punishment;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.sql.Team;
|
||||||
@ -80,14 +78,14 @@ public class BungeeCore extends Plugin {
|
|||||||
|
|
||||||
errorLogger = new ErrorLogger();
|
errorLogger = new ErrorLogger();
|
||||||
|
|
||||||
SWCommandUtils.init((SWTypeMapperCreator<TypeMapper<Object>, CommandSender, Object>) (mapper, tabCompleter) -> new TypeMapper<Object>() {
|
SWCommandUtils.init((SWTypeMapperCreator<TypeMapper<Object>, Chatter, Object>) (mapper, tabCompleter) -> new TypeMapper<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object map(CommandSender commandSender, String[] previousArguments, String s) {
|
public Object map(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
return mapper.apply(s);
|
return mapper.apply(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
return tabCompleter.apply(sender, s);
|
return tabCompleter.apply(sender, s);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -24,7 +24,6 @@ import de.steamwar.bungeecore.listeners.ConnectionListener;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
|
|
||||||
public class AlertCommand extends SWCommand {
|
public class AlertCommand extends SWCommand {
|
||||||
|
|
||||||
@ -33,9 +32,9 @@ public class AlertCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "USAGE_ALERT")
|
@Register(description = "USAGE_ALERT")
|
||||||
public void broadcast(CommandSender sender, @OptionalValue("") @StaticValue("-discord") String sendToDiscord, String... message) {
|
public void broadcast(Chatter sender, @OptionalValue("") @StaticValue("-discord") String sendToDiscord, String... message) {
|
||||||
if (message.length == 0) {
|
if (message.length == 0) {
|
||||||
Chatter.of(sender).system("USAGE_ALERT");
|
sender.system("USAGE_ALERT");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,9 +24,9 @@ import de.steamwar.bungeecore.Subserver;
|
|||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -39,29 +39,29 @@ public class ArenaCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void arenaJoin(ProxiedPlayer player, Subserver server) {
|
public void arenaJoin(PlayerChatter sender, Subserver server) {
|
||||||
TpCommand.teleport(player, server.getServer());
|
TpCommand.teleport(sender.getPlayer(), server.getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassMapper(value = Subserver.class, local = true)
|
@ClassMapper(value = Subserver.class, local = true)
|
||||||
public TypeMapper<Subserver> serverInfoTypeMapper() {
|
public TypeMapper<Subserver> serverInfoTypeMapper() {
|
||||||
return new TypeMapper<Subserver>() {
|
return new TypeMapper<Subserver>() {
|
||||||
@Override
|
@Override
|
||||||
public Subserver map(CommandSender commandSender, String[] previousArguments, String s) {
|
public Subserver map(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
return Subserver.getSubserver(ProxyServer.getInstance().getServerInfo(s));
|
return Subserver.getSubserver(ProxyServer.getInstance().getServerInfo(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean validate(CommandSender sender, Subserver value, MessageSender messageSender) {
|
public boolean validate(Chatter sender, Subserver value, MessageSender messageSender) {
|
||||||
if (value == null || value.getType() != Servertype.ARENA) {
|
if (value == null || value.getType() != Servertype.ARENA) {
|
||||||
messageSender.send("ARENA_NOT_FOUND");
|
sender.system("ARENA_NOT_FOUND");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
List<Subserver> subserverList = Subserver.getServerList();
|
List<Subserver> subserverList = Subserver.getServerList();
|
||||||
synchronized (subserverList) {
|
synchronized (subserverList) {
|
||||||
return subserverList.stream().filter(subserver -> subserver.getType() == Servertype.ARENA).map(subserver -> subserver.getServer().getName()).collect(Collectors.toList());
|
return subserverList.stream().filter(subserver -> subserver.getType() == Servertype.ARENA).map(subserver -> subserver.getServer().getName()).collect(Collectors.toList());
|
||||||
|
@ -31,12 +31,11 @@ import de.steamwar.command.SWCommand;
|
|||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||||
import de.steamwar.sql.BauweltMember;
|
import de.steamwar.sql.BauweltMember;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -46,26 +45,26 @@ public class BauCommand extends SWCommand {
|
|||||||
|
|
||||||
private final HelpCommand command;
|
private final HelpCommand command;
|
||||||
|
|
||||||
public BauCommand(HelpCommand command){
|
public BauCommand(HelpCommand command) {
|
||||||
super("bau", null, "b", "build", "gs");
|
super("bau", null, "b", "build", "gs");
|
||||||
this.command = command;
|
this.command = command;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(noTabComplete = true)
|
@Register(noTabComplete = true)
|
||||||
public void genericHelp(ProxiedPlayer p, String... args) {
|
public void genericHelp(Chatter sender, String... args) {
|
||||||
this.command.sendBauHelp(p);
|
this.command.sendBauHelp(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void toBau(ProxiedPlayer p, @OptionalValue(value = "", onlyUINIG = true) ServerVersion version) {
|
public void toBau(PlayerChatter sender, @OptionalValue(value = "", onlyUINIG = true) ServerVersion version) {
|
||||||
new ServerStarter().build(version, p.getUniqueId()).send(p).start();
|
new ServerStarter().build(version, sender.user().getUUID()).send(sender.getPlayer()).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "addmember", description = "BAU_ADDMEMBER_USAGE")
|
@Register(value = "addmember", description = "BAU_ADDMEMBER_USAGE")
|
||||||
public void addmember(ProxiedPlayer p, @Validator("addMemberTarget") SteamwarUser target) {
|
public void addmember(Chatter sender, @Validator("addMemberTarget") SteamwarUser target) {
|
||||||
BauweltMember.addMember(p.getUniqueId(), target.getUUID());
|
BauweltMember.addMember(sender.user().getUUID(), target.getUUID());
|
||||||
Chatter.of(p).system("BAU_ADDMEMBER_ADDED");
|
sender.system("BAU_ADDMEMBER_ADDED");
|
||||||
Chatter.of(target.getUUID()).system("BAU_ADDMEMBER_ADDED_TARGET", p);
|
Chatter.of(target.getUUID()).system("BAU_ADDMEMBER_ADDED_TARGET", sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Validator(value = "addMemberTarget", local = true)
|
@Validator(value = "addMemberTarget", local = true)
|
||||||
@ -75,11 +74,11 @@ public class BauCommand extends SWCommand {
|
|||||||
messageSender.send("UNKNOWN_PLAYER");
|
messageSender.send("UNKNOWN_PLAYER");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (((ProxiedPlayer) sender).getUniqueId().equals(value.getUUID())) {
|
if (sender.user().getUUID().equals(value.getUUID())) {
|
||||||
messageSender.send("BAU_ADDMEMBER_SELFADD");
|
messageSender.send("BAU_ADDMEMBER_SELFADD");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (BauweltMember.getBauMember(((ProxiedPlayer) sender).getUniqueId(), value.getUUID()) != null) {
|
if (BauweltMember.getBauMember(sender.user().getId(), value.getId()) != null) {
|
||||||
messageSender.send("BAU_ADDMEMBER_ISADDED");
|
messageSender.send("BAU_ADDMEMBER_ISADDED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -89,8 +88,8 @@ public class BauCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register(value = "tp", description = "BAU_TP_USAGE")
|
@Register(value = "tp", description = "BAU_TP_USAGE")
|
||||||
@Register("teleport")
|
@Register("teleport")
|
||||||
public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @OptionalValue(value = "", onlyUINIG = true) ServerVersion version) {
|
public void teleport(PlayerChatter sender, @Validator("teleportTarget") SteamwarUser worldOwner, @OptionalValue(value = "", onlyUINIG = true) ServerVersion version) {
|
||||||
new ServerStarter().build(version, worldOwner.getUUID()).send(p).start();
|
new ServerStarter().build(version, worldOwner.getUUID()).send(sender.getPlayer()).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Validator(value = "teleportTarget", local = true)
|
@Validator(value = "teleportTarget", local = true)
|
||||||
@ -100,47 +99,45 @@ public class BauCommand extends SWCommand {
|
|||||||
messageSender.send("UNKNOWN_PLAYER");
|
messageSender.send("UNKNOWN_PLAYER");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
if (sender.user().getId() != value.getId() && BauweltMember.getBauMember(value.getId(), sender.user().getId()) == null) {
|
||||||
if (!p.getUniqueId().equals(value.getUUID()) && BauweltMember.getBauMember(value.getUUID(), p.getUniqueId()) == null) {
|
SubserverSystem.sendDeniedMessage(sender, value.getUUID());
|
||||||
SubserverSystem.sendDeniedMessage(Chatter.of(p), value.getUUID());
|
|
||||||
messageSender.send("BAU_TP_NOALLOWED");
|
messageSender.send("BAU_TP_NOALLOWED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !BauLock.checkNotifyLocked(value, p);
|
return !BauLock.checkNotifyLocked(value, sender);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("info")
|
@Register("info")
|
||||||
public void info(ProxiedPlayer p) {
|
public void info(PlayerChatter sender) {
|
||||||
Chat19.chat(p, "/bauinfo");
|
Chat19.chat(sender.getPlayer(), "/bauinfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("setspectator")
|
@Register("setspectator")
|
||||||
public void setSpectator(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
public void setSpectator(Chatter sender, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
||||||
setPerms(p, user, "setspectator", "BAU_MEMBER_SET_SPECTATOR", member -> {
|
setPerms(sender, user, "setspectator", "BAU_MEMBER_SET_SPECTATOR", member -> {
|
||||||
member.setBuild(false);
|
member.setBuild(false);
|
||||||
member.setSupervisor(false);
|
member.setSupervisor(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("setbuild")
|
@Register("setbuild")
|
||||||
public void setBuild(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
public void setBuild(Chatter sender, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
||||||
setPerms(p, user, "setbuild", "BAU_MEMBER_SET_BUILDER", member -> {
|
setPerms(sender, user, "setbuild", "BAU_MEMBER_SET_BUILDER", member -> {
|
||||||
member.setBuild(true);
|
member.setBuild(true);
|
||||||
member.setSupervisor(false);
|
member.setSupervisor(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("setsupervisor")
|
@Register("setsupervisor")
|
||||||
public void setSupervisor(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
public void setSupervisor(Chatter sender, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
||||||
setPerms(p, user, "setsupervisor", "BAU_MEMBER_SET_SUPERVISOR", member -> {
|
setPerms(sender, user, "setsupervisor", "BAU_MEMBER_SET_SUPERVISOR", member -> {
|
||||||
member.setBuild(true);
|
member.setBuild(true);
|
||||||
member.setSupervisor(true);
|
member.setSupervisor(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPerms(ProxiedPlayer p, SteamwarUser user, String name, String permName, Consumer<BauweltMember> setter) {
|
private void setPerms(Chatter owner, SteamwarUser user, String name, String permName, Consumer<BauweltMember> setter) {
|
||||||
Chatter owner = Chatter.of(p);
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
owner.system("BAU_MEMBER_SET_USAGE", name);
|
owner.system("BAU_MEMBER_SET_USAGE", name);
|
||||||
return;
|
return;
|
||||||
@ -149,28 +146,25 @@ public class BauCommand extends SWCommand {
|
|||||||
withMember(owner, user, target -> {
|
withMember(owner, user, target -> {
|
||||||
setter.accept(target);
|
setter.accept(target);
|
||||||
|
|
||||||
Bauserver bauserver = Bauserver.get(p.getUniqueId());
|
Bauserver bauserver = Bauserver.get(owner.user().getUUID());
|
||||||
if(bauserver != null)
|
if(bauserver != null)
|
||||||
bauserver.getServer().getPlayers().stream().findAny().ifPresent(player -> NetworkSender.send(player, new BaumemberUpdatePacket()));
|
bauserver.getServer().getPlayers().stream().findAny().ifPresent(player -> NetworkSender.send(player, new BaumemberUpdatePacket()));
|
||||||
|
|
||||||
Chatter.of(user.getUUID()).system("BAU_MEMBER_SET_TARGET", p.getName(), new Message(permName));
|
Chatter.of(user.getUUID()).system("BAU_MEMBER_SET_TARGET", owner, new Message(permName));
|
||||||
owner.system("BAU_MEMBER_SET", new Message(permName));
|
owner.system("BAU_MEMBER_SET", new Message(permName));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "delmember", description = "BAU_DELMEMBER_USAGE")
|
@Register(value = "delmember", description = "BAU_DELMEMBER_USAGE")
|
||||||
public void delmember(ProxiedPlayer p, @Mapper("addedUsers") SteamwarUser user) {
|
public void delmember(Chatter owner, @Mapper("addedUsers") SteamwarUser user) {
|
||||||
Chatter owner = Chatter.of(p);
|
|
||||||
withMember(owner, user, target -> {
|
withMember(owner, user, target -> {
|
||||||
target.remove();
|
target.remove();
|
||||||
|
|
||||||
Chatter member = Chatter.of(user.getUUID());
|
Chatter member = Chatter.of(user.getUUID());
|
||||||
member.system("BAU_DELMEMBER_DELETED_TARGET", p);
|
member.system("BAU_DELMEMBER_DELETED_TARGET", owner);
|
||||||
member.withPlayer(toRemove -> {
|
member.withPlayer(player -> {
|
||||||
Subserver currentServer = Subserver.getSubserver(toRemove.getServer().getInfo());
|
if (Bauserver.get(owner.user().getUUID()).getServer().getPlayers().contains(player))
|
||||||
if (currentServer != null && currentServer.getType() == Servertype.BAUSERVER && ((Bauserver) currentServer).getOwner().equals(p.getUniqueId())) {
|
player.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER));
|
||||||
toRemove.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
owner.system("BAU_DELMEMBER_DELETED");
|
owner.system("BAU_DELMEMBER_DELETED");
|
||||||
@ -181,13 +175,13 @@ public class BauCommand extends SWCommand {
|
|||||||
public TypeMapper<SteamwarUser> addedUsers() {
|
public TypeMapper<SteamwarUser> addedUsers() {
|
||||||
return new TypeMapper<SteamwarUser>() {
|
return new TypeMapper<SteamwarUser>() {
|
||||||
@Override
|
@Override
|
||||||
public SteamwarUser map(CommandSender commandSender, String[] previousArguments, String s) {
|
public SteamwarUser map(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
return SteamwarUser.get(s);
|
return sender.user();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
return BauweltMember.getMembers(Chatter.of(sender).user().getId()).stream()
|
return BauweltMember.getMembers(sender.user().getId()).stream()
|
||||||
.map(bauweltMember -> SteamwarUser.get(bauweltMember.getMemberID()).getUserName())
|
.map(bauweltMember -> SteamwarUser.get(bauweltMember.getMemberID()).getUserName())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@ -196,20 +190,18 @@ public class BauCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register("resetall")
|
@Register("resetall")
|
||||||
@Register("delete")
|
@Register("delete")
|
||||||
public void delete(ProxiedPlayer p, @OptionalValue(value = "", onlyUINIG = true) ServerVersion version) {
|
public void delete(Chatter sender, @OptionalValue(value = "", onlyUINIG = true) ServerVersion version) {
|
||||||
Chatter player = Chatter.of(p);
|
SWInventory inventory = new SWInventory(sender, 9, new Message("BAU_DELETE_GUI_NAME"));
|
||||||
|
|
||||||
SWInventory inventory = new SWInventory(player, 9, new Message("BAU_DELETE_GUI_NAME"));
|
|
||||||
inventory.addItem(0, new SWItem(new Message("BAU_DELETE_GUI_DELETE"), 10), click -> {
|
inventory.addItem(0, new SWItem(new Message("BAU_DELETE_GUI_DELETE"), 10), click -> {
|
||||||
String world = version.getWorldFolder(ServerStarter.WORLDS_BASE_PATH) + (version != ServerVersion.SPIGOT_12 ? player.user().getId() : p.getUniqueId().toString());
|
String world = version.getWorldFolder(ServerStarter.WORLDS_BASE_PATH) + (version != ServerVersion.SPIGOT_12 ? sender.user().getId() : sender.user().getUUID().toString());
|
||||||
|
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
Bauserver subserver = Bauserver.get(p.getUniqueId());
|
Bauserver subserver = Bauserver.get(sender.user().getUUID());
|
||||||
if(subserver != null)
|
if(subserver != null)
|
||||||
subserver.stop();
|
subserver.stop();
|
||||||
|
|
||||||
SubserverSystem.deleteFolder(BungeeCore.local, world);
|
SubserverSystem.deleteFolder(BungeeCore.local, world);
|
||||||
player.system("BAU_DELETE_DELETED");
|
sender.system("BAU_DELETE_DELETED");
|
||||||
});
|
});
|
||||||
|
|
||||||
inventory.close();
|
inventory.close();
|
||||||
@ -220,20 +212,20 @@ public class BauCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register("test")
|
@Register("test")
|
||||||
@Register("testarena")
|
@Register("testarena")
|
||||||
public void testarena(ProxiedPlayer p, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
public void testarena(PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||||
FightCommand.createArena(p, "/bau testarena ", false, arenaMode, map, false, (player, mode, m) ->
|
FightCommand.createArena(sender.getPlayer(), "/bau testarena ", false, arenaMode, map, false, (player, mode, m) ->
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> new ServerStarter().test(mode, m, p).start())
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> new ServerStarter().test(mode, m, sender.getPlayer()).start())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "lock", description = "BAU_LOCKED_OPTIONS")
|
@Register(value = "lock", description = "BAU_LOCKED_OPTIONS")
|
||||||
public void lock(ProxiedPlayer p, BauLockState bauLockState) {
|
public void lock(Chatter sender, BauLockState bauLockState) {
|
||||||
BauLock.setLocked(p, bauLockState);
|
BauLock.setLocked(sender, bauLockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("unlock")
|
@Register("unlock")
|
||||||
public void unlock(ProxiedPlayer p) {
|
public void unlock(Chatter sender) {
|
||||||
BauLock.setLocked(p, BauLockState.OPEN);
|
BauLock.setLocked(sender, BauLockState.OPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void withMember(Chatter owner, SteamwarUser member, Consumer<BauweltMember> function) {
|
private static void withMember(Chatter owner, SteamwarUser member, Consumer<BauweltMember> function) {
|
||||||
|
@ -20,10 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.sql.SWException;
|
import de.steamwar.sql.SWException;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
public class BugCommand extends SWCommand {
|
public class BugCommand extends SWCommand {
|
||||||
public BugCommand() {
|
public BugCommand() {
|
||||||
@ -31,10 +29,11 @@ public class BugCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void bugMessage(ProxiedPlayer player, String... message) {
|
public void bugMessage(Chatter sender, String... message) {
|
||||||
String server = player.getServer().getInfo().getName();
|
SWException.log(
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
String.join(" ", message),
|
||||||
SWException.log(String.join(" ", message), server + " " + player.getName() + " " + user.getId());
|
sender.withPlayerOrOffline(player -> player.getServer().getInfo().getName(), () -> "offline") + " " + sender.user().getUserName() + " " + sender.user().getId()
|
||||||
Chatter.of(player).system("BUG_MESSAGE");
|
);
|
||||||
|
sender.system("BUG_MESSAGE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,15 @@ import de.steamwar.command.PreviousArguments;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class BuilderCloudCommand extends SWCommand {
|
public class BuilderCloudCommand extends SWCommand {
|
||||||
@ -26,32 +27,32 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "create", description = "BUILDERCLOUD_CREATE_USAGE")
|
@Register(value = "create", description = "BUILDERCLOUD_CREATE_USAGE")
|
||||||
public void create(ProxiedPlayer player, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map, @OptionalValue("") @Mapper("generator") @AllowNull File generator) {
|
public void create(Chatter sender, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map, @OptionalValue("") @Mapper("generator") @AllowNull File generator) {
|
||||||
mapFile(version, map).mkdir();
|
mapFile(version, map).mkdir();
|
||||||
new ServerStarter().builder(version, map, generator).send(player).start();
|
sender.withPlayer(p -> new ServerStarter().builder(version, map, generator).send(p).start());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "BUILDERCLOUD_USAGE")
|
@Register(description = "BUILDERCLOUD_USAGE")
|
||||||
public void start(ProxiedPlayer player, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map) {
|
public void start(PlayerChatter sender, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map) {
|
||||||
if(!mapFile(version, map).exists()) {
|
if(!mapFile(version, map).exists()) {
|
||||||
Chatter.of(player).system("BUILDERCLOUD_UNKNOWN_MAP");
|
sender.system("BUILDERCLOUD_UNKNOWN_MAP");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new ServerStarter().builder(version, map, null).send(player).start();
|
new ServerStarter().builder(version, map, null).send(sender.getPlayer()).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "rename", description = "BUILDERCLOUD_RENAME_USAGE")
|
@Register(value = "rename", description = "BUILDERCLOUD_RENAME_USAGE")
|
||||||
public void rename(ProxiedPlayer player, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String oldName, String newName) {
|
public void rename(Chatter sender, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String oldName, String newName) {
|
||||||
File oldMap = mapFile(version, oldName);
|
File oldMap = mapFile(version, oldName);
|
||||||
if(!oldMap.exists()) {
|
if(!oldMap.exists()) {
|
||||||
Chatter.of(player).system("BUILDERCLOUD_UNKNOWN_MAP");
|
sender.system("BUILDERCLOUD_UNKNOWN_MAP");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File newMap = mapFile(version, newName);
|
File newMap = mapFile(version, newName);
|
||||||
if(newMap.exists()) {
|
if(newMap.exists()) {
|
||||||
Chatter.of(player).system("BUILDERCLOUD_EXISTING_MAP");
|
sender.system("BUILDERCLOUD_EXISTING_MAP");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,20 +62,20 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
throw new SecurityException(e);
|
throw new SecurityException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Chatter.of(player).system("BUILDERCLOUD_RENAMED");
|
sender.system("BUILDERCLOUD_RENAMED");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "deploy", description = "BUILDERCLOUD_DEPLOY_USAGE")
|
@Register(value = "deploy", description = "BUILDERCLOUD_DEPLOY_USAGE")
|
||||||
public void deploy(ProxiedPlayer player, @Mapper("nonHistoricArenaMode") ArenaMode arenaMode, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map) {
|
public void deploy(Chatter sender, @Mapper("nonHistoricArenaMode") ArenaMode arenaMode, @ErrorMessage("BUILDERCLOUD_VERSION") ServerVersion version, @Mapper("map") String map) {
|
||||||
if(!mapFile(version, map).exists()) {
|
if(!mapFile(version, map).exists()) {
|
||||||
Chatter.of(player).system("BUILDERCLOUD_UNKNOWN_MAP");
|
sender.system("BUILDERCLOUD_UNKNOWN_MAP");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
BungeeCore.local.execute("/binarys/deployarena.py", arenaMode.getConfig(), Integer.toString(version.getVersionSuffix()), map);
|
BungeeCore.local.execute("/binarys/deployarena.py", arenaMode.getConfig(), Integer.toString(version.getVersionSuffix()), map);
|
||||||
ArenaMode.init();
|
ArenaMode.init();
|
||||||
Chatter.of(player).system("BUILDERCLOUD_DEPLOY_FINISHED");
|
sender.system("BUILDERCLOUD_DEPLOY_FINISHED");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,13 +85,13 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
|
|
||||||
return new TypeMapper<String>() {
|
return new TypeMapper<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
public String map(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
File folder = getWorldFolder(previousArguments.userArgs, 1);
|
File folder = getWorldFolder(previousArguments, 1);
|
||||||
|
|
||||||
String[] files;
|
String[] files;
|
||||||
if(folder == null || (files = folder.list()) == null)
|
if(folder == null || (files = folder.list()) == null)
|
||||||
@ -107,7 +108,7 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
|
|
||||||
return new TypeMapper<File>() {
|
return new TypeMapper<File>() {
|
||||||
@Override
|
@Override
|
||||||
public File map(CommandSender commandSender, String[] previousArguments, String s) {
|
public File map(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
if(s.isEmpty())
|
if(s.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@ -124,8 +125,8 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
File folder = getWorldFolder(previousArguments.userArgs, 2);
|
File folder = getWorldFolder(previousArguments, 2);
|
||||||
|
|
||||||
String[] files;
|
String[] files;
|
||||||
if(folder == null || (files = folder.list()) == null)
|
if(folder == null || (files = folder.list()) == null)
|
||||||
@ -140,8 +141,8 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
return new File(version.getWorldFolder(ServerStarter.BUILDER_BASE_PATH), map);
|
return new File(version.getWorldFolder(ServerStarter.BUILDER_BASE_PATH), map);
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getWorldFolder(String[] previousArguments, int offset) {
|
private File getWorldFolder(PreviousArguments previousArguments, int offset) {
|
||||||
ServerVersion v = ServerVersion.get(previousArguments[previousArguments.length - offset]);
|
ServerVersion v = ServerVersion.get(previousArguments.userArgs[previousArguments.userArgs.length - offset]);
|
||||||
if(v == null)
|
if(v == null)
|
||||||
return null;
|
return null;
|
||||||
return new File(v.getWorldFolder(ServerStarter.BUILDER_BASE_PATH));
|
return new File(v.getWorldFolder(ServerStarter.BUILDER_BASE_PATH));
|
||||||
|
@ -21,6 +21,7 @@ package de.steamwar.bungeecore.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import de.steamwar.sql.IgnoreSystem;
|
import de.steamwar.sql.IgnoreSystem;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
@ -38,13 +39,14 @@ public class ChallengeCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "CHALLENGE_USAGE")
|
@Register(description = "CHALLENGE_USAGE")
|
||||||
public void challenge(@Validator("arenaPlayer") ProxiedPlayer player, @Validator("target") ProxiedPlayer target, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
public void challenge(@Validator("arenaPlayer") PlayerChatter sender, @Validator("target") ProxiedPlayer target, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||||
FightCommand.createArena(player, "/challenge " + target.getName() + " ", false, arenaMode, map, false, (p, mode, m) -> {
|
FightCommand.createArena(sender, "/challenge " + target.getName() + " ", false, arenaMode, map, false, (chatter, mode, m) -> {
|
||||||
|
ProxiedPlayer p = sender.getPlayer();
|
||||||
if(challenges.containsKey(target) && challenges.get(target).contains(p)){
|
if(challenges.containsKey(target) && challenges.get(target).contains(p)){
|
||||||
challenges.remove(target);
|
challenges.remove(target);
|
||||||
challenges.remove(p);
|
challenges.remove(p);
|
||||||
|
|
||||||
new ServerStarter().arena(mode, map).blueLeader(player).redLeader(target).callback(
|
new ServerStarter().arena(mode, map).blueLeader(sender.getPlayer()).redLeader(target).callback(
|
||||||
arena -> Chatter.broadcast().system("CHALLENGE_BROADCAST", "CHALLENGE_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName(), target.getName())
|
arena -> Chatter.broadcast().system("CHALLENGE_BROADCAST", "CHALLENGE_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName(), target.getName())
|
||||||
).start();
|
).start();
|
||||||
}else{
|
}else{
|
||||||
@ -54,7 +56,7 @@ public class ChallengeCommand extends SWCommand {
|
|||||||
|
|
||||||
challenges.get(p).add(target);
|
challenges.get(p).add(target);
|
||||||
|
|
||||||
Chatter.of(p).system("CHALLENGE_CHALLENGED", target.getName(), mode.getDisplayName());
|
sender.system("CHALLENGE_CHALLENGED", target.getName(), mode.getDisplayName());
|
||||||
Chatter.of(target).system("CHALLENGE_CHALLENGED_TARGET", p.getName(), mode.getDisplayName(), mode.getMaps().size() != 1 ? new Message("CHALLENGE_CHALLENGED_MAP", m) : "");
|
Chatter.of(target).system("CHALLENGE_CHALLENGED_TARGET", p.getName(), mode.getDisplayName(), mode.getMaps().size() != 1 ? new Message("CHALLENGE_CHALLENGED_MAP", m) : "");
|
||||||
|
|
||||||
Chatter.of(target).system("CHALLENGE_ACCEPT", new Message("CHALLENGE_ACCEPT_HOVER"), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/challenge " + p.getName() + " " + mode.getChatName() + " " + m));
|
Chatter.of(target).system("CHALLENGE_ACCEPT", new Message("CHALLENGE_ACCEPT_HOVER"), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/challenge " + p.getName() + " " + mode.getChatName() + " " + m));
|
||||||
@ -66,21 +68,21 @@ public class ChallengeCommand extends SWCommand {
|
|||||||
public TypeValidator<ProxiedPlayer> targetValidator() {
|
public TypeValidator<ProxiedPlayer> targetValidator() {
|
||||||
return (sender, value, messageSender) -> {
|
return (sender, value, messageSender) -> {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
messageSender.send("CHALLENGE_OFFLINE");
|
sender.system("CHALLENGE_OFFLINE");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (sender == value) {
|
if (sender == value) {
|
||||||
messageSender.send("CHALLENGE_SELF");
|
sender.system("CHALLENGE_SELF");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (IgnoreSystem.isIgnored(value.getUniqueId(), ((ProxiedPlayer) sender).getUniqueId())) {
|
if (IgnoreSystem.isIgnored(value.getUniqueId(), sender.user().getUUID())) {
|
||||||
messageSender.send("CHALLENGE_IGNORED");
|
sender.system("CHALLENGE_IGNORED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Subserver subserver = Subserver.getSubserver(value);
|
Subserver subserver = Subserver.getSubserver(value);
|
||||||
if (subserver != null && subserver.getType() == Servertype.ARENA) {
|
if (subserver != null && subserver.getType() == Servertype.ARENA) {
|
||||||
messageSender.send("CHALLENGE_INARENA");
|
sender.system("CHALLENGE_INARENA");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -24,6 +24,7 @@ import de.steamwar.bungeecore.bot.util.DiscordAlert;
|
|||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.*;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
@ -79,11 +80,10 @@ public class CheckCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "list", description = "CHECK_HELP_LIST")
|
@Register(value = "list", description = "CHECK_HELP_LIST")
|
||||||
public void list(ProxiedPlayer player) {
|
public void list(Chatter sender) {
|
||||||
Chatter chatter = Chatter.of(player);
|
|
||||||
List<SchematicNode> schematicList = getSchemsToCheck();
|
List<SchematicNode> schematicList = getSchemsToCheck();
|
||||||
|
|
||||||
chatter.prefixless("CHECK_LIST_HEADER", schematicList.size());
|
sender.system("CHECK_LIST_HEADER", schematicList.size());
|
||||||
|
|
||||||
for (SchematicNode schematic : schematicList) {
|
for (SchematicNode schematic : schematicList) {
|
||||||
CheckSession current = currentSchems.get(schematic.getId());
|
CheckSession current = currentSchems.get(schematic.getId());
|
||||||
@ -91,15 +91,15 @@ public class CheckCommand extends SWCommand {
|
|||||||
String color = waitedMillis > 14400000 ? (waitedMillis > 86400000 ? "c" : "e") : "a";
|
String color = waitedMillis > 14400000 ? (waitedMillis > 86400000 ? "c" : "e") : "a";
|
||||||
long hours = waitedMillis / 3600000;
|
long hours = waitedMillis / 3600000;
|
||||||
long minutes = (waitedMillis - hours * 3600000) / 60000;
|
long minutes = (waitedMillis - hours * 3600000) / 60000;
|
||||||
Message waitTime = new Message("CHECK_LIST_WAIT", player, color, hours, (minutes < 10) ? "0" + minutes : minutes);
|
Message waitTime = new Message("CHECK_LIST_WAIT", color, hours, (minutes < 10) ? "0" + minutes : minutes);
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
chatter.prefixless("CHECK_LIST_TO_CHECK",
|
sender.prefixless("CHECK_LIST_TO_CHECK",
|
||||||
new Message("CHECK_LIST_TO_CHECK_HOVER"),
|
new Message("CHECK_LIST_TO_CHECK_HOVER"),
|
||||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getId()),
|
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getId()),
|
||||||
waitTime,
|
waitTime,
|
||||||
schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName());
|
schematic.getSchemtype().getKuerzel(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getName());
|
||||||
} else {
|
} else {
|
||||||
chatter.prefixless("CHECK_LIST_CHECKING",
|
sender.prefixless("CHECK_LIST_CHECKING",
|
||||||
new Message("CHECK_LIST_CHECKING_HOVER"),
|
new Message("CHECK_LIST_CHECKING_HOVER"),
|
||||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + current.checker.user().getUserName()),
|
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + current.checker.user().getUserName()),
|
||||||
waitTime,
|
waitTime,
|
||||||
@ -109,35 +109,33 @@ public class CheckCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "schematic", noTabComplete = true)
|
@Register(value = "schematic", noTabComplete = true)
|
||||||
public void schematic(ProxiedPlayer player, String schemID) {
|
public void schematic(PlayerChatter sender, String schemID) {
|
||||||
Chatter chatter = Chatter.of(player);
|
if(isChecking(sender.getPlayer())){
|
||||||
if(isChecking(player)){
|
sender.system("CHECK_SCHEMATIC_ALREADY_CHECKING");
|
||||||
chatter.system("CHECK_SCHEMATIC_ALREADY_CHECKING");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser checkingUser = SteamwarUser.get(player.getUniqueId());
|
|
||||||
SchematicNode schem = SchematicNode.getSchematicNode(Integer.parseInt(schemID));
|
SchematicNode schem = SchematicNode.getSchematicNode(Integer.parseInt(schemID));
|
||||||
if(!schem.getSchemtype().check()){
|
if(!schem.getSchemtype().check()){
|
||||||
ProxyServer.getInstance().getLogger().log(Level.SEVERE, () -> player.getName() + " tried to check an uncheckable schematic!");
|
ProxyServer.getInstance().getLogger().log(Level.SEVERE, () -> sender.user().getUserName() + " tried to check an uncheckable schematic!");
|
||||||
return;
|
return;
|
||||||
}else if(schem.getOwner() == checkingUser.getId()) {
|
}else if(schem.getOwner() == sender.user().getId()) {
|
||||||
chatter.system("CHECK_SCHEMATIC_OWN");
|
sender.system("CHECK_SCHEMATIC_OWN");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int playerTeam = checkingUser.hasPerm(UserPerm.MODERATION) ? 0 : checkingUser.getTeam();
|
int playerTeam = sender.user().hasPerm(UserPerm.MODERATION) ? 0 : sender.user().getTeam();
|
||||||
if (playerTeam != 0 && SteamwarUser.get(schem.getOwner()).getTeam() == playerTeam) {
|
if (playerTeam != 0 && SteamwarUser.get(schem.getOwner()).getTeam() == playerTeam) {
|
||||||
chatter.system("CHECK_SCHEMATIC_OWN_TEAM");
|
sender.system("CHECK_SCHEMATIC_OWN_TEAM");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new CheckSession(chatter, schem);
|
new CheckSession(sender, schem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "cancel", description = "CHECK_HELP_CANCEL")
|
@Register(value = "cancel", description = "CHECK_HELP_CANCEL")
|
||||||
@Register("abort")
|
@Register("abort")
|
||||||
public void abortCommand(ProxiedPlayer player) {
|
public void abortCommand(PlayerChatter sender) {
|
||||||
abort(player);
|
abort(sender.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void abort(ProxiedPlayer player) {
|
public static void abort(ProxiedPlayer player) {
|
||||||
@ -149,24 +147,24 @@ public class CheckCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "next", description = "CHECK_HELP_NEXT")
|
@Register(value = "next", description = "CHECK_HELP_NEXT")
|
||||||
public void next(ProxiedPlayer player) {
|
public void next(PlayerChatter sender) {
|
||||||
if(notChecking(player))
|
if(notChecking(sender.getPlayer()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
currentCheckers.get(player.getUniqueId()).next();
|
currentCheckers.get(sender.getPlayer().getUniqueId()).next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "accept")
|
@Register(value = "accept")
|
||||||
public void accept(ProxiedPlayer player, @OptionalValue("") String rank) {
|
public void accept(PlayerChatter sender) {
|
||||||
next(player);
|
next(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "decline", description = "CHECK_HELP_DECLINE")
|
@Register(value = "decline", description = "CHECK_HELP_DECLINE")
|
||||||
public void decline(ProxiedPlayer player, String... message) {
|
public void decline(PlayerChatter sender, String... message) {
|
||||||
if(notChecking(player))
|
if(notChecking(sender.getPlayer()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
currentCheckers.get(player.getUniqueId()).decline(String.join(" ", message));
|
currentCheckers.get(sender.getPlayer().getUniqueId()).decline(String.join(" ", message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SchematicNode> getSchemsToCheck(){
|
public static List<SchematicNode> getSchemsToCheck(){
|
||||||
@ -193,20 +191,20 @@ public class CheckCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class CheckSession{
|
private static class CheckSession{
|
||||||
private final Chatter checker;
|
private final PlayerChatter checker;
|
||||||
private final SchematicNode schematic;
|
private final SchematicNode schematic;
|
||||||
private final Timestamp startTime;
|
private final Timestamp startTime;
|
||||||
private final ListIterator<String> checkList;
|
private final ListIterator<String> checkList;
|
||||||
|
|
||||||
private CheckSession(Chatter checker, SchematicNode schematic){
|
private CheckSession(PlayerChatter checker, SchematicNode schematic){
|
||||||
this.checker = checker;
|
this.checker = checker;
|
||||||
this.schematic = schematic;
|
this.schematic = schematic;
|
||||||
this.startTime = Timestamp.from(Instant.now());
|
this.startTime = Timestamp.from(Instant.now());
|
||||||
this.checkList = checkQuestions.get(schematic.getSchemtype()).listIterator();
|
this.checkList = checkQuestions.get(schematic.getSchemtype()).listIterator();
|
||||||
|
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> checker.withPlayer(player -> {
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
ArenaMode mode = ArenaMode.getBySchemType(fightTypes.get(schematic.getSchemtype()));
|
ArenaMode mode = ArenaMode.getBySchemType(fightTypes.get(schematic.getSchemtype()));
|
||||||
if(!new ServerStarter().test(mode, mode.getRandomMap(), player).check(schematic.getId()).start()) {
|
if(!new ServerStarter().test(mode, mode.getRandomMap(), checker.getPlayer()).check(schematic.getId()).start()) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -216,7 +214,7 @@ public class CheckCommand extends SWCommand {
|
|||||||
for(CheckedSchematic previous : CheckedSchematic.previousChecks(schematic))
|
for(CheckedSchematic previous : CheckedSchematic.previousChecks(schematic))
|
||||||
checker.prefixless("CHECK_SCHEMATIC_PREVIOUS", previous.getEndTime(), SteamwarUser.get(previous.getValidator()).getUserName(), previous.getDeclineReason());
|
checker.prefixless("CHECK_SCHEMATIC_PREVIOUS", previous.getEndTime(), SteamwarUser.get(previous.getValidator()).getUserName(), previous.getDeclineReason());
|
||||||
next();
|
next();
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void next() {
|
private void next() {
|
||||||
@ -248,9 +246,9 @@ public class CheckCommand extends SWCommand {
|
|||||||
private void accept(){
|
private void accept(){
|
||||||
if(concludeCheckSession("freigegeben", fightTypes.get(schematic.getSchemtype()))) {
|
if(concludeCheckSession("freigegeben", fightTypes.get(schematic.getSchemtype()))) {
|
||||||
Chatter owner = Chatter.of(SteamwarUser.get(schematic.getOwner()).getUUID());
|
Chatter owner = Chatter.of(SteamwarUser.get(schematic.getOwner()).getUUID());
|
||||||
owner.withPlayerOrDiscord(
|
owner.withPlayerOrOffline(
|
||||||
player -> owner.system("CHECK_ACCEPTED", schematic.getSchemtype().name(), schematic.getName()),
|
player -> owner.system("CHECK_ACCEPTED", schematic.getSchemtype().name(), schematic.getName()),
|
||||||
user -> DiscordAlert.send(owner, Color.GREEN, new Message("DC_TITLE_SCHEMINFO"), new Message("DC_SCHEM_ACCEPT", schematic.getName()), true)
|
() -> DiscordAlert.send(owner, Color.GREEN, new Message("DC_TITLE_SCHEMINFO"), new Message("DC_SCHEM_ACCEPT", schematic.getName()), true)
|
||||||
);
|
);
|
||||||
Chatter.serverteam().system("CHECK_ACCEPTED_TEAM", schematic.getName(), owner.user().getUserName());
|
Chatter.serverteam().system("CHECK_ACCEPTED_TEAM", schematic.getName(), owner.user().getUserName());
|
||||||
}
|
}
|
||||||
@ -259,9 +257,9 @@ public class CheckCommand extends SWCommand {
|
|||||||
private void decline(String reason){
|
private void decline(String reason){
|
||||||
if(concludeCheckSession(reason, SchematicType.Normal)) {
|
if(concludeCheckSession(reason, SchematicType.Normal)) {
|
||||||
Chatter owner = Chatter.of(SteamwarUser.get(schematic.getOwner()).getUUID());
|
Chatter owner = Chatter.of(SteamwarUser.get(schematic.getOwner()).getUUID());
|
||||||
owner.withPlayerOrDiscord(
|
owner.withPlayerOrOffline(
|
||||||
player -> owner.system("CHECK_DECLINED", schematic.getSchemtype().name(), schematic.getName(), reason),
|
player -> owner.system("CHECK_DECLINED", schematic.getSchemtype().name(), schematic.getName(), reason),
|
||||||
user -> DiscordAlert.send(owner, Color.RED, new Message("DC_TITLE_SCHEMINFO"), new Message("DC_SCHEM_DECLINE", schematic.getName(), reason), false)
|
() -> DiscordAlert.send(owner, Color.RED, new Message("DC_TITLE_SCHEMINFO"), new Message("DC_SCHEM_DECLINE", schematic.getName(), reason), false)
|
||||||
);
|
);
|
||||||
Chatter.serverteam().system("CHECK_DECLINED_TEAM", schematic.getName(), owner.user().getUserName(), reason);
|
Chatter.serverteam().system("CHECK_DECLINED_TEAM", schematic.getName(), owner.user().getUserName(), reason);
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,15 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.SWCommandUtils;
|
||||||
|
import de.steamwar.command.TypeMapper;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import de.steamwar.sql.Punishment;
|
import de.steamwar.sql.Punishment;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.command.*;
|
|
||||||
import de.steamwar.messages.Chatter;
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
@ -43,46 +44,42 @@ public class DevCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void simpleCommand(@Validator ProxiedPlayer player) {
|
public void simpleCommand(@Validator PlayerChatter sender) {
|
||||||
updateDevServers();
|
updateDevServers();
|
||||||
Chatter sender = Chatter.of(player);
|
|
||||||
if (devServers.isEmpty()) {
|
if (devServers.isEmpty()) {
|
||||||
sender.system("DEV_NO_SERVER");
|
sender.system("DEV_NO_SERVER");
|
||||||
return;
|
return;
|
||||||
} else if (devServers.size() == 1) {
|
} else if (devServers.size() == 1) {
|
||||||
player.connect(devServers.values().stream().findAny().get());
|
sender.getPlayer().connect(devServers.values().stream().findAny().get());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInfo info = devServers.get(player.getName().toLowerCase());
|
ServerInfo info = devServers.get(sender.getPlayer().getName().toLowerCase());
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
sender.system("DEV_UNKNOWN_SERVER");
|
sender.system("DEV_UNKNOWN_SERVER");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.connect(info);
|
sender.getPlayer().connect(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void selectedCommand(@Validator ProxiedPlayer player, @Mapper("dev") String name) {
|
public void selectedCommand(@Validator PlayerChatter sender, @Mapper("dev") String name) {
|
||||||
updateDevServers();
|
updateDevServers();
|
||||||
Chatter sender = Chatter.of(player);
|
|
||||||
ServerInfo info = devServers.get(name.toLowerCase());
|
ServerInfo info = devServers.get(name.toLowerCase());
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
sender.system("DEV_NO_SERVER");
|
sender.system("DEV_NO_SERVER");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.connect(info);
|
sender.getPlayer().connect(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(value = ProxiedPlayer.class, local = true)
|
@ClassValidator(value = PlayerChatter.class, local = true)
|
||||||
public TypeValidator<ProxiedPlayer> punishmentGuardChecker() {
|
public TypeValidator<PlayerChatter> punishmentGuardChecker() {
|
||||||
return (sender, value, messageSender) -> {
|
return (sender, value, messageSender) -> {
|
||||||
SteamwarUser user = SteamwarUser.get(value.getUniqueId());
|
if (sender.user().isPunished(Punishment.PunishmentType.NoDevServer)) {
|
||||||
if (user.isPunished(Punishment.PunishmentType.NoDevServer)) {
|
sender.system(PunishmentCommand.punishmentMessage(sender.user(), Punishment.PunishmentType.NoDevServer));
|
||||||
Message message = PunishmentCommand.punishmentMessage(user, Punishment.PunishmentType.NoDevServer);
|
|
||||||
messageSender.send(message.getFormat(), message.getParams());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -25,9 +25,8 @@ import de.steamwar.bungeecore.SubserverSystem;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.*;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
@ -42,80 +41,77 @@ public class EventCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Validator("noEvent")
|
@Validator("noEvent")
|
||||||
public TypeValidator<ProxiedPlayer> noEventValidator() {
|
public TypeValidator<Chatter> noEventValidator() {
|
||||||
return (sender, value, messageSender) -> Event.get() == null;
|
return (sender, value, messageSender) -> Event.get() == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void noCurrentEvent(@Validator("noEvent") CommandSender sender) {
|
public void noCurrentEvent(@Validator("noEvent") Chatter sender) {
|
||||||
Chatter player = Chatter.of(sender);
|
sender.system("EVENT_NO_CURRENT");
|
||||||
player.system("EVENT_NO_CURRENT");
|
|
||||||
|
|
||||||
List<Event> coming = Event.getComing();
|
List<Event> coming = Event.getComing();
|
||||||
if(coming.isEmpty())
|
if(coming.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
player.system("EVENT_COMING");
|
sender.system("EVENT_COMING");
|
||||||
|
|
||||||
Instant now = Instant.now();
|
Instant now = Instant.now();
|
||||||
DateTimeFormatter format = DateTimeFormatter.ofPattern(player.parseToPlain("EVENT_DATE_FORMAT"));
|
DateTimeFormatter format = DateTimeFormatter.ofPattern(sender.parseToPlain("EVENT_DATE_FORMAT"));
|
||||||
for(Event e : coming){
|
for(Event e : coming){
|
||||||
player.prefixless("EVENT_COMING_EVENT", e.getStart().toLocalDateTime().format(format), e.getEnd().toLocalDateTime().format(format), e.getEventName());
|
sender.prefixless("EVENT_COMING_EVENT", e.getStart().toLocalDateTime().format(format), e.getEnd().toLocalDateTime().format(format), e.getEventName());
|
||||||
|
|
||||||
if(now.isBefore(e.getDeadline().toInstant()))
|
if(now.isBefore(e.getDeadline().toInstant()))
|
||||||
player.prefixless("EVENT_COMING_DEADLINE", e.getDeadline());
|
sender.prefixless("EVENT_COMING_DEADLINE", e.getDeadline());
|
||||||
|
|
||||||
SchematicType schemType = e.getSchematicType();
|
SchematicType schemType = e.getSchematicType();
|
||||||
if (schemType != null && schemType.getDeadline() != null && now.isBefore(schemType.getDeadline().toInstant()))
|
if (schemType != null && schemType.getDeadline() != null && now.isBefore(schemType.getDeadline().toInstant()))
|
||||||
player.prefixless("EVENT_COMING_SCHEM_DEADLINE", schemType.getDeadline());
|
sender.prefixless("EVENT_COMING_SCHEM_DEADLINE", schemType.getDeadline());
|
||||||
|
|
||||||
Set<Team> teams = TeamTeilnahme.getTeams(e.getEventID());
|
Set<Team> teams = TeamTeilnahme.getTeams(e.getEventID());
|
||||||
if(!teams.isEmpty())
|
if(!teams.isEmpty())
|
||||||
player.prefixless("EVENT_COMING_TEAMS", teams.stream().map(team -> player.parseToLegacy("EVENT_COMING_TEAM", team.getTeamColor(), team.getTeamKuerzel())).collect(Collectors.joining(" ")));
|
sender.prefixless("EVENT_COMING_TEAMS", teams.stream().map(team -> sender.parseToLegacy("EVENT_COMING_TEAM", team.getTeamColor(), team.getTeamKuerzel())).collect(Collectors.joining(" ")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void eventOverview(@Validator(value = "noEvent", invert = true) CommandSender sender) {
|
public void eventOverview(@Validator(value = "noEvent", invert = true) Chatter sender) {
|
||||||
Chatter player = Chatter.of(sender);
|
sender.system("EVENT_USAGE");
|
||||||
player.system("EVENT_USAGE");
|
|
||||||
|
|
||||||
Event currentEvent = Event.get();
|
Event currentEvent = Event.get();
|
||||||
player.system("EVENT_CURRENT_EVENT", currentEvent.getEventName());
|
sender.system("EVENT_CURRENT_EVENT", currentEvent.getEventName());
|
||||||
|
|
||||||
DateTimeFormatter format = DateTimeFormatter.ofPattern(player.parseToPlain("EVENT_TIME_FORMAT"));
|
DateTimeFormatter format = DateTimeFormatter.ofPattern(sender.parseToPlain("EVENT_TIME_FORMAT"));
|
||||||
for(EventFight fight : EventFight.getEvent(currentEvent.getEventID())){
|
for(EventFight fight : EventFight.getEvent(currentEvent.getEventID())){
|
||||||
Team blue = Team.get(fight.getTeamBlue());
|
Team blue = Team.get(fight.getTeamBlue());
|
||||||
Team red = Team.get(fight.getTeamRed());
|
Team red = Team.get(fight.getTeamRed());
|
||||||
StringBuilder fline = new StringBuilder(player.parseToLegacy("EVENT_CURRENT_FIGHT", fight.getStartTime().toLocalDateTime().format(format), blue.getTeamColor(), blue.getTeamKuerzel(), red.getTeamColor(), red.getTeamKuerzel()));
|
StringBuilder fline = new StringBuilder(sender.parseToLegacy("EVENT_CURRENT_FIGHT", fight.getStartTime().toLocalDateTime().format(format), blue.getTeamColor(), blue.getTeamKuerzel(), red.getTeamColor(), red.getTeamKuerzel()));
|
||||||
|
|
||||||
if(fight.hasFinished()){
|
if(fight.hasFinished()){
|
||||||
switch(fight.getErgebnis()){
|
switch(fight.getErgebnis()){
|
||||||
case 1:
|
case 1:
|
||||||
fline.append(player.parseToLegacy("EVENT_CURRENT_FIGHT_WIN", blue.getTeamColor(), blue.getTeamKuerzel()));
|
fline.append(sender.parseToLegacy("EVENT_CURRENT_FIGHT_WIN", blue.getTeamColor(), blue.getTeamKuerzel()));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
fline.append(player.parseToLegacy("EVENT_CURRENT_FIGHT_WIN", red.getTeamColor(), red.getTeamKuerzel()));
|
fline.append(sender.parseToLegacy("EVENT_CURRENT_FIGHT_WIN", red.getTeamColor(), red.getTeamKuerzel()));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fline.append(player.parseToLegacy("EVENT_CURRENT_FIGHT_DRAW"));
|
fline.append(sender.parseToLegacy("EVENT_CURRENT_FIGHT_DRAW"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.prefixless("PLAIN_STRING", fline.toString());
|
sender.prefixless("PLAIN_STRING", fline.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void eventWithTeam(@Validator(value = "noEvent", invert = true) ProxiedPlayer player, @ErrorMessage("EVENT_NO_TEAM") Team team) {
|
public void eventWithTeam(@Validator(value = "noEvent", invert = true) PlayerChatter sender, @ErrorMessage("EVENT_NO_TEAM") Team team) {
|
||||||
Chatter sender = Chatter.of(player);
|
|
||||||
Subserver eventArena = EventStarter.getEventServer().get(team.getTeamId());
|
Subserver eventArena = EventStarter.getEventServer().get(team.getTeamId());
|
||||||
if(eventArena == null || !Subserver.getServerList().contains(eventArena)){
|
if(eventArena == null || !Subserver.getServerList().contains(eventArena)){
|
||||||
sender.system("EVENT_NO_FIGHT_TEAM");
|
sender.system("EVENT_NO_FIGHT_TEAM");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) {
|
if (!PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) {
|
||||||
SubserverSystem.sendPlayer(eventArena, player);
|
SubserverSystem.sendPlayer(eventArena, sender.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import de.steamwar.messages.Chatter;
|
|||||||
import de.steamwar.sql.Event;
|
import de.steamwar.sql.Event;
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.sql.EventFight;
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.sql.Team;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -39,12 +38,10 @@ public class EventRescheduleCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void reschedule(CommandSender sender, Team teamBlue, Team teamRed) {
|
public void reschedule(Chatter sender, Team teamBlue, Team teamRed) {
|
||||||
Chatter player = Chatter.of(sender);
|
|
||||||
|
|
||||||
Event event = Event.get();
|
Event event = Event.get();
|
||||||
if(event == null){
|
if(event == null){
|
||||||
player.system("EVENTRESCHEDULE_UNKNOWN_TEAM");
|
sender.system("EVENTRESCHEDULE_UNKNOWN_TEAM");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,13 +54,13 @@ public class EventRescheduleCommand extends SWCommand {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(fight.getTeamBlue() == teamBlue.getTeamId() && fight.getTeamRed() == teamRed.getTeamId()){
|
if(fight.getTeamBlue() == teamBlue.getTeamId() && fight.getTeamRed() == teamRed.getTeamId()){
|
||||||
player.system("EVENTRESCHEDULE_STARTING");
|
sender.system("EVENTRESCHEDULE_STARTING");
|
||||||
fight.reschedule();
|
fight.reschedule();
|
||||||
EventFight.loadAllComingFights();
|
EventFight.loadAllComingFights();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.system("EVENTRESCHEDULE_NO_FIGHT");
|
sender.system("EVENTRESCHEDULE_NO_FIGHT");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||||
import de.steamwar.sql.EventFight;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.sql.EventFight;
|
||||||
|
|
||||||
public class EventreloadCommand extends SWCommand {
|
public class EventreloadCommand extends SWCommand {
|
||||||
public EventreloadCommand() {
|
public EventreloadCommand() {
|
||||||
@ -30,7 +30,7 @@ public class EventreloadCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void execute(CommandSender sender) {
|
public void execute(Chatter sender) {
|
||||||
EventFight.loadAllComingFights();
|
EventFight.loadAllComingFights();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import de.steamwar.bungeecore.inventory.SWInventory;
|
|||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@ -58,20 +59,18 @@ public class FightCommand extends SWCommand {
|
|||||||
sender.sendMessage(ChatMessageType.SYSTEM, start);
|
sender.sendMessage(ChatMessageType.SYSTEM, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean alreadyInArena(ProxiedPlayer player){
|
private static boolean alreadyInArena(PlayerChatter sender){
|
||||||
Subserver subserver = Subserver.getSubserver(player);
|
Subserver subserver = Subserver.getSubserver(sender.getPlayer());
|
||||||
if(subserver != null && subserver.getType() == Servertype.ARENA){
|
if(subserver != null && subserver.getType() == Servertype.ARENA){
|
||||||
Chatter.of(player).system("FIGHT_IN_ARENA");
|
sender.system("FIGHT_IN_ARENA");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createArena(ProxiedPlayer player, String precommand, boolean allowMerging, ArenaMode arenaMode, String map, boolean historic, FightCallback callback) {
|
static void createArena(PlayerChatter sender, String precommand, boolean allowMerging, ArenaMode arenaMode, String map, boolean historic, FightCallback callback) {
|
||||||
Chatter sender = Chatter.of(player);
|
if(alreadyInArena(sender))
|
||||||
|
|
||||||
if(alreadyInArena(player))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (arenaMode == null) {
|
if (arenaMode == null) {
|
||||||
@ -83,13 +82,13 @@ public class FightCommand extends SWCommand {
|
|||||||
map = arenaMode.getRandomMap();
|
map = arenaMode.getRandomMap();
|
||||||
|
|
||||||
if (!allowMerging) {
|
if (!allowMerging) {
|
||||||
callback.run(player, arenaMode, map);
|
callback.run(sender, arenaMode, map);
|
||||||
} else {
|
} else {
|
||||||
suggestMerging(player, arenaMode, map, callback);
|
suggestMerging(sender, arenaMode, map, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void suggestMerging(ProxiedPlayer player, ArenaMode mode, String map, FightCallback declineMerge) {
|
private static void suggestMerging(PlayerChatter sender, ArenaMode mode, String map, FightCallback declineMerge) {
|
||||||
Arenaserver mergable = null;
|
Arenaserver mergable = null;
|
||||||
synchronized (Subserver.getServerList()) {
|
synchronized (Subserver.getServerList()) {
|
||||||
for (Subserver subserver : Subserver.getServerList()) {
|
for (Subserver subserver : Subserver.getServerList()) {
|
||||||
@ -104,15 +103,14 @@ public class FightCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(mergable == null) {
|
if(mergable == null) {
|
||||||
declineMerge.run(player, mode, map);
|
declineMerge.run(sender, mode, map);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chatter chatter = Chatter.of(player);
|
SWInventory inventory = new SWInventory(sender, 9, new Message("FIGHT_MERGE_TITLE"));
|
||||||
SWInventory inventory = new SWInventory(chatter, 9, new Message("FIGHT_MERGE_TITLE"));
|
|
||||||
inventory.addItem(0, new SWItem(new Message("FIGHT_MERGE_DECLINE"), 1), click -> {
|
inventory.addItem(0, new SWItem(new Message("FIGHT_MERGE_DECLINE"), 1), click -> {
|
||||||
inventory.close();
|
inventory.close();
|
||||||
declineMerge.run(player, mode, map);
|
declineMerge.run(sender, mode, map);
|
||||||
});
|
});
|
||||||
Arenaserver finalMergable = mergable;
|
Arenaserver finalMergable = mergable;
|
||||||
SWItem item = new SWItem(new Message("FIGHT_MERGE_INFO", mode.getDisplayName(), finalMergable.getMap()), 11);
|
SWItem item = new SWItem(new Message("FIGHT_MERGE_INFO", mode.getDisplayName(), finalMergable.getMap()), 11);
|
||||||
@ -120,25 +118,25 @@ public class FightCommand extends SWCommand {
|
|||||||
inventory.addItem(4, item, click -> {});
|
inventory.addItem(4, item, click -> {});
|
||||||
inventory.addItem(8, new SWItem(new Message("FIGHT_MERGE_ACCEPT"), 10), click -> {
|
inventory.addItem(8, new SWItem(new Message("FIGHT_MERGE_ACCEPT"), 10), click -> {
|
||||||
if(Subserver.getServerList().contains(finalMergable)) {
|
if(Subserver.getServerList().contains(finalMergable)) {
|
||||||
finalMergable.sendPlayer(player);
|
finalMergable.sendPlayer(sender.getPlayer());
|
||||||
} else {
|
} else {
|
||||||
chatter.system("FIGHT_MERGE_OFFLINE");
|
sender.system("FIGHT_MERGE_OFFLINE");
|
||||||
declineMerge.run(player, mode, map);
|
declineMerge.run(sender, mode, map);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
inventory.open();
|
inventory.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void fight(@Validator("arenaPlayer") ProxiedPlayer player, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
public void fight(@Validator("arenaPlayer") PlayerChatter sender, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||||
createArena(player, "/fight ", true, arenaMode, map, false,
|
createArena(sender, "/fight ", true, arenaMode, map, false,
|
||||||
(p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p).callback(
|
(p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p.getPlayer()).callback(
|
||||||
arena -> Chatter.broadcast().system("FIGHT_BROADCAST", "FIGHT_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName())
|
arena -> Chatter.broadcast().system("FIGHT_BROADCAST", "FIGHT_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getPlayer().getName())
|
||||||
).start()
|
).start()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface FightCallback {
|
public interface FightCallback {
|
||||||
void run(ProxiedPlayer player, ArenaMode mode, String map);
|
void run(PlayerChatter player, ArenaMode mode, String map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||||
import de.steamwar.sql.internal.Statement;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import de.steamwar.sql.internal.Statement;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
@ -15,48 +16,42 @@ import java.util.zip.ZipOutputStream;
|
|||||||
public class GDPRQuery extends SWCommand {
|
public class GDPRQuery extends SWCommand {
|
||||||
|
|
||||||
public GDPRQuery() {
|
public GDPRQuery() {
|
||||||
super("gdprquery", "bungeecore.softreload");
|
super("gdprquery", ConnectionListener.SOFTRELOAD_PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void generate(ProxiedPlayer player) {
|
public void generate(PlayerChatter sender) {
|
||||||
generate(player, player);
|
generate(sender, sender.user());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void generate(ProxiedPlayer player, ProxiedPlayer forPlayer) {
|
public void generate(Chatter sender, SteamwarUser user) {
|
||||||
SteamwarUser user = SteamwarUser.get(forPlayer.getUniqueId());
|
|
||||||
if(user == null) {
|
|
||||||
Message.send("UNKNOWN_PLAYER", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BungeeCord.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
BungeeCord.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
try {
|
try {
|
||||||
createZip(player, user);
|
createZip(sender, user);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new SecurityException("Could not create zip", e);
|
throw new SecurityException("Could not create zip", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createZip(ProxiedPlayer player, SteamwarUser user) throws IOException {
|
private void createZip(Chatter sender, SteamwarUser user) throws IOException {
|
||||||
printUpdate(player, "GDPR_STATUS_WEBSITE");
|
sender.system("GDPR_STATUS_WEBSITE");
|
||||||
|
|
||||||
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(user.getUserName() + ".zip"));
|
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(user.getUserName() + ".zip"));
|
||||||
|
|
||||||
copy(getClass().getClassLoader().getResourceAsStream("GDPRQueryREADME.md"), out, "README.md");
|
copy(getClass().getClassLoader().getResourceAsStream("GDPRQueryREADME.md"), out, "README.md");
|
||||||
copy(getClass().getClassLoader().getResourceAsStream("GDPRQueryREADME.md"), out, "README.txt");
|
copy(getClass().getClassLoader().getResourceAsStream("GDPRQueryREADME.md"), out, "README.txt");
|
||||||
|
|
||||||
printUpdate(player, "GDPR_STATUS_WORLD");
|
sender.system("GDPR_STATUS_WORLD");
|
||||||
copyBauwelt(user, out, "/home/minecraft/userworlds/" + user.getUUID().toString(), "BuildWorld12");
|
copyBauwelt(user, out, "/home/minecraft/userworlds/" + user.getUUID().toString(), "BuildWorld12");
|
||||||
copyBauwelt(user, out, "/home/minecraft/userworlds15/" + user.getId(), "BuildWorld15");
|
copyBauwelt(user, out, "/home/minecraft/userworlds15/" + user.getId(), "BuildWorld15");
|
||||||
|
|
||||||
printUpdate(player, "GDPR_STATUS_INVENTORIES");
|
sender.system("GDPR_STATUS_INVENTORIES");
|
||||||
copyPlayerdata(user, out, "/home/minecraft/userworlds", "BuildInventories12");
|
copyPlayerdata(user, out, "/home/minecraft/userworlds", "BuildInventories12");
|
||||||
copyPlayerdata(user, out, "/home/minecraft/userworlds15", "BuildInventories15");
|
copyPlayerdata(user, out, "/home/minecraft/userworlds15", "BuildInventories15");
|
||||||
|
|
||||||
printUpdate(player, "GDPR_STATUS_DATABASE");
|
sender.system("GDPR_STATUS_DATABASE");
|
||||||
sqlCSV(user, out, bannedIPs, "BannedIPs.csv");
|
sqlCSV(user, out, bannedIPs, "BannedIPs.csv");
|
||||||
sqlCSV(user, out, bauweltMember, "BuildMember.csv");
|
sqlCSV(user, out, bauweltMember, "BuildMember.csv");
|
||||||
sqlCSV(user, out, bauweltMembers, "BuildMembers.csv");
|
sqlCSV(user, out, bauweltMembers, "BuildMembers.csv");
|
||||||
@ -78,11 +73,11 @@ public class GDPRQuery extends SWCommand {
|
|||||||
schematics(user, out);
|
schematics(user, out);
|
||||||
userConfig(user, out);
|
userConfig(user, out);
|
||||||
|
|
||||||
printUpdate(player, "GDPR_STATUS_LOGS");
|
sender.system("GDPR_STATUS_LOGS");
|
||||||
copyLogs(user, out, new File("/logs"), "logs");
|
copyLogs(user, out, new File("/logs"), "logs");
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
printUpdate(player, "GDPR_STATUS_FINISHED");
|
sender.system("GDPR_STATUS_FINISHED");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Statement bannedIPs = new Statement("SELECT Timestamp, IP FROM BannedUserIPs WHERE UserID = ?");
|
private static final Statement bannedIPs = new Statement("SELECT Timestamp, IP FROM BannedUserIPs WHERE UserID = ?");
|
||||||
@ -233,11 +228,6 @@ public class GDPRQuery extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printUpdate(ProxiedPlayer player, String message) {
|
|
||||||
if (player.isConnected())
|
|
||||||
Message.send(message, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void copy(File file, ZipOutputStream out, String path) throws IOException {
|
private void copy(File file, ZipOutputStream out, String path) throws IOException {
|
||||||
try(FileInputStream in = new FileInputStream(file)) {
|
try(FileInputStream in = new FileInputStream(file)) {
|
||||||
copy(in, out, path);
|
copy(in, out, path);
|
||||||
|
@ -23,7 +23,6 @@ import de.steamwar.bungeecore.Message;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
public class HelpCommand extends SWCommand {
|
public class HelpCommand extends SWCommand {
|
||||||
|
|
||||||
@ -32,9 +31,7 @@ public class HelpCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(ProxiedPlayer player) {
|
public void genericCommand(Chatter sender) {
|
||||||
Chatter sender = Chatter.of(player);
|
|
||||||
|
|
||||||
printPage(sender, ClickEvent.Action.RUN_COMMAND,
|
printPage(sender, ClickEvent.Action.RUN_COMMAND,
|
||||||
"HELP_LOBBY", "/l",
|
"HELP_LOBBY", "/l",
|
||||||
"HELP_BAU", "/build",
|
"HELP_BAU", "/build",
|
||||||
@ -48,33 +45,32 @@ public class HelpCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register({"build","world"})
|
@Register({"build","world"})
|
||||||
public void buildWorld(ProxiedPlayer player) {
|
public void buildWorld(Chatter sender) {
|
||||||
printPage(Chatter.of(player), "HELP_BAU_GROUP_WORLD_TITLE", "HELP_TNT", "HELP_FIRE", "HELP_FREEZE", "HELP_TPSLIMIT", "HELP_PROTECT", "HELP_RESET");
|
printPage(sender, "HELP_BAU_GROUP_WORLD_TITLE", "HELP_TNT", "HELP_FIRE", "HELP_FREEZE", "HELP_TPSLIMIT", "HELP_PROTECT", "HELP_RESET");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register({"build","player"})
|
@Register({"build","player"})
|
||||||
public void buildPlayer(ProxiedPlayer player) {
|
public void buildPlayer(Chatter sender) {
|
||||||
printPage(Chatter.of(player), "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_WV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER");
|
printPage(sender, "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_WV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register({"build","worldedit"})
|
@Register({"build","worldedit"})
|
||||||
@Register({"build","we"})
|
@Register({"build","we"})
|
||||||
@Register({"build","world-edit"})
|
@Register({"build","world-edit"})
|
||||||
@Register({"build","edit"})
|
@Register({"build","edit"})
|
||||||
public void buildWorldedit(ProxiedPlayer player) {
|
public void buildWorldedit(Chatter sender) {
|
||||||
printPage(Chatter.of(player), "HELP_BAU_GROUP_WE_TITLE", "HELP_WE_POS1", "HELP_WE_POS2", "HELP_WE_COPY", "HELP_WE_PASTE", "HELP_WE_FLOPY", "HELP_WE_FLOPYP", "HELP_WE_ROTATE_90", "HELP_WE_ROTATE_180", "HELP_WE_ROTATE_N90");
|
printPage(sender, "HELP_BAU_GROUP_WE_TITLE", "HELP_WE_POS1", "HELP_WE_POS2", "HELP_WE_COPY", "HELP_WE_PASTE", "HELP_WE_FLOPY", "HELP_WE_FLOPYP", "HELP_WE_ROTATE_90", "HELP_WE_ROTATE_180", "HELP_WE_ROTATE_N90");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register({"build","other"})
|
@Register({"build","other"})
|
||||||
public void buildOther(ProxiedPlayer player) {
|
public void buildOther(Chatter sender) {
|
||||||
Chatter sender = Chatter.of(player);
|
|
||||||
printPage(sender, "HELP_BAU_GROUP_OTHER_TITLE", "HELP_TESTBLOCK", "HELP_SKULL", "HELP_BAUINFO");
|
printPage(sender, "HELP_BAU_GROUP_OTHER_TITLE", "HELP_TESTBLOCK", "HELP_SKULL", "HELP_BAUINFO");
|
||||||
sender.prefixless("HELP_SCHEMSUBMIT", new Message("HELP_SCHEMSUBMIT_HOVER"), new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.youtube.com/watch?v=9QrQ3UBWveE"));
|
sender.prefixless("HELP_SCHEMSUBMIT", new Message("HELP_SCHEMSUBMIT_HOVER"), new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.youtube.com/watch?v=9QrQ3UBWveE"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("build")
|
@Register("build")
|
||||||
public void sendBauHelpGroup(ProxiedPlayer player) {
|
public void sendBauHelpGroup(Chatter sender) {
|
||||||
printPage(Chatter.of(player), ClickEvent.Action.RUN_COMMAND,
|
printPage(sender, ClickEvent.Action.RUN_COMMAND,
|
||||||
"HELP_BAU_GROUP_ADMIN", "/help build admin",
|
"HELP_BAU_GROUP_ADMIN", "/help build admin",
|
||||||
"HELP_BAU_GROUP_WORLD", "/help build world",
|
"HELP_BAU_GROUP_WORLD", "/help build world",
|
||||||
"HELP_BAU_GROUP_PLAYER", "/help build player",
|
"HELP_BAU_GROUP_PLAYER", "/help build player",
|
||||||
@ -86,8 +82,8 @@ public class HelpCommand extends SWCommand {
|
|||||||
@Register({"build","admin"})
|
@Register({"build","admin"})
|
||||||
@Register({"build","owner"})
|
@Register({"build","owner"})
|
||||||
@Register({"build","bauwelt"})
|
@Register({"build","bauwelt"})
|
||||||
public void sendBauHelp(ProxiedPlayer player) {
|
public void sendBauHelp(Chatter sender) {
|
||||||
printPage(Chatter.of(player), ClickEvent.Action.SUGGEST_COMMAND,
|
printPage(sender, ClickEvent.Action.SUGGEST_COMMAND,
|
||||||
"HELP_BAU_TP", "/build tp ",
|
"HELP_BAU_TP", "/build tp ",
|
||||||
"HELP_BAU_ADDMEMBER", "/build addmember ",
|
"HELP_BAU_ADDMEMBER", "/build addmember ",
|
||||||
"HELP_BAU_DELMEMBER", "/build delmember ",
|
"HELP_BAU_DELMEMBER", "/build delmember ",
|
||||||
|
@ -23,8 +23,8 @@ import de.steamwar.bungeecore.ArenaMode;
|
|||||||
import de.steamwar.bungeecore.ServerStarter;
|
import de.steamwar.bungeecore.ServerStarter;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
public class HistoricCommand extends SWCommand {
|
public class HistoricCommand extends SWCommand {
|
||||||
public HistoricCommand() {
|
public HistoricCommand() {
|
||||||
@ -32,9 +32,9 @@ public class HistoricCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void historic(@Validator("arenaPlayer") ProxiedPlayer player, @Mapper("historicArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
public void historic(@Validator("arenaPlayer") PlayerChatter player, @Mapper("historicArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||||
FightCommand.createArena(player, "/historic ", true, arenaMode, map, true, (p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p).callback(
|
FightCommand.createArena(player, "/historic ", true, arenaMode, map, true, (p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p.getPlayer()).callback(
|
||||||
arena -> Chatter.broadcast().system("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName())
|
arena -> Chatter.broadcast().system("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getPlayer().getName())
|
||||||
).start());
|
).start());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import de.steamwar.command.SWCommand;
|
|||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.sql.IgnoreSystem;
|
import de.steamwar.sql.IgnoreSystem;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
public class IgnoreCommand extends SWCommand {
|
public class IgnoreCommand extends SWCommand {
|
||||||
|
|
||||||
@ -32,8 +31,7 @@ public class IgnoreCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "USAGE_IGNORE")
|
@Register(description = "USAGE_IGNORE")
|
||||||
public void genericCommand(ProxiedPlayer p, @ErrorMessage("UNKNOWN_PLAYER") SteamwarUser target) {
|
public void genericCommand(Chatter player, @ErrorMessage("UNKNOWN_PLAYER") SteamwarUser target) {
|
||||||
Chatter player = Chatter.of(p);
|
|
||||||
SteamwarUser user = player.user();
|
SteamwarUser user = player.user();
|
||||||
|
|
||||||
if(target.equals(user)){
|
if(target.equals(user)){
|
||||||
|
@ -22,8 +22,8 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
public class JoinmeCommand extends SWCommand {
|
public class JoinmeCommand extends SWCommand {
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public class JoinmeCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(ProxiedPlayer player) {
|
public void genericCommand(PlayerChatter sender) {
|
||||||
Chatter.broadcast().system("JOINME_BROADCAST", "JOINME_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), player, player.getServer().getInfo().getName());
|
Chatter.broadcast().system("JOINME_BROADCAST", "JOINME_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + sender.getPlayer().getName()), sender, sender.getPlayer().getServer().getInfo().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
public class KickCommand extends SWCommand {
|
public class KickCommand extends SWCommand {
|
||||||
@ -32,12 +31,12 @@ public class KickCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "KICK_USAGE")
|
@Register(description = "KICK_USAGE")
|
||||||
public void genericCommand(CommandSender sender, @ErrorMessage("KICK_OFFLINE") ProxiedPlayer target, String... message) {
|
public void genericCommand(Chatter sender, @ErrorMessage("KICK_OFFLINE") ProxiedPlayer target, String... message) {
|
||||||
if (message.length == 0) {
|
if (message.length == 0) {
|
||||||
Chatter.disconnect(target).system("KICK_NORMAL");
|
Chatter.disconnect(target).system("KICK_NORMAL");
|
||||||
} else {
|
} else {
|
||||||
Chatter.disconnect(target).system("KICK_CUSTOM", String.join(" ", message));
|
Chatter.disconnect(target).system("KICK_CUSTOM", String.join(" ", message));
|
||||||
}
|
}
|
||||||
Chatter.of(sender).system("KICK_CONFIRM", target);
|
sender.system("KICK_CONFIRM", target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,16 +62,14 @@ public class ListCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void list(CommandSender sender) {
|
public void list(Chatter sender) {
|
||||||
Chatter chatter = Chatter.of(sender);
|
|
||||||
|
|
||||||
TreeMap<String, List<ProxiedPlayer>> playerMap = getCustomTablist();
|
TreeMap<String, List<ProxiedPlayer>> playerMap = getCustomTablist();
|
||||||
for (String server : playerMap.navigableKeySet()) {
|
for (String server : playerMap.navigableKeySet()) {
|
||||||
String serverName = server;
|
String serverName = server;
|
||||||
if (server.equals("Bau")) {
|
if (server.equals("Bau")) {
|
||||||
serverName = chatter.parseToLegacy("TABLIST_BAU");
|
serverName = sender.parseToLegacy("TABLIST_BAU");
|
||||||
}
|
}
|
||||||
chatter.prefixless("LIST_COMMAND", serverName, playerMap.get(server).stream().map(CommandSender::getName).collect(Collectors.joining(", ")));
|
sender.prefixless("LIST_COMMAND", serverName, playerMap.get(server).stream().map(CommandSender::getName).collect(Collectors.joining(", ")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,7 @@ package de.steamwar.bungeecore.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
public class LocalCommand extends SWCommand {
|
public class LocalCommand extends SWCommand {
|
||||||
|
|
||||||
@ -31,7 +30,7 @@ public class LocalCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(ProxiedPlayer player, String... message) {
|
public void genericCommand(PlayerChatter player, String... message) {
|
||||||
ChatListener.localChat(player, String.join(" ", message));
|
ChatListener.localChat(player, String.join(" ", message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ import de.steamwar.bungeecore.inventory.SWStreamInv;
|
|||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import de.steamwar.sql.Mod;
|
import de.steamwar.sql.Mod;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -45,12 +45,12 @@ public class ModCommand extends SWCommand {
|
|||||||
public static final Map<UUID, Mod.ModType> playerFilterType = new HashMap<>();
|
public static final Map<UUID, Mod.ModType> playerFilterType = new HashMap<>();
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void mods(ProxiedPlayer p) {
|
public void mods(PlayerChatter sender) {
|
||||||
playerFilterType.putIfAbsent(p.getUniqueId(), Mod.ModType.UNKLASSIFIED);
|
playerFilterType.putIfAbsent(sender.getPlayer().getUniqueId(), Mod.ModType.UNKLASSIFIED);
|
||||||
openGui(Chatter.of(p));
|
openGui(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openGui(Chatter player) {
|
private void openGui(PlayerChatter player) {
|
||||||
SWStreamInv<Mod> swStreamInv = new SWStreamInv<>(player, new Message("MOD_COMMAND_GUI_TITLE"), (click, mod) -> openTypeGUI(player, "MOD_COMMAND_CLASSICIATION_GUI", type -> {
|
SWStreamInv<Mod> swStreamInv = new SWStreamInv<>(player, new Message("MOD_COMMAND_GUI_TITLE"), (click, mod) -> openTypeGUI(player, "MOD_COMMAND_CLASSICIATION_GUI", type -> {
|
||||||
mod.setModType(type);
|
mod.setModType(type);
|
||||||
SWInventory.close(player);
|
SWInventory.close(player);
|
||||||
@ -68,7 +68,7 @@ public class ModCommand extends SWCommand {
|
|||||||
swStreamInv.open();
|
swStreamInv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openTypeGUI(Chatter player, String title, Consumer<Mod.ModType> function) {
|
private void openTypeGUI(PlayerChatter player, String title, Consumer<Mod.ModType> function) {
|
||||||
SWInventory inv = new SWInventory(player, 9, new Message(title));
|
SWInventory inv = new SWInventory(player, 9, new Message(title));
|
||||||
|
|
||||||
inv.addItem(1, new SWItem(new Message("MOD_UNCLASSIFIED"), 8), click -> function.accept(Mod.ModType.UNKLASSIFIED));
|
inv.addItem(1, new SWItem(new Message("MOD_UNCLASSIFIED"), 8), click -> function.accept(Mod.ModType.UNKLASSIFIED));
|
||||||
@ -86,39 +86,36 @@ public class ModCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = {"set"},description = "MOD_COMMAND_SET_USAGE")
|
@Register(value = {"set"},description = "MOD_COMMAND_SET_USAGE")
|
||||||
public void set(ProxiedPlayer p, String modName, Mod.Platform platform, Mod.ModType newModType) {
|
public void set(Chatter sender, String modName, Mod.Platform platform, Mod.ModType newModType) {
|
||||||
Chatter player = Chatter.of(p);
|
|
||||||
Mod mod = Mod.get(modName, platform);
|
Mod mod = Mod.get(modName, platform);
|
||||||
if(mod == null) {
|
if(mod == null) {
|
||||||
player.system("MOD_COMMAND_NOT_FOUND_IN_DATABASE", modName, platform.name());
|
sender.system("MOD_COMMAND_NOT_FOUND_IN_DATABASE", modName, platform.name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mod.setModType(newModType);
|
mod.setModType(newModType);
|
||||||
player.system("MOD_CHANGED_TYPE", modName, platform.name(), newModType.name());
|
sender.system("MOD_CHANGED_TYPE", modName, platform.name(), newModType.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = {"get"},description = "MOD_COMMAND_GET_USAGE")
|
@Register(value = {"get"},description = "MOD_COMMAND_GET_USAGE")
|
||||||
public void get(ProxiedPlayer p, String modName, Mod.Platform platform) {
|
public void get(Chatter sender, String modName, Mod.Platform platform) {
|
||||||
Chatter player = Chatter.of(p);
|
|
||||||
Mod mod = Mod.get(modName, platform);
|
Mod mod = Mod.get(modName, platform);
|
||||||
if(mod == null) {
|
if(mod == null) {
|
||||||
player.system("MOD_COMMAND_NOT_FOUND_IN_DATABASE", modName, platform.name());
|
sender.system("MOD_COMMAND_NOT_FOUND_IN_DATABASE", modName, platform.name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.system("MOD_COMMAND_INFO", modName, platform.name(), mod.getModType().name());
|
sender.system("MOD_COMMAND_INFO", modName, platform.name(), mod.getModType().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = {"next"})
|
@Register(value = {"next"})
|
||||||
public void next(ProxiedPlayer p) {
|
public void next(Chatter sender) {
|
||||||
Chatter player = Chatter.of(p);
|
|
||||||
Mod mod = Mod.findFirstMod();
|
Mod mod = Mod.findFirstMod();
|
||||||
if(mod == null) {
|
if(mod == null) {
|
||||||
player.system("MOD_NO_MORE_UNCLASSIFIED_MODS");
|
sender.system("MOD_NO_MORE_UNCLASSIFIED_MODS");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.system("MOD_FOUND_NEXT_MOD", mod.getModName(), mod.getPlatform().name());
|
sender.system("MOD_FOUND_NEXT_MOD", mod.getModName(), mod.getPlatform().name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import de.steamwar.bungeecore.listeners.ChatListener;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.messages.ChatterGroup;
|
import de.steamwar.messages.ChatterGroup;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import de.steamwar.sql.IgnoreSystem;
|
import de.steamwar.sql.IgnoreSystem;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
@ -35,26 +36,25 @@ public class MsgCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "MSG_USAGE")
|
@Register(description = "MSG_USAGE")
|
||||||
public void genericCommand(ProxiedPlayer sender, @ErrorMessage(value = "MSG_OFFLINE") ProxiedPlayer target, @ErrorMessage(value = "MSG_USAGE", allowEAs = false) String... message) {
|
public void genericCommand(PlayerChatter sender, @ErrorMessage(value = "MSG_OFFLINE") ProxiedPlayer target, @ErrorMessage(value = "MSG_USAGE", allowEAs = false) String... message) {
|
||||||
msg(sender, target, message);
|
msg(sender, target, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void msg(ProxiedPlayer player, ProxiedPlayer target, String[] args) {
|
public static void msg(PlayerChatter sender, ProxiedPlayer target, String[] args) {
|
||||||
Chatter sender = Chatter.of(player);
|
|
||||||
if(target == null || !target.isConnected()) {
|
if(target == null || !target.isConnected()) {
|
||||||
sender.system("MSG_OFFLINE");
|
sender.system("MSG_OFFLINE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IgnoreSystem.isIgnored(target.getUniqueId(), player.getUniqueId())) {
|
if (IgnoreSystem.isIgnored(target.getUniqueId(), sender.user().getUUID())) {
|
||||||
sender.system("MSG_IGNORED");
|
sender.system("MSG_IGNORED");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Chatter receiver = Chatter.of(target);
|
Chatter receiver = Chatter.of(target);
|
||||||
ChatListener.sendChat(sender, new ChatterGroup(sender, receiver), "CHAT_MSG", receiver, String.join(" ", args));
|
ChatListener.sendChat(sender, new ChatterGroup(sender, receiver), "CHAT_MSG", receiver, String.join(" ", args));
|
||||||
lastChats.put(player, target);
|
lastChats.put(sender.getPlayer(), target);
|
||||||
lastChats.put(target, player);
|
lastChats.put(target, sender.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remove(ProxiedPlayer player){
|
public static void remove(ProxiedPlayer player){
|
||||||
|
@ -20,8 +20,7 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
public class PingCommand extends SWCommand {
|
public class PingCommand extends SWCommand {
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ public class PingCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(ProxiedPlayer player) {
|
public void genericCommand(PlayerChatter sender) {
|
||||||
Chatter.of(player).system("PING_RESPONSE", player.getPing());
|
sender.system("PING_RESPONSE", sender.getPlayer().getPing());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
|
||||||
@ -33,12 +32,12 @@ public class PlaytimeCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(ProxiedPlayer player) {
|
public void genericCommand(Chatter sender) {
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = sender.user();
|
||||||
NumberFormat format = NumberFormat.getNumberInstance(user.getLocale());
|
NumberFormat format = NumberFormat.getNumberInstance(user.getLocale());
|
||||||
format.setMaximumFractionDigits(2);
|
format.setMaximumFractionDigits(2);
|
||||||
String formattedText = format.format((user.getOnlinetime() / (double) 3600));
|
String formattedText = format.format((user.getOnlinetime() / (double) 3600));
|
||||||
|
|
||||||
Chatter.of(player).system("HOURS_PLAYED", formattedText);
|
sender.system("HOURS_PLAYED", formattedText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
|
||||||
import de.steamwar.bungeecore.listeners.PollSystem;
|
import de.steamwar.bungeecore.listeners.PollSystem;
|
||||||
import de.steamwar.sql.PollAnswer;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.sql.PollAnswer;
|
||||||
|
|
||||||
public class PollCommand extends SWCommand {
|
public class PollCommand extends SWCommand {
|
||||||
|
|
||||||
@ -34,39 +32,33 @@ public class PollCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(ProxiedPlayer player) {
|
public void genericCommand(Chatter sender) {
|
||||||
PollSystem.sendPoll(player);
|
PollSystem.sendPoll(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(noTabComplete = true)
|
@Register(noTabComplete = true)
|
||||||
public void answerPoll(@Validator ProxiedPlayer player, String answerString) {
|
public void answerPoll(@Validator Chatter sender, String answerString) {
|
||||||
int answer;
|
int answer;
|
||||||
try {
|
try {
|
||||||
answer = Integer.parseUnsignedInt(answerString);
|
answer = Integer.parseUnsignedInt(answerString);
|
||||||
if(answer < 1 || answer > PollSystem.answers())
|
if(answer < 1 || answer > PollSystem.answers())
|
||||||
throw new NumberFormatException();
|
throw new NumberFormatException();
|
||||||
}catch(NumberFormatException e){
|
}catch(NumberFormatException e){
|
||||||
Message.send("POLL_NO_ANSWER", player);
|
sender.system("POLL_NO_ANSWER");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PollAnswer pollAnswer = PollAnswer.get(SteamwarUser.get(player.getUniqueId()).getId());
|
PollAnswer pollAnswer = PollAnswer.get(sender.user().getId());
|
||||||
if(pollAnswer.hasAnswered())
|
if(pollAnswer.hasAnswered())
|
||||||
Message.send("POLL_ANSWER_REFRESH", player);
|
sender.system("POLL_ANSWER_REFRESH");
|
||||||
else
|
else
|
||||||
Message.send("POLL_ANSWER_NEW", player);
|
sender.system("POLL_ANSWER_NEW");
|
||||||
|
|
||||||
pollAnswer.setAnswer(answer);
|
pollAnswer.setAnswer(answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(value = ProxiedPlayer.class, local = true)
|
@ClassValidator(value = Chatter.class, local = true)
|
||||||
public TypeValidator<ProxiedPlayer> noPoll() {
|
public TypeValidator<Chatter> noPoll() {
|
||||||
return (sender, value, messageSender) -> {
|
return PollSystem.noPoll();
|
||||||
if(PollSystem.noCurrentPoll()){
|
|
||||||
messageSender.send("POLL_NO_POLL");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,12 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||||
import de.steamwar.bungeecore.listeners.PollSystem;
|
import de.steamwar.bungeecore.listeners.PollSystem;
|
||||||
import de.steamwar.sql.PollAnswer;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.sql.PollAnswer;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -36,22 +35,16 @@ public class PollresultCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(@Validator ProxiedPlayer player) {
|
public void genericCommand(@Validator Chatter sender) {
|
||||||
Map<Integer, Integer> voted = PollAnswer.getCurrentResults();
|
Map<Integer, Integer> voted = PollAnswer.getCurrentResults();
|
||||||
Message.send("POLLRESULT_HEADER", player, voted.values().stream().reduce(Integer::sum).orElse(0), PollAnswer.getCurrentPoll());
|
sender.system("POLLRESULT_HEADER", voted.values().stream().reduce(Integer::sum).orElse(0), PollAnswer.getCurrentPoll());
|
||||||
for (Map.Entry<Integer, Integer> e: voted.entrySet()) {
|
for (Map.Entry<Integer, Integer> e: voted.entrySet()) {
|
||||||
Message.send("POLLRESULT_LIST", player, PollSystem.getAnswer(e.getKey()), e.getValue());
|
sender.prefixless("POLLRESULT_LIST", PollSystem.getAnswer(e.getKey()), e.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(value = ProxiedPlayer.class, local = true)
|
@ClassValidator(value = Chatter.class, local = true)
|
||||||
public TypeValidator<ProxiedPlayer> noPoll() {
|
public TypeValidator<Chatter> noPoll() {
|
||||||
return (sender, value, messageSender) -> {
|
return PollSystem.noPoll();
|
||||||
if (PollSystem.noCurrentPoll()) {
|
|
||||||
messageSender.send("POLL_NO_POLL");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,6 @@ import java.util.stream.Collectors;
|
|||||||
public class PunishmentCommand {
|
public class PunishmentCommand {
|
||||||
|
|
||||||
private static final String API_URL = "https://api.mojang.com/users/profiles/minecraft/";
|
private static final String API_URL = "https://api.mojang.com/users/profiles/minecraft/";
|
||||||
private static final JsonParser jsonParser = new JsonParser();
|
|
||||||
|
|
||||||
public static SteamwarUser getOrCreateOfflinePlayer(String name) {
|
public static SteamwarUser getOrCreateOfflinePlayer(String name) {
|
||||||
SteamwarUser user = SteamwarUser.get(name);
|
SteamwarUser user = SteamwarUser.get(name);
|
||||||
@ -73,7 +72,7 @@ public class PunishmentCommand {
|
|||||||
private static UUID getUUIDofOfflinePlayer(String playerName) {
|
private static UUID getUUIDofOfflinePlayer(String playerName) {
|
||||||
try {
|
try {
|
||||||
final URL url = new URL(API_URL + playerName);
|
final URL url = new URL(API_URL + playerName);
|
||||||
String uuid = jsonParser.parse(new Scanner(url.openConnection().getInputStream()).nextLine()).getAsJsonObject().get("id").getAsString();
|
String uuid = JsonParser.parseString(new Scanner(url.openConnection().getInputStream()).nextLine()).getAsJsonObject().get("id").getAsString();
|
||||||
return UUID.fromString(uuid.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5"));
|
return UUID.fromString(uuid.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5"));
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
// ignore, player does not exist
|
// ignore, player does not exist
|
||||||
@ -93,8 +92,6 @@ public class PunishmentCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void ban(SteamwarUser user, Timestamp time, String banReason, SteamwarUser punisher, boolean perma) {
|
public static void ban(SteamwarUser user, Timestamp time, String banReason, SteamwarUser punisher, boolean perma) {
|
||||||
user.punish(Punishment.PunishmentType.Ban, time, banReason, punisher.getId(), perma);
|
|
||||||
|
|
||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
String ip = IPSanitizer.getTrueAddress(player.getPendingConnection()).getHostAddress();
|
String ip = IPSanitizer.getTrueAddress(player.getPendingConnection()).getHostAddress();
|
||||||
@ -119,94 +116,17 @@ public class PunishmentCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) {
|
public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) {
|
||||||
new SWCommand(command, ConnectionListener.BAN_PERMISSION) {
|
new PunishCommand(command, punishmentType);
|
||||||
|
|
||||||
@Register
|
if (punishmentType.getUnpunishmentMessage() == null)
|
||||||
public void genericCommand(ProxiedPlayer player, @Mapper("toPunish") String toPunish, String date, @ErrorMessage(allowEAs = false, value = "PUNISHMENT_USAGE_REASON") String... message) {
|
|
||||||
SteamwarUser punisher = SteamwarUser.get(player.getUniqueId());
|
|
||||||
if (punishmentType.isNeedsAdmin() && !punisher.hasPerm(UserPerm.MODERATION)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SteamwarUser target = unsafeUser(player, toPunish);
|
|
||||||
if (target == null)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Timestamp banTime = parseTime(player, date);
|
new UnpunishCommand("un" + command, punishmentType);
|
||||||
if (banTime == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
boolean isPerma = date.equalsIgnoreCase("perma");
|
|
||||||
String msg = String.join(" ", message);
|
|
||||||
if(punishmentType == Punishment.PunishmentType.Ban)
|
|
||||||
ban(target, banTime, msg, punisher, isPerma);
|
|
||||||
else
|
|
||||||
target.punish(punishmentType, banTime, msg, punisher.getId(), isPerma);
|
|
||||||
Chatter.serverteam().system(punishmentType.getTeamMessage(), new Message("PREFIX"), target.getUserName(), player.getName(), new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
private static final Pattern RELATIVE_PATTERN = Pattern.compile("([1-9]\\d*[hdwmy])+");
|
||||||
public void genericError(ProxiedPlayer player, String... args) {
|
|
||||||
Chatter.of(player).send(true, ChatMessageType.CHAT, null, null, new Message("PUNISHMENT_USAGE", command));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mapper(value = "toPunish", local = true)
|
public static Timestamp parseTime(Chatter player, String arg) {
|
||||||
public TypeMapper<String> allUsers() {
|
|
||||||
return new TypeMapper<String>() {
|
|
||||||
@Override
|
|
||||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
|
||||||
List<String> players = BungeeCord.getInstance().getPlayers().stream()
|
|
||||||
.map(CommandSender::getName)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
players.add(s);
|
|
||||||
return players;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (punishmentType.getUnpunishmentMessage() == null) return;
|
|
||||||
String antiCommand = "un" + command;
|
|
||||||
new SWCommand(antiCommand, ConnectionListener.BAN_PERMISSION) {
|
|
||||||
@Register
|
|
||||||
public void genericCommand(ProxiedPlayer player, @ErrorMessage("UNKNOWN_PLAYER") SteamwarUser target) {
|
|
||||||
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.MODERATION)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!target.isPunished(punishmentType)) {
|
|
||||||
Message.send(punishmentType.getUsageNotPunished(), player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Message.send(punishmentType.getUnpunishmentMessage(), player, target.getUserName());
|
|
||||||
target.punish(punishmentType, Timestamp.from(new Date().toInstant()), antiCommand, SteamwarUser.get(player.getName()).getId(), false);
|
|
||||||
if(punishmentType == Punishment.PunishmentType.Ban)
|
|
||||||
BannedUserIPs.unbanIPs(target.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register
|
|
||||||
public void genericError(ProxiedPlayer player, String... args) {
|
|
||||||
Chatter.of(player).send(true, ChatMessageType.CHAT, null, null, new Message("UNPUNISHMENT_USAGE", antiCommand));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SteamwarUser unsafeUser(CommandSender sender, String arg){
|
|
||||||
SteamwarUser target = getOrCreateOfflinePlayer(arg);
|
|
||||||
if(target == null)
|
|
||||||
Message.send("UNKNOWN_PLAYER", sender);
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Pattern RELATIVE_PATTERN = Pattern.compile("([1-9]\\d*[hdwmy])+");
|
|
||||||
|
|
||||||
public static Timestamp parseTime(CommandSender sender, String arg) {
|
|
||||||
if (arg.equalsIgnoreCase("perma")) {
|
if (arg.equalsIgnoreCase("perma")) {
|
||||||
return Punishment.PERMA_TIME;
|
return Punishment.PERMA_TIME;
|
||||||
} else {
|
} else {
|
||||||
@ -251,12 +171,109 @@ public class PunishmentCommand {
|
|||||||
Date parsedDate = dateFormat.parse(arg.split("_")[0]);
|
Date parsedDate = dateFormat.parse(arg.split("_")[0]);
|
||||||
return new java.sql.Timestamp(parsedDate.getTime());
|
return new java.sql.Timestamp(parsedDate.getTime());
|
||||||
} catch (ParseException exception) {
|
} catch (ParseException exception) {
|
||||||
if (sender != null) {
|
player.system("INVALID_TIME");
|
||||||
Message.send("INVALID_TIME", sender);
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class PunishCommand extends SWCommand {
|
||||||
|
|
||||||
|
private final String command;
|
||||||
|
private final Punishment.PunishmentType punishmentType;
|
||||||
|
|
||||||
|
private PunishCommand(String command, Punishment.PunishmentType punishmentType) {
|
||||||
|
super(command, ConnectionListener.BAN_PERMISSION);
|
||||||
|
this.command = command;
|
||||||
|
this.punishmentType = punishmentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SteamwarUser unsafeUser(Chatter sender, String arg) {
|
||||||
|
SteamwarUser target = getOrCreateOfflinePlayer(arg);
|
||||||
|
if(target == null)
|
||||||
|
sender.system("UNKNOWN_PLAYER");
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericCommand(Chatter sender, @Mapper("toPunish") String toPunish, String date, @ErrorMessage(allowEAs = false, value = "PUNISHMENT_USAGE_REASON") String... message) {
|
||||||
|
SteamwarUser punisher = sender.user();
|
||||||
|
if (punishmentType.isNeedsAdmin() && !punisher.hasPerm(UserPerm.MODERATION))
|
||||||
|
return;
|
||||||
|
|
||||||
|
SteamwarUser target = unsafeUser(sender, toPunish);
|
||||||
|
if (target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Timestamp banTime = parseTime(sender, date);
|
||||||
|
if (banTime == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
boolean isPerma = date.equalsIgnoreCase("perma");
|
||||||
|
String msg = String.join(" ", message);
|
||||||
|
target.punish(punishmentType, banTime, msg, punisher.getId(), isPerma);
|
||||||
|
if(punishmentType == Punishment.PunishmentType.Ban)
|
||||||
|
ban(target, banTime, msg, punisher, isPerma);
|
||||||
|
Chatter.serverteam().system(punishmentType.getTeamMessage(), new Message("PREFIX"), target, sender, new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericError(Chatter sender, String... args) {
|
||||||
|
sender.send(true, ChatMessageType.CHAT, null, null, new Message("PUNISHMENT_USAGE", command));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mapper(value = "toPunish", local = true)
|
||||||
|
public TypeMapper<String> allUsers() {
|
||||||
|
return new TypeMapper<String>() {
|
||||||
|
@Override
|
||||||
|
public String map(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
|
List<String> players = BungeeCord.getInstance().getPlayers().stream()
|
||||||
|
.map(CommandSender::getName)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
players.add(s);
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class UnpunishCommand extends SWCommand {
|
||||||
|
|
||||||
|
private final String command;
|
||||||
|
private final Punishment.PunishmentType punishmentType;
|
||||||
|
|
||||||
|
private UnpunishCommand(String command, Punishment.PunishmentType punishmentType) {
|
||||||
|
super(command, ConnectionListener.BAN_PERMISSION);
|
||||||
|
this.command = command;
|
||||||
|
this.punishmentType = punishmentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericCommand(Chatter sender, @ErrorMessage("UNKNOWN_PLAYER") SteamwarUser target) {
|
||||||
|
if (punishmentType.isNeedsAdmin() && !sender.user().hasPerm(UserPerm.MODERATION))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!target.isPunished(punishmentType)) {
|
||||||
|
sender.system(punishmentType.getUsageNotPunished());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
target.punish(punishmentType, Timestamp.from(new Date().toInstant()), command, sender.user().getId(), false);
|
||||||
|
if(punishmentType == Punishment.PunishmentType.Ban)
|
||||||
|
BannedUserIPs.unbanIPs(target.getId());
|
||||||
|
|
||||||
|
sender.system(punishmentType.getUnpunishmentMessage(), target.getUserName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register
|
||||||
|
public void genericError(Chatter sender, String... args) {
|
||||||
|
sender.send(true, ChatMessageType.CHAT, null, null, new Message("UNPUNISHMENT_USAGE", command));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import de.steamwar.command.SWCommandUtils;
|
|||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import de.steamwar.sql.Punishment;
|
import de.steamwar.sql.Punishment;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
@ -41,15 +42,8 @@ public class TypeMappers {
|
|||||||
SWCommandUtils.addMapper("arenaMap", arenaMapTypeMapper());
|
SWCommandUtils.addMapper("arenaMap", arenaMapTypeMapper());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TypeValidator<ProxiedPlayer> arenaPlayer() {
|
private static TypeValidator<PlayerChatter> arenaPlayer() {
|
||||||
return (sender, value, messageSender) -> {
|
return (sender, player, messageSender) -> !PunishmentCommand.isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer);
|
||||||
Chatter player = Chatter.of(value);
|
|
||||||
if (PunishmentCommand.isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TypeMapper<ArenaMode> arenaModeTypeMapper(boolean historic) {
|
private static TypeMapper<ArenaMode> arenaModeTypeMapper(boolean historic) {
|
||||||
|
@ -66,6 +66,7 @@ public class SWInventory {
|
|||||||
addItem(pos, item, new ArrayList<>(), callback);
|
addItem(pos, item, new ArrayList<>(), callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void addItem(int pos, SWItem item, List<String> lore, InvCallback callback) {
|
public void addItem(int pos, SWItem item, List<String> lore, InvCallback callback) {
|
||||||
item.setCallback(callback);
|
item.setCallback(callback);
|
||||||
item.setLore(lore);
|
item.setLore(lore);
|
||||||
|
@ -26,6 +26,7 @@ import de.steamwar.bungeecore.network.NetworkSender;
|
|||||||
import de.steamwar.bungeecore.util.Chat19;
|
import de.steamwar.bungeecore.util.Chat19;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.messages.ChatterGroup;
|
import de.steamwar.messages.ChatterGroup;
|
||||||
|
import de.steamwar.messages.PlayerChatter;
|
||||||
import de.steamwar.network.packets.server.PingPacket;
|
import de.steamwar.network.packets.server.PingPacket;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.*;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
@ -122,20 +123,19 @@ public class ChatListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void localChat(ProxiedPlayer player, String message) {
|
public static void localChat(PlayerChatter sender, String message) {
|
||||||
Chatter sender = Chatter.of(player);
|
|
||||||
if(message.length() == 0){
|
if(message.length() == 0){
|
||||||
sender.system("CHAT_BC_USAGE");
|
sender.system("CHAT_BC_USAGE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ChatListener.filteredCommand(player, message))
|
if(ChatListener.filteredCommand(sender.getPlayer(), message))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!message.startsWith("/") && chatFilter(sender, message))
|
if(!message.startsWith("/") && chatFilter(sender, message))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Chat19.chat(player, message);
|
Chat19.chat(sender.getPlayer(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean chatFilter(Chatter sender, String message) {
|
private static boolean chatFilter(Chatter sender, String message) {
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
package de.steamwar.bungeecore.listeners;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.sql.PollAnswer;
|
import de.steamwar.sql.PollAnswer;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
@ -47,29 +47,37 @@ public class PollSystem extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPostLogin(PostLoginEvent event){
|
public void onPostLogin(PostLoginEvent event){
|
||||||
ProxiedPlayer player = event.getPlayer();
|
Chatter player = Chatter.of(event.getPlayer());
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
||||||
|
|
||||||
PollAnswer answer = PollAnswer.get(user.getId());
|
PollAnswer answer = PollAnswer.get(player.user().getId());
|
||||||
if(answer.hasAnswered())
|
if(answer.hasAnswered())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sendPoll(player);
|
sendPoll(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPoll(ProxiedPlayer player){
|
public static void sendPoll(Chatter player) {
|
||||||
Message.send("POLL_HEADER", player);
|
player.system("POLL_HEADER");
|
||||||
Message.sendPrefixless("POLL_HEADER2", player);
|
player.prefixless("POLL_HEADER2");
|
||||||
Message.sendPrefixless("POLL_QUESTION", player, question);
|
player.prefixless("POLL_QUESTION", question);
|
||||||
|
|
||||||
for(int i = 1; i <= answers.size(); i++){
|
for(int i = 1; i <= answers.size(); i++) {
|
||||||
Message.send("POLL_ANWSER", player, Message.parse("POLL_ANWSER_HOVER", player, answers.get(i-1)),
|
player.prefixless("POLL_ANSWER", new Message("POLL_ANSWER_HOVER", answers.get(i-1)), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/poll " + i), answers.get(i-1));
|
||||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/poll " + i), answers.get(i-1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean noCurrentPoll(){
|
public static boolean noCurrentPoll(){
|
||||||
return question == null || question.equals("");
|
return question == null || question.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TypeValidator<Chatter> noPoll() {
|
||||||
|
return (sender, value, messageSender) -> {
|
||||||
|
if (PollSystem.noCurrentPoll()) {
|
||||||
|
sender.system("POLL_NO_POLL");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int answers(){
|
public static int answers(){
|
||||||
|
@ -19,27 +19,22 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.util;
|
package de.steamwar.bungeecore.util;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserConfig;
|
import de.steamwar.sql.UserConfig;
|
||||||
import de.steamwar.sql.UserPerm;
|
import de.steamwar.sql.UserPerm;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class BauLock {
|
public class BauLock {
|
||||||
|
|
||||||
private static final String BAU_LOCK_CONFIG_NAME = "baulockstate";
|
private static final String BAU_LOCK_CONFIG_NAME = "baulockstate";
|
||||||
public static void setLocked(ProxiedPlayer p, BauLockState state) {
|
public static void setLocked(Chatter owner, BauLockState state) {
|
||||||
SteamwarUser owner = SteamwarUser.get(p.getUniqueId());
|
UserConfig.updatePlayerConfig(owner.user().getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name());
|
||||||
UserConfig.updatePlayerConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name());
|
owner.system("BAU_LOCKED_" + state.name());
|
||||||
Message.send("BAU_LOCKED_" + state.name(), p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkNotifyLocked(SteamwarUser owner, ProxiedPlayer player) {
|
public static boolean checkNotifyLocked(SteamwarUser owner, Chatter sender) {
|
||||||
Chatter sender = Chatter.of(player);
|
|
||||||
SteamwarUser target = sender.user();
|
SteamwarUser target = sender.user();
|
||||||
if (owner.getId() == target.getId())
|
if (owner.getId() == target.getId())
|
||||||
return false;
|
return false;
|
||||||
@ -69,10 +64,7 @@ public class BauLock {
|
|||||||
|
|
||||||
if(locked) {
|
if(locked) {
|
||||||
sender.system("BAU_LOCKED_NOALLOWED");
|
sender.system("BAU_LOCKED_NOALLOWED");
|
||||||
|
Chatter.of(owner.getUUID()).system("BAU_LOCK_BLOCKED", sender);
|
||||||
ProxiedPlayer ownerPlayer = ProxyServer.getInstance().getPlayer(owner.getUUID());
|
|
||||||
if(ownerPlayer != null)
|
|
||||||
Chatter.of(ownerPlayer).system("BAU_LOCK_BLOCKED", player.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return locked;
|
return locked;
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.command;
|
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
|
||||||
|
|
||||||
@UtilityClass
|
|
||||||
class CommandRegistering {
|
|
||||||
|
|
||||||
static void unregister(Command command) {
|
|
||||||
ProxyServer.getInstance().getPluginManager().unregisterCommand(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void register(Command command) {
|
|
||||||
ProxyServer.getInstance().getPluginManager().registerCommand(BungeeCore.get(), command);
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,27 +23,28 @@ import de.steamwar.bungeecore.BungeeCore;
|
|||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.messages.Chatter;
|
import de.steamwar.messages.Chatter;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
import net.md_5.bungee.api.plugin.Command;
|
||||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class SWCommand extends AbstractSWCommand<CommandSender> {
|
public class SWCommand extends AbstractSWCommand<Chatter> {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
TypeUtils.init();
|
TypeUtils.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String permission;
|
private final String permission;
|
||||||
private Command command;
|
private Command command;
|
||||||
|
|
||||||
private List<String> defaultHelpMessages = new ArrayList<>();
|
private final List<String> defaultHelpMessages = new ArrayList<>();
|
||||||
|
|
||||||
protected SWCommand(String command) {
|
protected SWCommand(String command) {
|
||||||
this(command, null);
|
this(command, null);
|
||||||
@ -54,7 +55,7 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected SWCommand(String command, String permission, String... aliases) {
|
protected SWCommand(String command, String permission, String... aliases) {
|
||||||
super(CommandSender.class, command, aliases);
|
super(Chatter.class, command, aliases);
|
||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
create = true;
|
create = true;
|
||||||
createAndSafeCommand(command, aliases);
|
createAndSafeCommand(command, aliases);
|
||||||
@ -70,12 +71,12 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
|||||||
this.command = new TabCompletableCommand(command, permission, aliases) {
|
this.command = new TabCompletableCommand(command, permission, aliases) {
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender commandSender, String[] strings) {
|
public void execute(CommandSender commandSender, String[] strings) {
|
||||||
SWCommand.this.execute(commandSender, null, strings);
|
SWCommand.this.execute(Chatter.of(commandSender), null, strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] strings) {
|
public Iterable<String> onTabComplete(CommandSender commandSender, String[] strings) {
|
||||||
return SWCommand.this.tabComplete(commandSender, null, strings);
|
return SWCommand.this.tabComplete(Chatter.of(commandSender), null, strings);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -89,19 +90,19 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
|||||||
@Override
|
@Override
|
||||||
public void unregister() {
|
public void unregister() {
|
||||||
if (command == null) return;
|
if (command == null) return;
|
||||||
CommandRegistering.unregister(this.command);
|
ProxyServer.getInstance().getPluginManager().unregisterCommand(this.command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register() {
|
||||||
if (command == null) return;
|
if (command == null) return;
|
||||||
CommandRegistering.register(this.command);
|
ProxyServer.getInstance().getPluginManager().registerCommand(BungeeCore.get(), this.command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void commandSystemError(CommandSender sender, CommandFrameworkException e) {
|
protected void commandSystemError(Chatter sender, CommandFrameworkException e) {
|
||||||
BungeeCore.get().getLogger().log(Level.SEVERE, e.getMessage(), e);
|
BungeeCore.get().getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||||
Chatter.of(sender).prefixless("COMMAND_SYSTEM_ERROR");
|
sender.prefixless("COMMAND_SYSTEM_ERROR");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -114,16 +115,15 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void sendMessage(CommandSender sender, String message, Object[] args) {
|
protected void sendMessage(Chatter sender, String message, Object[] args) {
|
||||||
Chatter.of(sender).system(message, args);
|
sender.system(message, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(noTabComplete = true)
|
@Register(noTabComplete = true)
|
||||||
public void internalHelp(ProxiedPlayer p, String... args) {
|
public void internalHelp(Chatter sender, String... args) {
|
||||||
Chatter chatter = Chatter.of(p);
|
|
||||||
try {
|
try {
|
||||||
chatter.prefixless("COMMAND_HELP_HEAD", command.getName());
|
sender.prefixless("COMMAND_HELP_HEAD", command.getName());
|
||||||
defaultHelpMessages.forEach(chatter::prefixless);
|
defaultHelpMessages.forEach(sender::prefixless);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
BungeeCore.get().getLogger().log(Level.WARNING, "Failed to send help message", e);
|
BungeeCore.get().getLogger().log(Level.WARNING, "Failed to send help message", e);
|
||||||
return;
|
return;
|
||||||
@ -131,7 +131,7 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
|||||||
AtomicInteger atomicInteger = new AtomicInteger();
|
AtomicInteger atomicInteger = new AtomicInteger();
|
||||||
if (args.length != 0) {
|
if (args.length != 0) {
|
||||||
commandList.forEach(subCommand -> {
|
commandList.forEach(subCommand -> {
|
||||||
List<String> tabCompletes = subCommand.tabComplete(p, args);
|
List<String> tabCompletes = subCommand.tabComplete(sender, args);
|
||||||
if (tabCompletes == null || tabCompletes.isEmpty()) {
|
if (tabCompletes == null || tabCompletes.isEmpty()) {
|
||||||
atomicInteger.incrementAndGet();
|
atomicInteger.incrementAndGet();
|
||||||
return;
|
return;
|
||||||
@ -139,7 +139,7 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
|||||||
boolean hasTabCompletes = tabCompletes.stream()
|
boolean hasTabCompletes = tabCompletes.stream()
|
||||||
.anyMatch(s -> s.toLowerCase().startsWith(args[args.length - 1].toLowerCase()));
|
.anyMatch(s -> s.toLowerCase().startsWith(args[args.length - 1].toLowerCase()));
|
||||||
if (hasTabCompletes) {
|
if (hasTabCompletes) {
|
||||||
send(chatter, subCommand);
|
send(sender, subCommand);
|
||||||
} else {
|
} else {
|
||||||
atomicInteger.incrementAndGet();
|
atomicInteger.incrementAndGet();
|
||||||
}
|
}
|
||||||
@ -147,14 +147,14 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
|||||||
}
|
}
|
||||||
if (args.length == 0 || atomicInteger.get() == commandList.size()) {
|
if (args.length == 0 || atomicInteger.get() == commandList.size()) {
|
||||||
commandList.forEach(subCommand -> {
|
commandList.forEach(subCommand -> {
|
||||||
if (subCommand.validator == null || subCommand.validator.validate(p, p, (s, args1) -> {})) {
|
if (subCommand.validator == null || subCommand.validator.validate(sender, sender, (s, args1) -> {})) {
|
||||||
send(chatter, subCommand);
|
send(sender, subCommand);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void send(Chatter chatter, SubCommand<CommandSender> subCommand) {
|
private void send(Chatter chatter, SubCommand<Chatter> subCommand) {
|
||||||
try {
|
try {
|
||||||
for (String s : subCommand.description) {
|
for (String s : subCommand.description) {
|
||||||
String hover = "§8/§e" + command.getName() + " " + String.join(" ", subCommand.subCommand);
|
String hover = "§8/§e" + command.getName() + " " + String.join(" ", subCommand.subCommand);
|
||||||
@ -162,7 +162,7 @@ public class SWCommand extends AbstractSWCommand<CommandSender> {
|
|||||||
chatter.prefixless(s, new Message("PLAIN_STRING", hover), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, suggest));
|
chatter.prefixless(s, new Message("PLAIN_STRING", hover), new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, suggest));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
BungeeCore.get().getLogger().log(Level.WARNING, "Failed to send description of registered method '" + subCommand.method + "' with description '" + subCommand.description + "'", e);
|
BungeeCore.get().getLogger().log(Level.WARNING, "Failed to send description of registered method '" + subCommand.method + "' with description '" + Arrays.toString(subCommand.description) + "'", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.command;
|
package de.steamwar.command;
|
||||||
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import de.steamwar.messages.Chatter;
|
||||||
|
|
||||||
public interface TypeMapper<T> extends AbstractTypeMapper<CommandSender, T> {
|
public interface TypeMapper<T> extends AbstractTypeMapper<Chatter, T> {
|
||||||
/**
|
/**
|
||||||
* The CommandSender can be null!
|
* The CommandSender can be null!
|
||||||
*/
|
*/
|
||||||
T map(CommandSender commandSender, String[] previousArguments, String s);
|
T map(Chatter sender, PreviousArguments previousArguments, String s);
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,11 @@ package de.steamwar.command;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.ServerVersion;
|
import de.steamwar.bungeecore.ServerVersion;
|
||||||
import de.steamwar.bungeecore.commands.TypeMappers;
|
import de.steamwar.bungeecore.commands.TypeMappers;
|
||||||
|
import de.steamwar.messages.Chatter;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.sql.Team;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -41,9 +41,10 @@ public class TypeUtils {
|
|||||||
SWCommandUtils.addMapper(SteamwarUser.class, SWCommandUtils.createMapper(SteamwarUser::get, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList())));
|
SWCommandUtils.addMapper(SteamwarUser.class, SWCommandUtils.createMapper(SteamwarUser::get, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList())));
|
||||||
SWCommandUtils.addMapper(ServerVersion.class, new TypeMapper<ServerVersion>() {
|
SWCommandUtils.addMapper(ServerVersion.class, new TypeMapper<ServerVersion>() {
|
||||||
@Override
|
@Override
|
||||||
public ServerVersion map(CommandSender sender, String[] previousArguments, String s) {
|
public ServerVersion map(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
if (sender instanceof ProxiedPlayer && s.isEmpty()) {
|
ProxiedPlayer player = sender.getPlayer();
|
||||||
int version = ((ProxiedPlayer) sender).getPendingConnection().getVersion();
|
if(player != null && s.isEmpty()) {
|
||||||
|
int version = player.getPendingConnection().getVersion();
|
||||||
if (version > 762) { // Version > 1.19.4
|
if (version > 762) { // Version > 1.19.4
|
||||||
return ServerVersion.PAPER_20;
|
return ServerVersion.PAPER_20;
|
||||||
} else if (version > 578) { // Version > 1.15.2
|
} else if (version > 578) { // Version > 1.15.2
|
||||||
@ -59,7 +60,7 @@ public class TypeUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(Chatter sender, PreviousArguments previousArguments, String s) {
|
||||||
return ServerVersion.chatVersions();
|
return ServerVersion.chatVersions();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.command;
|
package de.steamwar.command;
|
||||||
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import de.steamwar.messages.Chatter;
|
||||||
|
|
||||||
public interface TypeValidator<T> extends AbstractValidator<CommandSender, T> {
|
public interface TypeValidator<T> extends AbstractValidator<Chatter, T> {}
|
||||||
}
|
|
||||||
|
@ -569,8 +569,8 @@ EVENTMODE_KICK=§cYou are not an event participant.
|
|||||||
POLL_HEADER=§e§lPoll
|
POLL_HEADER=§e§lPoll
|
||||||
POLL_HEADER2=§7Click the answer you like!
|
POLL_HEADER2=§7Click the answer you like!
|
||||||
POLL_QUESTION=§e{0}
|
POLL_QUESTION=§e{0}
|
||||||
POLL_ANWSER=§7{0}
|
POLL_ANSWER=§7{0}
|
||||||
POLL_ANWSER_HOVER=§eChoose {0}
|
POLL_ANSWER_HOVER=§eChoose {0}
|
||||||
|
|
||||||
#TablistManager
|
#TablistManager
|
||||||
TABLIST_PHASE_WEBSITE=§8Website: https://§eSteam§8War.de
|
TABLIST_PHASE_WEBSITE=§8Website: https://§eSteam§8War.de
|
||||||
|
@ -545,8 +545,8 @@ EVENTMODE_KICK=§cDu bist kein Eventteilnehmer.
|
|||||||
POLL_HEADER=§e§lUmfrage
|
POLL_HEADER=§e§lUmfrage
|
||||||
POLL_HEADER2=§7Klicke die Antwort an, die dir gefällt!
|
POLL_HEADER2=§7Klicke die Antwort an, die dir gefällt!
|
||||||
POLL_QUESTION=§e{0}
|
POLL_QUESTION=§e{0}
|
||||||
POLL_ANWSER=§7{0}
|
POLL_ANSWER=§7{0}
|
||||||
POLL_ANWSER_HOVER=§e{0} §ewählen
|
POLL_ANSWER_HOVER=§e{0} §ewählen
|
||||||
|
|
||||||
#TablistManager
|
#TablistManager
|
||||||
TABLIST_PHASE_WEBSITE=§8Website: https://§eSteam§8War.de
|
TABLIST_PHASE_WEBSITE=§8Website: https://§eSteam§8War.de
|
||||||
|
@ -44,8 +44,9 @@ import java.util.Date;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -78,11 +79,25 @@ public interface Chatter {
|
|||||||
|
|
||||||
Locale getLocale();
|
Locale getLocale();
|
||||||
boolean chatShown();
|
boolean chatShown();
|
||||||
void sendMessage(ChatMessageType type, BaseComponent... msg);
|
void sendMessage(ChatMessageType type, BaseComponent msg);
|
||||||
void withPlayerOrDiscord(Consumer<ProxiedPlayer> withPlayer, Consumer<SteamwarUser> withDiscord);
|
ProxiedPlayer getPlayer();
|
||||||
|
|
||||||
|
default <T> T withPlayerOrOffline(Function<ProxiedPlayer, T> withPlayer, Supplier<T> withOffline) {
|
||||||
|
ProxiedPlayer player = getPlayer();
|
||||||
|
if(player == null)
|
||||||
|
return withOffline.get();
|
||||||
|
else
|
||||||
|
return withPlayer.apply(player);
|
||||||
|
}
|
||||||
|
default void withPlayerOrOffline(Consumer<ProxiedPlayer> withPlayer, Runnable withOffline) {
|
||||||
|
ProxiedPlayer player = getPlayer();
|
||||||
|
if(player == null)
|
||||||
|
withOffline.run();
|
||||||
|
else
|
||||||
|
withPlayer.accept(player);
|
||||||
|
}
|
||||||
default void withPlayer(Consumer<ProxiedPlayer> function) {
|
default void withPlayer(Consumer<ProxiedPlayer> function) {
|
||||||
withPlayerOrDiscord(function, user -> {});
|
withPlayerOrOffline(function, () -> {});
|
||||||
}
|
}
|
||||||
|
|
||||||
default void chat(Message message) {
|
default void chat(Message message) {
|
||||||
@ -164,41 +179,12 @@ public interface Chatter {
|
|||||||
return TextComponent.fromLegacy(format.format(params));
|
return TextComponent.fromLegacy(format.format(params));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Chatter ofProxiedPlayer(ProxiedPlayer player, BiConsumer<ChatMessageType, BaseComponent[]> sendMessage) {
|
static PlayerChatter of(ProxiedPlayer player) {
|
||||||
return new Chatter() {
|
return new PlayerChatter(player, player::sendMessage);
|
||||||
@Override
|
|
||||||
public SteamwarUser user() {
|
|
||||||
return SteamwarUser.get(player.getUniqueId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
static PlayerChatter disconnect(ProxiedPlayer player) {
|
||||||
public Locale getLocale() {
|
return new PlayerChatter(player, (type, msg) -> player.disconnect(msg));
|
||||||
return user().getLocale();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean chatShown() {
|
|
||||||
return player.getChatMode() == ProxiedPlayer.ChatMode.SHOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
|
||||||
sendMessage.accept(type, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void withPlayerOrDiscord(Consumer<ProxiedPlayer> withPlayer, Consumer<SteamwarUser> withDiscord) {
|
|
||||||
withPlayer.accept(player);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static Chatter of(ProxiedPlayer player) {
|
|
||||||
return ofProxiedPlayer(player, player::sendMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Chatter disconnect(ProxiedPlayer player) {
|
|
||||||
return ofProxiedPlayer(player, (type, msg) -> player.disconnect(msg));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Chatter of(CommandSender sender) {
|
static Chatter of(CommandSender sender) {
|
||||||
@ -218,12 +204,16 @@ public interface Chatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
public void sendMessage(ChatMessageType type, BaseComponent msg) {
|
||||||
sender.sendMessage(msg);
|
sender.sendMessage(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Chatter of(SteamwarUser user) {
|
||||||
|
return of(user.getUUID());
|
||||||
|
}
|
||||||
|
|
||||||
static Chatter of(UUID uuid) {
|
static Chatter of(UUID uuid) {
|
||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||||
if(player != null)
|
if(player != null)
|
||||||
@ -241,7 +231,7 @@ public interface Chatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
public void sendMessage(ChatMessageType type, BaseComponent msg) {
|
||||||
// Nowhere to send
|
// Nowhere to send
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -264,8 +254,9 @@ public interface Chatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
public void sendMessage(ChatMessageType type, BaseComponent msg) {
|
||||||
event.setCancelReason(msg);
|
event.setReason(msg);
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -283,9 +274,9 @@ public interface Chatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
public void sendMessage(ChatMessageType type, BaseComponent msg) {
|
||||||
try {
|
try {
|
||||||
channel.send("<t:" + (System.currentTimeMillis() / 1000) + "> " + new TextComponent(msg).toPlainText());
|
channel.send("<t:" + (System.currentTimeMillis() / 1000) + "> " + msg.toPlainText());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat message to discord", e);
|
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat message to discord", e);
|
||||||
}
|
}
|
||||||
@ -306,7 +297,7 @@ public interface Chatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
public void sendMessage(ChatMessageType type, BaseComponent msg) {
|
||||||
try {
|
try {
|
||||||
message.delete().queue();
|
message.delete().queue();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -319,12 +310,12 @@ public interface Chatter {
|
|||||||
abstract class PlayerlessChatter implements Chatter {
|
abstract class PlayerlessChatter implements Chatter {
|
||||||
@Override
|
@Override
|
||||||
public Locale getLocale() {
|
public Locale getLocale() {
|
||||||
return Locale.getDefault();
|
return user().getLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void withPlayerOrDiscord(Consumer<ProxiedPlayer> withPlayer, Consumer<SteamwarUser> withDiscord) {
|
public ProxiedPlayer getPlayer() {
|
||||||
withDiscord.accept(user());
|
return ProxyServer.getInstance().getPlayer(user().getUUID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,10 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
|||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class ChatterGroup implements Chatter {
|
public class ChatterGroup extends Chatter.PlayerlessChatter {
|
||||||
|
|
||||||
final Chatter[] chatters;
|
final Chatter[] chatters;
|
||||||
|
|
||||||
@ -60,12 +59,7 @@ public class ChatterGroup implements Chatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Locale getLocale() {
|
public void sendMessage(ChatMessageType type, BaseComponent msg) {
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMessage(ChatMessageType type, BaseComponent... msg) {
|
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
61
src/de/steamwar/messages/PlayerChatter.java
Normale Datei
61
src/de/steamwar/messages/PlayerChatter.java
Normale Datei
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2024 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.messages;
|
||||||
|
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PlayerChatter implements Chatter {
|
||||||
|
|
||||||
|
private final ProxiedPlayer player;
|
||||||
|
private final BiConsumer<ChatMessageType, BaseComponent> sendMessage;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SteamwarUser user() {
|
||||||
|
return SteamwarUser.get(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Locale getLocale() {
|
||||||
|
return user().getLocale();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean chatShown() {
|
||||||
|
return player.getChatMode() == ProxiedPlayer.ChatMode.SHOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(ChatMessageType type, BaseComponent msg) {
|
||||||
|
sendMessage.accept(type, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProxiedPlayer getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren