Made potatoes default to not sending

This commit is contained in:
alisolarflare 2016-12-14 22:54:01 -05:00
parent 7c6d0214f9
commit 7719f016e5

View file

@ -13,7 +13,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Optional;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
@ -29,6 +28,15 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
public final class TBMCCoreAPI { public final class TBMCCoreAPI {
static List<String> coders = new ArrayList<String>() {
private static final long serialVersionUID = -4462159250738367334L;
{
add("Alisolarflare");
add("NorbiPeti");
add("iie");
add("thewindmillman");
add("mayskam1995");
}};
/** /**
* Updates or installs the specified plugin. The plugin must use Maven. * Updates or installs the specified plugin. The plugin must use Maven.
* *
@ -85,10 +93,10 @@ public final class TBMCCoreAPI {
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
error(sender, error(sender,
"Can't find JAR for " + correctname + " from " + branch "Can't find JAR for " + correctname + " from " + branch
+ ", 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 + "/" + branch + "https://jitpack.io/com/github/TBMCPlugins/" + correctname + "/" + branch
+ "-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) {
error(sender, "IO error while updating " + correctname + "\n" + e.getMessage()); error(sender, "IO error while updating " + correctname + "\n" + e.getMessage());
} catch (Exception e) { } catch (Exception e) {
@ -153,7 +161,10 @@ public final class TBMCCoreAPI {
* @param e * @param e
* The exception to send * The exception to send
*/ */
public static void SendException(String sourcemsg, Throwable e) { public static void SendException(String sourcemsg, Throwable e){
SendException(sourcemsg, e, false);
}
public static void SendException(String sourcemsg, Throwable e, boolean debugPotato) {
SendUnsentExceptions(); SendUnsentExceptions();
TBMCExceptionEvent event = new TBMCExceptionEvent(sourcemsg, e); TBMCExceptionEvent event = new TBMCExceptionEvent(sourcemsg, e);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
@ -161,16 +172,28 @@ public final class TBMCCoreAPI {
exceptionsToSend.put(sourcemsg, e); exceptionsToSend.put(sourcemsg, e);
Bukkit.getLogger().warning(sourcemsg); Bukkit.getLogger().warning(sourcemsg);
e.printStackTrace(); e.printStackTrace();
Optional<? extends Player> randomPlayer = Bukkit.getOnlinePlayers().stream().findAny(); if (debugPotato){
if (randomPlayer.isPresent()) { List<Player> devsOnline = new ArrayList<Player>();
DebugPotato potato = new DebugPotato() for (Player player : Bukkit.getOnlinePlayers()){
.setMessage(new String[] { // if (coders.contains(player.getName())){
"§b§o" + e.getClass().getSimpleName(), // devsOnline.add(player);
"§c§o" + sourcemsg, // }
"§a§oFind a dev to fix this issue" }) };
.setType(e instanceof IOException ? "Potato on a Stick" if (!devsOnline.isEmpty()) {
: e instanceof ClassCastException ? "Square Potato" : "Plain Potato"); DebugPotato potato = new DebugPotato()
potato.Send(randomPlayer.get()); .setMessage(new String[] { //
"§b§o" + e.getClass().getSimpleName(), //
"§c§o" + sourcemsg, //
"§a§oFind a dev to fix this issue" })
.setType(e instanceof IOException ? "Throwable Potato"
: e instanceof ClassCastException ? "Squished Potato"
: e instanceof NullPointerException ? "Plain Potato"
: e instanceof StackOverflowError ? "Chips"
: "Error Potato");
for (Player dev : devsOnline){
potato.Send(dev);
}
}
} }
} }