mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-09 20:31:28 +01:00
Add block location placeholders to externalMobProviders map; resolves #538
This commit is contained in:
parent
39d4a910b9
commit
a8ad9c88d2
@ -17,8 +17,6 @@
|
|||||||
package de.erethon.dungeonsxl.mob;
|
package de.erethon.dungeonsxl.mob;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A custom external mob provider like defined in the main config file.
|
* A custom external mob provider like defined in the main config file.
|
||||||
@ -53,14 +51,4 @@ public class CustomExternalMobProvider implements ExternalMobProvider {
|
|||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommand(String mob, String world, double x, double y, double z) {
|
|
||||||
return command.replaceAll("%mob%", mob).replaceAll("%world%", world).replaceAll("%x%", String.valueOf(x)).replaceAll("%y%", String.valueOf(y)).replaceAll("%z%", String.valueOf(z));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void summon(String mob, Location location) {
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), getCommand(mob, location.getWorld().getName(), location.getX(), location.getY(), location.getZ()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package de.erethon.dungeonsxl.mob;
|
package de.erethon.dungeonsxl.mob;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Officially supported external mob plugins.
|
* Officially supported external mob plugins.
|
||||||
*
|
*
|
||||||
@ -26,7 +23,7 @@ import org.bukkit.Location;
|
|||||||
*/
|
*/
|
||||||
public enum ExternalMobPlugin implements ExternalMobProvider {
|
public enum ExternalMobPlugin implements ExternalMobProvider {
|
||||||
|
|
||||||
CUSTOM_MOBS("CM", "ccmob spawn %mob% %world% %x% %y% %z%"),
|
CUSTOM_MOBS("CM", "ccmob spawn %mob% %world% %block_x% %block_y% %block_z%"),
|
||||||
INSANE_MOBS("IM", "insanemobs %mob% %x% %y% %z% %world%"),
|
INSANE_MOBS("IM", "insanemobs %mob% %x% %y% %z% %world%"),
|
||||||
MYTHIC_MOBS("MM", "mythicmobs mobs spawn %mob% 1 %world%,%x%,%y%,%z%");
|
MYTHIC_MOBS("MM", "mythicmobs mobs spawn %mob% 1 %world%,%x%,%y%,%z%");
|
||||||
|
|
||||||
@ -48,24 +45,4 @@ public enum ExternalMobPlugin implements ExternalMobProvider {
|
|||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommand(String mob, String world, double x, double y, double z) {
|
|
||||||
String xStr, yStr, zStr;
|
|
||||||
if (this == CUSTOM_MOBS) {
|
|
||||||
xStr = String.valueOf(Location.locToBlock(x));
|
|
||||||
yStr = String.valueOf(Location.locToBlock(y));
|
|
||||||
zStr = String.valueOf(Location.locToBlock(z));
|
|
||||||
} else {
|
|
||||||
xStr = String.valueOf(x);
|
|
||||||
yStr = String.valueOf(y);
|
|
||||||
zStr = String.valueOf(z);
|
|
||||||
}
|
|
||||||
return command.replaceAll("%mob%", mob).replaceAll("%world%", world).replaceAll("%x%", xStr).replaceAll("%y%", yStr).replaceAll("%z%", zStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void summon(String mob, Location location) {
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), getCommand(mob, location.getWorld().getName(), location.getX(), location.getY(), location.getZ()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.erethon.dungeonsxl.mob;
|
package de.erethon.dungeonsxl.mob;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,12 +29,12 @@ public interface ExternalMobProvider {
|
|||||||
/**
|
/**
|
||||||
* @return the name of the provider plugin
|
* @return the name of the provider plugin
|
||||||
*/
|
*/
|
||||||
public String getIdentifier();
|
String getIdentifier();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the raw command without replaced variables
|
* @return the raw command without replaced variables
|
||||||
*/
|
*/
|
||||||
public String getRawCommand();
|
String getRawCommand();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mob the mob identifier
|
* @param mob the mob identifier
|
||||||
@ -43,12 +44,20 @@ public interface ExternalMobProvider {
|
|||||||
* @param z the z coordinate
|
* @param z the z coordinate
|
||||||
* @return the command with replaced variables
|
* @return the command with replaced variables
|
||||||
*/
|
*/
|
||||||
public String getCommand(String mob, String world, double x, double y, double z);
|
default String getCommand(String mob, String world, double x, double y, double z) {
|
||||||
|
return getRawCommand().replace("%mob%", mob).replace("%world%", world)
|
||||||
|
.replace("%x%", String.valueOf(x)).replace("%y%", String.valueOf(y)).replace("%z%", String.valueOf(z))
|
||||||
|
.replace("%block_x%", String.valueOf(Location.locToBlock(x)))
|
||||||
|
.replace("%block_y%", String.valueOf(Location.locToBlock(y)))
|
||||||
|
.replace("%block_z%", String.valueOf(Location.locToBlock(z)));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mob the mob identifier
|
* @param mob the mob identifier
|
||||||
* @param location the location where the mob will be spawned
|
* @param location the location where the mob will be spawned
|
||||||
*/
|
*/
|
||||||
public void summon(String mob, Location location);
|
default void summon(String mob, Location location) {
|
||||||
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), getCommand(mob, location.getWorld().getName(), location.getX(), location.getY(), location.getZ()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user