Register for your free account! | Forgot your password?

Go Back   elitepvpers > Other Online Games > Minecraft
You last visited: Today at 22:44

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Bukkit] Runnable Method, "Tot" Teleport

Discussion on [Bukkit] Runnable Method, "Tot" Teleport within the Minecraft forum part of the Other Online Games category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2012
Posts: 87
Received Thanks: 3
Question [Bukkit] Runnable Method, "Tot" Teleport

Hii,
Ich habe ein Problem und eine Frage.

Erstmal das Problem:
Ich habe einen RepeatingTask der eine Method ausführt
PHP Code:
Bukkit.getScheduler().scheduleSyncRepeatingTask(pluginrand_item(p), 30 *  20L60 20L); 
Die Method sieht so aus
PHP Code:
    private Runnable rand_item(Player p) {
        final List<
String> list = this.item.getStringList("items");
        
int number = (int) (Math.random()*list.size());
        
PlayerInventory pi p.getInventory();
        
Material mat Material.getMaterial(list.get(number).toUpperCase());
        if(
mat != null){
            
pi.addItem(new ItemStack(mat1));
        }
        
p.sendMessage("Neues Item: " + list.get(number));
        return 
null
Der sagt da ich darf kein null zurück geben. Was muss ich da returnen?



Jetzt komm ich zu meiner Frage:
Ich habe es bei Fun Plugins schon gesehen, dass wenn man kein Leben mehr hat, man nicht stirbt sonder in die Lobby hinteleportiert wird. Ich habe es mit PlayerDeathEvent und mit EntityDamageEvent veruscht aber erfolglos.
__Sandor__ is offline  
Old 03/14/2013, 18:04   #2
 
Howaner's Avatar
 
elite*gold: 132
Join Date: Apr 2010
Posts: 2,864
Received Thanks: 2,009
einfach EntityDamageEvent und da reinschreiben:
Code:
if (event.getEntity().getType() == EntityType.PLAYER)
{
Player player = (Player)event.getEntity();
if (player.getHealth()-event.getDamage() <= 0)
{
player.setHealth(20);
player.teleport(loc);
event.setCancelled(true);
}
}
Zu deinem null Problem:
Die Funktion muss so aussehen:
Code:
    private void rand_item(Player p) { 
        final List<String> list = this.item.getStringList("items"); 
        int number = (int) (Math.random()*list.size()); 
        PlayerInventory pi = p.getInventory(); 
        Material mat = Material.getMaterial(list.get(number).toUpperCase()); 
        if(mat != null){ 
            pi.addItem(new ItemStack(mat, 1)); 
        } 
        p.sendMessage("Neues Item: " + list.get(number)); 
}
Und dein Runnable so:
Code:
final Player player_final = p;
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
rand_item(player_final)
}
}, 30 *  20L, 60 * 20L);
Howaner is offline  
Thanks
1 User
Old 03/14/2013, 19:35   #3
 
elite*gold: 0
Join Date: Sep 2012
Posts: 87
Received Thanks: 3
Funktioniert ich danke dir
__Sandor__ is offline  
Reply




All times are GMT +1. The time now is 22:44.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.