Skip to content

Commit

Permalink
Fixing teleports
Browse files Browse the repository at this point in the history
Fixed:
- Teleports will actually teleport now

Internal:
Bump to 24.2
  • Loading branch information
Jakllp committed Mar 20, 2021
1 parent d59790d commit 6c86be5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 33 deletions.
55 changes: 23 additions & 32 deletions src/main/java/com/useful/ucars/uCarsListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -1086,22 +1086,6 @@ else if (fuelEnabled
raceCar = true;
}
UEntityMeta.setMetadata(car, "safeExit.ignore", new StatValue(null, plugin));
car.eject();

UUID carId = car.getUniqueId();

car.remove();

final Vehicle ca = car;
Bukkit.getScheduler().runTaskLater(plugin, new Runnable(){

@Override
public void run() {
if(ca != null){
ca.remove(); //For uCarsTrade
}
return;
}}, 2l);

String xs = lines[1];
String ys = lines[2];
Expand All @@ -1125,27 +1109,31 @@ public void run() {
valid = false;
}
if (valid) {
List<MetadataValue> metas = null;
List<MetadataValue> normalMeta = null;
List<MetadataValue> otherMeta = null;
if (player.hasMetadata("car.stayIn") || UEntityMeta.hasMetadata(player, "car.stayIn")) {
metas = player.getMetadata("car.stayIn");
List<MetadataValue> others = UEntityMeta.getMetadata(player, "car.stayIn");
if(others != null){
metas.addAll(others);
normalMeta = player.getMetadata("car.stayIn");
otherMeta = UEntityMeta.getMetadata(player, "car.stayIn");
for (MetadataValue val : normalMeta) {
player.removeMetadata("car.stayIn", val.getOwningPlugin());
}
for (MetadataValue val : metas) {
player.removeMetadata("car.stayIn",
val.getOwningPlugin());
UEntityMeta.removeMetadata(player, "car.stayIn");
if(otherMeta != null) {
for (MetadataValue val : otherMeta) {
UEntityMeta.removeMetadata(player, "car.stayIn");
}
}
}
car.eject();

UUID carId = car.getUniqueId();

Location toTele = new Location(s.getWorld(), x,
y, z);
Chunk ch = toTele.getChunk();
if (ch.isLoaded()) {
ch.load(true);
}
car = (Vehicle) s.getWorld().spawnEntity(
toTele, EntityType.MINECART);
car.teleport(toTele);
UEntityMeta.setMetadata(car, "carhealth", health);
if (raceCar) {
UEntityMeta.setMetadata(car, "kart.racing", new StatValue(null, plugin));
Expand All @@ -1155,8 +1143,7 @@ public void run() {
plugin.getServer().getPluginManager().callEvent(evnt);
if(evnt.isCancelled()){
car.remove();
}
else{
} else{
player.sendMessage(ucars.colors.getTp()
+ "Teleporting...");
final Vehicle ucar = car;
Expand All @@ -1167,12 +1154,16 @@ public void run() {
return;
}}, 2l);
car.setVelocity(travel);
if (metas != null) {
for (MetadataValue val : metas) {
UEntityMeta.setMetadata(player, "car.stayIn", val);
if (normalMeta != null) {
for (MetadataValue val : normalMeta) {
player.setMetadata("car.stayIn", val);
}
}
if (otherMeta != null) {
for (MetadataValue val : otherMeta) {
UEntityMeta.setMetadata(player, "car.stayIn", val);
}
}
plugin.getAPI().updateUcarMeta(carId,
car.getUniqueId());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: uCars
main: com.useful.ucars.ucars
version: 24.1
version: 24.2
api-version: 1.13
softdepend: [Vault]
depend: [ProtocolLib]
Expand Down

0 comments on commit 6c86be5

Please sign in to comment.