Thread: Deleted World Objects re-appearing after time

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Deleted World Objects re-appearing after time 
    Donator
    Sake's Avatar
    Join Date
    Jan 2013
    Posts
    398
    Thanks given
    71
    Thanks received
    23
    Rep Power
    2
    I'm pretty sure this might be affected by my Launcher.java since they disappear, but re-appear later on after a few hours.

    So I added the DigitalKilbas deleting world objects and they disappear for a while, then I don't know why but they re-appear later, when I'm offline.
    Here's my launcher.java

    Code:
     public static void main(String[] args) throws Exception {
            if (args.length < 3) {
                System.out.println("USE: guimode(boolean) debug(boolean) hosted(boolean)");
                return;
            }
            Settings.DEBUG = Boolean.parseBoolean(args[1]);
            Settings.HOSTED = Boolean.parseBoolean(args[2]);
            long currentTime = Utils.currentTimeMillis();
            if (Settings.HOSTED) { /* NOTHING */ }
            Logger.log("Launcher", "Loading " + Settings.SERVER_NAME + ", please wait...");
            Initializer.loadFiles();
            try {
                ServerChannelHandler.init();
                NPCSpawning.spawnNpcs();
                cleanHome();
                ObjectSpawning.spawnObjects();
            } catch (Throwable e) {
                Logger.handle(e);
                Logger.log("Launcher", "Failed initing Server Channel Handler. Shutting down...");
                System.exit(1);
                return;
            }
            Logger.log("Launcher", "Server is now online. Took " + (Utils.currentTimeMillis() - currentTime) + " seconds to load.");
    	RemoveObjects.removeObjects();
    	addCleanMemoryTask();
            addAccountsSavingTask();
        }
    
        private static void addCleanMemoryTask() {
            CoresManager.slowExecutor.scheduleWithFixedDelay(new Runnable() {
                @Override
                public void run() {
                    try {
                        cleanMemory(true);
                    } catch (Throwable e) {
                        Logger.handle(e);
                    }                
                }
            }, 0, 10, TimeUnit.MINUTES);
        }
        
        private static void addAccountsSavingTask() {
            CoresManager.slowExecutor.scheduleWithFixedDelay(new Runnable() {
                @Override
                public void run() {
                    try {
                     saveFiles();
                    } catch (Throwable e) {
                        Logger.handle(e);
                    }
                }
            }, 0, 3, TimeUnit.SECONDS);
        }
        
        public static void saveFiles() {
            for (Player player : World.getPlayers()) {
                if (player == null || !player.hasStarted() || player.hasFinished()) {
                    continue;
                }
            SerializableFilesManager.savePlayer(player);
            }
            DisplayNames.save();
            IPBanL.save();
            PkRank.save();
            DTRank.save();
        }
    
        public static void cleanHome() {
        WorldTasksManager.schedule(new WorldTask() {
    	@Override
                public void run() {
                    if (World.getPlayers().size() > 0) {
                        RemoveObjects.removeObjects();
                        stop(); 
                    }
                }
            }, 0, 10);
        }
        
        public static void cleanMemory(boolean force) {
            if (force) {
                ItemDefinitions.clearItemsDefinitions();
                NPCDefinitions.clearNPCDefinitions();
                ObjectDefinitions.clearObjectDefinitions();
                for (Region region : World.getRegions().values()) {
                    region.removeMapFromMemory();
                }
            }
            for (Index index : Cache.STORE.getIndexes()) {
                index.resetCachedFiles();
            }
            CoresManager.fastExecutor.purge();
            System.gc();
        }
    
        public static void shutdown() {
    		try {
    			//Getting the Current Date
        			SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd----HH.mm.ss");//
        			Date now = new Date();
    			String strDate = sdfDate.format(now);
    			File f = new File("./data/Logs/previous/" + strDate + ".txt");
    			if(!f.exists()){
    				try {
    					f.createNewFile();
    				} catch (IOException ioe) {
    					Logger.log("Shutdown", "Failed to create the new log file.");
    				}
    				//Copying the old file data to the new file
          			BufferedInputStream fin = null;
          			BufferedOutputStream fout = null;
          			try {
          			    int bufSize = 8 * 1024;
          			    fin = new BufferedInputStream(new FileInputStream("./data/Logs/publicChatLog.txt"), bufSize);
          			    fout = new BufferedOutputStream(new FileOutputStream(f), bufSize);
          			    copyPipe(fin, fout, bufSize);
          			} catch (IOException ioex) {
          			    Logger.log("Shutdown", "Failed to copy data to file.");
          			}
          			finally {
              				if (fin != null) {
                  				try {
                      				fin.close();
                				} catch (IOException cioex) {
                				}
              				}
              				if (fout != null) {
                  				try {
                      				fout.close();
                  				} catch (IOException cioex) {
                  				}
          				}
          			}
    			} else {
    				Logger.log("Shutdown", "Failed to save log, File already exists.");
    			}
    			try {
    				BufferedWriter out = new BufferedWriter(new FileWriter("./data/Logs/publicChatLog.txt"));
    				out.newLine();
          		      out.write("");
          		  	out.close();
    			} catch(IOException io) {
    				Logger.log("Shutdown", "Failed to empty the log file.");
    			}
    			closeServices();
    		} finally {
    			System.exit(0);
    		}
    	}
    
        private static void copyPipe(BufferedInputStream fin,
    			BufferedOutputStream fout, int bufSize) {
    		// TODO Auto-generated method stub
    		
    	}
    
    	public static void closeServices() {
            ServerChannelHandler.shutdown();
            CoresManager.shutdown();
        }
    
        public static void restart() {
            closeServices();
            System.gc();
            try {
                Runtime.getRuntime().exec("java -server -Xms2048m -Xmx20000m -cp bin;/data/libs/netty-3.2.7.Final.jar;/data/libs/FileStore.jar Launcher false false true false");
                System.exit(0);
            } catch (Throwable e) {
                Logger.handle(e);
            }
        }
    
        private Launcher() {
        }
    }
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Mar 2010
    Posts
    2,218
    Thanks given
    170
    Thanks received
    262
    Rep Power
    0
    show me your remove objects class, i want to see how it's handled, probably does it with an int of so many seconds.
    Reply With Quote  
     

  3. #3  
    Donator
    Sake's Avatar
    Join Date
    Jan 2013
    Posts
    398
    Thanks given
    71
    Thanks received
    23
    Rep Power
    2
    Quote Originally Posted by Teek View Post
    show me your remove objects class, i want to see how it's handled, probably does it with an int of so many seconds.
    Code:
    package com.rs.utils.spawning;
    
    import com.rs.game.World;
    import com.rs.game.WorldObject;
    import com.rs.game.WorldTile;
    import com.rs.utils.Utils.EntityDirection;
    
    public enum NPCSpawning {
    	
    		
            EDWARD(13727, 2673, 2665, 0, false),
    	MANAGER(13768, 3466, 2217, 0, false), 
    	GENERAL_STORE(529, 2409, 3804, 0, false),
    	GENERAL_STORE2(529, 2339, 3798, 0, false),  
    	HERBLORE(587, 2417, 3808, 0, false),
    	CRAFTING(585, 2407, 3802, 0, false),	
    	CRAFTING2(585, 2342, 3798, 0, false),
    	SLAYER(8467, 2400, 3799, 0, false),
    	BOB(519, 2405, 3804, 0, false),
    	BOB2(519, 2342, 3800, 0, false),
    	PVM_STORE(6537, 2410, 3817, 0, false), 
    	POTIONS(576, 2417, 3807, 0, false),
    	RANGED(575, 2404, 3814, 0, false),
    	VOTESHOP(9420, 2354, 3801, 0, false),
    	WEAPON_STORE(8280, 2396, 3804, 0, false),
    	LOW_LEVEL(1208, 2404, 3812, 0, false),
    	HORVIK_ARMOR(14058, 2397, 3797, 0, false),
    	HUNTER(5112, 2525, 2915, 0, false),
    	FOOD_SHOP(8864, 2417, 3815, 0, false),
    	MAGIC_SHOP(4513, 2405, 3816, 0, false),
    	RUNE_SHOP(5913, 2407, 3816, 0, false),
    	PURE_SHOP(15085, 2409, 3817, 0, false),
    	SKILLCAPES(3705, 2347, 3807, 0, false),
    	RUNECRAFTING(537, 2340, 3798, 0, false),
            PRESTIGE_SHOP(13959, 2338, 3798, 0, false),
    	ARCHAEOLOGIST(1918, 2251, 3307, 0, false),
    	PVP_SHOP(6539, 2673, 2655, 0, false),
    	CONSTRUCTION(4247, 2525, 2916, 0, false),
    	ZENEVIVIACOMP(11628, 2683, 2656, 0, false),
    	AGILITYSHOP(384, 2547, 3562, 0, false),
    	GNOMETRAINER(162, 2474, 3419, 2, false),
    	MAZCHADONATOR(8274, 2250, 3307, 0, false),
    	LIVIDFARM(7530, 2109, 3943, 0, false),
    	BANKER1(44, 2417, 3799, 0, false),
    	BANKER2(44, 2416, 3799, 0, false),
    	TUTOR(6521, 2415, 3829, 0, false),
    	RSAILOR(5508, 2416, 3835, 0, false),
    	JSAILOR(5481, 2361, 3807, 0, false),
    	RIDDLER(5520, 2335, 3806, 0, false),
    	ARMADYLSHOP(3142, 4186, 5737, 0, false),
    	OVERSEER(8904, 3319, 3495, 0, false),
    	
    	//PREM BANKS
    	PREMBANK1(4243, 2405, 10198, 0, false),
    	PREMBANK2(4243, 3040, 4841, 0, false),
    	PREMBANK3(4243, 2599, 3423, 0, false),
    	PREMBANK4(4243, 2204, 5345, 0, false),
    	PREMBANK5(4243, 3500, 3620, 0, false),
    
    	//NEW HOME
    	GENERAL_STORE3(529, 3080, 3512, 0, false),
    	GENERAL_STORE4(527, 3082, 3512, 0, false),
    	SLAYER2(8467, 3082, 3494, 0, false),
    	TUTOR2(6521, 3089, 3492, 0, false),
    	BANKER3(44, 3096, 3489, 0, false),
    	BANKER4(44, 3096, 3491, 0, false),
    	BANKER5(44, 3096, 3493, 0, false),
    	BANKER6(44, 3097, 3494, 0, false),
    	RIDDLER2(5520, 3097, 3499, 0, false),
    	PRESTIGE_SHOP2(13959, 3091, 3497, 0, false),
    	VOTESHOP2(9420, 3096, 3499, 0, false),
    	PVM_STORE2(6537, 3091, 3495, 0, false),
    BOB3(519, 3099, 3507, 0, false),
    CRAFTING3(585, 3098, 3507, 0, false),
    HERBLORE3(587, 3097, 3507, 0, false),
    POTIONS3(576, 3096, 3507, 0, false),
    RANGED3(575, 3092, 3507, 0, false),
    WEAPON_STORE3(8280, 3096, 3513, 0, false),
    LOW_LEVEL3(1208, 3097, 3513, 0, false),
    HORVIK_ARMOR3(14058, 3098, 3513, 0, false),
    FOOD_SHOP3(8864, 3095, 3507, 0, false),
    MAGIC_SHOP3(4513, 3094, 3507, 0, false),
    RUNE_SHOP3(5913, 3093, 3507, 0, false),
    PURE_SHOP3(15085, 3099, 3513, 0, false),
    SKILLCAPES3(3705, 3091, 3507, 0, false),
    ESSENCE3(537, 3100, 3513, 0, false),
    
    	FISHING_SPOT_1(327, 2421, 3789, 0, true),
    	FISHING_SPOT_2(6267, 2402, 3778, 0 , true),
    	FISHING_SPOT_3(312, 2411, 3780, 0, true),
    	FISHING_SPOT_4(313, 2604, 3422, 0, true),
    	FISHING_SPOT_5(952, 2603, 3422, 0, true),
    	FISHING_SPOT_6(327, 2604, 3423, 0, true),
    	FISHING_SPOT_7(6267, 2401, 3780, 0, true),
    	FISHING_SPOT_8(312, 2605, 3425, 0, true),
    	FISHING_SPOT_9(327, 2599, 3419, 0, true),
    	FISHING_SPOT_10(6267, 2598, 3422, 0, true),
    	FISHING_SPOT_11(8864, 2590, 3419, 0, true),
    	POLY_DUNG_SHOP(875, 4724, 5466, 0, false),
    	CORP_SHOP(13191, 2959, 4382, 2, false),
    	TZHAAR_1(2625, 2617, 5132, 0, false),
    	TZHAAR_2(2614, 4666, 5082, 0, false),
    	
    	/** DONOR ZONE NPCS **/
    	DONOR_ZONE_1(6892, 1605, 4508, 0, false),
    	DONOR_ZONE_2(1918, 1605, 4506, 0, false),
    	DONOR_ZONE_3(14854, 1605, 4505, 0, false),
    	DONOR_ZONE_4(537, 2598, 3162, 0, false),
    	DONOR_ZONE_5(6970, 2207, 5345, 0, false),
    
    	/** WARRIORS GUILD NPCS **/
    	WARRIORSGUILD(4289, 2845, 3534, 2, false);
    	
    	private int npcId;
    	private int posX;
    	private int posY;
    	private int height;
    	private boolean spawned;
    
    	NPCSpawning(int id, int x, int y, int z, boolean spawned) {
    		this.npcId = id;
    		this.posX = x;
    		this.posY = y;
    		this.height = z;
    		this.spawned = spawned;
    	}
    	
    	public static void spawnNpcs() {
    		for (NPCSpawning spawn : NPCSpawning.values()) {
    			World.spawnNPC(spawn.npcId, new WorldTile
    
    (spawn.posX, spawn.posY, spawn.height), 0, spawn.spawned);
    			World.deleteObject(new WorldTile(2415, 3807, 0));
    			World.deleteObject(new WorldTile(2417, 3807, 0));
    			World.deleteObject(new WorldTile(2409, 3801, 0));
    			World.deleteObject(new WorldTile(2405, 3801, 0));
    			World.deleteObject(new WorldTile(2407, 3801, 0));
    			World.deleteObject(new WorldTile(2407, 3800, 0));
    			World.deleteObject(new WorldTile(2408, 3812, 0));
    			World.deleteObject(new WorldTile(2407, 3812, 0));
    			World.deleteObject(new WorldTile(2406, 3812, 0));
    			World.deleteObject(new WorldTile(2409, 3812, 0));
    			World.deleteObject(new WorldTile(2410, 3812, 0));
    			World.deleteObject(new WorldTile(2408, 3811, 0));
    			World.deleteObject(new WorldTile(2407, 3811, 0));
    			World.deleteObject(new WorldTile(2406, 3811, 0));
    			World.deleteObject(new WorldTile(2409, 3811, 0));
    			World.deleteObject(new WorldTile(2410, 3813, 0));
    			World.deleteObject(new WorldTile(2409, 3813, 0));
    			World.deleteObject(new WorldTile(2408, 3813, 0));
    			World.deleteObject(new WorldTile(2407, 3813, 0));
    			World.deleteObject(new WorldTile(2406, 3813, 0));
    			World.deleteObject(new WorldTile(2407, 3815, 0));
    			World.deleteObject(new WorldTile(2409, 3815, 0));
    			World.deleteObject(new WorldTile(2409, 3817, 0));
    			World.deleteObject(new WorldTile(2405, 3814, 0));
    			World.deleteObject(new WorldTile(2405, 3816, 0));
    			World.deleteObject(new WorldTile(2410, 3815, 0));
    			World.deleteObject(new WorldTile(2410, 3817, 0));
    			World.deleteObject(new WorldTile(2404, 3814, 0));
    			World.deleteObject(new WorldTile(2410, 3814, 0));
    			World.deleteObject(new WorldTile(2363, 3799, 0));
    			World.deleteObject(new WorldTile(2354, 3802, 0));
    			World.deleteObject(new WorldTile(2354, 3800, 0));
    			World.deleteObject(new WorldTile(2346, 3798, 0));
    			World.deleteObject(new WorldTile(2349, 3800, 0));
    			World.deleteObject(new WorldTile(2347, 3800, 0));
    			World.deleteObject(new WorldTile(2341, 3814, 0));
    			World.deleteObject(new WorldTile(2341, 3812, 0));
    			World.deleteObject(new WorldTile(2342, 3812, 0));
    			World.deleteObject(new WorldTile(2344, 3812, 0));
    			World.deleteObject(new WorldTile(2344, 3813, 0));
    			World.deleteObject(new WorldTile(2344, 3814, 0));
    			World.deleteObject(new WorldTile(2344, 3809, 0));
    			World.deleteObject(new WorldTile(2342, 3807, 0));
    			World.deleteObject(new WorldTile(2338, 3798, 0));
    			World.deleteObject(new WorldTile(2341, 3800, 0));
    			World.deleteObject(new WorldTile(2342, 3798, 0));
    			World.deleteObject(new WorldTile(2334, 3799, 0));
    			World.deleteObject(new WorldTile(2347, 3805, 0));
    			World.deleteObject(new WorldTile(2348, 3808, 0));
    			World.deleteObject(new WorldTile(2846, 3535, 0));
    			World.deleteObject(new WorldTile(2846, 3536, 0));
    			World.deleteObject(new WorldTile(3093, 3507, 0));
    			World.deleteObject(new WorldTile(3092, 3511, 0));
    			World.deleteObject(new WorldTile(3091, 3511, 0));
    
    
    
    
    		
    		}
    		
    	}
    }
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Mar 2010
    Posts
    2,218
    Thanks given
    170
    Thanks received
    262
    Rep Power
    0
    Now show me this method.

    World.deleteObject(new WorldTile(2342, 3807, 0));

    Are you aware you would have to remove the clipping too with the world object if the packet doesn't handle it.
    Reply With Quote  
     

  5. #5  
    Donator
    Sake's Avatar
    Join Date
    Jan 2013
    Posts
    398
    Thanks given
    71
    Thanks received
    23
    Rep Power
    2
    Code:
    public static void deleteObject(WorldTile tile){
    	restrictedTiles.add(tile);
    	}
    Code:
    public void addObject(WorldObject object, int plane, int localX, int localY) {
    	if(World.restrictedTiles != null){
    	for(WorldTile restrictedTile : World.restrictedTiles){
    		if(restrictedTile != null){
    			int restX = restrictedTile.getX(), restY = restrictedTile.getY();
    			int restPlane = restrictedTile.getPlane();
    					
    			if(object.getX() == restX && object.getY() == restY && object.getPlane() == restPlane){
    				World.spawnObject(new WorldObject(-1, 10, 2, object.getX(), object.getY(), object.getPlane()), false);
    				return;
    			}
    		}
    	}
    }
    		addMapObject(object, localX, localY);
    		
    		if (objects == null)
    			objects = new WorldObject[4][64][64][];
    		WorldObject[] tileObjects = objects[plane][localX][localY];
    		if (tileObjects == null)
    			objects[plane][localX][localY] = new WorldObject[] { object };
    		else {
    			WorldObject[] newTileObjects = new WorldObject[tileObjects.length + 1];
    			newTileObjects[tileObjects.length] = object;
    			System.arraycopy(tileObjects, 0, newTileObjects, 0,
    					tileObjects.length);
    			objects[plane][localX][localY] = newTileObjects;
    		}
    	}
    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Mar 2010
    Posts
    2,218
    Thanks given
    170
    Thanks received
    262
    Rep Power
    0
    Doesn't look like it stores time so how it re-appears i have no idea..

    feel free to add me on skype and i'll try fix.
    Reply With Quote  
     

  7. #7  
    Donator
    Sake's Avatar
    Join Date
    Jan 2013
    Posts
    398
    Thanks given
    71
    Thanks received
    23
    Rep Power
    2
    Ghosts. The only answer.
    Reply With Quote  
     

  8. #8  
    Banned

    Join Date
    Mar 2010
    Posts
    2,218
    Thanks given
    170
    Thanks received
    262
    Rep Power
    0
    Quote Originally Posted by revize View Post
    Ghosts. The only answer.
    I'm asuming you probably made your own method to remove the object, clearly if it's being removed a timer is involved.. change the timer from what it is to Long.MAX_VALUE; or.. remove the time based method.
    Reply With Quote  
     

  9. #9  
    Donator
    Sake's Avatar
    Join Date
    Jan 2013
    Posts
    398
    Thanks given
    71
    Thanks received
    23
    Rep Power
    2
    Quote Originally Posted by Teek View Post
    I'm asuming you probably made your own method to remove the object, clearly if it's being removed a timer is involved.. change the timer from what it is to Long.MAX_VALUE; or.. remove the time based method.
    I used the method from DigitalKilbas, it seemed to work for everyone else. I'm honestly so frustrated as every day I have to keep logging in to restart the server for my players so the objects re-remove.
    Reply With Quote  
     

  10. #10  
    Banned

    Join Date
    Mar 2010
    Posts
    2,218
    Thanks given
    170
    Thanks received
    262
    Rep Power
    0
    Quote Originally Posted by revize View Post
    I used the method from DigitalKilbas, it seemed to work for everyone else. I'm honestly so frustrated as every day I have to keep logging in to restart the server for my players so the objects re-remove.
    You're doing something wrong, probably the it's handled.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 1
    Last Post: 06-12-2014, 12:58 AM
  2. [fixed] 718 deleting world object
    By kiltedknight in forum Help
    Replies: 4
    Last Post: 09-13-2013, 06:26 PM
  3. Replies: 13
    Last Post: 07-06-2008, 10:15 AM
  4. [SQL]Adding World Objects[/SQL]
    By Harvey in forum Tutorials
    Replies: 7
    Last Post: 02-16-2008, 04:55 PM
  5. Making 2 dialogues appear after each other
    By × Zenzie × in forum Tutorials
    Replies: 7
    Last Post: 11-18-2007, 03:17 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •