geforkt von SteamWar/BungeeCore
Merge pull request 'Ignore-System initial push' (#93) from IgnoreSystem into master
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
c881849f38
@ -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();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
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.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@ -22,14 +23,20 @@ public class ChallengeCommand extends BasicCommand {
|
|||||||
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§echallenge §8[§7Spieler§8]");
|
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§echallenge §8[§7Spieler§8]");
|
||||||
return;
|
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.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Subserver subserver = Subserver.getSubserver(target);
|
Subserver subserver = Subserver.getSubserver(target);
|
||||||
|
42
src/de/steamwar/bungeecore/commands/IgnoreCommand.java
Normale Datei
42
src/de/steamwar/bungeecore/commands/IgnoreCommand.java
Normale Datei
@ -0,0 +1,42 @@
|
|||||||
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
public class IgnoreCommand extends BasicCommand {
|
||||||
|
|
||||||
|
public IgnoreCommand() {
|
||||||
|
super("ignore", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, String[] args) {
|
||||||
|
if(args.length < 1) {
|
||||||
|
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§eignore §8[§7Spieler§8]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sender instanceof ProxiedPlayer))
|
||||||
|
return;
|
||||||
|
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||||
|
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(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.");
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
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.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.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -37,6 +38,9 @@ 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, 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,6 +1,7 @@
|
|||||||
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.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;
|
||||||
@ -30,11 +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(!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;
|
||||||
|
40
src/de/steamwar/bungeecore/commands/UnIgnoreCommand.java
Normale Datei
40
src/de/steamwar/bungeecore/commands/UnIgnoreCommand.java
Normale Datei
@ -0,0 +1,40 @@
|
|||||||
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
public class UnIgnoreCommand extends BasicCommand {
|
||||||
|
|
||||||
|
public UnIgnoreCommand() {
|
||||||
|
super("unignore", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(CommandSender sender, String[] args) {
|
||||||
|
if(args.length < 1) {
|
||||||
|
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§8/§eunignore §8[§7Spieler§8]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sender instanceof ProxiedPlayer))
|
||||||
|
return;
|
||||||
|
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
31
src/de/steamwar/bungeecore/sql/IgnoreSystem.java
Normale Datei
31
src/de/steamwar/bungeecore/sql/IgnoreSystem.java
Normale Datei
@ -0,0 +1,31 @@
|
|||||||
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class IgnoreSystem{
|
||||||
|
private IgnoreSystem(){}
|
||||||
|
|
||||||
|
public static boolean isIgnored(ProxiedPlayer ignorer, ProxiedPlayer ignored){
|
||||||
|
SteamwarUser user = SteamwarUser.get(ignorer.getUniqueId());
|
||||||
|
SteamwarUser target = SteamwarUser.get(ignored.getUniqueId());
|
||||||
|
return isIgnored(user, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isIgnored(SteamwarUser ignorer, SteamwarUser ignored) {
|
||||||
|
try {
|
||||||
|
return !SQL.select("SELECT * FROM IgnoredPlayers WHERE Ignorer = ? AND Ignored = ?", ignorer.getId(), ignored.getId()).next();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new SecurityException("Could not check if ignored", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ignore(SteamwarUser ignorer, SteamwarUser ignored) {
|
||||||
|
SQL.update("INSERT INTO IgnoredPlayers (Ignorer, Ignored) VALUES (?, ?)", ignorer.getId(), ignored.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unIgnore(SteamwarUser ignorer, SteamwarUser ignored) {
|
||||||
|
SQL.update("DELETE FROM IgnoredPlayers WHERE Ignorer = ? AND Ignored = ?", ignorer.getId(), ignored.getId());
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren