Adjusted fireworks and dungeon
This commit is contained in:
parent
5012bf486b
commit
8ab5021834
2 changed files with 131 additions and 91 deletions
|
@ -1,91 +1,95 @@
|
||||||
package buttondevteam.alipresents.components.dungeons.dungeons;
|
package buttondevteam.alipresents.components.dungeons.dungeons;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class GenericDungeonA1 extends Dungeon{
|
public class GenericDungeonA1 extends Dungeon{
|
||||||
private Location entrance;
|
private Location entrance;
|
||||||
private Location exit;
|
private Location exit;
|
||||||
private JavaPlugin plugin;
|
private JavaPlugin plugin;
|
||||||
|
|
||||||
public GenericDungeonA1(JavaPlugin plugin){
|
public GenericDungeonA1(JavaPlugin plugin){
|
||||||
if(!initDungeon(plugin)){
|
if(!initDungeon(plugin)){
|
||||||
plugin.getServer().broadcastMessage("DungeonA1 cant be initialized!");
|
plugin.getServer().broadcastMessage("DungeonA1 cant be initialized!");
|
||||||
}
|
}
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
private boolean initDungeon(JavaPlugin plugin){
|
private boolean initDungeon(JavaPlugin plugin){
|
||||||
/*
|
/*
|
||||||
if (plugin.getServer().getWorld("Dungeons") == null || plugin.getServer().getWorld("world") == null){
|
if (plugin.getServer().getWorld("Dungeons") == null || plugin.getServer().getWorld("world") == null){
|
||||||
plugin.getServer().broadcastMessage("GenericDungeonA1Error! One of the worlds is null!");
|
plugin.getServer().broadcastMessage("GenericDungeonA1Error! One of the worlds is null!");
|
||||||
plugin.getServer().broadcastMessage("Available Worlds... " + plugin.getServer().getWorlds().toString());
|
plugin.getServer().broadcastMessage("Available Worlds... " + plugin.getServer().getWorlds().toString());
|
||||||
return false;
|
return false;
|
||||||
}*/
|
}*/
|
||||||
Location temp;
|
Location temp;
|
||||||
if ((temp = loadLocation(plugin, "dungeons.dungeona1.enter")) != null){
|
if ((temp = loadLocation(plugin, "dungeons.dungeona1.enter")) != null){
|
||||||
entrance = temp;
|
entrance = temp;
|
||||||
}else if(plugin.getServer().getWorld("Dungeons") != null){
|
}else if(plugin.getServer().getWorld("Dungeons") != null){
|
||||||
entrance = new Location(plugin.getServer().getWorld("Dungeons"), -7.5, 138.0, -91.5);
|
entrance = new Location(plugin.getServer().getWorld("Dungeons"), -7.5, 138.0, -91.5);
|
||||||
}else{
|
}else{
|
||||||
plugin.getServer().broadcastMessage("There is no working default dungeon entrance for A1, setting to null");
|
plugin.getServer().broadcastMessage("There is no working default dungeon entrance for A1, setting to null");
|
||||||
entrance = null;
|
entrance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp = null;
|
temp = null;
|
||||||
if ((temp = loadLocation(plugin, "dungeons.dungeona1.exit")) != null){
|
if ((temp = loadLocation(plugin, "dungeons.dungeona1.exit")) != null){
|
||||||
exit = temp;
|
exit = temp;
|
||||||
}else if (plugin.getServer().getWorld("world") != null){
|
}else if (plugin.getServer().getWorld("world") != null){
|
||||||
exit = plugin.getServer().getWorld("world").getSpawnLocation().clone();
|
exit = plugin.getServer().getWorld("world").getSpawnLocation().clone();
|
||||||
}else{
|
}else{
|
||||||
plugin.getServer().broadcastMessage("There is no working default dungeon exit for A1, setting to null");
|
plugin.getServer().broadcastMessage("There is no working default dungeon exit for A1, setting to null");
|
||||||
exit = null;
|
exit = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entrance == null || exit == null){
|
if (entrance == null || exit == null){
|
||||||
plugin.getServer().broadcastMessage("DungeonA1Error! Dungeon Entrance or Exit is null!");
|
plugin.getServer().broadcastMessage("DungeonA1Error! Dungeon Entrance or Exit is null!");
|
||||||
plugin.getServer().broadcastMessage("Dungeon Entrance: " + entrance.toString());
|
plugin.getServer().broadcastMessage("Dungeon Entrance: " + entrance.toString());
|
||||||
plugin.getServer().broadcastMessage("Dungeon Exit: " + exit.toString());
|
plugin.getServer().broadcastMessage("Dungeon Exit: " + exit.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void setEntrance(Location location){
|
public void setEntrance(Location location){
|
||||||
saveLocation(plugin, "dungeons.dungeona1.enter", location);
|
saveLocation(plugin, "dungeons.dungeona1.enter", location);
|
||||||
entrance = location;
|
entrance = location;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void setExit(Location location){
|
public void setExit(Location location){
|
||||||
saveLocation(plugin, "dungeons.dungeona1.exit", location);
|
saveLocation(plugin, "dungeons.dungeona1.exit", location);
|
||||||
exit = location;
|
exit = location;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Location getDungeonEntrance() {
|
public Location getDungeonEntrance() {
|
||||||
return entrance;
|
return entrance;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public Location getDungeonExit() {
|
public Location getDungeonExit() {
|
||||||
return exit;
|
return exit;
|
||||||
}
|
}
|
||||||
private void saveLocation(JavaPlugin plugin, String path, Location location){
|
private void saveLocation(JavaPlugin plugin, String path, Location location){
|
||||||
plugin.getConfig().set(path+".world", location.getWorld().getName());
|
plugin.getConfig().set(path+".world", location.getWorld().getName());
|
||||||
plugin.getConfig().set(path+".x", location.getX());
|
plugin.getConfig().set(path+".x", location.getX());
|
||||||
plugin.getConfig().set(path+".y", location.getY());
|
plugin.getConfig().set(path+".y", location.getY());
|
||||||
plugin.getConfig().set(path+".z", location.getZ());
|
plugin.getConfig().set(path+".z", location.getZ());
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
}
|
}
|
||||||
private Location loadLocation(JavaPlugin plugin, String path){
|
private Location loadLocation(JavaPlugin plugin, String path){
|
||||||
try{
|
try{
|
||||||
World world = plugin.getServer().getWorld(plugin.getConfig().getString(path+".world"));
|
String worldname = plugin.getConfig().getString(path+".world");
|
||||||
double x = plugin.getConfig().getDouble(path+".x");
|
if(worldname == null) return null;
|
||||||
double y = plugin.getConfig().getDouble(path+".y");
|
|
||||||
double z = plugin.getConfig().getDouble(path+".z");
|
World world = plugin.getServer().getWorld(worldname);
|
||||||
|
double x = plugin.getConfig().getDouble(path+".x");
|
||||||
return new Location(world, x, y, z);
|
double y = plugin.getConfig().getDouble(path+".y");
|
||||||
}catch(Exception e){
|
double z = plugin.getConfig().getDouble(path+".z");
|
||||||
e.printStackTrace();
|
if (world == null) return null;
|
||||||
return null;
|
|
||||||
}
|
return new Location(world, x, y, z);
|
||||||
}
|
}catch(Exception e){
|
||||||
}
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package buttondevteam.alipresents.components.hotfix.hotfixes;
|
||||||
|
|
||||||
|
import org.bukkit.FireworkEffect;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.FireworkMeta;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class ElytraFireworks implements Listener {
|
||||||
|
JavaPlugin plugin;
|
||||||
|
public ElytraFireworks(JavaPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
public void onRightClick(PlayerInteractEvent event){
|
||||||
|
//ACTION SANITATION
|
||||||
|
if(!(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) return;
|
||||||
|
if(!(event.getPlayer().isGliding())) return;
|
||||||
|
if(!(event.getMaterial() == Material.FIREWORK)) return;
|
||||||
|
|
||||||
|
//BOW SANITATION
|
||||||
|
ItemStack firework = event.getItem();
|
||||||
|
FireworkMeta fireworkMeta= (FireworkMeta) firework.getItemMeta();
|
||||||
|
for (FireworkEffect effect : fireworkMeta.getEffects()){
|
||||||
|
event.getPlayer().sendMessage(effect.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
//PLAYER SANITATION
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if(player.getGameMode().equals(GameMode.SPECTATOR))return;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue