mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-03 06:01:30 +01:00
Add BedDestination
This commit is contained in:
parent
6039009e3f
commit
6b543a793a
@ -219,6 +219,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
||||
this.destFactory.registerDestinationType(ExactDestination.class, "e");
|
||||
this.destFactory.registerDestinationType(PlayerDestination.class, "pl");
|
||||
this.destFactory.registerDestinationType(CannonDestination.class, "ca");
|
||||
this.destFactory.registerDestinationType(BedDestination.class, "b");
|
||||
}
|
||||
|
||||
/**
|
||||
|
85
src/main/java/com/onarandombox/utils/BedDestination.java
Normal file
85
src/main/java/com/onarandombox/utils/BedDestination.java
Normal file
@ -0,0 +1,85 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* Multiverse 2
|
||||
*
|
||||
* @author fernferret
|
||||
*/
|
||||
public class BedDestination implements MVDestination {
|
||||
|
||||
private boolean isValid;
|
||||
private Location knownBedLoc;
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "b";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThisType(JavaPlugin plugin, String destination) {
|
||||
String[] split = destination.split(":");
|
||||
this.isValid = split.length >= 1 && split.length <= 2 && split[0].equals(this.getIdentifier());
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation(Entity entity) {
|
||||
if(entity instanceof Player) {
|
||||
this.knownBedLoc = ((Player)entity).getBedSpawnLocation();
|
||||
return this.knownBedLoc;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getVelocity() {
|
||||
return new Vector();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String destination) {
|
||||
// Not needed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return this.isValid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "Bed";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Bed";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
if(knownBedLoc != null){
|
||||
return "multiverse.access."+knownBedLoc.getWorld().getName();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useSafeTeleporter() {
|
||||
// Bukkit should have already checked this.
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user