Plugin list gen, fixes
It'll generate a plugin list file on each start #37
This commit is contained in:
parent
a24c4a5e54
commit
75ab715c6e
9 changed files with 156 additions and 128 deletions
|
@ -1,13 +1,13 @@
|
||||||
<component name="libraryTable">
|
<component name="libraryTable">
|
||||||
<library name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT">
|
<library name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-20180420.081408-78.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-20180513.014306-84.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC>
|
<JAVADOC>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-20180420.081408-78-javadoc.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-20180513.014306-84-javadoc.jar!/" />
|
||||||
</JAVADOC>
|
</JAVADOC>
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-20180420.081408-78-sources.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-20180513.014306-84-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
</component>
|
</component>
|
|
@ -1,13 +1,13 @@
|
||||||
<component name="libraryTable">
|
<component name="libraryTable">
|
||||||
<library name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT">
|
<library name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT">
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-20180506.041854-145.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-SNAPSHOT.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC>
|
<JAVADOC>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-20180506.041854-145-javadoc.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-SNAPSHOT-javadoc.jar!/" />
|
||||||
</JAVADOC>
|
</JAVADOC>
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-20180506.041854-145-sources.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.12.2-R0.1-SNAPSHOT/spigot-api-1.12.2-R0.1-SNAPSHOT-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
</component>
|
</component>
|
|
@ -6,6 +6,13 @@
|
||||||
<option value="$PROJECT_DIR$/pom.xml" />
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="ignoredFiles">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
|
||||||
</project>
|
</project>
|
|
@ -3,7 +3,6 @@
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/BuildConfigUpdater/BuildConfigUpdater.iml" filepath="$PROJECT_DIR$/BuildConfigUpdater/BuildConfigUpdater.iml" />
|
<module fileurl="file://$PROJECT_DIR$/BuildConfigUpdater/BuildConfigUpdater.iml" filepath="$PROJECT_DIR$/BuildConfigUpdater/BuildConfigUpdater.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/ButtonCore.iml" filepath="$PROJECT_DIR$/.idea/ButtonCore.iml" />
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml" filepath="$PROJECT_DIR$/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml" />
|
<module fileurl="file://$PROJECT_DIR$/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml" filepath="$PROJECT_DIR$/ButtonCore/ButtonCore (1) (com.github.TBMCPlugins.ButtonCore).iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/ButtonProcessor/ButtonProcessor.iml" filepath="$PROJECT_DIR$/ButtonProcessor/ButtonProcessor.iml" />
|
<module fileurl="file://$PROJECT_DIR$/ButtonProcessor/ButtonProcessor.iml" filepath="$PROJECT_DIR$/ButtonProcessor/ButtonProcessor.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
||||||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
||||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.10" level="project" />
|
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.10" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
|
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
|
||||||
|
|
|
@ -8,6 +8,7 @@ import buttondevteam.lib.chat.Color;
|
||||||
import buttondevteam.lib.chat.TBMCChatAPI;
|
import buttondevteam.lib.chat.TBMCChatAPI;
|
||||||
import buttondevteam.lib.player.TBMCPlayerBase;
|
import buttondevteam.lib.player.TBMCPlayerBase;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
@ -16,7 +17,9 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MainPlugin extends JavaPlugin {
|
public class MainPlugin extends JavaPlugin {
|
||||||
public static MainPlugin Instance;
|
public static MainPlugin Instance;
|
||||||
|
@ -52,6 +55,11 @@ public class MainPlugin extends JavaPlugin {
|
||||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§aGREEN", Color.Green, "green"));
|
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§aGREEN", Color.Green, "green"));
|
||||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§bBLUE", Color.Blue, "blue"));
|
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§bBLUE", Color.Blue, "blue"));
|
||||||
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§5PURPLE", Color.DarkPurple, "purple"));
|
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§5PURPLE", Color.DarkPurple, "purple"));
|
||||||
|
try {
|
||||||
|
Files.write(new File("plugins", "plugins.txt").toPath(), Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(p -> (CharSequence) p.getDataFolder().getName())::iterator);
|
||||||
|
} catch (IOException e) {
|
||||||
|
TBMCCoreAPI.SendException("Failed to write plugin list!", e);
|
||||||
|
}
|
||||||
logger.info(pdfFile.getName() + " has been Enabled (V." + pdfFile.getVersion() + ") Test: " + Test + ".");
|
logger.info(pdfFile.getName() + " has been Enabled (V." + pdfFile.getVersion() + ") Test: " + Test + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,13 +75,14 @@ public class MainPlugin extends JavaPlugin {
|
||||||
System.out.println("Updating " + files.length + " plugins...");
|
System.out.println("Updating " + files.length + " plugins...");
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
try {
|
try {
|
||||||
Files.move(file.toPath(), new File("plugins").toPath(), StandardCopyOption.REPLACE_EXISTING)
|
Files.move(file.toPath(), new File("plugins", file.getName()).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
System.out.println("Updated " + file.getName());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("Update complete!");
|
System.out.println("Update complete!");
|
||||||
});
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setupPermissions() {
|
private boolean setupPermissions() {
|
||||||
|
|
|
@ -17,8 +17,8 @@ public class Channel {
|
||||||
public final String DisplayName;
|
public final String DisplayName;
|
||||||
public final Color color;
|
public final Color color;
|
||||||
public final String ID;
|
public final String ID;
|
||||||
public @Nullable
|
@Nullable
|
||||||
String[] IDs;
|
public String[] IDs;
|
||||||
/**
|
/**
|
||||||
* Filters both the sender and the targets
|
* Filters both the sender and the targets
|
||||||
*/
|
*/
|
||||||
|
@ -29,14 +29,10 @@ public class Channel {
|
||||||
/**
|
/**
|
||||||
* Creates a channel.
|
* Creates a channel.
|
||||||
*
|
*
|
||||||
* @param displayname
|
* @param displayname The name that should appear at the start of the message. <b>A chat color is expected at the beginning (§9).</b>
|
||||||
* The name that should appear at the start of the message. <b>A chat color is expected at the beginning (§9).</b>
|
* @param color The default color of the messages sent in the channel
|
||||||
* @param color
|
* @param command The command to be used for the channel <i>without /</i>. For example "mod". It's also used for scoreboard objective names.
|
||||||
* The default color of the messages sent in the channel
|
* @param filteranderrormsg Checks all senders against the criteria provided here and sends the message if the index matches the sender's - if no score at all, displays the error.<br>
|
||||||
* @param command
|
|
||||||
* The command to be used for the channel <i>without /</i>. For example "mod". It's also used for scoreboard objective names.
|
|
||||||
* @param filteranderrormsg
|
|
||||||
* Checks all senders against the criteria provided here and sends the message if the index matches the sender's - if no score at all, displays the error.<br>
|
|
||||||
* May be null to send to everyone.
|
* May be null to send to everyone.
|
||||||
*/
|
*/
|
||||||
public Channel(String displayname, Color color, String command,
|
public Channel(String displayname, Color color, String command,
|
||||||
|
@ -69,8 +65,7 @@ public class Channel {
|
||||||
* Convenience method for the function parameter of {@link #Channel(String, Color, String, Function)}. It checks if the sender is OP or optionally has the specified group. The error message is
|
* Convenience method for the function parameter of {@link #Channel(String, Color, String, Function)}. It checks if the sender is OP or optionally has the specified group. The error message is
|
||||||
* generated automatically.
|
* generated automatically.
|
||||||
*
|
*
|
||||||
* @param permgroup
|
* @param permgroup The group that can access the channel or <b>null</b> to only allow OPs.
|
||||||
* The group that can access the channel or <b>null</b> to only allow OPs.
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Function<CommandSender, RecipientTestResult> inGroupFilter(String permgroup) {
|
public static Function<CommandSender, RecipientTestResult> inGroupFilter(String permgroup) {
|
||||||
|
@ -106,8 +101,7 @@ public class Channel {
|
||||||
/**
|
/**
|
||||||
* Creates a result that indicates an <b>error</b>
|
* Creates a result that indicates an <b>error</b>
|
||||||
*
|
*
|
||||||
* @param errormessage
|
* @param errormessage The error message to show the sender if they don't meet the criteria.
|
||||||
* The error message to show the sender if they don't meet the criteria.
|
|
||||||
*/
|
*/
|
||||||
public RecipientTestResult(String errormessage) {
|
public RecipientTestResult(String errormessage) {
|
||||||
this.errormessage = errormessage;
|
this.errormessage = errormessage;
|
||||||
|
@ -116,8 +110,7 @@ public class Channel {
|
||||||
/**
|
/**
|
||||||
* Creates a result that indicates a <b>success</b>
|
* Creates a result that indicates a <b>success</b>
|
||||||
*
|
*
|
||||||
* @param score
|
* @param score The score that identifies the target group. For example, the index of the town or nation to send to.
|
||||||
* The score that identifies the target group. For example, the index of the town or nation to send to.
|
|
||||||
*/
|
*/
|
||||||
public RecipientTestResult(int score) {
|
public RecipientTestResult(int score) {
|
||||||
this.score = score;
|
this.score = score;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="ExternalSystem" externalSystem="Maven" />
|
||||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||||
<output url="file://$MODULE_DIR$/target/classes" />
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package buttondevteam.buttonproc;
|
package buttondevteam.buttonproc;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import javax.annotation.processing.AbstractProcessor;
|
import javax.annotation.processing.AbstractProcessor;
|
||||||
import javax.annotation.processing.RoundEnvironment;
|
import javax.annotation.processing.RoundEnvironment;
|
||||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||||
|
@ -7,23 +11,32 @@ import javax.annotation.processing.SupportedSourceVersion;
|
||||||
import javax.lang.model.SourceVersion;
|
import javax.lang.model.SourceVersion;
|
||||||
import javax.lang.model.element.AnnotationMirror;
|
import javax.lang.model.element.AnnotationMirror;
|
||||||
import javax.lang.model.element.Element;
|
import javax.lang.model.element.Element;
|
||||||
|
import javax.lang.model.element.Modifier;
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
import java.util.List;
|
import javax.lang.model.util.Elements;
|
||||||
import java.util.Set;
|
import javax.tools.Diagnostic.Kind;
|
||||||
|
|
||||||
/** * A simple session bean type annotation processor. The implementation * is based on the standard annotation processing API in Java 6. */
|
|
||||||
@SupportedSourceVersion(SourceVersion.RELEASE_8)
|
|
||||||
@SupportedAnnotationTypes("buttondevteam.*")
|
@SupportedAnnotationTypes("buttondevteam.*")
|
||||||
public class ButtonProcessor extends AbstractProcessor {
|
public class ButtonProcessor extends AbstractProcessor {
|
||||||
/** * Check if both @Stateful and @Stateless are present in an * session bean. If so, emits a warning message. */
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(Set<? extends TypeElement> typeElements, RoundEnvironment roundEnv) { // TODO: SEparate JAR
|
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||||
for (TypeElement te : typeElements) {
|
for (TypeElement te : annotations) {
|
||||||
Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(te);
|
Set<? extends Element> classes = roundEnv.getElementsAnnotatedWith(te);
|
||||||
for (Element element : elements) {
|
for (Element targetcl : classes) {
|
||||||
System.out.println("Processing " + element);
|
System.out.println("Processing " + targetcl);
|
||||||
List<? extends AnnotationMirror> annotationMirrors = element.getAnnotationMirrors();
|
List<? extends AnnotationMirror> annotationMirrors = processingEnv.getElementUtils()
|
||||||
|
.getAllAnnotationMirrors(targetcl);
|
||||||
System.out.println("Annotations: " + annotationMirrors);
|
System.out.println("Annotations: " + annotationMirrors);
|
||||||
|
Function<String, Boolean> hasAnnotation = ann -> annotationMirrors.stream()
|
||||||
|
.anyMatch(am -> am.getAnnotationType().toString().contains(ann));
|
||||||
|
if (hasAnnotation.apply("ChromaGamerEnforcer") && !hasAnnotation.apply("UserClass")
|
||||||
|
&& !targetcl.getModifiers().contains(Modifier.ABSTRACT))
|
||||||
|
processingEnv.getMessager().printMessage(Kind.ERROR,
|
||||||
|
"No UserClass annotation found for " + targetcl.getSimpleName(), targetcl);
|
||||||
|
if (hasAnnotation.apply("TBMCPlayerEnforcer") && !hasAnnotation.apply("PlayerClass")
|
||||||
|
&& !targetcl.getModifiers().contains(Modifier.ABSTRACT))
|
||||||
|
processingEnv.getMessager().printMessage(Kind.ERROR,
|
||||||
|
"No PlayerClass annotation found for " + targetcl.getSimpleName(), targetcl);
|
||||||
for (AnnotationMirror annotation : annotationMirrors) {
|
for (AnnotationMirror annotation : annotationMirrors) {
|
||||||
String type = annotation.getAnnotationType().toString();
|
String type = annotation.getAnnotationType().toString();
|
||||||
System.out.println("Type: " + type);
|
System.out.println("Type: " + type);
|
||||||
|
@ -32,4 +45,9 @@ public class ButtonProcessor extends AbstractProcessor {
|
||||||
}
|
}
|
||||||
return true; // claim the annotations
|
return true; // claim the annotations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SourceVersion getSupportedSourceVersion() {
|
||||||
|
return SourceVersion.latestSupported();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue