-
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 409f07e
Showing
74 changed files
with
9,274 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,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="Spigot-API-1.12.2-79a30d7-20190219-1130" level="project" /> | ||
</component> | ||
</module> |
Binary file added
BIN
+16 Bytes
out/production/RolePlayChat-PLUGIN/META-INF/RolePlayChat-PLUGIN.kotlin_module
Binary file not shown.
Binary file added
BIN
+3.57 KB
out/production/RolePlayChat-PLUGIN/fr/nathanael2611/roleplaychat/plugin/RolePlayChat.class
Binary file not shown.
Binary file added
BIN
+3.41 KB
...tion/RolePlayChat-PLUGIN/fr/nathanael2611/roleplaychat/plugin/command/CommandRPName.class
Binary file not shown.
Binary file added
BIN
+1.4 KB
...oduction/RolePlayChat-PLUGIN/fr/nathanael2611/roleplaychat/plugin/core/ChatConfig$1.class
Binary file not shown.
Binary file added
BIN
+4.74 KB
...production/RolePlayChat-PLUGIN/fr/nathanael2611/roleplaychat/plugin/core/ChatConfig.class
Binary file not shown.
Binary file added
BIN
+795 Bytes
out/production/RolePlayChat-PLUGIN/fr/nathanael2611/roleplaychat/plugin/core/ChatType.class
Binary file not shown.
Binary file added
BIN
+1.26 KB
...duction/RolePlayChat-PLUGIN/fr/nathanael2611/roleplaychat/plugin/core/EnumCHatTypes.class
Binary file not shown.
Binary file added
BIN
+1.17 KB
...oduction/RolePlayChat-PLUGIN/fr/nathanael2611/roleplaychat/plugin/core/EnumMessages.class
Binary file not shown.
Binary file added
BIN
+2.6 KB
...duction/RolePlayChat-PLUGIN/fr/nathanael2611/roleplaychat/plugin/core/RolePlayNames.class
Binary file not shown.
Binary file added
BIN
+4.37 KB
...oduction/RolePlayChat-PLUGIN/fr/nathanael2611/roleplaychat/plugin/event/ChatHandler.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+611 Bytes
out/production/RolePlayChat-PLUGIN/org/json/JSONPointerException.class
Binary file not shown.
Binary file added
BIN
+438 Bytes
out/production/RolePlayChat-PLUGIN/org/json/JSONPropertyIgnore.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.08 KB
out/production/RolePlayChat-PLUGIN/org/json/XMLParserConfiguration.class
Binary file not shown.
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,9 @@ | ||
name: RolePlayChat | ||
version: 1.0 | ||
author: Nathanael2611 | ||
main: fr.nathanael2611.roleplaychat.plugin.RolePlayChat | ||
commands: | ||
roleplaychat: | ||
description: RolePlayChat command | ||
rpname: | ||
description: NameRP |
67 changes: 67 additions & 0 deletions
67
src/fr/nathanael2611/roleplaychat/plugin/RolePlayChat.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,67 @@ | ||
package fr.nathanael2611.roleplaychat.plugin; | ||
|
||
import fr.nathanael2611.roleplaychat.plugin.command.CommandRPName; | ||
import fr.nathanael2611.roleplaychat.plugin.core.ChatConfig; | ||
import fr.nathanael2611.roleplaychat.plugin.event.ChatHandler; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.command.TabCompleter; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class RolePlayChat extends JavaPlugin { | ||
|
||
private static ChatConfig chatConfig; | ||
private static File roleplayNames; | ||
|
||
@Override | ||
public void onEnable() { | ||
super.onEnable(); | ||
new ChatHandler(this); | ||
getDataFolder().mkdir(); | ||
File file = new File(getDataFolder(), "config.properties"); | ||
roleplayNames = new File(getDataFolder(), "roleplaynames.json"); | ||
if(!file.exists()) { | ||
try { | ||
file.createNewFile(); | ||
} catch (IOException ex) { | ||
ex.printStackTrace(); | ||
} | ||
} | ||
if(!roleplayNames.exists()) { | ||
try { | ||
roleplayNames.createNewFile(); | ||
} catch (IOException ex) { | ||
ex.printStackTrace(); | ||
} | ||
} | ||
try { | ||
chatConfig = new ChatConfig(file); | ||
} catch (Exception ex) { | ||
ex.printStackTrace(); | ||
} | ||
this.getCommand("rpname").setExecutor(new CommandRPName()); | ||
this.getCommand("rpname").setTabCompleter((commandSender, command, s, strings) -> { | ||
List<String> list = new ArrayList<>(); | ||
for(Player player : Bukkit.getServer().getOnlinePlayers()){ | ||
list.add(player.getName()); | ||
} | ||
return list; | ||
}); | ||
} | ||
|
||
public static ChatConfig getChatConfig() { | ||
return chatConfig; | ||
} | ||
|
||
public static File getRoleplayNamesFile() { | ||
return roleplayNames; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/fr/nathanael2611/roleplaychat/plugin/command/CommandRPName.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,60 @@ | ||
package fr.nathanael2611.roleplaychat.plugin.command; | ||
|
||
import fr.nathanael2611.roleplaychat.plugin.RolePlayChat; | ||
import fr.nathanael2611.roleplaychat.plugin.core.EnumMessages; | ||
import fr.nathanael2611.roleplaychat.plugin.core.RolePlayNames; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CommandRPName implements CommandExecutor { | ||
@Override | ||
public boolean onCommand(final CommandSender sender, final Command command, final String s, final String[] args) { | ||
if (args.length >= 1) { | ||
List<String> players = new ArrayList<>(); | ||
for (Player online : Bukkit.getServer().getOnlinePlayers()) { | ||
players.add(online.getName()); | ||
} | ||
|
||
|
||
|
||
if (players.contains(args[0]) && args.length > 1) { | ||
if (sender.hasPermission("roleplaychat.setrpname.other")) { | ||
StringBuilder builder = new StringBuilder(); | ||
for(int i = 1; i < args.length; i++){ | ||
builder.append(" ").append(args[i]); | ||
} | ||
String rpName = builder.toString().substring(1); | ||
RolePlayNames.setRPName(args[0], rpName); | ||
String result = RolePlayChat.getChatConfig().getMessageTemplate(EnumMessages.SETRPNAMEOTHER); | ||
if (result.contains("{player}")) result = result.replace("{player}", args[0]); | ||
if (result.contains("{rpname}")) result = result.replace("{rpname}", rpName); | ||
sender.sendMessage(result); | ||
} else { | ||
sender.sendMessage(RolePlayChat.getChatConfig().getMessageTemplate(EnumMessages.NOPERM)); | ||
} | ||
}else{ | ||
StringBuilder builder = new StringBuilder(); | ||
for(String str : args){ | ||
builder.append(" ").append(str); | ||
} | ||
String rpName = builder.toString().substring(1); | ||
RolePlayNames.setRPName(sender.getName(), rpName); | ||
String result = RolePlayChat.getChatConfig().getMessageTemplate(EnumMessages.SETRPNAME); | ||
if (result.contains("{player}")) result = result.replace("{player}", sender.getName()); | ||
if (result.contains("{rpname}")) result = result.replace("{rpname}", rpName); | ||
sender.sendMessage(result); | ||
} | ||
} else { | ||
sender.sendMessage("§cCorrect usage: /rpname <rpname> OR /rpname <player> <rpname>"); | ||
} | ||
return false; | ||
} | ||
|
||
} |
132 changes: 132 additions & 0 deletions
132
src/fr/nathanael2611/roleplaychat/plugin/core/ChatConfig.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,132 @@ | ||
package fr.nathanael2611.roleplaychat.plugin.core; | ||
|
||
import com.sun.org.apache.bcel.internal.generic.NOP; | ||
import fr.nathanael2611.roleplaychat.plugin.RolePlayChat; | ||
|
||
import java.io.*; | ||
import java.nio.charset.Charset; | ||
import java.util.Properties; | ||
|
||
public class ChatConfig { | ||
|
||
private ChatType hrp; | ||
private ChatType normal; | ||
private ChatType shout; | ||
private ChatType whisp; | ||
private ChatType action; | ||
|
||
private String noperm_template; | ||
private String setrpname_template; | ||
private String setrpname_other_template; | ||
|
||
private ChatType[] chatTypes; | ||
|
||
private final File configFile; | ||
|
||
private Properties properties = new Properties(); | ||
|
||
private FileInputStream input; | ||
|
||
public ChatConfig(File configFile) throws Exception { | ||
this.configFile = configFile; | ||
reload(); | ||
chatTypes = new ChatType[]{ | ||
hrp, normal, shout, whisp, action | ||
}; | ||
} | ||
|
||
public void reload() throws Exception { | ||
input = new FileInputStream(configFile); | ||
properties.load( | ||
new InputStreamReader(input, Charset.forName("UTF-8")) | ||
); | ||
|
||
createPropertyIfNull("prefix.hrp", "("); | ||
createPropertyIfNull("prefix.normal", ""); | ||
createPropertyIfNull("prefix.shout", "!"); | ||
createPropertyIfNull("prefix.whisp", "$"); | ||
createPropertyIfNull("prefix.action", "*"); | ||
|
||
createPropertyIfNull("distance.hrp", "0"); | ||
createPropertyIfNull("distance.normal", "15"); | ||
createPropertyIfNull("distance.shout", "30"); | ||
createPropertyIfNull("distance.whisp", "2"); | ||
createPropertyIfNull("distance.action", "15"); | ||
|
||
createPropertyIfNull("format.hrp", "§7[HRP] {player} ({rpname}) : {message}"); | ||
createPropertyIfNull("format.normal", "[RP] {rpname} : {message}"); | ||
createPropertyIfNull("format.shout", "§c[RP-SHOUT] {rpname} : {message}"); | ||
createPropertyIfNull("format.whisp", "§2[RP-WHISP] {rpname} : {message}"); | ||
createPropertyIfNull("format.action", "§a1§o{rpname} {message}"); | ||
|
||
createPropertyIfNull("message.nopermission", "§cVous n'avez pas la permission."); | ||
createPropertyIfNull("message.setrpname", "§aVotre nom rp a été défini à {rpname}"); | ||
createPropertyIfNull("message.setrpname.other", "§aLe nom rp de {player] a été défini à {rpname}"); | ||
|
||
hrp = new ChatType( | ||
properties.getProperty("prefix.hrp"), | ||
Integer.parseInt(properties.getProperty("distance.hrp")), | ||
properties.getProperty("format.hrp") | ||
); | ||
normal = new ChatType( | ||
properties.getProperty("prefix.normal"), | ||
Integer.parseInt(properties.getProperty("distance.normal")), | ||
properties.getProperty("format.normal") | ||
); | ||
shout = new ChatType( | ||
properties.getProperty("prefix.shout"), | ||
Integer.parseInt(properties.getProperty("distance.shout")), | ||
properties.getProperty("format.shout") | ||
); | ||
whisp = new ChatType( | ||
properties.getProperty("prefix.whisp"), | ||
Integer.parseInt(properties.getProperty("distance.whisp")), | ||
properties.getProperty("format.whisp") | ||
); | ||
action = new ChatType( | ||
properties.getProperty("prefix.action"), | ||
Integer.parseInt(properties.getProperty("distance.action")), | ||
properties.getProperty("format.action") | ||
); | ||
|
||
noperm_template = properties.getProperty("message.nopermission"); | ||
setrpname_template = properties.getProperty("message.setrpname"); | ||
setrpname_other_template = properties.getProperty("message.setrpname.other"); | ||
|
||
properties.store(new OutputStreamWriter(new FileOutputStream(configFile), "UTF-8"), ""); | ||
input.close(); | ||
} | ||
|
||
public void createPropertyIfNull(String key, String value) { | ||
if(properties.getProperty(key) == null){ | ||
properties.setProperty(key, value); | ||
} | ||
} | ||
|
||
public ChatType getChatType(EnumCHatTypes type){ | ||
switch (type){ | ||
case HRP: return hrp; | ||
case SHOUT: return shout; | ||
case WISPH: return whisp; | ||
case ACTION: return action; | ||
case NORMAL: return normal; | ||
} | ||
return normal; | ||
} | ||
|
||
public String getMessageTemplate(EnumMessages msgTemplate){ | ||
switch (msgTemplate){ | ||
case NOPERM:return noperm_template; | ||
case SETRPNAME:return setrpname_template; | ||
case SETRPNAMEOTHER:return setrpname_other_template; | ||
|
||
|
||
|
||
} | ||
return ""; | ||
} | ||
|
||
public ChatType[] getChatTypes() { | ||
return chatTypes; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/fr/nathanael2611/roleplaychat/plugin/core/ChatType.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,26 @@ | ||
package fr.nathanael2611.roleplaychat.plugin.core; | ||
|
||
public class ChatType { | ||
|
||
private String prefix; | ||
private int distance; | ||
private String format; | ||
|
||
public ChatType(String prefix, int distance, String format) { | ||
this.prefix = prefix; | ||
this.distance = distance; | ||
this.format = format; | ||
} | ||
|
||
public String getPrefix() { | ||
return prefix; | ||
} | ||
|
||
public int getDistance() { | ||
return distance; | ||
} | ||
|
||
public String getFormat() { | ||
return format; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/fr/nathanael2611/roleplaychat/plugin/core/EnumCHatTypes.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,5 @@ | ||
package fr.nathanael2611.roleplaychat.plugin.core; | ||
|
||
public enum EnumCHatTypes { | ||
HRP, NORMAL, SHOUT, WISPH,ACTION | ||
} |
5 changes: 5 additions & 0 deletions
5
src/fr/nathanael2611/roleplaychat/plugin/core/EnumMessages.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,5 @@ | ||
package fr.nathanael2611.roleplaychat.plugin.core; | ||
|
||
public enum EnumMessages { | ||
SETRPNAME, SETRPNAMEOTHER, NOPERM | ||
} |
Oops, something went wrong.