1
1
mirror of https://github.com/geekfrog/PermissionsTime.git synced 2024-11-24 17:28:51 +00:00

修复路径BUG 更换统计

This commit is contained in:
GeekFrog 2017-07-31 01:45:11 +08:00
parent 6953d1b5dd
commit b94799dcea
4 changed files with 183 additions and 173 deletions

253
pom.xml
View File

@ -1,125 +1,132 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<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"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<modelVersion>4.0.0</modelVersion> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>gg.frog.mc</groupId> <modelVersion>4.0.0</modelVersion>
<artifactId>permissionstime</artifactId> <groupId>gg.frog.mc</groupId>
<version>0.2.3-SNAPSHOT</version> <artifactId>permissionstime</artifactId>
<packaging>jar</packaging> <version>0.2.4-SNAPSHOT</version>
<name>PermissionsTime</name> <packaging>jar</packaging>
<description>支持跨服的权限限时插件</description> <name>PermissionsTime</name>
<organization> <description>支持跨服的权限限时插件</description>
<url>https://github.com/geekfrog</url> <organization>
<name>GeekFrog</name> <url>https://github.com/geekfrog</url>
</organization> <name>GeekFrog</name>
<url>https://github.com/geekfrog/PermissionsTime/</url> </organization>
<properties> <url>https://github.com/geekfrog/PermissionsTime/</url>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <properties>
</properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<repositories> </properties>
<repository> <repositories>
<id>spigotmc-repo</id> <repository>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url> <id>spigotmc-repo</id>
</repository> <url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
<repository> </repository>
<id>dakani</id> <repository>
<name>Dakani Nexus Repo</name> <id>dakani</id>
<url>https://repo.dakanilabs.com/repository/public/</url> <name>Dakani Nexus Repo</name>
</repository> <url>https://repo.dakanilabs.com/repository/public/</url>
<repository> </repository>
<id>vault-repo</id> <repository>
<url>http://nexus.hc.to/content/repositories/pub_releases/</url> <id>vault-repo</id>
</repository> <url>http://nexus.hc.to/content/repositories/pub_releases/</url>
<repository> </repository>
<id>Plugin Metrics</id> <repository>
<url>http://repo.mcstats.org/content/repositories/public</url> <id>bstats-repo</id>
</repository> <url>http://repo.bstats.org/content/repositories/releases/</url>
</repositories> </repository>
<dependencies> </repositories>
<dependency> <dependencies>
<groupId>org.bukkit</groupId> <dependency>
<artifactId>bukkit</artifactId> <groupId>org.bukkit</groupId>
<version>1.8-R0.1-SNAPSHOT</version> <artifactId>bukkit</artifactId>
<type>jar</type> <version>1.9-R0.1-SNAPSHOT</version>
<scope>compile</scope> <type>jar</type>
</dependency> <scope>compile</scope>
<dependency> </dependency>
<groupId>org.mcstats.bukkit</groupId> <dependency>
<artifactId>metrics</artifactId> <groupId>org.bstats</groupId>
<version>R8-SNAPSHOT</version> <artifactId>bstats-bukkit</artifactId>
<scope>compile</scope> <version>1.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.milkbowl.vault</groupId> <groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId> <artifactId>VaultAPI</artifactId>
<version>1.6</version> <version>1.6</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>lib.PatPeter.SQLibrary</groupId> <groupId>lib.PatPeter.SQLibrary</groupId>
<artifactId>SQLibrary</artifactId> <artifactId>SQLibrary</artifactId>
<version>7.1</version> <version>7.1</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>PermissionsTime-${project.version}</finalName> <finalName>PermissionsTime-${project.version}</finalName>
<sourceDirectory>${basedir}/src/main</sourceDirectory> <sourceDirectory>${basedir}/src/main</sourceDirectory>
<resources> <resources>
<resource> <resource>
<directory>src/resources</directory> <directory>src/resources</directory>
</resource> </resource>
<resource> <resource>
<targetPath>.</targetPath> <targetPath>.</targetPath>
<filtering>true</filtering> <filtering>true</filtering>
<directory>${basedir}</directory> <directory>${basedir}</directory>
<includes> <includes>
<include>README.md</include> <include>README.md</include>
</includes> </includes>
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version> <version>3.6.1</version>
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
<!-- 解决资源文件的编码问题 --> <!-- 解决资源文件的编码问题 -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version> <version>3.0.2</version>
<configuration> <configuration>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version> <version>3.0.0</version>
<configuration> <configuration>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet> <artifactSet>
<includes> <includes>
<include>org.mcstats.*:*</include> <include>org.bstats:*</include>
</includes> </includes>
</artifactSet> </artifactSet>
</configuration> <relocations>
<executions> <relocation>
<execution> <pattern>org.bstats</pattern>
<phase>package</phase> <!-- Replace this with your package! -->
<goals> <shadedPattern>gg.frog.mc.permissionstime</shadedPattern>
<goal>shade</goal> </relocation>
</goals> </relocations>
</execution> </configuration>
</executions> <executions>
</plugin> <execution>
</plugins> <phase>package</phase>
</build> <goals>
<ciManagement> <goal>shade</goal>
<system>Jenkins</system> </goals>
<url>http://ci.frog.gg/jenkins/job/PermissionsTime/</url> </execution>
</ciManagement> </executions>
</plugin>
</plugins>
</build>
<ciManagement>
<system>Jenkins</system>
<url>http://ci.frog.gg/jenkins/job/PermissionsTime/</url>
</ciManagement>
</project> </project>

