@Override
public void onEnable(){
Bukkit.getServer().getPluginManager().registerEvents(this , this);
}
@EventHandler
public void onExplode(EntityExplodeEvent e){
Settings ss = Settings.getInstance();
Region region = RegionUtils.getAt(e.getLocation());
if (region == null){
return;
}
Guild g = region.getGuild();
if (g == null || g.getName() == null){
return;
}
if (g != null) {
List<Location> s = sphere(e.getLocation(), 5, 5, false, true, 0);
Map ExplodeMaterials = ss.explodeMaterials;
for (final Location loc : s) {
Material mat = loc.getBlock().getType();
if (ExplodeMaterials.containsKey(mat)) {
if(mat.equals(Material.WATER)){
loc.getBlock().setType(Material.AIR);
}
else{ loc.getBlock().breakNaturally();
}
}
if (mat.equals(Material.JUKEBOX)) {
Bukkit.getScheduler().runTaskLater(new Main(), new Runnable(){
public void run(){
loc.getBlock().setType(Material.JUKEBOX);
}
}, 1L);
}
}
g.setBuild(System.currentTimeMillis() + Settings.getInstance().regionExplode * 1000L);
for (User user : g.getMembers()){
Player player = Bukkit.getPlayer(user.getName());
if (player != null) {
player.sendMessage(Messages.getInstance().getMessage("regionExplode")
.replace("{TIME}", Integer.toString(Settings.getInstance().regionExplode)));
}
}
}
}
public static List<Location> sphere(Location loc, int radius, int height, boolean hollow, boolean sphere, int plusY){
List circleblocks = new ArrayList();
int cx = loc.getBlockX();
int cy = loc.getBlockY();
int cz = loc.getBlockZ();
for (int x = cx - radius; x <= cx + radius; x++) {
for (int z = cz - radius; z <= cz + radius; z++) {
for (int y = sphere ? cy - radius : cy; y < (sphere ? cy + radius : cy + height); y++) {
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0);
if ((dist < radius * radius) && ((!hollow) || (dist >= (radius - 1) * (radius - 1)))) {
Location l = new Location(loc.getWorld(), x, y + plusY, z);
circleblocks.add(l);
}
}
}
}
return circleblocks;
}
ale oczywiście nie działa tylko to co chcę
Material mat = loc.getBlock().getType();
if (ExplodeMaterials.containsKey(mat)) {
if(mat.equals(Material.WATER)){
loc.getBlock().setType(Material.AIR);
}
else{ loc.getBlock().breakNaturally();
}
}
if (mat.equals(Material.JUKEBOX)) {
Bukkit.getScheduler().runTaskLater(new Main(), new Runnable(){
public void run(){
loc.getBlock().setType(Material.JUKEBOX);
}
}, 1L);
}
Pytanie
xTea_199 4
Mam oto taki kod:
ale oczywiście nie działa tylko to co chcę
Material mat = loc.getBlock().getType(); if (ExplodeMaterials.containsKey(mat)) { if(mat.equals(Material.WATER)){ loc.getBlock().setType(Material.AIR); } else{ loc.getBlock().breakNaturally(); } } if (mat.equals(Material.JUKEBOX)) { Bukkit.getScheduler().runTaskLater(new Main(), new Runnable(){ public void run(){ loc.getBlock().setType(Material.JUKEBOX); } }, 1L); }Pomoże ktoś to naprawić?
Odnośnik do komentarza
https://skript.pl/temat/20421-wybuchanie-wody-poprzez-tnt/Udostępnij na innych stronach
2 odpowiedzi na to pytanie
Rekomendowane odpowiedzi