setResourcePack Help

Discussion in 'Plugin Development' started by GRocksMc, Mar 13, 2017.

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

    timtower Administrator Administrator Moderator

    @GRocksMc Try to find out where it stops working.
     
  2. Offline

    GRocksMc

    @timtower

    It stops working when it checks if Resource_Pack_Worlds + toWorld isn't null
     
  3. Offline

    timtower Administrator Administrator Moderator

    @GRocksMc Can you post your world name and config?
     
  4. Offline

    GRocksMc

    @timtower

    Worldname: world

    Code:java
    1.  
    2. [SIZE=16px]Resource_Pack_Worlds:[/SIZE]
    3. world: [URL='http://download1584.mediafire.com/b4q2327752rg/nqgkyjrusmq6j56/Default.zip']http://download1584.mediafire.com/b4q2327752rg/nqgkyjrusmq6j56/[/URL]Default.zip
    4. [SIZE=16px][/SIZE]
     
  5. Offline

    timtower Administrator Administrator Moderator

    @GRocksMc use getString and contains please.
    And post your code again, preferably the entire class.
     
  6. Offline

    GRocksMc

    @timtower

    I just realized how stupid of a mistake I've made. The command rpack saves it to a different plugin's config -_- I just have to refer to that config in my listener (which is my main class.)

    Any idea on how to go about this?

    EDIT: Nevermind, I just used

    Code:java
    1.  
    2. Plugin main = Bukkit.getPluginManager().getPlugin("GamerVerse");
    3. Main plugin;
    4. public tpack(Main instance) {
    5. plugin = instance;
    6. }
    7.  
     
  7. Offline

    timtower Administrator Administrator Moderator

    @GRocksMc Why would you save it to a config that is not part of the same plugin?
    Fix that first.
     
  8. Offline

    GRocksMc

    @timtower

    I made both plugins.

    Now the console is giving me an error that it can't load the plugin because it is an abnormal plugin type.

    EDIT: I just had to make a new class with the listener stuff.

    Everything works, it just isn't applying the rpack which is probably a website problem that I have to fix
     
    Last edited: Mar 19, 2017
  9. Offline

    timtower Administrator Administrator Moderator

    @GRocksMc Having 2 plugins handling the same config isn't something you should do.
    Then turn one of the plugins into an API.
     
  10. Offline

    GRocksMc

    @timtower

    Using it'a own config still doesn't work. It's reading the URL and downloading the pack, it's just not being applied.
     
  11. Offline

    timtower Administrator Administrator Moderator

    That is an issue I won't be able to fix for you.
     
  12. Offline

    SeniorCluckers

    @GRocksMc

    Is the resourcepack setup correctly? Have you tried a different host?
     
  13. Offline

    GRocksMc

    @SeniorCluckers

    I tried using the host you gave me. It worked when I had it setting your resource pack on a command. It just isn't working now. By not working, I mean it downloads it but doesn't actually apply it.

    Btw, I'm using the same resource pack I was before.
     
  14. Offline

    SeniorCluckers

    @GRocksMc

    Can I see some code? Is the version right? Is your minecraft version right for the texturepack being applied?
     
  15. Offline

    GRocksMc

    @SeniorCluckers

    Code:java
    1.  
    2. package com.GRocks.TexturePackPlugin;
    3.  
    4. import org.bukkit.Bukkit;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.Listener;
    8. import org.bukkit.event.player.PlayerTeleportEvent;
    9. import org.bukkit.plugin.Plugin;
    10.  
    11. public class teleportListener implements Listener{
    12.  
    13. Plugin main = Bukkit.getPluginManager().getPlugin("TexturePack");
    14. Main plugin;
    15. public teleportListener(Main instance) {
    16. plugin = instance;
    17. }
    18.  
    19. @EventHandler
    20. public void onPlayerTeleport(PlayerTeleportEvent event){
    21. Player player = event.getPlayer();
    22. String toWorld = event.getTo().getWorld().getName();
    23. if(main.getConfig().getString("Resource_Pack_Worlds." + toWorld) != null){
    24. String URL = (String) main.getConfig().get("Resource_Pack_Worlds." + toWorld);
    25. if(event.getTo().getWorld() != event.getFrom().getWorld()){
    26. Bukkit.getScheduler().scheduleSyncDelayedTask(main, new Runnable(){
    27. public void run(){
    28. player.setResourcePack(URL);
    29. }
    30. }, 20);
    31. }
    32. }
    33. }
    34.  
    35. }
    36.  


    Everything else is the same as when it was working.
     
  16. Offline

    timtower Administrator Administrator Moderator

    @GRocksMc Why do you have a plugin variable and a main?
     
  17. Offline

    GRocksMc

    @timtower

    It's not my only class, I have a few others.
     
  18. Offline

    timtower Administrator Administrator Moderator

    @GRocksMc
    Code:
    Plugin main = Bukkit.getPluginManager().getPlugin("TexturePack");
    Main plugin;
    Are those not the same then?
     
Thread Status:
Not open for further replies.

Share This Page