init project...

Signed-off-by: j502647092 <jtb1@163.com>
master
j502647092 2015-05-06 13:38:26 +08:00
commit 7014e7947d
8 changed files with 247 additions and 0 deletions

40
.gitignore vendored Normal file
View File

@ -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

BIN
lib/AuthMe-3.5-SNAPSHOT.jar Normal file

Binary file not shown.

Binary file not shown.

67
pom.xml Normal file
View File

@ -0,0 +1,67 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.CityCraft</groupId>
<artifactId>JoinMessage</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>JoinMessage</name>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>shadowvolt-repo</id>
<url>http://ci.shadowvolt.com/plugin/repository/everything/</url>
</repository>
<repository>
<id>vault-repo</id>
<name>Vault Repository</name>
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<type>jar</type>
<version>1.8.3-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/spigot-api-1.8.3-R0.1-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>fr.xephi.authme.AuthMe</groupId>
<artifactId>AuthMe</artifactId>
<version>3.5-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/AuthMe-3.5-SNAPSHOT.jar</systemPath>
</dependency>
<!--
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.5</version>
<scope>provided</scope>
</dependency> -->
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -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<String, String[]> msg = new HashMap<String, String[]>();
List<Map<String, String[]>> perms = new ArrayList<Map<String, String[]>>();
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;
}
}
}

View File

@ -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<Map<?, ?>> 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);
}
}
}
}
}
}

19
src/config.yml Normal file
View File

@ -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=='

8
src/plugin.yml Normal file
View File

@ -0,0 +1,8 @@
name: JoinMessage
main: cn.citycraft.JoinMessage.Main
version: 1.0
auther: 喵♂呜
commands:
joinmessage:
description: 登录消息
usage: 使用/joinmessage reload 重载配置!