-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a49b1c4
Showing
6 changed files
with
183 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="lib" path="C:/Users/Ramon/Desktop/Coding/bukkit-1.7.9-R0.2.jar"> | ||
<attributes> | ||
<attribute name="javadoc_location" value="http://jd.bukkit.org/apidocs/"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>RoleplayChat</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
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,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
Binary file not shown.
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,14 @@ | ||
name: RoleplayChat | ||
main: nomarthehero.RoleplayChat | ||
version: 1.0 | ||
commands: | ||
roleplay: | ||
description: Enable roleplay chat | ||
usage: /roleplay | ||
permission: roleplay.use | ||
permission-message: Missing permission. | ||
rp: | ||
description: Enable roleplay chat | ||
usage: /roleplay | ||
permission: roleplay.use | ||
permission-message: Missing permission. |
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,130 @@ | ||
package nomarthehero; | ||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.AsyncPlayerChatEvent; | ||
import org.bukkit.event.player.PlayerJoinEvent; | ||
import org.bukkit.event.player.PlayerQuitEvent; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
|
||
public class RoleplayChat extends JavaPlugin implements Listener, CommandExecutor { | ||
|
||
//Every 5~10 min "Hey <player>, you know you're still talking in roleplay chat?" (async runnable) | ||
|
||
private ArrayList<String> roleplayers = new ArrayList<String>(); | ||
private ArrayList<String> staff = new ArrayList<String>(); | ||
|
||
|
||
public void onEnable() { | ||
|
||
getCommand("roleplay").setExecutor(this); | ||
getCommand("rp").setExecutor(this); | ||
getServer().getPluginManager().registerEvents(this, this); | ||
|
||
} | ||
|
||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, | ||
String label, String[] args) { | ||
|
||
if (command.getName().equalsIgnoreCase("roleplay") || command.getName().equalsIgnoreCase("rp")) { | ||
|
||
Player player = (Player)sender; | ||
String playerName = player.getName(); | ||
|
||
if (roleplayers.contains(playerName)) { | ||
|
||
roleplayers.remove(playerName); | ||
player.sendMessage(ChatColor.YELLOW + "Disabled roleplay chat!"); | ||
|
||
} else { | ||
|
||
roleplayers.add(playerName); | ||
player.sendMessage(ChatColor.YELLOW + "Enabled roleplay chat!"); | ||
player.sendMessage(ChatColor.YELLOW + "Roleplayers will have a yellow chat, and their messages " + ChatColor.RED + "won't" + ChatColor.YELLOW + " be sent in global chat."); | ||
player.sendMessage(ChatColor.YELLOW + "To disable it, type /roleplay again."); | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
return true; | ||
} | ||
|
||
@EventHandler | ||
public void onChat(AsyncPlayerChatEvent e) { | ||
|
||
Player player = e.getPlayer(); | ||
|
||
if (isRoleplayer(player)) { | ||
|
||
String message = e.getMessage(); | ||
message = ChatColor.YELLOW + message; | ||
|
||
e.setCancelled(true); | ||
|
||
for (String playerName : roleplayers) { | ||
|
||
Bukkit.getPlayer(playerName).sendMessage(ChatColor.YELLOW + "[RP] " + player.getDisplayName() + ChatColor.YELLOW + ": " + message); | ||
|
||
} | ||
|
||
for (String playerName : staff) { | ||
|
||
if (!roleplayers.contains(playerName)) { | ||
|
||
Bukkit.getPlayer(playerName).sendMessage(ChatColor.YELLOW + "[RP] " + player.getDisplayName() + ChatColor.YELLOW + ": " + message); | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
@EventHandler | ||
public void onJoin(PlayerJoinEvent e) { | ||
|
||
Player player = e.getPlayer(); | ||
|
||
if (player.hasPermission("roleplay.staff")) { | ||
staff.add(player.getName()); | ||
} | ||
|
||
} | ||
|
||
@EventHandler | ||
public void onLeave(PlayerQuitEvent e) { | ||
|
||
roleplayers.remove(e.getPlayer().getName()); | ||
|
||
} | ||
|
||
private boolean isRoleplayer(Player player) { | ||
|
||
if (roleplayers.contains(player.getName())) { | ||
|
||
return true; | ||
|
||
} | ||
|
||
return false; | ||
|
||
} | ||
|
||
|
||
|
||
} |