mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-12-01 06:53:26 +01:00
Started with chunkupdater sign
Fixed parseInt error
This commit is contained in:
parent
186719d879
commit
affbe91352
@ -67,15 +67,15 @@ public class DConfig {
|
||||
|
||||
//Check Id & Data
|
||||
String[] idAndData=itemsplit[0].split("/");
|
||||
itemId=Integer.parseInt(idAndData[0]);
|
||||
itemId=P.p.parseInt(idAndData[0]);
|
||||
|
||||
if(idAndData.length>1){
|
||||
itemData=Integer.parseInt(idAndData[1]);
|
||||
itemData=P.p.parseInt(idAndData[1]);
|
||||
}
|
||||
|
||||
//Size
|
||||
if(itemsplit.length>1){
|
||||
itemSize=Integer.parseInt(itemsplit[1]);
|
||||
itemSize=P.p.parseInt(itemsplit[1]);
|
||||
}
|
||||
|
||||
//Enchantment
|
||||
@ -85,7 +85,7 @@ public class DConfig {
|
||||
itemEnchantment=Enchantment.getByName(enchantmentSplit[0]);
|
||||
|
||||
if(enchantmentSplit.length>1){
|
||||
itemLvlEnchantment=Integer.parseInt(enchantmentSplit[1]);
|
||||
itemLvlEnchantment=P.p.parseInt(enchantmentSplit[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ public class DConfig {
|
||||
if (configSetionMessages != null) {
|
||||
Set<String> list = configSetionMessages.getKeys(false);
|
||||
for (String messagePath:list) {
|
||||
int messageId = Integer.parseInt(messagePath);
|
||||
int messageId = P.p.parseInt(messagePath);
|
||||
this.msgs.put(messageId,configSetionMessages.getString(messagePath));
|
||||
}
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ public class DMobType {
|
||||
String[] splittedEnchantment = enchantment.split(" ");
|
||||
if(Enchantment.getByName(splittedEnchantment[0].toUpperCase())!=null){
|
||||
if (splittedEnchantment.length>1) {
|
||||
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), Integer.parseInt(splittedEnchantment[1]), true);
|
||||
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), P.p.parseInt(splittedEnchantment[1]), true);
|
||||
} else {
|
||||
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), 1, true);
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -32,6 +34,7 @@ import com.dre.dungeonsxl.listener.BlockListener;
|
||||
import com.dre.dungeonsxl.listener.CommandListener;
|
||||
import com.dre.dungeonsxl.listener.EntityListener;
|
||||
import com.dre.dungeonsxl.listener.PlayerListener;
|
||||
import com.dre.dungeonsxl.listener.WorldListener;
|
||||
|
||||
public class P extends JavaPlugin{
|
||||
public static P p;
|
||||
@ -40,6 +43,7 @@ public class P extends JavaPlugin{
|
||||
private static Listener entitylistener;
|
||||
private static Listener playerlistener;
|
||||
private static Listener blocklistener;
|
||||
private static Listener worldlistener;
|
||||
|
||||
//Main Config Reader
|
||||
public MainConfig mainConfig;
|
||||
@ -79,10 +83,12 @@ public class P extends JavaPlugin{
|
||||
entitylistener = new EntityListener();
|
||||
playerlistener = new PlayerListener();
|
||||
blocklistener = new BlockListener();
|
||||
worldlistener = new WorldListener();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(entitylistener,this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(playerlistener,this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(blocklistener,this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(worldlistener,this);
|
||||
|
||||
//Load All
|
||||
this.loadAll();
|
||||
@ -438,7 +444,11 @@ public class P extends JavaPlugin{
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public int parseInt(String string){
|
||||
return NumberUtils.toInt(string, 0);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// LOGGING
|
||||
// -------------------------------------------- //
|
||||
|
@ -18,7 +18,7 @@ public class CMDHelp extends DCommand{
|
||||
|
||||
if(args.length>1){
|
||||
try{
|
||||
page=Integer.parseInt(args[1]);
|
||||
page=p.parseInt(args[1]);
|
||||
}catch(NumberFormatException e){
|
||||
page=1;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class CMDMsg extends DCommand{
|
||||
if(eworld!=null){
|
||||
if(args.length>1){
|
||||
try{
|
||||
int id=Integer.parseInt(args[1]);
|
||||
int id=p.parseInt(args[1]);
|
||||
|
||||
DConfig confreader = new DConfig(new File(p.getDataFolder()+"/dungeons/"+eworld.dungeonname, "config.yml"));
|
||||
|
||||
|
@ -8,6 +8,7 @@ import java.io.ObjectInputStream;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -46,7 +47,8 @@ public class GameWorld {
|
||||
public boolean isPlaying=false;
|
||||
public int id;
|
||||
public CopyOnWriteArrayList<Material> secureobjects = new CopyOnWriteArrayList<Material>();
|
||||
|
||||
public CopyOnWriteArrayList<Chunk> loadedChunks = new CopyOnWriteArrayList<Chunk>();
|
||||
|
||||
public CopyOnWriteArrayList<Sign> signClass=new CopyOnWriteArrayList<Sign>();
|
||||
public CopyOnWriteArrayList<DMob> dmobs = new CopyOnWriteArrayList<DMob>();
|
||||
public CopyOnWriteArrayList<GameChest> gchests = new CopyOnWriteArrayList<GameChest>();
|
||||
@ -77,39 +79,34 @@ public class GameWorld {
|
||||
String[] lines=sign.getLines();
|
||||
|
||||
if(!isPlaying){
|
||||
if(lines[1].equalsIgnoreCase("lobby")){
|
||||
if (lines[1].equalsIgnoreCase("lobby")) {
|
||||
this.locLobby=block.getLocation();
|
||||
block.setTypeId(0);
|
||||
}
|
||||
if(lines[1].equalsIgnoreCase("ready")){
|
||||
} else if (lines[1].equalsIgnoreCase("ready")) {
|
||||
this.blocksReady.add(block);
|
||||
sign.setLine(0, ChatColor.BLUE+"############");
|
||||
sign.setLine(1, ChatColor.DARK_GREEN+"Ready");
|
||||
sign.setLine(2, "");
|
||||
sign.setLine(3, ChatColor.BLUE+"############");
|
||||
sign.update();
|
||||
}
|
||||
if(lines[1].equalsIgnoreCase("leave")){
|
||||
} else if (lines[1].equalsIgnoreCase("leave")){
|
||||
this.blocksLeave.add(block);
|
||||
sign.setLine(0, ChatColor.BLUE+"############");
|
||||
sign.setLine(1, ChatColor.DARK_GREEN+"Leave");
|
||||
sign.setLine(2, "");
|
||||
sign.setLine(3, ChatColor.BLUE+"############");
|
||||
sign.update();
|
||||
}
|
||||
if(lines[1].equalsIgnoreCase("start")){
|
||||
} else if (lines[1].equalsIgnoreCase("start")){
|
||||
this.locStart=block.getLocation();
|
||||
block.setTypeId(0);
|
||||
}
|
||||
if(lines[1].equalsIgnoreCase("end")){
|
||||
} else if (lines[1].equalsIgnoreCase("end")){
|
||||
this.blocksEnd.add(block);
|
||||
sign.setLine(0, ChatColor.DARK_BLUE+"############");
|
||||
sign.setLine(1, ChatColor.DARK_GREEN+"End");
|
||||
sign.setLine(2, "");
|
||||
sign.setLine(3, ChatColor.DARK_BLUE+"############");
|
||||
sign.update();
|
||||
}
|
||||
if(lines[1].equalsIgnoreCase("classes")){
|
||||
} else if (lines[1].equalsIgnoreCase("classes")){
|
||||
if(!config.isLobbyDisabled){
|
||||
int[] direction=DGSign.getDirection(block.getData());
|
||||
int directionX=direction[0];
|
||||
@ -150,6 +147,22 @@ public class GameWorld {
|
||||
block.setTypeId(0);
|
||||
}
|
||||
|
||||
} else if (lines[1].equalsIgnoreCase("chunkupdater")){
|
||||
Chunk chunk = this.world.getChunkAt(block);
|
||||
if(!lines[2].equals("")){
|
||||
Integer radius = p.parseInt(lines[2]);
|
||||
for(int x = -radius; x<radius; x++){
|
||||
for(int z = -radius; z<radius; z++){
|
||||
Chunk chunk1 = this.world.getChunkAt(chunk.getX()-x,chunk.getZ()-z);
|
||||
chunk1.load();
|
||||
this.loadedChunks.add(chunk1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
chunk.load();
|
||||
this.loadedChunks.add(chunk);
|
||||
}
|
||||
block.setTypeId(0);
|
||||
}
|
||||
|
||||
}else{
|
||||
@ -159,10 +172,10 @@ public class GameWorld {
|
||||
if(mob!=null){
|
||||
String[] atributes=lines[3].split(",");
|
||||
if(atributes.length==3){
|
||||
new MobSpawner(block, mob, Integer.parseInt(atributes[0]), Integer.parseInt(atributes[1]), Integer.parseInt(atributes[2]),0);
|
||||
new MobSpawner(block, mob, p.parseInt(atributes[0]), p.parseInt(atributes[1]), p.parseInt(atributes[2]),0);
|
||||
}
|
||||
if(atributes.length==4){
|
||||
new MobSpawner(block, mob, Integer.parseInt(atributes[0]), Integer.parseInt(atributes[1]), Integer.parseInt(atributes[2]),Integer.parseInt(atributes[3]));
|
||||
new MobSpawner(block, mob, p.parseInt(atributes[0]), p.parseInt(atributes[1]), p.parseInt(atributes[2]),p.parseInt(atributes[3]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -174,7 +187,7 @@ public class GameWorld {
|
||||
}
|
||||
if(lines[1].equalsIgnoreCase("msg")){
|
||||
if(lines[2]!=""&&lines[3]!=""){
|
||||
new GameMessage(block,Integer.parseInt(lines[2]),this,Integer.parseInt(lines[3]));
|
||||
new GameMessage(block,p.parseInt(lines[2]),this,p.parseInt(lines[3]));
|
||||
block.setTypeId(0);
|
||||
}
|
||||
}
|
||||
@ -184,7 +197,7 @@ public class GameWorld {
|
||||
|
||||
if(lines[2]!=null ){
|
||||
if(lines[2].length()>0){
|
||||
radius=Integer.parseInt(lines[2]);
|
||||
radius=p.parseInt(lines[2]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,8 +117,8 @@ public class BlockListener implements Listener {
|
||||
|
||||
String[] data = lines[3].split("\\,");
|
||||
if(data.length==2){
|
||||
int maxGroups=Integer.parseInt(data[0]);
|
||||
int maxPlayersPerGroup=Integer.parseInt(data[1]);
|
||||
int maxGroups=P.p.parseInt(data[0]);
|
||||
int maxPlayersPerGroup=P.p.parseInt(data[1]);
|
||||
if(maxGroups>0 && maxPlayersPerGroup>0){
|
||||
if(DGSign.tryToCreate(event.getBlock(), dungeonName, maxGroups, maxPlayersPerGroup)!=null){
|
||||
event.setCancelled(true);
|
||||
|
21
src/com/dre/dungeonsxl/listener/WorldListener.java
Normal file
21
src/com/dre/dungeonsxl/listener/WorldListener.java
Normal file
@ -0,0 +1,21 @@
|
||||
package com.dre.dungeonsxl.listener;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
|
||||
import com.dre.dungeonsxl.game.GameWorld;
|
||||
|
||||
public class WorldListener implements Listener{
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onChunkUnload(ChunkUnloadEvent event){
|
||||
GameWorld gWorld = GameWorld.get(event.getWorld());
|
||||
if(gWorld!=null){
|
||||
if(gWorld.loadedChunks.contains(event.getChunk())){
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user