Skip to content

Commit d4e3fcf

Browse files
author
Xyness
committed
1.12.0.6
1 parent ce2ae09 commit d4e3fcf

File tree

7 files changed

+98
-70
lines changed

7 files changed

+98
-70
lines changed

src/main/java/fr/xyness/SCS/ClaimMain.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -877,46 +877,6 @@ public void teleportPlayerToExpulsion(Player player) {
877877
Location loc = instance.getSettings().getExpulsionLocation();
878878
teleportPlayer(player,loc == null ? Bukkit.getWorlds().get(0).getSpawnLocation() : loc);
879879
}
880-
881-
/**
882-
* Teleport player to the ground.
883-
*
884-
* @param player The player to teleport.
885-
*/
886-
public void teleportToGround(Player player) {
887-
Location loc = player.getLocation();
888-
if(instance.isFolia()) {
889-
Bukkit.getRegionScheduler().run(instance, loc, task -> {
890-
World world = player.getWorld();
891-
int startY = loc.getBlockY();
892-
for (int y = startY - 1; y >= Math.max(startY - 10, world.getMinHeight()); y--) {
893-
Block block = world.getBlockAt(loc.getBlockX(), y, loc.getBlockZ());
894-
if (block.getType() != Material.AIR) {
895-
Location cloned = loc.clone();
896-
cloned.setY(block.getLocation().getY());
897-
teleportPlayer(player, cloned);
898-
return;
899-
}
900-
}
901-
teleportPlayer(player, loc);
902-
});
903-
} else {
904-
World world = player.getWorld();
905-
int startY = loc.getBlockY();
906-
for (int y = startY - 1; y >= Math.max(startY - 10, world.getMinHeight()); y--) {
907-
Block block = world.getBlockAt(loc.getBlockX(), y, loc.getBlockZ());
908-
if (block.getType() != Material.AIR) {
909-
Location cloned = loc.clone();
910-
cloned.setY(block.getLocation().getY());
911-
teleportPlayer(player, cloned);
912-
return;
913-
}
914-
}
915-
teleportPlayer(player, loc);
916-
}
917-
918-
}
919-
920880

921881
/**
922882
* Creates the teleport task for goClaim method.

src/main/java/fr/xyness/SCS/Config/ClaimSettings.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,11 @@ public boolean getSettingSRC(String setting) {
467467
* @param mat The list of material names to restrict.
468468
*/
469469
public void setRestrictedItems(List<String> mat) {
470-
restrictedItems.clear();
470+
restrictedItems.clear();
471471
mat.stream()
472-
.map(Material::matchMaterial)
473-
.filter(Objects::nonNull)
474-
.peek(restrictedItems::add);
472+
.map(Material::matchMaterial)
473+
.filter(Objects::nonNull)
474+
.forEach(restrictedItems::add); // Utilisation de forEach ici
475475
}
476476

477477
/**
@@ -480,11 +480,11 @@ public void setRestrictedItems(List<String> mat) {
480480
* @param mat The list of material names to restrict as containers.
481481
*/
482482
public void setRestrictedContainers(List<String> mat) {
483-
restrictedInteractBlocks.clear();
483+
restrictedInteractBlocks.clear();
484484
mat.stream()
485-
.map(Material::matchMaterial)
486-
.filter(Objects::nonNull)
487-
.peek(restrictedInteractBlocks::add);
485+
.map(Material::matchMaterial)
486+
.filter(Objects::nonNull)
487+
.forEach(restrictedInteractBlocks::add); // Utilisation de forEach ici
488488
}
489489

