9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00

fix mongodb string url

This commit is contained in:
XiaoMoMi
2024-08-03 04:19:47 +08:00
parent 190c13c795
commit 5921b8823e
3 changed files with 47 additions and 62 deletions

View File

@@ -209,23 +209,20 @@ public class BukkitActionManager implements ActionManager<Player> {
double realRange = range.evaluate(context); double realRange = range.evaluate(context);
Player owner = context.getHolder(); Player owner = context.getHolder();
Location location = requireNonNull(context.arg(ContextKeys.LOCATION)); Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
plugin.getScheduler().sync().run(() -> { for (Player player : Bukkit.getOnlinePlayers()) {
for (Entity player : location.getWorld().getNearbyEntities(location, realRange, realRange, realRange, entity -> entity instanceof Player)) { if (LocationUtils.getDistance(player.getLocation(), location) <= realRange) {
double distance = LocationUtils.getDistance(player.getLocation(), location); context.arg(ContextKeys.TEMP_NEAR_PLAYER, player.getName());
if (distance <= realRange) { List<String> replaced = BukkitPlaceholderManager.getInstance().parse(
context.arg(ContextKeys.TEMP_NEAR_PLAYER, player.getName()); owner,
List<String> replaced = BukkitPlaceholderManager.getInstance().parse( messages,
owner, context.placeholderMap()
messages, );
context.placeholderMap() Audience audience = plugin.getSenderFactory().getAudience(player);
); for (String text : replaced) {
Audience audience = plugin.getSenderFactory().getAudience(player); audience.sendMessage(AdventureHelper.miniMessage(text));
for (String text : replaced) {
audience.sendMessage(AdventureHelper.miniMessage(text));
}
} }
} }
}, location); }
}; };
} else { } else {
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at message-nearby action which should be Section"); plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at message-nearby action which should be Section");
@@ -280,18 +277,15 @@ public class BukkitActionManager implements ActionManager<Player> {
Player owner = context.getHolder(); Player owner = context.getHolder();
double realRange = range.evaluate(context); double realRange = range.evaluate(context);
Location location = requireNonNull(context.arg(ContextKeys.LOCATION)); Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
plugin.getScheduler().sync().run(() -> { for (Player player : Bukkit.getOnlinePlayers()) {
for (Entity player : location.getWorld().getNearbyEntities(location, realRange, realRange, realRange, entity -> entity instanceof Player)) { if (LocationUtils.getDistance(player.getLocation(), location) <= realRange) {
double distance = LocationUtils.getDistance(player.getLocation(), location); context.arg(ContextKeys.TEMP_NEAR_PLAYER, player.getName());
if (distance <= realRange) { List<String> replaced = BukkitPlaceholderManager.getInstance().parse(owner, cmd, context.placeholderMap());
context.arg(ContextKeys.TEMP_NEAR_PLAYER, player.getName()); for (String text : replaced) {
List<String> replaced = BukkitPlaceholderManager.getInstance().parse(owner, cmd, context.placeholderMap()); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), text);
for (String text : replaced) {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), text);
}
} }
} }
}, null); }
}; };
} else { } else {
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at command-nearby action which should be Section"); plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at command-nearby action which should be Section");
@@ -336,18 +330,14 @@ public class BukkitActionManager implements ActionManager<Player> {
Player owner = context.getHolder(); Player owner = context.getHolder();
Location location = requireNonNull(context.arg(ContextKeys.LOCATION)); Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
double realRange = range.evaluate(context); double realRange = range.evaluate(context);
plugin.getScheduler().sync().run(() -> { for (Player player : Bukkit.getOnlinePlayers()) {
for (Entity player : location.getWorld().getNearbyEntities(location, realRange, realRange, realRange, entity -> entity instanceof Player)) { if (LocationUtils.getDistance(player.getLocation(), location) <= realRange) {
double distance = LocationUtils.getDistance(player.getLocation(), location); context.arg(ContextKeys.TEMP_NEAR_PLAYER, player.getName());
if (distance <= realRange) { String replaced = plugin.getPlaceholderManager().parse(owner, actionbar, context.placeholderMap());
context.arg(ContextKeys.TEMP_NEAR_PLAYER, player.getName()); Audience audience = plugin.getSenderFactory().getAudience(player);
String replaced = plugin.getPlaceholderManager().parse(owner, actionbar, context.placeholderMap()); audience.sendActionBar(AdventureHelper.miniMessage(replaced));
Audience audience = plugin.getSenderFactory().getAudience(player); }
audience.sendActionBar(AdventureHelper.miniMessage(replaced)); }
}
}
}, location
);
}; };
} else { } else {
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at actionbar-nearby action which should be Section"); plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at actionbar-nearby action which should be Section");
@@ -756,21 +746,17 @@ public class BukkitActionManager implements ActionManager<Player> {
return context -> { return context -> {
if (Math.random() > chance) return; if (Math.random() > chance) return;
Location location = requireNonNull(context.arg(ContextKeys.LOCATION)); Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
plugin.getScheduler().sync().run(() -> { for (Player player : Bukkit.getOnlinePlayers()) {
for (Entity player : location.getWorld().getNearbyEntities(location, range, range, range, entity -> entity instanceof Player)) { if (LocationUtils.getDistance(player.getLocation(), location) <= range) {
double distance = LocationUtils.getDistance(player.getLocation(), location); context.arg(ContextKeys.TEMP_NEAR_PLAYER, player.getName());
if (distance <= range) { Audience audience = plugin.getSenderFactory().getAudience(player);
context.arg(ContextKeys.TEMP_NEAR_PLAYER, player.getName()); AdventureHelper.sendTitle(audience,
Audience audience = plugin.getSenderFactory().getAudience(player); AdventureHelper.miniMessage(title.render(context)),
AdventureHelper.sendTitle(audience, AdventureHelper.miniMessage(subtitle.render(context)),
AdventureHelper.miniMessage(title.render(context)), fadeIn, stay, fadeOut
AdventureHelper.miniMessage(subtitle.render(context)), );
fadeIn, stay, fadeOut }
); }
}
}
}, location
);
}; };
} else { } else {
plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at title-nearby action which is expected to be `Section`"); plugin.getPluginLogger().warn("Invalid value type: " + args.getClass().getSimpleName() + " found at title-nearby action which is expected to be `Section`");
@@ -806,10 +792,9 @@ public class BukkitActionManager implements ActionManager<Player> {
armorStand.equipment(EquipmentSlot.HEAD, plugin.getItemManager().buildInternal(context, finalItemID)); armorStand.equipment(EquipmentSlot.HEAD, plugin.getItemManager().buildInternal(context, finalItemID));
ArrayList<Player> viewers = new ArrayList<>(); ArrayList<Player> viewers = new ArrayList<>();
if (range > 0) { if (range > 0) {
for (Entity player : location.getWorld().getNearbyEntities(location, range, range, range, entity -> entity instanceof Player)) { for (Player player : Bukkit.getOnlinePlayers()) {
double distance = LocationUtils.getDistance(player.getLocation(), location); if (LocationUtils.getDistance(player.getLocation(), location) <= range) {
if (distance <= range) { viewers.add(player);
viewers.add((Player) player);
} }
} }
} else { } else {
@@ -854,10 +839,9 @@ public class BukkitActionManager implements ActionManager<Player> {
armorStand.name(AdventureHelper.miniMessageToJson(text.render(context))); armorStand.name(AdventureHelper.miniMessageToJson(text.render(context)));
ArrayList<Player> viewers = new ArrayList<>(); ArrayList<Player> viewers = new ArrayList<>();
if (range > 0) { if (range > 0) {
for (Entity player : location.getWorld().getNearbyEntities(location, range, range, range, entity -> entity instanceof Player)) { for (Player player : Bukkit.getOnlinePlayers()) {
double distance = LocationUtils.getDistance(player.getLocation(), location); if (LocationUtils.getDistance(player.getLocation(), location) <= range) {
if (distance <= range) { viewers.add(player);
viewers.add((Player) player);
} }
} }
} else { } else {

View File

@@ -60,7 +60,8 @@ public class MongoDBProvider extends AbstractStorage {
var settings = MongoClientSettings.builder().uuidRepresentation(UuidRepresentation.STANDARD); var settings = MongoClientSettings.builder().uuidRepresentation(UuidRepresentation.STANDARD);
if (!section.getString("connection-uri", "").equals("")) { if (!section.getString("connection-uri", "").equals("")) {
settings.applyConnectionString(new ConnectionString(section.getString("connection-uri", ""))); settings.applyConnectionString(new ConnectionString(section.getString("connection-uri", "")));
mongoClient = MongoClients.create(settings.build()); this.mongoClient = MongoClients.create(settings.build());
this.database = mongoClient.getDatabase(section.getString("database", "minecraft"));
return; return;
} }

View File

@@ -1,6 +1,6 @@
# Project settings # Project settings
# Rule: [major update].[feature update].[bug fix] # Rule: [major update].[feature update].[bug fix]
project_version=2.2.13 project_version=2.2.14
config_version=35 config_version=35
project_group=net.momirealms project_group=net.momirealms