Merge pull request '+Fixed player connect with teleport' (#435) from BauLock into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #435 Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
4cfb7830f9
@ -23,10 +23,7 @@ import de.steamwar.bungeecore.*;
|
|||||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.bungeecore.network.NetworkSender;
|
import de.steamwar.bungeecore.network.NetworkSender;
|
||||||
import de.steamwar.bungeecore.sql.BauLockState;
|
import de.steamwar.bungeecore.sql.*;
|
||||||
import de.steamwar.bungeecore.sql.BauweltMember;
|
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
|
||||||
import de.steamwar.bungeecore.sql.UserConfig;
|
|
||||||
import de.steamwar.bungeecore.util.Chat19;
|
import de.steamwar.bungeecore.util.Chat19;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||||
@ -88,10 +85,10 @@ public class BauCommand extends BasicCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setLocked(p, args[1].toUpperCase());
|
BauLock.setLocked(p, args[1].toUpperCase());
|
||||||
break;
|
break;
|
||||||
case "unlock":
|
case "unlock":
|
||||||
setLocked(p, "OPEN");
|
BauLock.setLocked(p, "OPEN");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
HelpCommand.sendBauHelp(ChatSender.of(p));
|
HelpCommand.sendBauHelp(ChatSender.of(p));
|
||||||
@ -142,7 +139,7 @@ public class BauCommand extends BasicCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isLocked(worldOwner, SteamwarUser.get(p))) {
|
if(BauLock.isLocked(worldOwner, SteamwarUser.get(p))) {
|
||||||
Message.send("BAU_LOCKED_NOALLOWED", p);
|
Message.send("BAU_LOCKED_NOALLOWED", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -325,35 +322,4 @@ public class BauCommand extends BasicCommand {
|
|||||||
Message.send("BAU_MEMBER_TOGGLE_OFF", p, Message.parse(what, p));
|
Message.send("BAU_MEMBER_TOGGLE_OFF", p, Message.parse(what, p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String BAU_LOCK_CONFIG_NAME = "baulockstate";
|
|
||||||
private static void setLocked(ProxiedPlayer p, String arg) {
|
|
||||||
SteamwarUser owner = SteamwarUser.get(p.getUniqueId());
|
|
||||||
BauLockState state;
|
|
||||||
try {
|
|
||||||
state = BauLockState.valueOf(arg);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
Message.send("BAU_LOCKED_OPTIONS", owner.getPlayer());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UserConfig.updateUserConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name());
|
|
||||||
Message.send("BAU_LOCKED_" + state.name(), owner.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
|
|
||||||
if (owner.getId() == target.getId())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
String state = UserConfig.getConfig(owner.getId(), BAU_LOCK_CONFIG_NAME);
|
|
||||||
switch (state == null ? BauLockState.OPEN : BauLockState.valueOf(state)) {
|
|
||||||
case NOBODY:
|
|
||||||
return true;
|
|
||||||
case TEAM:
|
|
||||||
return owner.getTeam() != target.getTeam();
|
|
||||||
case OPEN:
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,8 @@ public class TpCommand extends BasicCommand {
|
|||||||
} else {
|
} else {
|
||||||
sender.system("JOIN_PLAYER_BLOCK");
|
sender.system("JOIN_PLAYER_BLOCK");
|
||||||
}
|
}
|
||||||
|
}else if (BauLock.isLocked(SteamwarUser.get(bauserver.getOwner()), sender.user())) {
|
||||||
|
Message.send("BAU_LOCKED_NOALLOWED", player);
|
||||||
}else if (bauserver.getOwner().equals(player.getUniqueId()) || BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) {
|
}else if (bauserver.getOwner().equals(player.getUniqueId()) || BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) {
|
||||||
SubserverSystem.sendPlayer(subserver, player);
|
SubserverSystem.sendPlayer(subserver, player);
|
||||||
} else {
|
} else {
|
||||||
|
58
src/de/steamwar/bungeecore/sql/BauLock.java
Normale Datei
58
src/de/steamwar/bungeecore/sql/BauLock.java
Normale Datei
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
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.bungeecore.sql;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
public class BauLock {
|
||||||
|
|
||||||
|
private static final String BAU_LOCK_CONFIG_NAME = "baulockstate";
|
||||||
|
public static void setLocked(ProxiedPlayer p, String arg) {
|
||||||
|
SteamwarUser owner = SteamwarUser.get(p.getUniqueId());
|
||||||
|
BauLockState state;
|
||||||
|
try {
|
||||||
|
state = BauLockState.valueOf(arg);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Message.send("BAU_LOCKED_OPTIONS", owner.getPlayer());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserConfig.updateUserConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name());
|
||||||
|
Message.send("BAU_LOCKED_" + state.name(), owner.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isLocked(SteamwarUser owner, SteamwarUser target) {
|
||||||
|
if (owner.getId() == target.getId())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
String state = UserConfig.getConfig(owner.getId(), BAU_LOCK_CONFIG_NAME);
|
||||||
|
switch (state == null ? BauLockState.OPEN : BauLockState.valueOf(state)) {
|
||||||
|
case NOBODY:
|
||||||
|
return true;
|
||||||
|
case TEAM:
|
||||||
|
return owner.getTeam() != target.getTeam();
|
||||||
|
case OPEN:
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren