Remove Spam, Add auto-pastebin code, Minor bugfixes.

This commit is contained in:
Eric Stokes 2011-08-04 20:26:25 -06:00
parent dd388d0d9f
commit f81a9d15c0
6 changed files with 82 additions and 25 deletions

View File

@ -91,11 +91,8 @@ public class MVPermissions implements PermissionsInterface {
return false; return false;
} }
if(!canEnterLocation(p, d.getLocation())) { if(!canEnterLocation(p, d.getLocation())) {
System.out.print("Can't enter location");
return false; return false;
} }
System.out.print("Can't enter destination: " + this.hasPermission(p, d.getRequiredPermission(), false));
System.out.print("Can't enter destination: " + d.getRequiredPermission());
return this.hasPermission(p, d.getRequiredPermission(), false); return this.hasPermission(p, d.getRequiredPermission(), false);
} }

View File

@ -1,7 +1,7 @@
package com.onarandombox.MultiverseCore; package com.onarandombox.MultiverseCore;
public interface MVPlugin extends LoggablePlugin { public interface MVPlugin extends LoggablePlugin {
public void dumpVersionInfo(); public String dumpVersionInfo(String buffer);
public MultiverseCore getCore(); public MultiverseCore getCore();
public void setCore(MultiverseCore core); public void setCore(MultiverseCore core);
} }

View File

@ -201,7 +201,6 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
// Call the defaultConfiguration class to create the config files if they don't already exist. // Call the defaultConfiguration class to create the config files if they don't already exist.
new DefaultConfiguration(getDataFolder(), "config.yml", this.migrator); new DefaultConfiguration(getDataFolder(), "config.yml", this.migrator);
new DefaultConfiguration(getDataFolder(), "worlds.yml", this.migrator); new DefaultConfiguration(getDataFolder(), "worlds.yml", this.migrator);
// Now grab the Configuration Files. // Now grab the Configuration Files.
this.configMV = new Configuration(new File(getDataFolder(), "config.yml")); this.configMV = new Configuration(new File(getDataFolder(), "config.yml"));
this.configWorlds = new Configuration(new File(getDataFolder(), "worlds.yml")); this.configWorlds = new Configuration(new File(getDataFolder(), "worlds.yml"));

View File

