mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-12-28 03:57:44 +01:00
v0.89.1 - Added update checking and fixed bugs.
This commit is contained in:
parent
9c0f442755
commit
d03e56f915
BIN
MobArena.jar
BIN
MobArena.jar
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
name: MobArena
|
||||
main: com.garbagemule.MobArena.MobArena
|
||||
version: 0.89
|
||||
version: 0.89.1
|
||||
commands:
|
||||
ma:
|
||||
description: Base command for MobArena
|
||||
|
@ -36,6 +36,7 @@ public class ArenaManager
|
||||
protected static boolean isSetup = false;
|
||||
protected static boolean isEnabled = true;
|
||||
protected static boolean isProtected = true;
|
||||
protected static boolean checkUpdates = true;
|
||||
|
||||
// Location variables for the arena region.
|
||||
protected static Location p1 = null;
|
||||
@ -125,6 +126,7 @@ public class ArenaManager
|
||||
p1 = MAUtils.getCoords("p1");
|
||||
p2 = MAUtils.getCoords("p2");
|
||||
spawnpoints = MAUtils.getSpawnPoints();
|
||||
checkUpdates = MAUtils.getUpdateNotification();
|
||||
|
||||
// Set the boolean if all variables are valid.
|
||||
ArenaManager.isSetup = MAUtils.verifyData();
|
||||
@ -286,6 +288,7 @@ public class ArenaManager
|
||||
{
|
||||
p.teleport(spectatorLoc);
|
||||
MAUtils.clearInventory(p);
|
||||
p.setFireTicks(0);
|
||||
p.setHealth(20);
|
||||
tellAll(p.getName() + " died!");
|
||||
|
||||
|
@ -118,6 +118,18 @@ public class MACommands implements CommandExecutor
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cmd.equals("check"))
|
||||
{
|
||||
if (!arg.equals("updates"))
|
||||
{
|
||||
ArenaManager.tellPlayer(p, "/ma check updates");
|
||||
return true;
|
||||
}
|
||||
|
||||
MAUtils.checkForUpdates(p, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ma force end
|
||||
if (cmd.equals("force"))
|
||||
{
|
||||
|
@ -42,7 +42,6 @@ public class MADamageListener extends EntityListener
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
p.setFireTicks(0);
|
||||
ArenaManager.playerDeath(p);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
/**
|
||||
* This listener acts when a player is kicked or disconnected
|
||||
@ -43,4 +44,24 @@ public class MADisconnectListener extends PlayerListener
|
||||
ArenaManager.playerLeave(p);
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (!ArenaManager.checkUpdates)
|
||||
return;
|
||||
|
||||
final Player p = event.getPlayer();
|
||||
|
||||
if (!event.getPlayer().isOp())
|
||||
return;
|
||||
|
||||
ArenaManager.server.getScheduler().scheduleSyncDelayedTask(ArenaManager.plugin,
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
MAUtils.checkForUpdates(p, true);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}
|
@ -1,10 +1,14 @@
|
||||
package com.garbagemule.MobArena;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URI;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Scanner;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
@ -245,6 +249,18 @@ public class MAUtils
|
||||
return new Configuration(configFile);
|
||||
}
|
||||
|
||||
public static boolean getUpdateNotification()
|
||||
{
|
||||
Configuration c = ArenaManager.config;
|
||||
c.load();
|
||||
|
||||
boolean result = c.getBoolean("updatenotification", false);
|
||||
c.setProperty("updatenotification", result);
|
||||
c.save();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<String> getDisabledCommands()
|
||||
{
|
||||
Configuration c = ArenaManager.config;
|
||||
@ -445,6 +461,9 @@ public class MAUtils
|
||||
*/
|
||||
public static boolean inRegion(Location loc)
|
||||
{
|
||||
if (!loc.getWorld().getName().equals(ArenaManager.world.getName()))
|
||||
return false;
|
||||
|
||||
Location p1 = ArenaManager.p1;
|
||||
Location p2 = ArenaManager.p2;
|
||||
|
||||
@ -632,6 +651,54 @@ public class MAUtils
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is a new update of MobArena and notifies the
|
||||
* player if the boolean specified is true
|
||||
*/
|
||||
public static void checkForUpdates(final Player p, boolean response)
|
||||
{
|
||||
String site = "http://forums.bukkit.org/threads/818.19144/";
|
||||
try
|
||||
{
|
||||
// Make a URL of the site address
|
||||
//URL baseURL = new URL(site);
|
||||
URI baseURL = new URI(site);
|
||||
|
||||
// Open the connection and don't redirect.
|
||||
HttpURLConnection con = (HttpURLConnection) baseURL.toURL().openConnection();
|
||||
con.setInstanceFollowRedirects(false);
|
||||
|
||||
String header = con.getHeaderField("Location");
|
||||
|
||||
// If something's wrong with the connection...
|
||||
if (header == null)
|
||||
{
|
||||
ArenaManager.tellPlayer(p, "Couldn't connect to the MobArena thread.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, grab the location header to get the real URI.
|
||||
String url = new URI(con.getHeaderField("Location")).toString();
|
||||
|
||||
// If the current version is the same as the thread version.
|
||||
if (url.contains(ArenaManager.plugin.getDescription().getVersion().replace(".", "-")))
|
||||
{
|
||||
if (!response)
|
||||
return;
|
||||
|
||||
ArenaManager.tellPlayer(p, "Your version of MobArena is up to date!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, notify the player that there is a new version.
|
||||
ArenaManager.tellPlayer(p, "There is a new version of MobArena available!");;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns the current set of players into an array, and grabs a random
|
||||
* element out of it.
|
||||
|
@ -61,6 +61,7 @@ public class MobArena extends JavaPlugin
|
||||
pm.registerEvent(Event.Type.PLAYER_TELEPORT, teleportListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_QUIT, discListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_KICK, discListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_JOIN, discListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_DAMAGE, blockListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this);
|
||||
|
Loading…
Reference in New Issue
Block a user