View File

@ -5,6 +5,7 @@ import java.util.Locale;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
@ -41,7 +42,6 @@ public class PluginMain extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
super.onEnable();
pm = this; pm = this;
cm = new ConfigManager(pm); cm = new ConfigManager(pm);
getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "===============================")); getServer().getConsoleSender().sendMessage(StrUtil.messageFormat(PluginCfg.PLUGIN_PREFIX + "==============================="));
@ -64,8 +64,8 @@ public class PluginMain extends JavaPlugin {
} }
if (PluginCfg.IS_METRICS) { if (PluginCfg.IS_METRICS) {
try { try {
org.mcstats.Metrics mcstats = new org.mcstats.Metrics(pm); Metrics metrics = new Metrics(pm);
mcstats.start(); // metrics.addCustomChart(new Metrics.SimplePie("chart_id", () -> "My value"));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -132,7 +132,6 @@ public class PluginMain extends JavaPlugin {
@Override @Override
public void onDisable() { public void onDisable() {
super.onDisable();
getServer().getServicesManager().unregisterAll(pm); getServer().getServicesManager().unregisterAll(pm);
Bukkit.getScheduler().cancelTasks(pm); Bukkit.getScheduler().cancelTasks(pm);
try { try {

View File

@ -4,57 +4,61 @@ import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
public class FileUtil { public class FileUtil {
public interface FindFilesDo { public interface FindFilesDo {
boolean isProcess(String fileName); boolean isProcess(String fileName);
void process(String fileName, InputStream is);
}
public static void findFilesFromJar(FindFilesDo ffd, Class<?> jarClazz) { void process(String fileName, InputStream is);
JarFile jarFile = null; }
try {
String jarFilePath = jarClazz.getProtectionDomain().getCodeSource().getLocation().getFile();
jarFile = new JarFile(jarFilePath);
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry e = entries.nextElement();
if (ffd.isProcess(e.getName())) {
InputStream is = jarFile.getInputStream(e);
ffd.process(e.getName(), is);
try {
is.close();
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (jarFile != null) {
try {
jarFile.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static void writeOnFile(String fileName, String content) { public static void findFilesFromJar(FindFilesDo ffd, Class<?> jarClazz) {
FileWriter fw; JarFile jarFile = null;
try { try {
File f = new File(fileName); String jarFilePath = jarClazz.getProtectionDomain().getCodeSource().getLocation().getFile();
fw = new FileWriter(f, true); jarFilePath = URLDecoder.decode(jarFilePath, Charset.defaultCharset().name());
fw.write(content + "\r\n"); jarFile = new JarFile(jarFilePath);
fw.close(); Enumeration<JarEntry> entries = jarFile.entries();
} catch (IOException e) { while (entries.hasMoreElements()) {
e.printStackTrace(); JarEntry e = entries.nextElement();
} if (ffd.isProcess(e.getName())) {
} InputStream is = jarFile.getInputStream(e);
ffd.process(e.getName(), is);
try {
is.close();
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (jarFile != null) {
try {
jarFile.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static void writeOnFile(String fileName, String content) {
FileWriter fw;
try {
File f = new File(fileName);
fw = new FileWriter(f, true);
fw.write(content + "\r\n");
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }

View File

@ -1,5 +1,5 @@
name: PermissionsTime name: PermissionsTime
version: 0.2.3-SNAPSHOT version: 0.2.4-SNAPSHOT
main: gg.frog.mc.permissionstime.PluginMain main: gg.frog.mc.permissionstime.PluginMain
author: GeekFrog author: GeekFrog
softdepend: softdepend: