java - Bukkit title issue -
in minecraft, plugin i've been making few things, including sending title player on join. loop , send title many times. biggest 1 it's gotten far on 100,000 times. can't figure out problem is. there no errors of kind. here bit of code:
class plogin:
package me.photon.plogin; import org.bukkit.bukkit; import org.bukkit.chatcolor; import org.bukkit.entity.player; import org.bukkit.event.eventhandler; import org.bukkit.event.listener; import org.bukkit.event.player.playerjoinevent; import org.bukkit.inventory.itemstack; import org.bukkit.scheduler.bukkitrunnable; public class onlogin implements listener{ private final main plugin; public onlogin(main plugin){ this.plugin=plugin; plugin.getserver().getpluginmanager().registerevents(this, plugin); } //variables---------------------- private string name; private player target; private string world="spawn2.0"; //end variables------------------ @eventhandler private void onjoin(playerjoinevent event){ new bukkitrunnable(){ @suppresswarnings("deprecation") @override public void run() { if((event.getplayer() instanceof player)){ target=event.getplayer(); name=event.getplayer().getname(); bukkit.getserver().dispatchcommand(bukkit.getserver().getconsolesender(),"sun "+target.getworld().getname()+" sun"); bukkit.getserver().dispatchcommand(bukkit.getserver().getconsolesender(),"title "+name+" title {text:'"+plugin.getconfig().getstring("title")+"';color:"+plugin.getconfig().getstring("titlecolor")+"}"); bukkit.getserver().dispatchcommand(bukkit.getserver().getconsolesender(),"title "+name+" subtitle {text:'"+plugin.getconfig().getstring("subtitle")+"';color:"+plugin.getconfig().getstring("subcolor")+"}"); if(target.getworld().getname().equals(world)||target.getworld().getname().equals("skyblock")){ giveitems gi=new giveitems(plugin); gi.main(target); }else{ for(int i=0;i<target.getinventory().getsize();i++){ itemstack ci=target.getinventory().getitem(i); giveitems gi=new giveitems(plugin); system.out.println(ci); if(ci.getamount()>=1&&ci!=null&&(ci==gi.creative()||ci==gi.new_survival()||ci==gi.ninjas()||ci==gi.old_survival()||ci==gi.parkour()||ci==gi.prison()||ci==gi.skyblock()||ci==gi.dcreative()||ci==gi.dnew_survival()||ci==gi.dninjas()||ci==gi.dold_survival()||ci==gi.dparkour()||ci==gi.dprison()||ci==gi.dskyblock())){ int amt=ci.getamount(); ci.setamount(amt-=1); target.updateinventory(); system.out.println("deleted "+ci); } } } if(!target.hasplayedbefore()){ plugin.getconfig().set("exempt."+name+".exempt", false); plugin.saveconfig(); plugin.reloadconfig(); } } if(plugin.getconfig().getboolean("tp")){ if(plugin.getconfig().getboolean("exempt."+name+".exempt")==false){ b("tp","spawn"); } } this.cancel(); } }.runtasklater(this.plugin, 20); } @suppresswarnings("unused") private void a(string msg){ target.sendmessage(chatcolor.translatealternatecolorcodes('&', msg)); } private void b(string cmd1, string cmd2){ bukkit.getserver().dispatchcommand(bukkit.getserver().getconsolesender(), cmd1+name+cmd2); } public player gettarget(){ return target; } public string getworld(){ return world; } }
class main:
package me.photon.plogin //imports public final class main extends javaplugin{ @override public void onenable(){ this.getconfig().options().copydefaults(true); this.saveconfig(); this.savedefaultconfig(); new onlogin(this); } }
sorry if left out variables. in advance help,
photon
p.s. looking code examples, don't use post! (some things may missing) thanks
the problem not cancelling bukkitrunnable after displaying tile. should add this.cancel();
after displaying titles.
Comments
Post a Comment