Finished DiscordPlayerSender and improved things
This commit is contained in:
parent
19df7a375e
commit
71e90bcf60
2 changed files with 93 additions and 143 deletions
|
@ -103,12 +103,12 @@ public class DiscordPlayerSender implements Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOp() { // TODO: Connect with TBMC acc
|
public boolean isOp() {
|
||||||
return player.isOp();
|
return player.isOp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOp(boolean value) { // TODO: Connect with TBMC acc
|
public void setOp(boolean value) {
|
||||||
player.setOp(value);
|
player.setOp(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
TBMCCoreAPI.SendException("An error occured while sending message to DiscordSender", e);
|
TBMCCoreAPI.SendException("An error occured while sending message to DiscordSender", e);
|
||||||
}
|
}
|
||||||
|
player.sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -201,8 +202,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean performCommand(String command) {
|
public boolean performCommand(String command) {
|
||||||
player.performCommand(command);
|
return player.performCommand(command);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find: " (\w+)\(\) \{\s+\/\/ TO\DO Auto-generated method stub\s+return false;" - Replace: " $1() { return player.$1();"
|
// Find: " (\w+)\(\) \{\s+\/\/ TO\DO Auto-generated method stub\s+return false;" - Replace: " $1() { return player.$1();"
|
||||||
|
@ -356,8 +356,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasAchievement(Achievement achievement) {
|
public boolean hasAchievement(Achievement achievement) {
|
||||||
player.hasAchievement(achievement);
|
return player.hasAchievement(achievement);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -388,8 +387,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStatistic(Statistic statistic) throws IllegalArgumentException {
|
public int getStatistic(Statistic statistic) throws IllegalArgumentException {
|
||||||
player.getStatistic(statistic);
|
return player.getStatistic(statistic);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -404,8 +402,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStatistic(Statistic statistic, Material material) throws IllegalArgumentException {
|
public int getStatistic(Statistic statistic, Material material) throws IllegalArgumentException {
|
||||||
player.getStatistic(statistic, material);
|
return player.getStatistic(statistic, material);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find: " (\w+)\((\w+) (\w+), (\w+) (\w+), (\w+) (\w+)\)(.+)\{\s+\/\/ TO\DO Auto-generated method stub\s" - Replace: " $1($2 $3, $4 $5, $6 $7) $8 { player.$1($3, $5, $7);"
|
// Find: " (\w+)\((\w+) (\w+), (\w+) (\w+), (\w+) (\w+)\)(.+)\{\s+\/\/ TO\DO Auto-generated method stub\s" - Replace: " $1($2 $3, $4 $5, $6 $7) $8 { player.$1($3, $5, $7);"
|
||||||
|
@ -436,8 +433,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getStatistic(Statistic statistic, EntityType entityType) throws IllegalArgumentException {
|
public int getStatistic(Statistic statistic, EntityType entityType) throws IllegalArgumentException {
|
||||||
player.getStatistic(statistic, entityType);
|
return player.getStatistic(statistic, entityType);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -466,14 +462,12 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getPlayerTime() {
|
public long getPlayerTime() {
|
||||||
player.getPlayerTime();
|
return player.getPlayerTime();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getPlayerTimeOffset() {
|
public long getPlayerTimeOffset() {
|
||||||
player.getPlayerTimeOffset();
|
return player.getPlayerTimeOffset();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -513,8 +507,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getExp() {
|
public float getExp() {
|
||||||
player.getExp();
|
return player.getExp();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -524,8 +517,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLevel() {
|
public int getLevel() {
|
||||||
player.getLevel();
|
return player.getLevel();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -535,8 +527,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTotalExperience() {
|
public int getTotalExperience() {
|
||||||
player.getTotalExperience();
|
return player.getTotalExperience();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -546,8 +537,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getExhaustion() {
|
public float getExhaustion() {
|
||||||
player.getExhaustion();
|
return player.getExhaustion();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -557,8 +547,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getSaturation() {
|
public float getSaturation() {
|
||||||
player.getSaturation();
|
return player.getSaturation();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -568,8 +557,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFoodLevel() {
|
public int getFoodLevel() {
|
||||||
player.getFoodLevel();
|
return player.getFoodLevel();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -614,8 +602,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canSee(Player player) {
|
public boolean canSee(Player player) {
|
||||||
player.canSee(player);
|
return player.canSee(player);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -643,16 +630,15 @@ public class DiscordPlayerSender implements Player {
|
||||||
player.setWalkSpeed(value);
|
player.setWalkSpeed(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find: "\{\s+(.+)\s+return (?:(?:0)|(?:null)|(?:false));" - Replace: "{ return $1"
|
||||||
@Override
|
@Override
|
||||||
public float getFlySpeed() {
|
public float getFlySpeed() {
|
||||||
player.getFlySpeed();
|
return player.getFlySpeed();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getWalkSpeed() {
|
public float getWalkSpeed() {
|
||||||
player.getWalkSpeed();
|
return player.getWalkSpeed();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -693,8 +679,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getHealthScale() {
|
public double getHealthScale() {
|
||||||
player.getHealthScale();
|
return player.getHealthScale();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -809,8 +794,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setWindowProperty(Property prop, int value) {
|
public boolean setWindowProperty(Property prop, int value) {
|
||||||
player.setWindowProperty(prop, value);
|
return player.setWindowProperty(prop, value);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -820,20 +804,17 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryView openInventory(Inventory inventory) {
|
public InventoryView openInventory(Inventory inventory) {
|
||||||
player.openInventory(inventory);
|
return player.openInventory(inventory);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryView openWorkbench(Location location, boolean force) {
|
public InventoryView openWorkbench(Location location, boolean force) {
|
||||||
player.openWorkbench(location, force);
|
return player.openWorkbench(location, force);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryView openEnchanting(Location location, boolean force) {
|
public InventoryView openEnchanting(Location location, boolean force) {
|
||||||
player.openEnchanting(location, force);
|
return player.openEnchanting(location, force);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -843,14 +824,12 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryView openMerchant(Villager trader, boolean force) {
|
public InventoryView openMerchant(Villager trader, boolean force) {
|
||||||
player.openMerchant(trader, force);
|
return player.openMerchant(trader, force);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryView openMerchant(Merchant merchant, boolean force) {
|
public InventoryView openMerchant(Merchant merchant, boolean force) {
|
||||||
player.openMerchant(merchant, force);
|
return player.openMerchant(merchant, force);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -885,8 +864,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSleepTicks() {
|
public int getSleepTicks() {
|
||||||
player.getSleepTicks();
|
return player.getSleepTicks();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -911,20 +889,17 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getExpToLevel() {
|
public int getExpToLevel() {
|
||||||
player.getExpToLevel();
|
return player.getExpToLevel();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getEyeHeight() {
|
public double getEyeHeight() {
|
||||||
player.getEyeHeight();
|
return player.getEyeHeight();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getEyeHeight(boolean ignoreSneaking) {
|
public double getEyeHeight(boolean ignoreSneaking) {
|
||||||
player.getEyeHeight(ignoreSneaking);
|
return player.getEyeHeight(ignoreSneaking);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -964,8 +939,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRemainingAir() {
|
public int getRemainingAir() {
|
||||||
player.getRemainingAir();
|
return player.getRemainingAir();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -975,8 +949,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaximumAir() {
|
public int getMaximumAir() {
|
||||||
player.getMaximumAir();
|
return player.getMaximumAir();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -986,8 +959,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaximumNoDamageTicks() {
|
public int getMaximumNoDamageTicks() {
|
||||||
player.getMaximumNoDamageTicks();
|
return player.getMaximumNoDamageTicks();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -997,14 +969,12 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getLastDamage() {
|
public double getLastDamage() {
|
||||||
player.getLastDamage();
|
return player.getLastDamage();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int _INVALID_getLastDamage() {
|
public int _INVALID_getLastDamage() {
|
||||||
player._INVALID_getLastDamage();
|
return player._INVALID_getLastDamage();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1019,8 +989,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getNoDamageTicks() {
|
public int getNoDamageTicks() {
|
||||||
player.getNoDamageTicks();
|
return player.getNoDamageTicks();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1035,14 +1004,12 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addPotionEffect(PotionEffect effect) {
|
public boolean addPotionEffect(PotionEffect effect) {
|
||||||
player.addPotionEffect(effect);
|
return player.addPotionEffect(effect);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addPotionEffect(PotionEffect effect, boolean force) {
|
public boolean addPotionEffect(PotionEffect effect, boolean force) {
|
||||||
player.addPotionEffect(effect, force);
|
return player.addPotionEffect(effect, force);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1052,14 +1019,12 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPotionEffect(PotionEffectType type) {
|
public boolean hasPotionEffect(PotionEffectType type) {
|
||||||
player.hasPotionEffect(type);
|
return player.hasPotionEffect(type);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PotionEffect getPotionEffect(PotionEffectType type) {
|
public PotionEffect getPotionEffect(PotionEffectType type) {
|
||||||
player.getPotionEffect(type);
|
return player.getPotionEffect(type);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1074,8 +1039,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasLineOfSight(Entity other) {
|
public boolean hasLineOfSight(Entity other) {
|
||||||
player.hasLineOfSight(other);
|
return player.hasLineOfSight(other);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1115,8 +1079,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setLeashHolder(Entity holder) {
|
public boolean setLeashHolder(Entity holder) {
|
||||||
player.setLeashHolder(holder);
|
return player.setLeashHolder(holder);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1151,8 +1114,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AttributeInstance getAttribute(Attribute attribute) {
|
public AttributeInstance getAttribute(Attribute attribute) {
|
||||||
player.getAttribute(attribute);
|
return player.getAttribute(attribute);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1162,8 +1124,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getLocation(Location loc) {
|
public Location getLocation(Location loc) {
|
||||||
player.getLocation(loc);
|
return player.getLocation(loc);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1183,50 +1144,42 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(Location location) {
|
public boolean teleport(Location location) {
|
||||||
player.teleport(location);
|
return player.teleport(location);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(Location location, TeleportCause cause) {
|
public boolean teleport(Location location, TeleportCause cause) {
|
||||||
player.teleport(location, cause);
|
return player.teleport(location, cause);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(Entity destination) {
|
public boolean teleport(Entity destination) {
|
||||||
player.teleport(destination);
|
return player.teleport(destination);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(Entity destination, TeleportCause cause) {
|
public boolean teleport(Entity destination, TeleportCause cause) {
|
||||||
player.teleport(destination, cause);
|
return player.teleport(destination, cause);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Entity> getNearbyEntities(double x, double y, double z) {
|
public List<Entity> getNearbyEntities(double x, double y, double z) {
|
||||||
player.getNearbyEntities(x, y, z);
|
return player.getNearbyEntities(x, y, z);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEntityId() {
|
public int getEntityId() {
|
||||||
player.getEntityId();
|
return player.getEntityId();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFireTicks() {
|
public int getFireTicks() {
|
||||||
player.getFireTicks();
|
return player.getFireTicks();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxFireTicks() {
|
public int getMaxFireTicks() {
|
||||||
player.getMaxFireTicks();
|
return player.getMaxFireTicks();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1256,8 +1209,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setPassenger(Entity passenger) {
|
public boolean setPassenger(Entity passenger) {
|
||||||
player.setPassenger(passenger);
|
return player.setPassenger(passenger);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1272,8 +1224,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getFallDistance() {
|
public float getFallDistance() {
|
||||||
player.getFallDistance();
|
return player.getFallDistance();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1298,8 +1249,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTicksLived() {
|
public int getTicksLived() {
|
||||||
player.getTicksLived();
|
return player.getTicksLived();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1384,8 +1334,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPortalCooldown() {
|
public int getPortalCooldown() {
|
||||||
player.getPortalCooldown();
|
return player.getPortalCooldown();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1400,14 +1349,12 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addScoreboardTag(String tag) {
|
public boolean addScoreboardTag(String tag) {
|
||||||
player.addScoreboardTag(tag);
|
return player.addScoreboardTag(tag);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeScoreboardTag(String tag) {
|
public boolean removeScoreboardTag(String tag) {
|
||||||
player.removeScoreboardTag(tag);
|
return player.removeScoreboardTag(tag);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1417,14 +1364,12 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MetadataValue> getMetadata(String metadataKey) {
|
public List<MetadataValue> getMetadata(String metadataKey) {
|
||||||
player.getMetadata(metadataKey);
|
return player.getMetadata(metadataKey);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasMetadata(String metadataKey) {
|
public boolean hasMetadata(String metadataKey) {
|
||||||
player.hasMetadata(metadataKey);
|
return player.hasMetadata(metadataKey);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1464,14 +1409,12 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getHealth() {
|
public double getHealth() {
|
||||||
player.getHealth();
|
return player.getHealth();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int _INVALID_getHealth() {
|
public int _INVALID_getHealth() {
|
||||||
player._INVALID_getHealth();
|
return player._INVALID_getHealth();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1486,14 +1429,12 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMaxHealth() {
|
public double getMaxHealth() {
|
||||||
player.getMaxHealth();
|
return player.getMaxHealth();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int _INVALID_getMaxHealth() {
|
public int _INVALID_getMaxHealth() {
|
||||||
player._INVALID_getMaxHealth();
|
return player._INVALID_getMaxHealth();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1533,8 +1474,7 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean beginConversation(Conversation conversation) {
|
public boolean beginConversation(Conversation conversation) {
|
||||||
player.beginConversation(conversation);
|
return player.beginConversation(conversation);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1579,14 +1519,12 @@ public class DiscordPlayerSender implements Player {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getFirstPlayed() {
|
public long getFirstPlayed() {
|
||||||
player.getFirstPlayed();
|
return player.getFirstPlayed();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getLastPlayed() {
|
public long getLastPlayed() {
|
||||||
player.getLastPlayed();
|
return player.getLastPlayed();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,11 +7,13 @@ import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import buttondevteam.discordplugin.DiscordPlayer;
|
import buttondevteam.discordplugin.DiscordPlayer;
|
||||||
|
import buttondevteam.discordplugin.DiscordPlayerSender;
|
||||||
import buttondevteam.discordplugin.DiscordPlugin;
|
import buttondevteam.discordplugin.DiscordPlugin;
|
||||||
import buttondevteam.discordplugin.DiscordSender;
|
import buttondevteam.discordplugin.DiscordSender;
|
||||||
import buttondevteam.lib.TBMCChatEvent;
|
import buttondevteam.lib.TBMCChatEvent;
|
||||||
|
@ -33,9 +35,11 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
"<" + e.getSender().getName() + "> " + e.getMessage());
|
"<" + e.getSender().getName() + "> " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String[] UnconnectedCmds = new String[] { "list", "u", "shrug", "tableflip", "unflip", "mwiki" };
|
private static final String[] UnconnectedCmds = new String[] { "list", "u", "shrug", "tableflip", "unflip",
|
||||||
|
"mwiki" };
|
||||||
|
|
||||||
public static final HashMap<String, DiscordSender> UnconnectedSenders = new HashMap<>();
|
public static final HashMap<String, DiscordSender> UnconnectedSenders = new HashMap<>();
|
||||||
|
public static final HashMap<String, DiscordPlayerSender> ConnectedSenders = new HashMap<>();
|
||||||
|
|
||||||
@Override // Discord
|
@Override // Discord
|
||||||
public void handle(MessageReceivedEvent event) {
|
public void handle(MessageReceivedEvent event) {
|
||||||
|
@ -45,26 +49,26 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
if (!event.getMessage().getChannel().getID().equals(DiscordPlugin.chatchannel.getID())
|
if (!event.getMessage().getChannel().getID().equals(DiscordPlugin.chatchannel.getID())
|
||||||
/* && !(event.getMessage().getChannel().isPrivate() && privatechat) */)
|
/* && !(event.getMessage().getChannel().isPrivate() && privatechat) */)
|
||||||
return;
|
return;
|
||||||
if (!UnconnectedSenders.containsKey(author.getID()))
|
|
||||||
UnconnectedSenders.put(author.getID(), new DiscordSender(author));
|
|
||||||
final DiscordSender dsender = UnconnectedSenders.get(author.getID());
|
|
||||||
dsender.setChannel(event.getMessage().getChannel());
|
|
||||||
if (event.getMessage().getContent().startsWith("/")) {
|
if (event.getMessage().getContent().startsWith("/")) {
|
||||||
final String cmd = event.getMessage().getContent().substring(1);
|
final String cmd = event.getMessage().getContent().substring(1);
|
||||||
Optional<? extends Player> str = Bukkit.getOnlinePlayers().stream().filter(p -> { // TODO: Support offline players
|
Optional<? extends Player> str = Bukkit.getOnlinePlayers().stream().filter(p -> { // TODO: Support offline players
|
||||||
try (DiscordPlayer dp = TBMCPlayer.getPlayerAs(p, DiscordPlayer.class)) {
|
DiscordPlayer dp = TBMCPlayer.getPlayerAs(p, DiscordPlayer.class); // Online player, already loaded
|
||||||
return author.getID().equals(dp.getDiscordID());
|
return author.getID().equals(dp.getDiscordID());
|
||||||
} catch (Exception e) {
|
|
||||||
TBMCCoreAPI.SendException("An error occured while getting Discord player for chat", e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).findAny();
|
}).findAny();
|
||||||
try {
|
try {
|
||||||
if (str.isPresent()) // Connected?
|
if (str.isPresent()) // Connected?
|
||||||
{
|
{
|
||||||
|
if (!ConnectedSenders.containsKey(author.getID()))
|
||||||
|
ConnectedSenders.put(author.getID(), new DiscordPlayerSender(author, str.get()));
|
||||||
|
final DiscordPlayerSender dsender = ConnectedSenders.get(author.getID());
|
||||||
|
dsender.setChannel(event.getMessage().getChannel());
|
||||||
// Execute as ingame player
|
// Execute as ingame player
|
||||||
Bukkit.dispatchCommand(str.get(), cmd);
|
Bukkit.dispatchCommand(dsender, cmd);
|
||||||
} else {
|
} else {
|
||||||
|
if (!UnconnectedSenders.containsKey(author.getID()))
|
||||||
|
UnconnectedSenders.put(author.getID(), new DiscordSender(author));
|
||||||
|
final DiscordSender dsender = UnconnectedSenders.get(author.getID());
|
||||||
|
dsender.setChannel(event.getMessage().getChannel());
|
||||||
if (!Arrays.stream(UnconnectedCmds).anyMatch(s -> cmd.startsWith(s))) {
|
if (!Arrays.stream(UnconnectedCmds).anyMatch(s -> cmd.startsWith(s))) {
|
||||||
// Command not whitelisted
|
// Command not whitelisted
|
||||||
DiscordPlugin.sendMessageToChannel(event.getMessage().getChannel(), // TODO
|
DiscordPlugin.sendMessageToChannel(event.getMessage().getChannel(), // TODO
|
||||||
|
@ -77,10 +81,18 @@ public class MCChatListener implements Listener, IListener<MessageReceivedEvent>
|
||||||
TBMCCoreAPI.SendException("An error occured while executing command " + cmd + "!", e);
|
TBMCCoreAPI.SendException("An error occured while executing command " + cmd + "!", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
|
CommandSender dsender = UnconnectedSenders.get(author.getID());
|
||||||
|
if (dsender == null)
|
||||||
|
dsender = ConnectedSenders.get(author.getID());
|
||||||
|
if (dsender == null) {
|
||||||
|
UnconnectedSenders.put(author.getID(), new DiscordSender(author));
|
||||||
|
dsender = UnconnectedSenders.get(author.getID());
|
||||||
|
}
|
||||||
TBMCChatAPI.SendChatMessage(Channel.GlobalChat, dsender,
|
TBMCChatAPI.SendChatMessage(Channel.GlobalChat, dsender,
|
||||||
event.getMessage().getContent()
|
event.getMessage().getContent()
|
||||||
+ (event.getMessage().getAttachments().size() > 0 ? event.getMessage().getAttachments()
|
+ (event.getMessage().getAttachments().size() > 0 ? event.getMessage().getAttachments()
|
||||||
.stream().map(a -> a.getUrl()).collect(Collectors.joining("\n")) : ""));
|
.stream().map(a -> a.getUrl()).collect(Collectors.joining("\n")) : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue