Skip to content

Commit

Permalink
main getters + 3.6.10 release
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperRonanCraft committed Jun 15, 2023
1 parent ee87464 commit c271045
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 67 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>me.SuperRonanCraft</groupId>
<artifactId>BetterRTP</artifactId>
<packaging>jar</packaging>
<version>3.6.10-2DEV</version>
<version>3.6.10</version>

<!-- Upload patches to https://repo.ronanplugins.com/#/ -->

Expand Down
62 changes: 10 additions & 52 deletions src/main/java/me/SuperRonanCraft/BetterRTP/BetterRTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,27 @@
import java.util.logging.Level;

public class BetterRTP extends JavaPlugin {
private final Permissions perms = new Permissions();
private final DepEconomy eco = new DepEconomy();
private final Commands cmd = new Commands(this);
private final RTP rtp = new RTP();
@Getter private final Permissions perms = new Permissions();
@Getter private final DepEconomy eco = new DepEconomy();
@Getter private final Commands cmd = new Commands(this);
@Getter private final RTP RTP = new RTP();
private final EventListener listener = new EventListener();
private static BetterRTP instance;
private final Files files = new Files();
private final RTPInventories invs = new RTPInventories();
private final PlayerInfo pInfo = new PlayerInfo();
@Getter private static BetterRTP instance;
@Getter private final Files files = new Files();
@Getter private final RTPInventories invs = new RTPInventories();
@Getter private final PlayerInfo pInfo = new PlayerInfo();
@Getter private final PlayerDataManager playerDataManager = new PlayerDataManager();
private final Settings settings = new Settings();
@Getter private final Settings settings = new Settings();
@Getter private final CooldownHandler cooldowns = new CooldownHandler();
@Getter private final QueueHandler queue = new QueueHandler();
@Getter private final DatabaseHandler databaseHandler = new DatabaseHandler();
@Getter private final WarningHandler warningHandler = new WarningHandler();
//@Getter private BukkitAudiences adventure;
@Getter private boolean PlaceholderAPI;
@Getter private final RTPLogger rtpLogger = new RTPLogger();

@Override
public void onEnable() {
instance = this;
//this.adventure = BukkitAudiences.create(this);
registerDependencies();
new Updater(this);
new Metrics(this);
Expand All @@ -71,24 +69,12 @@ public void onDisable() {
invs.closeAll();
queue.unload();
rtpLogger.unload();
/*if (this.adventure != null) {
this.adventure.close();
this.adventure = null;
}*/
}

private void registerDependencies() {
PlaceholderAPI = Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI");
}

public Files getFiles() {
return files;
}

public static BetterRTP getInstance() {
return instance;
}

@Override
public boolean onCommand(CommandSender sendi, Command cmd, String label, String[] args) {
try {
Expand All @@ -105,40 +91,12 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
return this.cmd.onTabComplete(sender, args);
}

public Permissions getPerms() {
return perms;
}

public DepEconomy getEco() {
return eco;
}

public Commands getCmd() {
return cmd;
}

public RTP getRTP() {
return rtp;
}

public Settings getSettings() {
return settings;
}

public void reload(CommandSender sendi) {
invs.closeAll();
loadAll();
MessagesCore.RELOAD.send(sendi);
}

public RTPInventories getInvs() {
return invs;
}

public PlayerInfo getpInfo() {
return pInfo;
}

//(Re)Load all plugin systems/files/cache
private void loadAll() {
playerDataManager.clear();
Expand All @@ -148,7 +106,7 @@ private void loadAll() {
rtpLogger.setup(this);
invs.load();
cooldowns.load();
rtp.load();
RTP.load();
cmd.load();
listener.load();
eco.load();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void start(WorldPlayer pWorld) {
private void rtp(CommandSender sendi, WorldPlayer pWorld, RTP_TYPE type) {
//Cooldown
Player p = pWorld.getPlayer();
getPl().getpInfo().getRtping().put(p, true); //Cache player so they cant run '/rtp' again while rtp'ing
getPl().getPInfo().getRtping().put(p, true); //Cache player so they cant run '/rtp' again while rtp'ing
//Setup player rtp methods
RTPPlayer rtpPlayer = new RTPPlayer(p, this, pWorld, type);
// Delaying? Else, just go
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ private void cancel() {
getPl().getRTP().getTeleport().cancelledTeleport(rtp.getPlayer());
//getPl().getEco().unCharge(rtp.getPlayer(), rtp.pWorld);
getPl().getCooldowns().removeCooldown(rtp.getPlayer(), rtp.worldPlayer.getWorld());
getPl().getpInfo().getRtping().remove(rtp.getPlayer());
getPl().getPInfo().getRtping().remove(rtp.getPlayer());
Bukkit.getServer().getPluginManager().callEvent(new RTP_CancelledEvent(rtp.getPlayer()));
}

private Runnable run(final CommandSender sendi, final RTPDelay cls) {
return () -> {
HandlerList.unregisterAll(cls);
if (getPl().getpInfo().getRtping().containsKey(rtp.getPlayer()))
if (getPl().getPInfo().getRtping().containsKey(rtp.getPlayer()))
rtp.randomlyTeleport(sendi);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private void attempt(CommandSender sendi, Location loc) {
} else {
if (worldPlayer.getPlayerInfo().applyCooldown)
getPl().getCooldowns().removeCooldown(player, worldPlayer.getWorld());
getPl().getpInfo().getRtping().remove(player);
getPl().getPInfo().getRtping().remove(player);
}
} else {
randomlyTeleport(sendi);
Expand All @@ -110,7 +110,7 @@ private void attempt(CommandSender sendi, Location loc) {
private void metMax(CommandSender sendi, Player p) {
settings.teleport.failedTeleport(p, sendi);
getPl().getCooldowns().removeCooldown(p, worldPlayer.getWorld());
getPl().getpInfo().getRtping().remove(p);
getPl().getPInfo().getRtping().remove(p);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ public void run() {
afterTeleport(p, loc, wPlayer, attempts, oldLoc, type);
if (sendi != p) //Tell player who requested that the player rtp'd
sendSuccessMsg(sendi, p.getName(), loc, wPlayer, false, attempts);
getPl().getpInfo().getRtping().remove(p); //No longer rtp'ing
getPl().getPInfo().getRtping().remove(p); //No longer rtp'ing
//Save respawn location if first join
if (type == RTP_TYPE.JOIN) //RTP Type was Join
if (BetterRTP.getInstance().getSettings().isRtpOnFirstJoin_SetAsRespawn()) //Save as respawn is enabled
p.setBedSpawnLocation(loc, true); //True means to force a respawn even without a valid bed
}
});
} catch (Exception e) {
getPl().getpInfo().getRtping().remove(p); //No longer rtp'ing (errored)
getPl().getPInfo().getRtping().remove(p); //No longer rtp'ing (errored)
e.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static RTP_ERROR_REQUEST_REASON canRTP(Player player, CommandSender sendi
}

private static boolean isRTPing(Player player) {
return getPl().getpInfo().getRtping().getOrDefault(player, false);
return getPl().getPInfo().getRtping().getOrDefault(player, false);
}

public static boolean isCoolingDown(Player player, WorldPlayer pWorld) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public void load() {
public void closeAll() {
BetterRTP main = BetterRTP.getInstance();
for (Player p : Bukkit.getOnlinePlayers())
if (main.getpInfo().playerExists(p)) {
main.getpInfo().clearInvs(p);
if (main.getPInfo().playerExists(p)) {
main.getPInfo().clearInvs(p);
p.closeInventory();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
public class RTPInvCoordinates extends RTPInventory {

public void show(Player p) {
if (BetterRTP.getInstance().getpInfo().getInvWorld().get(p) == null) {
BetterRTP.getInstance().getpInfo().setNextInv(p, this.type);
if (BetterRTP.getInstance().getPInfo().getInvWorld().get(p) == null) {
BetterRTP.getInstance().getPInfo().setNextInv(p, this.type);
BetterRTP.getInstance().getInvs().getInv(RTP_INV_SETTINGS.WORLDS).show(p);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public void clickEvent(InventoryClickEvent e) {
int _index = 0;
for (World world : Bukkit.getWorlds()) {
if (_index == slot) {
BetterRTP.getInstance().getpInfo().setInvWorld(p, world);
BetterRTP.getInstance().getInvs().getInv(BetterRTP.getInstance().getpInfo().getInvNextInv().get(p)).show(p);
BetterRTP.getInstance().getPInfo().setInvWorld(p, world);
BetterRTP.getInstance().getInvs().getInv(BetterRTP.getInstance().getPInfo().getInvNextInv().get(p)).show(p);
}
_index ++;
}
Expand Down

0 comments on commit c271045

Please sign in to comment.