Fixes I thought were merged

This commit is contained in:
Norbi Peti 2018-05-15 23:34:34 +02:00
parent 739276e797
commit eb8dff3a41
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
9 changed files with 41 additions and 50 deletions

View file

@ -46,11 +46,6 @@
<configuration> <configuration>
<artifactSet> <artifactSet>
</artifactSet> </artifactSet>
<pluginExecution>
<action>
<execute />
</action>
</pluginExecution>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>

View file

@ -56,7 +56,7 @@ public class CommandCaller implements CommandExecutor {
cmd = TBMCChatAPI.GetCommands().get(path); cmd = TBMCChatAPI.GetCommands().get(path);
} }
if (cmd == null) { if (cmd == null) {
if (subcmds == null || subcmds.length > 0) if (subcmds.length > 0) //Subcmds will always have value here (see assignment above)
sender.sendMessage(subcmds); sender.sendMessage(subcmds);
else { else {
final String errormsg = "§cYou don't have access to any of this command's subcommands or it doesn't have any."; final String errormsg = "§cYou don't have access to any of this command's subcommands or it doesn't have any.";

View file

@ -19,7 +19,6 @@ import java.nio.file.Files;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import java.util.Arrays; 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;
@ -42,19 +41,19 @@ public class MainPlugin extends JavaPlugin {
TBMCChatAPI.AddCommand(this, ScheduledRestartCommand.class); TBMCChatAPI.AddCommand(this, ScheduledRestartCommand.class);
TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this); TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class); TBMCCoreAPI.RegisterUserClass(TBMCPlayerBase.class);
TBMCChatAPI.RegisterChatChannel(Channel.GlobalChat = new Channel("§fOOC§f", Color.White, "ooc", null)); TBMCChatAPI.RegisterChatChannel(Channel.GlobalChat = new Channel("§fOOC§f", Color.White, "ooc", null));
Channel.GlobalChat.IDs = new String[]{"g"}; //Support /g as well Channel.GlobalChat.IDs = new String[]{"g"}; //Support /g as well
TBMCChatAPI.RegisterChatChannel( TBMCChatAPI.RegisterChatChannel(
Channel.AdminChat = new Channel("§cADMIN§f", Color.Red, "a", Channel.inGroupFilter(null))); Channel.AdminChat = new Channel("§cADMIN§f", Color.Red, "a", Channel.inGroupFilter(null)));
TBMCChatAPI.RegisterChatChannel( TBMCChatAPI.RegisterChatChannel(
Channel.ModChat = new Channel("§9MOD§f", Color.Blue, "mod", Channel.inGroupFilter("mod"))); Channel.ModChat = new Channel("§9MOD§f", Color.Blue, "mod", Channel.inGroupFilter("mod")));
TBMCChatAPI.RegisterChatChannel(new Channel("§6DEV§", Color.Gold, "dev", Channel.inGroupFilter("developer"))); TBMCChatAPI.RegisterChatChannel(new Channel("§6DEV§", Color.Gold, "dev", Channel.inGroupFilter("developer")));
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§cRED", Color.DarkRed, "red")); TBMCChatAPI.RegisterChatChannel(new ChatRoom("§cRED", Color.DarkRed, "red"));
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§6ORANGE", Color.Gold, "orange")); TBMCChatAPI.RegisterChatChannel(new ChatRoom("§6ORANGE", Color.Gold, "orange"));
TBMCChatAPI.RegisterChatChannel(new ChatRoom("§eYELLOW", Color.Yellow, "yellow")); TBMCChatAPI.RegisterChatChannel(new ChatRoom("§eYELLOW", Color.Yellow, "yellow"));
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 { try {
Files.write(new File("plugins", "plugins.txt").toPath(), Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(p -> (CharSequence) p.getDataFolder().getName())::iterator); Files.write(new File("plugins", "plugins.txt").toPath(), Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(p -> (CharSequence) p.getDataFolder().getName())::iterator);
} catch (IOException e) { } catch (IOException e) {
@ -68,20 +67,20 @@ public class MainPlugin extends JavaPlugin {
logger.info("Saving player data..."); logger.info("Saving player data...");
TBMCPlayerBase.savePlayers(); TBMCPlayerBase.savePlayers();
logger.info("Player data saved."); logger.info("Player data saved.");
new Thread(() -> { new Thread(() -> {
File[] files = PluginUpdater.updatedir.listFiles(); File[] files = PluginUpdater.updatedir.listFiles();
if (files == null) if (files == null)
return; return;
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", file.getName()).toPath(), StandardCopyOption.REPLACE_EXISTING); Files.move(file.toPath(), new File("plugins", file.getName()).toPath(), StandardCopyOption.REPLACE_EXISTING);
System.out.println("Updated " + file.getName()); 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(); }).start();
} }

View file

@ -22,15 +22,15 @@ public class PluginUpdater {
private PluginUpdater() { private PluginUpdater() {
} }
public static final File updatedir = new File("TBMC", "pluginupdates"); public static final File updatedir = new File("TBMC", "pluginupdates");
/** /**
* See {@link TBMCCoreAPI#UpdatePlugin(String, CommandSender, String)} * See {@link TBMCCoreAPI#UpdatePlugin(String, CommandSender, String)}
*/ */
public static boolean UpdatePlugin(String name, CommandSender sender, String branch) { public static boolean UpdatePlugin(String name, CommandSender sender, String branch) {
if (!updatedir.exists() && !updatedir.mkdirs()) { if (!updatedir.exists() && !updatedir.mkdirs()) {
error(sender, "Failed to create update directory!"); error(sender, "Failed to create update directory!");
return false; return false;
} }
info(sender, "Checking plugin name..."); info(sender, "Checking plugin name...");
List<String> plugins = GetPluginNames(); List<String> plugins = GetPluginNames();
String correctname = null; String correctname = null;
@ -60,32 +60,32 @@ public class PluginUpdater {
return false; return false;
} }
info(sender, "Updating TBMC plugin: " + correctname + " from " + correctbranch.get()); info(sender, "Updating TBMC plugin: " + correctname + " from " + correctbranch.get());
return updatePluginJitPack(sender, correctname, correctbranch.get()); return updatePluginJitPack(sender, correctname, correctbranch.get());
} }
private static boolean updatePluginJitPack(CommandSender sender, String correctname, private static boolean updatePluginJitPack(CommandSender sender, String correctname,
String correctbranch) { String correctbranch) {
URL url; URL url;
File result = new File(updatedir, correctname + ".jar"); File result = new File(updatedir, correctname + ".jar");
try { try {
url = new URL("https://jitpack.io/com/github/TBMCPlugins/" url = new URL("https://jitpack.io/com/github/TBMCPlugins/"
+ (correctname.equals("ButtonCore") ? "ButtonCore/ButtonCore" : correctname) + "/" + (correctname.equals("ButtonCore") ? "ButtonCore/ButtonCore" : correctname) + "/"
+ correctbranch + "-SNAPSHOT/" + correctname + "-" + correctbranch + "-SNAPSHOT.jar"); // ButtonCore exception required since it hosts Towny as well + correctbranch + "-SNAPSHOT/" + correctname + "-" + correctbranch + "-SNAPSHOT.jar"); // ButtonCore exception required since it hosts Towny as well
FileUtils.copyURLToFile(url, result); FileUtils.copyURLToFile(url, result);
if (!result.exists() || result.length() < 25) { if (!result.exists() || result.length() < 25) {
result.delete(); result.delete();
error(sender, "The downloaded JAR for " + correctname + " from " + correctbranch error(sender, "The downloaded JAR for " + correctname + " from " + correctbranch
+ " is too small (smnaller than 25 bytes). Am I downloading from the right place?"); + " is too small (smnaller than 25 bytes). Am I downloading from the right place?");
return false; return false;
} else { } else {
info(sender, "Updating plugin " + correctname + " from " + correctbranch + " done!"); info(sender, "Updating plugin " + correctname + " from " + correctbranch + " done!");
return true; return true;
} }
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
error(sender, error(sender,
"Can't find JAR for " + correctname + " from " + correctbranch "Can't find JAR for " + correctname + " from " + correctbranch
+ ", the build probably failed. Build log (scroll to bottom):" + "\n" + ", the build probably failed. Build log (scroll to bottom):" + "\n"
+ "https://jitpack.io/com/github/TBMCPlugins/" + correctname + "/" + correctbranch + "https://jitpack.io/com/github/TBMCPlugins/" + correctname + "/" + correctbranch
+ "-SNAPSHOT/build.log\nIf you'd like to rebuild the same commit, go to:\nhttps://jitpack.io/#TBMCPlugins/" + "-SNAPSHOT/build.log\nIf you'd like to rebuild the same commit, go to:\nhttps://jitpack.io/#TBMCPlugins/"
+ correctname + "\nAnd delete the newest build."); + correctname + "\nAnd delete the newest build.");
} catch (IOException e) { } catch (IOException e) {

View file

@ -71,8 +71,8 @@ public class TBMCCoreAPI {
return body; return body;
} }
private static final HashMap<String, Throwable> exceptionsToSend = new HashMap<>(); private static final HashMap<String, Throwable> exceptionsToSend = new HashMap<>();
private static final List<String> debugMessagesToSend = new ArrayList<>(); private static final List<String> debugMessagesToSend = new ArrayList<>();
/** /**
* Send exception to the {@link TBMCExceptionEvent}. * Send exception to the {@link TBMCExceptionEvent}.

View file

@ -7,7 +7,7 @@ import org.bukkit.event.HandlerList;
/** /**
* <p> * <p>
* This event gets called (ideally) each time an exception occurs in a TBMC plugin. To call it, use {@link TBMCCoreAPI#SendException(String, Exception)}. * This event gets called (ideally) each time an exception occurs in a TBMC plugin. To call it, use {@link TBMCCoreAPI#SendException(String, Throwable)}.
* </p> * </p>
* *
* @author Norbi * @author Norbi

View file

@ -91,7 +91,7 @@ public class Channel {
static void RegisterChannel(Channel channel) { static void RegisterChannel(Channel channel) {
channels.add(channel); channels.add(channel);
Bukkit.getScheduler().runTask(Bukkit.getPluginManager().callEvent(new ChatChannelRegisterEvent(channel))); // Wait for server start Bukkit.getScheduler().runTask(MainPlugin.Instance, () -> Bukkit.getPluginManager().callEvent(new ChatChannelRegisterEvent(channel))); // Wait for server start
} }
public static class RecipientTestResult { public static class RecipientTestResult {

View file

@ -66,7 +66,7 @@ public abstract class ChromaGamerBase implements AutoCloseable {
} }
/** /**
* Use {@link #data()} or {@link #data(String)} where possible; the 'id' must be always set * Use {@link #data(Object)} or {@link #data(String, Object)} where possible; the 'id' must be always set
*/ */
protected YamlConfiguration plugindata; protected YamlConfiguration plugindata;

View file

@ -1,20 +1,17 @@
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;
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.Modifier;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;
import javax.tools.Diagnostic.Kind; import javax.tools.Diagnostic.Kind;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
@SupportedAnnotationTypes("buttondevteam.*") @SupportedAnnotationTypes("buttondevteam.*")
public class ButtonProcessor extends AbstractProcessor { public class ButtonProcessor extends AbstractProcessor {