Added Spout sounds

This commit is contained in:
Grafe 2013-01-18 02:21:23 +01:00
parent affbe91352
commit 7c978bab0c
2 changed files with 24 additions and 3 deletions

View File

@ -3,6 +3,9 @@ package com.dre.dungeonsxl.game;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.block.Block;
import org.getspout.spoutapi.Spout;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.dre.dungeonsxl.DPlayer;
import com.dre.dungeonsxl.P;
@ -17,12 +20,14 @@ public class GameMessage {
public String msg;
public GameWorld gworld;
public int radius;
public boolean isSpoutSoundMsg;
public GameMessage(Block block, int msgid,GameWorld gworld,int radius){
public GameMessage(Block block, int msgid,GameWorld gworld,int radius,boolean isSpoutSoundMsg){
this.block=block;
this.msg=gworld.config.getMsg(msgid);
this.gworld=gworld;
this.radius=radius;
this.isSpoutSoundMsg=isSpoutSoundMsg;
if(this.msg!=null){
gmessages.add(this);
@ -37,8 +42,18 @@ public class GameMessage {
for(DPlayer dplayer:DPlayer.get(gmessage.gworld.world)){
if(!gmessage.playerDone.contains(dplayer)){
if(dplayer.player.getLocation().distance(gmessage.block.getLocation())<gmessage.radius+1){
P.p.msg(dplayer.player, gmessage.msg);
gmessage.playerDone.add(dplayer);
if(gmessage.isSpoutSoundMsg){
if(P.p.isSpoutEnabled){
SpoutPlayer sPlayer = Spout.getServer().getPlayer(dplayer.player.getName());
if(sPlayer.isSpoutCraftEnabled()){
SpoutManager.getSoundManager().playCustomMusic(P.p, sPlayer, gmessage.msg, false, gmessage.block.getLocation());
}
}
} else {
P.p.msg(dplayer.player, gmessage.msg);
}
}
}
}

View File

@ -187,7 +187,13 @@ public class GameWorld {
}
if(lines[1].equalsIgnoreCase("msg")){
if(lines[2]!=""&&lines[3]!=""){
new GameMessage(block,p.parseInt(lines[2]),this,p.parseInt(lines[3]));
new GameMessage(block,p.parseInt(lines[2]),this,p.parseInt(lines[3]),false);
block.setTypeId(0);
}
}
if(lines[1].equalsIgnoreCase("soundmsg")){
if(lines[2]!=""&&lines[3]!=""){
new GameMessage(block,p.parseInt(lines[2]),this,p.parseInt(lines[3]),true);
block.setTypeId(0);
}
}