Changed GameMessages update method

This commit is contained in:
Grafe 2013-01-18 03:08:55 +01:00
parent cdf8331dbe
commit 1e3482fe3c
5 changed files with 32 additions and 38 deletions

View File

@ -123,8 +123,8 @@ public class DConfig {
}
/* Secure Objects */
if(configFile.contains("secureobjects")){
List<Integer> secureobjectlist = configFile.getIntegerList("secureobjects");
if(configFile.contains("secureObjects")){
List<Integer> secureobjectlist = configFile.getIntegerList("secureObjects");
for(int i:secureobjectlist){
this.secureObjects.add(Material.getMaterial(i));
}
@ -172,13 +172,13 @@ public class DConfig {
}
//Secure Objects
CopyOnWriteArrayList<Integer> secureobjectsids=new CopyOnWriteArrayList<Integer>();
CopyOnWriteArrayList<Integer> secureObjectsids=new CopyOnWriteArrayList<Integer>();
for(Material mat:this.secureObjects){
secureobjectsids.add(mat.getId());
secureObjectsids.add(mat.getId());
}
configFile.set("secureobjects", secureobjectsids);
configFile.set("secureObjects", secureObjectsids);
//Invited Players
configFile.set("invitedplayers", this.invitedPlayers);

View File

@ -189,7 +189,7 @@ public class DPlayer {
if(groupplayer!=null){
for(ItemStack istack:this.player.getInventory()){
if(istack!=null){
if(gworld.secureobjects.contains(istack.getType())){
if(gworld.secureObjects.contains(istack.getType())){
groupplayer.getInventory().addItem(istack);
}
}

View File

@ -27,7 +27,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.dre.dungeonsxl.commands.DCommandRoot;
import com.dre.dungeonsxl.game.GameCheckpoint;
import com.dre.dungeonsxl.game.GameMessage;
import com.dre.dungeonsxl.game.GameWorld;
import com.dre.dungeonsxl.game.MobSpawner;
import com.dre.dungeonsxl.listener.BlockListener;
@ -141,7 +140,6 @@ public class P extends JavaPlugin{
LeaveSign.lsigns.clear();
DCommandRoot.root.commands.clear();
GameCheckpoint.gcheckpoints.clear();
GameMessage.gmessages.clear();
MobSpawner.mobspawners.clear();
//Delete Worlds
@ -192,10 +190,9 @@ public class P extends JavaPlugin{
public void run() {
MobSpawner.updateAll();
GameWorld.update();
GameMessage.updateAll();
GameCheckpoint.update();
DPlayer.update(true);
//Tutorial Mode
if(p.mainConfig.tutorialActivated){
for(Player player:p.getServer().getOnlinePlayers()){

View File

@ -2,7 +2,7 @@ package com.dre.dungeonsxl.game;
import java.util.concurrent.CopyOnWriteArrayList;
import org.bukkit.block.Block;
import org.bukkit.Location;
import org.getspout.spoutapi.Spout;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
@ -11,44 +11,37 @@ import com.dre.dungeonsxl.DPlayer;
import com.dre.dungeonsxl.P;
public class GameMessage {
public static CopyOnWriteArrayList<GameMessage> gmessages=new CopyOnWriteArrayList<GameMessage>();
//Variables
public CopyOnWriteArrayList<DPlayer> playerDone=new CopyOnWriteArrayList<DPlayer>();
public Block block;
public Location location;
public String msg;
public GameWorld gworld;
public int radius;
public boolean isSpoutSoundMsg;
public GameMessage(Block block, int msgid,GameWorld gworld,int radius,boolean isSpoutSoundMsg){
this.block=block;
this.msg=gworld.config.getMsg(msgid);
this.gworld=gworld;
public GameMessage(Location location, String msg,int radius,boolean isSpoutSoundMsg){
this.location=location;
this.msg = msg;
this.radius=radius;
this.isSpoutSoundMsg=isSpoutSoundMsg;
if(this.msg!=null){
gmessages.add(this);
}
}
//Static
public static void updateAll(){
for(GameMessage gmessage:gmessages){
for(DPlayer dplayer:DPlayer.get(gmessage.gworld.world)){
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.block.getLocation())<gmessage.radius+1){
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.block.getLocation());
SpoutManager.getSoundManager().playCustomMusic(P.p, sPlayer, gmessage.msg, false, gmessage.location);
}
}
} else {

View File

@ -46,8 +46,9 @@ public class GameWorld {
public CopyOnWriteArrayList<Block> blocksLeave=new CopyOnWriteArrayList<Block>();
public boolean isPlaying=false;
public int id;
public CopyOnWriteArrayList<Material> secureobjects = new CopyOnWriteArrayList<Material>();
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>();
@ -187,14 +188,20 @@ 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]),false);
block.setTypeId(0);
String msg = config.getMsg(p.parseInt(lines[2]));
if(msg!=null){
messages.add(new GameMessage(block.getLocation(),msg,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);
String msg = config.getMsg(p.parseInt(lines[2]));
if(msg!=null){
messages.add(new GameMessage(block.getLocation(),msg,p.parseInt(lines[3]),true));
block.setTypeId(0);
}
}
}
if(lines[1].equalsIgnoreCase("checkpoint")){
@ -246,10 +253,8 @@ public class GameWorld {
this.checkSign(block);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@ -308,7 +313,6 @@ public class GameWorld {
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@ -352,7 +356,7 @@ public class GameWorld {
gworld.config = new DConfig(new File(p.getDataFolder()+"/dungeons/"+gworld.dungeonname, "config.yml"));
//Secure Objects
gworld.secureobjects=gworld.config.secureObjects;
gworld.secureObjects=gworld.config.secureObjects;
//World
p.copyDirectory(file,new File("DXL_Game_"+gworld.id));
@ -375,10 +379,8 @@ public class GameWorld {
os.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@ -390,6 +392,8 @@ public class GameWorld {
public static void update(){
for(GameWorld gworld:gworlds){
//Update Messages
GameMessage.update(gworld);
//Update Spiders
for(LivingEntity mob:gworld.world.getLivingEntities()){