geforkt von SteamWar/BungeeCore
A probably working ignore system
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
17e971f668
Commit
cc3a5fcf18
@ -52,7 +52,7 @@ public class BungeeCore extends Plugin {
|
|||||||
public void onEnable(){
|
public void onEnable(){
|
||||||
setInstance(this);
|
setInstance(this);
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
new ErrorLogger();
|
new ErrorLogger();
|
||||||
new ConnectionListener();
|
new ConnectionListener();
|
||||||
new Forge();
|
new Forge();
|
||||||
@ -99,6 +99,8 @@ public class BungeeCore extends Plugin {
|
|||||||
new CheckCommand();
|
new CheckCommand();
|
||||||
new RankedCommand();
|
new RankedCommand();
|
||||||
new RankCommand();
|
new RankCommand();
|
||||||
|
new IgnoreCommand();
|
||||||
|
new UnIgnoreCommand();
|
||||||
|
|
||||||
new EventStarter();
|
new EventStarter();
|
||||||
new Broadcaster();
|
new Broadcaster();
|
||||||
|
@ -24,19 +24,18 @@ public class ChallengeCommand extends BasicCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(sender instanceof ProxiedPlayer)) {return;}
|
if (!(sender instanceof ProxiedPlayer))
|
||||||
|
return;
|
||||||
|
|
||||||
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
|
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
|
||||||
if(target == null){
|
if(target == null){
|
||||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cDer gewünschte Spieler ist nicht online.");
|
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cDer Herausgeforderte ist nicht online.");
|
||||||
return;
|
return;
|
||||||
}else if(target == sender){
|
}else if(target == sender){
|
||||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cSchizophren?");
|
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cSchizophren?");
|
||||||
return;
|
return;
|
||||||
}
|
}else if (IgnoreSystem.isIgnored(target, (ProxiedPlayer) sender)) {
|
||||||
|
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cDer Herausgeforderte hat dich geblockt.");
|
||||||
if (IgnoreSystem.isIgnored(target.getUniqueId(), ((ProxiedPlayer) sender).getUniqueId())) {
|
|
||||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cDer gewünschte Spieler hat dich geblockt.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,32 +1,42 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
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 IgnoreCommand extends BasicCommand {
|
public class IgnoreCommand extends BasicCommand {
|
||||||
|
|
||||||
public IgnoreCommand() {
|
public IgnoreCommand() {
|
||||||
super("ignore", null);
|
super("ignore", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender s, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if (!(s instanceof ProxiedPlayer)) return;
|
if(args.length < 1) {
|
||||||
ProxiedPlayer p = (ProxiedPlayer) s;
|
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§eignore §8[§7Spieler§8]");
|
||||||
SteamwarUser target = SteamwarUser.get(args[0]);
|
return;
|
||||||
if(target == null){
|
}
|
||||||
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§cDieser Spieler wurde nicht in der Datenbank gefunden!");
|
|
||||||
return;
|
if (!(sender instanceof ProxiedPlayer))
|
||||||
}else if(target.equals(p)){
|
return;
|
||||||
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§cWie willst du dich selber ignorieren?");
|
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||||
return;
|
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
||||||
}else {
|
|
||||||
IgnoreSystem.ignore(p.getUniqueId(), target.getUuid());
|
SteamwarUser target = SteamwarUser.get(args[0]);
|
||||||
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§7Du ignorierst nun " + target.getUserName() + ".");
|
if(target == null){
|
||||||
}
|
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§cDiesen Spieler gibt es nicht.");
|
||||||
}
|
return;
|
||||||
|
}else if(target.equals(user)){
|
||||||
}
|
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§cWie willst du dich selber ignorieren?");
|
||||||
|
return;
|
||||||
|
}else if(IgnoreSystem.isIgnored(user, target)){
|
||||||
|
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§cDu ignorierst diesen Spieler bereits.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IgnoreSystem.ignore(user, target);
|
||||||
|
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§7Du ignorierst nun §e" + target.getUserName() + "§8.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class MsgCommand extends BasicCommand {
|
|||||||
if(target == null){
|
if(target == null){
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler ist derzeit nicht online!");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler ist derzeit nicht online!");
|
||||||
return;
|
return;
|
||||||
}else if (IgnoreSystem.isIgnored(target.getUniqueId(), player.getUniqueId())) {
|
}else if (IgnoreSystem.isIgnored(target, player)) {
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler hat dich geblockt!");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler hat dich geblockt!");
|
||||||
return;
|
return;
|
||||||
}else if(target.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){
|
}else if(target.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){
|
||||||
|
@ -31,14 +31,12 @@ public class RCommand extends BasicCommand {
|
|||||||
if(target == null){
|
if(target == null){
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDu hast bisher mit niemandem geschrieben!");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDu hast bisher mit niemandem geschrieben!");
|
||||||
return;
|
return;
|
||||||
}
|
}else if(!target.isConnected()){
|
||||||
if (IgnoreSystem.isIgnored(target.getUniqueId(), player.getUniqueId())) {
|
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler hat dich geblockt!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(!target.isConnected()){
|
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler ist derzeit nicht online!");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler ist derzeit nicht online!");
|
||||||
return;
|
return;
|
||||||
|
}else if (IgnoreSystem.isIgnored(target, player)) {
|
||||||
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler hat dich geblockt!");
|
||||||
|
return;
|
||||||
}else if(target.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){
|
}else if(target.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){
|
||||||
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler empfängt derzeit keine Chatnachrichten!");
|
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler empfängt derzeit keine Chatnachrichten!");
|
||||||
return;
|
return;
|
||||||
|
@ -1,29 +1,40 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
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 UnIgnoreCommand extends BasicCommand {
|
public class UnIgnoreCommand extends BasicCommand {
|
||||||
|
|
||||||
public UnIgnoreCommand() {
|
public UnIgnoreCommand() {
|
||||||
super("unignore", null);
|
super("unignore", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender s, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if (!(s instanceof ProxiedPlayer)) return;
|
if(args.length < 1) {
|
||||||
ProxiedPlayer p = (ProxiedPlayer) s;
|
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§eunignore §8[§7Spieler§8]");
|
||||||
SteamwarUser t = SteamwarUser.get(args[0]);
|
return;
|
||||||
if(t == null){
|
}
|
||||||
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§cDieser Spieler ist derzeit nicht online!");
|
|
||||||
return;
|
if (!(sender instanceof ProxiedPlayer))
|
||||||
}else {
|
return;
|
||||||
IgnoreSystem.unIgnore(p.getUniqueId(), t.getUuid());
|
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||||
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§7Du beachtest nun " + t.getUserName() + " wieder.");
|
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
||||||
}
|
|
||||||
}
|
SteamwarUser target = SteamwarUser.get(args[0]);
|
||||||
|
if(target == null){
|
||||||
|
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§cDiesen Spieler gibt es nicht!");
|
||||||
|
return;
|
||||||
|
}else if(!IgnoreSystem.isIgnored(user, target)){
|
||||||
|
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§cDu ignorierst diesen Spieler nicht.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IgnoreSystem.unIgnore(user, target);
|
||||||
|
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§7Du empfängst nun wieder Nachrichten von §e" + target.getUserName() + "§8.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,26 +1,31 @@
|
|||||||
package de.steamwar.bungeecore.sql;
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import java.util.UUID;
|
|
||||||
|
import java.sql.SQLException;
|
||||||
public class IgnoreSystem{
|
|
||||||
//SQL-Table:
|
public class IgnoreSystem{
|
||||||
// Name=UserIgnoreSystem
|
private IgnoreSystem(){}
|
||||||
// Content: a ([UUID des Ignoriers]z[UUID des Ignorierten])
|
|
||||||
// UUID is a HEX-Number -> it cant contain 'z'
|
public static boolean isIgnored(ProxiedPlayer ignorer, ProxiedPlayer ignored){
|
||||||
|
SteamwarUser user = SteamwarUser.get(ignorer.getUniqueId());
|
||||||
public static boolean isIgnored(UUID ignorer, UUID ignored) {
|
SteamwarUser target = SteamwarUser.get(ignored.getUniqueId());
|
||||||
try {
|
return isIgnored(user, target);
|
||||||
return !(SQL.select("SELECT * FROM UserIgnoreSystem WHERE a = ?", ignorer.toString()+"z"+ignored.toString())).next();
|
}
|
||||||
} catch (SQLException e) {return false;}
|
|
||||||
}
|
public static boolean isIgnored(SteamwarUser ignorer, SteamwarUser ignored) {
|
||||||
public static void ignore(UUID victim, UUID offender) {
|
try {
|
||||||
if (victim==null || offender==null) return;
|
return !SQL.select("SELECT * FROM Ignore WHERE Ignorer = ? AND Ignored = ?", ignorer.getId(), ignored.getId()).next();
|
||||||
if (!isIgnored(victim,offender))
|
} catch (SQLException e) {
|
||||||
SQL.update("INSERT INTO UserIgnoreSystem (a) VALUES (?)",victim.toString()+"z"+offender.toString());
|
throw new SecurityException("Could not check if ignored", e);
|
||||||
}
|
}
|
||||||
public static void unIgnore(UUID victim, UUID offender) {
|
}
|
||||||
if (victim==null || offender==null) return;
|
|
||||||
SQL.update("DELETE FROM UserIgnoreSystem WHERE a = " + victim.toString()+"z"+offender.toString());
|
public static void ignore(SteamwarUser ignorer, SteamwarUser ignored) {
|
||||||
}
|
SQL.update("INSERT INTO Ignore (Ignorer, Ignored) VALUES (?, ?)", ignorer.getId(), ignored.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unIgnore(SteamwarUser ignorer, SteamwarUser ignored) {
|
||||||
|
SQL.update("DELETE FROM Ignore WHERE Ignorer = ? AND Ignored = ?", ignorer.getId(), ignored.getId());
|
||||||
|
}
|
||||||
}
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren