mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Fixed: Little language bug
This commit is contained in:
parent
53c58b574f
commit
84dfb069e6
@ -12,15 +12,15 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
import com.dre.dungeonsxl.game.GameWorld;
|
||||||
|
|
||||||
public class DGSign {
|
public class DGSign {
|
||||||
public static CopyOnWriteArrayList<DGSign> dgsigns=new CopyOnWriteArrayList<DGSign>();
|
public static CopyOnWriteArrayList<DGSign> dgsigns=new CopyOnWriteArrayList<DGSign>();
|
||||||
|
|
||||||
//Sign Labels
|
//Sign Labels
|
||||||
public static String strIsPlaying=ChatColor.DARK_RED + "Is Playing";
|
public static String strIsPlaying=ChatColor.DARK_RED + "Is Playing";
|
||||||
public static String strFull=ChatColor.DARK_RED + "Full";
|
public static String strFull=ChatColor.DARK_RED + "Full";
|
||||||
public static String strJoinGrp=ChatColor.DARK_GREEN + "Join Group";
|
public static String strJoinGrp=ChatColor.DARK_GREEN + "Join Group";
|
||||||
public static String strNewGrp=ChatColor.DARK_GREEN + "New Group";
|
public static String strNewGrp=ChatColor.DARK_GREEN + "New Group";
|
||||||
|
|
||||||
//Variables
|
//Variables
|
||||||
public DGroup[] dgroups;
|
public DGroup[] dgroups;
|
||||||
public String dungeonName;
|
public String dungeonName;
|
||||||
@ -28,32 +28,32 @@ public class DGSign {
|
|||||||
public Block startSign;
|
public Block startSign;
|
||||||
public int directionX=0,directionZ=0;
|
public int directionX=0,directionZ=0;
|
||||||
public int verticalSigns;
|
public int verticalSigns;
|
||||||
|
|
||||||
public DGSign(Block startSign,String dungeonName, int maxGroups, int maxPlayersPerGroup){
|
public DGSign(Block startSign,String dungeonName, int maxGroups, int maxPlayersPerGroup){
|
||||||
dgsigns.add(this);
|
dgsigns.add(this);
|
||||||
|
|
||||||
this.startSign=startSign;
|
this.startSign=startSign;
|
||||||
this.dungeonName=dungeonName;
|
this.dungeonName=dungeonName;
|
||||||
this.dgroups=new DGroup[maxGroups];
|
this.dgroups=new DGroup[maxGroups];
|
||||||
this.maxPlayersPerGroup=maxPlayersPerGroup;
|
this.maxPlayersPerGroup=maxPlayersPerGroup;
|
||||||
this.verticalSigns=(int)Math.ceil((float)(1+maxPlayersPerGroup)/4);
|
this.verticalSigns=(int)Math.ceil((float)(1+maxPlayersPerGroup)/4);
|
||||||
|
|
||||||
int[] direction=getDirection(this.startSign.getData());
|
int[] direction=getDirection(this.startSign.getData());
|
||||||
this.directionX=direction[0];
|
this.directionX=direction[0];
|
||||||
this.directionZ=direction[1];
|
this.directionZ=direction[1];
|
||||||
|
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(){
|
public void update(){
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(DGroup dgroup:this.dgroups){
|
for(DGroup dgroup:this.dgroups){
|
||||||
if((this.startSign.getRelative(i*directionX, 0, i*directionZ).getState() instanceof Sign)){
|
if((this.startSign.getRelative(i*directionX, 0, i*directionZ).getState() instanceof Sign)){
|
||||||
Sign sign = (Sign) this.startSign.getRelative(i*directionX, 0, i*directionZ).getState();
|
Sign sign = (Sign) this.startSign.getRelative(i*directionX, 0, i*directionZ).getState();
|
||||||
|
|
||||||
//Reset Signs
|
//Reset Signs
|
||||||
sign.setLine(0, "");sign.setLine(1, "");sign.setLine(2, "");sign.setLine(3, "");
|
sign.setLine(0, "");sign.setLine(1, "");sign.setLine(2, "");sign.setLine(3, "");
|
||||||
|
|
||||||
int yy=-1;
|
int yy=-1;
|
||||||
while(sign.getBlock().getRelative(0, yy, 0).getState() instanceof Sign){
|
while(sign.getBlock().getRelative(0, yy, 0).getState() instanceof Sign){
|
||||||
Sign subsign=(Sign)sign.getBlock().getRelative(0, yy, 0).getState();
|
Sign subsign=(Sign)sign.getBlock().getRelative(0, yy, 0).getState();
|
||||||
@ -61,7 +61,7 @@ public class DGSign {
|
|||||||
subsign.update();
|
subsign.update();
|
||||||
yy--;
|
yy--;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set Signs
|
//Set Signs
|
||||||
if(dgroup!=null){
|
if(dgroup!=null){
|
||||||
if(dgroup.isPlaying){
|
if(dgroup.isPlaying){
|
||||||
@ -92,19 +92,19 @@ public class DGSign {
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Static
|
//Static
|
||||||
|
|
||||||
public static DGSign tryToCreate(Block startSign,String dungeonName, int maxGroups, int maxPlayersPerGroup){
|
public static DGSign tryToCreate(Block startSign,String dungeonName, int maxGroups, int maxPlayersPerGroup){
|
||||||
World world=startSign.getWorld();
|
World world=startSign.getWorld();
|
||||||
int direction=startSign.getData();
|
int direction=startSign.getData();
|
||||||
int x=startSign.getX(),y=startSign.getY(),z=startSign.getZ();
|
int x=startSign.getX(),y=startSign.getY(),z=startSign.getZ();
|
||||||
|
|
||||||
int verticalSigns=(int)Math.ceil((float)(1+maxPlayersPerGroup)/4);
|
int verticalSigns=(int)Math.ceil((float)(1+maxPlayersPerGroup)/4);
|
||||||
|
|
||||||
CopyOnWriteArrayList<Block> changeBlocks=new CopyOnWriteArrayList<Block>();
|
CopyOnWriteArrayList<Block> changeBlocks=new CopyOnWriteArrayList<Block>();
|
||||||
|
|
||||||
int xx,yy,zz;
|
int xx,yy,zz;
|
||||||
switch(direction){
|
switch(direction){
|
||||||
case 2:
|
case 2:
|
||||||
@ -126,7 +126,7 @@ public class DGSign {
|
|||||||
zz=z;
|
zz=z;
|
||||||
for(yy=y;yy>y-verticalSigns;yy--){
|
for(yy=y;yy>y-verticalSigns;yy--){
|
||||||
for(xx=x;xx<x+maxGroups;xx++){
|
for(xx=x;xx<x+maxGroups;xx++){
|
||||||
|
|
||||||
Block block=world.getBlockAt(xx,yy,zz);
|
Block block=world.getBlockAt(xx,yy,zz);
|
||||||
if(block.getTypeId()!=0 && block.getTypeId()!=68){
|
if(block.getTypeId()!=0 && block.getTypeId()!=68){
|
||||||
return null;
|
return null;
|
||||||
@ -174,10 +174,10 @@ public class DGSign {
|
|||||||
block.setTypeIdAndData(68, startSign.getData(), true);
|
block.setTypeIdAndData(68, startSign.getData(), true);
|
||||||
}
|
}
|
||||||
DGSign sign=new DGSign(startSign,dungeonName,maxGroups,maxPlayersPerGroup);
|
DGSign sign=new DGSign(startSign,dungeonName,maxGroups,maxPlayersPerGroup);
|
||||||
|
|
||||||
return sign;
|
return sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRelativeSign(Block block,int x,int z){
|
public static boolean isRelativeSign(Block block,int x,int z){
|
||||||
DGSign dgsign=getSign(block.getRelative(x,0,z));
|
DGSign dgsign=getSign(block.getRelative(x,0,z));
|
||||||
if(dgsign!=null){
|
if(dgsign!=null){
|
||||||
@ -186,10 +186,10 @@ public class DGSign {
|
|||||||
if(z==-1 && dgsign.startSign.getData()==2) return true;
|
if(z==-1 && dgsign.startSign.getData()==2) return true;
|
||||||
if(z==1 && dgsign.startSign.getData()==3) return true;
|
if(z==1 && dgsign.startSign.getData()==3) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DGSign getSign(Block block){
|
public static DGSign getSign(Block block){
|
||||||
if(block.getTypeId()==68){
|
if(block.getTypeId()==68){
|
||||||
int x=block.getX(),y=block.getY(),z=block.getZ();
|
int x=block.getX(),y=block.getY(),z=block.getZ();
|
||||||
@ -198,33 +198,33 @@ public class DGSign {
|
|||||||
int sx2=sx1+(dgsign.dgroups.length-1)*dgsign.directionX;
|
int sx2=sx1+(dgsign.dgroups.length-1)*dgsign.directionX;
|
||||||
int sy2=sy1-dgsign.verticalSigns+1;
|
int sy2=sy1-dgsign.verticalSigns+1;
|
||||||
int sz2=sz1+(dgsign.dgroups.length-1)*dgsign.directionZ;
|
int sz2=sz1+(dgsign.dgroups.length-1)*dgsign.directionZ;
|
||||||
|
|
||||||
if(sx1>sx2){if(x<sx2 || x>sx1) continue;}else if(sx1<sx2){if(x>sx2 || x<sx1) continue;}else{if(x!=sx1) continue;}
|
if(sx1>sx2){if(x<sx2 || x>sx1) continue;}else if(sx1<sx2){if(x>sx2 || x<sx1) continue;}else{if(x!=sx1) continue;}
|
||||||
if(sy1>sy2){if(y<sy2 || y>sy1) continue;}else{if(y!=sy1) continue;}
|
if(sy1>sy2){if(y<sy2 || y>sy1) continue;}else{if(y!=sy1) continue;}
|
||||||
if(sz1>sz2){if(z<sz2 || z>sz1) continue;}else if(sz1<sz2){if(z>sz2 || z<sz1) continue;}else{if(z!=sz1) continue;}
|
if(sz1>sz2){if(z<sz2 || z>sz1) continue;}else if(sz1<sz2){if(z>sz2 || z<sz1) continue;}else{if(z!=sz1) continue;}
|
||||||
|
|
||||||
return dgsign;
|
return dgsign;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean playerInteract(Block block,Player player){
|
public static boolean playerInteract(Block block,Player player){
|
||||||
int x=block.getX(),y=block.getY(),z=block.getZ();
|
int x=block.getX(),y=block.getY(),z=block.getZ();
|
||||||
DGSign dgsign=getSign(block);
|
DGSign dgsign=getSign(block);
|
||||||
if(dgsign!=null){
|
if(dgsign!=null){
|
||||||
if(GameWorld.canPlayDungeon(dgsign.dungeonName, player)){
|
if(GameWorld.canPlayDungeon(dgsign.dungeonName, player)){
|
||||||
int sx1=dgsign.startSign.getX(),sy1=dgsign.startSign.getY(),sz1=dgsign.startSign.getZ();
|
int sx1=dgsign.startSign.getX(),sy1=dgsign.startSign.getY(),sz1=dgsign.startSign.getZ();
|
||||||
|
|
||||||
Block topBlock=block.getRelative(0, sy1-y, 0);
|
Block topBlock=block.getRelative(0, sy1-y, 0);
|
||||||
|
|
||||||
int column;
|
int column;
|
||||||
if(dgsign.directionX!=0){
|
if(dgsign.directionX!=0){
|
||||||
column=Math.abs(x-sx1);
|
column=Math.abs(x-sx1);
|
||||||
}else{
|
}else{
|
||||||
column=Math.abs(z-sz1);
|
column=Math.abs(z-sz1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((topBlock.getState() instanceof Sign)){
|
if((topBlock.getState() instanceof Sign)){
|
||||||
Sign topSign=(Sign)topBlock.getState();
|
Sign topSign=(Sign)topBlock.getState();
|
||||||
if(topSign.getLine(0).equals(strNewGrp)){
|
if(topSign.getLine(0).equals(strNewGrp)){
|
||||||
@ -240,7 +240,7 @@ public class DGSign {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -248,19 +248,19 @@ public class DGSign {
|
|||||||
if(file!=null){
|
if(file!=null){
|
||||||
ConfigReader confReader=new ConfigReader(file);
|
ConfigReader confReader=new ConfigReader(file);
|
||||||
if(confReader!=null){
|
if(confReader!=null){
|
||||||
P.p.msg(player, P.p.language.get("player_join_error"));
|
P.p.msg(player, P.p.language.get("player_join_error",""+confReader.timeToNextPlay));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updatePerGroup(DGroup dgroupsearch){
|
public static void updatePerGroup(DGroup dgroupsearch){
|
||||||
|
|
||||||
for(DGSign dgsign:dgsigns){
|
for(DGSign dgsign:dgsigns){
|
||||||
int i=0;
|
int i=0;
|
||||||
for(DGroup dgroup:dgsign.dgroups){
|
for(DGroup dgroup:dgsign.dgroups){
|
||||||
@ -274,7 +274,7 @@ public class DGSign {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[] getDirection(byte data){
|
public static int[] getDirection(byte data){
|
||||||
int[] direction=new int[2];
|
int[] direction=new int[2];
|
||||||
switch(data){
|
switch(data){
|
||||||
@ -293,25 +293,25 @@ public class DGSign {
|
|||||||
}
|
}
|
||||||
return direction;
|
return direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save and Load
|
//Save and Load
|
||||||
public static void save(FileConfiguration configFile){
|
public static void save(FileConfiguration configFile){
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
|
||||||
for(DGSign dgsign:dgsigns){
|
for(DGSign dgsign:dgsigns){
|
||||||
id++;
|
id++;
|
||||||
String preString="groupsign."+dgsign.startSign.getWorld().getName()+"."+id;
|
String preString="groupsign."+dgsign.startSign.getWorld().getName()+"."+id;
|
||||||
|
|
||||||
//Location
|
//Location
|
||||||
configFile.set(preString+".x",dgsign.startSign.getX());
|
configFile.set(preString+".x",dgsign.startSign.getX());
|
||||||
configFile.set(preString+".y",dgsign.startSign.getY());
|
configFile.set(preString+".y",dgsign.startSign.getY());
|
||||||
configFile.set(preString+".z",dgsign.startSign.getZ());
|
configFile.set(preString+".z",dgsign.startSign.getZ());
|
||||||
|
|
||||||
//Etc.
|
//Etc.
|
||||||
configFile.set(preString+".dungeon",dgsign.dungeonName);
|
configFile.set(preString+".dungeon",dgsign.dungeonName);
|
||||||
configFile.set(preString+".maxGroups",dgsign.dgroups.length);
|
configFile.set(preString+".maxGroups",dgsign.dgroups.length);
|
||||||
configFile.set(preString+".maxPlayersPerGroup",dgsign.maxPlayersPerGroup);
|
configFile.set(preString+".maxPlayersPerGroup",dgsign.maxPlayersPerGroup);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,19 +323,19 @@ public class DGSign {
|
|||||||
do{
|
do{
|
||||||
id++;
|
id++;
|
||||||
preString="groupsign."+world.getName()+"."+id+".";
|
preString="groupsign."+world.getName()+"."+id+".";
|
||||||
if(configFile.contains(preString)){
|
if(configFile.contains(preString)){
|
||||||
String dungeonName=configFile.getString(preString+".dungeon");
|
String dungeonName=configFile.getString(preString+".dungeon");
|
||||||
int maxGroups=configFile.getInt(preString+".maxGroups");
|
int maxGroups=configFile.getInt(preString+".maxGroups");
|
||||||
int maxPlayersPerGroup=configFile.getInt(preString+".maxPlayersPerGroup");
|
int maxPlayersPerGroup=configFile.getInt(preString+".maxPlayersPerGroup");
|
||||||
Block startSign=world.getBlockAt(configFile.getInt(preString+".x"),configFile.getInt(preString+".y"),configFile.getInt(preString+".z"));
|
Block startSign=world.getBlockAt(configFile.getInt(preString+".x"),configFile.getInt(preString+".y"),configFile.getInt(preString+".z"));
|
||||||
|
|
||||||
new DGSign(startSign, dungeonName, maxGroups, maxPlayersPerGroup);
|
new DGSign(startSign, dungeonName, maxGroups, maxPlayersPerGroup);
|
||||||
}
|
}
|
||||||
}while(configFile.contains(preString));
|
}while(configFile.contains(preString));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user