├── .gitignore ├── MuxSystem ├── base │ └── base.schematic └── event │ └── varo-portal.schematic ├── README.md ├── libs ├── Client-1.0.2-RELEASE.jar ├── GrimAPI-add576b.jar ├── NoteBlockAPI-1.4.4.jar ├── Server-1.0.2-RELEASE.jar ├── Shared-1.0.2-RELEASE.jar ├── SimpleNetty-All-1.0.2-RELEASE.jar ├── fawe-api-latest.jar ├── httpclient-4.5.13.jar ├── httpcore-4.4.15.jar ├── json-20210307.jar ├── mail-1.5.0-b01.jar ├── nocheatplus-3.17.1b154.jar ├── spigot-Paper1.8.8.jar ├── worldedit-6.1.3.jar └── worldguard-5.9.1.jar └── src └── main └── java ├── Bike.schem ├── chatfilters.yml ├── config.yml ├── email.html ├── email.txt ├── emailsupport.html ├── emailsupport.txt ├── lang_de.properties ├── lang_en.properties ├── me └── muxteam │ ├── base │ ├── MuxBase.java │ ├── MuxBaseBlockRegistry.java │ ├── MuxBaseHandler.java │ ├── MuxGriefing.java │ ├── PlayerBase.java │ └── PlayerBaseBlock.java │ ├── basic │ ├── ConfirmInventory.java │ ├── MuxActions.java │ ├── MuxAntiBot.java │ ├── MuxAntiBugs.java │ ├── MuxAntiLags.java │ ├── MuxAnvil.java │ ├── MuxBossBar.java │ ├── MuxChairs.java │ ├── MuxChatInput.java │ ├── MuxChunkSpawner.java │ ├── MuxCraft18.java │ ├── MuxFirework.java │ ├── MuxFonts.java │ ├── MuxGiantItems.java │ ├── MuxHolograms.java │ ├── MuxLanguage.java │ ├── MuxLocation.java │ ├── MuxMusic.java │ ├── MuxNPCs.java │ ├── MuxOfflinePlayer.java │ ├── MuxPackets.java │ ├── MuxPlayerNPC.java │ ├── MuxScoreboard.java │ ├── MuxSnow.java │ ├── MuxTimings.java │ ├── NMSReflection.java │ ├── Pageifier.java │ ├── PathfinderGoalEntityDirection.java │ ├── PathfinderGoalPlayerFollow.java │ └── Stacktrace.java │ ├── casino │ ├── BlackJack.java │ ├── BlackJackGame.java │ ├── CasinoStats.java │ ├── CoinFlip.java │ ├── CoinFlipGame.java │ ├── CoinPusher.java │ ├── CoinPusherGame.java │ ├── Crash.java │ ├── GuessTheNumber.java │ ├── GuessTheNumberGame.java │ ├── ItemFlip.java │ ├── ItemFlipGame.java │ ├── MuxCasino.java │ ├── MuxCasinoUser.java │ ├── RockPaperScissors.java │ ├── RockPaperScissorsGame.java │ ├── Roulette.java │ ├── RouletteGame.java │ ├── ScratchCards.java │ ├── SixFields.java │ ├── SixFieldsGame.java │ ├── SlotMachine.java │ ├── TexasHoldem.java │ ├── TexasHoldemGame.java │ └── WheelOfFortune.java │ ├── events │ ├── Event.java │ ├── MuxAnvilDrop.java │ ├── MuxArena.java │ ├── MuxBlockParty.java │ ├── MuxBoss.java │ ├── MuxButton.java │ ├── MuxChamber.java │ ├── MuxCustom.java │ ├── MuxDropSearch.java │ ├── MuxDropper.java │ ├── MuxEXP.java │ ├── MuxEvents.java │ ├── MuxExit.java │ ├── MuxFastChat.java │ ├── MuxGetDown.java │ ├── MuxGiveAll.java │ ├── MuxGuess.java │ ├── MuxGunWar.java │ ├── MuxGuns.java │ ├── MuxJump.java │ ├── MuxLastChat.java │ ├── MuxLotto.java │ ├── MuxMine.java │ ├── MuxQuiz.java │ ├── MuxRandom.java │ ├── MuxSplegg.java │ ├── MuxSurvivalGames.java │ ├── MuxTNT.java │ ├── MuxTNTRun.java │ ├── MuxTempleRun.java │ ├── MuxTopArena.java │ ├── MuxTournament.java │ ├── MuxVaro.java │ ├── MuxWar.java │ ├── NonJoinableEvent.java │ └── SearchEventUser.java │ ├── extras │ ├── MuxBigEnderChest.java │ ├── MuxBoosters.java │ ├── MuxCars.java │ ├── MuxChestUser.java │ ├── MuxChests.java │ ├── MuxEmojis.java │ ├── MuxExtraCommands.java │ ├── MuxExtraUser.java │ ├── MuxExtras.java │ ├── MuxMounts.java │ ├── MuxPerks.java │ └── MuxPets.java │ ├── holidays │ ├── MuxAdvent.java │ ├── MuxBirthday.java │ ├── MuxChristmas.java │ ├── MuxEaster.java │ ├── MuxHalloween.java │ ├── MuxHoliday.java │ └── MuxSummer.java │ ├── marketing │ ├── MuxAffiliate.java │ ├── MuxEmails.java │ ├── MuxGiftCodes.java │ ├── MuxNewbies.java │ ├── MuxTips.java │ └── MuxVotes.java │ ├── muxsystem │ ├── MuxHistory.java │ ├── MuxHomes.java │ ├── MuxInventory.java │ ├── MuxMenu.java │ ├── MuxPayments.java │ ├── MuxProfiles.java │ ├── MuxSystem.java │ ├── MuxUser.java │ ├── MuxWarps.java │ ├── MySQL.java │ └── Settings.java │ ├── muxteam │ ├── Analytics.java │ ├── BanEntry.java │ ├── MuxAdmin.java │ ├── MuxAnalytics.java │ ├── MuxAntiCheat.java │ ├── MuxBans.java │ ├── MuxChatFilter.java │ ├── MuxDeveloper.java │ ├── MuxFeedback.java │ ├── MuxOverview.java │ ├── MuxPolls.java │ ├── MuxReports.java │ ├── MuxSupport.java │ ├── MuxTeam.java │ ├── MuxUserTransfer.java │ └── MuxVanish.java │ ├── pvp │ ├── MuxClanWar.java │ ├── MuxGames.java │ ├── MuxPvP.java │ ├── MuxPvPBots.java │ ├── MuxPvPStats.java │ └── MuxSeason.java │ ├── ranks │ ├── MuxBenefits.java │ ├── MuxCreators.java │ ├── MuxCustomRank.java │ ├── MuxGold.java │ ├── MuxKits.java │ ├── MuxRanks.java │ └── MuxUltra.java │ ├── shared │ ├── MuxNetty.java │ ├── MuxShared.java │ ├── MuxSharedPackets.java │ ├── TestNettyClient.java │ └── TestNettyListener.java │ ├── shop │ ├── MuxGemShop.java │ ├── MuxMarket.java │ ├── MuxMining.java │ ├── MuxShop.java │ ├── MuxTrade.java │ ├── PremiumItem.java │ └── ShopItem.java │ └── social │ ├── MuxChat.java │ ├── MuxClans.java │ └── MuxFriends.java └── plugin.yml /.gitignore: -------------------------------------------------------------------------------- 1 | ### JetBrains template 2 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 3 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 4 | 5 | # User-specific stuff 6 | .idea/**/workspace.xml 7 | .idea/**/tasks.xml 8 | .idea/**/usage.statistics.xml 9 | .idea/**/dictionaries 10 | .idea/**/shelf 11 | .idea 12 | *.iml 13 | 14 | # AWS User-specific 15 | .idea/**/aws.xml 16 | 17 | # Generated files 18 | .idea/**/contentModel.xml 19 | 20 | # Sensitive or high-churn files 21 | .idea/**/dataSources/ 22 | .idea/**/dataSources.ids 23 | .idea/**/dataSources.local.xml 24 | .idea/**/sqlDataSources.xml 25 | .idea/**/dynamic.xml 26 | .idea/**/uiDesigner.xml 27 | .idea/**/dbnavigator.xml 28 | 29 | # Gradle 30 | .idea/**/gradle.xml 31 | .idea/**/libraries 32 | 33 | # Gradle and Maven with auto-import 34 | # When using Gradle or Maven with auto-import, you should exclude module files, 35 | # since they will be recreated, and may cause churn. Uncomment if using 36 | # auto-import. 37 | # .idea/artifacts 38 | # .idea/compiler.xml 39 | # .idea/jarRepositories.xml 40 | # .idea/modules.xml 41 | # .idea/*.iml 42 | # .idea/modules 43 | # *.iml 44 | # *.ipr 45 | 46 | # CMake 47 | cmake-build-*/ 48 | 49 | # Mongo Explorer plugin 50 | .idea/**/mongoSettings.xml 51 | 52 | # File-based project format 53 | *.iws 54 | 55 | # IntelliJ 56 | out/ 57 | 58 | # mpeltonen/sbt-idea plugin 59 | .idea_modules/ 60 | 61 | # JIRA plugin 62 | atlassian-ide-plugin.xml 63 | 64 | # Cursive Clojure plugin 65 | .idea/replstate.xml 66 | 67 | # SonarLint plugin 68 | .idea/sonarlint/ 69 | 70 | # Crashlytics plugin (for Android Studio and IntelliJ) 71 | com_crashlytics_export_strings.xml 72 | crashlytics.properties 73 | crashlytics-build.properties 74 | fabric.properties 75 | 76 | # Editor-based Rest Client 77 | .idea/httpRequests 78 | 79 | # Android studio 3.1+ serialized cache file 80 | .idea/caches/build_file_checksums.ser 81 | 82 | -------------------------------------------------------------------------------- /MuxSystem/base/base.schematic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/MuxSystem/base/base.schematic -------------------------------------------------------------------------------- /MuxSystem/event/varo-portal.schematic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/MuxSystem/event/varo-portal.schematic -------------------------------------------------------------------------------- /libs/Client-1.0.2-RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/Client-1.0.2-RELEASE.jar -------------------------------------------------------------------------------- /libs/GrimAPI-add576b.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/GrimAPI-add576b.jar -------------------------------------------------------------------------------- /libs/NoteBlockAPI-1.4.4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/NoteBlockAPI-1.4.4.jar -------------------------------------------------------------------------------- /libs/Server-1.0.2-RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/Server-1.0.2-RELEASE.jar -------------------------------------------------------------------------------- /libs/Shared-1.0.2-RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/Shared-1.0.2-RELEASE.jar -------------------------------------------------------------------------------- /libs/SimpleNetty-All-1.0.2-RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/SimpleNetty-All-1.0.2-RELEASE.jar -------------------------------------------------------------------------------- /libs/fawe-api-latest.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/fawe-api-latest.jar -------------------------------------------------------------------------------- /libs/httpclient-4.5.13.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/httpclient-4.5.13.jar -------------------------------------------------------------------------------- /libs/httpcore-4.4.15.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/httpcore-4.4.15.jar -------------------------------------------------------------------------------- /libs/json-20210307.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/json-20210307.jar -------------------------------------------------------------------------------- /libs/mail-1.5.0-b01.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/mail-1.5.0-b01.jar -------------------------------------------------------------------------------- /libs/nocheatplus-3.17.1b154.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/nocheatplus-3.17.1b154.jar -------------------------------------------------------------------------------- /libs/spigot-Paper1.8.8.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/spigot-Paper1.8.8.jar -------------------------------------------------------------------------------- /libs/worldedit-6.1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/worldedit-6.1.3.jar -------------------------------------------------------------------------------- /libs/worldguard-5.9.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/muxcraftserver/MuxSystem/6efca3546b868a650401de5ce382aa3a5925b479/libs/worldguard-5.9.1.jar -------------------------------------------------------------------------------- /src/main/java/config.yml: -------------------------------------------------------------------------------- 1 | #############>>MYSQL<<############# 2 | database: 3 | username: root 4 | password: test 5 | url: jdbc:mysql://localhost:3306/dbname?autoReconnect=true&maxReconnects=3 6 | shared: 7 | username: root 8 | password: test 9 | url: jdbc:mysql://localhost:3306/dbname?autoReconnect=true&maxReconnects=3 10 | #################################### 11 | #############>>EMAIL<<############## 12 | email: 13 | auth_enabled: true 14 | info: 15 | username: "info@muxcraft.eu" 16 | password: "password" 17 | support: 18 | username: "support@muxcraft.eu" 19 | password: "password" 20 | starttls_enabled: true 21 | host: mail.muxcraft.eu 22 | port: 25 23 | ssl_trust: mail.muxcraft.eu 24 | #################################### 25 | ########>>SLOTS, MOTD, usw.<<####### 26 | servername: Server 27 | joinmsg: '§8§l>> §fChange this message in the §c§lAdmin Menu' 28 | bossbar: '§7§lMux§a§lCraft' 29 | slots: 400 30 | lang: 'de' 31 | worldlimit: 50000 32 | warpworldlimit: 600 33 | shutdown: false 34 | debug: false 35 | beta: false 36 | telegrambot: 'key' 37 | #################################### 38 | #############>>BOSSBAR<<############ 39 | ##########>>AUTOMESSAGES<<########## 40 | automessages: [] 41 | #################################### 42 | ##############>>VOTE<<############## 43 | vote: 44 | items: 45 | - 332 5 46 | - 264 10 47 | commands: 48 | - gems add [NAME] 10 49 | - coins add [NAME] 5000 50 | - crate add [NAME] RANDOM 51 | message: 52 | - '&5▛▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▜' 53 | - ' &7Du hast &63 Zufälige Kisten &7erhalten!' 54 | - ' &7Du hast §e5000 MuxCoins &7erhalten!' 55 | - ' &7Du hast &a10 Gems erhalten!' 56 | - ' &7Du hast &b10 Diamanten &7erhalten!' 57 | - ' &7Du hast &cZugriff auf das Menü&7!' 58 | - ' &7Du hast &d5 Schneebälle &7erhalten!' 59 | - ' &eDanke für das Voten!' 60 | - '&5▙▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▟' 61 | #################################### 62 | ##############>>NEWS<<############## 63 | news: 64 | title: 'News' 65 | text: 'Welcome to the server!' 66 | link: 'news' 67 | linktext: 'To the website' 68 | ##############>>MAPS<<############## 69 | rankedmaps: 70 | - Wüste 71 | - Dschungel 72 | - Fluss 73 | - Royale 74 | - Podzol 75 | duelmaps: 76 | - Burg 77 | - Sand 78 | #######>>SPECIALPERMISSIONS<<####### 79 | trusted: 80 | - marint94 81 | fulltrusted: 82 | - CONSOLE 83 | - marint94 84 | worldguard: 85 | - marint94 86 | worldedit: 87 | - marint94 88 | #################################### -------------------------------------------------------------------------------- /src/main/java/email.txt: -------------------------------------------------------------------------------- 1 | Hey $playername, hier ist dein Verifizierungscode, gib diesen im Minecraft Chat auf MuxCraft ein. $msg -------------------------------------------------------------------------------- /src/main/java/emailsupport.txt: -------------------------------------------------------------------------------- 1 | Hey $playername, du hast eine neue Antwort von MuxSupport. Antwort: $msg -------------------------------------------------------------------------------- /src/main/java/me/muxteam/base/PlayerBaseBlock.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.base; 2 | 3 | import java.util.List; 4 | 5 | public class PlayerBaseBlock { 6 | private final String id; 7 | private long amount; 8 | private final double pricePerBlock, priceForAmount; 9 | 10 | public PlayerBaseBlock(final String id, final long amount, final double pricePerBlock, final List halfBlocks) { 11 | this.id = id; 12 | boolean b = false; 13 | if (amount >= 2) { 14 | for (final String hb : halfBlocks) { 15 | if (id.startsWith(hb)) { 16 | b = true; 17 | this.amount = amount / 2; 18 | break; 19 | } 20 | } 21 | } 22 | if (b == false) this.amount = amount; 23 | this.pricePerBlock = pricePerBlock; 24 | this.priceForAmount = pricePerBlock * this.amount; 25 | } 26 | 27 | public double getPricePerBlock() { 28 | return pricePerBlock; 29 | } 30 | 31 | public double getPriceForAmount() { 32 | return priceForAmount; 33 | } 34 | 35 | public long getAmount() { 36 | return amount; 37 | } 38 | 39 | public String getId() { 40 | return id; 41 | } 42 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/ConfirmInventory.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import me.muxteam.basic.MuxActions.PlayerAction; 4 | import me.muxteam.muxsystem.MuxInventory.InvType; 5 | import me.muxteam.muxsystem.MuxSystem; 6 | import org.bukkit.Material; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.inventory.Inventory; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | public final class ConfirmInventory { 12 | private MuxSystem ms; 13 | private ConfirmActions actions; 14 | private byte abortcolor = (byte) 14; 15 | 16 | public ConfirmInventory(final MuxSystem ms, final PlayerAction confirm, final PlayerAction cancel) { 17 | this.ms = ms; 18 | this.actions = new ConfirmActions(confirm, cancel); 19 | } 20 | 21 | public Inventory show(final Player p, final String name, final String confirmlabel, final String abortlabel) { 22 | final Inventory i = ms.getServer().createInventory(null, 45, name); 23 | final ItemStack ok = ms.renameItemStack(new ItemStack(new ItemStack(Material.STAINED_CLAY, 1, (byte) 5)), confirmlabel), 24 | abort = ms.renameItemStack(new ItemStack(new ItemStack(Material.STAINED_CLAY, 1, abortcolor)), abortlabel); 25 | createButton(i, 10, ok); 26 | createButton(i, 14, abort); 27 | p.openInventory(i); 28 | ms.getInv().setConfirm(p.getName(), actions); 29 | ms.setActiveInv(p.getName(), InvType.CONFIRM); 30 | this.ms = null; 31 | this.actions = null; 32 | return i; 33 | } 34 | public Inventory show(final Player p, final String name, final String confirmlabel, final String abortlabel, final ItemStack item, final String itemname, final String ... itemlore) { 35 | final Inventory inv = ms.getServer().createInventory(null, 54, name); 36 | final ItemStack ok = ms.renameItemStack(new ItemStack(new ItemStack(Material.STAINED_CLAY, 1, (byte) 5)), confirmlabel), 37 | abort = ms.renameItemStack(new ItemStack(new ItemStack(Material.STAINED_CLAY, 1, abortcolor)), abortlabel); 38 | inv.setItem(13, ms.renameItemStack(item, itemname, itemlore)); 39 | createButton(inv, 27, ok); 40 | createButton(inv, 33, abort); 41 | p.openInventory(inv); 42 | ms.getInv().setConfirm(p.getName(), actions); 43 | ms.setActiveInv(p.getName(), InvType.CONFIRM); 44 | this.ms = null; 45 | this.actions = null; 46 | return inv; 47 | } 48 | public ConfirmInventory setAbortColor(final byte color) { 49 | abortcolor = color; 50 | return this; 51 | } 52 | private void createButton(final Inventory i, int pos, final ItemStack item) { 53 | for (short n = 1; n <= 9; n++) { 54 | i.setItem(pos, item); 55 | if (n % 3 == 0) pos += 7; 56 | else pos++; 57 | } 58 | } 59 | public final class ConfirmActions { 60 | public final PlayerAction cancelaction, confirmaction; 61 | public ConfirmActions(final PlayerAction confirm, final PlayerAction cancel) { 62 | this.confirmaction = confirm; 63 | this.cancelaction = cancel; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/MuxActions.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import me.muxteam.basic.MuxHolograms.IndividualHologram; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.inventory.ItemStack; 6 | 7 | public final class MuxActions { 8 | 9 | public interface PlayerAction { 10 | 11 | void call(final Player p); 12 | 13 | } 14 | 15 | public interface AnvilAction { 16 | 17 | void call(final String input, final Player p); 18 | 19 | } 20 | 21 | public interface RouletteAction { 22 | 23 | void call(final ItemStack i); 24 | 25 | } 26 | 27 | public interface HologramAction { 28 | 29 | void call(final IndividualHologram holo, final Player p); 30 | } 31 | 32 | public interface Action { 33 | 34 | void call(); 35 | 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/MuxAnvil.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import me.muxteam.basic.MuxActions.AnvilAction; 4 | import me.muxteam.muxsystem.MuxInventory.InvType; 5 | import me.muxteam.muxsystem.MuxSystem; 6 | import net.minecraft.server.v1_8_R3.*; 7 | import org.bukkit.Material; 8 | import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | public final class MuxAnvil { 13 | private MuxSystem ms; 14 | private AnvilAction action; 15 | 16 | public MuxAnvil(final MuxSystem ms, final AnvilAction action) { 17 | this.ms = ms; 18 | this.action = action; 19 | } 20 | 21 | public void show(final Player p, final String text, final ItemStack item) { 22 | final EntityPlayer ep = ((CraftPlayer) p).getHandle(); 23 | final int c = ep.nextContainerCounter(); 24 | final ContainerAnvil container = new ContainerAnvil(ep.inventory, ep.world, new BlockPosition(0,0,0), ep); 25 | 26 | container.checkReachable = false; 27 | 28 | container.getBukkitView().getTopInventory().setItem(0, ms.renameItemStack(item, text)); 29 | 30 | ep.playerConnection.sendPacket(new PacketPlayOutOpenWindow(c, "minecraft:anvil", new ChatMessage("Repairing"), 0)); 31 | ep.activeContainer = container; 32 | ep.activeContainer.windowId = c; 33 | ep.activeContainer.addSlotListener(ep); 34 | 35 | ms.setActiveInv(p.getName(), InvType.MUXANVIL); 36 | ms.getInv().setAnvil(p.getName(), this.action); 37 | this.ms = null; 38 | this.action = null; 39 | } 40 | public void show(final Player p, final String text) { 41 | show(p, text, new ItemStack(Material.PAPER)); 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/MuxBossBar.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | import net.minecraft.server.v1_8_R3.*; 5 | import org.bukkit.Location; 6 | import org.bukkit.configuration.file.FileConfiguration; 7 | import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; 8 | import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; 9 | import org.bukkit.entity.Player; 10 | 11 | import java.util.Map.Entry; 12 | import java.util.concurrent.ConcurrentHashMap; 13 | 14 | public final class MuxBossBar { 15 | private MuxSystem ms; 16 | private String bosstitle; 17 | private final ConcurrentHashMap withers = new ConcurrentHashMap<>(); 18 | private final ConcurrentHashMap titles = new ConcurrentHashMap<>(); 19 | 20 | public MuxBossBar(final MuxSystem ms) { 21 | this.ms = ms; 22 | } 23 | public void close() { 24 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 25 | removePlayer(pl); 26 | } 27 | this.ms = null; 28 | } 29 | public void loadConfig(final FileConfiguration config) { 30 | this.bosstitle = config.getString("bossbar") + (ms.isBeta() ? " §3§lbeta" : ""); 31 | } 32 | public void sendBossBar() { 33 | for (final Entry entry : withers.entrySet()) { 34 | final EntityWither wither = entry.getValue(); 35 | final Player p = ms.getServer().getPlayer(entry.getKey()); 36 | if (p == null) { 37 | withers.remove(entry.getKey()); 38 | titles.remove(entry.getKey()); 39 | continue; 40 | } 41 | final Location l = getWitherLocation(p.getLocation()); 42 | wither.setLocation(l.getX(), l.getY(), l.getZ(), 0, 0); 43 | final PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(wither); 44 | ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); 45 | } 46 | } 47 | public void addPlayer(final Player p) { 48 | if (withers.containsKey(p.getName())) return; 49 | final EntityWither wither = new EntityWither(((CraftWorld) p.getWorld()).getHandle()); 50 | final Location l = getWitherLocation(p.getLocation()); 51 | final String t = titles.get(p.getName()); 52 | wither.setCustomName(t == null ? bosstitle : t); 53 | wither.setInvisible(true); 54 | wither.setLocation(l.getX(), l.getY(), l.getZ(), 0, 0); 55 | final PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(wither); 56 | ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); 57 | withers.put(p.getName(), wither); 58 | } 59 | public void removePlayer(final Player p) { 60 | final EntityWither wither = withers.remove(p.getName()); 61 | if (wither == null) return; 62 | final PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(wither.getId()); 63 | ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); 64 | } 65 | public void setTitle(final Player p, final String title) { 66 | titles.put(p.getName(), title); 67 | final EntityWither wither = withers.get(p.getName()); 68 | if (wither == null) return; 69 | wither.setCustomName(title); 70 | wither.setHealth(wither.getMaxHealth()); 71 | final PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(wither.getId(), wither.getDataWatcher(), true); 72 | ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); 73 | } 74 | private Location getWitherLocation(final Location l) { 75 | return l.add(l.getDirection().multiply(23)); 76 | } 77 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/MuxChairs.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import com.sk89q.worldguard.bukkit.WGBukkit; 4 | import com.sk89q.worldguard.protection.ApplicableRegionSet; 5 | import com.sk89q.worldguard.protection.flags.DefaultFlag; 6 | import me.muxteam.muxsystem.MuxSystem; 7 | import org.bukkit.Location; 8 | import org.bukkit.Material; 9 | import org.bukkit.block.Block; 10 | import org.bukkit.entity.ArmorStand; 11 | import org.bukkit.entity.EntityType; 12 | import org.bukkit.entity.Player; 13 | import org.bukkit.event.EventHandler; 14 | import org.bukkit.event.Listener; 15 | import org.bukkit.event.block.Action; 16 | import org.bukkit.event.player.PlayerInteractEvent; 17 | 18 | import java.util.Map; 19 | import java.util.concurrent.ConcurrentHashMap; 20 | import java.util.concurrent.ConcurrentMap; 21 | 22 | public class MuxChairs implements Listener { 23 | private MuxSystem ms; 24 | private final ConcurrentHashMap chairs = new ConcurrentHashMap<>(); 25 | 26 | public MuxChairs(final MuxSystem ms) { 27 | this.ms = ms; 28 | ms.getServer().getPluginManager().registerEvents(this, ms); 29 | } 30 | public void close() { 31 | for (final ArmorStand chair : chairs.values()) { 32 | if (chair != null) { 33 | chair.remove(); 34 | } 35 | } 36 | this.ms = null; 37 | } 38 | public ConcurrentMap getChairs() { 39 | return chairs; 40 | } 41 | public void clearEmpty() { 42 | for (final Map.Entry entry : chairs.entrySet()) { 43 | final ArmorStand a = entry.getValue(); 44 | if (a == null || a.isDead() || a.getPassenger() == null) { 45 | if (a != null) a.remove(); 46 | chairs.remove(entry.getKey()); 47 | } 48 | } 49 | } 50 | @EventHandler 51 | public void onInteract(final PlayerInteractEvent e) { 52 | final Action a = e.getAction(); 53 | if (a == Action.RIGHT_CLICK_BLOCK) { 54 | final Block b = e.getClickedBlock(); 55 | final Material t = b.getType(); 56 | final Player p = e.getPlayer(); 57 | if ((t == Material.DARK_OAK_STAIRS || t == Material.SPRUCE_WOOD_STAIRS || t == Material.WOOD_STAIRS) && p.isInsideVehicle() == false && p.getItemInHand().getType() == Material.AIR) { 58 | if ((b.getData() < 4 || (b.getData() > 7 && b.getData() < 12)) == false) return; 59 | if (ms.checkGeneralCooldown(p.getName(), "STAIRS", 3000L, true)) return; 60 | final Location l = b.getLocation(); 61 | final ApplicableRegionSet rgs = WGBukkit.getRegionManager(l.getWorld()).getApplicableRegions(l); 62 | if (rgs.size() == 0 || rgs.allows(DefaultFlag.PVP)) return; 63 | float yaw = 0F; 64 | if (b.getData() == 1 || b.getData() == 9) { 65 | yaw = -90F; 66 | } else if (b.getData() == 3 || b.getData() == 11) { 67 | yaw = 0F; 68 | } else if (b.getData() == 0 || b.getData() == 8) { 69 | yaw = 90F; 70 | } else if (b.getData() == 2 || b.getData() == 10) { 71 | yaw = 180F; 72 | } 73 | l.setYaw(yaw); 74 | if (chairs.containsKey(l)) { 75 | ms.showItemBar(p, "§cDieser Stuhl ist besetzt."); 76 | return; 77 | } else if (p.isInsideVehicle()) { 78 | return; 79 | } 80 | final ArmorStand stand = (ArmorStand) p.getWorld().spawnEntity(l.clone().add(0.5D, -1.2D, 0.5D), EntityType.ARMOR_STAND); 81 | stand.setGravity(false); 82 | stand.setVisible(false); 83 | stand.setPassenger(p); 84 | e.setCancelled(true); 85 | chairs.put(l, stand); 86 | } 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/MuxChatInput.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import me.muxteam.basic.MuxActions.AnvilAction; 4 | import me.muxteam.muxsystem.MuxSystem; 5 | import org.bukkit.Sound; 6 | import org.bukkit.entity.Player; 7 | 8 | public final class MuxChatInput { 9 | private final MuxSystem ms; 10 | private final AnvilAction action; 11 | private long time; 12 | private String cancelreason; 13 | private int tries, currentTries; 14 | private boolean infinite, cancelled, handleCancelLocal; 15 | 16 | public MuxChatInput(final MuxSystem ms, final AnvilAction action) { 17 | this.ms = ms; 18 | this.action = action; 19 | } 20 | 21 | public void show(final Player p, final String text, final boolean infinite, final String cancelReason, final int tries, boolean handleCancelLocal) { 22 | this.handleCancelLocal = handleCancelLocal; 23 | this.show(p, text, infinite, cancelReason, tries); 24 | } 25 | 26 | public void show(final Player p, final String text, final boolean infinite, final String cancelReason, final int tries) { 27 | p.closeInventory(); 28 | ms.getChat().disableChat(p.getName()); 29 | p.playSound(p.getLocation(), Sound.NOTE_PLING, 1F, 1.6F); 30 | p.sendMessage(new String[]{"", "", text}); 31 | ms.getChat().setChatInput(p.getName(), this); 32 | this.infinite = infinite; 33 | this.time = System.currentTimeMillis(); 34 | this.tries = tries; 35 | this.cancelreason = cancelReason; 36 | } 37 | 38 | public void show(final Player p, final String text, final boolean infinite) { 39 | this.show(p, text, infinite, null, -1); 40 | } 41 | 42 | public void show(final Player p, final String text) { 43 | this.show(p, text, false); 44 | } 45 | 46 | public long getTime() { 47 | return time; 48 | } 49 | 50 | public boolean isInfinite() { 51 | return infinite; 52 | } 53 | 54 | public int getTries() { 55 | return tries; 56 | } 57 | 58 | public int getCurrentTries() { 59 | return currentTries; 60 | } 61 | 62 | public String getCancelReason() { 63 | return cancelreason; 64 | } 65 | 66 | public AnvilAction getAction() { 67 | return action; 68 | } 69 | 70 | public void tryInput() { 71 | currentTries++; 72 | } 73 | 74 | public boolean isCancelled() { 75 | return cancelled; 76 | } 77 | 78 | public void cancel() { 79 | this.cancelled = true; 80 | } 81 | 82 | public boolean isHandleCancelLocal() { 83 | return handleCancelLocal; 84 | } 85 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/MuxChunkSpawner.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | 4 | import me.muxteam.muxsystem.MuxSystem; 5 | import org.bukkit.Location; 6 | import org.bukkit.entity.Entity; 7 | import org.bukkit.entity.EntityType; 8 | 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | public class MuxChunkSpawner { 13 | 14 | private final Map pendingMobs = new HashMap<>(); 15 | 16 | private long lastSpawn; 17 | 18 | public MuxChunkSpawner() { 19 | this.lastSpawn = System.currentTimeMillis(); 20 | } 21 | 22 | public boolean canSpawn(EntityType type) { 23 | return this.lastSpawn + 30_000 < System.currentTimeMillis() && pendingMobs.get(type) > 10; 24 | } 25 | 26 | private void addMob(EntityType entityType, Location location) { 27 | pendingMobs.put(entityType, pendingMobs.getOrDefault(entityType, 0) + 1); 28 | } 29 | 30 | public void spawnMob(EntityType type, Location location) { 31 | this.addMob(type, location); 32 | if (!canSpawn(type)) 33 | return; 34 | this.lastSpawn = System.currentTimeMillis(); 35 | int amount = this.pendingMobs.get(type); 36 | Entity target = location.getWorld().spawnEntity(location, type); 37 | final String mobname = MuxChunkSpawner.getMobName(target.getType()); 38 | target.setCustomName("§a" + (amount) + "§a✕ §f" + mobname); 39 | target.setCustomNameVisible(true); 40 | pendingMobs.remove(type); 41 | } 42 | 43 | private static String getMobName(final EntityType type) { 44 | switch (type) { 45 | case PIG_ZOMBIE: 46 | return MuxSystem.getAPI().getLang("mob.zombiepigman"); 47 | case ZOMBIE: 48 | return MuxSystem.getAPI().getLang("mob.zombie"); 49 | case WITCH: 50 | return MuxSystem.getAPI().getLang("mob.witch"); 51 | case BLAZE: 52 | return MuxSystem.getAPI().getLang("mob.blaze"); 53 | case SKELETON: 54 | return MuxSystem.getAPI().getLang("mob.skeleton"); 55 | default: 56 | return ""; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/MuxFirework.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import net.minecraft.server.v1_8_R3.EntityFireworks; 4 | import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus; 5 | import org.bukkit.Color; 6 | import org.bukkit.FireworkEffect; 7 | import org.bukkit.FireworkEffect.Type; 8 | import org.bukkit.Location; 9 | import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; 10 | import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; 11 | import org.bukkit.entity.Firework; 12 | import org.bukkit.entity.Player; 13 | import org.bukkit.inventory.meta.FireworkMeta; 14 | 15 | import java.util.Random; 16 | 17 | public class MuxFirework extends EntityFireworks { 18 | final Player[] players; 19 | static final Random r = new Random(); 20 | 21 | public MuxFirework(final net.minecraft.server.v1_8_R3.World world, final Player... p) { 22 | super(world); 23 | this.players = p; 24 | this.a(0.25F, 0.25F); 25 | } 26 | 27 | boolean gone = false; 28 | 29 | @Override 30 | public void t_() { 31 | if (gone) { 32 | return; 33 | } 34 | if (this.world.isClientSide == false) { 35 | gone = true; 36 | if (players != null) { 37 | if (players.length > 0) { 38 | for (final Player player : players) { 39 | ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityStatus(this, (byte) 17)); 40 | } 41 | } else world.broadcastEntityEffect(this, (byte) 17); 42 | } 43 | this.die(); 44 | } 45 | } 46 | 47 | public static void spawnRandomBigBall(final Location loc) { 48 | final FireworkEffect.Builder builder = FireworkEffect.builder(); 49 | builder.with(Type.BALL_LARGE); 50 | FireworkEffect effect = null; 51 | final int zufall = r.nextInt(8); 52 | switch (zufall) { 53 | case 0: 54 | effect = builder.flicker(true).trail(true).withColor(Color.AQUA).build(); 55 | break; 56 | case 1: 57 | effect = builder.flicker(true).trail(true).withColor(Color.BLACK).build(); 58 | break; 59 | case 2: 60 | effect = builder.flicker(true).trail(true).withColor(Color.GREEN).build(); 61 | break; 62 | case 3: 63 | effect = builder.flicker(true).trail(true).withColor(Color.GRAY).build(); 64 | break; 65 | case 4: 66 | effect = builder.flicker(true).trail(true).withColor(Color.RED).build(); 67 | break; 68 | case 5: 69 | effect = builder.flicker(true).trail(true).withColor(Color.ORANGE).build(); 70 | break; 71 | case 6: 72 | effect = builder.flicker(true).trail(true).withColor(Color.BLUE).build(); 73 | break; 74 | case 7: 75 | effect = builder.flicker(true).trail(true).withColor(Color.YELLOW).build(); 76 | break; 77 | } 78 | MuxFirework.spawn(loc.add(0.5, 1, 0.5), effect); 79 | } 80 | public static void spawnCreeper(final Location loc) { 81 | final FireworkEffect.Builder builder = FireworkEffect.builder(); 82 | builder.with(Type.CREEPER); 83 | final FireworkEffect effect = builder.flicker(false).trail(true).withColor(Color.GREEN).withColor(Color.PURPLE).build(); 84 | MuxFirework.spawn(loc.add(0.5, 1, 0.5), effect); 85 | } 86 | public static void spawnColor(final Location loc, final Color c) { 87 | final FireworkEffect.Builder builder = FireworkEffect.builder(); 88 | builder.with(Type.BALL); 89 | final FireworkEffect effect = builder.flicker(false).trail(true).withColor(c).build(); 90 | MuxFirework.spawn(loc.add(0.5, 1, 0.5), effect); 91 | } 92 | public static void spawnBigGreen(final Location loc) { 93 | final FireworkEffect.Builder builder = FireworkEffect.builder(); 94 | builder.with(Type.BALL_LARGE); 95 | final FireworkEffect effect = builder.flicker(false).trail(true).withColor(Color.LIME).build(); 96 | MuxFirework.spawn(loc.clone().add(0.5, 1, 0.5), effect); 97 | } 98 | public static void spawnRandom(final Location loc) { 99 | final FireworkEffect.Builder builder = FireworkEffect.builder(); 100 | builder.with(Type.BALL); 101 | FireworkEffect effect = null; 102 | int zufall = r.nextInt(8); 103 | switch (zufall) { 104 | case 0: 105 | effect = builder.flicker(false).trail(true).withColor(Color.AQUA).build(); 106 | break; 107 | case 1: 108 | effect = builder.flicker(false).trail(true).withColor(Color.LIME).build(); 109 | break; 110 | case 2: 111 | effect = builder.flicker(false).trail(true).withColor(Color.GREEN).build(); 112 | break; 113 | case 3: 114 | effect = builder.flicker(false).trail(true).withColor(Color.FUCHSIA).build(); 115 | break; 116 | case 4: 117 | effect = builder.flicker(false).trail(true).withColor(Color.RED).build(); 118 | break; 119 | case 5: 120 | effect = builder.flicker(false).trail(true).withColor(Color.ORANGE).build(); 121 | break; 122 | case 6: 123 | effect = builder.flicker(false).trail(true).withColor(Color.BLUE).build(); 124 | break; 125 | case 7: 126 | effect = builder.flicker(false).trail(true).withColor(Color.YELLOW).build(); 127 | break; 128 | } 129 | MuxFirework.spawn(loc.add(0.5, 1, 0.5), effect); 130 | 131 | } 132 | public static void spawn(final Location location, final FireworkEffect effect, final Player... players) { 133 | try { 134 | final MuxFirework firework = new MuxFirework(((CraftWorld) location.getWorld()).getHandle(), players); 135 | final FireworkMeta meta = ((Firework) firework.getBukkitEntity()).getFireworkMeta(); 136 | meta.addEffect(effect); 137 | ((Firework) firework.getBukkitEntity()).setFireworkMeta(meta); 138 | firework.setPosition(location.getX(), location.getY(), location.getZ()); 139 | if (((CraftWorld) location.getWorld()).getHandle().addEntity(firework)) { 140 | firework.setInvisible(true); 141 | } 142 | } catch (final Exception e) { 143 | e.printStackTrace(); 144 | } 145 | } 146 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/MuxGiantItems.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | import net.minecraft.server.v1_8_R3.Entity; 5 | import net.minecraft.server.v1_8_R3.EntityGiantZombie; 6 | import net.minecraft.server.v1_8_R3.MobEffect; 7 | import org.bukkit.Location; 8 | import org.bukkit.World; 9 | import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; 10 | import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; 11 | import org.bukkit.entity.Giant; 12 | import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; 13 | import org.bukkit.inventory.ItemStack; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | public final class MuxGiantItems { 19 | private MuxSystem ms; 20 | private final List giantitems = new ArrayList<>(); 21 | 22 | public MuxGiantItems(final MuxSystem ms) { 23 | this.ms = ms; 24 | removeOld(); 25 | } 26 | public void close() { 27 | this.ms = null; 28 | } 29 | public void respawn() { 30 | giantitems.forEach(fv -> { 31 | final EntityGiantZombie entity = fv.entity; 32 | if (entity.dead) { 33 | entity.dead = false; 34 | entity.addEffect(new MobEffect(14, 9999999, 0, true, false)); 35 | entity.world.addEntity(entity, SpawnReason.CUSTOM); 36 | } else if (entity.hasEffect(14) == false) { 37 | entity.addEffect(new MobEffect(14, 9999999, 0, true, false)); 38 | } 39 | }); 40 | } 41 | public void removeSpawnGiant() { 42 | giantitems.get(0).entity.dead = true; 43 | } 44 | public void addGiant(final Location l, final ItemStack item) { 45 | giantitems.add(new MuxGiant(l, item)); 46 | } 47 | public void removeOld() { 48 | for (final World x : ms.getServer().getWorlds()) { 49 | x.getEntitiesByClass(Giant.class).forEach(org.bukkit.entity.Entity::remove); 50 | } 51 | } 52 | final class MuxGiant { 53 | public final EntityGiantZombie entity; 54 | 55 | public MuxGiant(final Location l, final ItemStack item) { 56 | entity = new EntityGiantZombie(((CraftWorld) l.getWorld()).getHandle()); 57 | 58 | entity.setPositionRotation(l.getX() + 2D, l.getY(), l.getZ(), l.getYaw(), l.getPitch()); 59 | entity.setEquipment(0, CraftItemStack.asNMSCopy(item)); 60 | 61 | l.getChunk().load(false); 62 | NMSReflection.setObject(Entity.class, "invulnerable", entity, true); 63 | NMSReflection.setObject(Entity.class, "uniqueID", entity, ms.getIdentificationId()); 64 | entity.addEffect(new MobEffect(14, 9999999, 0, true, false)); 65 | entity.canPickUpLoot = false; 66 | entity.persistent = true; 67 | entity.world.addEntity(entity, SpawnReason.CUSTOM); 68 | ms.noAI(entity.getBukkitEntity()); 69 | entity.b(true); 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/MuxLanguage.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | import org.bukkit.configuration.file.FileConfiguration; 5 | 6 | import java.io.InputStreamReader; 7 | import java.nio.charset.StandardCharsets; 8 | import java.util.PropertyResourceBundle; 9 | 10 | public final class MuxLanguage { 11 | private String locale; 12 | private PropertyResourceBundle bundle; 13 | 14 | public MuxLanguage(final MuxSystem ms) { 15 | loadConfig(ms, ms.getConfig()); 16 | } 17 | 18 | public void loadConfig(final MuxSystem ms, final FileConfiguration config) { 19 | locale = config.getString("lang"); 20 | final String filename = "lang_" + locale + ".properties"; 21 | try { 22 | bundle = new PropertyResourceBundle(new InputStreamReader(ms.getResource(filename), StandardCharsets.UTF_8)); 23 | } catch (final Exception e) { 24 | e.printStackTrace(); 25 | } 26 | } 27 | public String getLang(final String holder) { 28 | String l; 29 | try { 30 | l = bundle.getString(holder); 31 | } catch (final Exception ex) { 32 | System.err.println("MuxSystem> Language missing: " + holder); 33 | return holder; 34 | } 35 | return l.startsWith("\"") ? l.substring(1) : l; 36 | } 37 | public String getLocale() { 38 | return locale.toUpperCase(); 39 | } 40 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/MuxLocation.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.Location; 5 | import org.bukkit.World; 6 | 7 | public class MuxLocation { 8 | protected final double x, y, z; 9 | protected final int yaw, pitch; 10 | protected final String world; 11 | 12 | public MuxLocation(final String world, final double x, final double y, final double z, final int yaw, final int pitch) { 13 | this.world = world; 14 | this.x = x; 15 | this.y = y; 16 | this.z = z; 17 | this.yaw = yaw; 18 | this.pitch = pitch; 19 | } 20 | public MuxLocation(final String world, final double x, final double y, final double z) { 21 | this.world = world; 22 | this.x = x; 23 | this.y = y; 24 | this.z = z; 25 | this.yaw = 0; 26 | this.pitch = 0; 27 | } 28 | 29 | public MuxLocation(final Location l) { 30 | this(l.getWorld().getName(), Math.floor(l.getX() * 100) / 100, Math.floor(l.getY() * 100) / 100, Math.floor(l.getZ() * 100) / 100, Math.round(l.getYaw()) % 360, Math.round(l.getPitch()) % 360); 31 | } 32 | 33 | public Location getLocation() { 34 | final World w = Bukkit.getWorld(world); 35 | if (w == null) return null; 36 | return new Location(w, x, y, z, yaw, pitch); 37 | } 38 | public double getX() { 39 | return x; 40 | } 41 | public double getY() { 42 | return y; 43 | } 44 | public double getZ() { 45 | return z; 46 | } 47 | public String getWorld() { 48 | return world; 49 | } 50 | @Override 51 | public boolean equals(final Object obj) { 52 | if (obj == null || getClass() != obj.getClass()) { 53 | return false; 54 | } 55 | final MuxLocation other = (MuxLocation) obj; 56 | 57 | if (other.world != null && (this.world == null || this.world.equals(other.world) == false)) { 58 | return false; 59 | } else if (Double.doubleToLongBits(this.x) != Double.doubleToLongBits(other.x)) { 60 | return false; 61 | } else if (Double.doubleToLongBits(this.y) != Double.doubleToLongBits(other.y)) { 62 | return false; 63 | } else if (Double.doubleToLongBits(this.z) != Double.doubleToLongBits(other.z)) { 64 | return false; 65 | } else if (Float.floatToIntBits(this.pitch) != Float.floatToIntBits(other.pitch)) { 66 | return false; 67 | } else return Float.floatToIntBits(this.yaw) == Float.floatToIntBits(other.yaw); 68 | } 69 | @Override 70 | public int hashCode() { 71 | int hash = 3; 72 | hash = 19 * hash + (this.world != null ? this.world.hashCode() : 0); 73 | hash = 19 * hash + (int) (Double.doubleToLongBits(this.x) ^ Double.doubleToLongBits(this.x) >>> 32); 74 | hash = 19 * hash + (int) (Double.doubleToLongBits(this.y) ^ Double.doubleToLongBits(this.y) >>> 32); 75 | hash = 19 * hash + (int) (Double.doubleToLongBits(this.z) ^ Double.doubleToLongBits(this.z) >>> 32); 76 | hash = 19 * hash + Float.floatToIntBits(this.pitch); 77 | hash = 19 * hash + Float.floatToIntBits(this.yaw); 78 | return hash; 79 | } 80 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/MuxMusic.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import com.xxmicloxx.NoteBlockAPI.NoteBlockAPI; 4 | import com.xxmicloxx.NoteBlockAPI.event.SongEndEvent; 5 | import com.xxmicloxx.NoteBlockAPI.model.Song; 6 | import com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer; 7 | import com.xxmicloxx.NoteBlockAPI.songplayer.SongPlayer; 8 | import com.xxmicloxx.NoteBlockAPI.utils.NBSDecoder; 9 | import me.muxteam.muxsystem.MuxSystem; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.event.EventHandler; 12 | import org.bukkit.event.Listener; 13 | 14 | import java.io.File; 15 | import java.util.ArrayList; 16 | import java.util.Collection; 17 | import java.util.List; 18 | import java.util.Random; 19 | 20 | public class MuxMusic implements Listener { 21 | private final List history = new ArrayList<>(); 22 | private SongPlayer sp; 23 | private String song; 24 | private final Random r = new Random(); 25 | private final MuxSystem ms; 26 | 27 | public MuxMusic(final MuxSystem ms) { 28 | this.ms = ms; 29 | ms.getServer().getPluginManager().registerEvents(this, ms); 30 | } 31 | public void close() {} 32 | public void remove(final Player p) { 33 | NoteBlockAPI.setPlayerVolume(p, (byte) 0); 34 | } 35 | public void add(final Player p) { 36 | if (sp != null) sp.addPlayer(p); 37 | NoteBlockAPI.setPlayerVolume(p, (byte) 70); 38 | } 39 | public void playSong(final String song, final Collection list, final boolean force) { 40 | final Song s = NBSDecoder.parse(new File(ms.getDataFolder() + "/music", song + ".nbs")); 41 | if (s != null) { 42 | sp = new RadioSongPlayer(s); 43 | this.song = song; 44 | sp.setAutoDestroy(true); 45 | for (final Player pl : list) { 46 | if (force || ms.getMuxUser(pl.getName()).getSettings().hasMusic()) add(pl); 47 | } 48 | sp.setPlaying(true); 49 | } 50 | } 51 | @EventHandler 52 | public void onSongEnd(final SongEndEvent e) { 53 | if (e.getSongPlayer() == sp) sp = null; 54 | } 55 | public boolean isPlaying() { 56 | return sp != null; 57 | } 58 | public String getSongName() { 59 | return sp == null ? "" : sp.getSong().getTitle() == null || sp.getSong().getTitle().isEmpty() ? song : sp.getSong().getTitle(); 60 | } 61 | public String getRandomSongName() { 62 | final List songs = new ArrayList<>(); 63 | final File folder = new File(ms.getDataFolder() + "/music"); 64 | final File[] files = folder.listFiles(); 65 | if (files == null) return ""; 66 | for (final File s : files) { 67 | songs.add(s.getName().replace(".nbs", "")); 68 | } 69 | if (history.size() == songs.size()) history.clear(); 70 | final String ret = songs.get(r.nextInt(songs.size())); 71 | if (history.isEmpty() == false && history.contains(ret)) { 72 | return getRandomSongName(); 73 | } 74 | history.add(ret); 75 | return ret; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/MuxOfflinePlayer.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import net.minecraft.server.v1_8_R3.InventoryEnderChest; 4 | import net.minecraft.server.v1_8_R3.NBTCompressedStreamTools; 5 | import net.minecraft.server.v1_8_R3.NBTTagCompound; 6 | import net.minecraft.server.v1_8_R3.NBTTagList; 7 | import net.minecraft.server.v1_8_R3.PlayerInventory; 8 | import org.bukkit.Bukkit; 9 | import org.bukkit.Location; 10 | import org.bukkit.OfflinePlayer; 11 | import org.bukkit.World; 12 | import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventory; 13 | import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftInventoryPlayer; 14 | import org.bukkit.inventory.Inventory; 15 | 16 | import java.io.File; 17 | import java.io.FileInputStream; 18 | import java.io.FileNotFoundException; 19 | import java.io.FileOutputStream; 20 | import java.io.IOException; 21 | import java.util.UUID; 22 | 23 | public class MuxOfflinePlayer { 24 | private final UUID uuid; 25 | private final String name; 26 | private NBTTagCompound nbt = null; 27 | private File file; 28 | 29 | public MuxOfflinePlayer(final OfflinePlayer op) { 30 | this.uuid = op.getUniqueId(); 31 | this.name = op.getName(); 32 | 33 | try { 34 | load(); 35 | } catch (final Exception e) { 36 | e.printStackTrace(); 37 | } 38 | } 39 | 40 | private void load() throws IOException { 41 | final File folder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata"); 42 | this.file = new File(folder, uuid.toString() + ".dat"); 43 | 44 | if (file.exists() == false) throw new FileNotFoundException(); 45 | 46 | if (file.canWrite() == false) throw new IOException(); 47 | try (final FileInputStream in = new FileInputStream(file)) { 48 | nbt = NBTCompressedStreamTools.a(in); 49 | } catch (final IOException e) { 50 | e.printStackTrace(); 51 | } 52 | } 53 | 54 | public void save() { 55 | try (final FileOutputStream os = new FileOutputStream(file)) { 56 | NBTCompressedStreamTools.a(nbt, os); 57 | } catch (final IOException e) { 58 | e.printStackTrace(); 59 | } 60 | } 61 | 62 | public UUID getUUID() { 63 | return uuid; 64 | } 65 | public String getName() { 66 | return name; 67 | } 68 | 69 | private Inventory getInventory(final String path) { 70 | if (nbt == null) return null; 71 | final PlayerInventory pi = new PlayerInventory(null); 72 | pi.b(nbt.getList(path, NBTType.NBT_COMPOUND.getId())); 73 | return new CraftInventoryPlayer(pi); 74 | } 75 | 76 | public Inventory getInventory() { 77 | return getInventory("Inventory"); 78 | } 79 | 80 | public void setInventory(final Inventory inventory) { 81 | setInventory("Inventory", inventory); 82 | } 83 | 84 | private void setInventory(final String path, final Inventory inventory) { 85 | if (path.equals("EnderItems")) { 86 | nbt.set(path, ((InventoryEnderChest)((CraftInventory)inventory).getInventory()).h()); 87 | } else { 88 | nbt.set(path, ((CraftInventoryPlayer)inventory).getInventory().a(new NBTTagList())); 89 | } 90 | save(); 91 | } 92 | 93 | public Inventory getEnderChest() { 94 | if (nbt == null) return null; 95 | final InventoryEnderChest pe = new InventoryEnderChest(); 96 | pe.a(nbt.getList("EnderItems", NBTType.NBT_COMPOUND.getId())); 97 | return new CraftInventory(pe); 98 | } 99 | 100 | public void setEnderChest(final Inventory inventory) { 101 | setInventory("EnderItems", inventory); 102 | } 103 | 104 | public Location getLocation() { 105 | if (nbt == null) return null; 106 | final NBTTagList position = nbt.getList("Pos", NBTType.NBT_DOUBLE.getId()), rotation = nbt.getList("Rotation", NBTType.NBT_FLOAT.getId()); 107 | final UUID world = new UUID(nbt.getLong("WorldUUIDMost"), nbt.getLong("WorldUUIDLeast")); 108 | final double x = position.d(0), y = position.d(1), z = position.d(2); 109 | final float yaw = rotation.e(0), pitch = rotation.e(1); 110 | final World w = Bukkit.getWorld(world); 111 | if (w == null) return null; 112 | return new Location(w, x, y, z, yaw, pitch); 113 | } 114 | public enum NBTType { 115 | NBT_END(0), 116 | NBT_BYTE(1), 117 | NBT_SHORT(2), 118 | NBT_INT(3), 119 | NBT_LONG(4), 120 | NBT_FLOAT(5), 121 | NBT_DOUBLE(6), 122 | NBT_ARRAY_BYTE(7), 123 | NBT_STRING(8), 124 | NBT_LIST(9), 125 | NBT_COMPOUND(10), 126 | NBT_ARRAY_INT(11); 127 | 128 | private final int id; 129 | 130 | public int getId() { 131 | return id; 132 | } 133 | 134 | NBTType(final int type) { 135 | id = type; 136 | } 137 | } 138 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/MuxPackets.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import io.netty.channel.Channel; 4 | import io.netty.channel.ChannelHandlerContext; 5 | import io.netty.handler.codec.MessageToMessageDecoder; 6 | import me.muxteam.muxsystem.MuxSystem; 7 | import net.minecraft.server.v1_8_R3.Packet; 8 | import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; 9 | import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; 10 | import org.bukkit.entity.Player; 11 | 12 | import java.lang.reflect.Field; 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.UUID; 16 | 17 | public final class MuxPackets { 18 | private final HashMap reader = new HashMap<>(); 19 | private final MuxNPCs npcs; 20 | private final Field idfield; 21 | 22 | public MuxPackets(final MuxSystem ms) { 23 | npcs = ms.getNPCS(); 24 | this.idfield = NMSReflection.getField(PacketPlayInUseEntity.class, "a"); 25 | } 26 | 27 | public void handleJoin(final Player p) { 28 | reader.put(p.getUniqueId(), new PacketReader(p)); 29 | } 30 | public void handleQuit(final Player p) { 31 | final PacketReader pr = reader.remove(p.getUniqueId()); 32 | if (pr != null) pr.uninject(); 33 | } 34 | 35 | class PacketReader { 36 | private final Player player; 37 | public Channel channel; 38 | 39 | public PacketReader(final Player player) { 40 | this.player = player; 41 | this.inject(); 42 | } 43 | 44 | private void inject() { 45 | final CraftPlayer craftPlayer = (CraftPlayer) this.player; 46 | this.channel = craftPlayer.getHandle().playerConnection.networkManager.channel; 47 | try { 48 | if (channel.pipeline().get("JDoeoEodpEprL") == null) this.channel.pipeline().addAfter("decoder", "JDoeoEodpEprL", new MessageToMessageDecoder>() { 49 | @Override 50 | protected void decode(final ChannelHandlerContext chc, final Packet packet, final List list) { 51 | if (packet != null) { 52 | if (packet instanceof PacketPlayInUseEntity) { // PLAYER NPCs 53 | final PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet; 54 | try { 55 | if (idfield != null) { 56 | final int entid = (int) idfield.get(packet); 57 | npcs.handlePlayerNPC(player, entid, usePacket); 58 | } 59 | } catch (final Exception ex) { 60 | ex.printStackTrace(); 61 | } 62 | } 63 | } 64 | list.add(packet); 65 | } 66 | }); 67 | } catch (final Exception e) { 68 | e.printStackTrace(); 69 | System.out.println("MuxSystem> Error at intercepting player '" + player.getName() + "'. Ignoring..."); 70 | } 71 | } 72 | public void uninject() { 73 | channel.eventLoop().execute(() -> { 74 | try { 75 | if (channel.pipeline().get("JDoeoEodpEprL") != null) channel.pipeline().remove("JDoeoEodpEprL"); 76 | } catch (final Exception e) { 77 | System.out.println("MuxSystem> Error at removing channel from player. Ignoring..."); 78 | } 79 | }); 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/NMSReflection.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import java.lang.reflect.Field; 4 | import java.lang.reflect.Method; 5 | import java.lang.reflect.Modifier; 6 | 7 | public class NMSReflection { 8 | public static void setObject(final Class target, final String variable, final Object ob, final Object toset) { 9 | try { 10 | final Field f = target.getDeclaredField(variable); 11 | f.setAccessible(true); 12 | f.set(ob, toset); 13 | } catch (final Exception e) { 14 | e.printStackTrace(); 15 | } 16 | } 17 | 18 | public static Object getObject(final Class target, final String variable, final Object cl) { 19 | try { 20 | final Field f = target.getDeclaredField(variable); 21 | f.setAccessible(true); 22 | return f.get(cl); 23 | } catch (final Exception e) { 24 | e.printStackTrace(); 25 | return null; 26 | } 27 | } 28 | 29 | public static Field getField(final Class target, final String variable) { 30 | try { 31 | final Field f = target.getDeclaredField(variable); 32 | f.setAccessible(true); 33 | return f; 34 | } catch (final Exception e) { 35 | e.printStackTrace(); 36 | return null; 37 | } 38 | } 39 | 40 | public static Method getMethod(final Class target, final String method) { 41 | try { 42 | for (final Method methods : target.getMethods()) { 43 | if (methods.getName().equals(method)) return methods; 44 | } 45 | } catch (final Exception e) { 46 | e.printStackTrace(); 47 | } 48 | return null; 49 | } 50 | 51 | public static Object invoke(final Class target, final Method method, final Object obj, final Object... args) { 52 | return invoke(target, method.getName(), method.getParameterTypes(), method.getReturnType(), obj, args); 53 | } 54 | 55 | public static T invoke(final Class target, final String method, final Class[] arguments, final Class returntype, final Object cl, final Object... args) { 56 | try { 57 | final Method m = target.getMethod(method, arguments); 58 | m.setAccessible(true); 59 | return returntype.cast(m.invoke(cl, args)); 60 | } catch (final Exception e) { 61 | e.printStackTrace(); 62 | } 63 | return null; 64 | } 65 | 66 | public static void removeFinal(final Field field) { 67 | try { 68 | final Field modifiersField = Field.class.getDeclaredField("modifiers"); 69 | modifiersField.setAccessible(true); 70 | modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); 71 | } catch (final Exception e) { 72 | e.printStackTrace(); 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/Pageifier.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public final class Pageifier { 7 | private final int pagesize; 8 | private final List> pages; 9 | 10 | public Pageifier(final int pagesize) { 11 | this.pagesize = pagesize; 12 | this.pages = new ArrayList<>(); 13 | this.pages.add(new ArrayList<>()); 14 | } 15 | public void addItem(final T item) { 16 | final int pageNum = pages.size() - 1; 17 | List currentPage = this.pages.get(pageNum); 18 | if (currentPage.size() >= this.pagesize) { 19 | currentPage = new ArrayList<>(); 20 | this.pages.add(currentPage); 21 | } 22 | currentPage.add(item); 23 | } 24 | public List getPage(final int pageNum) { 25 | if (this.pages.isEmpty() || this.pages.get(pageNum) == null) 26 | return new ArrayList<>(); 27 | return this.pages.get(pageNum); 28 | } 29 | public List> getPages() { 30 | return this.pages; 31 | } 32 | public int getPageSize() { 33 | return this.pagesize; 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/PathfinderGoalEntityDirection.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import net.minecraft.server.v1_8_R3.EntityInsentient; 4 | import net.minecraft.server.v1_8_R3.PathfinderGoal; 5 | 6 | import org.bukkit.Location; 7 | import org.bukkit.block.BlockFace; 8 | 9 | public class PathfinderGoalEntityDirection extends PathfinderGoal { 10 | 11 | /** 12 | * @author Paul Gschwendtner 13 | * @version 0.1 14 | * @category Minecraft.NET Packet Interception Library 15 | */ 16 | 17 | EntityInsentient e; 18 | BlockFace bf; 19 | 20 | public PathfinderGoalEntityDirection(final EntityInsentient e, final BlockFace bf) { 21 | this.bf = bf; 22 | this.e = e; 23 | } 24 | 25 | @Override 26 | public boolean a() { 27 | return true; 28 | } 29 | 30 | @Override 31 | public void e() { 32 | final Location l = new Location(e.world.getWorld(), e.locX, e.locY, e.locZ).getBlock().getRelative(bf).getLocation(); 33 | e.getControllerLook().a(l.getBlockX() + .5, e.locY + e.getHeadHeight(), l.getBlockZ() + .5, 10F, this.e.bQ()); 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/PathfinderGoalPlayerFollow.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import net.minecraft.server.v1_8_R3.*; 4 | 5 | import org.bukkit.Location; 6 | import org.bukkit.entity.Player; 7 | 8 | import java.lang.reflect.Field; 9 | 10 | public class PathfinderGoalPlayerFollow extends PathfinderGoal { 11 | 12 | /** 13 | * @author Paul Gschwendtner 14 | * @version 0.1 15 | * @category Minecraft.NET Packet Interception Library 16 | */ 17 | 18 | EntityInsentient entity; 19 | Player p; 20 | double speed; 21 | 22 | public PathfinderGoalPlayerFollow(final EntityInsentient entity, final Player p, final double speed) { 23 | this.entity = entity; 24 | this.p = p; 25 | this.speed = speed; 26 | if (this.entity.getNavigation() instanceof NavigationGuardian) { 27 | try { 28 | final Field navigationField = EntityInsentient.class.getDeclaredField("navigation"); 29 | navigationField.setAccessible(true); 30 | navigationField.set(this.entity, new Navigation(this.entity, this.entity.world)); 31 | } catch (final NoSuchFieldException | IllegalAccessException e) { 32 | e.printStackTrace(); 33 | } 34 | } 35 | } 36 | 37 | @Override 38 | public boolean a() { 39 | if (p.getLocation().distance(new Location(p.getWorld(), entity.locX, entity.locY, entity.locZ)) > 30) { 40 | entity.setLocation(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), 0F, 0F); 41 | return false; 42 | } 43 | return true; 44 | } 45 | @Override 46 | public boolean b() { 47 | return false; 48 | } 49 | @Override 50 | public void e() { 51 | if (p.getLocation().distance(new Location(p.getWorld(), entity.locX, entity.locY, entity.locZ)) < 3) { 52 | return; 53 | } 54 | final Location l = p.getLocation(); 55 | final PathEntity pe = this.entity.getNavigation().a(l.getX() + 1.45, l.getY(), l.getZ() + 1); 56 | this.entity.getNavigation().a(pe, speed); 57 | } 58 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/basic/Stacktrace.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.basic; 2 | 3 | import org.apache.logging.log4j.LogManager; 4 | import org.apache.logging.log4j.Logger; 5 | 6 | import java.io.PrintWriter; 7 | import java.io.StringWriter; 8 | 9 | public class Stacktrace { 10 | private static final Logger LOGGER = LogManager.getLogger("MuxSystem-Error"); 11 | 12 | public static void print(final String str, final Throwable throwable) { LOGGER.error(str + (str.endsWith(" ") ? "" : " ") + getStacktrace(throwable));} 13 | 14 | public static void print(final Throwable throwable) { 15 | LOGGER.error("An error occurs! : " + getStacktrace(throwable)); 16 | } 17 | 18 | public static String getStacktrace(final Throwable throwable) { 19 | final StringWriter stack = new StringWriter(); 20 | throwable.printStackTrace(new PrintWriter(stack)); 21 | return stack.toString(); 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/casino/BlackJack.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.casino; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.Material; 5 | import org.bukkit.Sound; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | import java.util.ArrayList; 10 | import java.util.HashMap; 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | public class BlackJack { 15 | private final List games = new ArrayList<>(); 16 | public final Map gamenr = new HashMap<>(); 17 | private final MuxCasino c; 18 | 19 | public BlackJack(final MuxCasino c) { 20 | this.c = c; 21 | setup(); 22 | } 23 | 24 | public void setup() { 25 | games.add(new BlackJackGame(new Location(c.getWorld(), -14.5, 8, -161.5), c, this, 1)); 26 | } 27 | 28 | public void quit(final Player p) { 29 | for (final BlackJackGame g : games) { 30 | if (g.realstakes.containsKey(p)) { 31 | g.quit(p); 32 | } 33 | } 34 | gamenr.remove(p); 35 | } 36 | 37 | public void onInvClick(final Player p, final ItemStack i, final boolean rightclick, final String title) { 38 | if (title.contains("BlackJack") == false) return; 39 | BlackJackGame game = null; 40 | final int gn = gamenr.getOrDefault(p, -1); 41 | if (gn == -1) return; 42 | for (final BlackJackGame g : games) { 43 | if (g.gn == gn) game = g; 44 | } 45 | if (game == null) return; 46 | final Material m = i.getType(); 47 | if (m == Material.INK_SACK) { 48 | if (game.currentInv.containsKey(p) == false) { 49 | final int stake = game.stakes.get(p); 50 | if (rightclick) { 51 | if (stake >= 1000) { 52 | game.stakes.put(p, stake - c.getNextStakeChange(stake, false)); 53 | p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1F, 1F); 54 | } else { 55 | c.ms.showItemBar(p, "§cDer Einsatz muss mindestens §d500 Chips §cbetragen."); 56 | p.closeInventory(); 57 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 58 | return; 59 | } 60 | } else { 61 | final int newstake = stake + c.getNextStakeChange(stake, true); 62 | if (newstake > c.getChips(p) || newstake > 10000000) { 63 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 64 | return; 65 | } 66 | game.stakes.put(p, newstake); 67 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 10F); 68 | } 69 | game.openInv(p); 70 | return; 71 | } 72 | } else if (m == Material.EMERALD_BLOCK) { 73 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 10F); 74 | final int stake = game.stakes.get(p); 75 | if (c.canBuy(p, stake, "BlackJack") == false) { 76 | return; 77 | } 78 | game.realstakes.put(p, stake); 79 | c.ms.getAnalytics().getAnalytics().addPlayedCasinoGame("Blackjack"); 80 | c.getStats().BLACKJACK_GEWINN += stake; 81 | game.openFirstBank(p); 82 | return; 83 | } else if (m == Material.STAINED_CLAY) { 84 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 10F); 85 | game.nextCard(p); 86 | return; 87 | } else if (m == Material.BARRIER) { 88 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 10F); 89 | game.openBankInv(p); 90 | return; 91 | } 92 | p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1F, 1F); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/me/muxteam/casino/CoinFlip.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.casino; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.Material; 5 | import org.bukkit.Sound; 6 | import org.bukkit.block.Sign; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | import java.util.ArrayList; 11 | import java.util.HashMap; 12 | import java.util.List; 13 | import java.util.Map; 14 | 15 | 16 | public class CoinFlip { 17 | private final List games = new ArrayList<>(); 18 | public final Map stakes = new HashMap<>(); 19 | private final Map gamenr = new HashMap<>(); 20 | private final MuxCasino c; 21 | 22 | public CoinFlip(final MuxCasino c) { 23 | this.c = c; 24 | setup(); 25 | } 26 | public void setup() { 27 | games.add(new CoinFlipGame(1, new Location(c.getWorld(), -41.5, 11, -156.5), true, c, this)); 28 | games.add(new CoinFlipGame(2, new Location(c.getWorld(), -41.5, 11, -163.5), true, c, this)); 29 | games.add(new CoinFlipGame(3, new Location(c.getWorld(), 53.2, 11, -163.5), false, c, this)); 30 | games.add(new CoinFlipGame(4, new Location(c.getWorld(), 53.2, 11, -156.5), false, c, this)); 31 | games.add(new CoinFlipGame(5, new Location(c.getWorld(), -39.2, 23.5, -147.5), true, c, this)); 32 | games.add(new CoinFlipGame(6, new Location(c.getWorld(), 51, 23.5, -145.5), false, c, this)); 33 | } 34 | public void onInteract(final Player p, final Sign s) { 35 | if (s.getLine(0).equalsIgnoreCase("[CoinFlip]") || s.getLine(0).equalsIgnoreCase("§1§lCOINFLIP") || s.getLine(0).equalsIgnoreCase("§9§lCOINFLIP")) { 36 | s.setLine(0, "§1§lCOINFLIP"); 37 | s.setLine(1, "§8-*-"); 38 | s.setLine(2, "§l500+ Chips"); 39 | s.setLine(3, "Klicke zum Öffnen"); 40 | s.update(); 41 | final Location l = p.getLocation(); 42 | int game = -1; 43 | for (final CoinFlipGame g : games) { 44 | if ((g.p1 != null && g.p1.equals(p)) || (g.p2 != null && g.p2.equals(p))) { 45 | c.ms.showItemBar(p, "§cWarte auf einen Mitspieler."); 46 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 47 | return; 48 | } else if (g.getLocation().distance(l) < 3.5D) { 49 | game = g.gamenum; 50 | } 51 | } 52 | gamenr.put(p, game); 53 | for (final CoinFlipGame g : games) { 54 | if (g.gamenum == game) { 55 | int stake = stakes.getOrDefault(p, 0); 56 | if (stake == 0 || stake > c.getChips(p)) { 57 | stakes.put(p, 500); 58 | } 59 | if ((g.p1 != null && g.p2 != null) || g.runrandom || g.winning) { 60 | c.ms.showItemBar(p, "§cDieses Spiel ist derzeit besetzt."); 61 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 62 | return; 63 | } 64 | if (g.p1 == null || g.p1 != p) { 65 | g.openInv(p); 66 | } else { 67 | c.ms.showItemBar(p, "§cWarte auf einen Mitspieler."); 68 | } 69 | } 70 | } 71 | } 72 | } 73 | public void onUpdate() { 74 | for (final CoinFlipGame g : games) { 75 | g.onUpdate(); 76 | } 77 | } 78 | public void onUpdateHalf() { 79 | for (final CoinFlipGame g : games) { 80 | g.onUpdateHalf(); 81 | } 82 | } 83 | 84 | public void close() { 85 | for (final CoinFlipGame g : games) { 86 | g.close(); 87 | } 88 | } 89 | 90 | public void onInvClick(final Player p, final ItemStack i, final boolean rightclick, final String title) { 91 | if (title.contains("CoinFlip") == false) return; 92 | CoinFlipGame game = null; 93 | final int gn = gamenr.getOrDefault(p, -1); 94 | if (gn == -1) return; 95 | for (final CoinFlipGame g : games) { 96 | if (g.gamenum == gn) game = g; 97 | } 98 | if (game == null) return; 99 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 10F); 100 | final Material m = i.getType(); 101 | if (m == Material.INK_SACK) { 102 | final int stake = stakes.get(p); 103 | if (rightclick) { 104 | if (stake >= 1000) { 105 | stakes.put(p, stake - c.getNextStakeChange(stake, false)); 106 | p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1F, 1F); 107 | } else { 108 | c.ms.showItemBar(p, "§cDer Einsatz muss mindestens §d500 Chips §cbetragen."); 109 | p.closeInventory(); 110 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 111 | return; 112 | } 113 | } else { 114 | final int newstake = stake + c.getNextStakeChange(stake, true); 115 | if (newstake > c.getChips(p) || newstake > 1000000000) { 116 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 117 | return; 118 | } 119 | stakes.put(p, newstake); 120 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 10F); 121 | } 122 | game.openInv(p); 123 | } else if (m == Material.EMERALD_BLOCK) { 124 | final String display = i.getItemMeta().getDisplayName(); 125 | if (display.contains("Beitreten")) { 126 | if (game.p1 == null) { 127 | p.closeInventory(); 128 | c.ms.showItemBar(p, "§cDein Mitspieler ist weg."); 129 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 130 | return; 131 | } else if (game.p2 != null) { 132 | p.closeInventory(); 133 | c.ms.showItemBar(p, "§cDieses Spiel ist bereits besetzt."); 134 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 135 | return; 136 | } 137 | int stake = stakes.get(game.p1); 138 | if (c.canBuy(p, stake, "CoinFlip") == false) { 139 | return; 140 | } 141 | game.realstakes.put(p, stake); 142 | c.getStats().COINFLIP_GESETZT += stake; 143 | game.p2 = p; 144 | game.runrandom = true; 145 | c.ms.getAnalytics().getAnalytics().addPlayedCasinoGame("Coinflip"); 146 | p.closeInventory(); 147 | c.ms.showItemBar(p, "§aEinsatz von §d" + c.ms.getNumberFormat(stake) + " Chips §agesetzt."); 148 | } else if (display.contains("Erstellen")) { 149 | if (game.p1 != null) { 150 | p.closeInventory(); 151 | c.ms.showItemBar(p, "§cDieser Coinflip ist schon erstellt."); 152 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 153 | } else if (game.p2 == null) { 154 | int stake = stakes.get(p); 155 | if (c.canBuy(p, stake, "CoinFlip") == false) { 156 | return; 157 | } 158 | game.realstakes.put(p, stake); 159 | c.getStats().COINFLIP_GESETZT += stake; 160 | game.p1 = p; 161 | p.closeInventory(); 162 | c.ms.showItemBar(p, "§aEinsatz von §d" + c.ms.getNumberFormat(stake) + " Chips §agesetzt."); 163 | c.ms.sendNormalTitle(p, "§eWarte nun auf einen Mitspieler.", 10, 40, 10); 164 | } else { 165 | game.reset(); 166 | } 167 | } 168 | } 169 | } 170 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/casino/CoinPusher.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.casino; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.block.Sign; 5 | import org.bukkit.entity.ArmorStand; 6 | import org.bukkit.entity.Entity; 7 | import org.bukkit.entity.Player; 8 | 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | public class CoinPusher { 13 | private final Map games = new HashMap<>(); 14 | private int ticks = 0; 15 | private final MuxCasino c; 16 | 17 | public CoinPusher(final MuxCasino c) { 18 | this.c = c; 19 | //addCoinPusher(new Location(c.getWorld(), 16.5, 8, -162.5), new Location(c.getWorld(), -26.5, 50, -225.5), 500); 20 | //addCoinPusher(new Location(c.getWorld(), 1.5, 20, -153.5), new Location(c.getWorld(), -40.5, 50, -225.5), 5000); 21 | } 22 | 23 | public void close() { 24 | games.values().forEach(CoinPusherGame::close); 25 | } 26 | 27 | public void onUpdate() { 28 | games.values().forEach(CoinPusherGame::update); 29 | if (ticks++ > 10) { 30 | ticks = 0; 31 | games.values().forEach(game -> { 32 | game.updateMachine(); 33 | game.updateStartAmount(); 34 | }); 35 | } 36 | } 37 | 38 | private void addCoinPusher(final Location loc, final Location redstoneblock, final int stake) { 39 | final int nr = games.size() + 1; 40 | games.put(nr, new CoinPusherGame(c, loc, redstoneblock, nr, stake)); 41 | } 42 | 43 | public boolean onInteractAtEntity(final Player p, final Entity click) { 44 | if (click instanceof ArmorStand) { 45 | final ArmorStand clicked = (ArmorStand) click; 46 | for (final CoinPusherGame game : games.values()) { 47 | if (game.getConstruct().contains(clicked) || game.getIllustration1().containsValue(clicked) || game.getIllustration2().containsValue(clicked) || game.getIllustration3().containsValue(clicked)) { 48 | game.tryToPlay(p); 49 | return true; 50 | } 51 | } 52 | } 53 | return false; 54 | } 55 | 56 | public void onInteract(final Player p, final Sign sign) { 57 | games.values().stream().filter(game1 -> game1.button == sign.getBlock()).findFirst().ifPresent(game -> game.tryToPlay(p)); 58 | } 59 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/casino/GuessTheNumber.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.casino; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.Material; 5 | import org.bukkit.OfflinePlayer; 6 | import org.bukkit.Sound; 7 | import org.bukkit.entity.HumanEntity; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.inventory.Inventory; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | import java.util.*; 13 | 14 | public class GuessTheNumber { 15 | private final List games = new ArrayList<>(); 16 | private final MuxCasino c; 17 | 18 | public GuessTheNumber(final MuxCasino c) { 19 | this.c = c; 20 | setup(); 21 | } 22 | 23 | private void setup() { 24 | games.add(new GuessTheNumberGame(new Location(c.getWorld(), 42.5, 22, -184.5), c)); 25 | } 26 | 27 | public void close() { 28 | for (final GuessTheNumberGame g : games) { 29 | g.close(); 30 | } 31 | } 32 | 33 | public void quit(final Player p) { 34 | for (final GuessTheNumberGame g : games) { 35 | g.quit(p); 36 | } 37 | } 38 | 39 | public void onUpdate() { 40 | for (final GuessTheNumberGame g : games) { 41 | g.onUpdate(); 42 | } 43 | } 44 | 45 | public void onInvClick(final Player p, final ItemStack i, final int rawslot, final String title, final Inventory inv, boolean rightclick) { 46 | if (title.contains("Zahlen Raten") == false) return; 47 | GuessTheNumberGame game = null; 48 | for (final GuessTheNumberGame g : games) { 49 | if (g.inventories.containsValue(inv) || g.startinv.contains(p)) { 50 | game = g; 51 | } 52 | } 53 | if (game == null) { 54 | return; 55 | } 56 | final Material m = i.getType(); 57 | if (m == Material.INK_SACK) { 58 | if (game.started) { 59 | game.openInv(p); 60 | c.ms.showItemBar(p, "§cDas Spiel hat bereits begonnen."); 61 | return; 62 | } 63 | final int stake = game.realstakes.getOrDefault(p, 500); 64 | if (rightclick) { 65 | if (stake >= 1000) { 66 | game.realstakes.put(p, stake - c.getNextStakeChange(stake, false)); 67 | p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1F, 1F); 68 | } else { 69 | c.ms.showItemBar(p, "§cDer Einsatz muss mindestens §d500 Chips §cbetragen."); 70 | p.closeInventory(); 71 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 72 | return; 73 | } 74 | } else { 75 | final int newstake = stake + c.getNextStakeChange(stake, true); 76 | if (newstake > c.getChips(p) || newstake > 1000000000) { 77 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 78 | return; 79 | } 80 | game.realstakes.put(p, newstake); 81 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 10F); 82 | } 83 | game.openStartInv(p); 84 | } else if (m == Material.EMERALD_BLOCK) { 85 | if (game.started && inv.getItem(22).getType() != Material.EMERALD_BLOCK) { 86 | game.openInv(p); 87 | p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1F, 1F); 88 | c.ms.showItemBar(p, "§cDas Spiel hat bereits begonnen."); 89 | return; 90 | } 91 | final int stake = game.realstakes.getOrDefault(p, 500); 92 | if (stake > c.getChips(p)) { 93 | c.ms.showItemBar(p, "§cDu hast nicht genug Chips."); 94 | p.playSound(p.getLocation(), Sound.NOTE_BASS, 1F, 1F); 95 | p.closeInventory(); 96 | return; 97 | } 98 | game.realstake = game.realstakes.getOrDefault(p, 500); 99 | game.started = true; 100 | c.ms.getAnalytics().getAnalytics().addPlayedCasinoGame("Guess the Number"); 101 | game.startinv.stream().filter(Objects::nonNull).filter(OfflinePlayer::isOnline).forEach(HumanEntity::closeInventory); 102 | game.openInv(p); 103 | game.startinv.clear(); 104 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 1F); 105 | } else if (m == Material.MAP || m == Material.REDSTONE_BLOCK) { 106 | p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1F, 1F); 107 | } else if (m == Material.PAPER) { 108 | if (game.started == false) { 109 | c.ms.showItemBar(p, "§cDas Spiel hat noch nicht begonnen."); 110 | game.openStartInv(p); 111 | return; 112 | } else if (game.guesses.containsKey(p.getUniqueId())) { 113 | p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1F, 1F); 114 | return; 115 | } else if (c.canBuy(p, game.realstake, "Zahlen Raten") == false) { 116 | return; 117 | } 118 | c.ms.showItemBar(p, "§aDu hast deinen Einsatz gesetzt."); 119 | p.playSound(p.getLocation(), Sound.NOTE_PLING, 1F, 1F); 120 | c.getStats().GUESS_THE_NUMBER_EINSATZ += game.realstake; 121 | game.winnings += game.realstake; 122 | game.guesses.put(p.getUniqueId(), rawslot + 1); 123 | game.openInv(p); 124 | } 125 | } 126 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/casino/ItemFlip.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.casino; 2 | 3 | import me.muxteam.muxsystem.MuxInventory; 4 | import org.bukkit.Location; 5 | import org.bukkit.Material; 6 | import org.bukkit.Sound; 7 | import org.bukkit.block.BlockFace; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.inventory.Inventory; 10 | import org.bukkit.inventory.ItemStack; 11 | import org.bukkit.inventory.meta.SkullMeta; 12 | 13 | import java.util.ArrayList; 14 | import java.util.Arrays; 15 | import java.util.List; 16 | import java.util.Optional; 17 | 18 | 19 | public class ItemFlip { 20 | private final List games = new ArrayList<>(); 21 | private Inventory inv, invnohand; 22 | private final MuxCasino c; 23 | 24 | public ItemFlip(final MuxCasino c) { 25 | this.c = c; 26 | setup(); 27 | } 28 | 29 | public void setup() { 30 | final Location loc = new Location(c.getWorld(), -14.5, 8, -157.5, -145F, 0F); 31 | for (int i = 1; i < 8; i++) { 32 | final ItemFlipGame g1 = new ItemFlipGame(loc, c); 33 | games.add(g1); 34 | } 35 | inv = c.ms.getServer().createInventory(null, 54, "§0§lMuxCasino§0 | ItemFlip"); 36 | invnohand = c.ms.getServer().createInventory(null, 54, "§0§lMuxCasino§0 | ItemFlip"); 37 | c.ms.getNPCS().addVillager(0, loc.clone(), BlockFace.NORTH_EAST, "§a§lItemFlip", this::openInv); 38 | } 39 | 40 | public void onUpdate() { 41 | for (final ItemFlipGame g : games) { 42 | g.onUpdate(); 43 | } 44 | } 45 | 46 | public Optional getFrom(final Player p) { 47 | return games.stream().filter(itemFlipGame -> itemFlipGame.p1 == p || itemFlipGame.p2 == p).findFirst(); 48 | } 49 | 50 | public void onUpdateHalf() { 51 | for (final ItemFlipGame g : games) { 52 | g.onUpdateHalf(); 53 | } 54 | } 55 | 56 | public void onInvClick(final Player p, final ItemStack i, final int rawslot, final String title) { 57 | if (title.contains("ItemFlip") == false) return; 58 | final Material m = i.getType(); 59 | if (m == Material.SKULL_ITEM && title.contains("Raum") == false) { 60 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 10F); 61 | final ItemStack hand = p.getItemInHand(); 62 | if (hand == null || hand.getType() == Material.AIR || c.ms.getUltra().isUltraItem(hand) || c.ms.isMenuItem(hand)) { 63 | c.ms.showItemBar(p, "§cNimm ein Item in die Hand."); 64 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 65 | p.closeInventory(); 66 | return; 67 | } 68 | final ItemStack einsatz = p.getItemInHand().clone(); 69 | final ItemFlipGame game = games.get(rawslot - 19); 70 | if (game == null) { 71 | return; 72 | } 73 | if (game.p1 != null && game.p1 != p) { 74 | if (game.p2 != null) { 75 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 76 | return; 77 | } 78 | game.i2 = einsatz.clone(); 79 | game.p2 = p; 80 | game.openInv(game.p1); 81 | } else { 82 | if (game.p2 != null) { 83 | game.reset(); 84 | } 85 | game.i1 = einsatz.clone(); 86 | game.p1 = p; 87 | } 88 | game.openInv(p); 89 | updateInvs(); 90 | return; 91 | } 92 | ItemFlipGame game = null; 93 | for (final ItemFlipGame g : games) { 94 | if ((g.p1 != null && g.p1.equals(p)) || (g.p2 != null && g.p2.equals(p))) game = g; 95 | } 96 | if (game == null) { 97 | return; 98 | } 99 | if (m == Material.STAINED_CLAY && i.getDurability() == (short) 13) { 100 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 10F); 101 | if (game.p1.equals(p)) { 102 | game.accept1 = true; 103 | } 104 | if (game.p2.equals(p)) { 105 | game.accept2 = true; 106 | } 107 | game.openInv(game.p1); 108 | game.openInv(game.p2); 109 | if (game.accept1 && game.accept2 && game.runrandom == false) { 110 | game.runrandom = true; 111 | game.p1.setItemInHand(new ItemStack(Material.AIR)); 112 | game.p1.setItemInHand(null); 113 | game.p2.setItemInHand(new ItemStack(Material.AIR)); 114 | game.p2.setItemInHand(null); 115 | game.roll(); 116 | } 117 | } 118 | } 119 | 120 | private void updateInvs() { 121 | updateInv(true); 122 | updateInv(false); 123 | } 124 | 125 | private void updateInv(final boolean empty) { 126 | int step = 0; 127 | for (final ItemFlipGame iflip : games) { 128 | step++; 129 | final ItemStack skull1 = new ItemStack(Material.SKULL_ITEM, 1, (short) 3); 130 | final SkullMeta meta1 = (SkullMeta) skull1.getItemMeta(); 131 | if (iflip.p1 != null) { 132 | meta1.setOwner(iflip.p1.getName()); 133 | if (iflip.p2 != null) { 134 | meta1.setDisplayName("§3§l" + iflip.p1.getName() + "§7 gegen §3§l" + iflip.p2.getName()); 135 | } else { 136 | meta1.setDisplayName("§3§l" + iflip.p1.getName() + "§a §lherausfordern"); 137 | if (empty) { 138 | meta1.setLore(Arrays.asList("", "§cNehme das einsetzende Item in die", "§cHand, um dem Spiel beizutreten.")); 139 | } else { 140 | meta1.setLore(Arrays.asList("", "§7Klicke, um dem Spiel §abeizutreten§7.", "", "§cACHTUNG! §7Als Einsatz wird das", "§7Item in deiner Hand genommen.")); 141 | } 142 | } 143 | } else { 144 | meta1.setDisplayName("§f§lSpiel " + step + "§a §lerstellen"); 145 | if (empty) { 146 | meta1.setLore(Arrays.asList("", "§cNehme das einsetzende Item in die", "§cHand, um ein Spiel zu erstellen.")); 147 | } else { 148 | meta1.setLore(Arrays.asList("", "§7Klicke, um ein Spiel zu §aerstellen§7.", "", "§cACHTUNG! §7Als Einsatz wird das", "§7Item in deiner Hand genommen.")); 149 | } 150 | } 151 | skull1.setItemMeta(meta1); 152 | if (empty) invnohand.setItem(step + 18, skull1); 153 | else inv.setItem(step + 18, skull1); 154 | } 155 | } 156 | 157 | public void openInv(final Player p) { 158 | if (c.inCasino(p) == false) return; 159 | updateInvs(); 160 | if (c.ms.getActiveInv(p.getName()) != MuxInventory.InvType.CASINO) p.closeInventory(); 161 | p.openInventory(p.getItemInHand() == null || p.getItemInHand().getType() == Material.AIR ? invnohand : inv); 162 | c.ms.setActiveInv(p.getName(), MuxInventory.InvType.CASINO); 163 | } 164 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/casino/MuxCasinoUser.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.casino; 2 | 3 | import java.util.UUID; 4 | 5 | public class MuxCasinoUser { 6 | private final UUID uuid; 7 | private long chips, weeklywins; 8 | private int energy; 9 | private boolean changed = false; 10 | 11 | public MuxCasinoUser(final UUID uuid, final long chips, final int energy, final long weeklywins) { 12 | this.uuid = uuid; 13 | this.chips = chips; 14 | this.energy = energy; 15 | this.weeklywins = weeklywins; 16 | } 17 | public UUID getUUID() { 18 | return uuid; 19 | } 20 | public long getChips() { 21 | return chips; 22 | } 23 | public void setChips(final long chips) { 24 | this.chips = chips; 25 | this.changed = true; 26 | } 27 | public int getEnergy() { 28 | return energy; 29 | } 30 | public void setEnergy(final int energy) { 31 | this.energy = energy; 32 | this.changed = true; 33 | } 34 | public long getWeeklyWins() { 35 | return weeklywins; 36 | } 37 | public void setWeeklyWins(final long weeklywins) { 38 | this.weeklywins = weeklywins; 39 | this.changed = true; 40 | } 41 | public boolean hasChanged() { 42 | return changed; 43 | } 44 | public void saved() { 45 | this.changed = false; 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/casino/Roulette.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.casino; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.Material; 5 | import org.bukkit.Sound; 6 | import org.bukkit.block.Block; 7 | import org.bukkit.block.Sign; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | import java.util.HashSet; 12 | import java.util.Map; 13 | import java.util.Set; 14 | 15 | 16 | public class Roulette { 17 | private final Set games = new HashSet<>(); 18 | private final MuxCasino c; 19 | 20 | public Roulette(final MuxCasino c) { 21 | this.c = c; 22 | setup(); 23 | } 24 | private void setup() { 25 | games.add(new RouletteGame(new Location(c.getWorld(), -21, 9, -166), c)); 26 | games.add(new RouletteGame(new Location(c.getWorld(), -21, 9, -159), c)); 27 | games.add(new RouletteGame(new Location(c.getWorld(), 32, 9, -166), c)); 28 | games.add(new RouletteGame(new Location(c.getWorld(), 32, 9, -159), c)); 29 | games.add(new RouletteGame(new Location(c.getWorld(), 48, 22, -139), c)); 30 | games.add(new RouletteGame(new Location(c.getWorld(), -37, 21, -178), c)); 31 | } 32 | public void onUpdate() { 33 | for (final RouletteGame g : games) { 34 | g.onUpdate(); 35 | } 36 | } 37 | public void quit(final Player p) { 38 | for (final RouletteGame g : games) { 39 | g.quit(p); 40 | } 41 | } 42 | 43 | public void close() { 44 | for (final RouletteGame g : games) { 45 | for (final Map.Entry entry : g.realstakes.entrySet()) { 46 | c.addChipsOffline(entry.getKey(), entry.getValue(), "Roulette"); 47 | c.getStats().ROULETTE_GEWINN -= entry.getValue(); 48 | } 49 | g.cancel(); 50 | } 51 | } 52 | 53 | public void onInteract(final Player p, final Sign s) { 54 | if (s.getLine(0).equalsIgnoreCase("[roulette]") || s.getLine(0).equalsIgnoreCase("§1§lRoulette") || s.getLine(0).equals("§9§lRoulette")) { 55 | s.setLine(0, "§1§lRoulette"); 56 | s.setLine(1, "§8-*-"); 57 | s.setLine(2, "§l500+ Chips"); 58 | s.setLine(3, "Klicke zum Öffnen"); 59 | s.update(); 60 | final Location bloc = s.getLocation(); 61 | for (final RouletteGame g : games) { 62 | if (g.getLocation().distance(bloc) < 3.5D) { 63 | final Block stair = p.getLocation().clone().add(0, 1, 0).getBlock(); 64 | if (stair != null && stair.getType() == Material.DARK_OAK_STAIRS) { 65 | g.joinPlayer(p); 66 | } else { 67 | c.ms.showItemBar(p, "§cSetze dich hin, um mitzuspielen."); 68 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 69 | } 70 | } 71 | } 72 | } 73 | } 74 | public void onInvClick(final Player p, final ItemStack i, final boolean rightclick) { 75 | RouletteGame game = null; 76 | for (final RouletteGame g : games) { 77 | if (g.isPlaying(p)) { 78 | game = g; 79 | } 80 | } 81 | if (game == null) { 82 | return; 83 | } 84 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 10F); 85 | final Material m = i.getType(); 86 | if (m == Material.INK_SACK) { 87 | final int stake = game.stakes.get(p); 88 | if (rightclick) { 89 | if (stake >= 1000) { 90 | game.stakes.put(p, stake - c.getNextStakeChange(stake, false)); 91 | p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1F, 1F); 92 | } else { 93 | c.ms.showItemBar(p, "§cDer Einsatz muss mindestens §d500 Chips §cbetragen."); 94 | p.closeInventory(); 95 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 96 | return; 97 | } 98 | } else { 99 | final int newstake = stake + c.getNextStakeChange(stake, true); 100 | if (newstake > c.getChips(p) || newstake > 10000000) { 101 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 102 | return; 103 | } 104 | game.stakes.put(p, newstake); 105 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 10F); 106 | } 107 | game.openInv(p); 108 | } else if (m == Material.WOOL) { 109 | if (game.colorset.keySet().parallelStream().anyMatch(player -> player.getUniqueId().equals(p.getUniqueId()))) { 110 | c.ms.showItemBar(p, "§cDu hast bereits auf eine Farbe getippt."); 111 | p.closeInventory(); 112 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 113 | return; 114 | } 115 | int einsatz = game.stakes.get(p); 116 | if (c.canBuy(p, einsatz, "Roulette") == false) { 117 | return; 118 | } 119 | c.getStats().ROULETTE_GEWINN += einsatz; 120 | int set = 1; 121 | if (i.getDurability() == (short) 15) { 122 | set = 2; 123 | } else if (i.getDurability() == (short) 13) { 124 | set = 3; 125 | } 126 | game.colorset.put(p, set); 127 | game.realstakes.put(p, einsatz); 128 | p.closeInventory(); 129 | c.ms.showItemBar(p, "§aDu hast deinen Einsatz gesetzt."); 130 | p.playSound(p.getLocation(), Sound.NOTE_PLING, 1F, 1F); 131 | } 132 | } 133 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/casino/SixFields.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.casino; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.Material; 5 | import org.bukkit.Sound; 6 | import org.bukkit.block.Block; 7 | import org.bukkit.block.Sign; 8 | import org.bukkit.entity.ArmorStand; 9 | import org.bukkit.entity.EntityType; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.inventory.ItemStack; 12 | import org.bukkit.util.EulerAngle; 13 | 14 | import java.util.*; 15 | 16 | public class SixFields { 17 | private final Set games = new HashSet<>(); 18 | private final Random r = new Random(); 19 | private final MuxCasino c; 20 | 21 | public SixFields(final MuxCasino c) { 22 | this.c = c; 23 | setup(); 24 | } 25 | private void setup() { 26 | games.add(new SixFieldsGame(new Location(c.getWorld(), -22.5, 10, -143.5), c)); 27 | games.add(new SixFieldsGame(new Location(c.getWorld(), -39.5, 10, -144.5), c)); 28 | games.add(new SixFieldsGame(new Location(c.getWorld(), -35.5, 10, -180.5), c)); 29 | games.add(new SixFieldsGame(new Location(c.getWorld(), 49.5, 10, -144.5), c)); 30 | games.add(new SixFieldsGame(new Location(c.getWorld(), 32.5, 10, -143.5), c)); 31 | games.add(new SixFieldsGame(new Location(c.getWorld(), -37.5, 22, -184.5), c)); 32 | games.add(new SixFieldsGame(new Location(c.getWorld(), -24.5, 23, -137.5), c)); 33 | games.add(new SixFieldsGame(new Location(c.getWorld(), 47.5, 22, -184.5), c)); 34 | games.add(new SixFieldsGame(new Location(c.getWorld(), 47.5, 22, -179.5), c)); 35 | } 36 | public void onUpdate() { 37 | for (final SixFieldsGame g : games) { 38 | g.onUpdate(); 39 | } 40 | } 41 | public void quit(final Player p) { 42 | for (final SixFieldsGame g : games) { 43 | g.quit(p); 44 | } 45 | } 46 | 47 | public void close() { 48 | for (final SixFieldsGame g : games) { 49 | for (final Map.Entry entry : g.setonfield.entrySet()) { 50 | final int einsatz = g.chipsonfield.get(g.setonfield.get(entry.getKey())); 51 | c.addChipsOffline(entry.getKey(), einsatz, "6 Felder"); 52 | } 53 | g.cancel(); 54 | } 55 | } 56 | 57 | public void onInteract(final Player p, final Sign s) { 58 | if (s.getLine(0).equalsIgnoreCase("[sixfields]") || s.getLine(0).equalsIgnoreCase("§1§l6 FELDER") || s.getLine(0).equalsIgnoreCase("§9§lPOKER") || s.getLine(0).equalsIgnoreCase("§1§lPOKER")) { 59 | s.setLine(0, "§1§l6 FELDER"); 60 | s.setLine(1, "§8-*-"); 61 | s.setLine(2, "§l500+ Chips"); 62 | s.setLine(3, "Klicke zum Öffnen"); 63 | s.update(); 64 | final Location bloc = s.getLocation(); 65 | for (final SixFieldsGame g : games) { 66 | if (g.getLocation().distance(bloc) < 3.5D) { 67 | final Block stair = p.getLocation().clone().add(0, 1, 0).getBlock(); 68 | if (stair != null && stair.getType() == Material.DARK_OAK_STAIRS) { 69 | g.joinPlayer(p); 70 | } else { 71 | c.ms.showItemBar(p, "§cSetze dich hin, um mitzuspielen."); 72 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 73 | } 74 | } 75 | } 76 | } 77 | } 78 | public void onInvClick(final Player p, final ItemStack i, final int rawslot, final boolean rightclick) { 79 | SixFieldsGame game = null; 80 | for (final SixFieldsGame g : games) { 81 | if (g.isPlaying(p)) { 82 | game = g; 83 | } 84 | } 85 | if (game == null) { 86 | return; 87 | } 88 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 10F); 89 | final Material m = i.getType(); 90 | if (m == Material.INK_SACK) { 91 | final int stake = game.stakes.get(p); 92 | if (rightclick) { 93 | if (stake >= 1000) { 94 | game.stakes.put(p, stake - c.getNextStakeChange(stake, false)); 95 | p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1F, 1F); 96 | } else { 97 | c.ms.showItemBar(p, "§cDer Einsatz muss mindestens §d500 Chips §cbetragen."); 98 | p.closeInventory(); 99 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 100 | return; 101 | } 102 | } else { 103 | final int newstake = stake + c.getNextStakeChange(stake, true); 104 | if (newstake > c.getChips(p) || newstake > 10000000) { 105 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 106 | return; 107 | } 108 | game.stakes.put(p, newstake); 109 | p.playSound(p.getLocation(), Sound.CLICK, 1F, 10F); 110 | } 111 | game.openInv(p); 112 | } else if (m == Material.WOOL) { 113 | if (game.setonfield.keySet().parallelStream().anyMatch(player -> player.getUniqueId().equals(p.getUniqueId()))) { 114 | c.ms.showItemBar(p, "§cDu hast bereits auf ein Feld getippt."); 115 | p.closeInventory(); 116 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 117 | return; 118 | } else if (c.ms.hasGlow(i)) { 119 | p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1F, 1F); 120 | return; 121 | } 122 | int set = 1; 123 | Location chips = game.spielfeld.get(set).getLocation(); 124 | if (rawslot == 11) { 125 | set = 1; 126 | chips = game.getLocation().clone().add(0, 0, 2); 127 | } else if (rawslot == 12) { 128 | set = 2; 129 | chips = game.getLocation().clone().add(0, 0, 1); 130 | } else if (rawslot == 13) { 131 | set = 3; 132 | chips = game.getLocation().clone(); 133 | } else if (rawslot == 20) { 134 | set = 4; 135 | chips = game.getLocation().clone().add(1, 0, 2); 136 | } else if (rawslot == 21) { 137 | set = 5; 138 | chips = game.getLocation().clone().add(1, 0, 1); 139 | } else if (rawslot == 22) { 140 | set = 6; 141 | chips = game.getLocation().clone().add(1, 0, 0); 142 | } 143 | boolean alreadyused = false; 144 | for (final int a : game.setonfield.values()) { 145 | if (a == set) { 146 | alreadyused = true; 147 | break; 148 | } 149 | } 150 | if (alreadyused) { 151 | p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1F, 1F); 152 | game.openInv(p); 153 | return; 154 | } 155 | int einsatz = game.stakes.get(p); 156 | if (c.canBuy(p, einsatz, "6 Felder") == false) { 157 | return; 158 | } 159 | c.getStats().SIXFIELDS_GEWINN += einsatz; 160 | 161 | game.setonfield.put(p, set); 162 | game.chipsonfield.put(set, game.chipsonfield.get(set) + einsatz); 163 | if (chips != null) { 164 | final Location loc = chips.clone(); 165 | final int r1 = r.nextInt(5) + 2, r2 = r.nextInt(5) + 2, r3 = r.nextInt(5) + 2; 166 | for (int n = 0; n < r1; n++) { 167 | spawnChips(game.chipsontable, loc, 0.2, n, 0.2, (byte) 13); 168 | } 169 | for (int n = 0; n < r2; n++) { 170 | spawnChips(game.chipsontable, loc, 0.4, n, 0.6, (byte) 10); 171 | } 172 | for (int n = 0; n < r3; n++) { 173 | spawnChips(game.chipsontable, loc, 0.5, n, 0.2, (byte) 5); 174 | } 175 | } 176 | p.closeInventory(); 177 | c.ms.showItemBar(p, "§aDu hast deinen Einsatz gesetzt."); 178 | c.ms.getAnalytics().getAnalytics().addPlayedCasinoGame("Sechs Felder"); 179 | p.playSound(p.getLocation(), Sound.NOTE_PLING, 1F, 1F); 180 | } 181 | } 182 | private void spawnChips(final List ar, final Location loc, final double x, final int b, final double z, final byte data) { 183 | final ArmorStand a = (ArmorStand) loc.getWorld().spawnEntity(loc.clone().add(x, 0.2 + (0.03 * b), z), EntityType.ARMOR_STAND); 184 | a.setVisible(false); 185 | a.setGravity(false); 186 | a.setItemInHand(new ItemStack(Material.INK_SACK, 1, data)); 187 | a.setRightArmPose(new EulerAngle(0.0, 3.0, 0.0)); 188 | ar.add(a); 189 | } 190 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/casino/WheelOfFortune.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.casino; 2 | 3 | import me.muxteam.basic.MuxFirework; 4 | import me.muxteam.basic.MuxHolograms; 5 | import org.bukkit.Color; 6 | import org.bukkit.Location; 7 | import org.bukkit.Material; 8 | import org.bukkit.Sound; 9 | import org.bukkit.block.Sign; 10 | import org.bukkit.entity.ArmorStand; 11 | import org.bukkit.entity.EntityType; 12 | import org.bukkit.entity.Player; 13 | import org.bukkit.inventory.ItemStack; 14 | import org.bukkit.scheduler.BukkitRunnable; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | import java.util.Random; 19 | 20 | public class WheelOfFortune { 21 | private boolean running = false, winning = false; 22 | private int amount = 50000; 23 | private Player player = null; 24 | private Location loc; 25 | private MuxHolograms.Hologram jackpot = null; 26 | private final List acircle = new ArrayList<>(); 27 | private final Random r = new Random(); 28 | private final MuxCasino c; 29 | 30 | public WheelOfFortune(final MuxCasino c) { 31 | this.c = c; 32 | setup(); 33 | } 34 | 35 | public void close() { 36 | if (player != null) { 37 | c.addChipsOffline(player, 10000, "Glücksrad"); 38 | c.getStats().GRAD_GEWINN -= 10000; 39 | amount -= 5000; 40 | } 41 | } 42 | 43 | private void setup() { 44 | loc = new Location(c.getWorld(), 21.5, 9, -154.5); 45 | acircle.clear(); 46 | for (int i = 0; i < 12; i++) { 47 | Location spawn; 48 | if (i == 0) spawn = loc.clone().add(0.5, 2, 0); 49 | else if (i == 1) spawn = loc.clone().add(0, 2, 0); 50 | else if (i == 2) spawn = loc.clone().add(-0.5, 2, 0); 51 | else if (i == 3) spawn = loc.clone().add(-1, 1.5, 0); 52 | else if (i == 4) spawn = loc.clone().add(-1, 1, 0); 53 | else if (i == 5) spawn = loc.clone().add(-1, 0.5, 0); 54 | else if (i == 6) spawn = loc.clone().add(-0.5, 0, 0); 55 | else if (i == 7) spawn = loc.clone().add(-0, 0, 0); 56 | else if (i == 8) spawn = loc.clone().add(0.5, 0, 0); 57 | else if (i == 9) spawn = loc.clone().add(1, 0.5, 0); 58 | else if (i == 10) spawn = loc.clone().add(1, 1, 0); 59 | else spawn = loc.clone().add(1, 1.5, 0); 60 | spawn = spawn.clone().add(0, -0.2, 0); 61 | spawn.setYaw(-90); 62 | final ArmorStand a = (ArmorStand) loc.getWorld().spawnEntity(spawn, EntityType.ARMOR_STAND); 63 | a.setSmall(true); 64 | a.setGravity(false); 65 | a.setVisible(false); 66 | a.setHelmet(new ItemStack(Material.CLAY, 0)); 67 | acircle.add(a); 68 | if (i == 1) { 69 | a.setCustomName("§a§l⬇"); 70 | a.setCustomNameVisible(true); 71 | a.setHelmet(new ItemStack(Material.EMERALD_BLOCK)); 72 | } 73 | } 74 | final Location dloc = new Location(c.getWorld(), 25.5, 9, -158.5); 75 | c.ms.getHolograms().addHologram("crashwheel", dloc.clone(), "§fGlücksrad §a§lJACKPOT§f:"); 76 | jackpot = c.ms.getHolograms().addHologram("crashwheelinfo", dloc.clone().add(0, -0.4, 0), "§cWird geladen..."); 77 | } 78 | public void onUpdate() { 79 | final String msg = "§d" + c.ms.getNumberFormat(amount) + " Chips"; 80 | if (jackpot != null && jackpot.getMessage().equals(msg) == false) 81 | jackpot.setMessage(msg); 82 | if (running && winning == false) { 83 | final ItemStack head1 = acircle.get(0).getHelmet().clone(); 84 | acircle.get(0).setHelmet(acircle.get(11).getHelmet()); 85 | acircle.get(11).setHelmet(acircle.get(10).getHelmet()); 86 | acircle.get(10).setHelmet(acircle.get(9).getHelmet()); 87 | acircle.get(9).setHelmet(acircle.get(8).getHelmet()); 88 | acircle.get(8).setHelmet(acircle.get(7).getHelmet()); 89 | acircle.get(7).setHelmet(acircle.get(6).getHelmet()); 90 | acircle.get(6).setHelmet(acircle.get(5).getHelmet()); 91 | acircle.get(5).setHelmet(acircle.get(4).getHelmet()); 92 | acircle.get(4).setHelmet(acircle.get(3).getHelmet()); 93 | acircle.get(3).setHelmet(acircle.get(2).getHelmet()); 94 | acircle.get(2).setHelmet(acircle.get(1).getHelmet()); 95 | acircle.get(1).setHelmet(head1); 96 | loc.getWorld().playSound(loc, Sound.CLICK, 1F, 10F); 97 | } 98 | } 99 | public void onInteract(final Player p, final Sign s) { 100 | if (s.getLine(0).equalsIgnoreCase("[jackpot]") || s.getLine(0).equalsIgnoreCase("§1§lJACKPOT")) { 101 | s.setLine(0, "§1§lJACKPOT"); 102 | s.setLine(1, "§8-*-"); 103 | s.setLine(2, "§l10.000 Chips"); 104 | s.setLine(3, "Klicke zum Drehen"); 105 | s.update(); 106 | if (player != null) { 107 | if (player.equals(p) == false) { 108 | c.ms.showItemBar(p, "§cJemand anderes ist gerade am Zug."); 109 | p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1F, 1F); 110 | } else { 111 | c.ms.showItemBar(p, "§cWarte bis deine Runde zuende ist."); 112 | } 113 | return; 114 | } else if (c.canBuy(p, 10000, "Glücksrad") == false) { 115 | return; 116 | } 117 | c.getStats().GRAD_GEWINN += 10000; 118 | c.ms.getAnalytics().getAnalytics().addPlayedCasinoGame("Wheel Of Fortune"); 119 | player = p; 120 | running = true; 121 | c.ms.showItemBar(p, "§aEinsatz von §d10.000 Chips §agesetzt."); 122 | loc.getWorld().playSound(loc, Sound.NOTE_PLING, 1F, 1F); 123 | amount = amount + 5000; 124 | new BukkitRunnable() { 125 | @Override 126 | public void run() { 127 | running = false; 128 | winning = true; 129 | if (acircle.get(1).getHelmet().getType() == Material.EMERALD_BLOCK) { 130 | c.getStats().GRAD_VERLUST += amount; 131 | loc.getWorld().playSound(loc, Sound.LEVEL_UP, 1F, 1F); 132 | c.moneyRain(Material.EMERALD, loc.clone(), Material.EMERALD_BLOCK); 133 | c.getStats().GRAD_RUNDEN_GEWONNEN += 1; 134 | if (p.isOnline() && c.inCasino(p)) { 135 | c.addChips(p, amount, "Glücksrad"); 136 | c.broadcast("§5§lMuxCasino>§d " + p.getName() + "§7 gewinnt beim §a§lGlücksrad §7(§d" + c.ms.getNumberFormat(amount) + " Chips§7)!"); 137 | MuxFirework.spawnColor(p.getLocation(), Color.GREEN); 138 | } else { 139 | c.addChipsOffline(p, amount, "Glücksrad"); 140 | } 141 | amount = 50000; 142 | } else { 143 | loc.getWorld().playSound(loc, Sound.NOTE_BASS_GUITAR, 1F, 1F); 144 | if (p.isOnline()) c.ms.showItemBar(p, "§cLeider nicht gewonnen."); 145 | } 146 | new BukkitRunnable() { 147 | @Override public void run() { 148 | winning = false; 149 | player = null; 150 | loc.getWorld().playSound(loc, Sound.NOTE_STICKS, 1F, 1F); 151 | } 152 | }.runTaskLater(c.ms, 20L); 153 | } 154 | }.runTaskLater(c.ms, 20L * (2L + r.nextInt(2) + r.nextInt(3))); 155 | } 156 | } 157 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/events/MuxButton.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.events; 2 | 3 | import me.muxteam.muxsystem.MuxInventory; 4 | import me.muxteam.muxsystem.MuxSystem; 5 | import me.muxteam.muxsystem.MuxUser; 6 | import org.bukkit.Material; 7 | import org.bukkit.Sound; 8 | import org.bukkit.configuration.file.FileConfiguration; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.inventory.ItemStack; 11 | import org.bukkit.scheduler.BukkitRunnable; 12 | 13 | import java.util.HashSet; 14 | import java.util.Set; 15 | import java.util.UUID; 16 | 17 | @NonJoinableEvent 18 | public class MuxButton extends Event { 19 | private int sec, jackpot = 0; 20 | private final Set clicked = new HashSet<>(); 21 | private Player winner = null; 22 | 23 | public MuxButton(final MuxEvents e) { 24 | super(e); 25 | name = "MuxButton"; 26 | item = new ItemStack(Material.SEA_LANTERN); 27 | leaveInventoryOpen = true; 28 | final FileConfiguration hashYML = ms.getHashYAML(); 29 | if (hashYML.contains("eventbutton")) { 30 | jackpot = hashYML.getInt("eventbutton"); 31 | sec = 120; 32 | handleStart(60); 33 | } else { 34 | sec = 60; 35 | } 36 | } 37 | 38 | private void handleStart(final int delay) { 39 | new BukkitRunnable() { 40 | @Override 41 | public void run() { 42 | if (ms.getEvents().startEvent(null, MuxButton.this) == false) { 43 | handleStart(120); 44 | } 45 | } 46 | }.runTaskLater(ms, delay); 47 | } 48 | 49 | @Override 50 | public void stop() { 51 | final int coinswon = jackpot; 52 | if (sec > 0) { 53 | ms.getHashYAML().set("eventbutton", jackpot); 54 | return; 55 | } else { 56 | ms.getHashYAML().set("eventbutton", null); 57 | jackpot = 0; 58 | sec = 60; 59 | } 60 | if (winner == null) return; 61 | else { 62 | ms.broadcastMessage("§d§lMuxEvent>§7 Der Spieler §d" + winner.getName() + " §7hat bei Button §agewonnen§7!", null, MuxSystem.Priority.HIGH); 63 | winner.playSound(winner.getLocation(), Sound.ENDERDRAGON_DEATH, 1F, 0.1F); 64 | final MuxUser u = ms.getMuxUser(winner.getName()); 65 | u.addCoins(coinswon); 66 | ms.getHistory().addHistory(winner.getUniqueId(), null, "COINS", String.valueOf(coinswon), "Event"); 67 | ms.saveMuxUser(u); 68 | ms.sendScoreboard(winner); 69 | winner.sendMessage("§d§lMuxEvent>§7 Dir wurden §e" + ms.getNumberFormat(coinswon) + " MuxCoins §7gutgeschrieben."); 70 | } 71 | winner = null; 72 | } 73 | 74 | @Override 75 | public String[] getDescription() { 76 | return new String[]{ 77 | "§7Sei der Letzte, der den Knopf drückt,", 78 | "§7bevor der Timer abläuft. Man kann ihn", 79 | "§7nur ein einziges Mal drücken.", 80 | "", 81 | "§7Timer: §d" + ms.timeToString(sec * 1000L, false, true), 82 | "§7Letzter Käufer: §d" + (winner == null ? "Keiner" : winner.getName()), 83 | "", 84 | "§7Knopfpreis: §e50 MuxCoins", 85 | "§7Jackpot: §e" + ms.getNumberFormat(jackpot) + " MuxCoins" 86 | }; 87 | } 88 | 89 | @Override 90 | public String getClickToJoin() { 91 | return "§dKlicke§7, um den Knopfdruck zu kaufen."; 92 | } 93 | 94 | @Override 95 | public long getUpdateTime() { 96 | return 20L; 97 | } 98 | 99 | @Override 100 | public void update() { 101 | sec--; 102 | updateItem(); 103 | if (sec == 0) { 104 | stopEvent(true); 105 | } 106 | } 107 | 108 | @Override 109 | public void start() { 110 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 111 | ms.chatClickHoverRun(pl, "§d§lMuxEvent>§7 Das Button Event hat begonnen.", "§d§oKlicke um teilzunehmen", "/event"); 112 | ms.chatClickHoverRun(pl, "§d§lMuxEvent>§7 Klicke §dhier §7um teilzunehmen.", "§d§oKlicke um teilzunehmen", "/event"); 113 | pl.playSound(pl.getLocation(), Sound.NOTE_PLING, 1F, 0.1F); 114 | } 115 | spawnEventNPC("§d§lButton Event"); 116 | } 117 | 118 | @Override 119 | public boolean join(final Player p) { 120 | if (clicked.contains(p.getUniqueId()) && players.contains(p) == false) players.add(p); 121 | final MuxInventory.InvType it = ms.getActiveInv(p.getName()); 122 | if (it != MuxInventory.InvType.EVENT) { 123 | p.performCommand("event"); 124 | return false; 125 | } else if (clicked.contains(p.getUniqueId())) { 126 | ms.showItemBar(p, "§cDu hast den Knopf bereits gedrückt."); 127 | return false; 128 | } else if (ms.hasVoted(p) == false) { 129 | ms.sendNoVoteMessage(p); 130 | return false; 131 | } 132 | final MuxUser u = ms.getMuxUser(p.getName()); 133 | if (u.getCoins() < 50) { 134 | ms.showItemBar(p, "§cDu hast nicht genügend MuxCoins, um den Knopf zu drücken."); 135 | return false; 136 | } 137 | p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1F, 1F); 138 | ms.showItemBar(p, "§fDu hast den §dKnopf §fgedrückt."); 139 | u.addCoins(-50); 140 | clicked.add(p.getUniqueId()); 141 | jackpot += 50; 142 | sec = 60; 143 | winner = p; 144 | updateItem(); 145 | ms.sendScoreboard(p); 146 | return false; 147 | } 148 | 149 | private void updateItem() { 150 | final ItemStack evitem = ms.addLore(ms.renameItemStack(getItem().clone(), "§d§l" + getName(), getDescription()), "", getClickToJoin()); 151 | e.pinv.setItem(13, evitem); 152 | e.opinv.setItem(4, evitem); 153 | } 154 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/events/MuxCustom.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.events; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.Material; 5 | import org.bukkit.Sound; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.block.BlockBreakEvent; 10 | import org.bukkit.event.entity.EntityDamageEvent; 11 | import org.bukkit.event.entity.PlayerDeathEvent; 12 | import org.bukkit.inventory.ItemStack; 13 | import org.bukkit.scheduler.BukkitRunnable; 14 | 15 | public class MuxCustom extends Event implements Listener { 16 | // Ideas: Labyrinth, Wahr Falsch, Climb, Swim fast, Obstacle, Snake, Drop 17 | // Other: Schatzsuche 18 | private Location loc = ms.getGameSpawn().clone(); 19 | 20 | public MuxCustom(final MuxEvents e) { 21 | super(e); 22 | name = "Eigenes Event"; 23 | item = new ItemStack(Material.CAKE); 24 | canMoveItems = true; 25 | maxPlayers = 500; 26 | } 27 | 28 | public void setLoc(final Location l) { 29 | loc = l.clone(); 30 | ms.setLoc("eventspawn", l); 31 | } 32 | 33 | public void toggleKeepInventory() { 34 | keepInventory ^= true; 35 | } 36 | 37 | @Override 38 | public String[] getDescription() { 39 | return new String[]{ 40 | "§7Dies ist ein Event was spontan von", 41 | "§7dem MuxTeam erstellt wurde und", 42 | "§7nicht normal stattfindet.", 43 | "", 44 | "§7Teilnehmer: §d" + players.size() 45 | }; 46 | } 47 | 48 | @Override 49 | public void start() { 50 | final Location l = ms.getLoc("eventspawn"); 51 | if (l != null) loc = l; 52 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 53 | ms.chatClickHoverRun(pl, "§d§lMuxEvent>§7 Das " + name + " §7Event hat begonnen.", "§d§oKlicke um teilzunehmen", "/event join"); 54 | ms.chatClickHoverRun(pl, "§d§lMuxEvent>§7 Klicke §dhier §7um teilzunehmen.", "§d§oKlicke um teilzunehmen", "/event join"); 55 | pl.playSound(pl.getLocation(), Sound.NOTE_PLING, 1F, 0.1F); 56 | } 57 | spawnEventNPC("§d§lEvent beitreten"); 58 | } 59 | 60 | @Override 61 | public boolean join(final Player p) { 62 | equipPlayer(p); 63 | ms.forcePlayer(p, loc.clone().add(0, 4, 0)); 64 | ms.getMounts().deactivateMount(p); 65 | if (keepInventory == false) 66 | p.getInventory().setHelmet(new ItemStack(Material.STAINED_GLASS, 1, (byte) r.nextInt(15))); 67 | p.getInventory().setHeldItemSlot(0); 68 | return true; 69 | } 70 | 71 | @Override 72 | public void quit(final Player p) { 73 | resetPlayer(p); 74 | } 75 | 76 | @EventHandler 77 | public void onDeath(final PlayerDeathEvent e) { 78 | if (players.contains(e.getEntity()) == false) { 79 | return; 80 | } 81 | new BukkitRunnable() { 82 | @Override 83 | public void run() { 84 | quit(e.getEntity()); 85 | } 86 | }.runTaskLater(ms, 5L); 87 | e.getDrops().clear(); 88 | } 89 | 90 | @EventHandler 91 | public void onDamage(final EntityDamageEvent e) { 92 | if (e.getEntity() instanceof Player && players.contains((Player) e.getEntity()) && keepInventory) { 93 | e.setCancelled(true); 94 | e.setDamage(0D); 95 | } 96 | } 97 | 98 | @EventHandler 99 | public void onBreak(final BlockBreakEvent e) { 100 | if (players.contains(e.getPlayer()) == false) { 101 | return; 102 | } 103 | e.setCancelled(true); 104 | } 105 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/events/MuxEXP.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.events; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.Sound; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | @NonJoinableEvent 9 | public class MuxEXP extends Event { 10 | public byte expboost = 0; 11 | private boolean byplayer = false; 12 | 13 | public MuxEXP(final MuxEvents e) { 14 | super(e); 15 | item = new ItemStack(Material.EXP_BOTTLE); 16 | name = ms.getMultiplier(expboost) + " EXP"; 17 | } 18 | 19 | public void setEXPBoost(final byte expboost, final boolean byplayer) { 20 | if (expboost < 0 || expboost > 4) return; 21 | this.expboost = expboost; 22 | name = ms.getMultiplier(ms.getEvents().getExpBoost()) + " EXP"; 23 | this.byplayer = byplayer; 24 | } 25 | 26 | @Override 27 | public void stop() { 28 | expboost = 0; 29 | } 30 | 31 | @Override 32 | public String[] getDescription() { 33 | if (byplayer) { 34 | return new String[]{ 35 | "§7Bei diesem Event wird auf dem Server", 36 | "§7die Anzahl an EXP, die du gewöhnlich", 37 | "§7erhältst, temporär vervielfacht.", 38 | "", 39 | "§dDurch einen Booster derzeit aktiv." 40 | }; 41 | } 42 | return new String[]{ 43 | "§7Bei diesem Event wird auf dem Server", 44 | "§7die Anzahl an EXP, die du gewöhnlich", 45 | "§7erhältst, temporär vervielfacht.", 46 | }; 47 | } 48 | 49 | @Override 50 | public void start() { 51 | if (expboost == 0) setEXPBoost((byte) 1, false); 52 | byplayer = false; 53 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 54 | pl.sendMessage("§d§lMuxEvent>§7 " + getName() + " hat jetzt begonnen."); 55 | pl.playSound(pl.getLocation(), Sound.NOTE_PLING, 1F, 0.1F); 56 | } 57 | spawnEventNPC("§d§lEXP Event Infos"); 58 | } 59 | 60 | @Override 61 | public boolean join(final Player p) { 62 | p.sendMessage("§d§lMuxEvent>§7 Derzeit läuft das §d" + getName() + "§7 Event."); 63 | p.sendMessage("§d§lMuxEvent>§7 Du bekommst §dmehr EXP §7als sonst."); 64 | return false; 65 | } 66 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/events/MuxExit.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.events; 2 | 3 | import me.muxteam.muxsystem.MuxInventory; 4 | import me.muxteam.muxsystem.MuxSystem; 5 | import me.muxteam.muxsystem.MuxUser; 6 | import org.bukkit.Material; 7 | import org.bukkit.Sound; 8 | import org.bukkit.configuration.file.FileConfiguration; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.inventory.ItemStack; 11 | import org.bukkit.scheduler.BukkitRunnable; 12 | 13 | @NonJoinableEvent 14 | public class MuxExit extends Event { 15 | private int sec, jackpot = 0; 16 | private Player winner = null; 17 | 18 | public MuxExit(final MuxEvents e) { 19 | super(e); 20 | name = "MuxExit"; 21 | item = new ItemStack(Material.FIREBALL); 22 | leaveInventoryOpen = true; 23 | final FileConfiguration hashYML = ms.getHashYAML(); 24 | if (hashYML.contains("eventexit")) { 25 | jackpot = hashYML.getInt("eventexit"); 26 | sec = 300; 27 | handleStart(60); 28 | } else { 29 | sec = 3600; 30 | } 31 | } 32 | 33 | private void handleStart(final int delay) { 34 | new BukkitRunnable() { 35 | @Override 36 | public void run() { 37 | if (ms.getEvents().startEvent(null, MuxExit.this) == false) { 38 | handleStart(120); 39 | } 40 | } 41 | }.runTaskLater(ms, delay); 42 | } 43 | 44 | @Override 45 | public void stop() { 46 | final int coinswon = jackpot; 47 | if (sec > 0) { 48 | ms.getHashYAML().set("eventexit", jackpot); 49 | return; 50 | } else { 51 | ms.getHashYAML().set("eventexit", null); 52 | jackpot = 0; 53 | sec = 3600; 54 | } 55 | if (winner == null) return; 56 | else { 57 | ms.broadcastMessage("§d§lMuxEvent>§7 Der Spieler §d" + winner.getName() + " §7hat bei Exit §agewonnen§7!", null, MuxSystem.Priority.HIGH); 58 | winner.playSound(winner.getLocation(), Sound.ENDERDRAGON_DEATH, 1F, 0.1F); 59 | final MuxUser u = ms.getMuxUser(winner.getName()); 60 | u.addCoins(coinswon); 61 | ms.getHistory().addHistory(winner.getUniqueId(), null, "COINS", String.valueOf(coinswon), "Event"); 62 | ms.saveMuxUser(u); 63 | ms.sendScoreboard(winner); 64 | winner.sendMessage("§d§lMuxEvent>§7 Dir wurden §e" + ms.getNumberFormat(coinswon) + " MuxCoins §7gutgeschrieben."); 65 | } 66 | winner = null; 67 | } 68 | 69 | @Override 70 | public String[] getDescription() { 71 | return new String[]{ 72 | "§7Sei der Letzte, der ein Ticket kauft,", 73 | "§7bevor der Timer abläuft. Schaffst", 74 | "§7du das, erhältst du den Jackpot.", 75 | "", 76 | "§7Timer: §d" + ms.timeToString(sec * 1000L, false, true), 77 | "§7Letzter Käufer: §d" + (winner == null ? "Keiner" : winner.getName()), 78 | "", 79 | "§7Ticketpreis: §e50 MuxCoins", 80 | "§7Jackpot: §e" + ms.getNumberFormat(jackpot) + " MuxCoins" 81 | }; 82 | } 83 | 84 | @Override 85 | public String getClickToJoin() { 86 | return "§dKlicke§7, um ein Ticket zu kaufen."; 87 | } 88 | 89 | @Override 90 | public long getUpdateTime() { 91 | return 20L; 92 | } 93 | 94 | @Override 95 | public void update() { 96 | sec--; 97 | updateItem(); 98 | if (sec == 0) { 99 | stopEvent(true); 100 | } 101 | } 102 | 103 | @Override 104 | public void start() { 105 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 106 | ms.chatClickHoverRun(pl, "§d§lMuxEvent>§7 Das Exit Event hat begonnen.", "§d§oKlicke um teilzunehmen", "/event"); 107 | ms.chatClickHoverRun(pl, "§d§lMuxEvent>§7 Klicke §dhier §7um teilzunehmen.", "§d§oKlicke um teilzunehmen", "/event"); 108 | pl.playSound(pl.getLocation(), Sound.NOTE_PLING, 1F, 0.1F); 109 | } 110 | spawnEventNPC("§d§lExit Event"); 111 | } 112 | 113 | @Override 114 | public boolean join(final Player p) { 115 | final MuxInventory.InvType it = ms.getActiveInv(p.getName()); 116 | if (it != MuxInventory.InvType.EVENT) { 117 | p.performCommand("event"); 118 | return false; 119 | } 120 | final MuxUser u = ms.getMuxUser(p.getName()); 121 | if (u.getCoins() < 50) { 122 | ms.showItemBar(p, "§cDu hast nicht genügend MuxCoins, um ein Ticket zu kaufen."); 123 | return false; 124 | } 125 | p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1F, 1F); 126 | ms.showItemBar(p, "§fDu hast ein §dTicket §fgekauft."); 127 | u.addCoins(-50); 128 | jackpot += 50; 129 | sec += 5; 130 | winner = p; 131 | if (sec >= 3600) sec = 3600; 132 | updateItem(); 133 | ms.sendScoreboard(p); 134 | return false; 135 | } 136 | 137 | private void updateItem() { 138 | final ItemStack evitem = ms.addLore(ms.renameItemStack(getItem().clone(), "§d§l" + getName(), getDescription()), "", getClickToJoin()); 139 | e.pinv.setItem(13, evitem); 140 | e.opinv.setItem(4, evitem); 141 | } 142 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/events/MuxFastChat.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.events; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | import org.bukkit.Material; 5 | import org.bukkit.Sound; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.player.AsyncPlayerChatEvent; 10 | import org.bukkit.inventory.ItemStack; 11 | import org.bukkit.scheduler.BukkitRunnable; 12 | 13 | import java.util.Arrays; 14 | import java.util.Collections; 15 | import java.util.List; 16 | import java.util.stream.Collectors; 17 | import java.util.stream.IntStream; 18 | 19 | @NonJoinableEvent 20 | public class MuxFastChat extends Event implements Listener { 21 | private String word; 22 | private long start; 23 | private int num = 0; 24 | 25 | public MuxFastChat(final MuxEvents e) { 26 | super(e); 27 | name = "MuxSchnelltipper"; 28 | item = new ItemStack(Material.PAPER); 29 | chatOnly = true; 30 | } 31 | 32 | @Override 33 | public String[] getDescription() { 34 | return new String[]{ 35 | "§7Halte auf die Nachricht, die im Chat", 36 | "§7angezeigt wird. Gib dann das Wort", 37 | "§7so schnell wie möglich ein.", 38 | }; 39 | } 40 | 41 | @Override 42 | public void start() { 43 | final List words = Arrays.asList("Vogel", "Vulkan", "Liebe", "Tanzen", "Haare", "Glas", "Domino", "Würfel", "Computer", "Bart", "Wind", "Regen", "Minecraft", "MuxCraft", "Kämpfen", "Clown", "Miner", "Creeper", "Ghast", "Spinne", "Roller", "Strand", "Kalt", "Schwanger", "Foto", "Schnell", "Mario", "Luigi", "Schildkröte", "Türknopf", 44 | "Teleskop", "Planet", "Mountain Bike", "Mond", "Komet", "Blume", "Chef", "Elefant", "Shotgun", "Pistole", "James Bond", "Geld", "Salz und Pfeffer", "Hubschrauber", "Luftballon", "Schreien", "Muskel", "Mager", "Zombie", "Lava", "Schlange", "Boot", "Fenster", "Lollipop", "Handschellen", "Polizei", "Uppercut"); 45 | word = words.get(r.nextInt(words.size())); 46 | num = 0; 47 | final String[] chars = {"R", "G", "V", "B", "Z", "A"}; 48 | final String rndchar = chars[r.nextInt(chars.length)]; 49 | final String noise = String.join("", Collections.nCopies(r.nextInt(3) + 1, rndchar)), 50 | noise2 = IntStream.range(0, noise.length()).mapToObj(i -> i == noise.length() - 1 ? noise.substring(i) : noise.charAt(i) + (r.nextInt(10) < 2 ? "§d§0" : "")).collect(Collectors.joining()); 51 | final String secret = word.chars().map(c -> (c >= 0x21 && c <= 0x7E) ? c + 0xFEE0 : c).collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append).toString(); 52 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 53 | ms.chatClickHoverShow(pl, "§d§lMuxEvent>§7 Schnelltipper hat jetzt begonnen.", "§d§0" + noise2 + noise2 + "§d" + secret + "§0" + noise2 + "§d", ""); 54 | ms.chatClickHoverShow(pl, "§d§lMuxEvent>§7 Halte §dhier §7und schreibe §ddas Wort §7im Chat.", "§d§0" + noise2 + noise2 + "§d" + secret + "§0" + noise2 + "§d", ""); 55 | pl.playSound(pl.getLocation(), Sound.NOTE_PLING, 1F, 0.1F); 56 | } 57 | final boolean mute = ms.getChat().isMute1(); 58 | ms.getChat().unmuteEverything(); 59 | start = System.currentTimeMillis(); 60 | new BukkitRunnable() { 61 | @Override 62 | public void run() { 63 | stopEvent(true); 64 | if (mute) ms.getChat().muteEverything(); 65 | } 66 | }.runTaskLater(ms, 200L); 67 | } 68 | 69 | @Override 70 | public boolean join(final Player p) { 71 | p.sendMessage("§d§lMuxEvent>§7 Derzeit läuft das §d" + getName() + "§7 Event."); 72 | p.sendMessage("§d§lMuxEvent>§7 Tippe §ddas Wort §7so schnell wie möglich im Chat."); 73 | return false; 74 | } 75 | 76 | @EventHandler 77 | public void onChat(final AsyncPlayerChatEvent e) { 78 | e.setCancelled(true); 79 | final Player p = e.getPlayer(); 80 | if (e.getMessage().contains(word)) { 81 | if (players.contains(p)) { 82 | return; 83 | } 84 | players.add(p); 85 | num++; 86 | if (startedByPlayer == false) { 87 | final int reward = num == 1 ? 80 : num == 2 ? 40 : num == 3 ? 20 : 5; 88 | p.sendMessage("§d§lMuxEvent>§7 Dir wurden §e" + ms.getNumberFormat(giveReward(p, reward)) + " MuxCoins §7gutgeschrieben."); 89 | new BukkitRunnable() { 90 | @Override public void run() { // To avoid async 91 | ms.sendScoreboard(p); 92 | } 93 | }.runTask(ms); 94 | } 95 | ms.showItemBar(p, "§fDu hast §ddas Wort §frichtig geschrieben. (§d#" + num + "§f)"); 96 | final long time = System.currentTimeMillis() - start; 97 | if (num <= 3) { 98 | final int n = num; 99 | new BukkitRunnable() { 100 | @Override 101 | public void run() { 102 | ms.broadcastMessage("§d§lMuxEvent>§7 Spieler §a#" + n + "§7: §d" + p.getName() + " §7(" + String.valueOf(time / 1000D).replace(".", ",") + " Sekunden)", null, MuxSystem.Priority.HIGH); 103 | } 104 | }.runTaskLater(ms, 200L); 105 | } 106 | } else { 107 | ms.showItemBar(p, "§cFalsche Antwort! Versuche es erneut."); 108 | p.playSound(p.getLocation(), Sound.NOTE_BASS, 1F, 1F); 109 | } 110 | } 111 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/events/MuxGiveAll.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.events; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | import org.bukkit.Material; 5 | import org.bukkit.Sound; 6 | import org.bukkit.configuration.file.FileConfiguration; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.inventory.Inventory; 9 | import org.bukkit.inventory.ItemStack; 10 | import org.bukkit.util.io.BukkitObjectInputStream; 11 | import org.bukkit.util.io.BukkitObjectOutputStream; 12 | import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; 13 | 14 | import java.io.ByteArrayInputStream; 15 | import java.io.ByteArrayOutputStream; 16 | import java.util.ArrayList; 17 | import java.util.Collections; 18 | import java.util.Iterator; 19 | import java.util.List; 20 | 21 | @NonJoinableEvent 22 | public class MuxGiveAll extends Event { 23 | private List items; 24 | private final Inventory inv; 25 | 26 | public MuxGiveAll(final MuxEvents e) { 27 | super(e); 28 | name = "MuxGiveAll"; 29 | item = new ItemStack(Material.PRISMARINE_CRYSTALS); 30 | final FileConfiguration hashYML = ms.getHashYAML(); 31 | if (hashYML.contains("eventgiveall")) { 32 | items = fromBase64(hashYML.getString("eventgiveall")); 33 | } else { 34 | items = new ArrayList<>(); 35 | items.add(new ItemStack(Material.DIRT)); 36 | } 37 | inv = ms.getServer().createInventory(null, 54, "§0§lMuxEvent§0 | GiveAll"); 38 | inv.setItem(0, ms.renameItemStack(new ItemStack(Material.ITEM_FRAME), ms.getLang("back"))); 39 | inv.setItem(4, ms.renameItemStack(getItem(), "§d§l" + getName(), getDescription())); 40 | inv.setItem(6, ms.renameItemStack(new ItemStack(Material.CHEST), "§6§lKisten verteilen", "", "§7Klicke, um eine Kiste §6auszuwählen§7.")); 41 | inv.setItem(8, ms.renameItemStack(new ItemStack(Material.RABBIT_FOOT), "§6§lNächstes Item", "", "§7Klicke, um das nächste Item zu §6verteilen§7.")); 42 | for (int i = 18; i < items.size() + 18; i++) { 43 | inv.setItem(i, items.get(i - 18)); 44 | } 45 | } 46 | 47 | public Inventory getInventory() { 48 | return inv; 49 | } 50 | 51 | public List getItems() { 52 | return items; 53 | } 54 | 55 | public void saveItems(final List items) { 56 | this.items = items; 57 | ms.getHashYAML().set("eventgiveall", toBase64(items)); 58 | } 59 | 60 | public boolean giveItem() { 61 | if (items.isEmpty()) return false; 62 | final Iterator iterator = items.iterator(); 63 | final ItemStack it = iterator.next(); 64 | iterator.remove(); 65 | if (it == null || it.getType() == Material.AIR || it.getType() == Material.MOB_SPAWNER) return true; 66 | final String itemname = it.getType().toString().toLowerCase().replace("_", "").replace("item", ""), 67 | msg = "§a" + it.getAmount() + " " + itemname + " wurde dir ins Inventar hinzugefügt."; 68 | ms.broadcastMessage("§d§lMuxGiveAll>§7 Alle Spieler haben §e" + it.getAmount() + " " + itemname + " §7erhalten.", null, MuxSystem.Priority.HIGH); 69 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 70 | if (ms.hasVoted(pl) == false) { 71 | ms.chatClickHoverRun(pl, "§d§lMuxGiveAll>§7 Klicke §dhier§7, um zu voten und teilzunehmen.", "§d§oKlicke zum voten", "/vote"); 72 | continue; 73 | } 74 | pl.getInventory().addItem(it.clone()); 75 | ms.showItemBar(pl, msg); 76 | } 77 | return true; 78 | } 79 | 80 | private String toBase64(final List items) { 81 | try { 82 | final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 83 | final BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream); 84 | dataOutput.writeInt(items.size()); 85 | for (final ItemStack item : items) { 86 | dataOutput.writeObject(item); 87 | } 88 | dataOutput.close(); 89 | final byte[] b = outputStream.toByteArray(); 90 | outputStream.close(); 91 | return Base64Coder.encodeLines(b); 92 | } catch (final Exception e) { 93 | System.err.println("MuxSystem> Error while saving MuxGiveAll Items."); 94 | e.printStackTrace(); 95 | } 96 | return null; 97 | } 98 | 99 | private List fromBase64(final String data) { 100 | try { 101 | final ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); 102 | final BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); 103 | final List itemstacks = new ArrayList<>(); 104 | final int size = dataInput.readInt(); 105 | for (int i = 0; i < size; i++) { 106 | itemstacks.add((ItemStack) dataInput.readObject()); 107 | } 108 | dataInput.close(); 109 | inputStream.close(); 110 | return itemstacks; 111 | } catch (final Exception e) { 112 | System.err.println("MuxSystem> Error while loading MuxGiveAll Items."); 113 | e.printStackTrace(); 114 | } 115 | return Collections.emptyList(); 116 | } 117 | 118 | @Override 119 | public String[] getDescription() { 120 | return new String[]{ 121 | "§7Verschiedene Items oder Kisten", 122 | "§7werden an alle Spieler verteilt,", 123 | "§7die bereits gevotet haben.", 124 | }; 125 | } 126 | 127 | @Override 128 | public void start() { 129 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 130 | pl.sendMessage("§d§lMuxEvent>§7 GiveAll hat jetzt begonnen."); 131 | if (ms.hasVoted(pl) == false) ms.chatClickHoverRun(pl, "§d§lMuxEvent>§7 Klicke §dhier§7, um zu voten und teilzunehmen.", "§d§oKlicke zum voten", "/vote"); 132 | pl.playSound(pl.getLocation(), Sound.NOTE_PLING, 1F, 0.1F); 133 | } 134 | spawnEventNPC("§d§lEvent Infos"); 135 | } 136 | 137 | @Override 138 | public boolean join(final Player p) { 139 | p.sendMessage("§d§lMuxEvent>§7 Derzeit läuft das §d" + getName() + "§7 Event."); 140 | p.sendMessage("§d§lMuxEvent>§7 Verschiedene Items werden vergeben."); 141 | return false; 142 | } 143 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/events/MuxGuess.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.events; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | import net.md_5.bungee.api.chat.ClickEvent; 5 | import net.md_5.bungee.api.chat.ComponentBuilder; 6 | import net.md_5.bungee.api.chat.HoverEvent; 7 | import net.md_5.bungee.api.chat.TextComponent; 8 | import org.bukkit.Material; 9 | import org.bukkit.Sound; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.inventory.ItemStack; 12 | import org.bukkit.scheduler.BukkitRunnable; 13 | 14 | import java.util.ArrayList; 15 | import java.util.Arrays; 16 | import java.util.List; 17 | 18 | @NonJoinableEvent 19 | public class MuxGuess extends Event { 20 | private String chosen; 21 | private final List guessed = new ArrayList<>(); 22 | private boolean stopped = false; 23 | 24 | public MuxGuess(final MuxEvents e) { 25 | super(e); 26 | name = "MuxRaten"; 27 | item = new ItemStack(Material.NAME_TAG); 28 | chatOnly = true; 29 | } 30 | 31 | @Override 32 | public String[] getDescription() { 33 | return new String[]{ 34 | "§7Errate den richtigen Block zwischen", 35 | "§7den drei Optionen im Chat. Er wurde", 36 | "§7vorher zufällig ausgewählt." 37 | }; 38 | } 39 | 40 | @Override 41 | public String[] getAdminInformation() { 42 | return new String[]{ 43 | "§7Teilnehmer: §d" + guessed.size() 44 | }; 45 | } 46 | 47 | @Override 48 | public void stop() { 49 | stopped = true; 50 | } 51 | 52 | @Override 53 | public void start() { 54 | stopped = false; 55 | guessed.clear(); 56 | final List blocks = new ArrayList<>(Arrays.asList("Stein", "Gras", "Holz", "Kaktus", "Kuchen", "Bett", "Bedrock", "Sand", "Sandstein", 57 | "Glas", "Werkbank", "Ofen", "Diamantblock", "Goldblock", "Eisenblock", "Kohle", "Braustand", "Kies", "Werfer", "Schild", "Spender", "Kiste", 58 | "Wasser", "Lava", "Leiter", "Kessel", "Ton", "Emeraldblock")), chosenblocks = new ArrayList<>(); 59 | for (byte i = 0; i < 3; i++) { 60 | String block = blocks.get(r.nextInt(blocks.size() - 1)); 61 | while (chosenblocks.contains(block)) { 62 | block = blocks.get(r.nextInt(blocks.size() - 1)); 63 | } 64 | chosenblocks.add(block); 65 | } 66 | chosen = chosenblocks.get(r.nextInt(3)); 67 | final TextComponent textComponent = new TextComponent(TextComponent.fromLegacyText("§d§lMuxEvent>§r §7Klicke: ")); 68 | for (final String s : chosenblocks) { 69 | final TextComponent blockComponent = new TextComponent(TextComponent.fromLegacyText("§d" + s + " ")); 70 | blockComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/event action " + s)); 71 | blockComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§d" + s).create())); 72 | textComponent.addExtra(blockComponent); 73 | } 74 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 75 | pl.sendMessage("§d§lMuxEvent>§7 Welcher zufällige Block wurde ausgewählt?"); 76 | pl.spigot().sendMessage(textComponent); 77 | pl.playSound(pl.getLocation(), Sound.NOTE_PLING, 1F, 0.1F); 78 | } 79 | final boolean unmute = ms.getChat().isMute1() == false; 80 | new BukkitRunnable() { 81 | @Override 82 | public void run() { 83 | if (stopped == false) { 84 | finish(unmute); 85 | } 86 | } 87 | }.runTaskLater(ms, 320L); 88 | ms.getChat().muteEverything(); 89 | } 90 | 91 | @Override 92 | public boolean join(final Player p) { 93 | p.sendMessage("§d§lMuxEvent>§7 Derzeit läuft das §d" + getName() + "§7 Event."); 94 | p.sendMessage("§d§lMuxEvent>§7 Errate den §dausgewählten Block§7."); 95 | return false; 96 | } 97 | 98 | @Override 99 | public void action(final Player p, final String[] args) { 100 | final String guess = args[1]; 101 | if (guessed.contains(p)) return; 102 | if (guess.equals(chosen)) { 103 | players.add(p); 104 | } 105 | ms.showItemBar(p, "§fDu hast §d" + args[1] + " §fausgewählt."); 106 | guessed.add(p); 107 | } 108 | 109 | private void finish(boolean unmute) { 110 | ms.broadcastMessage("§d§lMuxEvent>§7 Der ausgewählte Block war...", null, MuxSystem.Priority.NORMAL); 111 | new BukkitRunnable() { 112 | @Override 113 | public void run() { 114 | ms.broadcastMessage("§d§lMuxEvent>§7 " + chosen + "§7! §a" + players.size() + " Spieler lag" + (players.size() == 1 ? "" : "en") + " richtig.", null, MuxSystem.Priority.NORMAL); 115 | for (final Player pl : players) { 116 | if (startedByPlayer == false) { 117 | pl.sendMessage("§d§lMuxEvent>§7 Dir wurden §e" + ms.getNumberFormat(giveReward(pl, 5)) + " MuxCoins §7gutgeschrieben."); 118 | } 119 | ms.sendScoreboard(pl); 120 | } 121 | guessed.clear(); 122 | stopEvent(true); 123 | if (unmute) ms.getChat().unmuteEverything(); 124 | } 125 | }.runTaskLater(ms, 60L); 126 | } 127 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/events/MuxLastChat.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.events; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | import org.bukkit.Material; 5 | import org.bukkit.Sound; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.player.AsyncPlayerChatEvent; 10 | import org.bukkit.inventory.ItemStack; 11 | import org.bukkit.scheduler.BukkitRunnable; 12 | 13 | @NonJoinableEvent 14 | public class MuxLastChat extends Event implements Listener { 15 | private Player last; 16 | 17 | public MuxLastChat(final MuxEvents e) { 18 | super(e); 19 | name = "MuxChatChaos"; 20 | item = new ItemStack(Material.EMPTY_MAP); 21 | } 22 | 23 | @Override 24 | public void stop() { 25 | if (last != null) { 26 | if (startedByPlayer == false) { 27 | last.sendMessage("§d§lMuxEvent>§7 Dir wurden §e" + ms.getNumberFormat(giveReward(last, 100)) + " MuxCoins §7gutgeschrieben."); 28 | } 29 | ms.broadcastMessage("§d§lMuxEvent>§7 Der Spieler §d" + last.getName() + " §7hat §agewonnen§7!", null, MuxSystem.Priority.HIGH); 30 | } 31 | } 32 | 33 | @Override 34 | public String[] getDescription() { 35 | return new String[]{ 36 | "§7Der allerletzte Spieler, der im Chat", 37 | "§7etwas schreibt, gewinnt das Event.", 38 | "§7Spammen erhöht deine Chancen.", 39 | }; 40 | } 41 | 42 | @Override 43 | public void start() { 44 | last = null; 45 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 46 | pl.sendMessage("§d§lMuxEvent>§7 Der globale Chat wird gleich aktiviert."); 47 | pl.sendMessage("§d§lMuxEvent>§7 Sei der §oletzte§7, der §dim Chat schreibt§7."); 48 | pl.playSound(pl.getLocation(), Sound.NOTE_PLING, 1F, 0.1F); 49 | } 50 | final boolean unmute = ms.getChat().isMute1() == false; 51 | new BukkitRunnable() { 52 | @Override 53 | public void run() { 54 | ms.getChat().unmuteEverything(); 55 | ms.runLater(new BukkitRunnable() { 56 | @Override 57 | public void run() { 58 | ms.getChat().muteEverything(); 59 | stopEvent(true); 60 | if (unmute) { 61 | ms.runLater(new BukkitRunnable() { 62 | @Override 63 | public void run() { 64 | ms.getChat().unmuteEverything(); 65 | } 66 | }, 400L); 67 | } 68 | } 69 | }, 20L * (r.nextInt(13) + 3)); 70 | } 71 | }.runTaskLater(ms, 80L); 72 | } 73 | 74 | @Override 75 | public boolean join(final Player p) { 76 | p.sendMessage("§d§lMuxEvent>§7 Derzeit läuft das §d" + getName() + "§7 Event."); 77 | p.sendMessage("§d§lMuxEvent>§7 Sei der §dletzte §7der im Chat schreibt."); 78 | return false; 79 | } 80 | 81 | @EventHandler(ignoreCancelled = true) 82 | public void onChat(final AsyncPlayerChatEvent e) { 83 | if (e.getPlayer().hasPermission("muxsystem.unmutable")) return; 84 | last = e.getPlayer(); 85 | } 86 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/events/MuxLotto.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.events; 2 | 3 | import me.muxteam.basic.ConfirmInventory; 4 | import me.muxteam.basic.MuxActions; 5 | import me.muxteam.muxsystem.MuxSystem; 6 | import me.muxteam.muxsystem.MuxUser; 7 | import org.bukkit.Material; 8 | import org.bukkit.Sound; 9 | import org.bukkit.entity.HumanEntity; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.inventory.ItemStack; 12 | import org.bukkit.scheduler.BukkitRunnable; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | @NonJoinableEvent 18 | public class MuxLotto extends Event { 19 | private int lottocoins = 200; 20 | private long currentEndTime; 21 | 22 | public MuxLotto(final MuxEvents e) { 23 | super(e); 24 | name = "MuxLotto"; 25 | item = new ItemStack(Material.GOLD_INGOT); 26 | chatOnly = true; 27 | } 28 | 29 | @Override 30 | public void stop() { 31 | final List lottos = new ArrayList<>(players); 32 | if (lottos.isEmpty()) return; 33 | ms.broadcastMessage("§d§lMuxEvent>§7 Lotto wird aufgelöst...", null, MuxSystem.Priority.HIGH); 34 | new BukkitRunnable() { 35 | @Override 36 | public void run() { 37 | final int gewinn = lottos.size() * lottocoins; 38 | final Player winner = lottos.get(r.nextInt(lottos.size())); 39 | ms.broadcastMessage("§d§lMuxEvent>§7 Der Spieler §d" + winner.getName() + " §7hat beim Lotto §agewonnen§7!", null, MuxSystem.Priority.HIGH); 40 | final MuxUser u = ms.getMuxUser(winner.getName()); 41 | u.addCoins(gewinn); 42 | ms.getHistory().addHistory(winner.getUniqueId(), null, "COINS", String.valueOf(gewinn), "Event"); 43 | ms.saveMuxUser(u); 44 | ms.sendScoreboard(winner); 45 | winner.sendMessage("§d§lMuxEvent>§7 Dir wurden §e" + ms.getNumberFormat(gewinn) + " MuxCoins §7gutgeschrieben."); 46 | } 47 | }.runTaskLater(ms, 60L); 48 | } 49 | 50 | @Override 51 | public String[] getDescription() { 52 | return new String[]{ 53 | "§7Sobald du ein Lotto-Ticket kaufst, hast", 54 | "§7du die Möglichkeit, den großen Jackpot", 55 | "§7nach der Auflösung zu gewinnen.", 56 | "", 57 | "§7Ticketpreis: §e" + ms.getNumberFormat(lottocoins) + " MuxCoins", 58 | "§7Jackpot: §e" + ms.getNumberFormat(players.size() * (long) lottocoins) + " MuxCoins" 59 | }; 60 | } 61 | 62 | @Override 63 | public String[] getAdminInformation() { 64 | return new String[]{ 65 | "§7Teilnehmer: §d" + players.size() 66 | }; 67 | } 68 | 69 | @Override 70 | public void start() { 71 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 72 | ms.chatClickHoverRun(pl, "§d§lMuxEvent>§7 Lotto hat jetzt begonnen.", "§d§oKlicke um teilzunehmen", "/event join"); 73 | ms.chatClickHoverRun(pl, "§d§lMuxEvent>§7 Klicke §dhier §7um für §e" + ms.getNumberFormat(lottocoins) + " MuxCoins §7teilzunehmen.", "§d§oKlicke um teilzunehmen", "/event join"); 74 | pl.playSound(pl.getLocation(), Sound.NOTE_PLING, 1F, 0.1F); 75 | } 76 | currentEndTime = System.currentTimeMillis() + 10000; 77 | } 78 | 79 | @Override 80 | public void update() { 81 | if (currentEndTime <= System.currentTimeMillis()) { 82 | stopEvent(true); 83 | } 84 | } 85 | 86 | @Override 87 | public long getUpdateTime() { 88 | return 1L; 89 | } 90 | 91 | @Override 92 | public boolean join(final Player p) { 93 | final MuxUser u = ms.getMuxUser(p.getName()); 94 | if (u.getCoins() < lottocoins) { 95 | ms.showItemBar(p, "§cDu hast nicht genügend MuxCoins, um ein Lotto-Ticket zu kaufen."); 96 | return false; 97 | } 98 | final boolean expensive = ((double) lottocoins / (double) u.getCoins()) > 0.10D; 99 | final MuxActions.PlayerAction confirm = player -> { 100 | currentEndTime = System.currentTimeMillis() + 10_000L; 101 | p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1F, 1F); 102 | u.addCoins(-lottocoins); 103 | ms.getHistory().addHistory(p.getUniqueId(), null, "COINS", String.valueOf(-lottocoins), "Event"); 104 | ms.sendScoreboard(p); 105 | if (expensive) { 106 | ms.showItemBar(p, "§fDu nimmst nun am §dEvent §fteil."); 107 | players.add(p); 108 | } 109 | p.closeInventory(); 110 | }, cancel = HumanEntity::closeInventory; 111 | if (expensive) { 112 | new ConfirmInventory(ms, confirm, cancel).show(p, "§0§lLotto Ticket kaufen", "§aBestätigen (" + ms.getNumberFormat(lottocoins) + " MuxCoins)", "§cAbbrechen"); 113 | return false; 114 | } 115 | confirm.call(p); 116 | return true; 117 | } 118 | 119 | public int getCoins() { 120 | return lottocoins; 121 | } 122 | 123 | public void setCoins(final Player p, final String c) { 124 | int coins; 125 | try { 126 | coins = Integer.parseInt(ms.removeNonDigits(c)); 127 | if (coins < 5) coins = 5; 128 | else if (coins > getMaxTicketPrice()) throw new NumberFormatException(); 129 | } catch (final NumberFormatException e) { 130 | ms.showItemBar(p, "§cBitte gebe eine Zahl von 5 bis " + ms.getNumberFormat(getMaxTicketPrice()) + " ein."); 131 | return; 132 | } 133 | lottocoins = coins; 134 | } 135 | private long getMaxTicketPrice() { 136 | final long supply = ms.getActiveMuxCoinsSupply(); 137 | final double percentage = 0.0001D; 138 | long result = (long) Math.ceil((supply * percentage)); 139 | int n = (int) Math.ceil(Math.log10(result + 1D)); 140 | n = Math.max(0, n - 1); 141 | result = (long) Math.ceil(result / Math.pow(10, n)) * (long) Math.pow(10, n); 142 | return Math.max(result, 1000L); 143 | } 144 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/events/MuxRandom.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.events; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | import org.bukkit.Material; 5 | import org.bukkit.Sound; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | import java.util.Collection; 10 | 11 | @NonJoinableEvent 12 | public class MuxRandom extends Event { 13 | private short randomcoins; 14 | public boolean paused = false; 15 | 16 | public MuxRandom(final MuxEvents e) { 17 | super(e); 18 | name = "MuxZufall"; 19 | item = new ItemStack(Material.COMPASS); 20 | } 21 | 22 | private void random() { 23 | final Collection collection = ms.getServer().getOnlinePlayers(); 24 | if (collection.isEmpty()) { 25 | return; 26 | } 27 | final Player p = collection.toArray(new Player[0])[r.nextInt(collection.size())]; 28 | if (p.isOnline() == false) return; 29 | final String name = p.getName(); 30 | if (p.hasPermission("muxsystem.exclude")) { 31 | ms.broadcastMessage("§d§lMuxZufall>§7 " + name + " hätte gewonnen, ist aber ausgeschlossen.", null, MuxSystem.Priority.NORMAL); 32 | return; 33 | } else if (ms.hasVoted(p) == false) { 34 | ms.broadcastMessage("§d§lMuxZufall>§7 " + name + " hätte gewonnen, hat aber nicht gevotet.", null, MuxSystem.Priority.NORMAL); 35 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 36 | if (ms.hasVoted(pl) == false) ms.chatClickHoverRun(pl, "§d§lMuxZufall>§7 Klicke §dhier§7, um zu voten und teilzunehmen.", "§d§oKlicke zum voten", "/vote"); 37 | } 38 | return; 39 | } else if (randomcoins > 0) { 40 | addCoins(p, randomcoins); 41 | p.sendMessage("§d§lMuxEvent>§7 Dir wurden §e" + ms.getNumberFormat(randomcoins) + " MuxCoins §7gutgeschrieben."); 42 | } 43 | ms.broadcastMessage("§d§lMuxZufall>§7 " + name + " hat die Verlosung §agewonnen§7!", null, MuxSystem.Priority.NORMAL); 44 | } 45 | 46 | public void setPaused(final boolean paused) { 47 | this.paused = paused; 48 | } 49 | 50 | public void setCoins(final Player p, final String c) { 51 | short coins; 52 | try { 53 | coins = Short.parseShort(ms.removeNonDigits(c)); 54 | if (coins < 0) coins = 0; 55 | else if (coins > 30000) throw new NumberFormatException(); 56 | } catch (final NumberFormatException e) { 57 | ms.showItemBar(p, "§cBitte gebe eine Zahl von 0 bis 30.000 ein."); 58 | return; 59 | } 60 | randomcoins = coins; 61 | if (randomcoins == 0) { 62 | ms.showItemBar(p, "§cDer Gewinnpreis wurde entfernt."); 63 | } else { 64 | ms.broadcastMessage("§d§lMuxZufall>§7 Der Gewinn wurde auf §e" + randomcoins + " MuxCoins §7gesetzt.", null, MuxSystem.Priority.HIGH); 65 | } 66 | } 67 | 68 | public short getCoins() { 69 | return randomcoins; 70 | } 71 | 72 | @Override 73 | public String[] getDescription() { 74 | return new String[]{ 75 | "§7Der Gewinner wird hier absolut zufällig", 76 | "§7ausgewählt. Vote, um bei der Auslosung", 77 | "§7sofort teilnehmen zu können.", 78 | }; 79 | } 80 | 81 | @Override 82 | public String[] getAdminInformation() { 83 | short notvoted = 0; 84 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 85 | if (ms.hasVoted(pl) == false) { 86 | notvoted++; 87 | } 88 | } 89 | return new String[]{ 90 | "§7MuxCoins gesetzt: §e" + randomcoins, 91 | "§7Nicht gevoted: §d" + notvoted 92 | }; 93 | } 94 | 95 | @Override 96 | public long getUpdateTime() { 97 | return 140L; 98 | } 99 | 100 | @Override 101 | public void update() { 102 | if (paused == false) { 103 | random(); 104 | } 105 | } 106 | 107 | @Override 108 | public void start() { 109 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 110 | ms.chatClickHoverRun(pl, "§d§lMuxEvent>§7 Das Zufall Event hat begonnen.", "§d§oKlicke um teilzunehmen", "/event join"); 111 | ms.chatClickHoverRun(pl, "§d§lMuxEvent>§7 Es werden §dzufällige Spieler §7ausgewählt.", "§d§oKlicke um teilzunehmen", "/event join"); 112 | pl.playSound(pl.getLocation(), Sound.NOTE_PLING, 1F, 0.1F); 113 | } 114 | spawnEventNPC("§d§lEvent Infos"); 115 | } 116 | 117 | @Override 118 | public boolean join(final Player p) { 119 | if (ms.hasVoted(p)) { 120 | ms.showItemBar(p, "§aDu hast bereits gevotet und nimmst somit am Event teil."); 121 | } else { 122 | ms.chatClickHoverLink(p, "§d§lMuxEvent>§7 Vote, um am Event teilzunehmen.", "§d§oKlicke um zu voten", "https://muxcraft.eu/vote/?ign=" + p.getName()); 123 | ms.chatClickHoverLink(p, "§d§lMuxEvent>§7 Klicke §dhier§7, um zu voten.", "§d§oKlicke um zu voten", "https://muxcraft.eu/vote/?ign=" + p.getName()); 124 | } 125 | return false; 126 | } 127 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/events/NonJoinableEvent.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.events; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.TYPE) 10 | public @interface NonJoinableEvent { 11 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/events/SearchEventUser.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.events; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | 6 | public class SearchEventUser { 7 | private final UUID uuid; 8 | private short count, coinscount; 9 | private final List found, coinsfound; 10 | 11 | public SearchEventUser(final UUID uuid, final List found, final List coinsfound) { 12 | this.uuid = uuid; 13 | this.found = found; 14 | this.coinsfound = coinsfound; 15 | this.count = (short) found.size(); 16 | this.coinscount = (short) coinsfound.size(); 17 | } 18 | public UUID getUUID() { 19 | return uuid; 20 | } 21 | public short getScore() { 22 | return count; 23 | } 24 | public List getFound() { 25 | return found; 26 | } 27 | public void addFound(final short id) { 28 | found.add(id); 29 | count++; 30 | } 31 | public List getCoinsFound() { 32 | return coinsfound; 33 | } 34 | public void addCoinFound(final short id) { 35 | coinsfound.add(id); 36 | coinscount++; 37 | } 38 | public short getCoinScore() { 39 | return coinscount; 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/extras/MuxBigEnderChest.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.extras; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | import org.bukkit.OfflinePlayer; 5 | import org.bukkit.Sound; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.inventory.Inventory; 8 | import org.bukkit.inventory.ItemStack; 9 | import org.bukkit.util.io.BukkitObjectInputStream; 10 | import org.bukkit.util.io.BukkitObjectOutputStream; 11 | import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; 12 | 13 | import java.io.ByteArrayInputStream; 14 | import java.io.ByteArrayOutputStream; 15 | import java.util.UUID; 16 | 17 | public final class MuxBigEnderChest { 18 | private MuxSystem ms; 19 | private MuxExtras extras; 20 | 21 | public MuxBigEnderChest(final MuxSystem ms) { 22 | this.ms = ms; 23 | this.extras = ms.getExtras(); 24 | } 25 | 26 | public void close() { 27 | this.extras = null; 28 | this.ms = null; 29 | } 30 | public boolean openExtraEnderChest(final Player p, final boolean sound) { 31 | if (extras.hasExtraEnderChest(p.getUniqueId())) { 32 | if (ms.getInv().isBeingEdited(p, false)) { 33 | ms.showItemBar(p, "§cBitte warte etwas."); 34 | return true; 35 | } 36 | p.closeInventory(); 37 | String enderchest = ms.getDB().loadEnderChest(p.getUniqueId()); 38 | if (enderchest == null) { 39 | createAccount(p.getUniqueId()); 40 | enderchest = toBase64(p.getEnderChest()); 41 | } else if (enderchest.equals("error")) { 42 | return true; 43 | } 44 | if (sound) p.playSound(p.getLocation(), Sound.CHEST_OPEN, 1F, 1F); 45 | p.openInventory(getInventory(p, enderchest)); 46 | return true; 47 | } 48 | return false; 49 | } 50 | public void handleClose(final Player p, final Inventory inv) { 51 | if (inv.getHolder() != null && inv.getHolder().equals(p)) { 52 | p.playSound(p.getLocation(), Sound.CHEST_CLOSE, 1F, 1F); 53 | ms.getDB().saveEnderChest(p.getUniqueId(), p.getName(), toBase64(inv)); 54 | } 55 | } 56 | public Inventory getInventory(final OfflinePlayer p, final String enderchest) { 57 | final Inventory inv = ms.getServer().createInventory(p.isOnline() ? p.getPlayer() : null , 54, ms.getLang("extraenderchest")), mysqlInv = fromBase64(enderchest); 58 | if (mysqlInv == null) { 59 | return null; 60 | } else for (int i = 0; i < mysqlInv.getSize(); i++) { 61 | inv.setItem(i, mysqlInv.getItem(i)); 62 | } 63 | return inv; 64 | } 65 | public void setEnderchest(final Player p, final UUID uuid, final String name, final Inventory inv) { 66 | p.playSound(p.getLocation(), Sound.CHEST_CLOSE, 1F, 1F); 67 | ms.getDB().saveEnderChest(uuid, name, toBase64(inv)); 68 | } 69 | public void createAccount(final UUID uuid) { 70 | final Player p = ms.getServer().getPlayer(uuid); 71 | ms.getDB().saveEnderChest(uuid, p.getName(), toBase64(p.getEnderChest())); 72 | } 73 | private String toBase64(final Inventory inventory) { 74 | try { 75 | final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 76 | final BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream); 77 | dataOutput.writeInt(inventory.getSize()); 78 | for (int i = 0; i < inventory.getSize(); i++) { 79 | dataOutput.writeObject(inventory.getItem(i)); 80 | } 81 | dataOutput.close(); 82 | final byte[] b = outputStream.toByteArray(); 83 | outputStream.close(); 84 | return Base64Coder.encodeLines(b); 85 | } catch (final Exception e) { 86 | System.err.println("MuxSystem> Error while saving a MuxBigEnderChest."); 87 | e.printStackTrace(); 88 | } 89 | return null; 90 | } 91 | private Inventory fromBase64(final String data) { 92 | try { 93 | final ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); 94 | final BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream); 95 | final Inventory inventory = ms.getServer().createInventory(null, dataInput.readInt()); 96 | for (int i = 0; i < inventory.getSize(); i++) { 97 | inventory.setItem(i, (ItemStack) dataInput.readObject()); 98 | } 99 | dataInput.close(); 100 | inputStream.close(); 101 | return inventory; 102 | } catch (final Exception e) { 103 | System.err.println("MuxSystem> Error while loading a MuxBigEnderChest."); 104 | e.printStackTrace(); 105 | } 106 | return null; 107 | } 108 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/extras/MuxChestUser.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.extras; 2 | 3 | import me.muxteam.extras.MuxChests.ChestType; 4 | 5 | import java.util.List; 6 | import java.util.UUID; 7 | 8 | public final class MuxChestUser { 9 | private final UUID uuid; 10 | private final List chests; 11 | private boolean changed, daily; 12 | 13 | public MuxChestUser(final UUID uuid, final List chests, final boolean daily) { 14 | this.uuid = uuid; 15 | this.chests = chests; 16 | this.daily = daily; 17 | } 18 | 19 | public UUID getUUID() { 20 | return uuid; 21 | } 22 | 23 | public boolean hasChanged() { 24 | return changed; 25 | } 26 | 27 | public void saved() { 28 | this.changed = false; 29 | } 30 | 31 | public List getChests() { 32 | return chests; 33 | } 34 | 35 | public void addChest(final ChestType type) { 36 | addChest(type, false); 37 | } 38 | 39 | public void addChest(final ChestType type, final boolean bypass) { 40 | if (chests.size() >= 10 && bypass == false) return; 41 | chests.add(type); 42 | this.changed = true; 43 | } 44 | 45 | public void removeChest(final int pos) { 46 | chests.remove(pos); 47 | this.changed = true; 48 | } 49 | 50 | public boolean getDaily() { 51 | return daily; 52 | } 53 | 54 | public void setDaily(final boolean daily) { 55 | this.daily = daily; 56 | } 57 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/extras/MuxExtraUser.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.extras; 2 | 3 | import me.muxteam.extras.MuxMounts.MountStore; 4 | import me.muxteam.extras.MuxPerks.PerkStore; 5 | import me.muxteam.extras.MuxPets.PetStore; 6 | 7 | import java.util.Set; 8 | import java.util.UUID; 9 | 10 | public final class MuxExtraUser { 11 | private final UUID uuid; 12 | private String name; 13 | private PerkStore perks; 14 | private MountStore mounts; 15 | private PetStore pets; 16 | private Set extracmds; 17 | private Set emojis; 18 | private byte enderchest; 19 | private boolean changed = false; 20 | 21 | public MuxExtraUser(final UUID uuid, final String name, final PerkStore perks, final MountStore mounts, final PetStore pets, 22 | final Set extracmds, final Set emojis, final byte enderchest) { 23 | this.uuid = uuid; 24 | this.name = name; 25 | this.perks = perks; 26 | this.mounts = mounts; 27 | this.pets = pets; 28 | this.extracmds = extracmds; 29 | this.emojis = emojis; 30 | this.enderchest = enderchest; 31 | } 32 | 33 | public UUID getUUID() { 34 | return uuid; 35 | } 36 | public String getName() { 37 | return name; 38 | } 39 | public void setName(final String name) { 40 | if (this.name.equals(name) == false) { 41 | this.name = name; 42 | this.changed = true; 43 | } 44 | } 45 | public boolean hasChanged() { 46 | return changed; 47 | } 48 | public void saved() { 49 | this.changed = false; 50 | } 51 | public PerkStore getPerks() { 52 | return perks; 53 | } 54 | public void setPerks(final PerkStore perks) { 55 | this.perks = perks; 56 | this.changed = true; 57 | } 58 | public Set getExtraCMDs() { 59 | return extracmds; 60 | } 61 | public void setExtraCMDs(final Set extracmds) { 62 | this.extracmds = extracmds; 63 | this.changed = true; 64 | } 65 | public PetStore getPets() { 66 | return pets; 67 | } 68 | public void setPets(final PetStore pets) { 69 | this.pets = pets; 70 | this.changed = true; 71 | } 72 | 73 | public MountStore getMounts() { 74 | return mounts; 75 | } 76 | public void setMounts(final MountStore mounts) { 77 | this.mounts = mounts; 78 | this.changed = true; 79 | } 80 | public Set getEmojis() { 81 | return emojis; 82 | } 83 | public void setEmojis(final Set emojis) { 84 | this.emojis = emojis; 85 | this.changed = true; 86 | } 87 | public byte getEnderChest() { 88 | return enderchest; 89 | } 90 | public void setEnderChest(final byte enderchest) { 91 | this.enderchest = enderchest; 92 | this.changed = true; 93 | } 94 | public void setChanged(boolean changed) { 95 | this.changed = changed; 96 | } 97 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/extras/MuxPerks.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.extras; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | import org.bukkit.Material; 5 | import org.bukkit.Sound; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.block.BlockBreakEvent; 10 | import org.bukkit.potion.PotionEffect; 11 | import org.bukkit.potion.PotionEffectType; 12 | import org.bukkit.scheduler.BukkitRunnable; 13 | 14 | import java.util.HashSet; 15 | import java.util.Set; 16 | 17 | public class MuxPerks implements Listener { 18 | private MuxSystem ms; 19 | private final Set nohunger = new HashSet<>(), doubleexp = new HashSet<>(), antipoison = new HashSet<>(), 20 | noweakness = new HashSet<>(); 21 | private final Set fastbreaklimit = new HashSet<>(); 22 | 23 | public MuxPerks(final MuxSystem ms) { 24 | this.ms = ms; 25 | ms.getServer().getPluginManager().registerEvents(this, ms); 26 | } 27 | public void close() { 28 | this.ms = null; 29 | } 30 | public boolean hasNoHunger(final String pname) { 31 | return nohunger.contains(pname); 32 | } 33 | public boolean hasDoubleEXP(final String pname) { 34 | return doubleexp.contains(pname); 35 | } 36 | public boolean hasAntiPoison(final String pname) { 37 | return antipoison.contains(pname); 38 | } 39 | public boolean hasNoWeakness(final String pname) { 40 | return noweakness.contains(pname); 41 | } 42 | public void deactivatePerks(final String pname) { 43 | nohunger.remove(pname); 44 | doubleexp.remove(pname); 45 | noweakness.remove(pname); 46 | antipoison.remove(pname); 47 | } 48 | public void activatePerks(final Player p) { 49 | activatePerks(p, true); 50 | } 51 | public void activatePerks(final Player p, final boolean delay) { 52 | try { 53 | final MuxExtraUser eu = ms.getExtras().getExtraUser(p.getUniqueId()); 54 | final PerkStore ps = eu.getPerks(); 55 | if (ps != null && ps.getActive().isEmpty() == false) { 56 | if (delay == false) { 57 | final Set active = ps.getActive(); 58 | active.forEach(b -> activatePerk(p, b)); 59 | return; 60 | } 61 | new BukkitRunnable() { 62 | final Set active = ps.getActive(); 63 | @Override public void run() { 64 | active.forEach(b -> activatePerk(p, b)); 65 | } 66 | }.runTaskLater(ms, 0L); 67 | } 68 | } catch (final Exception ex) { 69 | ex.printStackTrace(); 70 | } 71 | } 72 | public void activatePerk(final Player p, final byte b) { 73 | switch (b) { 74 | case 1: nohunger.add(p.getName()); p.setFoodLevel(20); break; 75 | case 2: p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 9999999, 1)); break; 76 | case 3: p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 9999999, 0)); break; 77 | case 4: p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 9999999, 1)); break; 78 | case 5: doubleexp.add(p.getName()); break; 79 | case 6: p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 9999999, 0)); break; 80 | case 7: p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 9999999, 1)); break; 81 | case 8: antipoison.add(p.getName()); break; 82 | case 9: p.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 9999999, 1)); break; 83 | case 10: noweakness.add(p.getName()); break; 84 | default: break; 85 | } 86 | } 87 | public void removeActivePerk(final Player p, final byte b) { 88 | switch (b) { 89 | case 1: 90 | nohunger.remove(p.getName()); 91 | break; 92 | case 2: 93 | p.removePotionEffect(PotionEffectType.JUMP); 94 | break; 95 | case 3: 96 | p.removePotionEffect(PotionEffectType.FIRE_RESISTANCE); 97 | break; 98 | case 4: 99 | p.removePotionEffect(PotionEffectType.SPEED); 100 | break; 101 | case 5: 102 | doubleexp.remove(p.getName()); 103 | break; 104 | case 6: 105 | p.removePotionEffect(PotionEffectType.NIGHT_VISION); 106 | break; 107 | case 7: 108 | p.removePotionEffect(PotionEffectType.INCREASE_DAMAGE); 109 | break; 110 | case 8: 111 | antipoison.remove(p.getName()); 112 | break; 113 | case 9: 114 | p.removePotionEffect(PotionEffectType.FAST_DIGGING); 115 | break; 116 | case 10: 117 | noweakness.remove(p.getName()); 118 | break; 119 | default: 120 | break; 121 | } 122 | } 123 | public String getPerkName(final byte b) { 124 | switch (b) { 125 | case 1: return "No Hunger"; 126 | case 2: return "High Jump"; 127 | case 3: return "Anti Fire"; 128 | case 4: return "Runner"; 129 | case 5: return ms.getMultiplier(1 + ms.getEvents().getExpBoost()) + " EXP"; 130 | case 6: return "Night Vision"; 131 | case 7: return "Power"; 132 | case 8: return "Anti Poison"; 133 | case 9: return "Fast Break"; 134 | case 10: return "No Weakness"; 135 | default: return "Unbekannt"; 136 | } 137 | } 138 | public byte getPerkFromMaterial(final Material m) { 139 | switch (m) { 140 | case APPLE: return 1; 141 | case HOPPER: return 2; 142 | case MAGMA_CREAM: return 3; 143 | case DIAMOND_BOOTS: return 4; 144 | case EXP_BOTTLE: return 5; 145 | case EYE_OF_ENDER: return 6; 146 | case FIREBALL: return 7; 147 | case INK_SACK: return 8; 148 | case DIAMOND_PICKAXE: return 9; 149 | case FERMENTED_SPIDER_EYE: return 10; 150 | default: return -1; 151 | } 152 | } 153 | @EventHandler 154 | public void onBreak(final BlockBreakEvent e) { 155 | final Player p = e.getPlayer(); 156 | final Material m = e.getBlock().getType(); 157 | if (m == Material.DIAMOND_ORE || m == Material.GOLD_ORE || m == Material.IRON_ORE || m == Material.EMERALD_ORE || m == Material.QUARTZ_ORE) { 158 | final MuxExtraUser eu = ms.getExtras().getExtraUser(p.getUniqueId()); 159 | final boolean hasfastbreak = eu.getPerks().getActive().contains((byte) 9); 160 | if (hasfastbreak && ms.checkLimit(p.getName(), "FASTBREAKMINE", 850, true)) { 161 | fastbreaklimit.add(p.getName()); 162 | final PerkStore es = eu.getPerks(); 163 | es.remActive((byte) 9); 164 | eu.setPerks(es); 165 | p.playSound(p.getLocation(), Sound.ANVIL_BREAK, 1F, 1F); 166 | removeActivePerk(p, (byte) 9); 167 | } 168 | } 169 | } 170 | public boolean hasFastBreakBlock(final String pname) { 171 | return fastbreaklimit.contains(pname); 172 | } 173 | public final class PerkStore { 174 | private final Set active, owned; 175 | 176 | public PerkStore(final Set active, final Set owned) { 177 | this.active = active; 178 | this.owned = owned; 179 | } 180 | 181 | public Set getActive() { 182 | return active; 183 | } 184 | public void addActive(final byte active) { 185 | this.active.add(active); 186 | } 187 | public void remActive(final Byte active) { 188 | this.active.remove(active); 189 | } 190 | public Set getOwned() { 191 | return owned; 192 | } 193 | public void addOwned(final byte perk) { 194 | owned.add(perk); 195 | } 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /src/main/java/me/muxteam/holidays/MuxBirthday.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.holidays; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | 5 | public class MuxBirthday implements MuxHoliday { 6 | public MuxBirthday(final MuxSystem ms) {} 7 | 8 | @Override 9 | public void close() {} 10 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/holidays/MuxChristmas.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.holidays; 2 | 3 | import me.muxteam.basic.NMSReflection; 4 | import me.muxteam.muxsystem.MuxSystem; 5 | import net.minecraft.server.v1_8_R3.EntityVillager; 6 | import org.bukkit.Effect; 7 | import org.bukkit.Location; 8 | import org.bukkit.Material; 9 | import org.bukkit.Sound; 10 | import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; 11 | import org.bukkit.entity.ArmorStand; 12 | import org.bukkit.entity.EntityType; 13 | import org.bukkit.entity.Villager; 14 | import org.bukkit.event.EventHandler; 15 | import org.bukkit.event.Listener; 16 | import org.bukkit.event.player.PlayerInteractAtEntityEvent; 17 | import org.bukkit.inventory.ItemStack; 18 | import org.bukkit.potion.PotionEffect; 19 | import org.bukkit.potion.PotionEffectType; 20 | import org.bukkit.scheduler.BukkitRunnable; 21 | import org.bukkit.util.Vector; 22 | 23 | import java.util.ArrayList; 24 | import java.util.HashMap; 25 | import java.util.Map; 26 | import java.util.Random; 27 | import java.util.concurrent.CopyOnWriteArrayList; 28 | 29 | public final class MuxChristmas implements Listener, MuxHoliday { 30 | private MuxSystem ms; 31 | 32 | private final CopyOnWriteArrayList pinguin = new CopyOnWriteArrayList<>(); 33 | private final Map> elements = new HashMap<>(); 34 | private final Random r = new Random(); 35 | 36 | public MuxChristmas(final MuxSystem ms, boolean fake) { 37 | if (fake) return; 38 | this.ms = ms; 39 | new BukkitRunnable() { 40 | final Location spawn = ms.getGameSpawn(); 41 | 42 | @Override 43 | public void run() { 44 | short living = 0; 45 | for (final Villager e : pinguin) 46 | if (e.isDead() || e.isValid() == false) { 47 | remove(e); 48 | } else if (e.getWorld() != spawn.getWorld() || e.getLocation().distance(spawn) >= 45.0D) { 49 | remove(e); 50 | e.getWorld().playEffect(e.getLocation(), Effect.SNOWBALL_BREAK, 0); 51 | } else { 52 | onMove(e); 53 | living = (short) (living + 1); 54 | } 55 | for (short i = (short) (15 - living); i > 0; i = (short) (i - 1)) { 56 | spawnMob(spawn.clone().add((17 + r.nextInt(8)) * (r.nextBoolean() ? -1D : 1D), 0.0D, (17 + r.nextInt(8)) * (r.nextBoolean() ? -1D : 1D))); 57 | } 58 | } 59 | }.runTaskTimer(ms, 20L, 100L); 60 | new BukkitRunnable() { 61 | @Override 62 | public void run() { 63 | onUpdate(); 64 | } 65 | }.runTaskTimer(ms, 100L, 2L); 66 | ms.getServer().getPluginManager().registerEvents(this, ms); 67 | } 68 | 69 | @Override 70 | public void close() { 71 | removeAll(); 72 | this.ms = null; 73 | } 74 | 75 | @EventHandler 76 | public void onInteract(final PlayerInteractAtEntityEvent e) { 77 | if (e.getRightClicked().getType() == EntityType.ARMOR_STAND) { 78 | final ArmorStand a = (ArmorStand) e.getRightClicked(); 79 | if (a.isVisible() == false && a.getEquipment().getHelmet() != null && (a.getEquipment().getHelmet().getType() == Material.WOOL || a.getEquipment().getHelmet().getType() == Material.SNOW_BLOCK || a.getEquipment().getHelmet().getType() == Material.SKULL_ITEM)) { 80 | e.getPlayer().playSound(a.getLocation(), Sound.CAT_HISS, 0.1F, 1F); 81 | a.getWorld().playEffect(a.getLocation().clone().add(0, 1.1D, 0), Effect.HEART, 20); 82 | } 83 | } 84 | } 85 | 86 | private void spawnMob(final Location l) { 87 | final Villager z = l.getWorld().spawn(l, Villager.class); 88 | z.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 9999999, 1, false, false)); 89 | z.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1, false, false)); 90 | z.setAge(-24000); 91 | z.setAgeLock(true); 92 | z.setMaxHealth(2048.0D); 93 | z.setHealth(2048.0D); 94 | z.setCanPickupItems(false); 95 | z.setRemoveWhenFarAway(false); 96 | ms.removeSounds(z); 97 | final net.minecraft.server.v1_8_R3.Entity nms = ((CraftEntity) z).getHandle(); 98 | ((EntityVillager) nms).persistent = true; 99 | NMSReflection.setObject(net.minecraft.server.v1_8_R3.Entity.class, "invulnerable", nms, true); 100 | spawn(z); 101 | } 102 | 103 | private void spawn(final Villager z) { 104 | pinguin.add(z); 105 | final ItemStack skull1 = ms.getHead("Penguin"); 106 | 107 | final ArrayList list = new ArrayList<>(); 108 | for (int i = 0; i <= 5; i++) { 109 | final ArmorStand a1 = (ArmorStand) z.getWorld().spawnEntity(z.getLocation().add(0.0D, -1.25D, 0.0D), EntityType.ARMOR_STAND); 110 | if (i == 1) { 111 | a1.setHelmet(new ItemStack(Material.WOOL, 1, (byte) 15)); 112 | } 113 | if (i == 2) { 114 | a1.setHelmet(new ItemStack(Material.SNOW_BLOCK)); 115 | } 116 | if (i == 3) { 117 | a1.setItemInHand(new ItemStack(Material.STONE_SLAB2)); 118 | } 119 | if (i == 4) { 120 | a1.setItemInHand(new ItemStack(Material.STONE_SLAB2)); 121 | } 122 | if (i != 1) { 123 | a1.setSmall(true); 124 | } 125 | a1.setGravity(false); 126 | if (i == 0) { 127 | a1.setHelmet(skull1); 128 | } 129 | a1.setVisible(false); 130 | a1.setMarker(false); 131 | 132 | list.add(a1); 133 | } 134 | elements.put(z, list); 135 | } 136 | 137 | private void remove(final Villager z) { 138 | if (pinguin.contains(z)) { 139 | pinguin.remove(z); 140 | final ArrayList list = elements.get(z); 141 | for (final ArmorStand a : list) { 142 | a.remove(); 143 | } 144 | elements.remove(z); 145 | z.remove(); 146 | } 147 | } 148 | 149 | private void onMove(final Villager s) { 150 | if (pinguin.contains(s) && elements.containsKey(s)) { 151 | final ArmorStand head = elements.get(s).get(0), bauch = elements.get(s).get(1), 152 | bauchmitte = elements.get(s).get(2), foot1 = elements.get(s).get(3), foot2 = elements.get(s).get(4); 153 | 154 | head.teleport(s.getLocation().add(0.0D, -0.01D, 0.0D)); 155 | head.getLocation().setDirection(s.getLocation().getDirection()); 156 | 157 | final Vector v = head.getLocation().getDirection().clone(); 158 | final Location loc = s.getLocation().clone(); 159 | bauch.teleport(s.getLocation().clone().add(0.0D, -1.25D, 0.0D)); 160 | bauchmitte.teleport(loc.clone().add(v.getX() * 0.2D, -0.4D, v.getZ() * 0.2D)); 161 | 162 | final Location loci = loc.clone().add(v.getX() * 0.2D, -0.35D, v.getZ() * 0.2D); 163 | loci.setYaw(loc.getYaw() - 90.0F); 164 | foot1.teleport(loci); 165 | foot2.teleport(loc.clone().add(v.getX() * 0.2D, -0.35D, v.getZ() * 0.2D)); 166 | } 167 | } 168 | 169 | private void onUpdate() { 170 | for (final Villager z : pinguin) { 171 | if (z == null || z.isDead()) { 172 | remove(z); 173 | } 174 | onMove(z); 175 | } 176 | } 177 | 178 | private void removeAll() { 179 | for (final Villager z : pinguin) { 180 | remove(z); 181 | } 182 | } 183 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/holidays/MuxEaster.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.holidays; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | 5 | public class MuxEaster implements MuxHoliday { 6 | public MuxEaster(final MuxSystem ms) {} 7 | 8 | @Override 9 | public void close() {} 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/me/muxteam/holidays/MuxHoliday.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.holidays; 2 | 3 | public interface MuxHoliday { 4 | void close(); 5 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/holidays/MuxSummer.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.holidays; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | 5 | public class MuxSummer implements MuxHoliday { 6 | public MuxSummer(final MuxSystem ms) {} 7 | 8 | @Override 9 | public void close() {} 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/me/muxteam/muxsystem/Settings.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.muxsystem; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | import java.util.UUID; 6 | 7 | public class Settings { 8 | private int entrycost, heals = 4, ops = 8, activepage; 9 | private boolean bodyfix = true, verified = false, menu = true, music = true, blood = true, chatfilter = true, sortfriendstrophies = false; 10 | private final Set friendalert = new HashSet<>(); 11 | 12 | public Settings() {} 13 | public int getEntryCost() { 14 | return entrycost; 15 | } 16 | public boolean hasBodyFix() { 17 | return bodyfix; 18 | } 19 | public int getOPs() { 20 | return ops; 21 | } 22 | public int getHeals() { return heals; } 23 | public boolean needsVerified() { return verified; } 24 | public int getActivePage() { 25 | return activepage; 26 | } 27 | public void setEntryCost(final int entrycost) { 28 | this.entrycost = entrycost; 29 | } 30 | public void setBodyFix(final boolean bodyfix) { 31 | this.bodyfix = bodyfix; 32 | } 33 | public void setOPs(final int ops) { 34 | this.ops = ops; 35 | } 36 | public void setHeals(final int heals) { this.heals = heals; } 37 | public void setVerified(final boolean verified) { this.verified = verified; } 38 | public Set getAlertFriends() { 39 | return friendalert; 40 | } 41 | public boolean hasMenu() { 42 | return menu; 43 | } 44 | public void setMenu(final boolean menu) { 45 | this.menu = menu; 46 | } 47 | public boolean hasMusic() { 48 | return music; 49 | } 50 | public void setMusic(final boolean music) { 51 | this.music = music; 52 | } 53 | public boolean hasBloodEffect() { 54 | return blood; 55 | } 56 | public void setBlood(final boolean blood) { 57 | this.blood = blood; 58 | } 59 | public void setActivePage(final int activepage) { 60 | this.activepage = activepage; 61 | } 62 | public void setShowFriendsByTrophies(boolean sortfriendstrophies) { 63 | this.sortfriendstrophies = sortfriendstrophies; 64 | } 65 | public boolean showFriendsByTrophies() { 66 | return sortfriendstrophies; 67 | } 68 | public boolean hasChatFilter() { 69 | return chatfilter; 70 | } 71 | public void setChatFilter(boolean chatfilter) { 72 | this.chatfilter = chatfilter; 73 | } 74 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/muxteam/BanEntry.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.muxteam; 2 | 3 | import java.util.UUID; 4 | 5 | public final class BanEntry { 6 | private final int id; 7 | private final UUID uuid; 8 | private final String name, action, extrainfo, reason, time, causer, removecauser, removetime, unformattedTime; 9 | 10 | public BanEntry(final int id, final UUID uuid, final String name, final String action, final String extrainfo, final String reason, final String time, final String causer, 11 | final String removecauser, String removetime, String unformattedTime) { 12 | this.id = id; 13 | this.uuid = uuid; 14 | this.name = name; 15 | this.action = action; 16 | this.extrainfo = extrainfo; 17 | this.reason = reason; 18 | this.time = time; 19 | this.causer = causer; 20 | this.removecauser = removecauser; 21 | this.removetime = removetime; 22 | this.unformattedTime = unformattedTime; 23 | } 24 | 25 | public int getID() { 26 | return id; 27 | } 28 | public UUID getUUID() { 29 | return uuid; 30 | } 31 | public String getName() { 32 | return name; 33 | } 34 | public String getAction() { 35 | return action; 36 | } 37 | public String getExtraInfo() { 38 | return extrainfo; 39 | } 40 | public String getTime() { 41 | return time; 42 | } 43 | public String getUnformattedTime() { 44 | return unformattedTime; 45 | } 46 | public String getReason() { 47 | return reason; 48 | } 49 | public String getCauser() { 50 | return causer; 51 | } 52 | public String getRemoveCauser() { 53 | return removecauser; 54 | } 55 | public String getRemoveTime() { 56 | return removetime; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/me/muxteam/muxteam/MuxAnalytics.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.muxteam; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | import me.muxteam.muxsystem.MuxUser; 5 | import org.bukkit.configuration.file.FileConfiguration; 6 | import org.bukkit.entity.Player; 7 | 8 | import java.util.Calendar; 9 | import java.util.HashSet; 10 | import java.util.TimeZone; 11 | import java.util.TreeMap; 12 | 13 | public class MuxAnalytics { 14 | private MuxSystem ms; 15 | private Analytics analytics; 16 | 17 | public MuxAnalytics(final MuxSystem ms) { 18 | this.ms = ms; 19 | analytics = loadAnalytics(Calendar.getInstance(TimeZone.getTimeZone("CET")).get(Calendar.DAY_OF_YEAR)); 20 | load(); 21 | } 22 | public void close() { 23 | saveTodayAnalytics(false); 24 | save(); 25 | this.ms = null; 26 | } 27 | private void load() { 28 | final FileConfiguration cfg = ms.getConfig(); 29 | pvpexpenses = cfg.getLong("pvpexpenses"); 30 | voteexpenses = cfg.getLong("voteexpenses"); 31 | eventexpenses = cfg.getLong("eventexpenses"); 32 | chestexpenses = cfg.getLong("chestexpenses"); 33 | minegenerated = cfg.getLong("minegenerated"); 34 | affiliateexpenses = cfg.getLong("affiliateexpenses"); 35 | purchasedgems = cfg.getLong("purchasedgems"); 36 | gemprofits = cfg.getLong("gemprofits"); 37 | } 38 | 39 | public void save() { 40 | final FileConfiguration cfg = ms.getConfig(); 41 | cfg.set("pvpexpenses", pvpexpenses); 42 | cfg.set("voteexpenses", voteexpenses); 43 | cfg.set("eventexpenses", eventexpenses); 44 | cfg.set("chestexpenses", chestexpenses); 45 | cfg.set("purchasedgems", purchasedgems); 46 | cfg.set("minegenerated", minegenerated); 47 | cfg.set("affiliateexpenses", affiliateexpenses); 48 | cfg.set("gemprofits", gemprofits); 49 | ms.saveConfig(); 50 | } 51 | public void saveTodayAnalytics(final boolean finishday) { 52 | if (finishday) { 53 | for (final Player pl : ms.getServer().getOnlinePlayers()) { 54 | if (pl.isOnline() == false) continue; 55 | final MuxUser u = ms.getMuxUser(pl.getName()); 56 | if (u != null) { 57 | getAnalytics().addPlayTime(pl.getUniqueId(), u.getLoginTimestamp()); 58 | } 59 | } 60 | } 61 | ms.getDB().saveAnalytics(analytics); 62 | checkDay(); 63 | } 64 | public Analytics getAnalytics() { 65 | return analytics; 66 | } 67 | public Analytics loadAnalytics(final int dayofyear) { 68 | return analytics != null && dayofyear == analytics.getDayOfYear() ? analytics : ms.getDB().loadAnalytics(dayofyear); 69 | } 70 | private void checkDay() { 71 | final int day = analytics.getDayOfYear(), today = Calendar.getInstance(TimeZone.getTimeZone("CET")).get(Calendar.DAY_OF_YEAR); 72 | if (day != today) { 73 | analytics = new Analytics(today, 0, new TreeMap<>(), 0, 0, 0, 0, 0, new HashSet<>(), new HashSet<>(), new HashSet<>(), new HashSet<>(), new HashSet<>(), new HashSet<>(), new TreeMap<>(), new TreeMap<>(), 74 | new TreeMap<>(), new TreeMap<>(), 0, new HashSet<>(), new TreeMap<>(), new TreeMap<>(), new TreeMap<>(), 0); 75 | } 76 | } 77 | 78 | private long pvpexpenses, voteexpenses, eventexpenses, chestexpenses, purchasedgems, minegenerated, affiliateexpenses, gemprofits; 79 | 80 | public long getPvPExpenses() { 81 | return pvpexpenses; 82 | } 83 | 84 | public long getVoteExpenses() { 85 | return voteexpenses; 86 | } 87 | 88 | public long getEventExpenses() { 89 | return eventexpenses; 90 | } 91 | 92 | public long getAffiliateExpenses() { 93 | return affiliateexpenses; 94 | } 95 | 96 | public long getGemProfits() { 97 | return gemprofits; 98 | } 99 | 100 | public long getChestExpenses() { 101 | return chestexpenses; 102 | } 103 | 104 | public long getPurchasedGems() { 105 | return purchasedgems; 106 | } 107 | 108 | public long getMineGenerated() { 109 | return minegenerated; 110 | } 111 | 112 | public void addMineGenerated(final int amount) { 113 | this.minegenerated += amount; 114 | } 115 | 116 | public void addPvPExpenses(final int expenses) { 117 | this.pvpexpenses += expenses; 118 | } 119 | 120 | public void addVoteExpenses(final int expenses) { 121 | this.voteexpenses += expenses; 122 | } 123 | 124 | public void addEventExpenses(final int expenses) { 125 | this.eventexpenses += expenses; 126 | } 127 | 128 | public void addChestExpenses(final int expenses) { 129 | this.chestexpenses += expenses; 130 | } 131 | 132 | public void addAffiliateExpenses(final long expenses) { 133 | this.affiliateexpenses += expenses; 134 | } 135 | 136 | public void addGemProfits(final int gemprofits) { 137 | this.gemprofits += gemprofits; 138 | } 139 | 140 | public void addPurchasedGems(final int purchased) { 141 | this.purchasedgems += purchased; 142 | } 143 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/muxteam/MuxVanish.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.muxteam; 2 | 3 | import me.muxteam.muxsystem.MuxSystem; 4 | import me.muxteam.shared.MuxSharedPackets; 5 | import org.bukkit.Server; 6 | import org.bukkit.entity.ArmorStand; 7 | import org.bukkit.entity.HumanEntity; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.potion.PotionEffect; 10 | import org.bukkit.potion.PotionEffectType; 11 | 12 | import java.util.HashMap; 13 | import java.util.HashSet; 14 | import java.util.Map; 15 | import java.util.Set; 16 | import java.util.stream.Collectors; 17 | 18 | public class MuxVanish { 19 | private MuxSystem ms; 20 | private final Map vplayers = new HashMap<>(); 21 | 22 | public MuxVanish(final MuxSystem ms) { 23 | this.ms = ms; 24 | } 25 | public void close() { 26 | final Server sr = ms.getServer(); 27 | for (final String s : vplayers.keySet()) { 28 | final Player p = sr.getPlayer(s); 29 | if (p == null) continue; 30 | p.removePotionEffect(PotionEffectType.INVISIBILITY); 31 | ms.sendNormalTitle(p, "§aDu bist wieder sichtbar.", 20, 100, 20); 32 | sr.getOnlinePlayers().forEach(pl -> pl.showPlayer(p)); 33 | } 34 | this.ms = null; 35 | } 36 | public boolean isVanish(final String pname) { 37 | return vplayers.containsKey(pname); 38 | } 39 | public void handleQuit(final Player p) { 40 | final String pname = p.getName(); 41 | if (vplayers.containsKey(pname)) { 42 | ms.getForkJoinPool().execute(() -> ms.getShared().getNetty().sendPacket(new MuxSharedPackets.PacketPlayerVanish(pname, true))); 43 | ms.getShared().onSharedVanish(pname, true); 44 | p.removePotionEffect(PotionEffectType.INVISIBILITY); 45 | } 46 | final Server sr = ms.getServer(); 47 | if (p.hasPermission("muxsystem.vanish")) { 48 | final Set closeinv = new HashSet<>(); 49 | p.getInventory().getViewers().forEach(victim -> closeinv.add(victim.getName())); 50 | for (final String v : closeinv) { 51 | final Player pl = sr.getPlayer(v); 52 | pl.closeInventory(); 53 | } 54 | } 55 | } 56 | public void handleJoin(final Player p) { 57 | final Server sr = ms.getServer(); 58 | if (p.hasPermission("muxsystem.vanish") && vplayers.containsKey(p.getName())) { 59 | ms.getForkJoinPool().execute(() -> ms.getShared().getNetty().sendPacket(new MuxSharedPackets.PacketPlayerVanish(p.getName(), false))); 60 | ms.getShared().onSharedVanish(p.getName(), false); 61 | sr.getOnlinePlayers().forEach(victim -> { 62 | if (victim.isOp() == false && (p.isOp() || victim.hasPermission("muxsystem.vanish") == false)) { 63 | victim.hidePlayer(p); 64 | } 65 | }); 66 | p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 0)); 67 | } 68 | if (p.isOp() == false) { 69 | for (final String s : vplayers.keySet()) { 70 | final Player pl = sr.getPlayer(s); 71 | if (pl == null || (pl.isOp() == false && p.hasPermission("muxsystem.vanish"))) continue; 72 | p.hidePlayer(pl); 73 | } 74 | } 75 | } 76 | public boolean handleCommand(final Player p, final String[] args) { 77 | if (p.hasPermission("muxsystem.vanish") == false) { 78 | ms.sendNoCMDMessage(p); 79 | return true; 80 | } 81 | final Long time = vplayers.remove(p.getName()); 82 | if (time != null) { 83 | final Set exclude = ms.getServer().getOnlinePlayers().stream().filter(victim -> victim.canSee(p)).map(HumanEntity::getName).collect(Collectors.toSet()); 84 | ms.getServer().getOnlinePlayers().forEach(victim -> victim.showPlayer(p)); 85 | p.removePotionEffect(PotionEffectType.INVISIBILITY); 86 | ms.getFriends().sendFriendAlert(p, exclude); 87 | ms.showItemBar(p, "§fDu hast dein Vanish-Modus §cdeaktiviert§f."); 88 | ms.getShared().onSharedVanish(p.getName(), true); 89 | ms.getShared().getNetty().sendPacket(new MuxSharedPackets.PacketPlayerVanish(p.getName(), true)); 90 | return true; 91 | } 92 | final Set closeinv = new HashSet<>(); 93 | p.getInventory().getViewers().forEach(victim -> closeinv.add(victim.getName())); 94 | ms.getServer().getOnlinePlayers().forEach(victim -> { 95 | if (victim.isOp() == false && (p.isOp() || victim.hasPermission("muxsystem.vanish") == false)) { 96 | victim.hidePlayer(p); 97 | if (closeinv.contains(victim.getName())) victim.closeInventory(); 98 | } 99 | }); 100 | p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 0)); 101 | vplayers.put(p.getName(), System.currentTimeMillis()); 102 | ms.getShared().onSharedVanish(p.getName(), false); 103 | ms.getShared().getNetty().sendPacket(new MuxSharedPackets.PacketPlayerVanish(p.getName(), false)); 104 | 105 | ms.showItemBar(p, "§fDu hast dein Vanish-Modus §aaktiviert§f."); 106 | if (args.length == 0 || args[0].equals("-p") == false) ms.getPets().deactivatePet(p); 107 | if (p.isInsideVehicle() == false || p.getVehicle() instanceof ArmorStand == false) ms.getMounts().deactivateMount(p); 108 | return true; 109 | } 110 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/ranks/MuxCreators.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.ranks; 2 | 3 | import com.sk89q.worldguard.protection.regions.ProtectedRegion; 4 | import me.muxteam.extras.MuxBoosters.BoosterType; 5 | import me.muxteam.muxsystem.MuxInventory.InvType; 6 | import me.muxteam.muxsystem.MuxSystem; 7 | import org.bukkit.*; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.inventory.Inventory; 10 | import org.bukkit.inventory.ItemFlag; 11 | import org.bukkit.inventory.ItemStack; 12 | import org.bukkit.inventory.meta.ItemMeta; 13 | 14 | import java.util.HashSet; 15 | import java.util.Set; 16 | import java.util.UUID; 17 | import java.util.concurrent.CopyOnWriteArraySet; 18 | 19 | public final class MuxCreators { 20 | private MuxSystem ms; 21 | private final Set recording = new HashSet<>(), flyspawn = new CopyOnWriteArraySet<>(); 22 | private final ItemStack youtubehead; 23 | 24 | public MuxCreators(final MuxSystem ms) { 25 | this.ms = ms; 26 | this.youtubehead = ms.getHeadFromURL("https://textures.minecraft.net/texture/bb7688da46586b859a1cde40cae1cdbc15abe35615c4bc5296fad09394105d0", ""); 27 | } 28 | public void close() { 29 | this.ms = null; 30 | } 31 | public void checkFlying() { 32 | final Server sr = ms.getServer(); 33 | for (final UUID uuid : flyspawn) { 34 | final Player p = sr.getPlayer(uuid); 35 | if (p == null) { 36 | flyspawn.remove(uuid); 37 | continue; 38 | } 39 | if (ms.hasNormalFlight(p)) continue; 40 | final Location l = p.getLocation(); 41 | final ProtectedRegion spawnrg = ms.getSpawnRegion(); 42 | final boolean canfly = (spawnrg != null && p.getWorld().equals(ms.getGameSpawn().getWorld()) && spawnrg.contains(l.getBlockX(), l.getBlockY(), l.getBlockZ())); 43 | if (p.getAllowFlight() && canfly == false) { 44 | p.setAllowFlight(false); 45 | p.setFlying(false); 46 | } else if (p.getAllowFlight() == false && canfly) { 47 | p.setAllowFlight(true); 48 | p.setFlying(true); 49 | p.setFlySpeed(0.05F); 50 | } 51 | if (p.isFlying()) { 52 | p.getWorld().spigot().playEffect(l.subtract(0D, 0.5D, 0D), Effect.CLOUD, 0, 0, (float) 0.1, (float) 0.1, (float) 0.1, (float) 0.01, 3, 50); 53 | } 54 | } 55 | } 56 | public void handleInventory(final Player p, final ItemStack i) { 57 | if (i.getItemMeta().hasLore() && i.getItemMeta().getLore().size() > 3 && i.getItemMeta().getLore().get(3).startsWith("§c")) { 58 | p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1F, 1F); 59 | p.updateInventory(); 60 | return; 61 | } 62 | final Material m = i.getType(); 63 | if (m == Material.RECORD_7) { 64 | toggleRecording(p.getUniqueId()); 65 | } else if (m == Material.SKULL_ITEM) { 66 | p.closeInventory(); 67 | p.playSound(p.getLocation(), Sound.ORB_PICKUP, 0.5F, 1F); 68 | p.getInventory().addItem(ms.renameItemStack(ms.getHead(p.getName()), "§dCreator §7» §a" + p.getName())); 69 | ms.getKits().checkKitCooldown(p.getUniqueId(), "Creator", true); 70 | return; 71 | } else if (m == Material.FEATHER) { 72 | if (toggleFlySpawn(p.getUniqueId())) { 73 | p.setAllowFlight(true); 74 | p.setFlying(true); 75 | p.setFlySpeed(0.05F); 76 | } else { 77 | p.setAllowFlight(false); 78 | p.setFlying(false); 79 | p.setFlySpeed(0.1F); 80 | } 81 | } else { 82 | p.playSound(p.getLocation(), Sound.NOTE_STICKS, 1F, 1F); 83 | return; 84 | } 85 | handleCreator(p); 86 | p.playSound(p.getLocation(), Sound.NOTE_PLING, 1F, 1.6F); 87 | } 88 | public boolean handleCreator(final Player p) { 89 | if (p.hasPermission("muxsystem.creator") == false) { 90 | ms.openBook(ms.book("Creator", "§5§lCreator\n\n§0Dieser Rang ist für prominente Creators reserviert die häufig MuxCraft Videos hochladen oder viele Spieler anwerben.\n\nVorteile:\n- 30% Cashback\n- §8[§5Creator§8]§0 Präfix\n- Eigenes Menü"), p); 91 | return true; 92 | } 93 | final UUID uuid = p.getUniqueId(); 94 | final String time = ms.getKits().checkKitCooldown(uuid, "Creator", false); 95 | final Inventory inv = ms.getServer().createInventory(null, 27, "§0§lMuxCreator§0 | /creator"); 96 | final Location l = p.getLocation(); 97 | final ProtectedRegion spawnrg = ms.getSpawnRegion(); 98 | final boolean nofly = (spawnrg != null && spawnrg.contains(l.getBlockX(), l.getBlockY(), l.getBlockZ())) == false; 99 | final boolean fly = isFlySpawn(uuid), rec = isRecording(p); 100 | final ItemStack flyitem = ms.addLore(ms.renameItemStack(new ItemStack(Material.FEATHER), "§f§lFlugmodus" + (fly ? "§a §laktiviert" : ""), 101 | "§7Hiermit kannst du am Spawn", "§7durch die Gegend fliegen.", ""), 102 | ms.getBooster().hasBooster(p, BoosterType.FLY) ? new String[] { "§cDu nutzt gerade einen Fly Booster." } : 103 | p.getAllowFlight() && fly == false ? new String[] { "§cDu hast bereits ein Flugmodus aktiv." } : 104 | nofly ? new String[] { "§cDu kannst es nur am Spawn aktivieren." } : 105 | new String[] { "§7Klicke, um den Flugmodus", "§7zu " + (fly ? "§cdeaktivieren" : "§aaktivieren") + "§7." }); 106 | inv.setItem(10, fly ? ms.addGlow(flyitem) : flyitem); 107 | inv.setItem(13, ms.addLore(ms.renameItemStack(youtubehead, "§f§lDein Kopf", "§7Sammle oder verlose deinen", "§7Kopf an andere Spieler.", ""), time == null ? new String[] { "§7Klicke, um deinen Kopf", "§7zu §aerhalten§7." } : new String[] { String.format("§cWarte §6%s§c, um deinen Kopf", time), "§cwieder zu erhalten."})); 108 | final ItemStack recorditem = ms.renameItemStack(new ItemStack(Material.RECORD_7), "§f§lAufnahmemodus" + (rec ? "§a §laktiviert" : ""), "§7MSGs von fremden Spielern und", "§7alle Anfragen werden ignoriert.", "", "§7Klicke, um den Aufnahmemodus", "§7zu " + (rec ? "§cdeaktivieren" : "§aaktivieren") + "§7."); 109 | final ItemMeta im = recorditem.getItemMeta(); 110 | im.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); 111 | recorditem.setItemMeta(im); 112 | inv.setItem(16, rec ? ms.addGlow(recorditem) : recorditem); 113 | if (ms.getActiveInv(p.getName()) != InvType.CREATOR) p.closeInventory(); 114 | p.openInventory(inv); 115 | ms.setActiveInv(p.getName(), InvType.CREATOR); 116 | return true; 117 | } 118 | public boolean isRecording(final Player p) { 119 | return recording.contains(p.getUniqueId()); 120 | } 121 | public void toggleRecording(final UUID uuid) { 122 | if (recording.remove(uuid) == false) recording.add(uuid); 123 | } 124 | public void removeFlySpawn(final UUID uuid) { 125 | flyspawn.remove(uuid); 126 | } 127 | public boolean isFlySpawn(final UUID uuid) { 128 | return flyspawn.contains(uuid); 129 | } 130 | public boolean toggleFlySpawn(final UUID uuid) { 131 | if (flyspawn.remove(uuid) == false) { 132 | flyspawn.add(uuid); 133 | return true; 134 | } 135 | return false; 136 | } 137 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/ranks/MuxKits.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.ranks; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.reflect.TypeToken; 5 | import me.muxteam.muxsystem.MuxSystem; 6 | import org.bukkit.Material; 7 | import org.bukkit.configuration.file.FileConfiguration; 8 | import org.bukkit.enchantments.Enchantment; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.inventory.ItemStack; 11 | import org.bukkit.inventory.PlayerInventory; 12 | import org.bukkit.scheduler.BukkitRunnable; 13 | 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | import java.util.UUID; 17 | 18 | public final class MuxKits { 19 | private MuxSystem ms; 20 | private Map> kitcooldowns = new HashMap<>(); 21 | 22 | public MuxKits(final MuxSystem ms) { 23 | this.ms = ms; 24 | final Gson gson = new Gson(); 25 | final FileConfiguration hashYML = ms.getHashYAML(); 26 | if (hashYML.contains("kitcooldowns")) { 27 | kitcooldowns = gson.fromJson(hashYML.getString("kitcooldowns"), new TypeToken>>() { }.getType()); 28 | } 29 | } 30 | public void close() { 31 | final long currentime = System.currentTimeMillis(); 32 | kitcooldowns.entrySet().removeIf(entry -> entry.getValue().entrySet().removeIf(entry2 -> entry2.getValue() + getCooldownTime(entry2.getKey()) < currentime) && entry.getValue().isEmpty()); 33 | saveKits(false); 34 | this.ms = null; 35 | } 36 | 37 | public String checkKitCooldown(final UUID uuid, final String type, final boolean save) { 38 | final HashMap map = kitcooldowns.getOrDefault(uuid, new HashMap<>()); 39 | final long cooldown = getCooldownTime(type); 40 | final Long current = map.get(type); 41 | if (current != null && current + cooldown > System.currentTimeMillis()) { 42 | return ms.getTime((int) ((current + cooldown - System.currentTimeMillis()) / 1000)); 43 | } 44 | if (save) { 45 | map.put(type, System.currentTimeMillis()); 46 | kitcooldowns.put(uuid, map); 47 | } 48 | return null; 49 | } 50 | public boolean giveKit(final Player p, final Material kit, final boolean save) { 51 | final PlayerInventory pi = p.getInventory(); 52 | if (pi.firstEmpty() == -1) { 53 | ms.showItemBar(p, ms.getLang("invfull")); 54 | return false; 55 | } 56 | switch (kit) { 57 | case IRON_CHESTPLATE: // Starter Kit 58 | pi.addItem(new ItemStack(Material.IRON_HELMET)); 59 | pi.addItem(new ItemStack(Material.IRON_CHESTPLATE)); 60 | pi.addItem(new ItemStack(Material.IRON_LEGGINGS)); 61 | pi.addItem(new ItemStack(Material.IRON_BOOTS)); 62 | final ItemStack iS = new ItemStack(Material.IRON_SWORD); 63 | iS.addEnchantment(Enchantment.DAMAGE_ALL, 2); 64 | iS.addEnchantment(Enchantment.FIRE_ASPECT, 2); 65 | pi.addItem(iS); 66 | final ItemStack iB = new ItemStack(Material.BOW); 67 | iB.addEnchantment(Enchantment.ARROW_DAMAGE, 1); 68 | if (p.hasPermission("muxsystem.elite") == false) pi.addItem(iB); 69 | pi.addItem(new ItemStack(Material.IRON_PICKAXE)); 70 | pi.addItem(new ItemStack(Material.IRON_AXE)); 71 | pi.addItem(new ItemStack(Material.IRON_SPADE)); 72 | pi.addItem(new ItemStack(Material.GOLDEN_APPLE, 5)); 73 | if (p.hasPermission("muxsystem.elite") == false) pi.addItem(new ItemStack(Material.ARROW, 32)); 74 | if (save) checkKitCooldown(p.getUniqueId(), "Starter", true); 75 | break; 76 | case DIAMOND_CHESTPLATE: 77 | pi.addItem(new ItemStack(Material.DIAMOND_HELMET)); 78 | pi.addItem(new ItemStack(Material.DIAMOND_CHESTPLATE)); 79 | pi.addItem(new ItemStack(Material.DIAMOND_LEGGINGS)); 80 | pi.addItem(new ItemStack(Material.DIAMOND_BOOTS)); 81 | pi.addItem(new ItemStack(Material.DIAMOND_SWORD)); 82 | pi.addItem(new ItemStack(Material.DIAMOND_PICKAXE)); 83 | pi.addItem(new ItemStack(Material.DIAMOND_AXE)); 84 | pi.addItem(new ItemStack(Material.DIAMOND_SPADE)); 85 | final ItemStack iB2 = new ItemStack(Material.BOW); 86 | iB2.addEnchantment(Enchantment.ARROW_DAMAGE, 2); 87 | pi.addItem(iB2); 88 | pi.addItem(new ItemStack(Material.ARROW, 32)); 89 | checkKitCooldown(p.getUniqueId(), "Tools", true); 90 | ms.checkLimit(p.getName(), "Tools", 4, true); 91 | break; 92 | case BREWING_STAND_ITEM: 93 | pi.addItem(new ItemStack(Material.POTION, 16, (short) 16421)); 94 | pi.addItem(new ItemStack(Material.POTION, 16, (short) 16417)); 95 | pi.addItem(new ItemStack(Material.POTION, 16, (short) 16418)); 96 | pi.addItem(new ItemStack(Material.POTION, 16, (short) 16425)); 97 | pi.addItem(new ItemStack(Material.POTION, 16, (short) 16451)); 98 | checkKitCooldown(p.getUniqueId(), "Potion", true); 99 | break; 100 | default: return true; 101 | } 102 | saveKits(true); 103 | return true; 104 | } 105 | private void saveKits(final boolean async) { 106 | final Gson gson = new Gson(); 107 | ms.getHashYAML().set("kitcooldowns", gson.toJson(kitcooldowns)); 108 | if (async == false) { 109 | ms.saveHashFile(); 110 | return; 111 | } 112 | new BukkitRunnable() { 113 | @Override 114 | public void run() { 115 | ms.saveHashFile(); 116 | } 117 | }.runTaskAsynchronously(ms); 118 | } 119 | private long getCooldownTime(final String type) { 120 | switch (type) { 121 | case "Heal": 122 | case "Tools": 123 | case "Potion": 124 | return 3600000L; 125 | case "UltraArmor": 126 | case "UltraSword": 127 | case "UltraApple": 128 | return 86400000L; 129 | case "UltraTools": 130 | case "Creator": 131 | return 172800000L; 132 | case "UltraPotato": 133 | return 259200000L; 134 | default: 135 | return 0L; 136 | } 137 | } 138 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/shared/MuxShared.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.shared; 2 | 3 | import io.netty.util.internal.ConcurrentSet; 4 | import me.muxteam.muxsystem.MuxSystem; 5 | import org.bukkit.entity.Player; 6 | 7 | import java.io.BufferedReader; 8 | import java.io.IOException; 9 | import java.io.InputStreamReader; 10 | import java.net.URL; 11 | import java.nio.charset.StandardCharsets; 12 | import java.util.Map; 13 | import java.util.Set; 14 | import java.util.UUID; 15 | import java.util.concurrent.ConcurrentHashMap; 16 | 17 | public class MuxShared { 18 | private final MuxSystem ms; 19 | private boolean isDaemon = false; 20 | 21 | private final MuxNetty netty; 22 | 23 | private final Map uuidNameCache = new ConcurrentHashMap<>(); 24 | private final Map onlinePlayers = new ConcurrentHashMap<>(); // player uuid & server uuid 25 | private final Set playersInVanish = new ConcurrentSet<>(); 26 | 27 | public MuxShared(final MuxSystem ms) { 28 | this.ms = ms; 29 | this.netty = new MuxNetty(ms); 30 | netty.setup(this); 31 | } 32 | 33 | public void setDaemon(boolean daemon) { 34 | System.out.println("setDaemon to " + daemon); 35 | isDaemon = daemon; 36 | } 37 | 38 | public boolean isDaemon() { 39 | return isDaemon; 40 | } 41 | 42 | public MuxNetty getNetty() { 43 | return netty; 44 | } 45 | 46 | public void shutdown() { 47 | if (isDaemon) ms.getDB().deleteSharedData("NettyServerAddress"); 48 | if (this.netty != null && this.netty.getEndPoint() != null && this.netty.getEndPoint().isConnected()) 49 | this.netty.getEndPoint().close(); 50 | } 51 | 52 | public void updateCachedName(final UUID uuid, final String newName) { 53 | if (this.uuidNameCache.containsKey(uuid)) 54 | this.addNameToCache(uuid, newName); 55 | } 56 | 57 | public void broadcastCachedNameUpdate(final UUID uuid, final String newName) { 58 | this.netty.sendPacket(new MuxSharedPackets.PacketUpdateCachedName(uuid, newName)); 59 | } 60 | 61 | public String getNameFromUUID(final UUID uuid) { 62 | String cachedName = uuidNameCache.get(uuid); 63 | if (cachedName == null) { 64 | cachedName = this.fetchName(uuid); 65 | if (cachedName != null) 66 | uuidNameCache.put(uuid, cachedName); 67 | } 68 | return cachedName; 69 | } 70 | 71 | private String fetchName(final UUID uuid) { 72 | final Player player = ms.getServer().getPlayer(uuid); 73 | return player != null ? player.getName() : this.ms.getDB().getPlayerName(uuid); // no need to fetch the name from the db if the player is online 74 | } 75 | 76 | public void addNameToCache(final UUID uuid, final String name) { 77 | this.uuidNameCache.put(uuid, name); 78 | } 79 | 80 | public void removeNameFromCache(final UUID uuid, final String name) { 81 | this.uuidNameCache.remove(uuid, name); 82 | } 83 | 84 | public String getMachineIp() throws IOException { 85 | final URL aws = new URL("https://checkip.amazonaws.com"); 86 | try (BufferedReader in = new BufferedReader(new InputStreamReader(aws.openStream(), StandardCharsets.UTF_8))) { 87 | return in.readLine(); 88 | } 89 | } 90 | 91 | public void onSharedJoin(final UUID player, final UUID server) { 92 | this.onlinePlayers.put(player, server); 93 | } 94 | 95 | public void onSharedQuit(final UUID player) { 96 | this.onlinePlayers.remove(player); 97 | } 98 | 99 | public void onSharedVanish(final String player, boolean remove) { 100 | if (remove) 101 | this.playersInVanish.remove(player); 102 | else 103 | this.playersInVanish.add(player); 104 | } 105 | 106 | public Map getOnlinePlayers() { 107 | return onlinePlayers; 108 | } 109 | 110 | public Set getPlayersInVanish() { 111 | return playersInVanish; 112 | } 113 | 114 | public String getServerName(final UUID player) { 115 | return this.onlinePlayers.containsKey(player) ? ms.getServers().get(this.onlinePlayers.get(player)) : null; 116 | } 117 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/shared/TestNettyClient.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.shared; 2 | 3 | import de.vantrex.simplenetty.annotations.exceptions.AnnotationNotFoundException; 4 | import de.vantrex.simplenetty.client.SimpleClient; 5 | import de.vantrex.simplenetty.client.settings.SimpleClientSettings; 6 | import de.vantrex.simplenetty.packet.exceptions.PacketAlreadyRegisteredException; 7 | import de.vantrex.simplenetty.packet.exceptions.PacketIdAlreadyRegisteredException; 8 | import de.vantrex.simplenetty.protocol.impl.NumericProtocol; 9 | 10 | import java.lang.reflect.InvocationTargetException; 11 | import java.lang.reflect.Method; 12 | 13 | /** 14 | * DIESE KLASSE ERST DELETEN WENN WIR EINE ANDERE METHODE ZUM TESTEN HABEN (2 Server z.B.) 15 | */ 16 | public class TestNettyClient { 17 | 18 | public static void main(String[] args) { 19 | System.out.println("STARTING"); 20 | SimpleClient client = new SimpleClient(new SimpleClientSettings() 21 | .address("195.82.158.107") // <- address saved in SharedData DB table 22 | .port(38104) 23 | .threads(2) 24 | .protocol(new NumericProtocol())); 25 | try { 26 | client.getSettings().protocol().registerPacket(MuxSharedPackets.PacketResetVotes.class); 27 | } catch (AnnotationNotFoundException | PacketAlreadyRegisteredException | PacketIdAlreadyRegisteredException e) { 28 | throw new RuntimeException(e); 29 | } 30 | client.getSettings().protocol().registerListener(new TestNettyListener()); 31 | try { 32 | Thread.sleep(500); 33 | } catch (InterruptedException e) { 34 | throw new RuntimeException(e); 35 | } 36 | System.out.println("connected? " + client.getChannel()); 37 | if (client.getChannel() == null) { // Bei mir am PC wird der Thread im Constructor von new SimpleClient() nicht gestartet? 38 | try { 39 | Method method = client.getClass().getDeclaredMethod("init"); 40 | method.setAccessible(true); 41 | method.invoke(client); 42 | } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { 43 | throw new RuntimeException(e); 44 | } 45 | } 46 | // client.connect(); 47 | client.send(new MuxSharedPackets.PacketResetVotes()); 48 | try { 49 | Thread.sleep(10_000); 50 | } catch (InterruptedException e) { 51 | throw new RuntimeException(e); 52 | } 53 | System.out.println("closing"); 54 | client.close(); 55 | System.out.println("closed"); 56 | 57 | try { 58 | Thread.sleep(5000); 59 | } catch (InterruptedException e) { 60 | throw new RuntimeException(e); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/me/muxteam/shared/TestNettyListener.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.shared; 2 | 3 | import de.vantrex.simplenetty.listener.SimplePacketListener; 4 | import de.vantrex.simplenetty.listener.handler.SimplePacketHandler; 5 | import de.vantrex.simplenetty.session.Session; 6 | 7 | /** 8 | * DIESE KLASSE ERST DELETEN WENN WIR EINE ANDERE METHODE ZUM TESTEN HABEN (2 Server z.B.) 9 | */ 10 | public class TestNettyListener implements SimplePacketListener { 11 | 12 | @SimplePacketHandler 13 | public void handleResetVote(MuxSharedPackets.PacketResetVotes packet, Session session) { 14 | System.out.println("HUH"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/me/muxteam/shop/MuxMining.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.shop; 2 | 3 | import me.muxteam.basic.NMSReflection; 4 | import me.muxteam.muxsystem.MuxSystem; 5 | import me.muxteam.muxsystem.MuxUser; 6 | import net.minecraft.server.v1_8_R3.Entity; 7 | import net.minecraft.server.v1_8_R3.EntityArmorStand; 8 | import net.minecraft.server.v1_8_R3.Tuple; 9 | import org.bukkit.Location; 10 | import org.bukkit.Material; 11 | import org.bukkit.block.Block; 12 | import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArmorStand; 13 | import org.bukkit.enchantments.Enchantment; 14 | import org.bukkit.entity.ArmorStand; 15 | import org.bukkit.entity.EntityType; 16 | import org.bukkit.entity.Player; 17 | import org.bukkit.event.EventHandler; 18 | import org.bukkit.event.Listener; 19 | import org.bukkit.event.player.PlayerInteractAtEntityEvent; 20 | import org.bukkit.inventory.ItemStack; 21 | 22 | import java.util.ArrayList; 23 | import java.util.Arrays; 24 | import java.util.EnumMap; 25 | import java.util.HashSet; 26 | import java.util.List; 27 | import java.util.Map; 28 | import java.util.Set; 29 | import java.util.UUID; 30 | 31 | public final class MuxMining implements Listener { 32 | private final MuxSystem ms; 33 | private final List> mineHoloList = new ArrayList<>(); 34 | private final Set noholos = new HashSet<>(); 35 | 36 | public MuxMining(final MuxSystem ms) { 37 | this.ms = ms; 38 | Arrays.stream(OreTypes.values()).forEach(type -> oreTypes.put(type.material, type)); 39 | ms.getServer().getPluginManager().registerEvents(this, ms); 40 | } 41 | 42 | public void clearHolos() { 43 | mineHoloList.removeIf(tuple -> { 44 | if (tuple.b() <= System.currentTimeMillis()) { 45 | tuple.a().remove(); 46 | return true; 47 | } 48 | return false; 49 | }); 50 | } 51 | 52 | public void handleBreak(final Player p, final Block b, final ItemStack hand) { 53 | final Material m = b.getType(); 54 | final OreTypes type = oreTypes.get(m); 55 | if (b.getWorld() == ms.getFarmWorld() && type != null) { 56 | if (ms.hasVoted(p) == false) { 57 | if (ms.checkGeneralCooldown(p.getName(), "ORENEEDVOTE", 30000L, true)) { 58 | ms.chatClickHoverLink(p, "§6§lMuxCraft>§7 Vote§7, §7um §7beim §7Erze §7Minen §eMuxCoins §7zu §7erhalten.", ms.getLang("vote.hoverunlock"), "https://muxcraft.eu/vote/?ign=" + p.getName()); 59 | ms.chatClickHoverLink(p, ms.getLang("vote.tounlock2"), ms.getLang("vote.hoverunlock"), "https://muxcraft.eu/vote/?ign=" + p.getName()); 60 | } 61 | return; 62 | } 63 | if (hand != null && hand.getEnchantmentLevel(Enchantment.SILK_TOUCH) > 0) return; 64 | if (ms.getActiveMuxCoinsSupply() > 0) { 65 | final MuxUser u = ms.getMuxUser(p.getName()); 66 | int coins = (int) (ms.getActiveMuxCoinsSupply() * type.percentage / 100); 67 | if (coins < 1) coins = 1; 68 | if (ms.hasGold(p.getUniqueId())) 69 | coins *= 2; 70 | u.addCoins(coins); 71 | ms.getHistory().addCoinHistory(u.getUUID(), "Mining", coins); 72 | ms.getAnalytics().addMineGenerated(coins); 73 | ms.sendScoreboard(p); 74 | if (noholos.contains(p.getUniqueId())) { 75 | ms.showItemBar(p, "§e+" + coins + " MuxCoin" + (coins > 1 ? "s" : "")); 76 | } else { 77 | spawnTempHologram(b.getLocation(), "§e+" + coins + " MuxCoin" + (coins > 1 ? "s" : "")); 78 | } 79 | } 80 | } 81 | } 82 | 83 | // 1.8 HOLOGRAM FIX 84 | @EventHandler 85 | public void onInteractAtEntity(final PlayerInteractAtEntityEvent e) { 86 | final org.bukkit.entity.Entity clicked = e.getRightClicked(); 87 | if (clicked.getWorld() != ms.getFarmWorld() || clicked instanceof ArmorStand == false) return; 88 | final ArmorStand armorStand = (ArmorStand) e.getRightClicked(); 89 | final String cname = armorStand.getCustomName(); 90 | if (cname != null && cname.contains("MuxCoins")) { 91 | noholos.add(e.getPlayer().getUniqueId()); 92 | } 93 | } 94 | 95 | private void spawnTempHologram(final Location loc, final String text) { 96 | final ArmorStand dam = (ArmorStand) loc.getWorld().spawnEntity(getDisplayLoc(loc.add(0.5, 0, 0.5)), EntityType.ARMOR_STAND); 97 | dam.setMarker(true); 98 | dam.setVisible(false); 99 | dam.setCustomNameVisible(true); 100 | dam.setCustomName(text); 101 | dam.setGravity(false); 102 | EntityArmorStand handle = ((CraftArmorStand) dam).getHandle(); 103 | NMSReflection.setObject(Entity.class, "uniqueID", handle, ms.getIdentificationId()); 104 | NMSReflection.setObject(Entity.class, "invulnerable", handle, true); 105 | mineHoloList.add(new Tuple<>(dam, System.currentTimeMillis() + 2000)); 106 | } 107 | private Location getDisplayLoc(final Location from) { 108 | final Location l = from.clone(); 109 | final Block b = l.getBlock(); 110 | if (b.getRelative(0, 1, 0).getType() == Material.AIR) { 111 | return l.add(0, 1, 0); 112 | } else if (b.getRelative(0, -1, 0).getType() == Material.AIR) { 113 | return l.add(0, -1, 0); 114 | } else if (b.getRelative(1, 0, 0).getType() == Material.AIR) { 115 | return l.add(1, 0, 0); 116 | } else if (b.getRelative(-1, 0, 0).getType() == Material.AIR) { 117 | return l.add(-1, 0, 0); 118 | } else if (b.getRelative(0, 0, 1).getType() == Material.AIR) { 119 | return l.add(0, 0, 1); 120 | } else if (b.getRelative(0, 0, -1).getType() == Material.AIR) { 121 | return l.add(0, 0, -1); 122 | } 123 | return from; 124 | } 125 | private final Map oreTypes = new EnumMap<>(Material.class); 126 | 127 | public enum OreTypes { 128 | IRON(0.00001D, Material.IRON_ORE), 129 | GOLD(0.00003D, Material.GOLD_ORE), 130 | EMERALD(0.0001D, Material.EMERALD_ORE), 131 | DIAMOND(0.00005D, Material.DIAMOND_ORE); 132 | 133 | private final double percentage; 134 | private final Material material; 135 | 136 | OreTypes(final double percentage, final Material material) { 137 | this.percentage = percentage; 138 | this.material = material; 139 | } 140 | 141 | public double getPercentage() { 142 | return percentage; 143 | } 144 | 145 | public Material getMaterial() { 146 | return material; 147 | } 148 | } 149 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/shop/PremiumItem.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.shop; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | import java.util.UUID; 6 | 7 | public class PremiumItem { 8 | private final UUID owner; 9 | private final ItemStack item; 10 | private final int price; 11 | private long id, updated; 12 | 13 | public PremiumItem(final long id, final UUID owner, final ItemStack is, final int price, final long updated) { 14 | this.id = id; 15 | this.owner = owner; 16 | this.item = is; 17 | this.price = price; 18 | this.updated = updated; 19 | } 20 | 21 | public void setKeyId(final long id) { 22 | this.id = id; 23 | } 24 | 25 | public long getKeyId() { 26 | return id; 27 | } 28 | 29 | public UUID getOwner() { 30 | return owner; 31 | } 32 | 33 | public ItemStack getItem() { 34 | return item; 35 | } 36 | 37 | public int getPrice() { 38 | return price; 39 | } 40 | 41 | public long getUpdated() { 42 | return updated; 43 | } 44 | 45 | public boolean isValid() { 46 | return updated + 86500000 * 2 > System.currentTimeMillis(); 47 | } 48 | 49 | public void update() { 50 | this.updated = System.currentTimeMillis(); 51 | } 52 | } -------------------------------------------------------------------------------- /src/main/java/me/muxteam/shop/ShopItem.java: -------------------------------------------------------------------------------- 1 | package me.muxteam.shop; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | import org.bukkit.inventory.meta.ItemMeta; 5 | 6 | import java.util.UUID; 7 | 8 | public class ShopItem { 9 | private final String fullid; 10 | private final UUID uuid; 11 | private final short durability; 12 | private final int itemid; 13 | private int amount; 14 | private double price; 15 | private long id; 16 | 17 | public ShopItem(final long id, final UUID uuid, final String fullid, double price, int amount) { 18 | this.id = id; 19 | this.uuid = uuid; 20 | this.fullid = fullid; 21 | final String[] split = fullid.split(":"); 22 | this.itemid = Integer.parseInt(split[0]); 23 | this.durability = Short.parseShort(split[1]); 24 | this.price = price; 25 | this.amount = amount; 26 | } 27 | 28 | public long getKeyId() { 29 | return id; 30 | } 31 | 32 | public void setKeyId(final long id) { 33 | this.id = id; 34 | } 35 | 36 | public UUID getUUID() { 37 | return uuid; 38 | } 39 | 40 | public String getFullId() { 41 | return fullid; 42 | } 43 | 44 | public int getId() { 45 | return itemid; 46 | } 47 | 48 | public short getDurability() { 49 | return durability; 50 | } 51 | 52 | public ItemStack getItemStack() { 53 | if (itemid == 52) { 54 | final ItemStack is = new ItemStack(itemid, 1, durability); 55 | final ItemMeta im = is.getItemMeta(); 56 | im.setDisplayName("§a§lMuxSpawner"); 57 | is.setItemMeta(im); 58 | return is; 59 | } 60 | return new ItemStack(itemid, 1, durability); 61 | } 62 | 63 | public double getPrice() { 64 | return price; 65 | } 66 | 67 | public int getAmount() { 68 | return amount; 69 | } 70 | 71 | public void setAmount(final int amount) { 72 | this.amount = amount; 73 | } 74 | 75 | public void setPrice(final double price) { 76 | this.price = price; 77 | } 78 | 79 | public void removeOne() { 80 | this.amount--; 81 | } 82 | } --------------------------------------------------------------------------------