v0.92.1 - Bugfixes, added player-limit setting and showregion command, as well as lobby region commands.

This commit is contained in:
Garbage Mule
2011-07-07 11:36:36 +02:00
parent 6b457833e1
commit 508134c60d
8 changed files with 202 additions and 17 deletions
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -1,7 +1,7 @@
name: MobArena
main: com.garbagemule.MobArena.MobArena
version: 0.92
softdepend: [MultiVerse]
version: 0.92.1
softdepend: [MultiVerse,XcraftGate]
commands:
ma:
description: Base command for MobArena
@@ -9,6 +9,7 @@ JOIN_ARENA_NOT_SETUP=Arenaen er ikke blevet sat op endnu.
JOIN_ARENA_IS_RUNNING=Arenaen er allerede startet.
JOIN_ALREADY_PLAYING=Du spiller allerede!
JOIN_ARG_NEEDED=Arenanavn påkrævet. Skriv /ma arenas for en liste.
JOIN_PLAYER_LIMIT_REACHED=Der kan ikke være flere spillere i arenaen.
JOIN_EMPTY_INV=Du skal tømme dit inventory før du kan joine arenaen.
JOIN_STORE_INV_FAIL=Kunne ikke gemme dit inventory. Prøv igen.
LEAVE_PLAYER_LEFT=Du forlod arenaen.
@@ -9,6 +9,7 @@ JOIN_ARENA_NOT_SETUP=Cette arène n'a pas encore été configurée.
JOIN_ARENA_IS_RUNNING=L'arène est déjà occupée.
JOIN_ALREADY_PLAYING=Vous êtes déjà en train de jouer.
JOIN_ARG_NEEDED=Vous devez spécifier une arène. Entrez "/ma arenas" pour la liste.
JOIN_PLAYER_LIMIT_REACHED=La limite de joueur pour cette arène a été atteinte.
JOIN_EMPTY_INV=Vous devez vider votre inventaire afin de joindre l'arène.
JOIN_STORE_INV_FAIL=La sauvegarde de l'inventaire a échouée. Essayez encore.
LEAVE_PLAYER_LEFT=Vous avez quitté l'arène. Merci d'avoir joué !
@@ -9,6 +9,7 @@ JOIN_ARENA_NOT_SETUP=Arrrgh! We be missing the top sail!
JOIN_ARENA_IS_RUNNING=That ship has sailed, landlubber!
JOIN_ALREADY_PLAYING=Ye be aboard already, ye scurvy dog!
JOIN_ARG_NEEDED=Which ship are ye boarding? Type /ma arenas for a list, arrgh!
JOIN_PLAYER_LIMIT_REACHED=Thar be too many men aboard this ship already, landlubber!
JOIN_EMPTY_INV=Throw ye belongings overboard, scallywag!
JOIN_STORE_INV_FAIL=Ye belongings didn't fit in the storage deck, arrgh!
LEAVE_PLAYER_LEFT=Ye abandonned the ship! Arrrgh!
+5 -3
View File
@@ -250,7 +250,10 @@ public class Arena
{
// Force leave.
for (Player p : getAllPlayers())
{
plugin.getAM().arenaMap.remove(p);
playerLeave(p);
}
}
/**
@@ -316,7 +319,7 @@ public class Arena
public void playerDeath(final Player p)
{
p.teleport(arenaLoc); // This will force players to drop any items held
p.teleport(arenaLoc); // This will sometimes force players to drop any items held (not confirmed)
p.teleport(spectatorLoc);
p.setFireTicks(0);
p.setHealth(20);
@@ -1198,8 +1201,7 @@ public class Arena
{
MAUtils.clearInventory(p);
MAUtils.tellPlayer(p, MAMessages.get(Msg.FORCE_END_IDLE));
p.damage(32768);
//playerDeath(p);
playerDeath(p);
}
}
}, maxIdleTime);
+107 -12
View File
@@ -2,10 +2,14 @@ package com.garbagemule.MobArena;
import java.util.List;
import java.util.LinkedList;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -43,6 +47,7 @@ public class MACommands implements CommandExecutor
COMMANDS.add("editarena"); // Editing
COMMANDS.add("setregion"); // Set a region point
COMMANDS.add("expandregion"); // Expand the region
COMMANDS.add("showregion"); // Show the region
COMMANDS.add("setlobbyregion"); // Set a region point
COMMANDS.add("expandlobbyregion"); // Expand the region
COMMANDS.add("setwarp"); // Set arena/lobby/spec
@@ -53,7 +58,7 @@ public class MACommands implements CommandExecutor
COMMANDS.add("auto-generate"); // Auto-generate arena
COMMANDS.add("auto-degenerate"); // Restore cuboid
}
private boolean meanAdmins;
private boolean meanAdmins, showingRegion;
private Server server;
private MobArena plugin;
private ArenaMaster am;
@@ -149,8 +154,6 @@ public class MACommands implements CommandExecutor
if (error)
return true;
System.out.println("playerLimit: " + arena.playerLimit + ", livePlayers: " + arena.livePlayers.size());
am.arenaMap.put(p,arena);
arena.playerJoin(p, p.getLocation());
@@ -689,21 +692,61 @@ public class MACommands implements CommandExecutor
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
return true;
}
if (arg1.isEmpty() || !(arg2.equals("true") || arg2.equals("false")))
Arena arena;
// No arguments.
if (arg1.isEmpty())
{
MAUtils.tellPlayer(sender, "Usage: /ma editarena <arena name> [true|false]");
return true;
arena = am.selectedArena;
arena.edit = !arena.edit;
}
Arena arena = am.getArenaWithName(arg1);
if (arena == null)
// One argument.
else if (arg2.isEmpty())
{
MAUtils.tellPlayer(sender, "There is no arena with that name.");
return true;
// Argument is [true|false]
if (arg1.equals("true") || arg1.equals("false"))
{
arena = am.selectedArena;
arena.edit = arg1.equals("true");
}
// Argument is <arena name>
else
{
arena = am.getArenaWithName(arg1);
if (arena == null)
{
MAUtils.tellPlayer(sender, "There is no arena with that name.");
MAUtils.tellPlayer(sender, "Usage: /ma editarena ([true|false])");
MAUtils.tellPlayer(sender, " or /ma editarena <arena name> ([true|false])");
return true;
}
arena.edit = !arena.edit;
}
}
arena.edit = arg2.equals("true");
MAUtils.tellPlayer(sender, "Edit mode for arena '" + arg1 + "': " + ((arena.edit) ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
// Two arguments
else
{
if (!(arg2.equals("true") || arg2.equals("false")))
{
MAUtils.tellPlayer(sender, "Usage: /ma editarena ([true|false])");
MAUtils.tellPlayer(sender, " or /ma editarena <arena name> ([true|false])");
return true;
}
arena = am.getArenaWithName(arg1);
if (arena == null)
{
MAUtils.tellPlayer(sender, "There is no arena with that name.");
MAUtils.tellPlayer(sender, "Usage: /ma editarena ([true|false])");
MAUtils.tellPlayer(sender, " or /ma editarena <arena name> ([true|false])");
return true;
}
arena.edit = arg2.equals("true");
}
MAUtils.tellPlayer(sender, "Edit mode for arena '" + arena.configName() + "': " + ((arena.edit) ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
if (arena.edit) MAUtils.tellPlayer(sender, "Remember to turn it back off after editing!");
return true;
}
@@ -778,6 +821,58 @@ public class MACommands implements CommandExecutor
return true;
}
if (base.equals("showregion"))
{
if (!(player && MobArena.has(p, "mobarena.setup.showregion")) && !op)
{
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
return true;
}
if (am.selectedArena.p1 == null || am.selectedArena.p2 == null)
{
MAUtils.tellPlayer(sender, "The region is not defined for the selected arena.");
return true;
}
if (showingRegion || !am.selectedArena.edit)
{
MAUtils.tellPlayer(sender, "Must be in edit mode.");
return true;
}
Material mat = Material.WOOL;
byte color = (byte)0;
if (arg1.equals("glowstone"))
mat = Material.GLOWSTONE;
else if (arg1.equals("white") || arg1.equals("red") || arg1.equals("blue"))
color = DyeColor.valueOf(arg1.toUpperCase()).getData();
else if (arg1.equals("green")) // Dark green sucks
color = 0x5;
else
mat = Material.GLASS;
// Set the variable so we don't overwrite the region.
showingRegion = true;
// Show the frame.
final World world = am.selectedArena.world;
final Set<int[]> blocks = MAUtils.showRegion(world, am.selectedArena.p1, am.selectedArena.p2, mat.getId(), color);
// And hide the frame.
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
new Runnable()
{
public void run()
{
for (int[] buffer : blocks)
world.getBlockAt(buffer[0], buffer[1], buffer[2]).setTypeIdAndData(buffer[3], (byte) 0, false);
showingRegion = false;
}
}, 2*20);
return true;
}
if (base.equals("setlobbyregion"))
{
if (!(player && MobArena.has(p, "mobarena.setup.setlobbyregion")) && !op)
+85
View File
@@ -608,6 +608,91 @@ public class MAUtils
// ///////////////////////////////////////////////////////////////////// */
/**
* Create a frame spanned by the two input coordinates.
* @return An int arry holding x,y,z and the original type IDs of each block.
*/
public static Set<int[]> showRegion(World world, Location p1, Location p2, int id, byte color)
{
Set<int[]> result = new HashSet<int[]>();
int x1 = p1.getBlockX(); int y1 = p1.getBlockY(); int z1 = p1.getBlockZ();
int x2 = p2.getBlockX(); int y2 = p2.getBlockY(); int z2 = p2.getBlockZ();
int[] buffer;
for (int i = x1; i <= x2; i++)
{
buffer = new int[] {i, y1, z1, world.getBlockTypeIdAt(i, y1, z1)};
result.add(buffer);
world.getBlockAt(i, y1, z1).setTypeIdAndData(id, color, false);
buffer = new int[] {i, y2, z1, world.getBlockTypeIdAt(i, y2, z1)};
result.add(buffer);
world.getBlockAt(i, y2, z1).setTypeIdAndData(id, color, false);
buffer = new int[] {i, y1, z2, world.getBlockTypeIdAt(i, y1, z2)};
result.add(buffer);
world.getBlockAt(i, y1, z2).setTypeIdAndData(id, color, false);
buffer = new int[] {i, y2, z2, world.getBlockTypeIdAt(i, y2, z2)};
result.add(buffer);
world.getBlockAt(i, y2, z2).setTypeIdAndData(id, color, false);
}
for (int j = y1+1; j <= y2-1; j++)
{
buffer = new int[] {x1, j, z1, world.getBlockTypeIdAt(x1, j, z1)};
result.add(buffer);
world.getBlockAt(x1, j, z1).setTypeIdAndData(id, color, false);
buffer = new int[] {x2, j, z1, world.getBlockTypeIdAt(x2, j, z1)};
result.add(buffer);
world.getBlockAt(x2, j, z1).setTypeIdAndData(id, color, false);
buffer = new int[] {x1, j, z2, world.getBlockTypeIdAt(x1, j, z2)};
result.add(buffer);
world.getBlockAt(x1, j, z2).setTypeIdAndData(id, color, false);
buffer = new int[] {x2, j, z2, world.getBlockTypeIdAt(x2, j, z2)};
result.add(buffer);
world.getBlockAt(x2, j, z2).setTypeIdAndData(id, color, false);
}
for (int k = z1+1; k <= z2-1; k++)
{
buffer = new int[] {x1, y1, k, world.getBlockTypeIdAt(x1, y1, k)};
result.add(buffer);
world.getBlockAt(x1, y1, k).setTypeIdAndData(id, color, false);
buffer = new int[] {x2, y1, k, world.getBlockTypeIdAt(x2, y1, k)};
result.add(buffer);
world.getBlockAt(x2, y1, k).setTypeIdAndData(id, color, false);
buffer = new int[] {x1, y2, k, world.getBlockTypeIdAt(x1, y2, k)};
result.add(buffer);
world.getBlockAt(x1, y2, k).setTypeIdAndData(id, color, false);
buffer = new int[] {x2, y2, k, world.getBlockTypeIdAt(x2, y2, k)};
result.add(buffer);
world.getBlockAt(x2, y2, k).setTypeIdAndData(id, color, false);
}
return result;
}
public static Set<int[]> showRegion(World world, Location p1, Location p2, int id)
{
return showRegion(world, p1, p2, id, (byte) 0);
}
/**
* Take all the blocks with coordinates (buffer[0], buffer[1], buffer[2]) and set
* their type ID to buffer[3]. Used to hide regions shown by showRegion.
*/
public static void hideRegion(int[] buffer)
{
}
/**
* Create a Location object from the config-file.
*/