commit 7014e7947df9e20b9c07412bca4513438d2f1af0 Author: j502647092 Date: Wed May 6 13:38:26 2015 +0800 init project... Signed-off-by: j502647092 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d80b42 --- /dev/null +++ b/.gitignore @@ -0,0 +1,40 @@ +# Eclipse stuff +/.classpath +/.project +/.settings + +# netbeans +/nbproject + +# we use maven! +/build.xml + +# maven +/target +/repo + +# vim +.*.sw[a-p] + +# various other potential build files +/build +/bin +/dist +/manifest.mf + +/world + +# Mac filesystem dust +*.DS_Store + +# intellij +*.iml +*.ipr +*.iws +.idea/ + +# Project Stuff +/src/main/resources/Soulbound + +# Atlassian Stuff +/atlassian-ide-plugin.xml \ No newline at end of file diff --git a/lib/AuthMe-3.5-SNAPSHOT.jar b/lib/AuthMe-3.5-SNAPSHOT.jar new file mode 100644 index 0000000..2f524d2 Binary files /dev/null and b/lib/AuthMe-3.5-SNAPSHOT.jar differ diff --git a/lib/spigot-api-1.8.3-R0.1-SNAPSHOT.jar b/lib/spigot-api-1.8.3-R0.1-SNAPSHOT.jar new file mode 100644 index 0000000..f5d47b5 Binary files /dev/null and b/lib/spigot-api-1.8.3-R0.1-SNAPSHOT.jar differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a7a4db6 --- /dev/null +++ b/pom.xml @@ -0,0 +1,67 @@ + + 4.0.0 + cn.CityCraft + JoinMessage + 0.0.1-SNAPSHOT + JoinMessage + + src + + + src + + **/*.java + + + + + + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + + + + + shadowvolt-repo + http://ci.shadowvolt.com/plugin/repository/everything/ + + + vault-repo + Vault Repository + http://nexus.theyeticave.net/content/repositories/pub_releases + + + + + org.spigotmc + spigot-api + jar + 1.8.3-R0.1-SNAPSHOT + system + ${project.basedir}/lib/spigot-api-1.8.3-R0.1-SNAPSHOT.jar + + + fr.xephi.authme.AuthMe + AuthMe + 3.5-SNAPSHOT + system + ${project.basedir}/lib/AuthMe-3.5-SNAPSHOT.jar + + + + + UTF-8 + + \ No newline at end of file diff --git a/src/cn/citycraft/JoinMessage/Main.java b/src/cn/citycraft/JoinMessage/Main.java new file mode 100644 index 0000000..6a21d27 --- /dev/null +++ b/src/cn/citycraft/JoinMessage/Main.java @@ -0,0 +1,35 @@ +package cn.citycraft.JoinMessage; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; + +import cn.citycraft.JoinMessage.listen.PlayerJoin; + +public class Main extends JavaPlugin{ + + HashMap msg = new HashMap(); + List> perms = new ArrayList>(); + + public boolean authme; + + public void onLoad() { + this.saveDefaultConfig(); + } + + public void onEnable() { + this.getLogger().info("登录提示语已加载..."); + PluginManager pm = Bukkit.getPluginManager(); + pm.registerEvents(new PlayerJoin(this), this); + if (pm.isPluginEnabled("AuthMe")) { + this.getLogger().info("Find AuthMe Hook..."); + authme = true; + } + } + +} diff --git a/src/cn/citycraft/JoinMessage/listen/PlayerJoin.java b/src/cn/citycraft/JoinMessage/listen/PlayerJoin.java new file mode 100644 index 0000000..a6e337c --- /dev/null +++ b/src/cn/citycraft/JoinMessage/listen/PlayerJoin.java @@ -0,0 +1,78 @@ +package cn.citycraft.JoinMessage.listen; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + +import cn.citycraft.JoinMessage.Main; +import fr.xephi.authme.events.LoginEvent; + +public class PlayerJoin implements Listener { + + Main plugin; + + String[] lines; + + Player p; + + public PlayerJoin(Main main) { + plugin = main; + + } + + // Message: + // - joinmessage.vip: + // - '%name%' + // - '%displayname%' + // - joinmessage + // - vip + + @EventHandler(priority = EventPriority.HIGHEST) + public void onJoin(PlayerJoinEvent e) { + if (e.getJoinMessage() == null) { + return; + } + if (plugin.authme) { + return; + } + e.setJoinMessage(null); + Player p = e.getPlayer(); + this.sendJoinMessage(p); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onLogin(LoginEvent e) { + Player p = e.getPlayer(); + this.sendJoinMessage(p); + } + + void sendJoinMessage(Player p) { + String pn = p.getName(); + String pdn = p.getDisplayName(); + List> perms = plugin.getConfig().getMapList("Message"); + for (Map smp : perms) { + for (Entry key : smp.entrySet()) { + String permission = (String) key.getKey(); + if (p.hasPermission(permission)) { + String[] msg = ((ArrayList) key.getValue()) + .toArray(new String[0]); + for (String message : msg) { + message = message.replaceAll("%name%", pn) + .replaceAll("%displayname%", pdn) + .replaceAll("&", "§"); + Bukkit.broadcastMessage(message); + } + } + } + } + } + +} diff --git a/src/config.yml b/src/config.yml new file mode 100644 index 0000000..e394a5a --- /dev/null +++ b/src/config.yml @@ -0,0 +1,19 @@ +#本文件为登录插件的主配置文件 +#服务器名称 +servername: '' +#插件名称 +pluginname: '&6[&3JoinMessage&6]&r' +#提示消息 +Message: +#exapmle +#- permission.vip 权限节点 +# - 'fist line' 自定义消息(%name% ==> 玩家名称,%displayname% ==> 带称号的名称) +# - '%name%' +# - '%displayname%' +# - 'fourth line' +- joinmessage.vip: + - '&1==&2==&3==&4==&5==&6==&7==&8==&9==&a==&b==&c==&d==&e==&f==&1==&2==&3==&4==&5==&6==&7==&8==&9==&a==&b==&c==&d==&e==&f==' + - '' + - ' &6欢迎&a&l至&e&l尊&c&l会员 &a%displayname% &3回到了&d服务器!' + - '' + - '&1==&2==&3==&4==&5==&6==&7==&8==&9==&a==&b==&c==&d==&e==&f==&1==&2==&3==&4==&5==&6==&7==&8==&9==&a==&b==&c==&d==&e==&f==' diff --git a/src/plugin.yml b/src/plugin.yml new file mode 100644 index 0000000..b6f4e37 --- /dev/null +++ b/src/plugin.yml @@ -0,0 +1,8 @@ +name: JoinMessage +main: cn.citycraft.JoinMessage.Main +version: 1.0 +auther: 喵♂呜 +commands: + joinmessage: + description: 登录消息 + usage: 使用/joinmessage reload 重载配置! \ No newline at end of file