490490
/**
@@ -493,50 +493,50 @@ public void setRestrictedContainers(List<String> mat) {
493493
* @param mat The list of entity type names to restrict.
494494
*/
495495
public void setRestrictedEntityType(List<String> mat) {
496-
restrictedEntityType.clear();
496+
restrictedEntityType.clear();
497497
mat.stream()
498498
.map(EntityType::fromName)
499499
.filter(Objects::nonNull)
500-
.peek(restrictedEntityType::add);
500+
.forEach(restrictedEntityType::add); // Utilisation de forEach ici
501501
}
502-
502+
503503
/**
504504
* Sets the special blocks.
505505
*
506506
* @param mat The list of material names to restrict.
507507
*/
508508
public void setSpecialBlocks(List<String> mat) {
509-
specialBlocks.clear();
509+
specialBlocks.clear();
510510
mat.stream()
511511
.map(Material::matchMaterial)
512512
.filter(Objects::nonNull)
513-
.peek(specialBlocks::add);
513+
.forEach(specialBlocks::add); // Utilisation de forEach ici
514514
}
515-
515+
516516
/**
517517
* Sets the ignored break blocks.
518518
*
519519
* @param mat The list of ignored break blocks.
520520
*/
521521
public void setBreakBlocksIgnore(List<String> mat) {
522-
BreakBlocksIgnore.clear();
522+
BreakBlocksIgnore.clear();
523523
mat.stream()
524524
.map(Material::matchMaterial)
525525
.filter(Objects::nonNull)
526-
.peek(BreakBlocksIgnore::add);
526+
.forEach(BreakBlocksIgnore::add); // Utilisation de forEach ici
527527
}
528-
528+
529529
/**
530530
* Sets the ignored place blocks.
531531
*
532532
* @param mat The list of ignored place blocks.
533533
*/
534534
public void setPlaceBlocksIgnore(List<String> mat) {
535-
PlaceBlocksIgnore.clear();
535+
PlaceBlocksIgnore.clear();
536536
mat.stream()
537537
.map(Material::matchMaterial)
538538
.filter(Objects::nonNull)
539-
.peek(PlaceBlocksIgnore::add);
539+
.forEach(PlaceBlocksIgnore::add); // Utilisation de forEach ici
540540
}
541541

