mirror of
				https://e.coding.net/circlecloud/Yum.git
				synced 2025-11-04 05:06:02 +00:00 
			
		
		
		
	
							
								
								
									
										36
									
								
								.classpath
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								.classpath
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<classpath>
 | 
			
		||||
	<classpathentry kind="src" output="target/classes" path="src/main/java">
 | 
			
		||||
		<attributes>
 | 
			
		||||
			<attribute name="optional" value="true"/>
 | 
			
		||||
			<attribute name="maven.pomderived" value="true"/>
 | 
			
		||||
		</attributes>
 | 
			
		||||
	</classpathentry>
 | 
			
		||||
	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
 | 
			
		||||
		<attributes>
 | 
			
		||||
			<attribute name="maven.pomderived" value="true"/>
 | 
			
		||||
		</attributes>
 | 
			
		||||
	</classpathentry>
 | 
			
		||||
	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
 | 
			
		||||
		<attributes>
 | 
			
		||||
			<attribute name="optional" value="true"/>
 | 
			
		||||
			<attribute name="maven.pomderived" value="true"/>
 | 
			
		||||
		</attributes>
 | 
			
		||||
	</classpathentry>
 | 
			
		||||
	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
 | 
			
		||||
		<attributes>
 | 
			
		||||
			<attribute name="maven.pomderived" value="true"/>
 | 
			
		||||
		</attributes>
 | 
			
		||||
	</classpathentry>
 | 
			
		||||
	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
 | 
			
		||||
		<attributes>
 | 
			
		||||
			<attribute name="maven.pomderived" value="true"/>
 | 
			
		||||
		</attributes>
 | 
			
		||||
	</classpathentry>
 | 
			
		||||
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
 | 
			
		||||
		<attributes>
 | 
			
		||||
			<attribute name="maven.pomderived" value="true"/>
 | 
			
		||||
		</attributes>
 | 
			
		||||
	</classpathentry>
 | 
			
		||||
	<classpathentry kind="output" path="target/classes"/>
 | 
			
		||||
</classpath>
 | 
			
		||||
							
								
								
									
										38
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
			
		||||
# Eclipse stuff
 | 
			
		||||
/.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
 | 
			
		||||
							
								
								
									
										23
									
								
								.project
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								.project
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<projectDescription>
 | 
			
		||||
	<name>Yum</name>
 | 
			
		||||
	<comment></comment>
 | 
			
		||||
	<projects>
 | 
			
		||||
	</projects>
 | 
			
		||||
	<buildSpec>
 | 
			
		||||
		<buildCommand>
 | 
			
		||||
			<name>org.eclipse.jdt.core.javabuilder</name>
 | 
			
		||||
			<arguments>
 | 
			
		||||
			</arguments>
 | 
			
		||||
		</buildCommand>
 | 
			
		||||
		<buildCommand>
 | 
			
		||||
			<name>org.eclipse.m2e.core.maven2Builder</name>
 | 
			
		||||
			<arguments>
 | 
			
		||||
			</arguments>
 | 
			
		||||
		</buildCommand>
 | 
			
		||||
	</buildSpec>
 | 
			
		||||
	<natures>
 | 
			
		||||
		<nature>org.eclipse.jdt.core.javanature</nature>
 | 
			
		||||
		<nature>org.eclipse.m2e.core.maven2Nature</nature>
 | 
			
		||||
	</natures>
 | 
			
		||||
</projectDescription>
 | 
			
		||||
							
								
								
									
										38
									
								
								pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								pom.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
			
		||||
<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>Yum</artifactId>
 | 
			
		||||
	<version>0.0.1-SNAPSHOT</version>
 | 
			
		||||
	<name>Yum</name>
 | 
			
		||||
  <build>
 | 
			
		||||
    <finalName>${project.name}</finalName>
 | 
			
		||||
    <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>spigot-repo</id>
 | 
			
		||||
			<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
 | 
			
		||||
		</repository>
 | 
			
		||||
	</repositories>
 | 
			
		||||
	<dependencies>
 | 
			
		||||
		<dependency>
 | 
			
		||||
			<groupId>org.spigotmc</groupId>
 | 
			
		||||
			<artifactId>spigot-api</artifactId>
 | 
			
		||||
			<type>jar</type>
 | 
			
		||||
			<version>1.8.3-R0.1-SNAPSHOT</version>
 | 
			
		||||
		</dependency>
 | 
			
		||||
	</dependencies>
 | 
			
		||||
	<properties>
 | 
			
		||||
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 | 
			
		||||
	</properties>
 | 
			
		||||
</project>
 | 
			
		||||
							
								
								
									
										44
									
								
								src/main/java/cn/citycraft/Yum/Yum.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								src/main/java/cn/citycraft/Yum/Yum.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
/**
 | 
			
		||||
 * 
 | 
			
		||||
 */
 | 
			
		||||
