Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin/
target/
.classpath
.project
Expand Down
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>permissions</artifactId>
<version>3.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
40 changes: 35 additions & 5 deletions src/main/java/hef/IRCTransport/IRCTransport.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;

/**
* IRCTransport for Bukkit
*
Expand All @@ -39,6 +43,7 @@ public class IRCTransport extends JavaPlugin {
private String nickSuffix = "";
private boolean verbose;
private static final Logger log = Logger.getLogger("Minecraft");
private PermissionHandler perms = null;

public String getIrcServer()
{
Expand Down Expand Up @@ -99,7 +104,15 @@ public void onEnable() {

initDatabase();

//Event Registration
Plugin check = this.getServer().getPluginManager().getPlugin("Permissions");
if (check != null) {
perms = ((Permissions) check).getHandler();
log.info("Permissions detected");
} else {
log.info("Permissions not detected.");
}

//Event Registration

//establish list of players
Player[] players = getServer().getOnlinePlayers();
Expand Down Expand Up @@ -329,16 +342,33 @@ public String getAutoJoinKey()
* Nick prefix is only used as a default
* @return the nickPrefix
*/
public String getNickPrefix() {
return nickPrefix;
public String getNickPrefix(Player player) {
String prefix = nickPrefix;
prefix = prefix.replace("%group%", getPermGroup(player));
return prefix;
}

/**
* nick suffix is only used as a default
* If the plugin has a suffix of "_mc" and a player with nick of "player" will become "player_mc"
* @return the nickSuffix
*/
public String getNickSuffix() {
return nickSuffix;
public String getNickSuffix(Player player) {
String suffix = nickSuffix;
suffix = suffix.replace("%group%", getPermGroup(player));
return suffix;
}

/**
* get the player's group
* @return the player's Group
*/
private String getPermGroup(Player player) {
if (perms == null)
return "";
String result = perms.getGroup(player.getWorld().getName(), player.getName());
if (result == null)
return "";
return result;
}
}
2 changes: 1 addition & 1 deletion src/main/java/hef/IRCTransport/IrcAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public IrcAgent(IRCTransport instance, Player player) {
if (null == getSettings())
{
setSettings(new AgentSettings(player));
getSettings().setIrcNick(String.format("%s%s%s",plugin.getNickPrefix(), player.getName(), plugin.getNickSuffix()));
getSettings().setIrcNick(String.format("%s%s%s",plugin.getNickPrefix(player), player.getName(), plugin.getNickSuffix(player)));
}
else
{
Expand Down