Undo eclipse regression
This commit is contained in:
1 parent
fa2a372ee8
commit
d7a10e1331
4 files changed
+135
-123
No files matched your search
@@ -129,3 +129,13 @@ tasks.named("compileJava") {
|
||||
tasks.named("spotlessCheck") {
|
||||
dependsOn("spotlessApply") // Run spotless before checking if spotless ran.
|
||||
}
|
||||
|
||||
/* ------------------------------ Eclipse SHIM ------------------------- */
|
||||
|
||||
// This can't be put in eclipse.gradle.kts because Gradle is weird.
|
||||
subprojects {
|
||||
apply(plugin = "java-library")
|
||||
apply(plugin = "eclipse")
|
||||
eclipse.project.name = "${project.name}-${rootProject.name}"
|
||||
tasks.withType<Jar>().configureEach { archiveBaseName.set("${project.name}-${rootProject.name}") }
|
||||
}
|
||||
@@ -13,63 +13,63 @@ import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class Listeners implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
|
||||
// Make sure to never run any other Bukkit functions in runTaskAsynchronously()
|
||||
// (for example accessing players'
|
||||
// inventories)
|
||||
// runTaskAsynchronously() is needed in this case since getTotalShards() calls a
|
||||
// database which can be
|
||||
// too slow to run on the main thread
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TemplateOG.getPlugin(), () -> {
|
||||
// Make sure to never run any other Bukkit functions in runTaskAsynchronously()
|
||||
// (for example accessing players'
|
||||
// inventories)
|
||||
// runTaskAsynchronously() is needed in this case since getTotalShards() calls a
|
||||
// database which can be
|
||||
// too slow to run on the main thread
|
||||
Bukkit.getScheduler().runTaskAsynchronously(TemplateOG.getPlugin(), () -> {
|
||||
|
||||
final int totalShards;
|
||||
try {
|
||||
final int totalShards;
|
||||
try {
|
||||
|
||||
totalShards = TemplateOG.diamondBankAPI().getTotalShards(event.getPlayer().getUniqueId());
|
||||
totalShards = TemplateOG.diamondBankAPI().getTotalShards(event.getPlayer().getUniqueId());
|
||||
|
||||
} catch (DiamondBankException.EconomyDisabledException e) {
|
||||
} catch (DiamondBankException.EconomyDisabledException e) {
|
||||
|
||||
UtilitiesOG.trueogMessage(event.getPlayer(), "<red>The economy is disabled.");
|
||||
return;
|
||||
UtilitiesOG.trueogMessage(event.getPlayer(), "<red>The economy is disabled.");
|
||||
return;
|
||||
|
||||
} catch (DiamondBankException.TransactionsLockedException e) {
|
||||
} catch (DiamondBankException.TransactionsLockedException e) {
|
||||
|
||||
UtilitiesOG.trueogMessage(event.getPlayer(), "<red>Transactions are currently locked for you.");
|
||||
return;
|
||||
UtilitiesOG.trueogMessage(event.getPlayer(), "<red>Transactions are currently locked for you.");
|
||||
return;
|
||||
|
||||
} catch (DiamondBankException.DatabaseException e) {
|
||||
} catch (DiamondBankException.DatabaseException e) {
|
||||
|
||||
UtilitiesOG.trueogMessage(event.getPlayer(), "<red>Something went wrong with the database.");
|
||||
return;
|
||||
UtilitiesOG.trueogMessage(event.getPlayer(), "<red>Something went wrong with the database.");
|
||||
return;
|
||||
|
||||
}
|
||||
// If you don't care about the specific exceptions you can also do the
|
||||
// following:
|
||||
// try {
|
||||
// totalShards =
|
||||
// TemplateOG.diamondBankAPI().getTotalShards(event.getPlayer().getUniqueId());
|
||||
// } catch (DiamondBankException e) {
|
||||
// UtilitiesOG.trueogMessage(event.getPlayer(), "<red>Something went wrong.");
|
||||
// }
|
||||
}
|
||||
// If you don't care about the specific exceptions you can also do the
|
||||
// following:
|
||||
// try {
|
||||
// totalShards =
|
||||
// TemplateOG.diamondBankAPI().getTotalShards(event.getPlayer().getUniqueId());
|
||||
// } catch (DiamondBankException e) {
|
||||
// UtilitiesOG.trueogMessage(event.getPlayer(), "<red>Something went wrong.");
|
||||
// }
|
||||
|
||||
// Send a message to the player with their balance.
|
||||
UtilitiesOG.trueogMessage(event.getPlayer(), "&BYour balance is: &e" + totalShards + "&B Diamond Shards.");
|
||||
UtilitiesOG.logToConsole("[Template-OG]", "The player: " + event.getPlayer()
|
||||
+ "'s <aqua>balance</aqua> is: " + totalShards + "&B Diamond Shards");
|
||||
// Send a message to the player with their balance.
|
||||
UtilitiesOG.trueogMessage(event.getPlayer(), "&BYour balance is: &e" + totalShards + "&B Diamond Shards.");
|
||||
UtilitiesOG.logToConsole("[Template-OG]", "The player: " + event.getPlayer()
|
||||
+ "'s <aqua>balance</aqua> is: " + totalShards + "&B Diamond Shards");
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
save(TemplateOG.config(), Bukkit.getOfflinePlayer("TheMonsterEric"));
|
||||
save(TemplateOG.config(), Bukkit.getOfflinePlayer("TheMonsterEric"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(FileConfiguration config, OfflinePlayer player) {
|
||||
public static void save(FileConfiguration config, OfflinePlayer player) {
|
||||
|
||||
config.set("players." + player.getUniqueId(), player);
|
||||
TemplateOG.getPlugin().saveConfig();
|
||||
config.set("players." + player.getUniqueId(), player);
|
||||
TemplateOG.getPlugin().saveConfig();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,98 +19,100 @@ import net.trueog.gxui.GUIItem;
|
||||
|
||||
public class SpectatorGui extends GUIBase {
|
||||
|
||||
private final Player assignedPlayer;
|
||||
private final Player assignedPlayer;
|
||||
|
||||
public SpectatorGui(JavaPlugin plugin, Player player) {
|
||||
public SpectatorGui(JavaPlugin plugin, Player player) {
|
||||
|
||||
super(plugin, player, "&3&lTest GUI", 9, true);
|
||||
super(plugin, player, "&3&lTest GUI", 9, true);
|
||||
|
||||
assignedPlayer = player;
|
||||
assignedPlayer = player;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupItems() {
|
||||
@Override
|
||||
public void setupItems() {
|
||||
|
||||
int curr = 0;
|
||||
GUIItem item = null;
|
||||
final List<String> name = new ArrayList<>(18);
|
||||
int curr = 0;
|
||||
GUIItem item = null;
|
||||
final List<String> name = new ArrayList<>(18);
|
||||
|
||||
// Add a new element to the list for each player.
|
||||
Bukkit.getOnlinePlayers().forEach((Player p) -> name.add("&eTeleport to: &d&l" + p.getName()));
|
||||
// Add a new element to the list for each player.
|
||||
Bukkit.getOnlinePlayers().forEach((Player p) -> name.add("&eTeleport to: &d&l" + p.getName()));
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
|
||||
item = new GUIItem(Material.PLAYER_HEAD, 1, name.get(curr), p.getName());
|
||||
final GUIButton guibutton = new GUIButton() {
|
||||
item = new GUIItem(Material.PLAYER_HEAD, 1, name.get(curr), p.getName());
|
||||
final GUIButton guibutton = new GUIButton() {
|
||||
|
||||
@Override
|
||||
public boolean leftClick() {
|
||||
@Override
|
||||
public boolean leftClick() {
|
||||
|
||||
assignedPlayer.closeInventory();
|
||||
assignedPlayer.teleport(p);
|
||||
assignedPlayer.closeInventory();
|
||||
assignedPlayer.teleport(p);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean leftClickShift() {
|
||||
@Override
|
||||
public boolean leftClickShift() {
|
||||
|
||||
return false;
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rightClick() {
|
||||
@Override
|
||||
public boolean rightClick() {
|
||||
|
||||
return false;
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rightClickShift() {
|
||||
@Override
|
||||
public boolean rightClickShift() {
|
||||
|
||||
return false;
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
item.setButton(guibutton);
|
||||
item.setButton(guibutton);
|
||||
|
||||
addItem(curr, item);
|
||||
curr = nextCurr(curr);
|
||||
addItem(curr, item);
|
||||
curr = nextCurr(curr);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private int nextCurr(int curr) {
|
||||
private int nextCurr(int curr) {
|
||||
|
||||
if (curr == 3) {
|
||||
if (curr == 3) {
|
||||
|
||||
return 6;
|
||||
return 6;
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
return (curr += 1);
|
||||
return (curr += 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<TextComponent> convertToTextComponents(List<String> stringList) {
|
||||
public static ArrayList<TextComponent> convertToTextComponents(List<String> stringList) {
|
||||
|
||||
final ArrayList<TextComponent> textComponents = new ArrayList<>(18);
|
||||
for (int i = 0; i < stringList.size(); i++) {
|
||||
final String str = stringList.get(i);
|
||||
final TextComponent textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(str);
|
||||
textComponents.add(textComponent);
|
||||
}
|
||||
final ArrayList<TextComponent> textComponents = new ArrayList<>(18);
|
||||
for (int i = 0; i < stringList.size(); i++) {
|
||||
|
||||
return textComponents;
|
||||
final String str = stringList.get(i);
|
||||
final TextComponent textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(str);
|
||||
textComponents.add(textComponent);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return textComponents;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,51 +11,51 @@ import net.trueog.diamondbankog.DiamondBankAPIJava;
|
||||
|
||||
public class TemplateOG extends JavaPlugin {
|
||||
|
||||
private static TemplateOG plugin;
|
||||
private static DiamondBankAPIJava diamondBankAPI;
|
||||
private static FileConfiguration config;
|
||||
private static TemplateOG plugin;
|
||||
private static DiamondBankAPIJava diamondBankAPI;
|
||||
private static FileConfiguration config;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
plugin = this;
|
||||
plugin = this;
|
||||
|
||||
saveDefaultConfig();
|
||||
config = getConfig();
|
||||
saveDefaultConfig();
|
||||
config = getConfig();
|
||||
|
||||
getServer().getPluginManager().registerEvents(new Listeners(), this);
|
||||
getServer().getPluginManager().registerEvents(new Listeners(), this);
|
||||
|
||||
final RegisteredServiceProvider<DiamondBankAPIJava> provider = getServer().getServicesManager()
|
||||
.getRegistration(DiamondBankAPIJava.class);
|
||||
final RegisteredServiceProvider<DiamondBankAPIJava> provider = getServer().getServicesManager()
|
||||
.getRegistration(DiamondBankAPIJava.class);
|
||||
|
||||
if (provider == null) {
|
||||
if (provider == null) {
|
||||
|
||||
getLogger().severe("DiamondBank-OG API is null – disabling plugin.");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
getLogger().severe("DiamondBank-OG API is null – disabling plugin.");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
diamondBankAPI = provider.getProvider();
|
||||
diamondBankAPI = provider.getProvider();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static TemplateOG getPlugin() {
|
||||
public static TemplateOG getPlugin() {
|
||||
|
||||
return plugin;
|
||||
return plugin;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static DiamondBankAPIJava diamondBankAPI() {
|
||||
public static DiamondBankAPIJava diamondBankAPI() {
|
||||
|
||||
return diamondBankAPI;
|
||||
return diamondBankAPI;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static FileConfiguration config() {
|
||||
public static FileConfiguration config() {
|
||||
|
||||
return config;
|
||||
return config;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user