v0.94
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="lib" path="MobArena.jar"/>
|
||||||
|
<classpathentry kind="lib" path="D:/General/Java/Minecraft/lib/BOSEconomy7.jar"/>
|
||||||
|
<classpathentry kind="lib" path="D:/General/Java/Minecraft/lib/Essentials.jar"/>
|
||||||
|
<classpathentry kind="lib" path="D:/General/Java/Minecraft/lib/iCo4.jar"/>
|
||||||
|
<classpathentry kind="lib" path="D:/General/Java/Minecraft/lib/iCo5.jar"/>
|
||||||
|
<classpathentry kind="lib" path="D:/General/Java/Minecraft/lib/MeanAdmins.jar"/>
|
||||||
|
<classpathentry kind="lib" path="D:/General/Java/Minecraft/lib/Permissions.jar"/>
|
||||||
|
<classpathentry kind="lib" path="D:/General/Java/Minecraft/lib/Register.jar"/>
|
||||||
|
<classpathentry kind="lib" path="D:/General/Java/Minecraft/lib/craftbukkit-0.0.1-SNAPSHOT.jar"/>
|
||||||
|
<classpathentry kind="lib" path="D:/General/Java/Minecraft/lib/iCo6.jar"/>
|
||||||
|
<classpathentry kind="lib" path="D:/General/Java/Minecraft/lib/MultiCurrency.jar"/>
|
||||||
|
<classpathentry kind="lib" path="D:/General/Java/Minecraft/lib/jdom.jar"/>
|
||||||
|
<classpathentry kind="lib" path="D:/General/Java/Minecraft/lib/Spout.jar"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>MobArena</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
Go to the Wiki for more info: https://github.com/garbagemule/MobArena/wiki/dev-v0.94
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project name="MobArena" default="dist" basedir=".">
|
||||||
|
<property name="pluginname" value="MobArena"/>
|
||||||
|
<property name="server" location="D:\General\Java\Minecraft\Minecraft Server\plugins"/>
|
||||||
|
|
||||||
|
<property name="src" location="src"/>
|
||||||
|
<property name="bin" location="bin"/>
|
||||||
|
<property name="lib" location="../lib"/>
|
||||||
|
<property name="res" location="resources"/>
|
||||||
|
<path id="classpath">
|
||||||
|
<fileset dir="${lib}" includes="**/*.jar"/>
|
||||||
|
<fileset dir="${res}" includes="**/*.*"/>
|
||||||
|
</path>
|
||||||
|
|
||||||
|
<target name="init">
|
||||||
|
<mkdir dir="${bin}"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Compile the source and put in the bin-folder -->
|
||||||
|
<target name="compile" depends="init">
|
||||||
|
<javac srcdir="${src}" destdir="${bin}" includeantruntime="false" classpathref="classpath"/>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<!-- Build a .jar and copy to server's plugins-folder -->
|
||||||
|
<target name="dist" depends="compile">
|
||||||
|
<delete file="${pluginname}.jar"/>
|
||||||
|
<jar jarfile="${pluginname}.jar">
|
||||||
|
<!-- Include the class-files (bin) and the resources (res) -->
|
||||||
|
<fileset dir="${bin}"/>
|
||||||
|
<fileset dir="${res}"/>
|
||||||
|
<!-- Set up the classpath so MobArena can find JDOM if needed -->
|
||||||
|
<manifest>
|
||||||
|
<attribute name="Main-Class" value="com.garbagemule.MobArena.MobArena"/>
|
||||||
|
<attribute name="Class-Path" value="plugins/MobArena/lib/jdom.jar MobArena/lib/jdom.jar"/>
|
||||||
|
</manifest>
|
||||||
|
</jar>
|
||||||
|
<!-- Copy to server and clean up -->
|
||||||
|
<copy file="${pluginname}.jar" tofile="${server}/${pluginname}.jar"/>
|
||||||
|
<delete dir="${bin}"/>
|
||||||
|
</target>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
name: MobArena
|
||||||
|
main: com.garbagemule.MobArena.MobArena
|
||||||
|
version: 0.94
|
||||||
|
softdepend: [Spout,Permissions,MultiVerse,XcraftGate,Towny]
|
||||||
|
commands:
|
||||||
|
ma:
|
||||||
|
description: Base command for MobArena
|
||||||
|
usage: |
|
||||||
|
/ma join - Join the arena.
|
||||||
|
/ma leave - Leave the arena.
|
||||||
|
/ma notready - List of players who aren't ready.
|
||||||
|
/ma spectate - Warp to the spectator area.
|
||||||
|
mobarena:
|
||||||
|
description: Base command for MobArena
|
||||||
|
usage: |
|
||||||
|
/mobarena join - Join the arena.
|
||||||
|
/mobarena leave - Leave the arena.
|
||||||
|
/mobarena notready - List of players who aren't ready.
|
||||||
|
/mobarena spectate - Warp to the spectator area.
|
||||||
|
permissions:
|
||||||
|
mobarena.use.*:
|
||||||
|
description: Gives access to usage commands
|
||||||
|
default: true
|
||||||
|
children:
|
||||||
|
mobarena.use.join: true
|
||||||
|
mobarena.use.spec: true
|
||||||
|
mobarena.use.leave: true
|
||||||
|
mobarena.use.join:
|
||||||
|
default: true
|
||||||
|
mobarena.use.spec:
|
||||||
|
default: true
|
||||||
|
mobarena.use.leave:
|
||||||
|
default: true
|
||||||
|
|
||||||
|
mobarena.admin.*:
|
||||||
|
description: Gives access to admin commands
|
||||||
|
default: op
|
||||||
|
children:
|
||||||
|
mobarena.admin.enable: true
|
||||||
|
mobarena.admin.kick: true
|
||||||
|
mobarena.admin.restore: true
|
||||||
|
mobarena.admin.force.end: true
|
||||||
|
mobarena.admin.force.start: true
|
||||||
|
mobarena.admin.config.reload: true
|
||||||
|
mobarena.admin.enable:
|
||||||
|
default: false
|
||||||
|
mobarena.admin.kick:
|
||||||
|
default: false
|
||||||
|
mobarena.admin.restore:
|
||||||
|
default: false
|
||||||
|
mobarena.admin.force.end:
|
||||||
|
default: false
|
||||||
|
mobarena.admin.force.start:
|
||||||
|
default: false
|
||||||
|
mobarena.admin.config.reload:
|
||||||
|
default: false
|
||||||
|
|
||||||
|
mobarena.setup.*:
|
||||||
|
description: Gives access to setup commands
|
||||||
|
default: op
|
||||||
|
children:
|
||||||
|
mobarena.setup.arena: true
|
||||||
|
mobarena.setup.setarena: true
|
||||||
|
mobarena.setup.addarena: true
|
||||||
|
mobarena.setup.delarena: true
|
||||||
|
mobarena.setup.protect: true
|
||||||
|
mobarena.setup.editarena: true
|
||||||
|
mobarena.setup.setregion: true
|
||||||
|
mobarena.setup.expandregion: true
|
||||||
|
mobarena.setup.showregion: true
|
||||||
|
mobarena.setup.setlobbyregion: true
|
||||||
|
mobarena.setup.expandlobbyregion: true
|
||||||
|
mobarena.setup.setwarp: true
|
||||||
|
mobarena.setup.spawnpoints: true
|
||||||
|
mobarena.setup.addspawn: true
|
||||||
|
mobarena.setup.delspawn: true
|
||||||
|
mobarena.setup.containers: true
|
||||||
|
mobarena.setup.addcontainer: true
|
||||||
|
mobarena.setup.delcontainer: true
|
||||||
|
mobarena.setup.checkdata: true
|
||||||
|
mobarena.setup.autogenerate: true
|
||||||
|
mobarena.setup.autodegenerate: true
|
||||||
|
mobarena.setup.arena:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.setarena:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.addarena:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.delarena:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.protect:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.editarena:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.setregion:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.expandregion:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.showregion:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.setlobbyregion:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.expandlobbyregion:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.setwarp:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.spawnpoints:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.addspawn:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.delspawn:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.containers:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.addcontainer:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.delcontainer:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.checkdata:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.autogenerate:
|
||||||
|
default: false
|
||||||
|
mobarena.setup.autodegenerate:
|
||||||
|
default: false
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
ARENA_START=Let the slaughter begin!
|
||||||
|
ARENA_END=Arena finished.
|
||||||
|
ARENA_DOES_NOT_EXIST=That arena does not exist. Type /ma arenas for a list.
|
||||||
|
JOIN_PLAYER_JOINED=
|
||||||
|
JOIN_NOT_ENABLED=MobArena is not enabled.
|
||||||
|
JOIN_IN_OTHER_ARENA=You are already in an arena! Leave that one first.
|
||||||
|
JOIN_ARENA_NOT_ENABLED=This arena is not enabled.
|
||||||
|
JOIN_ARENA_NOT_SETUP=This arena has not been set up yet.
|
||||||
|
JOIN_ARENA_PERMISSION=You don't have permission to join this arena.
|
||||||
|
JOIN_FEE_REQUIRED=Insufficient funds. Price: %
|
||||||
|
JOIN_FEE_PAID=Price to join was: %
|
||||||
|
JOIN_ARENA_IS_RUNNING=This arena is in already progress.
|
||||||
|
JOIN_ALREADY_PLAYING=You are already playing!
|
||||||
|
JOIN_ARG_NEEDED=You must specify an arena. Type /ma arenas for a list.
|
||||||
|
JOIN_TOO_FAR=You are too far away from the arena to join/spectate.
|
||||||
|
JOIN_EMPTY_INV=You must empty your inventory to join the arena.
|
||||||
|
JOIN_PLAYER_LIMIT_REACHED=The player limit of this arena has been reached.
|
||||||
|
JOIN_STORE_INV_FAIL=Failed to store inventory. Try again.
|
||||||
|
LEAVE_PLAYER_LEFT=You left the arena. Thanks for playing!
|
||||||
|
LEAVE_NOT_PLAYING=You are not in the arena.
|
||||||
|
PLAYER_DIED=% died!
|
||||||
|
SPEC_PLAYER_SPECTATE=Enjoy the show!
|
||||||
|
SPEC_NOT_RUNNING=This arena isn't running.
|
||||||
|
SPEC_ARG_NEEDED=You must specify an arena. Type /ma arenas for a list.
|
||||||
|
SPEC_EMPTY_INV=Empty your inventory first!
|
||||||
|
SPEC_ALREADY_PLAYING=Can't spectate when in the arena!
|
||||||
|
NOT_READY_PLAYERS=Not ready: %
|
||||||
|
FORCE_START_STARTED=Forced arena start.
|
||||||
|
FORCE_START_RUNNING=Arena has already started.
|
||||||
|
FORCE_START_NOT_READY=Can't force start, no players are ready.
|
||||||
|
FORCE_END_ENDED=Forced arena end.
|
||||||
|
FORCE_END_EMPTY=No one is in the arena.
|
||||||
|
FORCE_END_IDLE=You weren't quick enough!
|
||||||
|
REWARDS_GIVE=Here are all of your rewards!
|
||||||
|
LOBBY_CLASS_PICKED=You have chosen % as your class!
|
||||||
|
LOBBY_CLASS_RANDOM=You will get a random class on arena start.
|
||||||
|
LOBBY_CLASS_PERMISSION=You don't have permission to use this class!
|
||||||
|
LOBBY_PLAYER_READY=You have been flagged as ready!
|
||||||
|
LOBBY_DROP_ITEM=No sharing before the arena starts!
|
||||||
|
LOBBY_PICK_CLASS=You must first pick a class!
|
||||||
|
LOBBY_RIGHT_CLICK=Punch the sign. Don't right-click.
|
||||||
|
WARP_TO_ARENA=Can't warp to the arena during battle!
|
||||||
|
WARP_FROM_ARENA=Warping not allowed in the arena!
|
||||||
|
WAVE_DEFAULT=Get ready for wave #%!
|
||||||
|
WAVE_SPECIAL=Get ready for wave #%! [SPECIAL]
|
||||||
|
WAVE_REWARD=You just earned a reward: %
|
||||||
|
MISC_LIST_ARENAS=Available arenas: %
|
||||||
|
MISC_LIST_PLAYERS=Live players: %
|
||||||
|
MISC_COMMAND_NOT_ALLOWED=You can't use that command in the arena!
|
||||||
|
MISC_NO_ACCESS=You don't have access to this command.
|
||||||
|
MISC_NONE=<none>
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
### MobArena Configuration File
|
||||||
|
### Please visit the MobArena Wiki here: http://goo.gl/F5TTc for more details
|
||||||
|
### on how to set up this file.
|
||||||
|
### Note that you CAN'T use tabs in this file! Always use spaces!
|
||||||
|
|
||||||
|
### GLOBAL SETTINGS
|
||||||
|
# These settings are arena-independent and count in all arenas. Note that if
|
||||||
|
# enabled: false in the global settings, MobArena is disabled globally, and
|
||||||
|
# arena-specific enabled-values do not matter. If true, however, the per-arena
|
||||||
|
# enabled-values count.
|
||||||
|
global-settings:
|
||||||
|
enabled: true
|
||||||
|
allowed-commands: /list, /pl
|
||||||
|
update-notification: true
|
||||||
|
|
||||||
|
### CLASS SETUP
|
||||||
|
# Items can be written as either their data value (numbers) or their Material
|
||||||
|
# type (names); check the Wiki for links to lists of both.
|
||||||
|
# The notation is <item>:<amount>. If no amount is given, 1 is assumed. Sub-
|
||||||
|
# types can be created
|
||||||
|
# Item SUBTYPES (wool/dye colors) are written as <item>:<subtype>:<amount>,
|
||||||
|
# but here, the amount is REQUIRED, even if it is just 1.
|
||||||
|
# Note: If you want to specify only one item, but apostrophes around that one
|
||||||
|
# item, e.g.: items: '278'
|
||||||
|
# Note: For every bone a class has, one PET WOLF will spawn upon arena start,
|
||||||
|
# which will assist the player in the arena session.
|
||||||
|
classes:
|
||||||
|
Knight:
|
||||||
|
items: diamond_sword, grilled_pork:2
|
||||||
|
armor: 306,307,308,309
|
||||||
|
Tank:
|
||||||
|
items: iron_sword, grilled_pork:3, apple
|
||||||
|
armor: 310,311,312,313
|
||||||
|
Archer:
|
||||||
|
items: wood_sword, bow, arrow:256, grilled_pork, bone
|
||||||
|
armor: 298,299,300,301
|
||||||
|
Chef:
|
||||||
|
items: stone_sword, bread:6, grilled_pork:4, mushroom_soup, cake:5
|
||||||
|
armor: 314,315,316,317
|
||||||
|
Oddjob:
|
||||||
|
items: stone_sword, flint_and_steel, netherrack:2, tnt:4, pork:3
|
||||||
|
armor: 298,299,300,301
|
||||||
|
|
||||||
|
### ARENA SETUP
|
||||||
|
# The arena setup is split into 4 different sections per arena: settings,
|
||||||
|
# waves, rewards and coords (not shown until coords are set up).
|
||||||
|
# Please refer to the Wiki for descriptions of all these settings.
|
||||||
|
# Note: The REWARDS use the same notation as the items in the CLASS SETUP
|
||||||
|
# section. However, only -one- item from the list is picked (at random) when
|
||||||
|
# the rewards are given.
|
||||||
|
arenas:
|
||||||
|
default:
|
||||||
|
settings:
|
||||||
|
world: ''
|
||||||
|
enabled: true
|
||||||
|
protect: true
|
||||||
|
entry-fee: ''
|
||||||
|
logging: true
|
||||||
|
clear-wave-before-next: false
|
||||||
|
detonate-creepers: false
|
||||||
|
detonate-damage: false
|
||||||
|
lightning: true
|
||||||
|
auto-equip-armor: true
|
||||||
|
force-restore: false
|
||||||
|
soft-restore: false
|
||||||
|
soft-restore-drops: false
|
||||||
|
require-empty-inv-join: false
|
||||||
|
require-empty-inv-spec: false
|
||||||
|
hellhounds: false
|
||||||
|
pvp-enabled: false
|
||||||
|
monster-infight: false
|
||||||
|
allow-teleporting: false
|
||||||
|
spectate-on-death: true
|
||||||
|
share-items-in-arena: true
|
||||||
|
min-players: 0
|
||||||
|
max-players: 0
|
||||||
|
max-join-distance: 0
|
||||||
|
repair-delay: 5
|
||||||
|
first-wave-delay: 5
|
||||||
|
wave-interval: 20
|
||||||
|
special-modulo: 4
|
||||||
|
max-idle-time: 0
|
||||||
|
waves:
|
||||||
|
recurrent:
|
||||||
|
def1:
|
||||||
|
type: default
|
||||||
|
priority: 1
|
||||||
|
frequency: 1
|
||||||
|
monsters:
|
||||||
|
zombies: 10
|
||||||
|
skeletons: 10
|
||||||
|
spiders: 10
|
||||||
|
creepers: 10
|
||||||
|
wolves: 10
|
||||||
|
spec1:
|
||||||
|
type: special
|
||||||
|
priority: 2
|
||||||
|
frequency: 4
|
||||||
|
monsters:
|
||||||
|
powered-creepers: 10
|
||||||
|
zombie-pigmen: 10
|
||||||
|
angry-wolves: 10
|
||||||
|
humans: 10
|
||||||
|
rewards:
|
||||||
|
waves:
|
||||||
|
every:
|
||||||
|
'3': feather, bone, stick
|
||||||
|
'5': dirt:4, gravel:4, stone:4
|
||||||
|
'10': iron_ingot:10, gold_ingot:8
|
||||||
|
after:
|
||||||
|
'7': minecart, storage_minecart, powered_minecart
|
||||||
|
'13': iron_sword, iron_pickaxe, iron_spade
|
||||||
|
'16': diamond_sword
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
### General data
|
||||||
|
### Statistics for overall information about the arena, such as
|
||||||
|
### times played, durations, max players seen, total kills, etc.
|
||||||
|
general-info:
|
||||||
|
total-games-played: 0
|
||||||
|
total-duration: 0:00:00
|
||||||
|
longest-session-duration: 0:00:00
|
||||||
|
most-players: 0
|
||||||
|
highest-wave-reached: 0
|
||||||
|
total-monsters-killed: 0
|
||||||
|
|
||||||
|
### Class specific data
|
||||||
|
### How many times has each class been played, and how many kills, how
|
||||||
|
### much damage, etc. does the class make/do/take.
|
||||||
|
classes:
|
||||||
|
overall-distribution:
|
||||||
|
# Percentages can be calculated with <classname> / total-count * 100.
|
||||||
|
total-count: 0
|
||||||
|
|
||||||
|
#classes:
|
||||||
|
# overall-distribution:
|
||||||
|
# total-count: 0
|
||||||
|
# archer:
|
||||||
|
# kills:
|
||||||
|
# damage-done:
|
||||||
|
# damage-taken:
|
||||||
|
# accuracy:
|
||||||
|
# knight:
|
||||||
|
# kills:
|
||||||
|
# damage-done:
|
||||||
|
# damage-taken:
|
||||||
|
# accuracy:
|
||||||
|
# ...
|
||||||
|
### Reward data
|
||||||
|
### Totals for all rewards given, perhaps good for balancing?
|
||||||
|
rewards:
|
||||||
|
total-given:
|
||||||
|
# This might be useless information, I don't know.
|
||||||
|
# Might have to make it data values instead of Material names?
|
||||||
|
money: 0
|
||||||
|
|
||||||
|
### Player data
|
||||||
|
### Total games played, kills, damage, swings and hits (for accuracy), and how
|
||||||
|
### many times the player has played as each class.
|
||||||
|
players: {}
|
||||||
|
# garbagemule:
|
||||||
|
# games-played: 5
|
||||||
|
# kills: 4
|
||||||
|
# damage-done: 251
|
||||||
|
# damage-taken: 102
|
||||||
|
# swings: 1820
|
||||||
|
# hits: 1214
|
||||||
|
# classes-played:
|
||||||
|
# archer: 2
|
||||||
|
# ...
|
||||||
|
# Agnate:
|
||||||
|
# ...
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
### General data
|
||||||
|
### Statistics for overall information about the arena, such as
|
||||||
|
### times played, durations, max players seen, total kills, etc.
|
||||||
|
general-info:
|
||||||
|
total-games-played: 0
|
||||||
|
total-duration: 0:00:00
|
||||||
|
longest-session-duration: 0:00:00
|
||||||
|
most-players: 0
|
||||||
|
highest-wave-reached: 0
|
||||||
|
total-monsters-killed: 0
|
||||||
|
|
||||||
|
### Class specific data
|
||||||
|
### How many times has each class been played, and how many kills, how
|
||||||
|
### much damage, etc. does the class make/do/take.
|
||||||
|
classes:
|
||||||
|
overall-distribution:
|
||||||
|
# Percentages can be calculated with <classname> / total-count * 100.
|
||||||
|
total-count: 0
|
||||||
|
|
||||||
|
#classes:
|
||||||
|
# overall-distribution:
|
||||||
|
# total-count: 0
|
||||||
|
# archer:
|
||||||
|
# kills:
|
||||||
|
# damage-done:
|
||||||
|
# damage-taken:
|
||||||
|
# accuracy:
|
||||||
|
# knight:
|
||||||
|
# kills:
|
||||||
|
# damage-done:
|
||||||
|
# damage-taken:
|
||||||
|
# accuracy:
|
||||||
|
# ...
|
||||||
|
### Reward data
|
||||||
|
### Totals for all rewards given, perhaps good for balancing?
|
||||||
|
rewards:
|
||||||
|
total-given:
|
||||||
|
# This might be useless information, I don't know.
|
||||||
|
# Might have to make it data values instead of Material names?
|
||||||
|
money: 0
|
||||||
|
|
||||||
|
### Player data
|
||||||
|
### Total games played, kills, damage, swings and hits (for accuracy), and how
|
||||||
|
### many times the player has played as each class.
|
||||||
|
players: {}
|
||||||
|
# garbagemule:
|
||||||
|
# games-played: 5
|
||||||
|
# kills: 4
|
||||||
|
# damage-done: 251
|
||||||
|
# damage-taken: 102
|
||||||
|
# swings: 1820
|
||||||
|
# hits: 1214
|
||||||
|
# classes-played:
|
||||||
|
# archer: 2
|
||||||
|
# ...
|
||||||
|
# Agnate:
|
||||||
|
# ...
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
package com.garbagemule.MobArena;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public abstract class AbstractArena
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Start the arena session.
|
|
||||||
* This method should warp all players to their respective warp points, start all
|
|
||||||
* needed timers, clear/populate all sets and lists, and flag all booleans.
|
|
||||||
*/
|
|
||||||
public abstract void startArena();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Force the arena to start.
|
|
||||||
* If some players are ready, this method will force all non-ready players to leave,
|
|
||||||
* and the arena will start with only the currently ready players.
|
|
||||||
* @return true, if the arena was successfully started, false otherwise
|
|
||||||
*/
|
|
||||||
public abstract boolean forceStart();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stop the arena session.
|
|
||||||
* Distribute rewards, clean up arena floor and reset everything to how it was before
|
|
||||||
* the arena session was started, false otherwise
|
|
||||||
*/
|
|
||||||
public abstract void endArena();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Force the arena to end.
|
|
||||||
* Returns all players to their entry locations, distributes rewards, cleans the arena
|
|
||||||
* floor, as well as all lists, sets and maps. Calling this method will return the
|
|
||||||
* arena to the state it would be in right after MobArena has loaded.
|
|
||||||
* @return true, if the session was successfully ended.
|
|
||||||
*/
|
|
||||||
public abstract boolean forceEnd();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Player joins the arena/lobby.
|
|
||||||
* @param p A player
|
|
||||||
* @precondition Calling canJoin(p) for the given player must return true.
|
|
||||||
*/
|
|
||||||
public abstract void playerJoin(Player p);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Player leaves the arena or lobby.
|
|
||||||
* @param p A player
|
|
||||||
* @precondition Calling canLeave(p) for the given player must return true.
|
|
||||||
*/
|
|
||||||
public abstract void playerLeave(Player p);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Player joins the spectator area.
|
|
||||||
* @param p A player
|
|
||||||
* @precondition Calling canSpec(p) for the given player must return true.
|
|
||||||
*/
|
|
||||||
public abstract void playerSpec(Player p);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Player dies in the arena.
|
|
||||||
*/
|
|
||||||
public abstract void playerDeath(Player p);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Player signals that they are ready.
|
|
||||||
*/
|
|
||||||
public abstract void playerReady(Player p);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a player can join the arena.
|
|
||||||
* @param p A player
|
|
||||||
* @return true, if the player is eligible to join the arena.
|
|
||||||
*/
|
|
||||||
public abstract boolean canJoin(Player p);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a player can leave the arena.
|
|
||||||
* @param p A player
|
|
||||||
* @return true, if the player is eligible to leave the arena.
|
|
||||||
*/
|
|
||||||
public abstract boolean canLeave(Player p);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a player can spectate the arena.
|
|
||||||
* @param p A player
|
|
||||||
* @return true, if the player is eligible for spectating.
|
|
||||||
*/
|
|
||||||
public abstract boolean canSpec(Player p);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the arena is enabled.
|
|
||||||
* @return true, if the arena is enabled.
|
|
||||||
*/
|
|
||||||
public abstract boolean isEnabled();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the arena is running.
|
|
||||||
* @return true, if the arena is running.
|
|
||||||
*/
|
|
||||||
public abstract boolean isRunning();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the arena is set up and ready for use.
|
|
||||||
* @return true, if the arena is ready for use.
|
|
||||||
*/
|
|
||||||
public abstract boolean isSetup();
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
|||||||
package com.garbagemule.MobArena;
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
@@ -20,7 +21,8 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
|||||||
public interface ArenaListener
|
public interface ArenaListener
|
||||||
{
|
{
|
||||||
public void onBlockBreak(BlockBreakEvent event);
|
public void onBlockBreak(BlockBreakEvent event);
|
||||||
public void onBlockPlace(BlockPlaceEvent event);
|
public void onBlockPlace(BlockPlaceEvent event);
|
||||||
|
public void onBlockIgnite(BlockIgniteEvent event);
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event);
|
public void onCreatureSpawn(CreatureSpawnEvent event);
|
||||||
public void onEntityExplode(EntityExplodeEvent event);
|
public void onEntityExplode(EntityExplodeEvent event);
|
||||||
public void onEntityCombust(EntityCombustEvent event);
|
public void onEntityCombust(EntityCombustEvent event);
|
||||||
@@ -35,23 +37,4 @@ public interface ArenaListener
|
|||||||
public void onPlayerKick(PlayerKickEvent event);
|
public void onPlayerKick(PlayerKickEvent event);
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event);
|
public void onPlayerTeleport(PlayerTeleportEvent event);
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event);
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event);
|
||||||
|
|
||||||
/*
|
|
||||||
public abstract void onBlockBreak(BlockBreakEvent event);
|
|
||||||
public abstract void onBlockPlace(BlockPlaceEvent event);
|
|
||||||
public abstract void onCreatureSpawn(CreatureSpawnEvent event);
|
|
||||||
public abstract void onEntityExplode(EntityExplodeEvent event);
|
|
||||||
public abstract void onEntityCombust(EntityCombustEvent event);
|
|
||||||
public abstract void onEntityTarget(EntityTargetEvent event);
|
|
||||||
public abstract void onEntityRegainHealth(EntityRegainHealthEvent event);
|
|
||||||
public abstract void onEntityDeath(EntityDeathEvent event);
|
|
||||||
public abstract void onEntityDamage(EntityDamageEvent event);
|
|
||||||
public abstract void onPlayerDropItem(PlayerDropItemEvent event);
|
|
||||||
public abstract void onPlayerBucketEmpty(PlayerBucketEmptyEvent event);
|
|
||||||
public abstract void onPlayerInteract(PlayerInteractEvent event);
|
|
||||||
public abstract void onPlayerQuit(PlayerQuitEvent event);
|
|
||||||
public abstract void onPlayerKick(PlayerKickEvent event);
|
|
||||||
public abstract void onPlayerTeleport(PlayerTeleportEvent event);
|
|
||||||
public abstract void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,134 +1,141 @@
|
|||||||
package com.garbagemule.MobArena;
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedList;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.garbagemule.MobArena.util.data.PlainText;
|
||||||
|
import com.garbagemule.MobArena.util.data.Totals;
|
||||||
|
import com.garbagemule.MobArena.util.data.XML;
|
||||||
|
import com.garbagemule.MobArena.util.data.YAML;
|
||||||
|
|
||||||
public class ArenaLog
|
public class ArenaLog
|
||||||
{
|
{
|
||||||
protected MobArena plugin;
|
public MobArena plugin;
|
||||||
protected Arena arena;
|
public Arena arena;
|
||||||
protected List<String> log, classDistribution;
|
public Timestamp startTime, endTime;
|
||||||
protected Timestamp startTime, endTime;
|
public int lastWave;
|
||||||
|
|
||||||
|
public Map<Player,ArenaPlayer> players;
|
||||||
|
public Map<String,Integer> distribution;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new ArenaLog.
|
||||||
|
* @param plugin MobArena instance
|
||||||
|
* @param arena The arena
|
||||||
|
*/
|
||||||
public ArenaLog(MobArena plugin, Arena arena)
|
public ArenaLog(MobArena plugin, Arena arena)
|
||||||
{
|
{
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.arena = arena;
|
this.arena = arena;
|
||||||
log = new LinkedList<String>();
|
this.players = new HashMap<Player,ArenaPlayer>(arena.arenaPlayers.size());
|
||||||
classDistribution = new LinkedList<String>();
|
this.distribution = new HashMap<String,Integer>(arena.classes.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start logging by creating ArenaPlayer objects and recording
|
||||||
|
* the class distributions and the start time.
|
||||||
|
*/
|
||||||
public void start()
|
public void start()
|
||||||
{
|
{
|
||||||
startTime = new Timestamp((new Date()).getTime());
|
// Populate the data maps
|
||||||
|
populatePlayerMap();
|
||||||
|
populateDistributionMap();
|
||||||
|
|
||||||
// Class distribution
|
// Grab the current timestamp
|
||||||
int length = 0;
|
startTime = new Timestamp((new Date()).getTime());
|
||||||
for (String c : plugin.getAM().classes)
|
|
||||||
if (c.length() > length)
|
|
||||||
length = c.length();
|
|
||||||
|
|
||||||
List<String> classList = new LinkedList<String>(arena.classMap.values());
|
|
||||||
for (String c : plugin.getAM().classes)
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
int id = classList.indexOf(c);
|
|
||||||
while (id != -1)
|
|
||||||
{
|
|
||||||
classList.remove(id);
|
|
||||||
count++;
|
|
||||||
id = classList.indexOf(c);
|
|
||||||
}
|
|
||||||
//int percentage = (int) (((double) count) / ((double) arena.livePlayers.size())) * 100;
|
|
||||||
int percentage = (int) (((double) count) / ((double) arena.arenaPlayers.size())) * 100;
|
|
||||||
classDistribution.add(MAUtils.padRight(c + ": ", length + 2) + MAUtils.padLeft("" + count, 2) + " (" + percentage + "%)");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* End logging by recording the last wave and the end time.
|
||||||
|
*/
|
||||||
public void end()
|
public void end()
|
||||||
{
|
{
|
||||||
|
lastWave = arena.spawnThread.getWave() - 1;
|
||||||
endTime = new Timestamp((new Date()).getTime());
|
endTime = new Timestamp((new Date()).getTime());
|
||||||
|
|
||||||
// General stuff
|
|
||||||
log.add("--------------------------------------------------- ENTRY ---");
|
|
||||||
log.add("Start: " + startTime);
|
|
||||||
log.add("End: " + endTime);
|
|
||||||
log.add("Duration: " + MAUtils.getDuration(endTime.getTime() - startTime.getTime()));
|
|
||||||
log.add("Last wave: " + (arena.spawnThread.wave - 1));
|
|
||||||
log.add(" ");
|
|
||||||
|
|
||||||
// Class distribution
|
|
||||||
log.add("Class Distribution: " + plugin.getAM().classes.size() + " classes");
|
|
||||||
for (String c : classDistribution)
|
|
||||||
log.add("- " + c);
|
|
||||||
classDistribution.clear();
|
|
||||||
log.add(" ");
|
|
||||||
|
|
||||||
// Player data
|
|
||||||
int NAME = 12; int CLASS = 0; int WAVE = 4; int KILLS = 5;
|
|
||||||
for (String c : plugin.getAM().classes)
|
|
||||||
if (c.length() > CLASS)
|
|
||||||
CLASS = c.length();
|
|
||||||
|
|
||||||
log.add("Player Data: " + arena.classMap.keySet().size() + " players");
|
|
||||||
log.add("- " + MAUtils.padRight("Name", NAME + 2, ' ') + MAUtils.padRight("Class", CLASS + 2, ' ') + MAUtils.padRight("Wave", WAVE + 2, ' ') + MAUtils.padRight("Kills", KILLS + 2, ' ') + "Rewards");
|
|
||||||
for (Map.Entry<Player,String> entry : arena.classMap.entrySet())
|
|
||||||
{
|
|
||||||
Player p = entry.getKey();
|
|
||||||
StringBuffer buffy = new StringBuffer();
|
|
||||||
buffy.append(" ");
|
|
||||||
// Name
|
|
||||||
String name = (p.getName().length() <= NAME) ? p.getName() : p.getName().substring(0, NAME+1);
|
|
||||||
buffy.append(MAUtils.padRight(name, NAME + 2, ' '));
|
|
||||||
// Class
|
|
||||||
buffy.append(MAUtils.padRight(entry.getValue(), CLASS + 2, ' '));
|
|
||||||
// Wave
|
|
||||||
buffy.append(MAUtils.padLeft(arena.waveMap.remove(p).toString(), WAVE, ' ') + " ");
|
|
||||||
// Kills
|
|
||||||
buffy.append(MAUtils.padLeft(arena.killMap.remove(p).toString(), KILLS, ' ') + " ");
|
|
||||||
// Rewards
|
|
||||||
buffy.append(MAUtils.listToString(arena.rewardMap.get(p), plugin));
|
|
||||||
log.add(buffy.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
log.add(" ");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serialize()
|
/**
|
||||||
|
* Map players to ArenaPlayer objects.
|
||||||
|
*/
|
||||||
|
private void populatePlayerMap()
|
||||||
{
|
{
|
||||||
try
|
for (Player p : arena.arenaPlayers)
|
||||||
{
|
players.put(p, new ArenaPlayer(p, arena, plugin));
|
||||||
new File(plugin.getDataFolder() + File.separator + "logs").mkdir();
|
|
||||||
File logFile = new File(plugin.getDataFolder() + File.separator + "logs" + File.separator + arena.configName() + ".log");
|
|
||||||
if (logFile.exists())
|
|
||||||
logFile.createNewFile();
|
|
||||||
|
|
||||||
FileWriter fw = new FileWriter(logFile, true);
|
|
||||||
BufferedWriter bw = new BufferedWriter(fw);
|
|
||||||
for (String l : log)
|
|
||||||
{
|
|
||||||
bw.write(l);
|
|
||||||
bw.write(System.getProperty("line.separator"));
|
|
||||||
}
|
|
||||||
|
|
||||||
bw.close();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
System.out.println("[MobArena] ERROR! Could not create log file!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map classes to amounts of players playing as the classes.
|
||||||
|
*/
|
||||||
|
private void populateDistributionMap()
|
||||||
|
{
|
||||||
|
// Initialize the map
|
||||||
|
for (String c : arena.classes)
|
||||||
|
distribution.put(c,0);
|
||||||
|
|
||||||
public void add(String s) { log.add(s); }
|
// Count occurrences
|
||||||
public void clear() { log.clear(); }
|
for (String c : arena.classMap.values())
|
||||||
|
distribution.put(c,distribution.get(c) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the data of the current session according to the logging type.
|
||||||
|
*/
|
||||||
|
public void saveSessionData()
|
||||||
|
{
|
||||||
|
if (arena.logging.equals("xml"))
|
||||||
|
XML.saveSessionData(this);
|
||||||
|
else if (arena.logging.equals("yml") || arena.logging.equals("yaml"))
|
||||||
|
YAML.saveSessionData(this);
|
||||||
|
else
|
||||||
|
PlainText.saveSessionData(this);
|
||||||
|
//CSV.saveSessionData(this, plugin);
|
||||||
|
//YAML.saveSessionData(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the totals-file
|
||||||
|
*/
|
||||||
|
public void updateArenaTotals()
|
||||||
|
{
|
||||||
|
Totals.updateArenaTotals(this);
|
||||||
|
|
||||||
|
if (arena.logging.equals("xml"))
|
||||||
|
XML.updateArenaTotals(this);
|
||||||
|
//PlainText.updateArenaTotals(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear maps.
|
||||||
|
*/
|
||||||
|
public void clearSessionData()
|
||||||
|
{
|
||||||
|
players.clear();
|
||||||
|
distribution.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Arena getArena() { return arena; }
|
||||||
|
public Timestamp getStartTime() { return startTime; }
|
||||||
|
public Timestamp getEndTime() { return endTime; }
|
||||||
|
public String getDuration() { return MAUtils.getDuration(endTime.getTime() - startTime.getTime()); }
|
||||||
|
public long getDurationLong() { return endTime.getTime() - startTime.getTime(); }
|
||||||
|
public int getLastWave() { return lastWave; }
|
||||||
|
|
||||||
|
public void playerKill(Player p)
|
||||||
|
{
|
||||||
|
players.get(p).kills++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playerDamager(Player p, int damage)
|
||||||
|
{
|
||||||
|
players.get(p).dmgDone += damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playerDamagee(Player p, int damage)
|
||||||
|
{
|
||||||
|
players.get(p).dmgTaken += damage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.util.config.Configuration;
|
||||||
|
|
||||||
public class ArenaMaster
|
//import com.garbagemule.ArenaPlugin.Master;
|
||||||
|
|
||||||
|
public class ArenaMaster //implements Master
|
||||||
{
|
{
|
||||||
private MobArena plugin;
|
private MobArena plugin;
|
||||||
private Configuration config;
|
private Configuration config;
|
||||||
@@ -49,6 +51,7 @@ public class ArenaMaster
|
|||||||
{
|
{
|
||||||
plugin = instance;
|
plugin = instance;
|
||||||
config = plugin.getConfig();
|
config = plugin.getConfig();
|
||||||
|
arenas = new LinkedList<Arena>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -68,6 +71,15 @@ public class ArenaMaster
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Arena> getPermittedArenas(Player p)
|
||||||
|
{
|
||||||
|
List<Arena> result = new LinkedList<Arena>();
|
||||||
|
for (Arena arena : arenas)
|
||||||
|
if (plugin.has(p, "mobarena.arenas." + arena.configName()))
|
||||||
|
result.add(arena);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public Arena getArenaAtLocation(Location loc)
|
public Arena getArenaAtLocation(Location loc)
|
||||||
{
|
{
|
||||||
for (Arena arena : arenas)
|
for (Arena arena : arenas)
|
||||||
@@ -221,21 +233,18 @@ public class ArenaMaster
|
|||||||
|
|
||||||
if (config.getKeys("arenas") == null)
|
if (config.getKeys("arenas") == null)
|
||||||
createArenaNode("default", Bukkit.getServer().getWorlds().get(0));
|
createArenaNode("default", Bukkit.getServer().getWorlds().get(0));
|
||||||
|
|
||||||
for (String configName : config.getKeys("arenas"))
|
for (String configName : config.getKeys("arenas"))
|
||||||
{
|
{
|
||||||
String arenaPath = "arenas." + configName + ".";
|
String arenaPath = "arenas." + configName + ".";
|
||||||
String worldName = config.getString(arenaPath + "settings.world");
|
String worldName = config.getString(arenaPath + "settings.world", null);
|
||||||
World world;
|
World world;
|
||||||
if (worldName == null)
|
if (worldName == null || worldName.equals(""))
|
||||||
{
|
{
|
||||||
System.out.println("[MobArena] ERROR! Could not find the world for arena '" + configName + "'. Using default world! Check the config-file!");
|
MobArena.warning("Could not find the world for arena '" + configName + "'. Using default world! Check the config-file!");
|
||||||
world = Bukkit.getServer().getWorlds().get(0);
|
world = Bukkit.getServer().getWorlds().get(0);
|
||||||
}
|
}
|
||||||
else
|
else world = Bukkit.getServer().getWorld(worldName);
|
||||||
{
|
|
||||||
world = Bukkit.getServer().getWorld(worldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world);
|
Arena arena = new Arena(MAUtils.nameConfigToArena(configName), world);
|
||||||
arena.load(config);
|
arena.load(config);
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class ArenaPlayer
|
||||||
|
{
|
||||||
|
public MobArena plugin;
|
||||||
|
public Player player;
|
||||||
|
public String className;
|
||||||
|
public Arena arena;
|
||||||
|
public List<ItemStack> rewards;
|
||||||
|
public List<Block> blocks;
|
||||||
|
|
||||||
|
protected boolean inArena, inLobby, inSpec, isReady;
|
||||||
|
|
||||||
|
// Session fields.
|
||||||
|
public int kills, dmgDone, dmgTaken, swings, hits, deaths, lastWave;
|
||||||
|
public int flagCaps, flagAttempts, flagReturns; // BG: Capture the Pumpkin
|
||||||
|
public int baseCaps; // BG: Domination
|
||||||
|
|
||||||
|
// All-time fields.
|
||||||
|
protected int totalKills, totalDmgDone, totalDmgTaken, totalSwings, totalHits, totalDeaths;
|
||||||
|
protected int totalFlagCaps, totalFlagAttempts, totalFlagReturns; // BG: Capture the Pumpkin
|
||||||
|
protected int totalBaseCaps; // BG: Domination
|
||||||
|
|
||||||
|
public ArenaPlayer(Player player, Arena arena, MobArena plugin)
|
||||||
|
{
|
||||||
|
this.player = player;
|
||||||
|
this.arena = arena;
|
||||||
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
className = arena.classMap.get(player);
|
||||||
|
rewards = new LinkedList<ItemStack>();
|
||||||
|
blocks = new LinkedList<Block>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() { return player; }
|
||||||
|
public Arena getArena() { return arena; }
|
||||||
|
public String getClassName() { return className; }
|
||||||
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.garbagemule.MobArena;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class Lobby
|
|
||||||
{
|
|
||||||
protected Arena arena;
|
|
||||||
protected ArenaMaster am;
|
|
||||||
protected Location warp, l1, l2;
|
|
||||||
|
|
||||||
public Lobby(Arena arena)
|
|
||||||
{
|
|
||||||
this.arena = arena;
|
|
||||||
}
|
|
||||||
public Lobby()
|
|
||||||
{
|
|
||||||
this(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playerJoin(Player p)
|
|
||||||
{
|
|
||||||
p.teleport(warp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.garbagemule.MobArena;
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
import org.bukkit.event.block.BlockListener;
|
import org.bukkit.event.block.BlockListener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
public class MABlockListener extends BlockListener
|
public class MABlockListener extends BlockListener
|
||||||
@@ -18,10 +21,28 @@ public class MABlockListener extends BlockListener
|
|||||||
for (Arena arena : am.arenas)
|
for (Arena arena : am.arenas)
|
||||||
arena.eventListener.onBlockBreak(event);
|
arena.eventListener.onBlockBreak(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onBlockBurn(BlockBurnEvent event)
|
||||||
|
{
|
||||||
|
for (Arena arena : am.arenas)
|
||||||
|
arena.eventListener.onBlockBurn(event);
|
||||||
|
}
|
||||||
|
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
for (Arena arena : am.arenas)
|
for (Arena arena : am.arenas)
|
||||||
arena.eventListener.onBlockPlace(event);
|
arena.eventListener.onBlockPlace(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onBlockIgnite(BlockIgniteEvent event)
|
||||||
|
{
|
||||||
|
for (Arena arena : am.arenas)
|
||||||
|
arena.eventListener.onBlockIgnite(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockPhysics(BlockPhysicsEvent event)
|
||||||
|
{
|
||||||
|
for (Arena arena : am.arenas)
|
||||||
|
arena.eventListener.onBlockPhysics(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.block.ContainerBlock;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@@ -55,10 +56,14 @@ public class MACommands implements CommandExecutor
|
|||||||
COMMANDS.add("setwarp"); // Set arena/lobby/spec
|
COMMANDS.add("setwarp"); // Set arena/lobby/spec
|
||||||
COMMANDS.add("spawnpoints"); // List spawnpoints
|
COMMANDS.add("spawnpoints"); // List spawnpoints
|
||||||
COMMANDS.add("addspawn"); // Add a spawnpoint
|
COMMANDS.add("addspawn"); // Add a spawnpoint
|
||||||
COMMANDS.add("delspawn"); // Delete a spawnpoint
|
COMMANDS.add("delspawn"); // Delete a spawnpoint
|
||||||
|
COMMANDS.add("containers"); // List containers
|
||||||
|
COMMANDS.add("addcontainer"); // Add a container block
|
||||||
|
COMMANDS.add("delcontainer"); // Delete a container block
|
||||||
COMMANDS.add("reset"); // Reset arena coordinates
|
COMMANDS.add("reset"); // Reset arena coordinates
|
||||||
COMMANDS.add("addclass"); // Add a new class
|
COMMANDS.add("addclass"); // Add a new class
|
||||||
COMMANDS.add("delclass"); // Delete a class
|
COMMANDS.add("delclass"); // Delete a class
|
||||||
|
COMMANDS.add("checkdata"); // Check arena well formedness
|
||||||
COMMANDS.add("auto-generate"); // Auto-generate arena
|
COMMANDS.add("auto-generate"); // Auto-generate arena
|
||||||
COMMANDS.add("auto-degenerate"); // Restore cuboid
|
COMMANDS.add("auto-degenerate"); // Restore cuboid
|
||||||
}
|
}
|
||||||
@@ -115,6 +120,11 @@ public class MACommands implements CommandExecutor
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////*/
|
////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
if (base.equals("spawn"))
|
||||||
|
{
|
||||||
|
p.getWorld().setSpawnLocation(p.getLocation().getBlockX(), p.getLocation().getBlockY() + 1, p.getLocation().getBlockZ());
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Player join
|
* Player join
|
||||||
*/
|
*/
|
||||||
@@ -122,61 +132,113 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!player || !plugin.has(p, "mobarena.use.join"))
|
if (!player || !plugin.has(p, "mobarena.use.join"))
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Arena> arenas = am.getEnabledArenas();
|
||||||
|
if (!am.enabled || arenas.size() < 1)
|
||||||
|
{
|
||||||
|
MAUtils.tellPlayer(p, Msg.JOIN_NOT_ENABLED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grab the arena to join
|
||||||
|
Arena arena = arenas.size() == 1 ? arenas.get(0) : am.getArenaWithName(arg1);
|
||||||
|
|
||||||
|
// Run a couple of basic sanity checks
|
||||||
|
if (!sanityChecks(p, arena, arg1, arenas))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Run a bunch of per-arena sanity checks
|
||||||
|
if (!arena.canJoin(p))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// If player is in a boat/minecart, eject!
|
||||||
|
if (p.isInsideVehicle())
|
||||||
|
p.leaveVehicle();
|
||||||
|
|
||||||
|
// Take entry fee and store inventory
|
||||||
|
arena.takeFee(p);
|
||||||
|
if (!arena.emptyInvJoin) MAUtils.storeInventory(p);
|
||||||
|
|
||||||
|
// If player is in a bed, unbed!
|
||||||
|
if (p.isSleeping())
|
||||||
|
{
|
||||||
|
p.kickPlayer("Banned for life... Nah, just don't join from a bed ;)");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Join the arena!
|
||||||
|
arena.playerJoin(p, p.getLocation());
|
||||||
|
|
||||||
|
MAUtils.tellPlayer(p, Msg.JOIN_PLAYER_JOINED);
|
||||||
|
if (!arena.entryFee.isEmpty())
|
||||||
|
MAUtils.tellPlayer(p, Msg.JOIN_FEE_PAID.get(MAUtils.listToString(arena.entryFee, plugin)));
|
||||||
|
if (arena.hasPaid.contains(p))
|
||||||
|
arena.hasPaid.remove(p);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Player leave
|
||||||
|
*/
|
||||||
|
if (base.equals("leave") || base.equals("l"))
|
||||||
|
{
|
||||||
|
if (!player || !plugin.has(p, "mobarena.use.leave"))
|
||||||
|
{
|
||||||
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!am.arenaMap.containsKey(p))
|
||||||
|
{
|
||||||
|
Arena arena = am.getArenaWithSpectator(p);
|
||||||
|
if (arena != null)
|
||||||
|
{
|
||||||
|
arena.playerLeave(p);
|
||||||
|
MAUtils.tellPlayer(p, Msg.LEAVE_PLAYER_LEFT);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MAUtils.tellPlayer(p, Msg.LEAVE_NOT_PLAYING);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Arena arena = am.arenaMap.get(p);
|
||||||
|
arena.playerLeave(p);
|
||||||
|
MAUtils.tellPlayer(p, Msg.LEAVE_PLAYER_LEFT);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Player spectate
|
||||||
|
*/
|
||||||
|
if (base.equals("spectate") || base.equals("spec"))
|
||||||
|
{
|
||||||
|
if (!player || !plugin.has(p, "mobarena.use.spectate"))
|
||||||
|
{
|
||||||
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
List<Arena> arenas = am.getEnabledArenas();
|
List<Arena> arenas = am.getEnabledArenas();
|
||||||
if (!am.enabled || arenas.size() < 1)
|
if (!am.enabled || arenas.size() < 1)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_NOT_ENABLED));
|
MAUtils.tellPlayer(p, Msg.JOIN_NOT_ENABLED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean error;
|
// Grab the arena to join
|
||||||
Arena arena;
|
Arena arena = arenas.size() == 1 ? arenas.get(0) : am.getArenaWithName(arg1);
|
||||||
|
|
||||||
if (!arg1.isEmpty())
|
// Run a couple of basic sanity checks
|
||||||
arena = am.getArenaWithName(arg1);
|
if (!sanityChecks(p, arena, arg1, arenas))
|
||||||
else if (arenas.size() == 1)
|
return true;
|
||||||
arena = arenas.get(0);
|
|
||||||
else
|
// Run a bunch of arena-specific sanity-checks
|
||||||
arena = null;
|
if (!arena.canSpec(p))
|
||||||
|
|
||||||
if (arenas.size() > 1 && arg1.isEmpty())
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARG_NEEDED));
|
|
||||||
else if (arena == null)
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
|
||||||
else if (am.arenaMap.containsKey(p) && (am.arenaMap.get(p).arenaPlayers.contains(p) || am.arenaMap.get(p).lobbyPlayers.contains(p)))
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_IN_OTHER_ARENA));
|
|
||||||
else if (!arena.enabled)
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_NOT_ENABLED));
|
|
||||||
else if (!arena.setup || arena.edit)
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_NOT_SETUP));
|
|
||||||
else if (arena.running && (arena.notifyPlayers.contains(p) || arena.notifyPlayers.add(p)))
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_IS_RUNNING));
|
|
||||||
else if (arena.arenaPlayers.contains(p))
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ALREADY_PLAYING));
|
|
||||||
else if (!plugin.has(p, "mobarena.arenas." + arena.configName()))
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_PERMISSION));
|
|
||||||
else if (arena.maxPlayers > 0 && arena.lobbyPlayers.size() >= arena.maxPlayers)
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_PLAYER_LIMIT_REACHED));
|
|
||||||
else if (arena.joinDistance > 0 && !arena.inRegionRadius(p.getLocation(), arena.joinDistance))
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_TOO_FAR));
|
|
||||||
else if (!arena.canAfford(p) || !arena.takeFee(p))
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_FEE_REQUIRED, MAUtils.listToString(arena.entryFee, plugin)));
|
|
||||||
else if (arena.emptyInvJoin && !MAUtils.hasEmptyInventory(p))
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_EMPTY_INV));
|
|
||||||
else if (!arena.emptyInvJoin && !MAUtils.storeInventory(p))
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_STORE_INV_FAIL));
|
|
||||||
else error = false;
|
|
||||||
|
|
||||||
// If there was an error, don't join.
|
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
if (arena != null)
|
|
||||||
arena.refund(p);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// If player is in a boat/minecart, eject!
|
// If player is in a boat/minecart, eject!
|
||||||
if (p.isInsideVehicle())
|
if (p.isInsideVehicle())
|
||||||
@@ -189,106 +251,10 @@ public class MACommands implements CommandExecutor
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
am.arenaMap.put(p,arena);
|
// Spectate the arena!
|
||||||
arena.playerJoin(p, p.getLocation());
|
|
||||||
|
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_PLAYER_JOINED));
|
|
||||||
if (!arena.entryFee.isEmpty())
|
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_FEE_PAID, MAUtils.listToString(arena.entryFee, plugin)));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Player leave
|
|
||||||
*/
|
|
||||||
if (base.equals("leave") || base.equals("l"))
|
|
||||||
{
|
|
||||||
if (!player || !plugin.has(p, "mobarena.use.leave"))
|
|
||||||
{
|
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!am.arenaMap.containsKey(p))
|
|
||||||
{
|
|
||||||
Arena arena = am.getArenaWithSpectator(p);
|
|
||||||
if (arena != null)
|
|
||||||
{
|
|
||||||
arena.playerLeave(p);
|
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LEAVE_PLAYER_LEFT));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LEAVE_NOT_PLAYING));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Arena arena = am.arenaMap.remove(p);
|
|
||||||
arena.playerLeave(p);
|
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LEAVE_PLAYER_LEFT));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Player spectate
|
|
||||||
*/
|
|
||||||
if (base.equals("spectate") || base.equals("spec"))
|
|
||||||
{
|
|
||||||
if (!player || !plugin.has(p, "mobarena.use.spectate"))
|
|
||||||
{
|
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
List<Arena> arenas = am.getEnabledArenas();
|
|
||||||
if (!am.enabled || arenas.size() < 1)
|
|
||||||
{
|
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_NOT_ENABLED));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean error;
|
|
||||||
Arena arena;
|
|
||||||
|
|
||||||
if (!arg1.isEmpty())
|
|
||||||
arena = am.getArenaWithName(arg1);
|
|
||||||
else if (arenas.size() == 1)
|
|
||||||
arena = arenas.get(0);
|
|
||||||
else
|
|
||||||
arena = null;
|
|
||||||
|
|
||||||
if (arenas.size() > 1 && arg1.isEmpty())
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARG_NEEDED));
|
|
||||||
else if (arena == null)
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
|
||||||
//else if (am.arenaMap.containsKey(p) && am.arenaMap.get(p).livePlayers.contains(p))
|
|
||||||
else if (am.arenaMap.containsKey(p) && (am.arenaMap.get(p).arenaPlayers.contains(p) || am.arenaMap.get(p).lobbyPlayers.contains(p)))
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_IN_OTHER_ARENA));
|
|
||||||
else if (!arena.enabled)
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_NOT_ENABLED));
|
|
||||||
else if (!arena.setup || arena.edit)
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_ARENA_NOT_SETUP));
|
|
||||||
//else if (arena.livePlayers.contains(p))
|
|
||||||
else if (arena.arenaPlayers.contains(p))
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.SPEC_ALREADY_PLAYING));
|
|
||||||
else if (arena.emptyInvSpec && !MAUtils.hasEmptyInventory(p))
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.SPEC_EMPTY_INV));
|
|
||||||
else if (arena.joinDistance > 0 && !arena.inRegionRadius(p.getLocation(), arena.joinDistance))
|
|
||||||
error = MAUtils.tellPlayer(p, MAMessages.get(Msg.JOIN_TOO_FAR));
|
|
||||||
else error = false;
|
|
||||||
|
|
||||||
// If there was an error, don't spec.
|
|
||||||
if (error)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// If player is in a boat/minecart, eject!
|
|
||||||
if (p.isInsideVehicle())
|
|
||||||
p.leaveVehicle();
|
|
||||||
|
|
||||||
am.arenaMap.put(p,arena);
|
|
||||||
arena.playerSpec(p, p.getLocation());
|
arena.playerSpec(p, p.getLocation());
|
||||||
|
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.SPEC_PLAYER_SPECTATE));
|
MAUtils.tellPlayer(p, Msg.SPEC_PLAYER_SPECTATE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,8 +263,8 @@ public class MACommands implements CommandExecutor
|
|||||||
*/
|
*/
|
||||||
if (base.equals("arenas"))
|
if (base.equals("arenas"))
|
||||||
{
|
{
|
||||||
String list = MAUtils.listToString(am.arenas, plugin);
|
String list = MAUtils.listToString(player ? am.getPermittedArenas(p) : am.arenas, plugin);
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_ARENAS, list));
|
MAUtils.tellPlayer(sender, Msg.MISC_LIST_ARENAS.get(list));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,12 +278,12 @@ public class MACommands implements CommandExecutor
|
|||||||
Arena arena = am.getArenaWithName(arg1);
|
Arena arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null)
|
if (arena == null)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
MAUtils.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String list = MAUtils.listToString(arena.getLivingPlayers(), plugin);
|
String list = MAUtils.listToString(arena.getLivingPlayers(), plugin);
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_PLAYERS, list));
|
MAUtils.tellPlayer(sender, Msg.MISC_LIST_PLAYERS.get(list));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -326,7 +292,7 @@ public class MACommands implements CommandExecutor
|
|||||||
for (Arena arena : am.arenas)
|
for (Arena arena : am.arenas)
|
||||||
players.addAll(arena.getLivingPlayers());
|
players.addAll(arena.getLivingPlayers());
|
||||||
buffy.append(MAUtils.listToString(players, plugin));
|
buffy.append(MAUtils.listToString(players, plugin));
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_PLAYERS, buffy.toString()));
|
MAUtils.tellPlayer(sender, Msg.MISC_LIST_PLAYERS.get(buffy.toString()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -342,7 +308,7 @@ public class MACommands implements CommandExecutor
|
|||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null)
|
if (arena == null)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
MAUtils.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -351,7 +317,7 @@ public class MACommands implements CommandExecutor
|
|||||||
arena = am.getArenaWithPlayer(p);
|
arena = am.getArenaWithPlayer(p);
|
||||||
if (arena == null)
|
if (arena == null)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.LEAVE_NOT_PLAYING));
|
MAUtils.tellPlayer(sender, Msg.LEAVE_NOT_PLAYING);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -362,7 +328,7 @@ public class MACommands implements CommandExecutor
|
|||||||
}
|
}
|
||||||
|
|
||||||
String list = MAUtils.listToString(arena.getNonreadyPlayers(), plugin);
|
String list = MAUtils.listToString(arena.getNonreadyPlayers(), plugin);
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_LIST_PLAYERS, list));
|
MAUtils.tellPlayer(sender, Msg.MISC_LIST_PLAYERS.get(list));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +347,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.admin.enable")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.admin.enable")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,7 +362,7 @@ public class MACommands implements CommandExecutor
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
MAUtils.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -415,7 +381,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.admin.kick")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.admin.kick")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,7 +415,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.admin.restore")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.admin.restore")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,7 +442,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.admin.force.end")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.admin.force.end")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -492,26 +458,25 @@ public class MACommands implements CommandExecutor
|
|||||||
Arena arena = am.getArenaWithName(arg2);
|
Arena arena = am.getArenaWithName(arg2);
|
||||||
if (arena == null)
|
if (arena == null)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
MAUtils.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (arena.livePlayers.isEmpty())
|
if (arena.getAllPlayers().isEmpty())
|
||||||
if (arena.arenaPlayers.isEmpty())
|
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.FORCE_END_EMPTY));
|
MAUtils.tellPlayer(sender, Msg.FORCE_END_EMPTY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.forceEnd();
|
arena.forceEnd();
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.FORCE_END_ENDED));
|
MAUtils.tellPlayer(sender, Msg.FORCE_END_ENDED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (arg1.equals("start"))
|
else if (arg1.equals("start"))
|
||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.admin.force.start")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.admin.force.start")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -524,23 +489,23 @@ public class MACommands implements CommandExecutor
|
|||||||
Arena arena = am.getArenaWithName(arg2);
|
Arena arena = am.getArenaWithName(arg2);
|
||||||
if (arena == null)
|
if (arena == null)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
MAUtils.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.running)
|
if (arena.running)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.FORCE_START_RUNNING));
|
MAUtils.tellPlayer(sender, Msg.FORCE_START_RUNNING);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (arena.readyPlayers.isEmpty())
|
if (arena.readyPlayers.isEmpty())
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.FORCE_START_NOT_READY));
|
MAUtils.tellPlayer(sender, Msg.FORCE_START_NOT_READY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.forceStart();
|
arena.forceStart();
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.FORCE_START_STARTED));
|
MAUtils.tellPlayer(sender, Msg.FORCE_START_STARTED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -557,7 +522,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.admin.config.reload")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.admin.config.reload")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,7 +544,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.setup.arena")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.setup.arena")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -592,7 +557,7 @@ public class MACommands implements CommandExecutor
|
|||||||
if (!arena.equals(am.selectedArena))
|
if (!arena.equals(am.selectedArena))
|
||||||
buffy.append(arena.configName() + " ");
|
buffy.append(arena.configName() + " ");
|
||||||
}
|
}
|
||||||
else buffy.append(MAMessages.get(Msg.MISC_NONE));
|
else buffy.append(Msg.MISC_NONE);
|
||||||
|
|
||||||
MAUtils.tellPlayer(sender, "Other arenas: " + buffy.toString());
|
MAUtils.tellPlayer(sender, "Other arenas: " + buffy.toString());
|
||||||
return true;
|
return true;
|
||||||
@@ -605,7 +570,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.setup.setarena")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.setup.setarena")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (arg1.isEmpty())
|
if (arg1.isEmpty())
|
||||||
@@ -622,7 +587,7 @@ public class MACommands implements CommandExecutor
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
MAUtils.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -634,7 +599,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!(player && plugin.has(p, "mobarena.setup.addarena")) && !op)
|
if (!(player && plugin.has(p, "mobarena.setup.addarena")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (arg1.isEmpty())
|
if (arg1.isEmpty())
|
||||||
@@ -662,7 +627,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.setup.delarena")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.setup.delarena")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (arg1.isEmpty())
|
if (arg1.isEmpty())
|
||||||
@@ -698,7 +663,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.setup.protect")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.setup.protect")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,7 +729,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.setup.editarena")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.setup.editarena")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -833,7 +798,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!(player && plugin.has(p, "mobarena.setup.setregion")) && !op)
|
if (!(player && plugin.has(p, "mobarena.setup.setregion")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -855,7 +820,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.setup.expandregion")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.setup.expandregion")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length != 3 || !arg1.matches("(-)?[0-9]+"))
|
if (args.length != 3 || !arg1.matches("(-)?[0-9]+"))
|
||||||
@@ -903,7 +868,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!(player && plugin.has(p, "mobarena.setup.showregion")) && !op)
|
if (!(player && plugin.has(p, "mobarena.setup.showregion")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (am.selectedArena.p1 == null || am.selectedArena.p2 == null)
|
if (am.selectedArena.p1 == null || am.selectedArena.p2 == null)
|
||||||
@@ -955,7 +920,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!(player && plugin.has(p, "mobarena.setup.setlobbyregion")) && !op)
|
if (!(player && plugin.has(p, "mobarena.setup.setlobbyregion")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -974,7 +939,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.setup.expandlobbyregion")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.setup.expandlobbyregion")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length != 3 || !arg1.matches("[0-9]+"))
|
if (args.length != 3 || !arg1.matches("[0-9]+"))
|
||||||
@@ -1022,7 +987,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!(player && plugin.has(p, "mobarena.setup.setwarp")) && !op)
|
if (!(player && plugin.has(p, "mobarena.setup.setwarp")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!(arg1.equals("arena") || arg1.equals("lobby") || arg1.equals("spectator")))
|
if (!(arg1.equals("arena") || arg1.equals("lobby") || arg1.equals("spectator")))
|
||||||
@@ -1032,7 +997,8 @@ public class MACommands implements CommandExecutor
|
|||||||
}
|
}
|
||||||
|
|
||||||
MAUtils.setArenaCoord(plugin.getConfig(), am.selectedArena, arg1, p.getLocation());
|
MAUtils.setArenaCoord(plugin.getConfig(), am.selectedArena, arg1, p.getLocation());
|
||||||
MAUtils.tellPlayer(sender, "Set warp point " + arg1 + " for arena '" + am.selectedArena.configName() + "'");
|
MAUtils.tellPlayer(sender, "Warp point " + arg1 + " was set for arena '" + am.selectedArena.configName() + "'");
|
||||||
|
MAUtils.tellPlayer(sender, "Type /ma checkdata to see if you're missing anything...");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1043,7 +1009,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.setup.spawnpoints")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.setup.spawnpoints")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1060,7 +1026,7 @@ public class MACommands implements CommandExecutor
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
buffy.append(MAMessages.get(Msg.MISC_NONE));
|
buffy.append(Msg.MISC_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
MAUtils.tellPlayer(sender, "Spawnpoints for arena '" + am.selectedArena.configName() + "': " + buffy.toString());
|
MAUtils.tellPlayer(sender, "Spawnpoints for arena '" + am.selectedArena.configName() + "': " + buffy.toString());
|
||||||
@@ -1074,7 +1040,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!(player && plugin.has(p, "mobarena.setup.addspawn")) && !op)
|
if (!(player && plugin.has(p, "mobarena.setup.addspawn")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$"))
|
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$"))
|
||||||
@@ -1084,7 +1050,7 @@ public class MACommands implements CommandExecutor
|
|||||||
}
|
}
|
||||||
|
|
||||||
MAUtils.setArenaCoord(plugin.getConfig(), am.selectedArena, "spawnpoints." + arg1, p.getLocation());
|
MAUtils.setArenaCoord(plugin.getConfig(), am.selectedArena, "spawnpoints." + arg1, p.getLocation());
|
||||||
MAUtils.tellPlayer(sender, "Added spawnpoint " + arg1 + " for arena \"" + am.selectedArena.configName() + "\"");
|
MAUtils.tellPlayer(sender, "Spawnpoint " + arg1 + " added for arena \"" + am.selectedArena.configName() + "\"");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1095,7 +1061,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.setup.delspawn")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.setup.delspawn")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$"))
|
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$"))
|
||||||
@@ -1105,22 +1071,112 @@ public class MACommands implements CommandExecutor
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (MAUtils.delArenaCoord(plugin.getConfig(), am.selectedArena, "spawnpoints." + arg1))
|
if (MAUtils.delArenaCoord(plugin.getConfig(), am.selectedArena, "spawnpoints." + arg1))
|
||||||
MAUtils.tellPlayer(sender, "Deleted spawnpoint " + arg1 + " for arena '" + am.selectedArena.configName() + "'");
|
MAUtils.tellPlayer(sender, "Spawnpoint " + arg1 + " deleted for arena '" + am.selectedArena.configName() + "'");
|
||||||
else
|
else
|
||||||
MAUtils.tellPlayer(sender, "Could not find the spawnpoint " + arg1 + "for the arena '" + am.selectedArena.configName() + "'");
|
MAUtils.tellPlayer(sender, "Could not find the spawnpoint " + arg1 + "for the arena '" + am.selectedArena.configName() + "'");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base.equals("auto-generate"))
|
if (base.equals("containers"))
|
||||||
{
|
{
|
||||||
if (!(player && plugin.has(p, "mobarena.setup.autogenerate")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.setup.containers")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuffer buffy = new StringBuffer();
|
||||||
|
List<String> containers = plugin.getConfig().getKeys("arenas." + am.selectedArena.configName() + ".coords.containers");
|
||||||
|
|
||||||
|
if (containers != null)
|
||||||
|
{
|
||||||
|
for (String s : containers)
|
||||||
|
{
|
||||||
|
buffy.append(s);
|
||||||
|
buffy.append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buffy.append(Msg.MISC_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
MAUtils.tellPlayer(sender, "Containers for arena '" + am.selectedArena.configName() + "': " + buffy.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (base.equals("addcontainer"))
|
||||||
|
{
|
||||||
|
if (!(player && plugin.has(p, "mobarena.setup.addchest")) && !op)
|
||||||
|
{
|
||||||
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$"))
|
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$"))
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, "Usage: /ma autogenerate <arena name>");
|
MAUtils.tellPlayer(sender, "Usage: /ma addcontainer <container name>");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(p.getTargetBlock(null, 50).getState() instanceof ContainerBlock))
|
||||||
|
{
|
||||||
|
MAUtils.tellPlayer(sender, "You must look at container.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MAUtils.setArenaCoord(plugin.getConfig(), am.selectedArena, "containers." + arg1, p.getTargetBlock(null, 50).getLocation());
|
||||||
|
MAUtils.tellPlayer(sender, "Container '" + arg1 + "' added for arena \"" + am.selectedArena.configName() + "\"");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (base.equals("delcontainer"))
|
||||||
|
{
|
||||||
|
if (!console && !(player && plugin.has(p, "mobarena.setup.delcontainer")) && !op)
|
||||||
|
{
|
||||||
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$"))
|
||||||
|
{
|
||||||
|
MAUtils.tellPlayer(sender, "Usage: /ma delcontainer <container name>");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MAUtils.delArenaCoord(plugin.getConfig(), am.selectedArena, "containers." + arg1))
|
||||||
|
MAUtils.tellPlayer(sender, "Container '" + arg1 + "' deleted for arena '" + am.selectedArena.configName() + "'");
|
||||||
|
else
|
||||||
|
MAUtils.tellPlayer(sender, "Could not find the container '" + arg1 + "' for arena '" + am.selectedArena.configName() + "'");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (base.equals("checkdata"))
|
||||||
|
{
|
||||||
|
if (!console && !(player && plugin.has(p, "mobarena.setup.checkdata")) && !op)
|
||||||
|
{
|
||||||
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Arena arena = arg1.isEmpty() ? am.selectedArena : am.getArenaWithName(arg1);
|
||||||
|
if (arena == null)
|
||||||
|
{
|
||||||
|
MAUtils.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
MAUtils.checkData(arena, sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (base.equals("auto-generate") || base.equals("autogenerate"))
|
||||||
|
{
|
||||||
|
if (!(player && plugin.has(p, "mobarena.setup.autogenerate")) && !op)
|
||||||
|
{
|
||||||
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (arg1 == null || !arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$"))
|
||||||
|
{
|
||||||
|
MAUtils.tellPlayer(sender, "Usage: /ma auto-generate <arena name>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (am.getArenaWithName(arg1) != null)
|
if (am.getArenaWithName(arg1) != null)
|
||||||
@@ -1136,11 +1192,11 @@ public class MACommands implements CommandExecutor
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base.equals("auto-degenerate"))
|
if (base.equals("auto-degenerate") || base.equals("autodegenerate"))
|
||||||
{
|
{
|
||||||
if (!console && !(player && plugin.has(p, "mobarena.setup.autodegenerate")) && !op)
|
if (!console && !(player && plugin.has(p, "mobarena.setup.autodegenerate")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (arg1.isEmpty())
|
if (arg1.isEmpty())
|
||||||
@@ -1155,7 +1211,7 @@ public class MACommands implements CommandExecutor
|
|||||||
}
|
}
|
||||||
if (am.getArenaWithName(arg1) == null)
|
if (am.getArenaWithName(arg1) == null)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
MAUtils.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1170,7 +1226,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!(player && plugin.has(p, "mobarena.setup.autogenerate")) && !op)
|
if (!(player && plugin.has(p, "mobarena.setup.autogenerate")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1189,7 +1245,7 @@ public class MACommands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
if (!(player && plugin.has(p, "mobarena.setup.autodegenerate")) && !op)
|
if (!(player && plugin.has(p, "mobarena.setup.autodegenerate")) && !op)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.MISC_NO_ACCESS));
|
MAUtils.tellPlayer(sender, Msg.MISC_NO_ACCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (am.arenas.size() < 2)
|
if (am.arenas.size() < 2)
|
||||||
@@ -1199,7 +1255,7 @@ public class MACommands implements CommandExecutor
|
|||||||
}
|
}
|
||||||
if (am.getArenaWithName("a1") == null)
|
if (am.getArenaWithName("a1") == null)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(sender, MAMessages.get(Msg.ARENA_DOES_NOT_EXIST));
|
MAUtils.tellPlayer(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1218,4 +1274,18 @@ public class MACommands implements CommandExecutor
|
|||||||
MAUtils.tellPlayer(sender, "Command not found.");
|
MAUtils.tellPlayer(sender, "Command not found.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean sanityChecks(Player p, Arena arena, String arg1, List<Arena> arenas)
|
||||||
|
{
|
||||||
|
if (arenas.size() > 1 && arg1.isEmpty())
|
||||||
|
MAUtils.tellPlayer(p, Msg.JOIN_ARG_NEEDED);
|
||||||
|
else if (arena == null)
|
||||||
|
MAUtils.tellPlayer(p, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
|
else if (am.arenaMap.containsKey(p) && (am.arenaMap.get(p).arenaPlayers.contains(p) || am.arenaMap.get(p).lobbyPlayers.contains(p)))
|
||||||
|
MAUtils.tellPlayer(p, Msg.JOIN_IN_OTHER_ARENA);
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.garbagemule.MobArena;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
public class MAInventoryItem implements Serializable
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 739709220350581510L;
|
|
||||||
private int typeId;
|
|
||||||
private int amount;
|
|
||||||
private short durability;
|
|
||||||
|
|
||||||
public MAInventoryItem(int typeId, int amount, short durability)
|
|
||||||
{
|
|
||||||
this.typeId = typeId;
|
|
||||||
this.amount = amount;
|
|
||||||
this.durability = durability;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTypeId() { return typeId; }
|
|
||||||
public int getAmount() { return amount; }
|
|
||||||
public short getDurability() { return durability; }
|
|
||||||
}
|
|
||||||
@@ -1,22 +1,27 @@
|
|||||||
package com.garbagemule.MobArena;
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.ContainerBlock;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
import org.bukkit.entity.Wolf;
|
import org.bukkit.entity.Wolf;
|
||||||
import org.bukkit.event.Event.Result;
|
import org.bukkit.event.Event.Result;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
|
import org.bukkit.event.block.BlockEvent;
|
||||||
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
@@ -27,6 +32,7 @@ import org.bukkit.event.entity.EntityTargetEvent;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||||
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||||
|
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
@@ -35,47 +41,88 @@ import org.bukkit.event.player.PlayerKickEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.material.Attachable;
|
||||||
|
import org.bukkit.material.Bed;
|
||||||
|
import org.bukkit.material.Door;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
import org.bukkit.material.Redstone;
|
||||||
|
|
||||||
import com.garbagemule.MobArena.MAMessages.Msg;
|
import com.garbagemule.MobArena.MAMessages.Msg;
|
||||||
|
import com.garbagemule.MobArena.repairable.*;
|
||||||
|
|
||||||
public class MAListener implements ArenaListener
|
public class MAListener implements ArenaListener
|
||||||
{
|
{
|
||||||
private MobArena plugin;
|
private MobArena plugin;
|
||||||
private Arena arena;
|
private Arena arena;
|
||||||
|
|
||||||
public MAListener(Arena arena, MobArena plugin)
|
public MAListener(Arena arena, MobArena plugin)
|
||||||
{
|
{
|
||||||
this.arena = arena;
|
this.arena = arena;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
public void onBlockPhysics(BlockPhysicsEvent event)
|
||||||
{
|
{
|
||||||
if (!arena.inRegion(event.getBlock().getLocation()) || arena.edit || (!arena.protect && arena.running))
|
if (!arena.inRegion(event.getBlock().getLocation()) || arena.softRestore)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
MaterialData data = event.getBlock().getState().getData();
|
||||||
|
if (data instanceof Attachable || data instanceof Bed || data instanceof Door || data instanceof Redstone)
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
if (onBlockDestroy(event))
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onBlockBurn(BlockBurnEvent event)
|
||||||
|
{
|
||||||
|
if (onBlockDestroy(event))
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean onBlockDestroy(BlockEvent event)
|
||||||
|
{
|
||||||
|
if (!arena.inRegion(event.getBlock().getLocation()) || arena.edit || (!arena.protect && arena.running))
|
||||||
|
return true;
|
||||||
|
|
||||||
Block b = event.getBlock();
|
Block b = event.getBlock();
|
||||||
if (arena.blocks.remove(b) || b.getType() == Material.TNT)
|
if (arena.blocks.remove(b) || b.getType() == Material.TNT)
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
if (arena.softRestore && arena.running)
|
if (arena.softRestore && arena.running)
|
||||||
{
|
{
|
||||||
int[] buffer = new int[5];
|
BlockState state = b.getState();
|
||||||
buffer[0] = b.getX();
|
|
||||||
buffer[1] = b.getY();
|
Repairable r = null;
|
||||||
buffer[2] = b.getZ();
|
if (state instanceof ContainerBlock)
|
||||||
buffer[3] = b.getTypeId();
|
r = new RepairableContainer(state);
|
||||||
buffer[4] = (int) b.getData();
|
else if (state instanceof Sign)
|
||||||
arena.repairList.add(buffer);
|
r = new RepairableSign(state);
|
||||||
if (!arena.softRestoreDrops) event.getBlock().setTypeId(0);
|
else if (state.getData() instanceof Attachable)
|
||||||
return;
|
r = new RepairableAttachable(state);
|
||||||
|
else
|
||||||
|
r = new RepairableBlock(state);
|
||||||
|
|
||||||
|
arena.repairables.add(r);
|
||||||
|
|
||||||
|
if (!arena.softRestoreDrops)
|
||||||
|
b.setTypeId(0);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
if (!arena.inRegion(event.getBlock().getLocation()) || arena.edit)
|
if (!arena.inRegion(event.getBlock().getLocation()) || arena.edit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -87,114 +134,255 @@ public class MAListener implements ArenaListener
|
|||||||
|
|
||||||
if (mat == Material.WOODEN_DOOR || mat == Material.IRON_DOOR_BLOCK)
|
if (mat == Material.WOODEN_DOOR || mat == Material.IRON_DOOR_BLOCK)
|
||||||
arena.blocks.add(b.getRelative(0,1,0));
|
arena.blocks.add(b.getRelative(0,1,0));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the arena isn't running, or if the player isn't in the arena, cancel.
|
// If the arena isn't running, or if the player isn't in the arena, cancel.
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
public void onBlockIgnite(BlockIgniteEvent event)
|
||||||
{
|
{
|
||||||
if (!arena.inRegion(event.getLocation()) || event.getSpawnReason() == SpawnReason.CUSTOM)
|
if (!arena.inRegion(event.getBlock().getLocation()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If running == true, setCancelled(false), and vice versa.
|
switch (event.getCause())
|
||||||
event.setCancelled(!arena.running);
|
{
|
||||||
}
|
case LIGHTNING:
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
case SPREAD:
|
||||||
|
case FLINT_AND_STEEL:
|
||||||
|
if (arena.running)
|
||||||
|
arena.blocks.add(event.getBlock());
|
||||||
|
else
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onEntityExplode(EntityExplodeEvent event)
|
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||||
{
|
{
|
||||||
|
if (!arena.inRegion(event.getLocation())) // || event.getSpawnReason() == SpawnReason.CUSTOM)
|
||||||
|
return;
|
||||||
|
|
||||||
|
LivingEntity entity = (LivingEntity) event.getEntity();
|
||||||
|
if (arena.running && entity instanceof Slime)
|
||||||
|
arena.monsters.add(entity);
|
||||||
|
else
|
||||||
|
// If running == true, setCancelled(false), and vice versa.
|
||||||
|
event.setCancelled(!arena.running);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEntityExplode(EntityExplodeEvent event)
|
||||||
|
{
|
||||||
if (!arena.monsters.contains(event.getEntity()) && !arena.inRegionRadius(event.getLocation(), 10))
|
if (!arena.monsters.contains(event.getEntity()) && !arena.inRegionRadius(event.getLocation(), 10))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event.setYield(0);
|
event.setYield(0);
|
||||||
arena.monsters.remove(event.getEntity());
|
arena.monsters.remove(event.getEntity());
|
||||||
|
|
||||||
// If the arena isn't running
|
// Cancel if the arena isn't running or if the repair delay is 0
|
||||||
if (!arena.running || arena.repairDelay == 0)
|
if (!arena.running || arena.repairDelay == 0)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a sign in the blocklist, cancel
|
|
||||||
for (Block b : event.blockList())
|
|
||||||
{
|
|
||||||
if (!(b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Uncancel, just in case.
|
// Uncancel, just in case.
|
||||||
event.setCancelled(false);
|
event.setCancelled(false);
|
||||||
|
|
||||||
int[] buffer;
|
// Handle all the blocks in the block list.
|
||||||
final HashMap<Block,Integer> blockMap = new HashMap<Block,Integer>();
|
|
||||||
for (Block b : event.blockList())
|
for (Block b : event.blockList())
|
||||||
{
|
{
|
||||||
Material mat = b.getType();
|
BlockState state = b.getState();
|
||||||
|
|
||||||
if (mat == Material.LAVA) b.setType(Material.STATIONARY_LAVA);
|
if (state.getData() instanceof Door && ((Door) state.getData()).isTopHalf())
|
||||||
else if (mat == Material.WATER) b.setType(Material.STATIONARY_WATER);
|
state = b.getRelative(BlockFace.DOWN).getState();
|
||||||
|
else if (state.getData() instanceof Bed && ((Bed) state.getData()).isHeadOfBed())
|
||||||
|
state = b.getRelative(((Bed) state.getData()).getFacing().getOppositeFace()).getState();
|
||||||
|
|
||||||
if (mat == Material.WOODEN_DOOR || mat == Material.IRON_DOOR_BLOCK || mat == Material.FIRE || mat == Material.CAKE_BLOCK || mat == Material.WATER || mat == Material.LAVA)
|
// Create a Repairable from the block.
|
||||||
{
|
Repairable r = null;
|
||||||
arena.blocks.remove(b);
|
if (state instanceof ContainerBlock)
|
||||||
}
|
r = new RepairableContainer(state);
|
||||||
else if (arena.blocks.remove(b))
|
else if (state instanceof Sign)
|
||||||
{
|
r = new RepairableSign(state);
|
||||||
arena.world.dropItemNaturally(b.getLocation(), new ItemStack(b.getTypeId(), 1));
|
else if (state.getData() instanceof Bed)
|
||||||
}
|
r = new RepairableBed(state);
|
||||||
else if (arena.softRestore)
|
else if (state.getData() instanceof Door)
|
||||||
{
|
r = new RepairableDoor(state);
|
||||||
buffer = new int[5];
|
else if (state.getData() instanceof Attachable || state.getData() instanceof Redstone)
|
||||||
buffer[0] = b.getX();
|
r = new RepairableAttachable(state);
|
||||||
buffer[1] = b.getY();
|
|
||||||
buffer[2] = b.getZ();
|
|
||||||
buffer[3] = b.getTypeId();
|
|
||||||
buffer[4] = (int) b.getData();
|
|
||||||
arena.repairList.add(buffer);
|
|
||||||
blockMap.put(b, b.getTypeId() + (b.getData() * 1000));
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
r = new RepairableBlock(state);
|
||||||
blockMap.put(b, b.getTypeId() + (b.getData() * 1000));
|
|
||||||
}
|
// Cakes and liquids should just get removed. If player-placed block, drop as item.
|
||||||
|
Material mat = state.getType();
|
||||||
|
if (mat == Material.CAKE_BLOCK || mat == Material.WATER || mat == Material.LAVA)
|
||||||
|
arena.blocks.remove(b);
|
||||||
|
else if (arena.blocks.remove(b))
|
||||||
|
arena.world.dropItemNaturally(b.getLocation(), new ItemStack(state.getTypeId(), 1));
|
||||||
|
else if (arena.softRestore)
|
||||||
|
arena.repairables.add(r);
|
||||||
|
else
|
||||||
|
arena.queueRepairable(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the arena isn't protected, or soft-restore is on, return.
|
||||||
if (!arena.protect || arena.softRestore)
|
if (!arena.protect || arena.softRestore)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Otherwise, schedule repairs!
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
||||||
new Runnable()
|
new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
for (Map.Entry<Block,Integer> entry : blockMap.entrySet())
|
arena.repairBlocks();
|
||||||
{
|
|
||||||
Block b = entry.getKey();
|
|
||||||
int type = entry.getValue();
|
|
||||||
|
|
||||||
b.getLocation().getBlock().setTypeId(type % 1000);
|
|
||||||
|
|
||||||
if (type > 1000)
|
|
||||||
b.getLocation().getBlock().setData((byte) (type / 1000));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, arena.repairDelay);
|
}, arena.repairDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEntityCombust(EntityCombustEvent event)
|
public void onEntityDeath(EntityDeathEvent event)
|
||||||
{
|
{
|
||||||
|
if (event.getEntity() instanceof Player)
|
||||||
|
{
|
||||||
|
Player p = (Player) event.getEntity();
|
||||||
|
|
||||||
|
if (!arena.arenaPlayers.contains(p))
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.getDrops().clear();
|
||||||
|
arena.playerDeath(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arena.monsters.remove(event.getEntity()))
|
||||||
|
{
|
||||||
|
EntityDamageEvent e1 = event.getEntity().getLastDamageCause();
|
||||||
|
EntityDamageByEntityEvent e2 = (e1 instanceof EntityDamageByEntityEvent) ? (EntityDamageByEntityEvent) e1 : null;
|
||||||
|
Entity damager = (e2 != null) ? e2.getDamager() : null;
|
||||||
|
|
||||||
|
if (damager instanceof Player)
|
||||||
|
arena.playerKill((Player) damager);
|
||||||
|
|
||||||
|
event.getDrops().clear();
|
||||||
|
arena.resetIdleTimer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEntityDamage(EntityDamageEvent event)
|
||||||
|
{
|
||||||
|
if (!arena.running) return;
|
||||||
|
|
||||||
|
EntityDamageByEntityEvent e = (event instanceof EntityDamageByEntityEvent) ? (EntityDamageByEntityEvent) event : null;
|
||||||
|
Entity damager = (e != null) ? e.getDamager() : null;
|
||||||
|
Entity damagee = event.getEntity();
|
||||||
|
|
||||||
|
// Pet wolf
|
||||||
|
if (damagee instanceof Wolf && arena.pets.contains(damagee))
|
||||||
|
{
|
||||||
|
if (damager == null)
|
||||||
|
{
|
||||||
|
damagee.setFireTicks(32768);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (damager instanceof Player)
|
||||||
|
event.setCancelled(true);
|
||||||
|
else
|
||||||
|
event.setDamage(0);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Arena player
|
||||||
|
else if (damagee instanceof Player)
|
||||||
|
{
|
||||||
|
if (arena.lobbyPlayers.contains(damagee))
|
||||||
|
event.setCancelled(true);
|
||||||
|
else if (!arena.arenaPlayers.contains(damagee))
|
||||||
|
return;
|
||||||
|
else if (!arena.detDamage && event.getCause() == DamageCause.BLOCK_EXPLOSION)
|
||||||
|
event.setCancelled(true);
|
||||||
|
else if (damager instanceof Player && !arena.pvp)
|
||||||
|
{
|
||||||
|
// if 'inLobby' fails, and 'not inArena' fails, 'inArena' is true
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!event.isCancelled())
|
||||||
|
arena.log.players.get((Player) damagee).dmgTaken += event.getDamage();
|
||||||
|
}
|
||||||
|
// Other LivingEntity
|
||||||
|
else if (arena.monsters.contains(damagee))
|
||||||
|
{
|
||||||
|
if (damager instanceof Player)
|
||||||
|
{
|
||||||
|
if (!arena.arenaPlayers.contains(damager))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
arena.log.players.get((Player) damager).dmgDone += event.getDamage();
|
||||||
|
arena.log.players.get((Player) damager).hits++;
|
||||||
|
}
|
||||||
|
else if (damager instanceof Wolf && arena.pets.contains(damager))
|
||||||
|
{
|
||||||
|
event.setDamage(1);
|
||||||
|
arena.log.players.get((Player) ((Wolf) damager).getOwner()).dmgDone += event.getDamage();
|
||||||
|
}
|
||||||
|
else if (damager instanceof LivingEntity)
|
||||||
|
{
|
||||||
|
if (!arena.monsterInfight)
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Boss
|
||||||
|
if (arena.bossWave != null && damagee.equals(arena.bossWave.getEntity()))
|
||||||
|
{
|
||||||
|
if (event.getCause() == DamageCause.LIGHTNING)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subtract boss health, and reset actual entity health
|
||||||
|
arena.bossWave.subtractHealth(event.getDamage());
|
||||||
|
arena.bossWave.getEntity().setHealth(200);
|
||||||
|
|
||||||
|
// Set damage to 1 for knockback and feedback
|
||||||
|
event.setDamage(1);
|
||||||
|
|
||||||
|
// If the boss is dead, remove the entity and create an explosion!
|
||||||
|
if (arena.bossWave.getHealth() <= 0)
|
||||||
|
{
|
||||||
|
arena.bossWave.clear();
|
||||||
|
arena.bossWave = null;
|
||||||
|
}
|
||||||
|
else if (arena.bossWave.getHealth() <= 100 && !arena.bossWave.isLowHealthAnnounced())
|
||||||
|
{
|
||||||
|
MAUtils.tellAll(arena, Msg.WAVE_BOSS_LOW_HEALTH);
|
||||||
|
arena.bossWave.setLowHealthAnnounced(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEntityCombust(EntityCombustEvent event)
|
||||||
|
{
|
||||||
if (arena.monsters.contains(event.getEntity()))
|
if (arena.monsters.contains(event.getEntity()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEntityTarget(EntityTargetEvent event)
|
public void onEntityTarget(EntityTargetEvent event)
|
||||||
{
|
{
|
||||||
if (!arena.running || event.isCancelled())
|
if (!arena.running || event.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -208,32 +396,28 @@ public class MAListener implements ArenaListener
|
|||||||
|
|
||||||
// If the target is a player, cancel.
|
// If the target is a player, cancel.
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.monsters.contains(event.getEntity()))
|
else if (arena.monsters.contains(event.getEntity()))
|
||||||
{
|
{
|
||||||
if (event.getReason() == TargetReason.FORGOT_TARGET)
|
if (event.getReason() == TargetReason.FORGOT_TARGET)
|
||||||
{
|
|
||||||
event.setTarget(MAUtils.getClosestPlayer(event.getEntity(), arena));
|
event.setTarget(MAUtils.getClosestPlayer(event.getEntity(), arena));
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getReason() == TargetReason.TARGET_DIED)
|
else if (event.getReason() == TargetReason.TARGET_DIED)
|
||||||
{
|
|
||||||
event.setTarget(MAUtils.getClosestPlayer(event.getEntity(), arena));
|
event.setTarget(MAUtils.getClosestPlayer(event.getEntity(), arena));
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getReason() == TargetReason.CLOSEST_PLAYER)
|
else if (event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY)
|
||||||
|
if (arena.pets.contains(event.getTarget()))
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
else if (event.getReason() == TargetReason.CLOSEST_PLAYER)
|
||||||
if (!arena.arenaPlayers.contains(event.getTarget()))
|
if (!arena.arenaPlayers.contains(event.getTarget()))
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
||||||
{
|
{
|
||||||
if (!arena.running) return;
|
if (!arena.running) return;
|
||||||
|
|
||||||
if (!(event.getEntity() instanceof Player) || !arena.arenaPlayers.contains((Player)event.getEntity()))
|
if (!(event.getEntity() instanceof Player) || !arena.arenaPlayers.contains((Player)event.getEntity()))
|
||||||
@@ -241,129 +425,70 @@ public class MAListener implements ArenaListener
|
|||||||
|
|
||||||
if (event.getRegainReason() == RegainReason.REGEN)
|
if (event.getRegainReason() == RegainReason.REGEN)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEntityDeath(EntityDeathEvent event)
|
public void onPlayerAnimation(PlayerAnimationEvent event)
|
||||||
{
|
{
|
||||||
if (event.getEntity() instanceof Player)
|
if (!arena.running || !arena.arenaPlayers.contains(event.getPlayer()))
|
||||||
{
|
|
||||||
Player p = (Player) event.getEntity();
|
|
||||||
|
|
||||||
if (!arena.arenaPlayers.contains(p))
|
|
||||||
return;
|
|
||||||
|
|
||||||
event.getDrops().clear();
|
|
||||||
arena.waveMap.put(p, arena.spawnThread.wave - 1);
|
|
||||||
arena.playerDeath(p);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
arena.log.players.get(event.getPlayer()).swings++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||||
|
{
|
||||||
|
Player p = event.getPlayer();
|
||||||
|
|
||||||
|
// Player is in the lobby
|
||||||
|
if (arena.lobbyPlayers.contains(p))
|
||||||
|
{
|
||||||
|
MAUtils.tellPlayer(p, Msg.LOBBY_DROP_ITEM);
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.monsters.remove(event.getEntity()))
|
// Player is in the arena
|
||||||
|
else if (arena.arenaPlayers.contains(p))
|
||||||
{
|
{
|
||||||
EntityDamageEvent e1 = event.getEntity().getLastDamageCause();
|
if (!arena.shareInArena)
|
||||||
EntityDamageByEntityEvent e2 = (e1 instanceof EntityDamageByEntityEvent) ? (EntityDamageByEntityEvent) e1 : null;
|
|
||||||
Entity damager = (e2 != null) ? e2.getDamager() : null;
|
|
||||||
|
|
||||||
if (e2 != null && damager instanceof Player)
|
|
||||||
arena.playerKill((Player) damager);
|
|
||||||
|
|
||||||
event.getDrops().clear();
|
|
||||||
arena.resetIdleTimer();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onEntityDamage(EntityDamageEvent event)
|
|
||||||
{
|
|
||||||
if (!arena.running) return;
|
|
||||||
|
|
||||||
EntityDamageByEntityEvent e = (event instanceof EntityDamageByEntityEvent) ? (EntityDamageByEntityEvent) event : null;
|
|
||||||
Entity damager = (e != null) ? e.getDamager() : null;
|
|
||||||
Entity damagee = event.getEntity();
|
|
||||||
|
|
||||||
// Damagee - Pet Wolf - cancel all damage.
|
|
||||||
if (damagee instanceof Wolf && arena.pets.contains(damagee))
|
|
||||||
{
|
|
||||||
if (event.getCause() == DamageCause.FIRE_TICK)
|
|
||||||
{
|
{
|
||||||
damagee.setFireTicks(32768); // For mcMMO
|
MAUtils.tellPlayer(p, Msg.LOBBY_DROP_ITEM);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
if (e != null && damager instanceof Player)
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
event.setDamage(0);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Player died/left
|
||||||
|
else if (p.getLocation().equals(arena.spectatorLoc) || p.getLocation().equals(arena.locations.get(p)))
|
||||||
|
{
|
||||||
|
MobArena.warning("Player '" + p.getName() + "' tried to steal item " + event.getItemDrop().getItemStack().getType());
|
||||||
|
event.getItemDrop().remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player is in the spectator area
|
||||||
|
else if (arena.specPlayers.contains(p))
|
||||||
|
{
|
||||||
|
MAUtils.tellPlayer(p, Msg.LOBBY_DROP_ITEM);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Damager - Pet Wolf - lower damage
|
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event)
|
||||||
if (e != null && damager instanceof Wolf && arena.pets.contains(damager))
|
{
|
||||||
{
|
|
||||||
event.setDamage(1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Damagee & Damager - Player - cancel if pvp disabled
|
|
||||||
if (damagee instanceof Player && damager instanceof Player)
|
|
||||||
{
|
|
||||||
if (arena.arenaPlayers.contains(damagee) && !arena.pvp)
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Damagee & Damager - Monsters - cancel if no monsterInfight
|
|
||||||
if (e != null && arena.monsters.contains(damagee) && arena.monsters.contains(damager))
|
|
||||||
{
|
|
||||||
if (!arena.monsterInfight)
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creeper detonations
|
|
||||||
if (arena.inRegion(damagee.getLocation()))
|
|
||||||
{
|
|
||||||
if (!arena.detDamage || !(damagee instanceof Player) || !arena.arenaPlayers.contains((Player) damagee))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (event.getCause() == DamageCause.BLOCK_EXPLOSION)
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
|
||||||
{
|
|
||||||
if (arena.running && arena.shareInArena) return;
|
|
||||||
|
|
||||||
Player p = event.getPlayer();
|
|
||||||
if (!arena.arenaPlayers.contains(p) && !arena.lobbyPlayers.contains(p))
|
|
||||||
return;
|
|
||||||
|
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_DROP_ITEM));
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event)
|
|
||||||
{
|
|
||||||
if (!arena.readyPlayers.contains(event.getPlayer()) && !arena.arenaPlayers.contains(event.getPlayer()))
|
if (!arena.readyPlayers.contains(event.getPlayer()) && !arena.arenaPlayers.contains(event.getPlayer()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!arena.running)
|
if (!arena.running)
|
||||||
{
|
{
|
||||||
event.getBlockClicked().getRelative(event.getBlockFace()).setTypeId(0);
|
event.getBlockClicked().getRelative(event.getBlockFace()).setTypeId(0);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block liquid = event.getBlockClicked().getRelative(event.getBlockFace());
|
Block liquid = event.getBlockClicked().getRelative(event.getBlockFace());
|
||||||
arena.blocks.add(liquid);
|
arena.blocks.add(liquid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (!arena.arenaPlayers.contains(event.getPlayer()) && !arena.lobbyPlayers.contains(event.getPlayer()))
|
if (!arena.arenaPlayers.contains(event.getPlayer()) && !arena.lobbyPlayers.contains(event.getPlayer()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -387,12 +512,12 @@ public class MAListener implements ArenaListener
|
|||||||
{
|
{
|
||||||
if (arena.classMap.containsKey(p))
|
if (arena.classMap.containsKey(p))
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_PLAYER_READY));
|
MAUtils.tellPlayer(p, Msg.LOBBY_PLAYER_READY);
|
||||||
arena.playerReady(p);
|
arena.playerReady(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_PICK_CLASS));
|
MAUtils.tellPlayer(p, Msg.LOBBY_PICK_CLASS);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -402,7 +527,7 @@ public class MAListener implements ArenaListener
|
|||||||
{
|
{
|
||||||
if (a == Action.RIGHT_CLICK_BLOCK)
|
if (a == Action.RIGHT_CLICK_BLOCK)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_RIGHT_CLICK));
|
MAUtils.tellPlayer(p, Msg.LOBBY_RIGHT_CLICK);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,46 +539,44 @@ public class MAListener implements ArenaListener
|
|||||||
if (!arena.classes.contains(className) && !className.equalsIgnoreCase("random"))
|
if (!arena.classes.contains(className) && !className.equalsIgnoreCase("random"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!plugin.hasDefTrue(p, "mobarena.classes." + className) && !className.equalsIgnoreCase("random"))
|
if (!plugin.has(p, "mobarena.classes." + className) && !className.equalsIgnoreCase("random"))
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_CLASS_PERMISSION));
|
MAUtils.tellPlayer(p, Msg.LOBBY_CLASS_PERMISSION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the player's class.
|
// Set the player's class.
|
||||||
arena.assignClass(p, className);
|
arena.assignClass(p, className);
|
||||||
if (!className.equalsIgnoreCase("random"))
|
if (!className.equalsIgnoreCase("random"))
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_CLASS_PICKED, className));
|
MAUtils.tellPlayer(p, Msg.LOBBY_CLASS_PICKED, className, arena.classItems.get(className).get(0).getType());
|
||||||
else
|
else
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.LOBBY_CLASS_RANDOM));
|
MAUtils.tellPlayer(p, Msg.LOBBY_CLASS_RANDOM);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
public void onPlayerQuit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
if (!arena.enabled || (!arena.arenaPlayers.contains(p) && !arena.lobbyPlayers.contains(p)))
|
if (!arena.enabled || (!arena.arenaPlayers.contains(p) && !arena.lobbyPlayers.contains(p)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
plugin.getAM().arenaMap.remove(p);
|
|
||||||
arena.playerLeave(p);
|
arena.playerLeave(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerKick(PlayerKickEvent event)
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
{
|
{
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
if (!arena.enabled || (!arena.arenaPlayers.contains(p) && !arena.lobbyPlayers.contains(p)))
|
if (!arena.enabled || (!arena.arenaPlayers.contains(p) && !arena.lobbyPlayers.contains(p)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
plugin.getAM().arenaMap.remove(p);
|
|
||||||
arena.playerLeave(p);
|
arena.playerLeave(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||||
{
|
{
|
||||||
if (arena.edit || !arena.enabled || !arena.setup || arena.allowWarp)
|
if (!arena.running || arena.edit || !arena.enabled || !arena.setup || arena.allowWarp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!arena.inRegion(event.getTo()) && !arena.inRegion(event.getFrom()))
|
if (!arena.inRegion(event.getTo()) && !arena.inRegion(event.getFrom()))
|
||||||
@@ -468,10 +591,10 @@ public class MAListener implements ArenaListener
|
|||||||
{
|
{
|
||||||
if (arena.inRegion(from))
|
if (arena.inRegion(from))
|
||||||
{
|
{
|
||||||
if (to.equals(arena.arenaLoc) || to.equals(arena.lobbyLoc) || to.equals(arena.spectatorLoc) || to.equals(old))
|
if (arena.inRegion(to) || to.equals(arena.arenaLoc) || to.equals(arena.lobbyLoc) || to.equals(arena.spectatorLoc) || to.equals(old))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.WARP_FROM_ARENA));
|
MAUtils.tellPlayer(p, Msg.WARP_FROM_ARENA);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -481,7 +604,7 @@ public class MAListener implements ArenaListener
|
|||||||
if (to.equals(arena.arenaLoc) || to.equals(arena.lobbyLoc) || to.equals(arena.spectatorLoc) || to.equals(old))
|
if (to.equals(arena.arenaLoc) || to.equals(arena.lobbyLoc) || to.equals(arena.spectatorLoc) || to.equals(old))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.WARP_TO_ARENA));
|
MAUtils.tellPlayer(p, Msg.WARP_TO_ARENA);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -494,10 +617,10 @@ public class MAListener implements ArenaListener
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
{
|
{
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
|
|
||||||
if (!arena.arenaPlayers.contains(p) && !arena.lobbyPlayers.contains(p))
|
if (!arena.arenaPlayers.contains(p) && !arena.lobbyPlayers.contains(p))
|
||||||
@@ -511,6 +634,6 @@ public class MAListener implements ArenaListener
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.MISC_COMMAND_NOT_ALLOWED));
|
MAUtils.tellPlayer(p, Msg.MISC_COMMAND_NOT_ALLOWED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,164 +6,192 @@ import java.io.File;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
public class MAMessages
|
public class MAMessages
|
||||||
{
|
{
|
||||||
protected static Map<Msg,String> msgMap;
|
public static enum Msg
|
||||||
private static Map<Msg,String> defaults = new HashMap<Msg,String>();
|
|
||||||
protected static enum Msg
|
|
||||||
{
|
{
|
||||||
ARENA_START,
|
ARENA_START("Let the slaughter begin!", "Arena started!", Material.REDSTONE_TORCH_ON),
|
||||||
ARENA_END,
|
ARENA_END("Arena finished.", "Arena finished.", Material.REDSTONE_TORCH_OFF),
|
||||||
ARENA_DOES_NOT_EXIST,
|
ARENA_DOES_NOT_EXIST("That arena does not exist. Type /ma arenas for a list.", "Can't find arena."),
|
||||||
JOIN_PLAYER_JOINED,
|
JOIN_NOT_ENABLED("MobArena is not enabled.", "MobArena disabled.", Material.REDSTONE_TORCH_OFF),
|
||||||
JOIN_NOT_ENABLED,
|
JOIN_IN_OTHER_ARENA("You are already in an arena! Leave that one first.", "In another arena."),
|
||||||
JOIN_IN_OTHER_ARENA,
|
JOIN_ARENA_NOT_ENABLED("This arena is not enabled.", "Arena disabled.", Material.REDSTONE_TORCH_OFF),
|
||||||
JOIN_ARENA_NOT_ENABLED,
|
JOIN_ARENA_NOT_SETUP("This arena has not been set up yet.", "Arena not set up.", Material.REDSTONE_TORCH_OFF),
|
||||||
JOIN_ARENA_NOT_SETUP,
|
JOIN_ARENA_EDIT_MODE("This arena is in edit mode.", "Arena in edit mode.", Material.IRON_SPADE),
|
||||||
JOIN_ARENA_PERMISSION,
|
JOIN_ARENA_PERMISSION("You don't have permission to join this arena.", "No permission!", Material.FENCE),
|
||||||
JOIN_FEE_REQUIRED,
|
JOIN_FEE_REQUIRED("Insufficient funds. Price: %", "Price: %", Material.DIAMOND),
|
||||||
JOIN_FEE_PAID,
|
JOIN_FEE_PAID("Price to join was: %", "Paid: %", Material.DIAMOND),
|
||||||
JOIN_ARENA_IS_RUNNING,
|
JOIN_ARENA_IS_RUNNING("This arena is in already progress.", "Already running!", Material.GOLD_RECORD),
|
||||||
JOIN_ALREADY_PLAYING,
|
JOIN_ALREADY_PLAYING("You are already playing!", "Already playing!", Material.GOLD_RECORD),
|
||||||
JOIN_ARG_NEEDED,
|
JOIN_ARG_NEEDED("You must specify an arena. Type /ma arenas for a list."),
|
||||||
JOIN_TOO_FAR,
|
JOIN_TOO_FAR("You are too far away from the arena to join/spectate.", "Too far from arena.", Material.COMPASS),
|
||||||
JOIN_EMPTY_INV,
|
JOIN_EMPTY_INV("You must empty your inventory to join the arena.", "Empty your inventory.", Material.CHEST),
|
||||||
JOIN_PLAYER_LIMIT_REACHED,
|
JOIN_PLAYER_LIMIT_REACHED("The player limit of this arena has been reached.", "No spots left.", Material.MILK_BUCKET),
|
||||||
JOIN_STORE_INV_FAIL,
|
JOIN_STORE_INV_FAIL("Failed to store inventory. Try again."),
|
||||||
LEAVE_PLAYER_LEFT,
|
JOIN_EXISTING_INV_RESTORED("Your old inventory items have been restored."),
|
||||||
LEAVE_NOT_PLAYING,
|
JOIN_PLAYER_JOINED("You joined the arena. Have fun!", "Joined arena.", Material.IRON_SWORD),
|
||||||
PLAYER_DIED,
|
LEAVE_NOT_PLAYING("You are not in the arena.", "Not in arena."),
|
||||||
SPEC_PLAYER_SPECTATE,
|
LEAVE_PLAYER_LEFT("You left the arena. Thanks for playing!", "Left arena.", Material.WOOD_DOOR),
|
||||||
SPEC_NOT_RUNNING,
|
PLAYER_DIED("% died!", "% died!", Material.BONE),
|
||||||
SPEC_ARG_NEEDED,
|
SPEC_PLAYER_SPECTATE("Enjoy the show!", "Enjoy the show!"),
|
||||||
SPEC_EMPTY_INV,
|
SPEC_NOT_RUNNING("This arena isn't running.", "Arena not running.", Material.REDSTONE_TORCH_OFF),
|
||||||
SPEC_ALREADY_PLAYING,
|
SPEC_ARG_NEEDED("You must specify an arena. Type /ma arenas for a list.", "Arena name required."),
|
||||||
NOT_READY_PLAYERS,
|
SPEC_EMPTY_INV("Empty your inventory first!", "Empty your inventory.", Material.CHEST),
|
||||||
FORCE_START_STARTED,
|
SPEC_ALREADY_PLAYING("Can't spectate when in the arena!", "Already playing!"),
|
||||||
FORCE_START_RUNNING,
|
NOT_READY_PLAYERS("Not ready: %"),
|
||||||
FORCE_START_NOT_READY,
|
FORCE_START_RUNNING("Arena has already started."),
|
||||||
FORCE_END_ENDED,
|
FORCE_START_NOT_READY("Can't force start, no players are ready."),
|
||||||
FORCE_END_EMPTY,
|
FORCE_START_STARTED("Forced arena start."),
|
||||||
FORCE_END_IDLE,
|
FORCE_END_EMPTY("No one is in the arena."),
|
||||||
REWARDS_GIVE,
|
FORCE_END_ENDED("Forced arena end."),
|
||||||
LOBBY_CLASS_PICKED,
|
FORCE_END_IDLE("You weren't quick enough!"),
|
||||||
LOBBY_CLASS_RANDOM,
|
REWARDS_GIVE("Here are all of your rewards!"),
|
||||||
LOBBY_CLASS_PERMISSION,
|
LOBBY_DROP_ITEM("No sharing allowed at this time!", "Can't drop items here."),
|
||||||
LOBBY_NOT_ENOUGH_PLAYERS,
|
LOBBY_PLAYER_READY("You have been flagged as ready!", "Flagged as ready!"),
|
||||||
LOBBY_PLAYER_READY,
|
LOBBY_PICK_CLASS("You must first pick a class!", "Pick a class first!"),
|
||||||
LOBBY_DROP_ITEM,
|
LOBBY_NOT_ENOUGH_PLAYERS("Not enough players to start. Need at least % players.", "Need more players."),
|
||||||
LOBBY_PICK_CLASS,
|
LOBBY_RIGHT_CLICK("Punch the sign. Don't right-click.", "Punch the sign."),
|
||||||
LOBBY_RIGHT_CLICK,
|
LOBBY_CLASS_PICKED("You have chosen % as your class!", "%"),
|
||||||
WARP_TO_ARENA,
|
LOBBY_CLASS_RANDOM("You will get a random class on arena start."),
|
||||||
WARP_FROM_ARENA,
|
LOBBY_CLASS_PERMISSION("You don't have permission to use this class!", "No permission!", Material.FENCE),
|
||||||
WAVE_DEFAULT,
|
WARP_TO_ARENA("Can't warp to the arena during battle!"),
|
||||||
WAVE_SPECIAL,
|
WARP_FROM_ARENA("Warping not allowed in the arena!"),
|
||||||
WAVE_REWARD,
|
WAVE_DEFAULT("Wave #%!", "Wave #%!", Material.YELLOW_FLOWER),
|
||||||
MISC_LIST_ARENAS,
|
WAVE_SPECIAL("Wave #%! [SPECIAL]", "Wave #%! [SPECIAL]", Material.RED_ROSE),
|
||||||
MISC_LIST_PLAYERS,
|
WAVE_SWARM("Wave #%! [SWARM]", "Wave #%! [SWARM]", Material.LONG_GRASS),
|
||||||
MISC_COMMAND_NOT_ALLOWED,
|
WAVE_BOSS("Wave #%! [BOSS]", "Wave #%! [BOSS]", Material.FIRE),
|
||||||
MISC_NO_ACCESS,
|
WAVE_BOSS_ABILITY("Boss used ability: %!", "Boss: %", Material.FIRE),
|
||||||
MISC_NONE
|
WAVE_BOSS_LOW_HEALTH("Boss is almost dead!", "Boss almost dead!", Material.FIRE),
|
||||||
|
WAVE_REWARD("You just earned a reward: %", "Reward: %"),
|
||||||
|
MISC_LIST_PLAYERS("Live players: %"),
|
||||||
|
MISC_LIST_ARENAS("Available arenas: %"),
|
||||||
|
MISC_COMMAND_NOT_ALLOWED("You can't use that command in the arena!"),
|
||||||
|
MISC_NO_ACCESS("You don't have access to this command."),
|
||||||
|
MISC_NONE("<none>");
|
||||||
|
|
||||||
|
private String msg, spoutMsg;
|
||||||
|
private Material logo;
|
||||||
|
|
||||||
|
private Msg(String msg)
|
||||||
|
{
|
||||||
|
this(msg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Msg(String msg, String spoutMsg)
|
||||||
|
{
|
||||||
|
this(msg, spoutMsg, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Msg(String msg, String spoutMsg, Material logo)
|
||||||
|
{
|
||||||
|
this.msg = msg;
|
||||||
|
this.spoutMsg = spoutMsg;
|
||||||
|
this.logo = logo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get()
|
||||||
|
{
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get(String s)
|
||||||
|
{
|
||||||
|
return (s != null) ? msg.replace("%", s) : msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSpout(String s)
|
||||||
|
{
|
||||||
|
if (spoutMsg == null)
|
||||||
|
return get(s);
|
||||||
|
|
||||||
|
return (s != null) ? spoutMsg.replace("%", s) : spoutMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(String msg)
|
||||||
|
{
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpout(String spoutMsg)
|
||||||
|
{
|
||||||
|
this.spoutMsg = spoutMsg;
|
||||||
|
|
||||||
|
if (spoutMsg == null)
|
||||||
|
logo = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasSpoutMsg()
|
||||||
|
{
|
||||||
|
return spoutMsg != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getLogo()
|
||||||
|
{
|
||||||
|
return logo == null ? Material.SLIME_BALL : logo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String get(Msg m)
|
||||||
|
{
|
||||||
|
return m.msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String get(Msg m, String s)
|
||||||
|
{
|
||||||
|
return m.msg.replace("%", s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void set(Msg m, String msg)
|
||||||
|
{
|
||||||
|
m.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate the defaults map.
|
|
||||||
static
|
|
||||||
{
|
|
||||||
defaults.put(Msg.ARENA_START, "Let the slaughter begin!");
|
|
||||||
defaults.put(Msg.ARENA_END, "Arena finished.");
|
|
||||||
defaults.put(Msg.ARENA_DOES_NOT_EXIST, "That arena does not exist. Type /ma arenas for a list.");
|
|
||||||
defaults.put(Msg.JOIN_NOT_ENABLED, "MobArena is not enabled.");
|
|
||||||
defaults.put(Msg.JOIN_IN_OTHER_ARENA, "You are already in an arena! Leave that one first.");
|
|
||||||
defaults.put(Msg.JOIN_ARENA_NOT_ENABLED, "This arena is not enabled.");
|
|
||||||
defaults.put(Msg.JOIN_ARENA_NOT_SETUP, "This arena has not been set up yet.");
|
|
||||||
defaults.put(Msg.JOIN_ARENA_PERMISSION, "You don't have permission to join this arena.");
|
|
||||||
defaults.put(Msg.JOIN_FEE_REQUIRED, "Insufficient funds. Price: %");
|
|
||||||
defaults.put(Msg.JOIN_FEE_PAID, "Price to join was: %");
|
|
||||||
defaults.put(Msg.JOIN_ARENA_IS_RUNNING, "This arena is in already progress.");
|
|
||||||
defaults.put(Msg.JOIN_ALREADY_PLAYING, "You are already playing!");
|
|
||||||
defaults.put(Msg.JOIN_ARG_NEEDED, "You must specify an arena. Type /ma arenas for a list.");
|
|
||||||
defaults.put(Msg.JOIN_TOO_FAR, "You are too far away from the arena to join/spectate.");
|
|
||||||
defaults.put(Msg.JOIN_EMPTY_INV, "You must empty your inventory to join the arena.");
|
|
||||||
defaults.put(Msg.JOIN_PLAYER_LIMIT_REACHED, "The player limit of this arena has been reached.");
|
|
||||||
defaults.put(Msg.JOIN_STORE_INV_FAIL, "Failed to store inventory. Try again.");
|
|
||||||
defaults.put(Msg.JOIN_PLAYER_JOINED, "You joined the arena. Have fun!");
|
|
||||||
defaults.put(Msg.LEAVE_NOT_PLAYING, "You are not in the arena.");
|
|
||||||
defaults.put(Msg.LEAVE_PLAYER_LEFT, "You left the arena. Thanks for playing!");
|
|
||||||
defaults.put(Msg.PLAYER_DIED, "% died!");
|
|
||||||
defaults.put(Msg.SPEC_PLAYER_SPECTATE, "Enjoy the show!");
|
|
||||||
defaults.put(Msg.SPEC_NOT_RUNNING, "This arena isn't running.");
|
|
||||||
defaults.put(Msg.SPEC_ARG_NEEDED, "You must specify an arena. Type /ma arenas for a list.");
|
|
||||||
defaults.put(Msg.SPEC_EMPTY_INV, "Empty your inventory first!");
|
|
||||||
defaults.put(Msg.SPEC_ALREADY_PLAYING, "Can't spectate when in the arena!");
|
|
||||||
defaults.put(Msg.NOT_READY_PLAYERS, "Not ready: %");
|
|
||||||
defaults.put(Msg.FORCE_START_RUNNING, "Arena has already started.");
|
|
||||||
defaults.put(Msg.FORCE_START_NOT_READY, "Can't force start, no players are ready.");
|
|
||||||
defaults.put(Msg.FORCE_START_STARTED, "Forced arena start.");
|
|
||||||
defaults.put(Msg.FORCE_END_EMPTY, "No one is in the arena.");
|
|
||||||
defaults.put(Msg.FORCE_END_ENDED, "Forced arena end.");
|
|
||||||
defaults.put(Msg.FORCE_END_IDLE, "You weren't quick enough!");
|
|
||||||
defaults.put(Msg.REWARDS_GIVE, "Here are all of your rewards!");
|
|
||||||
defaults.put(Msg.LOBBY_DROP_ITEM, "No sharing allowed at this time!");
|
|
||||||
defaults.put(Msg.LOBBY_PLAYER_READY, "You have been flagged as ready!");
|
|
||||||
defaults.put(Msg.LOBBY_PICK_CLASS, "You must first pick a class!");
|
|
||||||
defaults.put(Msg.LOBBY_NOT_ENOUGH_PLAYERS, "Not enough players to start. Need at least % players.");
|
|
||||||
defaults.put(Msg.LOBBY_RIGHT_CLICK, "Punch the sign. Don't right-click.");
|
|
||||||
defaults.put(Msg.LOBBY_CLASS_PICKED, "You have chosen % as your class!");
|
|
||||||
defaults.put(Msg.LOBBY_CLASS_RANDOM, "You will get a random class on arena start.");
|
|
||||||
defaults.put(Msg.LOBBY_CLASS_PERMISSION, "You don't have permission to use this class!");
|
|
||||||
defaults.put(Msg.WARP_TO_ARENA, "Can't warp to the arena during battle!");
|
|
||||||
defaults.put(Msg.WARP_FROM_ARENA, "Warping not allowed in the arena!");
|
|
||||||
defaults.put(Msg.WAVE_DEFAULT, "Get ready for wave #%!");
|
|
||||||
defaults.put(Msg.WAVE_SPECIAL, "Get ready for wave #%! [SPECIAL]");
|
|
||||||
defaults.put(Msg.WAVE_REWARD, "You just earned a reward: %");
|
|
||||||
defaults.put(Msg.MISC_LIST_PLAYERS, "Live players: %");
|
|
||||||
defaults.put(Msg.MISC_LIST_ARENAS, "Available arenas: %");
|
|
||||||
defaults.put(Msg.MISC_COMMAND_NOT_ALLOWED, "You can't use that command in the arena!");
|
|
||||||
defaults.put(Msg.MISC_NO_ACCESS, "You don't have access to this command.");
|
|
||||||
defaults.put(Msg.MISC_NONE, "<none>");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the msgMap by reading from the announcements-file.
|
* Initializes the msgMap by reading from the announcements-file.
|
||||||
*/
|
*/
|
||||||
public static void init(MobArena plugin, boolean update)
|
public static void init(MobArena plugin)
|
||||||
{
|
{
|
||||||
// Use defaults in case of any errors.
|
|
||||||
msgMap = defaults;
|
|
||||||
|
|
||||||
// Grab the announcements-file.
|
// Grab the announcements-file.
|
||||||
File msgFile;
|
File msgFile = new File(MobArena.dir, "announcements.properties");
|
||||||
try
|
|
||||||
|
// If the file doesn't exist, create it and use defaults.
|
||||||
|
if (!msgFile.exists())
|
||||||
{
|
{
|
||||||
msgFile = new File(plugin.getDataFolder(), "announcements.properties");
|
try
|
||||||
|
|
||||||
// If it doesn't exist, create it.
|
|
||||||
if (!msgFile.exists())
|
|
||||||
{
|
{
|
||||||
System.out.println("[MobArena] Announcements-file not found. Creating one...");
|
|
||||||
msgFile.createNewFile();
|
msgFile.createNewFile();
|
||||||
|
|
||||||
BufferedWriter bw = new BufferedWriter(new FileWriter(msgFile));
|
BufferedWriter bw = new BufferedWriter(new FileWriter(msgFile));
|
||||||
|
|
||||||
for (Msg m : Msg.values())
|
for (Msg m : Msg.values())
|
||||||
{
|
{
|
||||||
bw.write(m.toString() + "=" + defaults.get(m));
|
if (m.hasSpoutMsg())
|
||||||
|
bw.write(m.name() + "=" + m.msg + "|" + m.spoutMsg);
|
||||||
|
else
|
||||||
|
bw.write(m.name() + "=" + m.msg);
|
||||||
|
|
||||||
bw.newLine();
|
bw.newLine();
|
||||||
}
|
}
|
||||||
bw.close();
|
|
||||||
|
|
||||||
|
bw.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
catch (Exception e)
|
{
|
||||||
{
|
MobArena.warning("Couldn't initialize announcements-file. Using defaults.");
|
||||||
System.out.println("[MobArena] ERROR! Couldn't initialize announcements-file. Using defaults.");
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the file was found, populate the msgMap.
|
// Otherwise, read the file's contents.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(msgFile), "UTF-8"));
|
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(msgFile), "UTF-8"));
|
||||||
@@ -181,65 +209,45 @@ public class MAMessages
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("[MobArena] ERROR! Problem with announcements-file. Using defaults.");
|
MobArena.warning("Problem with announcements-file. Using defaults.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(MobArena plugin)
|
|
||||||
{
|
|
||||||
init(plugin, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Grabs the announcement from the msgMap, and in case of
|
|
||||||
* s not being null, replaces the % with s.
|
|
||||||
*/
|
|
||||||
public static String get(Msg msg, String s)
|
|
||||||
{
|
|
||||||
// If p is null, just return the announcement as is.
|
|
||||||
if (s == null)
|
|
||||||
return msgMap.get(msg);
|
|
||||||
|
|
||||||
// Otherwise, replace the % with the input string.
|
|
||||||
return msgMap.get(msg).replace("%", s);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Grabs the announcement from the msgMap.
|
|
||||||
*/
|
|
||||||
public static String get(Msg msg)
|
|
||||||
{
|
|
||||||
return get(msg, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper-method for parsing the strings from the
|
* Helper-method for parsing the strings from the
|
||||||
* announcements-file.
|
* announcements-file.
|
||||||
*/
|
*/
|
||||||
private static void process(String s)
|
private static void process(String s)
|
||||||
{
|
{
|
||||||
|
// If the line ends with =, just add a space
|
||||||
|
if (s.endsWith("=") || s.endsWith("|")) s += " ";
|
||||||
|
|
||||||
// Split the string by the equals-sign.
|
// Split the string by the equals-sign.
|
||||||
String[] split = s.split("=");
|
String[] split = s.split("=");
|
||||||
if (split.length != 2)
|
if (split.length != 2)
|
||||||
{
|
{
|
||||||
System.out.println("[MobArena] ERROR! Couldn't parse \"" + s + "\". Check announcements-file.");
|
MobArena.warning("Couldn't parse \"" + s + "\". Check announcements-file.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Split the value by the pipe-sign.
|
||||||
|
String[] vals = split[1].split("\\|");
|
||||||
|
|
||||||
// For simplicity...
|
// For simplicity...
|
||||||
String key = split[0];
|
String key = split[0];
|
||||||
String val = split[1];
|
String val = vals.length == 2 ? vals[0] : split[1];
|
||||||
Msg msg;
|
String spoutVal = vals.length == 2 ? vals[1] : null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
msg = Msg.valueOf(key);
|
Msg msg = Msg.valueOf(key);
|
||||||
msgMap.put(msg, val);
|
msg.set(val);
|
||||||
|
msg.setSpout(spoutVal);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
System.out.println("[MobArena] ERROR! " + key + " is not a valid key. Check announcements-file.");
|
MobArena.warning(key + " is not a valid key. Check announcements-file.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.garbagemule.MobArena;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
@@ -12,6 +13,7 @@ import org.bukkit.event.player.PlayerListener;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
|
|
||||||
public class MAPlayerListener extends PlayerListener
|
public class MAPlayerListener extends PlayerListener
|
||||||
{
|
{
|
||||||
private MobArena plugin;
|
private MobArena plugin;
|
||||||
@@ -23,6 +25,13 @@ public class MAPlayerListener extends PlayerListener
|
|||||||
this.am = am;
|
this.am = am;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onPlayerAnimation(PlayerAnimationEvent event)
|
||||||
|
{
|
||||||
|
if (!am.enabled) return;
|
||||||
|
for (Arena arena : am.arenas)
|
||||||
|
arena.eventListener.onPlayerAnimation(event);
|
||||||
|
}
|
||||||
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (!am.enabled) return;
|
if (!am.enabled) return;
|
||||||
@@ -82,6 +91,6 @@ public class MAPlayerListener extends PlayerListener
|
|||||||
{
|
{
|
||||||
MAUtils.checkForUpdates(plugin, p, false);
|
MAUtils.checkForUpdates(plugin, p, false);
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 60);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,23 @@
|
|||||||
package com.garbagemule.MobArena;
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Wolf;
|
|
||||||
import org.bukkit.entity.Ghast;
|
|
||||||
import org.bukkit.entity.Slime;
|
|
||||||
import org.bukkit.entity.Creeper;
|
import org.bukkit.entity.Creeper;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.CreatureType;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.garbagemule.MobArena.MAMessages.Msg;
|
import com.garbagemule.MobArena.MAMessages.Msg;
|
||||||
|
import com.garbagemule.MobArena.util.WaveUtils;
|
||||||
|
import com.garbagemule.MobArena.waves.Wave;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core class for handling wave spawning.
|
* Core class for handling wave spawning.
|
||||||
@@ -30,100 +27,155 @@ import com.garbagemule.MobArena.MAMessages.Msg;
|
|||||||
* host chooses. It is possible to create default waves that consist of
|
* host chooses. It is possible to create default waves that consist of
|
||||||
* only one type of monster, or ones that have no creepers, for example.
|
* only one type of monster, or ones that have no creepers, for example.
|
||||||
*/
|
*/
|
||||||
// TODO: Allow custom special wave monsters.
|
|
||||||
// TODO: Allow additional "default" waves.
|
|
||||||
public class MASpawnThread implements Runnable
|
public class MASpawnThread implements Runnable
|
||||||
{
|
{
|
||||||
protected int wave, previousSize, taskId;
|
|
||||||
private int ran, noOfPlayers, modulo;
|
|
||||||
private int dZombies, dSkeletons, dSpiders, dCreepers, dWolves;
|
|
||||||
private int dPoweredCreepers, dPigZombies, dSlimes, dMonsters, dAngryWolves, dGiants, dGhasts;
|
|
||||||
private Random random;
|
|
||||||
private MobArena plugin;
|
private MobArena plugin;
|
||||||
private Arena arena;
|
private Arena arena;
|
||||||
|
private int wave, taskId, previousSize, playerCount;
|
||||||
|
|
||||||
|
// NEW WAVES
|
||||||
|
private Wave defaultWave;
|
||||||
|
private TreeSet<Wave> recurrentWaves;
|
||||||
|
private TreeSet<Wave> singleWaves;
|
||||||
|
|
||||||
public MASpawnThread(MobArena plugin, Arena arena)
|
public MASpawnThread(MobArena plugin, Arena arena)
|
||||||
{
|
{
|
||||||
this.plugin = plugin;
|
// WAVES
|
||||||
this.arena = arena;
|
defaultWave = arena.recurrentWaves.first();
|
||||||
modulo = arena.specialModulo;
|
recurrentWaves = arena.recurrentWaves;
|
||||||
if (modulo <= 0) modulo = -32768;
|
singleWaves = new TreeSet<Wave>(arena.singleWaves);
|
||||||
|
|
||||||
taskId = -32768;
|
this.plugin = plugin;
|
||||||
|
this.arena = arena;
|
||||||
noOfPlayers = arena.arenaPlayers.size();
|
wave = 1;
|
||||||
wave = 1;
|
playerCount = arena.arenaPlayers.size();
|
||||||
random = new Random();
|
|
||||||
|
|
||||||
// Set up the distribution variables for the random spawner.
|
|
||||||
// Note: Updating these means MAUtils.getArenaDistributions() must also be updated!
|
|
||||||
dZombies = arena.distDefault.get("zombies");
|
|
||||||
dSkeletons = dZombies + arena.distDefault.get("skeletons");
|
|
||||||
dSpiders = dSkeletons + arena.distDefault.get("spiders");
|
|
||||||
dCreepers = dSpiders + arena.distDefault.get("creepers");
|
|
||||||
dWolves = dCreepers + arena.distDefault.get("wolves");
|
|
||||||
if (dWolves < 1) { dZombies = 1; dSkeletons = 2; dSpiders = 3; dCreepers = 4; dWolves = 5; }
|
|
||||||
|
|
||||||
dPoweredCreepers = arena.distSpecial.get("powered-creepers");
|
|
||||||
dPigZombies = dPoweredCreepers + arena.distSpecial.get("zombie-pigmen");
|
|
||||||
dSlimes = dPigZombies + arena.distSpecial.get("slimes");
|
|
||||||
dMonsters = dSlimes + arena.distSpecial.get("humans");
|
|
||||||
dAngryWolves = dMonsters + arena.distSpecial.get("angry-wolves");
|
|
||||||
dGiants = dAngryWolves + arena.distSpecial.get("giants");
|
|
||||||
dGhasts = dGiants + arena.distSpecial.get("ghasts");
|
|
||||||
if (dGhasts < 1) { dPoweredCreepers = 1; dPigZombies = 2; dSlimes = 3; dMonsters = 4; dAngryWolves = 5; dGiants = 5; dGhasts = 5; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
// Clear out all dead monsters in the monster set.
|
||||||
|
removeDeadMonsters();
|
||||||
|
|
||||||
|
// If there are no players in the arena, return.
|
||||||
if (arena.arenaPlayers.isEmpty())
|
if (arena.arenaPlayers.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Check if wave needs to be cleared first. If so, return!
|
||||||
|
if (arena.waveClear && wave > 1 && !arena.monsters.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Check if we're on a boss wave
|
||||||
|
if (!arena.waveClear && arena.bossWave != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Grant rewards (if any) for this wave
|
||||||
|
grantRewards(wave);
|
||||||
|
|
||||||
|
// Detonate creepers if needed
|
||||||
|
detonateCreepers(arena.detCreepers);
|
||||||
|
|
||||||
|
// Find the wave to spawn
|
||||||
|
spawnWave(wave);
|
||||||
|
|
||||||
|
wave++;
|
||||||
|
if (arena.monsters.isEmpty())
|
||||||
|
arena.resetIdleTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeDeadMonsters()
|
||||||
|
{
|
||||||
List<Entity> tmp = new LinkedList<Entity>(arena.monsters);
|
List<Entity> tmp = new LinkedList<Entity>(arena.monsters);
|
||||||
for (Entity e : tmp)
|
for (Entity e : tmp)
|
||||||
if (e.isDead())
|
{
|
||||||
|
if (e.isDead() || !arena.inRegion(e.getLocation()))
|
||||||
|
{
|
||||||
arena.monsters.remove(e);
|
arena.monsters.remove(e);
|
||||||
|
e.remove();
|
||||||
// Check if wave needs to be cleared first. If so, return!
|
}
|
||||||
if (arena.waveClear && wave > 1)
|
|
||||||
{
|
|
||||||
if (!arena.monsters.isEmpty())
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Check if we need to grant more rewards with the recurrent waves.
|
|
||||||
|
private void grantRewards(int wave)
|
||||||
|
{
|
||||||
for (Map.Entry<Integer,List<ItemStack>> entry : arena.everyWaveMap.entrySet())
|
for (Map.Entry<Integer,List<ItemStack>> entry : arena.everyWaveMap.entrySet())
|
||||||
if (wave % entry.getKey() == 0)
|
if (wave % entry.getKey() == 0)
|
||||||
addReward(entry.getValue());
|
addReward(entry.getValue());
|
||||||
|
|
||||||
// Same deal, this time with the one-time waves.
|
|
||||||
if (arena.afterWaveMap.containsKey(wave))
|
if (arena.afterWaveMap.containsKey(wave))
|
||||||
addReward(arena.afterWaveMap.get(wave));
|
addReward(arena.afterWaveMap.get(wave));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void spawnWave(int wave)
|
||||||
|
{
|
||||||
|
Wave w = null;
|
||||||
|
|
||||||
// Check if this is a special wave.
|
// Check the first element of the single waves.
|
||||||
if (wave % modulo == 0)
|
if (!singleWaves.isEmpty() && singleWaves.first().matches(wave))
|
||||||
{
|
{
|
||||||
MAUtils.tellAll(arena, MAMessages.get(Msg.WAVE_SPECIAL, ""+wave));
|
w = singleWaves.pollFirst();
|
||||||
detonateCreepers(arena.detCreepers);
|
|
||||||
specialWave();
|
|
||||||
|
|
||||||
// Notify listeners.
|
|
||||||
for (MobArenaListener listener : plugin.getAM().listeners)
|
|
||||||
listener.onSpecialWave(wave, wave/modulo);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MAUtils.tellAll(arena, MAMessages.get(Msg.WAVE_DEFAULT, ""+wave));
|
SortedSet<Wave> matches = getMatchingRecurrentWaves(wave);
|
||||||
detonateCreepers(arena.detCreepers);
|
w = matches.isEmpty() ? defaultWave : matches.last();
|
||||||
defaultWave();
|
|
||||||
|
|
||||||
// Notify listeners.
|
|
||||||
for (MobArenaListener listener : plugin.getAM().listeners)
|
|
||||||
listener.onDefaultWave(wave);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notify listeners.
|
||||||
|
for (MobArenaListener listener : plugin.getAM().listeners)
|
||||||
|
listener.onWave(arena, wave, w.getName(), w.getBranch(), w.getType());
|
||||||
|
|
||||||
|
w.spawn(wave);
|
||||||
|
}
|
||||||
|
|
||||||
|
private SortedSet<Wave> getMatchingRecurrentWaves(int wave)
|
||||||
|
{
|
||||||
|
TreeSet<Wave> result = new TreeSet<Wave>(WaveUtils.getRecurrentComparator());
|
||||||
|
|
||||||
|
for (Wave w : recurrentWaves)
|
||||||
|
{
|
||||||
|
if (w.matches(wave))
|
||||||
|
result.add(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wave++;
|
|
||||||
if (arena.maxIdleTime > 0 && arena.monsters.isEmpty()) arena.resetIdleTimer();
|
/*////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Getters/setters
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
public int getWave()
|
||||||
|
{
|
||||||
|
return wave;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTaskId()
|
||||||
|
{
|
||||||
|
return taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPreviousSize()
|
||||||
|
{
|
||||||
|
return previousSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlayerCount()
|
||||||
|
{
|
||||||
|
return playerCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskId(int taskId)
|
||||||
|
{
|
||||||
|
this.taskId = taskId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreviousSize(int previousSize)
|
||||||
|
{
|
||||||
|
this.previousSize = previousSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,158 +185,30 @@ public class MASpawnThread implements Runnable
|
|||||||
{
|
{
|
||||||
for (Player p : arena.arenaPlayers)
|
for (Player p : arena.arenaPlayers)
|
||||||
{
|
{
|
||||||
if (arena.rewardMap.get(p) == null)
|
if (arena.log.players.get(p) == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ItemStack reward = MAUtils.getRandomReward(rewards);
|
ItemStack reward = MAUtils.getRandomReward(rewards);
|
||||||
arena.rewardMap.get(p).add(reward);
|
arena.log.players.get(p).rewards.add(reward);
|
||||||
|
|
||||||
if (reward == null)
|
if (reward == null)
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(p, "ERROR! Problem with economy rewards. Notify server host!");
|
MAUtils.tellPlayer(p, "ERROR! Problem with economy rewards. Notify server host!");
|
||||||
System.out.println("[MobArena] ERROR! Could not add null reward. Please check the config-file!");
|
MobArena.warning("Could not add null reward. Please check the config-file!");
|
||||||
}
|
}
|
||||||
else if (reward.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
else if (reward.getTypeId() == MobArena.ECONOMY_MONEY_ID)
|
||||||
{
|
{
|
||||||
if (plugin.Methods.hasMethod())
|
if (plugin.Methods.hasMethod())
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.WAVE_REWARD, plugin.Method.format(reward.getAmount())));
|
MAUtils.tellPlayer(p, Msg.WAVE_REWARD, plugin.Method.format(reward.getAmount()));
|
||||||
else System.out.println("[MobArena] ERROR! No economy plugin detected!");
|
else MobArena.warning("Tried to add money, but no economy plugin detected!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MAUtils.tellPlayer(p, MAMessages.get(Msg.WAVE_REWARD, MAUtils.toCamelCase(reward.getType().toString()) + ":" + reward.getAmount()));
|
MAUtils.tellPlayer(p, Msg.WAVE_REWARD, MAUtils.toCamelCase(reward.getType().toString()) + ":" + reward.getAmount(), reward.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Spawns a default wave of monsters.
|
|
||||||
*/
|
|
||||||
private void defaultWave()
|
|
||||||
{
|
|
||||||
Location loc;
|
|
||||||
List<Location> spawnpoints = getValidSpawnpoints();
|
|
||||||
int noOfSpawnpoints = spawnpoints.size();
|
|
||||||
int count = wave + noOfPlayers;
|
|
||||||
CreatureType mob;
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
loc = spawnpoints.get(i % noOfSpawnpoints);
|
|
||||||
ran = random.nextInt(dWolves);
|
|
||||||
|
|
||||||
/* Because of the nature of the if-elseif-else statement,
|
|
||||||
* we're able to evaluate the random number in this way.
|
|
||||||
* If dSpiders = 0, then dSpiders = dSkeletons, which
|
|
||||||
* means if the random number is below that value, we will
|
|
||||||
* spawn a skeleton and break out of the statement. */
|
|
||||||
if (ran < dZombies) mob = CreatureType.ZOMBIE;
|
|
||||||
else if (ran < dSkeletons) mob = CreatureType.SKELETON;
|
|
||||||
else if (ran < dSpiders) mob = CreatureType.SPIDER;
|
|
||||||
else if (ran < dCreepers) mob = CreatureType.CREEPER;
|
|
||||||
else if (ran < dWolves) mob = CreatureType.WOLF;
|
|
||||||
else continue;
|
|
||||||
|
|
||||||
LivingEntity e = arena.world.spawnCreature(loc,mob);
|
|
||||||
arena.monsters.add(e);
|
|
||||||
|
|
||||||
if (mob == CreatureType.WOLF)
|
|
||||||
((Wolf)e).setOwner(null);
|
|
||||||
|
|
||||||
// Grab a random target.
|
|
||||||
Creature c = (Creature) e;
|
|
||||||
c.setTarget(getClosestPlayer(e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spawns a special wave of monsters.
|
|
||||||
*/
|
|
||||||
private void specialWave()
|
|
||||||
{
|
|
||||||
Location loc;
|
|
||||||
List<Location> spawnpoints = getValidSpawnpoints();
|
|
||||||
int noOfSpawnpoints = spawnpoints.size();
|
|
||||||
CreatureType mob;
|
|
||||||
ran = random.nextInt(dGhasts);
|
|
||||||
|
|
||||||
int count;
|
|
||||||
boolean slime = false;
|
|
||||||
boolean wolf = false;
|
|
||||||
boolean ghast = false;
|
|
||||||
boolean creeper = false;
|
|
||||||
|
|
||||||
if (ran < dPoweredCreepers) mob = CreatureType.CREEPER;
|
|
||||||
else if (ran < dPigZombies) mob = CreatureType.PIG_ZOMBIE;
|
|
||||||
else if (ran < dSlimes) mob = CreatureType.SLIME;
|
|
||||||
else if (ran < dMonsters) mob = CreatureType.MONSTER;
|
|
||||||
else if (ran < dAngryWolves) mob = CreatureType.WOLF;
|
|
||||||
else if (ran < dGiants) mob = CreatureType.GIANT;
|
|
||||||
else if (ran < dGhasts) mob = CreatureType.GHAST;
|
|
||||||
else return;
|
|
||||||
|
|
||||||
switch(mob)
|
|
||||||
{
|
|
||||||
case CREEPER:
|
|
||||||
count = noOfPlayers * 3;
|
|
||||||
creeper = true;
|
|
||||||
break;
|
|
||||||
case PIG_ZOMBIE:
|
|
||||||
count = noOfPlayers * 2;
|
|
||||||
break;
|
|
||||||
case SLIME:
|
|
||||||
count = noOfPlayers * 4;
|
|
||||||
slime = true;
|
|
||||||
break;
|
|
||||||
case MONSTER:
|
|
||||||
count = noOfPlayers + 1;
|
|
||||||
break;
|
|
||||||
case WOLF:
|
|
||||||
count = noOfPlayers * 3;
|
|
||||||
wolf = true;
|
|
||||||
break;
|
|
||||||
case GIANT:
|
|
||||||
count = 1;
|
|
||||||
break;
|
|
||||||
case GHAST:
|
|
||||||
count = 2;
|
|
||||||
ghast = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
count = 50;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spawn the hippie monsters.
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
loc = spawnpoints.get(i % noOfSpawnpoints);
|
|
||||||
|
|
||||||
LivingEntity e = arena.world.spawnCreature(loc,mob);
|
|
||||||
arena.monsters.add(e);
|
|
||||||
|
|
||||||
if (slime) ((Slime)e).setSize(2);
|
|
||||||
if (wolf) { ((Wolf)e).setAngry(true); ((Wolf)e).setOwner(null); }
|
|
||||||
if (ghast) ((Ghast)e).setHealth(Math.min(noOfPlayers*25, 200));
|
|
||||||
if (creeper) ((Creeper)e).setPowered(true);
|
|
||||||
|
|
||||||
// Slimes can't have targets, apparently.
|
|
||||||
if (!(e instanceof Creature))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Grab a random target.
|
|
||||||
Creature c = (Creature) e;
|
|
||||||
c.setTarget(getClosestPlayer(e));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!arena.lightning)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Lightning, just for effect ;)
|
|
||||||
for (Location spawn : arena.spawnpoints.values())
|
|
||||||
arena.world.strikeLightningEffect(spawn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Detonates" all the Creepers in the monsterSet.
|
* "Detonates" all the Creepers in the monsterSet.
|
||||||
*/
|
*/
|
||||||
@@ -312,74 +236,6 @@ public class MASpawnThread implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all the spawnpoints that have players nearby.
|
|
||||||
*/
|
|
||||||
public List<Location> getValidSpawnpoints()
|
|
||||||
{
|
|
||||||
List<Location> result = new ArrayList<Location>();
|
|
||||||
|
|
||||||
for (Location s : arena.spawnpoints.values())
|
|
||||||
{
|
|
||||||
//for (Player p : arena.livePlayers)
|
|
||||||
for (Player p : arena.arenaPlayers)
|
|
||||||
{
|
|
||||||
if (!arena.world.equals(p.getWorld()))
|
|
||||||
{
|
|
||||||
System.out.println("[MobArena] MASpawnThread:291: Player '" + p.getName() + "' is not in the right world. Force leaving...");
|
|
||||||
arena.playerLeave(p);
|
|
||||||
MAUtils.tellPlayer(p, "You warped out of the arena world.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s.distanceSquared(p.getLocation()) > MobArena.MIN_PLAYER_DISTANCE)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
result.add(s);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If no players are in range, just use all the spawnpoints.
|
|
||||||
if (result.isEmpty())
|
|
||||||
result.addAll(arena.spawnpoints.values());
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the player closest to the input entity.
|
|
||||||
*/
|
|
||||||
// TODO: Move this into MAUtils
|
|
||||||
public Player getClosestPlayer(Entity e)
|
|
||||||
{
|
|
||||||
// Set up the comparison variable and the result.
|
|
||||||
double dist = 0;
|
|
||||||
double current = Double.POSITIVE_INFINITY;
|
|
||||||
Player result = null;
|
|
||||||
|
|
||||||
/* Iterate through the ArrayList, and update current and result every
|
|
||||||
* time a squared distance smaller than current is found. */
|
|
||||||
//for (Player p : arena.livePlayers)
|
|
||||||
for (Player p : arena.arenaPlayers)
|
|
||||||
{
|
|
||||||
if (!arena.world.equals(p.getWorld()))
|
|
||||||
{
|
|
||||||
System.out.println("[MobArena] MASpawnThread:329: Player '" + p.getName() + "' is not in the right world. Force leaving...");
|
|
||||||
arena.playerLeave(p);
|
|
||||||
MAUtils.tellPlayer(p, "You warped out of the arena world.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
dist = p.getLocation().distanceSquared(e.getLocation());
|
|
||||||
if (dist < current && dist < MobArena.MIN_PLAYER_DISTANCE)
|
|
||||||
{
|
|
||||||
current = dist;
|
|
||||||
result = p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the targets of all monsters, if their targets aren't alive.
|
* Update the targets of all monsters, if their targets aren't alive.
|
||||||
*/
|
*/
|
||||||
@@ -399,7 +255,7 @@ public class MASpawnThread implements Runnable
|
|||||||
if (target instanceof Player && arena.arenaPlayers.contains(target))
|
if (target instanceof Player && arena.arenaPlayers.contains(target))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
c.setTarget(getClosestPlayer(e));
|
c.setTarget(MAUtils.getClosestPlayer(e, arena));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,6 +16,8 @@ import java.util.Map;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.minecraft.server.WorldServer;
|
import net.minecraft.server.WorldServer;
|
||||||
|
|
||||||
@@ -33,8 +36,19 @@ import org.bukkit.entity.Wolf;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.util.config.Configuration;
|
import org.bukkit.util.config.Configuration;
|
||||||
|
import org.getspout.spoutapi.SpoutManager;
|
||||||
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
|
|
||||||
import com.garbagemule.MobArena.MAMessages.Msg;
|
import com.garbagemule.MobArena.MAMessages.Msg;
|
||||||
|
import com.garbagemule.MobArena.util.EntityPosition;
|
||||||
|
import com.garbagemule.MobArena.util.InventoryItem;
|
||||||
|
import com.garbagemule.MobArena.util.jnbt.ByteTag;
|
||||||
|
import com.garbagemule.MobArena.util.jnbt.CompoundTag;
|
||||||
|
import com.garbagemule.MobArena.util.jnbt.ListTag;
|
||||||
|
import com.garbagemule.MobArena.util.jnbt.NBTInputStream;
|
||||||
|
import com.garbagemule.MobArena.util.jnbt.NBTOutputStream;
|
||||||
|
import com.garbagemule.MobArena.util.jnbt.ShortTag;
|
||||||
|
import com.garbagemule.MobArena.util.jnbt.Tag;
|
||||||
|
|
||||||
public class MAUtils
|
public class MAUtils
|
||||||
{
|
{
|
||||||
@@ -131,6 +145,20 @@ public class MAUtils
|
|||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////// */
|
// ///////////////////////////////////////////////////////////////////// */
|
||||||
|
|
||||||
|
public static Map<String,Location> getArenaContainers(Configuration config, World world, String arena)
|
||||||
|
{
|
||||||
|
Map<String,Location> containers = new HashMap<String,Location>();
|
||||||
|
String arenaPath = "arenas." + arena + ".coords.containers";
|
||||||
|
|
||||||
|
if (config.getKeys(arenaPath) == null)
|
||||||
|
return containers;
|
||||||
|
|
||||||
|
for (String point : config.getKeys(arenaPath))
|
||||||
|
containers.put(point, makeLocation(world, config.getString(arenaPath + "." + point)));
|
||||||
|
|
||||||
|
return containers;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab all the spawnpoints for a specific arena.
|
* Grab all the spawnpoints for a specific arena.
|
||||||
*/
|
*/
|
||||||
@@ -250,55 +278,6 @@ public class MAUtils
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Grabs the distribution coefficients from the config-file. If
|
|
||||||
* no coefficients are found, defaults (10) are added.
|
|
||||||
*/
|
|
||||||
public static Map<String,Integer> getArenaDistributions(Configuration config, String arena, String wave)
|
|
||||||
{
|
|
||||||
String arenaPath = "arenas." + arena + ".waves." + wave;
|
|
||||||
Map<String,Integer> result = new HashMap<String,Integer>();
|
|
||||||
List<String> dists = (config.getKeys(arenaPath) != null) ? config.getKeys(arenaPath) : new LinkedList<String>();
|
|
||||||
|
|
||||||
String[] monsters = (wave.equals("default")) ? new String[]{"zombies", "skeletons", "spiders", "creepers", "wolves"}
|
|
||||||
: new String[]{"powered-creepers", "zombie-pigmen", "slimes", "humans", "angry-wolves", "giants", "ghasts"};
|
|
||||||
boolean update = false;
|
|
||||||
for (String monster : monsters)
|
|
||||||
{
|
|
||||||
if (dists.contains(monster))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
//if (config.getInt(arenaPath + "." + m, -1) == -1)
|
|
||||||
config.setProperty(arenaPath + "." + monster, (monster.equals("giants") || monster.equals("ghasts")) ? 0 : 10);
|
|
||||||
update = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (update)
|
|
||||||
{
|
|
||||||
config.save();
|
|
||||||
dists = config.getKeys(arenaPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String monster : dists)
|
|
||||||
{
|
|
||||||
int value = config.getInt(arenaPath + "." + monster, -1);
|
|
||||||
|
|
||||||
// If no distribution value was found, set one.
|
|
||||||
if (value == -1)
|
|
||||||
{
|
|
||||||
value = 10;
|
|
||||||
if (monster.equals("giant") || monster.equals("ghast"))
|
|
||||||
value = 0;
|
|
||||||
|
|
||||||
config.setProperty(arenaPath + "." + monster, value);
|
|
||||||
}
|
|
||||||
config.save();
|
|
||||||
|
|
||||||
result.put(monster, value);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getAllowedCommands(Configuration config)
|
public static List<String> getAllowedCommands(Configuration config)
|
||||||
{
|
{
|
||||||
String commands = config.getString("global-settings.allowed-commands");
|
String commands = config.getString("global-settings.allowed-commands");
|
||||||
@@ -319,8 +298,7 @@ public class MAUtils
|
|||||||
INVENTORY AND REWARD METHODS
|
INVENTORY AND REWARD METHODS
|
||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////// */
|
// ///////////////////////////////////////////////////////////////////// */
|
||||||
|
|
||||||
/* Clears the players inventory and armor slots. */
|
|
||||||
public static PlayerInventory clearInventory(Player p)
|
public static PlayerInventory clearInventory(Player p)
|
||||||
{
|
{
|
||||||
PlayerInventory inv = p.getInventory();
|
PlayerInventory inv = p.getInventory();
|
||||||
@@ -334,26 +312,28 @@ public class MAUtils
|
|||||||
|
|
||||||
public static boolean storeInventory(Player p)
|
public static boolean storeInventory(Player p)
|
||||||
{
|
{
|
||||||
// Grab the contents.
|
// Set up the files and paths
|
||||||
ItemStack[] armor = p.getInventory().getArmorContents();
|
|
||||||
ItemStack[] items = p.getInventory().getContents();
|
|
||||||
|
|
||||||
String invPath = "plugins" + sep + "MobArena" + sep + "inventories";
|
String invPath = "plugins" + sep + "MobArena" + sep + "inventories";
|
||||||
new File(invPath).mkdir();
|
new File(invPath).mkdir();
|
||||||
File backupFile = new File(invPath + sep + p.getName() + ".inv");
|
File backupFile = new File(invPath + sep + p.getName() + ".inv");
|
||||||
|
|
||||||
|
// If a backup file already exists, restore the inventory first
|
||||||
|
if (backupFile.exists() && !restoreInventory(p))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Grab the inventory contents.
|
||||||
|
ItemStack[] items = p.getInventory().getContents();
|
||||||
|
ItemStack[] armor = p.getInventory().getArmorContents();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (backupFile.exists() && !restoreInventory(p))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
backupFile.createNewFile();
|
backupFile.createNewFile();
|
||||||
|
|
||||||
MAInventoryItem[] inv = new MAInventoryItem[armor.length + items.length];
|
InventoryItem[] inv = new InventoryItem[items.length + armor.length];
|
||||||
for (int i = 0; i < armor.length; i++)
|
|
||||||
inv[i] = stackToItem(armor[i]);
|
|
||||||
for (int i = 0; i < items.length; i++)
|
for (int i = 0; i < items.length; i++)
|
||||||
inv[armor.length + i] = stackToItem(items[i]);
|
inv[i] = InventoryItem.parseItemStack(items[i]);
|
||||||
|
for (int i = 0; i < armor.length; i++)
|
||||||
|
inv[i + items.length] = InventoryItem.parseItemStack(armor[i]);
|
||||||
|
|
||||||
FileOutputStream fos = new FileOutputStream(backupFile);
|
FileOutputStream fos = new FileOutputStream(backupFile);
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||||
@@ -363,7 +343,7 @@ public class MAUtils
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("[MobArena] ERROR! Could not create backup file for " + p.getName() + ".");
|
MobArena.warning("Could not create backup file for " + p.getName() + ".");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,6 +352,33 @@ public class MAUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean restoreInventory(Player p)
|
public static boolean restoreInventory(Player p)
|
||||||
|
{
|
||||||
|
// Grab the items from the MobArena .inv file
|
||||||
|
ItemStack[] stacks = getInventoryFile(p);
|
||||||
|
|
||||||
|
// If the player isn't online, hack the playerName.dat file
|
||||||
|
if (!p.isOnline())
|
||||||
|
return writeInventoryData(p, stacks);
|
||||||
|
|
||||||
|
// Otherwise, restore the inventory directly
|
||||||
|
ItemStack[] items = new ItemStack[stacks.length-4];
|
||||||
|
ItemStack[] armor = new ItemStack[4];
|
||||||
|
|
||||||
|
for (int i = 0; i < stacks.length - 4; i++)
|
||||||
|
items[i] = stacks[i];
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
armor[i] = stacks[stacks.length - 4 + i];
|
||||||
|
|
||||||
|
// Restore the inventory.
|
||||||
|
PlayerInventory inv = p.getInventory();
|
||||||
|
inv.setArmorContents(armor);
|
||||||
|
for (int i = 0; i < items.length; i++)
|
||||||
|
inv.setItem(i, items[i]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack[] getInventoryFile(Player p)
|
||||||
{
|
{
|
||||||
String invPath = "plugins" + sep + "MobArena" + sep + "inventories";
|
String invPath = "plugins" + sep + "MobArena" + sep + "inventories";
|
||||||
File backupFile = new File(invPath + sep + p.getName() + ".inv");
|
File backupFile = new File(invPath + sep + p.getName() + ".inv");
|
||||||
@@ -380,55 +387,111 @@ public class MAUtils
|
|||||||
{
|
{
|
||||||
// If the backup-file couldn't be found, return.
|
// If the backup-file couldn't be found, return.
|
||||||
if (!backupFile.exists())
|
if (!backupFile.exists())
|
||||||
return false;
|
return null;
|
||||||
|
|
||||||
// Grab the MAInventoryItem array from the backup-file.
|
// Grab the MAInventoryItem array from the backup-file.
|
||||||
FileInputStream fis = new FileInputStream(backupFile);
|
FileInputStream fis = new FileInputStream(backupFile);
|
||||||
ObjectInputStream ois = new ObjectInputStream(fis);
|
ObjectInputStream ois = new ObjectInputStream(fis);
|
||||||
MAInventoryItem[] fromFile = (MAInventoryItem[]) ois.readObject();
|
InventoryItem[] fromFile = (InventoryItem[]) ois.readObject();
|
||||||
ois.close();
|
ois.close();
|
||||||
|
|
||||||
// Split that shit.
|
// Delete the file
|
||||||
ItemStack[] armor = new ItemStack[4];
|
|
||||||
ItemStack[] items = new ItemStack[fromFile.length-4];
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
armor[i] = itemToStack(fromFile[i]);
|
|
||||||
for (int i = 4; i < fromFile.length; i++)
|
|
||||||
items[i - 4] = itemToStack(fromFile[i]);
|
|
||||||
|
|
||||||
// Restore the inventory.
|
|
||||||
PlayerInventory inv = p.getInventory();
|
|
||||||
inv.setArmorContents(armor);
|
|
||||||
for (ItemStack stack : items)
|
|
||||||
if (stack != null)
|
|
||||||
inv.addItem(stack);
|
|
||||||
|
|
||||||
// Remove the backup-file.
|
|
||||||
backupFile.delete();
|
backupFile.delete();
|
||||||
|
|
||||||
|
return InventoryItem.toItemStacks(fromFile);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("[MobArena] ERROR! Could not restore inventory for " + p.getName());
|
MobArena.warning("Could not restore inventory for " + p.getName());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack[] readInventoryData(Player p)
|
||||||
|
{
|
||||||
|
// Grab the data dir <world>/players/
|
||||||
|
File playerDir = new File(Bukkit.getServer().getWorlds().get(0).getName(), "players");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NBTInputStream in = new NBTInputStream(new FileInputStream(new File(playerDir, p.getName() + ".dat")));
|
||||||
|
CompoundTag tag = (CompoundTag) in.readTag();
|
||||||
|
in.close();
|
||||||
|
|
||||||
|
ListTag inventory = (ListTag) tag.getValue().get("Inventory");
|
||||||
|
|
||||||
|
ItemStack[] stacks = new ItemStack[40];
|
||||||
|
for (int i = 0; i < inventory.getValue().size(); i++)
|
||||||
|
{
|
||||||
|
CompoundTag item = (CompoundTag) inventory.getValue().get(i);
|
||||||
|
byte count = ((ByteTag) item.getValue().get("Count")).getValue();
|
||||||
|
byte slot = ((ByteTag) item.getValue().get("Slot")).getValue();
|
||||||
|
short damage = ((ShortTag) item.getValue().get("Damage")).getValue();
|
||||||
|
short id = ((ShortTag) item.getValue().get("id")).getValue();
|
||||||
|
stacks[slot < 36 ? slot : 36 + 103-slot] = new ItemStack(id, count, damage);
|
||||||
|
}
|
||||||
|
return stacks;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
MobArena.warning("Could not restore inventory for " + p.getName());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean writeInventoryData(Player p, ItemStack[] stacks)
|
||||||
|
{
|
||||||
|
// Abort if stacks is null
|
||||||
|
if (stacks == null) return false;
|
||||||
|
|
||||||
|
// Grab the data dir <world>/players/
|
||||||
|
File playerDir = new File(Bukkit.getServer().getWorlds().get(0).getName(), "players");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
NBTInputStream in = new NBTInputStream(new FileInputStream(new File(playerDir, p.getName() + ".dat")));
|
||||||
|
CompoundTag tag = (CompoundTag) in.readTag();
|
||||||
|
in.close();
|
||||||
|
|
||||||
|
ArrayList<Tag> tagList = new ArrayList<Tag>();
|
||||||
|
|
||||||
|
for (int i = 0; i < stacks.length; i++)
|
||||||
|
{
|
||||||
|
if (stacks[i] == null) continue;
|
||||||
|
|
||||||
|
ByteTag count = new ByteTag("Count", (byte) stacks[i].getAmount());
|
||||||
|
ByteTag slot = new ByteTag("Slot", (byte) (i < 36 ? i : 104-(stacks.length-i)));
|
||||||
|
ShortTag damage = new ShortTag("Damage", stacks[i].getDurability());
|
||||||
|
ShortTag id = new ShortTag("id", (short) stacks[i].getTypeId());
|
||||||
|
|
||||||
|
HashMap<String, Tag> tagMap = new HashMap<String, Tag>();
|
||||||
|
tagMap.put("Count", count);
|
||||||
|
tagMap.put("Slot", slot);
|
||||||
|
tagMap.put("Damage", damage);
|
||||||
|
tagMap.put("id", id);
|
||||||
|
|
||||||
|
tagList.add(new CompoundTag("", tagMap));
|
||||||
|
}
|
||||||
|
|
||||||
|
ListTag inventory = new ListTag("Inventory", CompoundTag.class, tagList);
|
||||||
|
|
||||||
|
HashMap<String, Tag> tagCompound = new HashMap<String, Tag>(tag.getValue());
|
||||||
|
tagCompound.put("Inventory", inventory);
|
||||||
|
tag = new CompoundTag("Player", tagCompound);
|
||||||
|
|
||||||
|
NBTOutputStream out = new NBTOutputStream(new FileOutputStream(new File(playerDir, p.getName() + ".dat")));
|
||||||
|
out.writeTag(tag);
|
||||||
|
out.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
MobArena.warning("Could not restore inventory for " + p.getName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MAInventoryItem stackToItem(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack == null)
|
|
||||||
return new MAInventoryItem(-1, -1, (short)0);
|
|
||||||
return new MAInventoryItem(stack.getTypeId(), stack.getAmount(), stack.getDurability());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ItemStack itemToStack(MAInventoryItem item)
|
|
||||||
{
|
|
||||||
if (item.getTypeId() == -1)
|
|
||||||
return null;
|
|
||||||
return new ItemStack(item.getTypeId(), item.getAmount(), item.getDurability());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Checks if all inventory and armor slots are empty. */
|
/* Checks if all inventory and armor slots are empty. */
|
||||||
@@ -456,6 +519,25 @@ public class MAUtils
|
|||||||
if (stacks == null)
|
if (stacks == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!p.isOnline())
|
||||||
|
{
|
||||||
|
ItemStack[] items = readInventoryData(p);
|
||||||
|
int currentSlot = 0;
|
||||||
|
for (ItemStack stack : stacks)
|
||||||
|
{
|
||||||
|
while (currentSlot < items.length && items[currentSlot] != null)
|
||||||
|
currentSlot++;
|
||||||
|
|
||||||
|
if (currentSlot >= items.length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
items[currentSlot] = stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
writeInventoryData(p, items);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PlayerInventory inv = p.getInventory();
|
PlayerInventory inv = p.getInventory();
|
||||||
for (ItemStack stack : stacks)
|
for (ItemStack stack : stacks)
|
||||||
{
|
{
|
||||||
@@ -474,7 +556,8 @@ public class MAUtils
|
|||||||
// If these are rewards, don't tamper with them.
|
// If these are rewards, don't tamper with them.
|
||||||
if (rewards)
|
if (rewards)
|
||||||
{
|
{
|
||||||
inv.addItem(stack);
|
//inv.addItem(stack);
|
||||||
|
giveItem(inv, stack);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,19 +572,36 @@ public class MAUtils
|
|||||||
if (WEAPONS_TYPE.contains(stack.getType()))
|
if (WEAPONS_TYPE.contains(stack.getType()))
|
||||||
stack.setDurability((short) -32768);
|
stack.setDurability((short) -32768);
|
||||||
|
|
||||||
inv.addItem(stack);
|
giveItem(inv, stack);
|
||||||
|
//inv.addItem(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void giveRewards(Player p, List<ItemStack> stacks, MobArena plugin)
|
|
||||||
{
|
|
||||||
giveItems(p, stacks, false, true, plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void giveItems(Player p, List<ItemStack> stacks, boolean autoEquip, MobArena plugin)
|
public static void giveItems(Player p, List<ItemStack> stacks, boolean autoEquip, MobArena plugin)
|
||||||
{
|
{
|
||||||
giveItems(p, stacks, autoEquip, false, plugin);
|
giveItems(p, stacks, autoEquip, false, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void giveItem(PlayerInventory inv, ItemStack stack)
|
||||||
|
{
|
||||||
|
int id = stack.getTypeId();
|
||||||
|
int amount = stack.getAmount();
|
||||||
|
|
||||||
|
int times = amount / 64;
|
||||||
|
int remainder = amount % 64;
|
||||||
|
|
||||||
|
for (int i = 0; i < times; i++)
|
||||||
|
inv.addItem(new ItemStack(id, 64));
|
||||||
|
|
||||||
|
if (remainder > 0)
|
||||||
|
inv.addItem(new ItemStack(id, remainder));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void giveRewards(Player p, List<ItemStack> stacks, MobArena plugin)
|
||||||
|
{
|
||||||
|
giveItems(p, stacks, false, true, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
public static int getPetAmount(Player p)
|
public static int getPetAmount(Player p)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@@ -559,7 +659,7 @@ public class MAUtils
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
System.out.println("[MobArena] ERROR! Could not create item \"" + name + "\". Check config.yml");
|
MobArena.warning("Could not create item \"" + name + "\". Check config.yml");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -592,10 +692,7 @@ public class MAUtils
|
|||||||
public static void sitPets(Player p)
|
public static void sitPets(Player p)
|
||||||
{
|
{
|
||||||
if (p == null)
|
if (p == null)
|
||||||
{
|
|
||||||
System.out.println("Player is null!");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
List<Entity> entities = p.getNearbyEntities(80, 40, 80);
|
List<Entity> entities = p.getNearbyEntities(80, 40, 80);
|
||||||
for (Entity e : entities)
|
for (Entity e : entities)
|
||||||
@@ -609,18 +706,6 @@ public class MAUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all the pets belonging to this player.
|
|
||||||
*//*
|
|
||||||
public static void clearPets(Arena arena, Player p)
|
|
||||||
{
|
|
||||||
for (Wolf w : arena.pets)
|
|
||||||
{
|
|
||||||
if (w.getOwner().equals(p))
|
|
||||||
w.remove();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ///////////////////////////////////////////////////////////////////// //
|
/* ///////////////////////////////////////////////////////////////////// //
|
||||||
@@ -629,6 +714,20 @@ public class MAUtils
|
|||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////// */
|
// ///////////////////////////////////////////////////////////////////// */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a Location is inside two points (x1,y1,z1) (x2,y2,z2)
|
||||||
|
*/
|
||||||
|
public static boolean inRegion(Location loc, double x1, double y1, double z1, double x2, double y2, double z2)
|
||||||
|
{
|
||||||
|
double x = loc.getBlockX();
|
||||||
|
double y = loc.getBlockY();
|
||||||
|
double z = loc.getBlockZ();
|
||||||
|
|
||||||
|
return x >= x1 && x <= x2 &&
|
||||||
|
y >= y1 && y <= y2 &&
|
||||||
|
z >= z1 && z <= z2;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a frame spanned by the two input coordinates.
|
* 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.
|
* @return An int arry holding x,y,z and the original type IDs of each block.
|
||||||
@@ -780,6 +879,10 @@ public class MAUtils
|
|||||||
arena.p1.setY(arena.p2.getY());
|
arena.p1.setY(arena.p2.getY());
|
||||||
arena.p2.setY(tmp);
|
arena.p2.setY(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!arena.world.getName().equals(world.getName()))
|
||||||
|
arena.world = world;
|
||||||
|
|
||||||
arena.serializeConfig();
|
arena.serializeConfig();
|
||||||
arena.load(config);
|
arena.load(config);
|
||||||
}
|
}
|
||||||
@@ -885,23 +988,84 @@ public class MAUtils
|
|||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////// */
|
// ///////////////////////////////////////////////////////////////////// */
|
||||||
|
|
||||||
/**
|
public static boolean tellSpoutPlayer(Player p, Msg msg, String s, Material logo)
|
||||||
* Sends a message to a player.
|
{
|
||||||
*/
|
// Grab the SpoutPlayer.
|
||||||
|
SpoutPlayer sp = MobArena.hasSpout ? SpoutManager.getPlayer(p) : null;
|
||||||
|
|
||||||
|
if (msg.hasSpoutMsg() && sp != null && sp.isSpoutCraftEnabled())
|
||||||
|
{
|
||||||
|
// Grab the message text.
|
||||||
|
String text = msg.getSpout(s);
|
||||||
|
|
||||||
|
// If more than 26 characters, truncate.
|
||||||
|
if (text.length() > 26)
|
||||||
|
text = text.substring(0, 26);
|
||||||
|
|
||||||
|
// If the logo is null, use an iron sword.
|
||||||
|
if (logo == null)
|
||||||
|
logo = msg.getLogo();
|
||||||
|
|
||||||
|
// Send the notification.
|
||||||
|
sp.sendNotification("MobArena", text, logo, (short) 0, 2000);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else return tellPlayer(p, msg.get(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean tellSpoutPlayer(Player p, Msg msg, Material logo)
|
||||||
|
{
|
||||||
|
return tellSpoutPlayer(p, msg, null, logo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean tellSpoutPlayer(Player p, Msg msg, String s)
|
||||||
|
{
|
||||||
|
return tellSpoutPlayer(p, msg, s, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean tellSpoutPlayer(Player p, Msg msg)
|
||||||
|
{
|
||||||
|
return tellSpoutPlayer(p, msg, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean tellPlayer(CommandSender p, String msg)
|
public static boolean tellPlayer(CommandSender p, String msg)
|
||||||
{
|
{
|
||||||
if (p == null)
|
// If the input sender is null or the string is empty, return.
|
||||||
|
if (p == null || msg.equals(" "))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Otherwise, send the message with the [MobArena] tag.
|
||||||
p.sendMessage(ChatColor.GREEN + "[MobArena] " + ChatColor.WHITE + msg);
|
p.sendMessage(ChatColor.GREEN + "[MobArena] " + ChatColor.WHITE + msg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean tellPlayer(CommandSender p, Msg msg, String s, boolean spout, Material logo)
|
||||||
|
{
|
||||||
|
if (spout && p instanceof Player)
|
||||||
|
return tellSpoutPlayer((Player) p, msg, s, logo);
|
||||||
|
|
||||||
|
return tellPlayer(p, msg.get(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean tellPlayer(CommandSender p, Msg msg, String s, Material logo)
|
||||||
|
{
|
||||||
|
return tellPlayer(p, msg, s, MobArena.hasSpout, logo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean tellPlayer(CommandSender p, Msg msg, String s)
|
||||||
|
{
|
||||||
|
return tellPlayer(p, msg, s, MobArena.hasSpout, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean tellPlayer(CommandSender p, Msg msg)
|
||||||
|
{
|
||||||
|
return tellPlayer(p, msg, null, MobArena.hasSpout, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a message to all players in and around the arena.
|
* Sends a message to all players in and around the arena.
|
||||||
*/
|
*/
|
||||||
public static void tellAll(Arena arena, String msg) { tellAll(arena, msg, false); }
|
public static void tellAll(Arena arena, Msg msg, String s, boolean notifyPlayers)
|
||||||
public static void tellAll(Arena arena, String msg, boolean notifyPlayers)
|
|
||||||
{
|
{
|
||||||
Set<Player> tmp = new HashSet<Player>();
|
Set<Player> tmp = new HashSet<Player>();
|
||||||
tmp.addAll(arena.arenaPlayers);
|
tmp.addAll(arena.arenaPlayers);
|
||||||
@@ -911,7 +1075,22 @@ public class MAUtils
|
|||||||
tmp.addAll(arena.specPlayers);
|
tmp.addAll(arena.specPlayers);
|
||||||
if (notifyPlayers) tmp.addAll(arena.notifyPlayers);
|
if (notifyPlayers) tmp.addAll(arena.notifyPlayers);
|
||||||
for (Player p : tmp)
|
for (Player p : tmp)
|
||||||
tellPlayer(p, msg);
|
tellPlayer(p, msg, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void tellAll(Arena arena, Msg msg, String s)
|
||||||
|
{
|
||||||
|
tellAll(arena, msg, s, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void tellAll(Arena arena, Msg msg, boolean notifyPlayers)
|
||||||
|
{
|
||||||
|
tellAll(arena, msg, null, notifyPlayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void tellAll(Arena arena, Msg msg)
|
||||||
|
{
|
||||||
|
tellAll(arena, msg, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Player getClosestPlayer(Entity e, Arena arena)
|
public static Player getClosestPlayer(Entity e, Arena arena)
|
||||||
@@ -927,8 +1106,8 @@ public class MAUtils
|
|||||||
{
|
{
|
||||||
if (!arena.world.equals(p.getWorld()))
|
if (!arena.world.equals(p.getWorld()))
|
||||||
{
|
{
|
||||||
System.out.println("[MobArena] MAUtils:908: Player '" + p.getName() + "' is not in the right world. Force leaving...");
|
MobArena.info("Player '" + p.getName() + "' is not in the right world. Kicking...");
|
||||||
arena.playerLeave(p);
|
p.kickPlayer("[MobArena] Cheater! (Warped out of the arena world.)");
|
||||||
tellPlayer(p, "You warped out of the arena world.");
|
tellPlayer(p, "You warped out of the arena world.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -994,7 +1173,7 @@ public class MAUtils
|
|||||||
if (list == null || list.isEmpty())
|
if (list == null || list.isEmpty())
|
||||||
{
|
{
|
||||||
if (none)
|
if (none)
|
||||||
return MAMessages.get(Msg.MISC_NONE);
|
return Msg.MISC_NONE.get();
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -1045,6 +1224,7 @@ public class MAUtils
|
|||||||
return buffy.toString().substring(0, buffy.length() - trimLength);
|
return buffy.toString().substring(0, buffy.length() - trimLength);
|
||||||
}
|
}
|
||||||
public static <E> String listToString(List<E> list, MobArena plugin) { return listToString(list, true, plugin); }
|
public static <E> String listToString(List<E> list, MobArena plugin) { return listToString(list, true, plugin); }
|
||||||
|
public static <E> String listToString(List<E> list) { return listToString(list, true, (MobArena) Bukkit.getServer().getPluginManager().getPlugin("MobArena")); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a String-list version of a comma-separated list.
|
* Returns a String-list version of a comma-separated list.
|
||||||
@@ -1080,7 +1260,7 @@ public class MAUtils
|
|||||||
* and spawnpoints are all set up.
|
* and spawnpoints are all set up.
|
||||||
*/
|
*/
|
||||||
public static boolean verifyData(Arena arena)
|
public static boolean verifyData(Arena arena)
|
||||||
{
|
{
|
||||||
return ((arena.arenaLoc != null) &&
|
return ((arena.arenaLoc != null) &&
|
||||||
(arena.lobbyLoc != null) &&
|
(arena.lobbyLoc != null) &&
|
||||||
(arena.spectatorLoc != null) &&
|
(arena.spectatorLoc != null) &&
|
||||||
@@ -1094,6 +1274,24 @@ public class MAUtils
|
|||||||
return ((arena.l1 != null) &&
|
return ((arena.l1 != null) &&
|
||||||
(arena.l2 != null));
|
(arena.l2 != null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void checkData(Arena arena, CommandSender p)
|
||||||
|
{
|
||||||
|
if (arena.arenaLoc == null)
|
||||||
|
tellPlayer(p, "Missing warp: arena");
|
||||||
|
if (arena.lobbyLoc == null)
|
||||||
|
tellPlayer(p, "Missing warp: lobby");
|
||||||
|
if (arena.spectatorLoc == null)
|
||||||
|
tellPlayer(p, "Missing warp: spectator");
|
||||||
|
if (arena.p1 == null)
|
||||||
|
tellPlayer(p, "Missing region point: p1");
|
||||||
|
if (arena.p2 == null)
|
||||||
|
tellPlayer(p, "Missing region point: p2");
|
||||||
|
if (arena.spawnpoints.size() <= 0)
|
||||||
|
tellPlayer(p, "Missing spawnpoints");
|
||||||
|
if (arena.setup)
|
||||||
|
tellPlayer(p, "Arena is ready to be used!");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if there is a new update of MobArena and notifies the
|
* Checks if there is a new update of MobArena and notifies the
|
||||||
@@ -1109,6 +1307,7 @@ public class MAUtils
|
|||||||
|
|
||||||
// Open the connection and don't redirect.
|
// Open the connection and don't redirect.
|
||||||
HttpURLConnection con = (HttpURLConnection) baseURI.toURL().openConnection();
|
HttpURLConnection con = (HttpURLConnection) baseURI.toURL().openConnection();
|
||||||
|
con.setConnectTimeout(5000);
|
||||||
con.setInstanceFollowRedirects(false);
|
con.setInstanceFollowRedirects(false);
|
||||||
|
|
||||||
String header = con.getHeaderField("Location");
|
String header = con.getHeaderField("Location");
|
||||||
@@ -1123,18 +1322,27 @@ public class MAUtils
|
|||||||
// Otherwise, grab the location header to get the real URI.
|
// Otherwise, grab the location header to get the real URI.
|
||||||
String url = new URI(con.getHeaderField("Location")).toString();
|
String url = new URI(con.getHeaderField("Location")).toString();
|
||||||
|
|
||||||
// If the current version is the same as the thread version.
|
// Set up the regex and matcher
|
||||||
if (url.contains(plugin.getDescription().getVersion().replace(".", "-")))
|
Pattern regex = Pattern.compile("v([0-9]+-)*[0-9]+");
|
||||||
{
|
Matcher matcher = regex.matcher(url);
|
||||||
if (!response)
|
if (!matcher.find())
|
||||||
return;
|
|
||||||
|
|
||||||
tellPlayer(p, "Your version of MobArena is up to date!");
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Split the version strings
|
||||||
|
String[] forumVersion = matcher.group().substring(1).split("-");
|
||||||
|
String[] thisVersion = plugin.getDescription().getVersion().split("\\.");
|
||||||
|
|
||||||
|
// If the current version is older than the forum version, notify.
|
||||||
|
for (int i = 0; i < Math.min(forumVersion.length, thisVersion.length); i++)
|
||||||
|
{
|
||||||
|
if (Integer.parseInt(forumVersion[i]) > Integer.parseInt(thisVersion[i]))
|
||||||
|
{
|
||||||
|
tellPlayer(p, "There is a new version of MobArena available!");;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, notify the player that there is a new version.
|
if (response) tellPlayer(p, "Your version of MobArena is up to date!");
|
||||||
tellPlayer(p, "There is a new version of MobArena available!");;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -1162,27 +1370,16 @@ public class MAUtils
|
|||||||
long hrs = ((seconds - secs) - (mins * 60)) / 60 / 60;
|
long hrs = ((seconds - secs) - (mins * 60)) / 60 / 60;
|
||||||
return hrs + ":" + ((mins < 10) ? "0" + mins : mins) + ":" + ((secs < 10) ? "0" + secs : secs);
|
return hrs + ":" + ((mins < 10) ? "0" + mins : mins) + ":" + ((secs < 10) ? "0" + secs : secs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String padRight(String s, int length) { return padRight(s, length, ' '); }
|
|
||||||
public static String padRight(String s, int length, char pad)
|
|
||||||
{
|
|
||||||
StringBuffer buffy = new StringBuffer();
|
|
||||||
buffy.append(s);
|
|
||||||
for (int i = s.length(); i < length; i++)
|
|
||||||
buffy.append(pad);
|
|
||||||
return buffy.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String padLeft(String s, int length) { return padLeft(s, length, ' '); }
|
|
||||||
public static String padLeft(String s, int length, char pad)
|
|
||||||
{
|
|
||||||
StringBuffer buffy = new StringBuffer();
|
|
||||||
for (int i = 0; i < length - s.length(); i++)
|
|
||||||
buffy.append(pad);
|
|
||||||
buffy.append(s);
|
|
||||||
return buffy.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public static long parseDuration(String duration)
|
||||||
|
{
|
||||||
|
String[] elements = duration.split(":");
|
||||||
|
long hrs = Long.parseLong(elements[0]) * 60 * 60;
|
||||||
|
long mins = Long.parseLong(elements[1]) * 60;
|
||||||
|
long secs = Long.parseLong(elements[2]);
|
||||||
|
|
||||||
|
return (hrs + mins + secs) * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stand back, I'm going to try science!
|
* Stand back, I'm going to try science!
|
||||||
@@ -1243,7 +1440,7 @@ public class MAUtils
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("[MobArena] ERROR! Couldn't create backup file. Aborting auto-generate...");
|
MobArena.warning("Couldn't create backup file. Aborting auto-generate...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1376,7 +1573,7 @@ public class MAUtils
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
if (error) System.out.println("[MobArena] ERROR! Couldn't find backup file for arena '" + name + "'");
|
if (error) MobArena.warning("Couldn't find backup file for arena '" + name + "'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.garbagemule.MobArena;
|
package com.garbagemule.MobArena;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.Event.Priority;
|
import org.bukkit.event.Event.Priority;
|
||||||
@@ -16,14 +18,17 @@ import org.bukkit.util.config.Configuration;
|
|||||||
|
|
||||||
import com.nijiko.permissions.PermissionHandler;
|
import com.nijiko.permissions.PermissionHandler;
|
||||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||||
|
import com.garbagemule.MobArena.util.FileUtils;
|
||||||
import com.garbagemule.register.payment.Method;
|
import com.garbagemule.register.payment.Method;
|
||||||
import com.garbagemule.register.payment.Methods;
|
import com.garbagemule.register.payment.Methods;
|
||||||
|
//import com.garbagemule.ArenaPlugin.ArenaPlugin;
|
||||||
|
//import com.garbagemule.ArenaPlugin.Master;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MobArena
|
* MobArena
|
||||||
* @author garbagemule
|
* @author garbagemule
|
||||||
*/
|
*/
|
||||||
public class MobArena extends JavaPlugin
|
public class MobArena extends JavaPlugin// implements ArenaPlugin
|
||||||
{
|
{
|
||||||
private Configuration config;
|
private Configuration config;
|
||||||
private ArenaMaster am;
|
private ArenaMaster am;
|
||||||
@@ -36,36 +41,76 @@ public class MobArena extends JavaPlugin
|
|||||||
protected Method Method;
|
protected Method Method;
|
||||||
|
|
||||||
// Global variables
|
// Global variables
|
||||||
protected static final double MIN_PLAYER_DISTANCE = 256.0;
|
public static PluginDescriptionFile desc;
|
||||||
protected static final int ECONOMY_MONEY_ID = -29;
|
public static File dir, arenaDir;
|
||||||
|
public static final double MIN_PLAYER_DISTANCE = 15.0;
|
||||||
|
public static final double MIN_PLAYER_DISTANCE_SQUARED = MIN_PLAYER_DISTANCE * MIN_PLAYER_DISTANCE;
|
||||||
|
public static final int ECONOMY_MONEY_ID = -29;
|
||||||
|
public static boolean hasSpout;
|
||||||
|
public static Random random = new Random();
|
||||||
|
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
// Description file and data folders
|
||||||
|
desc = getDescription();
|
||||||
|
dir = getDataFolder();
|
||||||
|
arenaDir = new File(dir, "arenas");
|
||||||
|
if (!dir.exists()) dir.mkdir();
|
||||||
|
if (!arenaDir.exists()) arenaDir.mkdir();
|
||||||
|
|
||||||
// Config, messages and ArenaMaster initialization
|
// Create default files and initialize config-file
|
||||||
|
FileUtils.extractDefaults("config.yml");
|
||||||
loadConfig();
|
loadConfig();
|
||||||
MAMessages.init(this);
|
|
||||||
|
// Download external libraries if needed.
|
||||||
|
FileUtils.fetchLibs(config);
|
||||||
|
|
||||||
|
// Set up permissions and economy
|
||||||
|
setupPermissions();
|
||||||
|
setupRegister();
|
||||||
|
setupSpout();
|
||||||
|
|
||||||
|
// Set up the ArenaMaster and the announcements
|
||||||
am = new ArenaMaster(this);
|
am = new ArenaMaster(this);
|
||||||
am.initialize();
|
am.initialize();
|
||||||
|
MAMessages.init(this);
|
||||||
|
|
||||||
// Permissions
|
// Register event listeners
|
||||||
setupPermissions();
|
registerListeners();
|
||||||
|
|
||||||
// Economy
|
// Announce enable!
|
||||||
Methods = new Methods();
|
info("v" + desc.getVersion() + " enabled.");
|
||||||
if (!Methods.hasMethod() && Methods.setMethod(this))
|
}
|
||||||
{
|
|
||||||
Method = Methods.getMethod();
|
public void onDisable()
|
||||||
System.out.println("[MobArena] Payment method found (" + Method.getName() + " version: " + Method.getVersion() + ")");
|
{
|
||||||
}
|
// Disable Spout features.
|
||||||
|
hasSpout = false;
|
||||||
|
|
||||||
// Bind the /ma, /marena, and /mobarena commands to MACommands.
|
// Force all arenas to end.
|
||||||
|
if (am == null) return;
|
||||||
|
for (Arena arena : am.arenas)
|
||||||
|
arena.forceEnd();
|
||||||
|
am.arenaMap.clear();
|
||||||
|
|
||||||
|
info("disabled.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadConfig()
|
||||||
|
{
|
||||||
|
File file = new File(dir, "config.yml");
|
||||||
|
config = new Configuration(file);
|
||||||
|
config.load();
|
||||||
|
config.setHeader(getHeader());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerListeners()
|
||||||
|
{
|
||||||
|
// Bind the /ma, /mobarena commands to MACommands.
|
||||||
MACommands commandExecutor = new MACommands(this, am);
|
MACommands commandExecutor = new MACommands(this, am);
|
||||||
getCommand("ma").setExecutor(commandExecutor);
|
getCommand("ma").setExecutor(commandExecutor);
|
||||||
getCommand("marena").setExecutor(commandExecutor);
|
getCommand("mobarena").setExecutor(commandExecutor);
|
||||||
getCommand("mobarena").setExecutor(commandExecutor);
|
|
||||||
|
|
||||||
// Create event listeners.
|
// Create event listeners.
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
PlayerListener playerListener = new MAPlayerListener(this, am);
|
PlayerListener playerListener = new MAPlayerListener(this, am);
|
||||||
@@ -73,6 +118,11 @@ public class MobArena extends JavaPlugin
|
|||||||
BlockListener blockListener = new MABlockListener(am);
|
BlockListener blockListener = new MABlockListener(am);
|
||||||
|
|
||||||
// Register events.
|
// Register events.
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Highest, this);
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_BURN, blockListener, Priority.Highest, this);
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Highest, this);
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_PHYSICS, blockListener, Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Priority.Highest, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.Normal, this);
|
||||||
@@ -80,8 +130,7 @@ public class MobArena extends JavaPlugin
|
|||||||
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_KICK, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_KICK, playerListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Highest, this);
|
pm.registerEvent(Event.Type.PLAYER_ANIMATION, playerListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Highest, this);
|
|
||||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.High, this); // mcMMO is "Highest"
|
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.High, this); // mcMMO is "Highest"
|
||||||
pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Lowest, this); // Lowest because of Tombstone
|
pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Lowest, this); // Lowest because of Tombstone
|
||||||
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, entityListener, Priority.Normal, this);
|
||||||
@@ -89,93 +138,28 @@ public class MobArena extends JavaPlugin
|
|||||||
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_TARGET, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_TARGET, entityListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Highest, this);
|
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Highest, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Monitor, this);
|
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Monitor, this); // I know Monitor is bad, but other plugins suck! :(
|
||||||
|
|
||||||
System.out.println("[MobArena] v" + pdfFile.getVersion() + " enabled." );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onDisable()
|
|
||||||
{
|
|
||||||
// Force all arenas to end.
|
|
||||||
for (Arena arena : am.arenas)
|
|
||||||
arena.forceEnd();
|
|
||||||
am.arenaMap.clear();
|
|
||||||
|
|
||||||
// Permissions & Economy
|
|
||||||
permissionHandler = null;
|
|
||||||
if (Methods != null && Methods.hasMethod())
|
|
||||||
{
|
|
||||||
Methods = null;
|
|
||||||
System.out.println("[MobArena] Payment method was disabled. No longer accepting payments.");
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("[MobArena] disabled.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the config-file and initialize the Configuration object.
|
|
||||||
*/
|
|
||||||
private void loadConfig()
|
|
||||||
{
|
|
||||||
File file = new File(this.getDataFolder(), "config.yml");
|
|
||||||
if (!file.exists())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.getDataFolder().mkdir();
|
|
||||||
file.createNewFile();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: Remove in v1.0
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Configuration tmp = new Configuration(file);
|
|
||||||
tmp.load();
|
|
||||||
if (tmp.getKeys("global-settings") == null)
|
|
||||||
{
|
|
||||||
file.renameTo(new File(this.getDataFolder(), "config_OLD.yml"));
|
|
||||||
file = new File(this.getDataFolder(), "config.yml");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.getDataFolder().mkdir();
|
|
||||||
file.createNewFile();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
config = new Configuration(file);
|
|
||||||
config.load();
|
|
||||||
fixConfig();
|
|
||||||
config.setHeader("# MobArena Configuration-file\r\n# Please go to https://github.com/garbagemule/MobArena/wiki/Installing-MobArena for more details.");
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
config = new Configuration(file);
|
|
||||||
config.load();
|
|
||||||
config.setHeader("# MobArena Configuration-file\r\n# Please go to https://github.com/garbagemule/MobArena/wiki/Installing-MobArena for more details.");
|
|
||||||
config.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Permissions stuff
|
// Permissions stuff
|
||||||
public boolean has(Player p, String s)
|
public boolean has(Player p, String s)
|
||||||
{
|
{
|
||||||
//return (permissionHandler != null && permissionHandler.has(p, s));
|
// First check for NijikoPerms
|
||||||
return (permissionHandler == null || permissionHandler.has(p, s));
|
if (permissionHandler != null)
|
||||||
|
return permissionHandler.has(p, s);
|
||||||
|
|
||||||
|
// If the permission is set, check if player has permission
|
||||||
|
if (p.isPermissionSet(s))
|
||||||
|
return p.hasPermission(s);
|
||||||
|
|
||||||
|
// Otherwise, only allow commands that aren't admin/setup commands.
|
||||||
|
return !s.matches("^.*\\.setup\\..*$") && !s.matches("^.*\\.admin\\..*$");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDefTrue(Player p, String s)
|
// Console printing
|
||||||
{
|
public static void info(String msg) { Bukkit.getServer().getLogger().info("[MobArena] " + msg); }
|
||||||
return (permissionHandler == null || permissionHandler.has(p, s));
|
public static void warning(String msg) { Bukkit.getServer().getLogger().warning("[MobArena] " + msg); }
|
||||||
}
|
public static void error(String msg) { Bukkit.getServer().getLogger().severe("[MobArena] " + msg); }
|
||||||
|
|
||||||
private void setupPermissions()
|
private void setupPermissions()
|
||||||
{
|
{
|
||||||
@@ -188,89 +172,34 @@ public class MobArena extends JavaPlugin
|
|||||||
permissionHandler = ((Permissions) permissionsPlugin).getHandler();
|
permissionHandler = ((Permissions) permissionsPlugin).getHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupRegister()
|
||||||
|
{
|
||||||
|
Methods = new Methods();
|
||||||
|
if (!Methods.hasMethod() && Methods.setMethod(this))
|
||||||
|
{
|
||||||
|
Method = Methods.getMethod();
|
||||||
|
info("Payment method found (" + Method.getName() + " version: " + Method.getVersion() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupSpout()
|
||||||
|
{
|
||||||
|
if (hasSpout)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Plugin spoutPlugin = this.getServer().getPluginManager().getPlugin("Spout");
|
||||||
|
hasSpout = spoutPlugin != null;
|
||||||
|
}
|
||||||
|
|
||||||
public Configuration getConfig() { return config; }
|
public Configuration getConfig() { return config; }
|
||||||
public ArenaMaster getAM() { return am; } // More convenient.
|
public ArenaMaster getAM() { return am; } // More convenient.
|
||||||
public ArenaMaster getArenaMaster() { return am; }
|
public ArenaMaster getArenaMaster() { return am; }
|
||||||
|
|
||||||
// TODO: Remove in v1.0
|
private String getHeader()
|
||||||
private void fixConfig()
|
|
||||||
{
|
{
|
||||||
// If global-settings is sorted, don't do anything.
|
String sep = System.getProperty("line.separator");
|
||||||
if (config.getKeys("global-settings") != null)
|
return "# MobArena v" + desc.getVersion() + " - Config-file" + sep +
|
||||||
return;
|
"# Read the Wiki for details on how to set up this file: http://goo.gl/F5TTc" + sep +
|
||||||
|
"# Note: You -must- use spaces instead of tabs!";
|
||||||
File oldFile = new File(this.getDataFolder(), "config_OLD.yml");
|
|
||||||
if (!oldFile.exists())
|
|
||||||
return;
|
|
||||||
|
|
||||||
System.out.println("[MobArena] Config-file appears to be old. Trying to fix it...");
|
|
||||||
|
|
||||||
Configuration oldConfig = new Configuration(oldFile);
|
|
||||||
oldConfig.load();
|
|
||||||
|
|
||||||
config.setProperty("global-settings.enabled", true);
|
|
||||||
config.save();
|
|
||||||
config.load();
|
|
||||||
config.setProperty("global-settings.update-notification", true);
|
|
||||||
config.save();
|
|
||||||
config.load();
|
|
||||||
|
|
||||||
// Copy classes
|
|
||||||
for (String s : oldConfig.getKeys("classes"))
|
|
||||||
{
|
|
||||||
config.setProperty("classes." + s + ".items", oldConfig.getString("classes." + s + ".items"));
|
|
||||||
config.setProperty("classes." + s + ".armor", oldConfig.getString("classes." + s + ".armor"));
|
|
||||||
}
|
|
||||||
config.save();
|
|
||||||
|
|
||||||
// Make the default arena node.
|
|
||||||
config.setProperty("arenas.default.settings.enabled", true);
|
|
||||||
config.save();
|
|
||||||
config.load();
|
|
||||||
config.setProperty("arenas.default.settings.world", oldConfig.getString("settings.world"));
|
|
||||||
config.save();
|
|
||||||
config.load();
|
|
||||||
|
|
||||||
// Copy the coords.
|
|
||||||
for (String s : oldConfig.getKeys("coords"))
|
|
||||||
{
|
|
||||||
if (s.equals("spawnpoints"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
StringBuffer buffy = new StringBuffer();
|
|
||||||
buffy.append(oldConfig.getString("coords." + s + ".x"));
|
|
||||||
buffy.append(",");
|
|
||||||
buffy.append(oldConfig.getString("coords." + s + ".y"));
|
|
||||||
buffy.append(",");
|
|
||||||
buffy.append(oldConfig.getString("coords." + s + ".z"));
|
|
||||||
buffy.append(",");
|
|
||||||
buffy.append(oldConfig.getString("coords." + s + ".yaw"));
|
|
||||||
buffy.append(",");
|
|
||||||
buffy.append(oldConfig.getString("coords." + s + ".pitch"));
|
|
||||||
|
|
||||||
config.setProperty("arenas.default.coords." + s, buffy.toString());
|
|
||||||
}
|
|
||||||
config.save();
|
|
||||||
config.load();
|
|
||||||
|
|
||||||
for (String s : oldConfig.getKeys("coords.spawnpoints"))
|
|
||||||
{
|
|
||||||
StringBuffer buffy = new StringBuffer();
|
|
||||||
buffy.append(oldConfig.getString("coords.spawnpoints." + s + ".x"));
|
|
||||||
buffy.append(",");
|
|
||||||
buffy.append(oldConfig.getString("coords.spawnpoints." + s + ".y"));
|
|
||||||
buffy.append(",");
|
|
||||||
buffy.append(oldConfig.getString("coords.spawnpoints." + s + ".z"));
|
|
||||||
buffy.append(",");
|
|
||||||
buffy.append(oldConfig.getString("coords.spawnpoints." + s + ".yaw"));
|
|
||||||
buffy.append(",");
|
|
||||||
buffy.append(oldConfig.getString("coords.spawnpoints." + s + ".pitch"));
|
|
||||||
|
|
||||||
config.setProperty("arenas.default.coords.spawnpoints." + s, buffy.toString());
|
|
||||||
}
|
|
||||||
config.save();
|
|
||||||
config.load();
|
|
||||||
|
|
||||||
System.out.println("[MobArena] Updated the config-file!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,13 +3,12 @@ package com.garbagemule.MobArena;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
public class MobArenaHandler
|
public class MobArenaHandler
|
||||||
{
|
{
|
||||||
MobArena plugin;
|
private MobArena plugin;
|
||||||
boolean ma = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Primary constructor.
|
* Primary constructor.
|
||||||
@@ -17,26 +16,24 @@ public class MobArenaHandler
|
|||||||
*/
|
*/
|
||||||
public MobArenaHandler()
|
public MobArenaHandler()
|
||||||
{
|
{
|
||||||
Plugin maPlugin = (MobArena) Bukkit.getServer().getPluginManager().getPlugin("MobArena");
|
plugin = (MobArena) Bukkit.getServer().getPluginManager().getPlugin("MobArena");
|
||||||
|
|
||||||
if (maPlugin == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ma = true;
|
|
||||||
plugin = (MobArena) maPlugin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
REGION/LOCATION METHODS
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a Location is inside of an arena region.
|
* Check if a Location is inside of any arena region.
|
||||||
* @param loc A location.
|
* @param loc A location.
|
||||||
* @return true, if the Location is inside of any arena region.
|
* @return true, if the Location is inside of any arena region.
|
||||||
*/
|
*/
|
||||||
public boolean inRegion(Location loc)
|
public boolean inRegion(Location loc)
|
||||||
{
|
{
|
||||||
// If the plugin doesn't exist, always return false.
|
|
||||||
if (!ma || plugin.getAM() == null) return false;
|
|
||||||
|
|
||||||
// Return true if location is within just one arena's region.
|
|
||||||
for (Arena arena : plugin.getAM().arenas)
|
for (Arena arena : plugin.getAM().arenas)
|
||||||
if (arena.inRegion(loc))
|
if (arena.inRegion(loc))
|
||||||
return true;
|
return true;
|
||||||
@@ -45,26 +42,50 @@ public class MobArenaHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a Location is inside of a specific arena region.
|
* Check if a Location is inside of a specific arena region (by arena object).
|
||||||
* @param arena An Arena object
|
* @param arena An Arena object
|
||||||
* @param loc A location
|
* @param loc A location
|
||||||
* @return true, if the Location is inside of the arena region.
|
* @return true, if the Location is inside of the arena region.
|
||||||
*/
|
*/
|
||||||
public boolean inRegion(Arena arena, Location loc) { return (ma && arena != null && arena.inRegion(loc)); }
|
public boolean inRegion(Arena arena, Location loc)
|
||||||
|
{
|
||||||
|
return (arena != null && arena.inRegion(loc));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a Location is inside of a specific arena region (by arena name).
|
||||||
|
* @param arenaName The name of an arena
|
||||||
|
* @param loc A location
|
||||||
|
* @return true, if the Location is inside of the arena region.
|
||||||
|
*/
|
||||||
|
public boolean inRegion(String arenaName, Location loc)
|
||||||
|
{
|
||||||
|
Arena arena = plugin.getAM().getArenaWithName(arenaName);
|
||||||
|
if (arena == null)
|
||||||
|
throw new NullPointerException("There is no arena with that name");
|
||||||
|
|
||||||
|
return arena.inRegion(loc);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a Location is inside of the region of an arena that is currently running.
|
* Check if a Location is inside of the region of an arena that is currently running.
|
||||||
* @param loc A location.
|
* @param loc A location.
|
||||||
* @return true, if the Location is inside of the region of an arena that is currently running.
|
* @return true, if the Location is inside of the region of an arena that is currently running.
|
||||||
*/
|
*/
|
||||||
public boolean inRunningRegion(Location loc) { return inRegion(loc, false, true); }
|
public boolean inRunningRegion(Location loc)
|
||||||
|
{
|
||||||
|
return inRegion(loc, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a Location is inside of the region of an arena that is currently enabled.
|
* Check if a Location is inside of the region of an arena that is currently enabled.
|
||||||
* @param loc A location.
|
* @param loc A location.
|
||||||
* @return true, if the Location is inside of the region of an arena that is currently enabled.
|
* @return true, if the Location is inside of the region of an arena that is currently enabled.
|
||||||
*/
|
*/
|
||||||
public boolean inEnabledRegion(Location loc) { return inRegion(loc, true, false); }
|
public boolean inEnabledRegion(Location loc)
|
||||||
|
{
|
||||||
|
return inRegion(loc, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private helper method for inRunningRegion and inEnabledRegion
|
* Private helper method for inRunningRegion and inEnabledRegion
|
||||||
@@ -76,7 +97,7 @@ public class MobArenaHandler
|
|||||||
private boolean inRegion(Location loc, boolean enabled, boolean running)
|
private boolean inRegion(Location loc, boolean enabled, boolean running)
|
||||||
{
|
{
|
||||||
// If the plugin doesn't exist, always return false.
|
// If the plugin doesn't exist, always return false.
|
||||||
if (!ma || plugin.getAM() == null) return false;
|
if (plugin.getAM() == null) return false;
|
||||||
|
|
||||||
// Return true if location is within just one arena's region.
|
// Return true if location is within just one arena's region.
|
||||||
for (Arena arena : plugin.getAM().arenas)
|
for (Arena arena : plugin.getAM().arenas)
|
||||||
@@ -87,40 +108,124 @@ public class MobArenaHandler
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
PLAYER/MONSTER/PET METHODS
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a player is in a MobArena arena (by Player).
|
||||||
|
* @param player The player
|
||||||
|
* @return true, if the player is in an arena
|
||||||
|
*/
|
||||||
|
public boolean isPlayerInArena(Player player)
|
||||||
|
{
|
||||||
|
return (plugin.getAM().getArenaWithPlayer(player) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a player is in a MobArena arena (by name).
|
||||||
|
* @param playerName The name of the player
|
||||||
|
* @return true, if the player is in an arena
|
||||||
|
*/
|
||||||
|
public boolean isPlayerInArena(String playerName)
|
||||||
|
{
|
||||||
|
return (plugin.getAM().getArenaWithPlayer(playerName) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MobArena class of a given player.
|
||||||
|
* @param player The player
|
||||||
|
* @return The class name of the player if the player is in the arena, null otherwise
|
||||||
|
*/
|
||||||
|
public String getPlayerClass(Player player)
|
||||||
|
{
|
||||||
|
Arena arena = plugin.getAM().getArenaWithPlayer(player);
|
||||||
|
if (arena == null) return null;
|
||||||
|
|
||||||
|
return arena.classMap.get(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MobArena class of a given player in a given arena.
|
||||||
|
* This method is faster than the above method, granted the Arena object is known.
|
||||||
|
* @param arena The MobArena arena to check in
|
||||||
|
* @param player The player to look up
|
||||||
|
* @return The class name of the player, if the player is in the arena, null otherwise
|
||||||
|
*/
|
||||||
|
public String getPlayerClass(Arena arena, Player player)
|
||||||
|
{
|
||||||
|
return arena.classMap.get(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a monster is in a MobArena arena.
|
||||||
|
* @param entity The monster entity
|
||||||
|
* @return true, if the monster is in an arena
|
||||||
|
*/
|
||||||
|
public boolean isMonsterInArena(LivingEntity entity)
|
||||||
|
{
|
||||||
|
return plugin.getAM().getArenaWithMonster(entity) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a pet is in a MobArena arena.
|
||||||
|
* @param wolf The pet wolf
|
||||||
|
* @return true, if the pet is in an arena
|
||||||
|
*/
|
||||||
|
public boolean isPetInArena(LivingEntity wolf)
|
||||||
|
{
|
||||||
|
return plugin.getAM().getArenaWithPet(wolf) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ARENA GETTERS
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an Arena object at the given location.
|
* Get an Arena object at the given location.
|
||||||
* @param loc A location
|
* @param loc A location
|
||||||
* @return an Arena object, or null
|
* @return an Arena object, or null
|
||||||
*/
|
*/
|
||||||
public Arena getArenaAtLocation(Location loc) { return (ma) ? plugin.getAM().getArenaAtLocation(loc) : null; }
|
public Arena getArenaAtLocation(Location loc)
|
||||||
|
{
|
||||||
|
return plugin.getAM().getArenaAtLocation(loc);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Arena object that the given player is currently in.
|
* Get the Arena object that the given player is currently in.
|
||||||
* @param p A player
|
* @param p A player
|
||||||
* @return an Arena object, or null
|
* @return an Arena object, or null
|
||||||
*/
|
*/
|
||||||
public Arena getArenaWithPlayer(Player p) { return (ma) ? plugin.getAM().getArenaWithPlayer(p) : null; }
|
public Arena getArenaWithPlayer(Player p)
|
||||||
|
{
|
||||||
|
return plugin.getAM().getArenaWithPlayer(p);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Arena object that the given pet is currently in.
|
* Get the Arena object that the given pet is currently in.
|
||||||
* @param wolf A pet wolf
|
* @param wolf A pet wolf
|
||||||
* @return an Arena object, or null
|
* @return an Arena object, or null
|
||||||
*/
|
*/
|
||||||
public Arena getArenaWithPet(Entity wolf) { return (ma) ? plugin.getAM().getArenaWithPet(wolf) : null; }
|
public Arena getArenaWithPet(Entity wolf)
|
||||||
|
{
|
||||||
|
return plugin.getAM().getArenaWithPet(wolf);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Arena object that the given monster is currently in.
|
* Get the Arena object that the given monster is currently in.
|
||||||
* @param monster A monster
|
* @param monster A monster
|
||||||
* @return an Arena object, or null
|
* @return an Arena object, or null
|
||||||
*/
|
*/
|
||||||
public Arena getArenaWithMonster(Entity monster) { return (ma) ? plugin.getAM().getArenaWithMonster(monster) : null; }
|
public Arena getArenaWithMonster(Entity monster)
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the server is running MobArena.
|
|
||||||
* @return true, if MobArena exists on the server.
|
|
||||||
*/
|
|
||||||
public boolean hasMA()
|
|
||||||
{
|
{
|
||||||
return ma;
|
return plugin.getAM().getArenaWithMonster(monster);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ package com.garbagemule.MobArena;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.garbagemule.MobArena.waves.Wave.WaveBranch;
|
||||||
|
import com.garbagemule.MobArena.waves.Wave.WaveType;
|
||||||
|
|
||||||
public class MobArenaListener
|
public class MobArenaListener
|
||||||
{
|
{
|
||||||
protected MobArena plugin;
|
protected MobArena plugin;
|
||||||
@@ -13,11 +16,10 @@ public class MobArenaListener
|
|||||||
plugin.getAM().listeners.add(this);
|
plugin.getAM().listeners.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onArenaStart() {}
|
public void onArenaStart(Arena arena) {}
|
||||||
public void onArenaEnd() {}
|
public void onArenaEnd(Arena arena) {}
|
||||||
public void onDefaultWave(int waveNumber) {}
|
public void onWave(Arena arena, int waveNumber, String waveName, WaveBranch waveBranch, WaveType waveType) {}
|
||||||
public void onSpecialWave(int waveNumber, int specialwaveNumber) {}
|
public void onPlayerJoin(Arena arena, Player p) {}
|
||||||
public void onPlayerJoin(Player p) {}
|
public void onPlayerLeave(Arena arena, Player p) {}
|
||||||
public void onPlayerLeave(Player p) {}
|
public void onPlayerDeath(Arena arena, Player p) {}
|
||||||
public void onPlayerDeath(Player p) {}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.garbagemule.MobArena.repairable;
|
||||||
|
|
||||||
|
//import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
|
||||||
|
public interface Repairable// extends Serializable
|
||||||
|
{
|
||||||
|
public void repair();
|
||||||
|
|
||||||
|
public BlockState getState();
|
||||||
|
|
||||||
|
public Material getType();
|
||||||
|
public int getId();
|
||||||
|
public byte getData();
|
||||||
|
|
||||||
|
public World getWorld();
|
||||||
|
public int getX();
|
||||||
|
public int getY();
|
||||||
|
public int getZ();
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.garbagemule.MobArena.repairable;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.material.Attachable;
|
||||||
|
|
||||||
|
public class RepairableAttachable extends RepairableBlock
|
||||||
|
{
|
||||||
|
private int x, y, z;
|
||||||
|
|
||||||
|
public RepairableAttachable(BlockState state)
|
||||||
|
{
|
||||||
|
super(state);
|
||||||
|
|
||||||
|
BlockState attached;
|
||||||
|
if (state.getData() instanceof Attachable)
|
||||||
|
attached = state.getBlock().getRelative(((Attachable) state.getData()).getAttachedFace()).getState();
|
||||||
|
else
|
||||||
|
attached = state.getBlock().getRelative(BlockFace.DOWN).getState();
|
||||||
|
|
||||||
|
x = attached.getX();
|
||||||
|
y = attached.getY();
|
||||||
|
z = attached.getZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void repair()
|
||||||
|
{
|
||||||
|
Block b = getWorld().getBlockAt(x,y,z);
|
||||||
|
if (b.getTypeId() == 0)
|
||||||
|
b.setTypeId(1);
|
||||||
|
|
||||||
|
super.repair();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.garbagemule.MobArena.repairable;
|
||||||
|
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.material.Bed;
|
||||||
|
|
||||||
|
public class RepairableBed extends RepairableBlock
|
||||||
|
{
|
||||||
|
private BlockState other;
|
||||||
|
|
||||||
|
public RepairableBed(BlockState state)
|
||||||
|
{
|
||||||
|
super(state);
|
||||||
|
other = state.getBlock().getRelative(((Bed) state.getData()).getFacing()).getState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void repair()
|
||||||
|
{
|
||||||
|
if (getWorld().getBlockAt(getX(), getY(), getZ()).getState().getData() instanceof Bed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
super.repair();
|
||||||
|
other.getBlock().setTypeIdAndData(getId(), (byte) (getData() + 8), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user