542542
/**

src/main/java/fr/xyness/SCS/Listeners/ClaimEvents.java

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.bukkit.Chunk;
99
import org.bukkit.Location;
1010
import org.bukkit.Material;
11+
import org.bukkit.World;
1112
import org.bukkit.block.Block;
1213
import org.bukkit.block.BlockFace;
1314
import org.bukkit.block.data.Directional;
@@ -18,6 +19,7 @@
1819
import org.bukkit.entity.EnderPearl;
1920
import org.bukkit.entity.Entity;
2021
import org.bukkit.entity.EntityType;
22+
import org.bukkit.entity.Firework;
2123
import org.bukkit.entity.GlowItemFrame;
2224
import org.bukkit.entity.ItemFrame;
2325
import org.bukkit.entity.Monster;
@@ -45,9 +47,11 @@
4547
import org.bukkit.event.entity.EntityDamageEvent;
4648
import org.bukkit.event.entity.EntityExplodeEvent;
4749
import org.bukkit.event.entity.EntityPlaceEvent;
50+
import org.bukkit.event.entity.EntityShootBowEvent;
4851
import org.bukkit.event.entity.EntityToggleGlideEvent;
4952
import org.bukkit.event.entity.PotionSplashEvent;
5053
import org.bukkit.event.entity.ProjectileHitEvent;
54+
import org.bukkit.event.entity.ProjectileLaunchEvent;
5155
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
5256
import org.bukkit.event.hanging.HangingBreakEvent;
5357
import org.bukkit.event.hanging.HangingPlaceEvent;
@@ -145,6 +149,8 @@ public void onCommandPreprocess(PlayerCommandPreprocessEvent event) {
145149
event.setMessage(newCommand);
146150
}
147151
}
152+
153+
148154

149155
/**
150156
* Handles player glide event for Elytra.
@@ -163,12 +169,41 @@ public void onPlayerToggleGlide(EntityToggleGlideEvent event) {
163169
if (!claim.getPermissionForPlayer("Elytra", player)) {
164170
instance.getMain().sendMessage(player, instance.getLanguage().getMessage("elytra"), instance.getSettings().getSetting("protection-message"));
165171
event.setCancelled(true);
166-
instance.getMain().teleportToGround(player);
172+
instance.getMain().teleportPlayer(player, player.getLocation());
173+
}
174+
} else if (mode == WorldMode.SURVIVAL_REQUIRING_CLAIMS && !instance.getSettings().getSettingSRC("Elytra")) {
175+
instance.getMain().sendMessage(player, instance.getLanguage().getMessage("elytra-mode"), instance.getSettings().getSetting("protection-message"));
176+
event.setCancelled(true);
177+
instance.getMain().teleportPlayer(player, player.getLocation());
178+
}
179+
}
180+
}
181+
}
182+
183+
/**
184+
* Handles the projectile launch event.
185+
*
186+
* @param event The ProjectileLaunchEvent event.
187+
*/
188+
@EventHandler
189+
public void onFireworkLaunch(ProjectileLaunchEvent event) {
190+
WorldMode mode = instance.getSettings().getWorldMode(event.getEntity().getWorld().getName());
191+
if (event.getEntity() instanceof Firework) {
192+
Firework firework = (Firework) event.getEntity();
193+
Player player = (Player) firework.getShooter();
194+
if (player == null) return;
195+
if (player.hasPermission("scs.bypass")) return;
196+
if (player.isGliding() || player.getTargetBlockExact(5) == null) {
197+
Chunk chunk = player.getLocation().getChunk();
198+
Claim claim = instance.getMain().getClaim(chunk);
199+
if (claim != null) {
200+
if (!claim.getPermissionForPlayer("Elytra", player)) {
201+
instance.getMain().sendMessage(player, instance.getLanguage().getMessage("elytra"), instance.getSettings().getSetting("protection-message"));
202+
event.setCancelled(true);
167203
}
168204
} else if (mode == WorldMode.SURVIVAL_REQUIRING_CLAIMS && !instance.getSettings().getSettingSRC("Elytra")) {
169205
instance.getMain().sendMessage(player, instance.getLanguage().getMessage("elytra-mode"), instance.getSettings().getSetting("protection-message"));
170206
event.setCancelled(true);
171-
instance.getMain().teleportToGround(player);
172207
}
173208
}
174209
}

src/main/java/fr/xyness/SCS/Listeners/ClaimEventsEnterLeave.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ public void onPlayerJoin(PlayerJoinEvent event) {
7373
instance.getPlayerMain().addPlayerPermSetting(player);
7474
instance.getPlayerMain().checkPlayer(player);
7575
if (player.hasPermission("scs.admin")) {
76-
if (instance.isUpdateAvailable()) {
77-
player.sendMessage(instance.getUpdateMessage());
78-
}
76+
instance.checkForUpdatesAsync().thenAccept(update -> {
77+
if(instance.isUpdateAvailable()) {
78+
instance.executeEntitySync(player, () -> player.sendMessage(instance.getUpdateMessage()));
79+
}
80+
});
7981
}
8082
Chunk chunk = player.getLocation().getChunk();
8183
handleWeatherSettings(player, chunk, chunk);

src/main/java/fr/xyness/SCS/SimpleClaimSystem.java

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public class SimpleClaimSystem extends JavaPlugin {
115115
private SimpleClaimSystem instance;
116116

117117
/** The version of the plugin */
118-
private String Version = "1.12.0.5";
118+
private String Version = "1.12.0.6";
119119

120120
/** Data source for database connections */
121121
private HikariDataSource dataSource;
@@ -1855,10 +1855,9 @@ private boolean checkKey(String key) {
18551855
}
18561856

18571857
/**
1858-
* Checks for updates for the
1858+
* Checks for updates for the plugin.
18591859
*
1860-
* @param plugin The plugin instance
1861-
* @return True if an update is available, false otherwise
1860+
* @return The update message.
18621861
*/
18631862
public String checkForUpdates() {
18641863
try {
@@ -1883,6 +1882,38 @@ public String checkForUpdates() {
18831882
}
18841883
}
18851884

1885+
/**
1886+
* Checks for updates for the plugin, asynchronously.
1887+
*
1888+
* @return The update message.
1889+
*/
1890+
public CompletableFuture<String> checkForUpdatesAsync() {
1891+
return CompletableFuture.supplyAsync(() -> {
1892+
try {
1893+
URI uri = URI.create("https://raw.githubusercontent.com/Xyness/SimpleClaimSystem/main/version.yml");
1894+
URL url = uri.toURL();
1895+
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
1896+
connection.setRequestMethod("GET");
1897+
connection.setConnectTimeout(5000); // Timeout de 5s
1898+
connection.setReadTimeout(5000);
1899+
1900+
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
1901+
String response = reader.readLine();
1902+
if (!Version.equalsIgnoreCase(response)) {
1903+
updateMessage = "§4[SCS] §cUpdate available : §l" + response + " §7(You have "+Version+")";
1904+
isUpdateAvailable = true;
1905+
return "§cUpdate available : §4" + response;
1906+
} else {
1907+
isUpdateAvailable = false;
1908+
return "You are using the latest version";
1909+
}
1910+
}
1911+
} catch (Exception e) {
1912+
return "Error when checking new update";
1913+
}
1914+
});
1915+
}
1916+
18861917
/**
18871918
* Checks and saves a resource file if it does not exist.
18881919
*

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: SimpleClaimSystem
2-
version: 1.12.0.5
2+
version: 1.12.0.6
33
main: fr.xyness.SCS.SimpleClaimSystem
44
authors: [Xyness]
55
softdepend: [PlaceholderAPI, WorldGuard, Vault, dynmap, BlueMap, pl3xmap, GriefPrevention]

version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.12.0.5
1+
1.12.0.6

0 commit comments

Comments
 (0)