@ -1,8 +1,15 @@
package com.onarandombox.MultiverseCore.commands; package com.onarandombox.MultiverseCore.commands;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault; import org.bukkit.permissions.PermissionDefault;
@ -15,35 +22,79 @@ public class VersionCommand extends MultiverseCommand {
public VersionCommand(MultiverseCore plugin) { public VersionCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.setName("Multiverse Version"); this.setName("Multiverse Version");
this.setCommandUsage("/mv version"); this.setCommandUsage("/mv version " + ChatColor.GOLD + "-p");
this.setArgRange(0, 0); this.setArgRange(0, 1);
this.addKey("mv version"); this.addKey("mv version");
this.addKey("mvv"); this.addKey("mvv");
this.addKey("mvversion"); this.addKey("mvversion");
this.setPermission("multiverse.core.version", "What version of Multiverse-Core are you on!.", PermissionDefault.TRUE); this.setPermission("multiverse.core.version", "Dumps version info to the console, optionally to pastebin.com with a -p.", PermissionDefault.TRUE);
} }
private String pasteBinBuffer = "";
@Override @Override
public void runCommand(CommandSender sender, List<String> args) { public void runCommand(CommandSender sender, List<String> args) {
// Check if the command was sent from a Player. // Check if the command was sent from a Player.
if (sender instanceof Player) { if (sender instanceof Player) {
sender.sendMessage("Version info dumped to console. Please check your server logs."); sender.sendMessage("Version info dumped to console. Please check your server logs.");
} }
this.plugin.log(Level.INFO, "Multiverse-Core Version: " + this.plugin.getDescription().getVersion());
this.plugin.log(Level.INFO, "Bukkit Version: " + this.plugin.getServer().getVersion()); logAndAddToPasteBinBuffer("Multiverse-Core Version: " + this.plugin.getDescription().getVersion());
this.plugin.log(Level.INFO, "Loaded Worlds: " + this.plugin.getMVWorlds().size()); logAndAddToPasteBinBuffer("Bukkit Version: " + this.plugin.getServer().getVersion());
this.plugin.log(Level.INFO, "Multiverse Plugins Loaded: " + this.plugin.getPluginCount()); logAndAddToPasteBinBuffer("Loaded Worlds: " + this.plugin.getMVWorlds().size());
this.plugin.log(Level.INFO, "Economy being used: " + this.plugin.getBank().getEconUsed()); logAndAddToPasteBinBuffer("Multiverse Plugins Loaded: " + this.plugin.getPluginCount());
this.plugin.log(Level.INFO, "Permissions Plugin: " + this.plugin.getPermissions().getType()); logAndAddToPasteBinBuffer("Economy being used: " + this.plugin.getBank().getEconUsed());
this.plugin.log(Level.INFO, "Dumping Config Values: (version " + this.plugin.getConfig().getString("version", "NOT SET") + ")"); logAndAddToPasteBinBuffer("Permissions Plugin: " + this.plugin.getPermissions().getType());
this.plugin.log(Level.INFO, "messagecooldown: " + this.plugin.getConfig().getString("messagecooldown", "NOT SET")); logAndAddToPasteBinBuffer("Dumping Config Values: (version " + this.plugin.getConfig().getString("version", "NOT SET") + ")");
this.plugin.log(Level.INFO, "teleportcooldown: " + this.plugin.getConfig().getString("teleportcooldown", "NOT SET")); logAndAddToPasteBinBuffer("messagecooldown: " + this.plugin.getConfig().getString("messagecooldown", "NOT SET"));
this.plugin.log(Level.INFO, "worldnameprefix: " + this.plugin.getConfig().getString("worldnameprefix", "NOT SET")); logAndAddToPasteBinBuffer("teleportcooldown: " + this.plugin.getConfig().getString("teleportcooldown", "NOT SET"));
this.plugin.log(Level.INFO, "opfallback: " + this.plugin.getConfig().getString("opfallback", "NOT SET")); logAndAddToPasteBinBuffer("worldnameprefix: " + this.plugin.getConfig().getString("worldnameprefix", "NOT SET"));
this.plugin.log(Level.INFO, "disableautoheal: " + this.plugin.getConfig().getString("disableautoheal", "NOT SET")); logAndAddToPasteBinBuffer("opfallback: " + this.plugin.getConfig().getString("opfallback", "NOT SET"));
this.plugin.log(Level.INFO, "fakepvp: " + this.plugin.getConfig().getString("fakepvp", "NOT SET")); logAndAddToPasteBinBuffer("disableautoheal: " + this.plugin.getConfig().getString("disableautoheal", "NOT SET"));
this.plugin.log(Level.INFO, "fakepvp: " + this.plugin.getConfig().getString("fakepvp", "NOT SET")); logAndAddToPasteBinBuffer("fakepvp: " + this.plugin.getConfig().getString("fakepvp", "NOT SET"));
this.plugin.log(Level.INFO, "Special Code: FRN001"); logAndAddToPasteBinBuffer("Special Code: FRN001");
this.plugin.getServer().getPluginManager().callEvent(new MVVersionRequestEvent());
MVVersionRequestEvent versionEvent = new MVVersionRequestEvent(pasteBinBuffer);
this.plugin.getServer().getPluginManager().callEvent(versionEvent);
pasteBinBuffer = versionEvent.getPasteBinBuffer();
if (args.size() == 1 && args.get(0).equalsIgnoreCase("-p")) {
String pasteBinUrl = postToPasteBin();
sender.sendMessage("Version info dumped here: " + ChatColor.GREEN + pasteBinUrl);
this.plugin.log(Level.INFO, "Version info dumped here: " + pasteBinUrl);
}
}
private void logAndAddToPasteBinBuffer(String string) {
this.pasteBinBuffer += "[Multiverse-Core] " + string + "\n";
this.plugin.log(Level.INFO, string);
}
private String postToPasteBin() {
try {
String data = URLEncoder.encode("api_dev_key", "UTF-8") + "=" + URLEncoder.encode("33ab32380506d99d872b69d35dc9d007", "UTF-8");
data += "&" + URLEncoder.encode("api_option", "UTF-8") + "=" + URLEncoder.encode("paste", "UTF-8");
data += "&" + URLEncoder.encode("api_paste_code", "UTF-8") + "=" + URLEncoder.encode(this.pasteBinBuffer, "UTF-8");
URL url = new URL("http://pastebin.com/api/api_post.php");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
String pasteBinUrl = "";
while ((line = rd.readLine()) != null) {
pasteBinUrl = line;
}
wr.close();
rd.close();
return pasteBinUrl;
} catch (Exception e) {
System.out.print(e);
return "Error Posting to pastebin.com";
}
} }
} }

View File

@ -4,7 +4,16 @@ import org.bukkit.event.Event;
public class MVVersionRequestEvent extends Event { public class MVVersionRequestEvent extends Event {
public MVVersionRequestEvent() { private String pasteBinBuffer;
public MVVersionRequestEvent(String pasteBinBuffer) {
super("MVVersion"); super("MVVersion");
this.pasteBinBuffer = pasteBinBuffer;
}
public String getPasteBinBuffer() {
return this.pasteBinBuffer;
}
public void setPasteBinBuffer(String buffer) {
this.pasteBinBuffer = buffer;
} }
} }

View File

@ -40,6 +40,7 @@ public class MVPlayerListener extends PlayerListener {
} }
// Check whether the Server is set to prefix the chat with the World name. If not we do nothing, if so we need to check if the World has an Alias. // Check whether the Server is set to prefix the chat with the World name. If not we do nothing, if so we need to check if the World has an Alias.
if (this.plugin.getConfig().getBoolean("worldnameprefix", true)) { if (this.plugin.getConfig().getBoolean("worldnameprefix", true)) {
this.plugin.getConfig().save();
String world = event.getPlayer().getWorld().getName(); String world = event.getPlayer().getWorld().getName();
String prefix = ""; String prefix = "";
// If we're not a MV world, don't do anything // If we're not a MV world, don't do anything