From f3e1c149fb45220cc6c86704ac87daf1c7538746 Mon Sep 17 00:00:00 2001 From: OpexHunter Date: Sat, 8 Feb 2025 12:22:57 +0300 Subject: [PATCH] init --- .../punkcraft/oneworld/OneWorldSponge.class | Bin 6322 -> 489 bytes .../punkcraft/oneworld/OneWorldSponge.java | 99 ------------------ .../org/punkcraft/oneworld/TestMessage.java | 31 ------ .../org/punkcraft/oneworld/WSListener.java | 44 -------- .../java/org/punkcraft/oneworld/Zone.java | 27 ----- 5 files changed, 201 deletions(-) delete mode 100644 lib/src/main/java/org/punkcraft/oneworld/TestMessage.java delete mode 100644 lib/src/main/java/org/punkcraft/oneworld/WSListener.java delete mode 100644 lib/src/main/java/org/punkcraft/oneworld/Zone.java diff --git a/lib/bin/main/org/punkcraft/oneworld/OneWorldSponge.class b/lib/bin/main/org/punkcraft/oneworld/OneWorldSponge.class index b9c7727ada91607b56fd2a1776afaba990914e90..5a192de075a39efc170d7fb6aa83dfdf99a6f347 100644 GIT binary patch delta 175 zcmdmF_>!6H)W2Q(7#J9A86+oixlCTqD9*;o!@$bGHu(!<)Z}JC<%!ucjH;6j*~KUC z6I5ei$xF8WA2h3&#(!5}KJ}}A8AONJLfO3KiEDS=$48jZ|#SEehV#N&N3=%*V05rN6J^%m! literal 6322 zcmb_h31Ae}8U9{2$!s>0gFrL^l;t!DkOj1;Sq>qBE+zp9f{8~NHj~Z3W+t881)|ow zt!>q|_SDwWgO+M9uoALT(6;unwcXhJzHF^M?0wtP@4eZC-H=UD3ncUApZEUv{rCSK zPyFYR;{aBQ1saM3<~wdIG?21)MO~ve8FFlMkK@LBLK|&!n;diwICjj`P%Kcr)7Wi< z;)WdyZQQZbj3xz2<4!DQx&k$Al20Pud*04ao1%pU>NltCq}6Y3wG!5jxVgr*ourYp z96KQ}y)EkWhhmNsi<=?Kmh3_i_29y?sAKn9v5PHop4O(ewJj&qYjN%-BiY9(4c>+d z-GH;lbj_ZSF<^zfm7&&A2Amp5^cnoT*>RFSN)7=n+Gp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mKxVZRQci2IW-&rFwjl$mDbQf`-pC-Q<1H@kKnrQnK5Kr(^`x<*jUW;&Db7 zot6x~jIU^TlEF zRn---ldYw zPjvhgKl9i`Y;MRp8u8=joG`f5k7xM2j?ZW1f@OaETGILat)#P||DC{$0=<@O>;iZW ze~>l%kDNC_Hjb!2vIY7x{;J_GG~-Fd%BDug-|%;WGJ5F2c}I)UMy6XT^Pf8YC0#@7 zGZG!tn;-ucXzXyjk{0ZBQg%kuvoAhiUfsm_r1L8TYVw!(166kbNZq$^Ohov~bHE)(+SwRbc8HlH1 zmL1xp9^9?SqB~X6LDj8ILY+oQ$mdCS;t4&$z^4N)ZC=8IOplp}x|Zq+*sMl)8RDuF zkIWicwgPD)$Ro=OQ3^eK!W$Az%;i-};WT;re0-E9bl3jS9Z<(5fc!Qia4CHJ+*#^E!r`)vNMQ~>G-VGjA#VHRn+w+2B1ly_8fFqiv{LYqgL(gr&NR0A zSg57Y64e|f>;j70Kva#GiA5ZR_;Mh`5S33)kZ1(aQBUl;n0;htf< zfy*f6A9O6p6}_?EyBzT2YJmt;Bp(BqWGkJ-NZ z$H-6TlFP=(zsMyA#>l_SC6|wpf0awt$H>3QC09sqI*RAI>a|*bZCP!gw!BuatvG_; zr}3vEY?A`~g94to-~eWE?);kP)A&yjJLV~E@^z{Z3)8|UJyB4>5z#hgT6Y7zv7NT=pnW&-@8!Hd*o+&{i94_b`)~!7vlUPBBI0RW$x_-SYIwh}lvgQX zTq9QDS`oo^(as}!H=@cj?)J=@^$cCCq-V$k&?2gYCj4}Q)gmCugzQT;QIK+uin-%q zp>tHieIF1NqLOjB5BIPisbUlj;d(Y6RZJyMqKB zones = new ArrayList<>(); - - @Listener - public void onServerStart(GameStartedServerEvent event) { - logger.info("Successfully running OneWorldSponge!!!"); - - ChannelRegistrar channelRegistrar = Sponge.getChannelRegistrar(); - this.channel = channelRegistrar.createChannel(this, "custom:main"); - - // Регистрация сообщения - this.channel.registerMessage(TestMessage.class, 0); - - // Загрузка конфигурации зон - createZones(); - loadZones(); - - Sponge.getEventManager().registerListeners(this, new WSListener(this, this.channel, zones)); - } - - private void createZones() { - File configFile = new File("zones.cfg"); - if (!configFile.exists()) { - try { - if (configFile.createNewFile()) { - System.out.println("Файл zones.cfg успешно создан."); - } else { - System.out.println("Не удалось создать файл zones.cfg."); - } - } catch (IOException e) { - System.out.println("Произошла ошибка при создании файла zones.cfg."); - e.printStackTrace(); - } - } - } - - private void loadZones() { - try { - Path configFile = configDir.resolve("zones.yml"); - if (Files.notExists(configFile)) { - Files.createDirectories(configDir); // на случай если каталог не существует - Files.createFile(configFile); - } - - YAMLConfigurationLoader loader = YAMLConfigurationLoader.builder().setPath(configFile).build(); - ConfigurationNode rootNode = loader.load(); - - ConfigurationNode zonesNode = rootNode.getNode("zones"); - if (!zonesNode.isVirtual()) { - for (ConfigurationNode node : zonesNode.getChildrenMap().values()) { - String name = node.getKey().toString(); - int x1 = node.getNode("x1").getInt(); - int y1 = node.getNode("y1").getInt(); - int z1 = node.getNode("z1").getInt(); - int x2 = node.getNode("x2").getInt(); - int y2 = node.getNode("y2").getInt(); - int z2 = node.getNode("z2").getInt(); - - zones.add(new Zone(name, x1, y1, z1, x2, y2, z2)); - } - } else { - logger.warn("No zones found in the configuration file."); - } - } catch (IOException e) { - logger.error("Failed to load zones from zones.yml", e); - } - } - - public ChannelBinding.IndexedMessageChannel getChannel() { - return channel; - } - - public Logger getLogger() { - return logger; - } } diff --git a/lib/src/main/java/org/punkcraft/oneworld/TestMessage.java b/lib/src/main/java/org/punkcraft/oneworld/TestMessage.java deleted file mode 100644 index 5291a71..0000000 --- a/lib/src/main/java/org/punkcraft/oneworld/TestMessage.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.punkcraft.oneworld; - -import org.spongepowered.api.network.ChannelBuf; -import org.spongepowered.api.network.Message; - -public class TestMessage implements Message { - private String string; - - public TestMessage(String string) { - this.string = string; - } - - @Override - public void readFrom(ChannelBuf buf) { - this.string = buf.readString(); - } - - @Override - public void writeTo(ChannelBuf buf) { - buf.writeString(this.string); - } - - public String getContent() { - return string; - } - - public void setContent(String content) { - this.string = content; - } -} - diff --git a/lib/src/main/java/org/punkcraft/oneworld/WSListener.java b/lib/src/main/java/org/punkcraft/oneworld/WSListener.java deleted file mode 100644 index aeb717f..0000000 --- a/lib/src/main/java/org/punkcraft/oneworld/WSListener.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.punkcraft.oneworld; - -import org.spongepowered.api.entity.Entity; -import org.spongepowered.api.entity.living.player.Player; -import org.spongepowered.api.event.Listener; -import org.spongepowered.api.event.entity.MoveEntityEvent; -import org.spongepowered.api.network.ChannelBinding; - -import java.util.List; - -public class WSListener { - private final ChannelBinding.IndexedMessageChannel channel; - private final List zones; - - public WSListener(OneWorldSponge plugin, ChannelBinding.IndexedMessageChannel channel, List zones) { - this.channel = channel; - this.zones = zones; - } - - @Listener - public void onEntityMove(MoveEntityEvent event) { - Entity entity = event.getTargetEntity(); - if (entity instanceof Player) { - Player player = (Player) entity; - int x = player.getLocation().getBlockX(); - int y = player.getLocation().getBlockY(); - int z = player.getLocation().getBlockZ(); - - for (Zone zone : zones) { - // player.sendMessage(Text.of("Перебор зоны" + zone.getName())); - if (zone.isWithinZone(x, y, z)) { - // player.sendMessage(Text.of("Вы находитесь в зоне: " + zone.getName())); - - // Создаем и отправляем сообщение - TestMessage testMessage = new TestMessage(player.getName() + " " + zone.getName()); - channel.sendTo(player, testMessage); - - // Выход из цикла после нахождения первой зоны - break; - } - } - } - } -} diff --git a/lib/src/main/java/org/punkcraft/oneworld/Zone.java b/lib/src/main/java/org/punkcraft/oneworld/Zone.java deleted file mode 100644 index 79e3124..0000000 --- a/lib/src/main/java/org/punkcraft/oneworld/Zone.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.punkcraft.oneworld; - -public class Zone { - private String name; - private int x1, y1, z1, x2, y2, z2; - - public Zone(String name, int x1, int y1, int z1, int x2, int y2, int z2) { - this.name = name; - this.x1 = x1; - this.y1 = y1; - this.z1 = z1; - this.x2 = x2; - this.y2 = y2; - this.z2 = z2; - } - - public String getName() { - return name; - } - - public boolean isWithinZone(int x, int y, int z) { - return (Math.min(x1, x2) <= x && x <= Math.max(x1, x2)) && - (Math.min(y1, y2) <= y && y <= Math.max(y1, y2)) && - (Math.min(z1, z2) <= z && z <= Math.max(z1, z2)); - } -} -