This repository has been archived by the owner on Jul 27, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code merge with Spigot version. Added game-first-join message template.
- Loading branch information
Showing
42 changed files
with
1,234 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
src/main/java/com/cnaude/purpleirc/Commands/AddBan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Copyright (C) 2014 cnaude | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.cnaude.purpleirc.Commands; | ||
|
||
import com.cnaude.purpleirc.PurpleIRC; | ||
import com.cnaude.purpleirc.Utilities.BotsAndChannels; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.CommandSender; | ||
import org.pircbotx.Channel; | ||
import org.pircbotx.User; | ||
|
||
/** | ||
* | ||
* @author Chris Naude | ||
*/ | ||
public class AddBan implements IRCCommandInterface { | ||
|
||
private final PurpleIRC plugin; | ||
private final String usage = "([bot]) ([channel]) [user|mask]"; | ||
private final String desc = "Add IRC users to the ban list."; | ||
private final String name = "addban"; | ||
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage; | ||
|
||
/** | ||
* | ||
* @param plugin the PurpleIRC plugin | ||
*/ | ||
public AddBan(PurpleIRC plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
/** | ||
* | ||
* @param sender | ||
* @param args | ||
*/ | ||
@Override | ||
public void dispatch(CommandSender sender, String[] args) { | ||
BotsAndChannels bac; | ||
int idx; | ||
|
||
if (args.length >= 4) { | ||
bac = new BotsAndChannels(plugin, sender, args[1], args[2]); | ||
idx = 3; | ||
} else if (args.length == 2) { | ||
bac = new BotsAndChannels(plugin, sender); | ||
idx = 1; | ||
} else { | ||
sender.sendMessage(fullUsage); | ||
return; | ||
} | ||
if (bac.bot.size() > 0 && bac.channel.size() > 0) { | ||
for (String botName : bac.bot) { | ||
for (String channelName : bac.channel) { | ||
for (int i = idx; i < args.length; i++) { | ||
|
||
String nick = args[i]; | ||
String mask = nick; | ||
Channel channel = plugin.ircBots.get(botName).getChannel(channelName); | ||
if (channel != null) { | ||
for (User user : channel.getUsers()) { | ||
if (user.getNick().equalsIgnoreCase(nick)) { | ||
mask = "*!*" + user.getLogin() + "@" + user.getHostmask(); | ||
} | ||
} | ||
} | ||
if (mask.split("[\\!\\@]", 3).length == 3) { | ||
plugin.ircBots.get(botName).addBan(channelName, mask, sender); | ||
plugin.ircBots.get(botName).ban(channelName, mask); | ||
} else { | ||
sender.sendMessage(ChatColor.RED + "Invalid user or mask: " | ||
+ ChatColor.WHITE + mask); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public String name() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public String desc() { | ||
return desc; | ||
} | ||
|
||
@Override | ||
public String usage() { | ||
return usage; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.