package cn.citycraft.Yum;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.Command;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.bukkit.plugin.java.JavaPlugin;
 | 
			
		||||
 | 
			
		||||
import cn.citycraft.Yum.utils.DownloadUtils;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * MC插件仓库
 | 
			
		||||
 * 
 | 
			
		||||
 * @author 蒋天蓓
 | 
			
		||||
 *         2015年8月21日下午5:14:39
 | 
			
		||||
 */
 | 
			
		||||
public class Yum extends JavaPlugin {
 | 
			
		||||
	String url = "http://ci.citycraft.cn:8800/jenkins/job/%1$s/lastSuccessfulBuild/artifact/target/%1$s.jar";
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
 | 
			
		||||
		switch (args.length) {
 | 
			
		||||
		case 0:
 | 
			
		||||
			break;
 | 
			
		||||
		case 2:
 | 
			
		||||
			switch (args[0]) {
 | 
			
		||||
			case "install":
 | 
			
		||||
				if (DownloadUtils.download(String.format(url, args[1]), getDataFolder().getParent(), args[1])) {
 | 
			
		||||
					sender.sendMessage("OK");
 | 
			
		||||
				} else {
 | 
			
		||||
					sender.sendMessage("Error");
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
			case "remove":
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										67
									
								
								src/main/java/cn/citycraft/Yum/utils/DownloadUtils.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								src/main/java/cn/citycraft/Yum/utils/DownloadUtils.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,67 @@
 | 
			
		||||
/**
 | 
			
		||||
 * 
 | 
			
		||||
 */
 | 
			
		||||
package cn.citycraft.Yum.utils;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedInputStream;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.FileOutputStream;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
import java.util.logging.Level;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author 蒋天蓓
 | 
			
		||||
 *         2015年8月21日下午6:08:09
 | 
			
		||||
 *         TODO
 | 
			
		||||
 */
 | 
			
		||||
public class DownloadUtils {
 | 
			
		||||
	public static boolean download(String url, String dir, String filename) {
 | 
			
		||||
 | 
			
		||||
		BufferedInputStream in = null;
 | 
			
		||||
		FileOutputStream fout = null;
 | 
			
		||||
		try {
 | 
			
		||||
			URL fileUrl = new URL(url);
 | 
			
		||||
			System.out.println("下载地址: " + url);
 | 
			
		||||
			int fileLength = fileUrl.openConnection().getContentLength();
 | 
			
		||||
			System.out.println("文件长度: " + fileLength);
 | 
			
		||||
			in = new BufferedInputStream(fileUrl.openStream());
 | 
			
		||||
			File file = new File(dir, filename + ".jar");
 | 
			
		||||
			if (!file.exists()) {
 | 
			
		||||
				file.createNewFile();
 | 
			
		||||
			}
 | 
			
		||||
			fout = new FileOutputStream(file);
 | 
			
		||||
 | 
			
		||||
			byte[] data = new byte[1024];
 | 
			
		||||
 | 
			
		||||
			// long downloaded = 0L;
 | 
			
		||||
			int count;
 | 
			
		||||
			while ((count = in.read(data)) != -1) {
 | 
			
		||||
				// downloaded += count;
 | 
			
		||||
				fout.write(data, 0, count);
 | 
			
		||||
				// int percent = (int) (downloaded / fileLength);
 | 
			
		||||
			}
 | 
			
		||||
			return true;
 | 
			
		||||
		} catch (Exception ex) {
 | 
			
		||||
			Bukkit.getLogger().log(Level.WARNING, "The auto-updater tried to download a new update, but was unsuccessful.", ex);
 | 
			
		||||
			return false;
 | 
			
		||||
		} finally {
 | 
			
		||||
			try {
 | 
			
		||||
				if (in != null) {
 | 
			
		||||
					in.close();
 | 
			
		||||
				}
 | 
			
		||||
			} catch (IOException ex) {
 | 
			
		||||
				Bukkit.getLogger().log(Level.SEVERE, null, ex);
 | 
			
		||||
			}
 | 
			
		||||
			try {
 | 
			
		||||
				if (fout != null) {
 | 
			
		||||
					fout.close();
 | 
			
		||||
				}
 | 
			
		||||
			} catch (IOException ex) {
 | 
			
		||||
				Bukkit.getLogger().log(Level.SEVERE, null, ex);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								src/main/resources/plugin.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								src/main/resources/plugin.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
name: Yum
 | 
			
		||||
main: cn.citycraft.Yum.Yum
 | 
			
		||||
website: http://ci.citycraft.cn:8800/jenkins/job/Yum/
 | 
			
		||||
version: 1.0
 | 
			
		||||
commands:
 | 
			
		||||
  yum:
 | 
			
		||||
    description: MC插件仓库
 | 
			
		||||
    usage: §6使用§a/yum help§6查看帮助!
 | 
			
		||||
		Reference in New Issue
	
	Block a user