Website PHP Body In Chat Help

Discussion in 'Plugin Development' started by lbjdaking23, Aug 10, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    lbjdaking23

    Is it possible to get a php body from a url then the body go into the broadcast chat?
    Im trying to get the body every time it changes.
    Or you type /radio and shows the text and updates every so often.
    This is for a radio thing

    Help please :)[diamond][diamond]
    [diamond][diamond][diamond][diamond][diamond][diamond][diamond]

    Bump Please

    Really no one can help :(

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
  2. Offline

    Supersam654

    You bumped your thread 3 times in 3 1/2 hours. ARE YOU OUT OF YOUR MIND! And besides, what you are asking doesn't exactly make sense. You might want to post this on the plugin request forum and first read what bukkit plugins can and cannot due (because if I am understanding what you are asking, you can't do this)
     
  3. Offline

    lbjdaking23

    I basically want in chat to show what is on this php page in chat
    http://gamer.fm/ajax-calls/stats.php
    and the page changes on refresh when there is a new song playing the text will change and when the text changes I want it to show it in chat. If you can't do that then show it every 1:30 minutes
     
  4. Offline

    Supersam654

    Oh! That's pretty easy! Take a look at this page. It basically describes what you want to do with that webpage. Then, (I believe it's called the task scheduler) add something in the task scheduler to run that piece of your plugin every 1:30 minutes. You might also want to add a feature to compare the last message sent out and the current message and only BROADCAST the current message if it is different from the old one.
     
  5. Offline

    lbjdaking23

    Where should I put it
    This is my whole code right now and it is not working

    Deleted
     
  6. Offline

    Supersam654

    Define "not working"
     
  7. Offline

    lbjdaking23

    Nothing Will Broadcast And I get errors
    Code:
    2011-08-10 23:54:17 [INFO] GamerFM Radio Enabled!
    2011-08-10 23:54:17 [SEVERE] Error occurred while enabling GamerFM Radio v1.0 (Is it up to date?): null
    java.lang.NullPointerException
        at omg.LBJDaKing23.GFM.GFM.onEnable(GFM.java:25)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:126)
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:878)
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:272)
        at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:162)
        at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:146)
        at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:284)
        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:271)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:148)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:335)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    
     
  8. Offline

    Supersam654

    You are getting an error in your onEnable() method. If you are getting an error in your onEnable() method, do you really think that it is enabling? I believe that line 25 is when you make that task. Try changing it from Plugin.blab.blab.blab to Bukkit.blab.blab.blab. You will need to import something (Eclipse will tell you automatically)

    EDIT: At the top, you put

    Plugin plugin;

    I think that needs to be changed to GFM plugin = this;

    Then when you are creating the task, change it from Plugin to plugin.
     
  9. Offline

    lbjdaking23

    I changed it to from plugin to bukkit

    Deleted

    and get more errors this time

    Code:
    2011-08-11 00:04:16 [INFO] GamerFM Radio Enabled!
    2011-08-11 00:04:16 [SEVERE] Error occurred while enabling GamerFM Radio v1.0 (Is it up to date?): org/htmlparser/util/ParserException
    java.lang.NoClassDefFoundError: org/htmlparser/util/ParserException
        at omg.LBJDaKing23.GFM.GFM.onEnable(GFM.java:25)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:126)
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:878)
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:272)
        at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:162)
        at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:146)
        at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:380)
        at org.bukkit.command.SimpleCommandMap$ReloadCommand.execute(SimpleCommandMap.java:281)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:129)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:320)
        at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:713)
        at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:677)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:670)
        at net.minecraft.server.Packet3Chat.a(Packet3Chat.java:33)
        at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
        at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:85)
        at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
        at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:451)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    Caused by: java.lang.ClassNotFoundException: org.htmlparser.util.ParserException
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:36)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:24)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        ... 20 more
     
  10. Offline

    Supersam654

    Look at the EDIT: portion of my last message

    EDIT: NVM, I am looking at it again

    Replace your onEnable() method with this:
    Code:
        public void onEnable() {
            log.info("GamerFM Radio Enabled!");
    
        Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new GFM(), 0, 4500L);
        }
        public void run() {
            try {
                StringExtractor se = new StringExtractor("http://gamer.fm/ajax-calls/stats.php");
                String content = se.extractStrings(false);
                getServer().broadcastMessage(ChatColor.YELLOW + "[GamerFM] " + ChatColor.WHITE + content);
            } catch (ParserException e) {
                e.printStackTrace();
            }
        }
    EDIT: I moved your run() method outside of the task. Even if that could work, it is a horrible practice. I then changed new Runnable() to new GFM(). Basically, you were trying to call Runnable.run() which was giving you the class not found exception because Runnable was not a class. I changed it to GFM() so that it runs GFM.run().

    Change that one line to

    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new GFM(), 0L, 4500L);

    If that doesn't work, try:

    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(GFM, new GFM(), 0L, 4500L);


    EDIT AGIAN: I am not thinking straight at 2 AM, but you might want to look into scheduleSyncRepeatedTask(...)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
  11. Offline

    masteroftime

    change it to syncDelayedTask(this, this, 0 4500L);
     
  12. Offline

    Darkman2412

    Did you put the htmlparser jar file in the main directory?
    edit: at your imports you have import org.htmlparser.***;
    Your error is java.lang.NoClassDefFoundError: org/htmlparser/util/ParserException.
    He just can't find that class.
     
  13. Offline

    cholo71796

    @lbjdaking23
    Code:java
    1. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    2. public void run() {
    3. //stuff
    4. }
    5. }, 0L, 4500L);
     
  14. Offline

    lbjdaking23

    I have that added to libaries
     
  15. Offline

    masteroftime

    sorry it is scheduleSyncDelayedTask

    you forgot a comma between 0 and 4500L
    if it still doesn't work try this:
    Code:
    scheduleSyncDelayedTask((Plugin)this, (Runnable)this, 0, 4500L);
    ah, there's one parameter too much. You have to remove the 0.

    You are using some additional library for parsing the html which is then not found during runtime.

    Read this http://wiki.netbeans.org/PackagingADistributableJavaApp for how to pack the library inside you plugin.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
Thread Status:
Not open for further replies.

Share This Page