Moved GameMessage to SIGNMsg and SIGNSoundMsg

Signed-off-by: Grafe <flingelfrank@hotmail.com>
This commit is contained in:
Grafe 2013-03-26 13:37:43 +01:00
parent 7846ecdc74
commit 26a9772f34
4 changed files with 25 additions and 70 deletions

View File

@ -1,57 +0,0 @@
package com.dre.dungeonsxl.game;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.Location;
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;
public class GameMessage {
//Variables
public CopyOnWriteArrayList<DPlayer> playerDone=new CopyOnWriteArrayList<DPlayer>();
public Location location;
public String msg;
public int radius;
public boolean isSpoutSoundMsg;
public GameMessage(Location location, String msg,int radius,boolean isSpoutSoundMsg){
this.location=location;
this.msg = msg;
this.radius=radius;
this.isSpoutSoundMsg=isSpoutSoundMsg;
}
//Static
public static void update(GameWorld gworld){
for(GameMessage gmessage:gworld.messages){
for(DPlayer dplayer:DPlayer.get(gworld.world)){
if(!gmessage.playerDone.contains(dplayer)){
if(dplayer.player.getLocation().distance(gmessage.location)<gmessage.radius+1){
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.location);
}
}
} else {
P.p.msg(dplayer.player, gmessage.msg);
}
}
}
}
}
}
}

View File

@ -46,7 +46,6 @@ public class GameWorld {
public int id;
public CopyOnWriteArrayList<Material> secureObjects = new CopyOnWriteArrayList<Material>();
public CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<Chunk>();
public CopyOnWriteArrayList<GameMessage> messages = new CopyOnWriteArrayList<GameMessage>();
public CopyOnWriteArrayList<Sign> signClass=new CopyOnWriteArrayList<Sign>();
public CopyOnWriteArrayList<DMob> dmobs = new CopyOnWriteArrayList<DMob>();
@ -224,9 +223,6 @@ public class GameWorld {
public static void update(){
for(GameWorld gworld:gworlds){
//Update Messages
GameMessage.update(gworld);
//Update Spiders
for(LivingEntity mob:gworld.world.getLivingEntities()){
if(mob.getType()==EntityType.SPIDER){

View File

@ -1,8 +1,7 @@
package com.dre.dungeonsxl.signs;
import org.bukkit.block.Sign;
import com.dre.dungeonsxl.game.GameMessage;
import org.bukkit.entity.Player;
import com.dre.dungeonsxl.game.GameWorld;
public class SIGNMsg extends DSign{
@ -11,6 +10,9 @@ public class SIGNMsg extends DSign{
public static String buildPermissions = "dxl.sign.msg";
public static boolean onDungeonInit = false;
//Variables
private String msg;
public SIGNMsg(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@ -29,7 +31,7 @@ public class SIGNMsg extends DSign{
if(lines[1]!=""&&lines[2]!=""){
String msg = gworld.config.getMsg(p.parseInt(lines[1]),true);
if(msg!=null){
gworld.messages.add(new GameMessage(sign.getBlock().getLocation(), msg,p.parseInt(lines[2]), false));
this.msg = msg;
sign.setTypeId(0);
}
}
@ -37,7 +39,8 @@ public class SIGNMsg extends DSign{
@Override
public void onTrigger() {
// TODO Auto-generated method stub
for(Player player : gworld.world.getPlayers()){
p.msg(player, msg);
}
}
}

View File

@ -1,8 +1,12 @@
package com.dre.dungeonsxl.signs;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.Spout;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.dre.dungeonsxl.game.GameMessage;
import com.dre.dungeonsxl.P;
import com.dre.dungeonsxl.game.GameWorld;
public class SIGNSoundMsg extends DSign{
@ -11,6 +15,9 @@ public class SIGNSoundMsg extends DSign{
public static String buildPermissions = "dxl.sign.soundmsg";
public static boolean onDungeonInit = false;
//Variables
private String msg;
public SIGNSoundMsg(Sign sign, GameWorld gworld) {
super(sign, gworld);
}
@ -29,7 +36,7 @@ public class SIGNSoundMsg extends DSign{
if(lines[1]!=""&&lines[2]!=""){
String msg = gworld.config.getMsg(p.parseInt(lines[1]),true);
if(msg!=null){
gworld.messages.add(new GameMessage(sign.getBlock().getLocation(), msg,p.parseInt(lines[2]), true));
this.msg = msg;
sign.setTypeId(0);
}
}
@ -37,7 +44,13 @@ public class SIGNSoundMsg extends DSign{
@Override
public void onTrigger() {
// TODO Auto-generated method stub
if(P.p.isSpoutEnabled){
for(Player player : gworld.world.getPlayers()){
SpoutPlayer sPlayer = Spout.getServer().getPlayer(player.getName());
if(sPlayer.isSpoutCraftEnabled()){
SpoutManager.getSoundManager().playCustomMusic(P.p, sPlayer, this.msg, false, this.sign.getLocation());
}
}
}
}
}