mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-02-26 09:11:55 +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
|
//Check Id & Data
|
||||||
String[] idAndData=itemsplit[0].split("/");
|
String[] idAndData=itemsplit[0].split("/");
|
||||||
itemId=Integer.parseInt(idAndData[0]);
|
itemId=P.p.parseInt(idAndData[0]);
|
||||||
|
|
||||||
if(idAndData.length>1){
|
if(idAndData.length>1){
|
||||||
itemData=Integer.parseInt(idAndData[1]);
|
itemData=P.p.parseInt(idAndData[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Size
|
//Size
|
||||||
if(itemsplit.length>1){
|
if(itemsplit.length>1){
|
||||||
itemSize=Integer.parseInt(itemsplit[1]);
|
itemSize=P.p.parseInt(itemsplit[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Enchantment
|
//Enchantment
|
||||||
@ -85,7 +85,7 @@ public class DConfig {
|
|||||||
itemEnchantment=Enchantment.getByName(enchantmentSplit[0]);
|
itemEnchantment=Enchantment.getByName(enchantmentSplit[0]);
|
||||||
|
|
||||||
if(enchantmentSplit.length>1){
|
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) {
|
if (configSetionMessages != null) {
|
||||||
Set<String> list = configSetionMessages.getKeys(false);
|
Set<String> list = configSetionMessages.getKeys(false);
|
||||||
for (String messagePath:list) {
|
for (String messagePath:list) {
|
||||||
int messageId = Integer.parseInt(messagePath);
|
int messageId = P.p.parseInt(messagePath);
|
||||||
this.msgs.put(messageId,configSetionMessages.getString(messagePath));
|
this.msgs.put(messageId,configSetionMessages.getString(messagePath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ public class DMobType {
|
|||||||
String[] splittedEnchantment = enchantment.split(" ");
|
String[] splittedEnchantment = enchantment.split(" ");
|
||||||
if(Enchantment.getByName(splittedEnchantment[0].toUpperCase())!=null){
|
if(Enchantment.getByName(splittedEnchantment[0].toUpperCase())!=null){
|
||||||
if (splittedEnchantment.length>1) {
|
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 {
|
} else {
|
||||||
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), 1, true);
|
itemMeta.addEnchant(Enchantment.getByName(splittedEnchantment[0].toUpperCase()), 1, true);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
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.CommandListener;
|
||||||
import com.dre.dungeonsxl.listener.EntityListener;
|
import com.dre.dungeonsxl.listener.EntityListener;
|
||||||
import com.dre.dungeonsxl.listener.PlayerListener;
|
import com.dre.dungeonsxl.listener.PlayerListener;
|
||||||
|
import com.dre.dungeonsxl.listener.WorldListener;
|
||||||
|
|
||||||
public class P extends JavaPlugin{
|
public class P extends JavaPlugin{
|
||||||
public static P p;
|
public static P p;
|
||||||
@ -40,6 +43,7 @@ public class P extends JavaPlugin{
|
|||||||
private static Listener entitylistener;
|
private static Listener entitylistener;
|
||||||
private static Listener playerlistener;
|
private static Listener playerlistener;
|
||||||
private static Listener blocklistener;
|
private static Listener blocklistener;
|
||||||
|
private static Listener worldlistener;
|
||||||
|
|
||||||
//Main Config Reader
|
//Main Config Reader
|
||||||
public MainConfig mainConfig;
|
public MainConfig mainConfig;
|
||||||
@ -79,10 +83,12 @@ public class P extends JavaPlugin{
|
|||||||
entitylistener = new EntityListener();
|
entitylistener = new EntityListener();
|
||||||
playerlistener = new PlayerListener();
|
playerlistener = new PlayerListener();
|
||||||
blocklistener = new BlockListener();
|
blocklistener = new BlockListener();
|
||||||
|
worldlistener = new WorldListener();
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(entitylistener,this);
|
Bukkit.getServer().getPluginManager().registerEvents(entitylistener,this);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(playerlistener,this);
|
Bukkit.getServer().getPluginManager().registerEvents(playerlistener,this);
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(blocklistener,this);
|
Bukkit.getServer().getPluginManager().registerEvents(blocklistener,this);
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvents(worldlistener,this);
|
||||||
|
|
||||||
//Load All
|
//Load All
|
||||||
this.loadAll();
|
this.loadAll();
|
||||||
@ -439,6 +445,10 @@ public class P extends JavaPlugin{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int parseInt(String string){
|
||||||
|
return NumberUtils.toInt(string, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// LOGGING
|
// LOGGING
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -18,7 +18,7 @@ public class CMDHelp extends DCommand{
|
|||||||
|
|
||||||
if(args.length>1){
|
if(args.length>1){
|
||||||
try{
|
try{
|
||||||
page=Integer.parseInt(args[1]);
|
page=p.parseInt(args[1]);
|
||||||
}catch(NumberFormatException e){
|
}catch(NumberFormatException e){
|
||||||
page=1;
|
page=1;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public class CMDMsg extends DCommand{
|
|||||||
if(eworld!=null){
|
if(eworld!=null){
|
||||||
if(args.length>1){
|
if(args.length>1){
|
||||||
try{
|
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"));
|
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 java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -46,6 +47,7 @@ public class GameWorld {
|
|||||||
public boolean isPlaying=false;
|
public boolean isPlaying=false;
|
||||||
public int id;
|
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<Sign> signClass=new CopyOnWriteArrayList<Sign>();
|
public CopyOnWriteArrayList<Sign> signClass=new CopyOnWriteArrayList<Sign>();
|
||||||
public CopyOnWriteArrayList<DMob> dmobs = new CopyOnWriteArrayList<DMob>();
|
public CopyOnWriteArrayList<DMob> dmobs = new CopyOnWriteArrayList<DMob>();
|
||||||
@ -77,39 +79,34 @@ public class GameWorld {
|
|||||||
String[] lines=sign.getLines();
|
String[] lines=sign.getLines();
|
||||||
|
|
||||||
if(!isPlaying){
|
if(!isPlaying){
|
||||||
if(lines[1].equalsIgnoreCase("lobby")){
|
if (lines[1].equalsIgnoreCase("lobby")) {
|
||||||
this.locLobby=block.getLocation();
|
this.locLobby=block.getLocation();
|
||||||
block.setTypeId(0);
|
block.setTypeId(0);
|
||||||
}
|
} else if (lines[1].equalsIgnoreCase("ready")) {
|
||||||
if(lines[1].equalsIgnoreCase("ready")){
|
|
||||||
this.blocksReady.add(block);
|
this.blocksReady.add(block);
|
||||||
sign.setLine(0, ChatColor.BLUE+"############");
|
sign.setLine(0, ChatColor.BLUE+"############");
|
||||||
sign.setLine(1, ChatColor.DARK_GREEN+"Ready");
|
sign.setLine(1, ChatColor.DARK_GREEN+"Ready");
|
||||||
sign.setLine(2, "");
|
sign.setLine(2, "");
|
||||||
sign.setLine(3, ChatColor.BLUE+"############");
|
sign.setLine(3, ChatColor.BLUE+"############");
|
||||||
sign.update();
|
sign.update();
|
||||||
}
|
} else if (lines[1].equalsIgnoreCase("leave")){
|
||||||
if(lines[1].equalsIgnoreCase("leave")){
|
|
||||||
this.blocksLeave.add(block);
|
this.blocksLeave.add(block);
|
||||||
sign.setLine(0, ChatColor.BLUE+"############");
|
sign.setLine(0, ChatColor.BLUE+"############");
|
||||||
sign.setLine(1, ChatColor.DARK_GREEN+"Leave");
|
sign.setLine(1, ChatColor.DARK_GREEN+"Leave");
|
||||||
sign.setLine(2, "");
|
sign.setLine(2, "");
|
||||||
sign.setLine(3, ChatColor.BLUE+"############");
|
sign.setLine(3, ChatColor.BLUE+"############");
|
||||||
sign.update();
|
sign.update();
|
||||||
}
|
} else if (lines[1].equalsIgnoreCase("start")){
|
||||||
if(lines[1].equalsIgnoreCase("start")){
|
|
||||||
this.locStart=block.getLocation();
|
this.locStart=block.getLocation();
|
||||||
block.setTypeId(0);
|
block.setTypeId(0);
|
||||||
}
|
} else if (lines[1].equalsIgnoreCase("end")){
|
||||||
if(lines[1].equalsIgnoreCase("end")){
|
|
||||||
this.blocksEnd.add(block);
|
this.blocksEnd.add(block);
|
||||||
sign.setLine(0, ChatColor.DARK_BLUE+"############");
|
sign.setLine(0, ChatColor.DARK_BLUE+"############");
|
||||||
sign.setLine(1, ChatColor.DARK_GREEN+"End");
|
sign.setLine(1, ChatColor.DARK_GREEN+"End");
|
||||||
sign.setLine(2, "");
|
sign.setLine(2, "");
|
||||||
sign.setLine(3, ChatColor.DARK_BLUE+"############");
|
sign.setLine(3, ChatColor.DARK_BLUE+"############");
|
||||||
sign.update();
|
sign.update();
|
||||||
}
|
} else if (lines[1].equalsIgnoreCase("classes")){
|
||||||
if(lines[1].equalsIgnoreCase("classes")){
|
|
||||||
if(!config.isLobbyDisabled){
|
if(!config.isLobbyDisabled){
|
||||||
int[] direction=DGSign.getDirection(block.getData());
|
int[] direction=DGSign.getDirection(block.getData());
|
||||||
int directionX=direction[0];
|
int directionX=direction[0];
|
||||||
@ -150,6 +147,22 @@ public class GameWorld {
|
|||||||
block.setTypeId(0);
|
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{
|
}else{
|
||||||
@ -159,10 +172,10 @@ public class GameWorld {
|
|||||||
if(mob!=null){
|
if(mob!=null){
|
||||||
String[] atributes=lines[3].split(",");
|
String[] atributes=lines[3].split(",");
|
||||||
if(atributes.length==3){
|
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){
|
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[1].equalsIgnoreCase("msg")){
|
||||||
if(lines[2]!=""&&lines[3]!=""){
|
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);
|
block.setTypeId(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,7 +197,7 @@ public class GameWorld {
|
|||||||
|
|
||||||
if(lines[2]!=null ){
|
if(lines[2]!=null ){
|
||||||
if(lines[2].length()>0){
|
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("\\,");
|
String[] data = lines[3].split("\\,");
|
||||||
if(data.length==2){
|
if(data.length==2){
|
||||||
int maxGroups=Integer.parseInt(data[0]);
|
int maxGroups=P.p.parseInt(data[0]);
|
||||||
int maxPlayersPerGroup=Integer.parseInt(data[1]);
|
int maxPlayersPerGroup=P.p.parseInt(data[1]);
|
||||||
if(maxGroups>0 && maxPlayersPerGroup>0){
|
if(maxGroups>0 && maxPlayersPerGroup>0){
|
||||||
if(DGSign.tryToCreate(event.getBlock(), dungeonName, maxGroups, maxPlayersPerGroup)!=null){
|
if(DGSign.tryToCreate(event.getBlock(), dungeonName, maxGroups, maxPlayersPerGroup)!=null){
|
||||||
event.setCancelled(true);
|
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