Skip to content

Instantly share code, notes, and snippets.

@EventHandler
public void onEntityExplode(EntityExplodeEvent e){
Entity entity = e.getEntity();
if(entity instanceof TNTPrimed){
List<Block> lb = e.blockList();
Location loc = entity.getLocation();
TNTExprotion(loc, lb);
return;
}
}
@keepoff07
keepoff07 / gist:7cd05a6e38eacd9388d8
Last active August 29, 2015 14:07
Schedulerのサンプル
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
final Player p = e.getPlayer();
ItemStack item = p.getItemInHand();
if(e.getAction().equals(Action.RIGHT_CLICK_AIR)||e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
if(item.getType().equals(Material.SUGAR)){
Bukkit.getScheduler().runTaskLater(this, new Runnable(){
public void run(){
Bukkit.broadcastMessage("Delay:"+p.getName());
}
@keepoff07
keepoff07 / gist:8a6f0690e7d6b5889b5b
Created October 4, 2014 06:34
TNTPrimedEventSample
@EventHandler
public void onTNTPrimed(TNTPrimedEvent event){
//着火済みTNTが火打石による着火なら
if(event.getReason().equals(TNTPrimedEvent.SpawnReson.IGNITE)){
Player player = event.getPlayer();
player.sendMessage("You ignition TNT !");
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e){
//死亡したプレイヤーの取得
Player player = e.getEntity();
//最後のダメージイベントがnullでなければ
if(player.getLastDamageCause() != null){
//最後のダメージイベントを取得
EntityDamageEvent damageE = player.getLastDamageCause();
@keepoff07
keepoff07 / DefWorld.java
Last active August 29, 2015 14:07
[Bukkit] DefWorld: get DefaultWorld
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;
@keepoff07
keepoff07 / ExpManager.java
Created October 11, 2014 16:05
[Bukkit] TimerSample
package com.github.keepoff07.hiyaserver.blockparty.timer;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
public class ExpManager {
private JavaPlugin main;
public static void setMain(JavaPlugin plugin){
@keepoff07
keepoff07 / ParticleAPI.java
Last active November 22, 2020 11:48
[Bukkit] ParticleAPI: パーティクル
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@keepoff07
keepoff07 / FireworkEffectAPI.java
Created December 16, 2014 09:43
[Bukkit] FireworkEffectAPI: Easy API to create FireworkEffect.
import java.lang.reflect.Method;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Firework;
import org.bukkit.inventory.meta.FireworkMeta;
public class FireworkEffectAPI {
@keepoff07
keepoff07 / JSONItem.java
Created January 11, 2015 21:25
[Bukkit] JSONItem: convert to ItemStack from JsonText
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
@keepoff07
keepoff07 / BookOpen.java
Last active March 18, 2021 23:36
[Bukkit] BookOpen: 記入済みの本の画面を開かせます。1.8.x用です。
/*
* @author keepoff07
* @license MIT License
* @copyright Copyright keepoff07 2015
*/
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;