├── .editorconfig
├── .github
├── CODEOWNERS
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── bug_report.yml
│ ├── config.yml
│ └── feature_request.yml
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ └── build.yml
├── .gitignore
├── HEADER.txt
├── LICENSE
├── README.md
├── build.gradle.kts
├── buildersutilities-logo.png
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── renovate.json
├── settings.gradle.kts
└── src
└── main
├── java
└── net
│ └── arcaniax
│ └── buildersutilities
│ ├── BuildersUtilities.java
│ ├── NoClipManager.java
│ ├── Settings.java
│ ├── commands
│ ├── AdvancedFlyCommand.java
│ ├── BannerCommand.java
│ ├── ColorCommand.java
│ ├── NightVisionCommand.java
│ ├── NoClipCommand.java
│ ├── SecretBlockCommand.java
│ ├── UtilsCommand.java
│ ├── aliases
│ │ ├── ConvexSelectionAliasCommand.java
│ │ ├── CopyAliasCommand.java
│ │ ├── CuboidSelectionAliasCommand.java
│ │ ├── DeformRotateAliasCommand.java
│ │ ├── FlipAliasCommand.java
│ │ ├── FlySpeedAliasCommand.java
│ │ ├── PasteAliasCommand.java
│ │ ├── PosOneAliasCommand.java
│ │ ├── PosTwoAliasCommand.java
│ │ ├── ReplaceAliasCommand.java
│ │ ├── ScaleAliasCommand.java
│ │ ├── SetAliasCommand.java
│ │ ├── TwistAliasCommand.java
│ │ └── WalkSpeedAliasCommand.java
│ └── system
│ │ ├── CommandForwarder.java
│ │ └── ICommand.java
│ ├── listeners
│ ├── BlockBreakListener.java
│ ├── BlockPhysicsListener.java
│ ├── ExplosionListener.java
│ ├── IronTrapdoorListener.java
│ ├── LeafDecayListener.java
│ ├── PlayerInteractListener.java
│ ├── PlayerMoveListener.java
│ ├── PlayerQuitAndJoinListener.java
│ ├── TeleportListener.java
│ ├── TerracottaInteractListener.java
│ └── WeatherChangeListener.java
│ ├── menus
│ ├── ColorMenuProvider.java
│ ├── Menus.java
│ ├── SecretBlockMenuProvider.java
│ ├── UtilitiesMenuProvider.java
│ ├── bannermenus
│ │ ├── BannerColorMenuProvider.java
│ │ ├── BannerMenuProvider.java
│ │ └── BannerPatternMenuProvider.java
│ └── inv
│ │ ├── ClickableItem.java
│ │ ├── InventoryListener.java
│ │ ├── InventoryManager.java
│ │ ├── SmartInventory.java
│ │ ├── content
│ │ ├── InventoryContents.java
│ │ ├── InventoryProvider.java
│ │ ├── Pagination.java
│ │ ├── SlotIterator.java
│ │ └── SlotPos.java
│ │ └── opener
│ │ ├── ChestInventoryOpener.java
│ │ ├── InventoryOpener.java
│ │ └── SpecialInventoryOpener.java
│ └── utils
│ ├── BannerUtil.java
│ ├── CustomConfig.java
│ ├── Items.java
│ ├── LogManagerCompat.java
│ └── Utility.java
└── resources
├── LICENSE
├── config.yml
└── plugin.yml
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @Brennian
2 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | patreon: Arcaniax # Replace with a single Patreon username
4 | custom: https://www.paypal.me/LesleyDom # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
5 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.yml:
--------------------------------------------------------------------------------
1 | name: Bug report
2 | description: Create a report to help us improve
3 | labels: 'Requires Testing'
4 |
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Thanks for taking the time to fill out this bug report for Builders-Utilities! Fill out the following form to your best ability to help us fix the problem.
10 | Only use this if you're absolutely sure that you found a bug and can reproduce it. For anything else, use: [our Discord server](https://discord.com/invite/jpRVrjd).
11 |
12 | - type: dropdown
13 | attributes:
14 | label: Server Implementation
15 | description: Which server Implementation are you using? If your server implementation is not listed, it is not supported. Switch to a supported version first.
16 | multiple: false
17 | options:
18 | - Paper
19 | - Spigot
20 | - Tuinity
21 | validations:
22 | required: true
23 |
24 | - type: dropdown
25 | attributes:
26 | label: Server Version
27 | description: Which server version version you using? If your server version is not listed, it is not supported. Update to a supported version first.
28 | multiple: false
29 | options:
30 | - '1.17.1'
31 | - '1.16.5'
32 | - '1.15.2'
33 | - '1.14.4'
34 | - '1.13.2'
35 | validations:
36 | required: true
37 |
38 | - type: textarea
39 | attributes:
40 | label: Describe the bug
41 | description: A clear and concise description of what the bug is.
42 | validations:
43 | required: true
44 |
45 | - type: textarea
46 | attributes:
47 | label: To Reproduce
48 | description: Steps to reproduce this behaviour
49 | placeholder: |
50 | 1. Go to '...'
51 | 2. Click on '...'
52 | 3. Scroll down to '...'
53 | 4. See error
54 | validations:
55 | required: true
56 |
57 | - type: textarea
58 | attributes:
59 | label: Expected behaviour
60 | description: A clear and concise description of what you expected to happen.
61 | validations:
62 | required: true
63 |
64 | - type: textarea
65 | attributes:
66 | label: Screenshots / Videos
67 | description: If applicable, add screenshots to help explain your problem.
68 |
69 | - type: input
70 | attributes:
71 | label: Error log (if applicable)
72 | description: If you are reporting a console error, upload any relevant log excerpts to either https://paste.gg/ or https://gist.github.com, save and the paste the link in this box.
73 |
74 | - type: input
75 | attributes:
76 | label: Builders-Utilities Version
77 | description: What version of Builders-Utilities are you running? (`/version Builders-Utilities`)
78 | placeholder: "For example: Builders-Utilities version 2.1.1-61"
79 | validations:
80 | required: true
81 |
82 | - type: checkboxes
83 | attributes:
84 | label: Checklist
85 | description: Make sure you have followed each of the steps outlined here.
86 | options:
87 | - label: I am using the newest build from https://ci.athion.net/job/Builders-Utilities/ and the issue still persists.
88 | required: true
89 |
90 | - type: textarea
91 | attributes:
92 | label: Anything else?
93 | description: You can provide additional context below.
94 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: "Arcaniax' Discord"
4 | url: https://discord.com/invite/jpRVrjd
5 | about: The support Discord, please ask questions and seek support here.
6 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.yml:
--------------------------------------------------------------------------------
1 | name: Feature request
2 | description: Suggest an idea for this project
3 | labels: 'enhancement'
4 |
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Thanks for taking the time to fill out this feature request for Builders-Utilities! Fill out the following form to your best ability to help us understand your feature request and greately improve the change of it getting added.
10 | For anything else than a feature request, use: [our Discord server](https://discord.com/invite/jpRVrjd).
11 |
12 | - type: textarea
13 | attributes:
14 | label: What feature do you want to see added?
15 | description: A clear and concise description of your feature request.
16 | validations:
17 | required: true
18 |
19 | - type: textarea
20 | attributes:
21 | label: Are there any alternatives?
22 | description: List any alternatives you might have tried
23 | validations:
24 | required: true
25 |
26 | - type: textarea
27 | attributes:
28 | label: Anything else?
29 | description: You can provide additional context below.
30 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Overview
2 |
7 |
8 | **Fixes #{Link to issue}**
9 |
10 | ## Description
11 |
12 | ## Checklist
13 |
14 | - [] I included all information required in the sections above
15 | - [] I tested my changes and approved their functionality
16 | - [] I ensured my changes do not break other parts of the code
17 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: "build"
2 |
3 | on: ["pull_request", "push"]
4 |
5 | jobs:
6 | build:
7 | runs-on: "ubuntu-latest"
8 | steps:
9 | - name: "Checkout Repository"
10 | uses: actions/checkout@v4
11 | - name : "Validate Gradle Wrapper"
12 | uses : "gradle/wrapper-validation-action@v3"
13 | - name : "Grab SHA"
14 | uses : "benjlevesque/short-sha@v3.0"
15 | id : "short-sha"
16 | with :
17 | length : "7"
18 | - name : "Echo SHA"
19 | run : "echo $SHA"
20 | env :
21 | SHA : "${{ steps.short-sha.outputs.sha }}"
22 | - name: "Setup JDK 17"
23 | uses: actions/setup-java@v4
24 | with:
25 | distribution: "temurin"
26 | java-version: "17"
27 | - name: Generate versions
28 | uses: HardNorth/github-version-generate@v1
29 | with:
30 | version-source: "file"
31 | version-file: "gradle.properties"
32 | version-file-extraction-pattern: "(?<=version=).+"
33 | - name: "Clean Build"
34 | run: "./gradlew clean build"
35 | - name : Archive Artifacts
36 | uses : actions/upload-artifact@v4
37 | with :
38 | name : Builders-Utilities-${{ env.CURRENT_VERSION }}-${{ env.SHA }}
39 | path : build/libs/Builders-Utilities-${{ env.CURRENT_VERSION }}-${{ env.SHA }}.jar
40 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Others ###
2 | *.cmd
3 | *.sh
4 | *.prefs
5 |
6 | ### Maven ###
7 | /mvn
8 | /target/lib
9 | /target/maven-archiver
10 | /target/classes
11 | /target/maven-status
12 | pom.xml.tag
13 | pom.xml.releaseBackup
14 | pom.xml.versionsBackup
15 | pom.xml.next
16 | release.properties
17 | dependency-reduced-pom.xml
18 | buildNumber.properties
19 | .mvn/timing.properties
20 | out/
21 |
22 |
23 | ### Java ###
24 | *.class
25 |
26 | # Mobile Tools for Java (J2ME)
27 | .mtj.tmp/
28 |
29 | # Package Files #
30 | *.war
31 | *.ear
32 |
33 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
34 | hs_err_pid*
35 |
36 |
37 | ### Intellij ###
38 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
39 |
40 | *.iml
41 |
42 | ## Directory-based project format:
43 | .idea/
44 | # if you remove the above rule, at least ignore the following:
45 |
46 | # User-specific stuff:
47 | # .idea/workspace.xml
48 | # .idea/tasks.xml
49 | # .idea/dictionaries
50 | # .idea/shelf
51 |
52 | # Sensitive or high-churn files:
53 | # .idea/dataSources.ids
54 | # .idea/dataSources.xml
55 | # .idea/sqlDataSources.xml
56 | # .idea/dynamic.xml
57 | # .idea/uiDesigner.xml
58 |
59 | # Gradle:
60 | # .idea/gradle.xml
61 | # .idea/libraries
62 | .gradle
63 |
64 | # Mongo Explorer plugin:
65 | # .idea/mongoSettings.xml
66 |
67 | ## File-based project format:
68 | *.ipr
69 | *.iws
70 |
71 | ## Plugin-specific files:
72 |
73 | # IntelliJ
74 | /out/
75 |
76 | # mpeltonen/sbt-idea plugin
77 | .idea_modules/
78 |
79 | # JIRA plugin
80 | atlassian-ide-plugin.xml
81 |
82 | # Crashlytics plugin (for Android Studio and IntelliJ)
83 | com_crashlytics_export_strings.xml
84 | crashlytics.properties
85 | crashlytics-build.properties
86 | fabric.properties
87 |
88 |
89 | ### Eclipse ###
90 | *.pydevproject
91 | .metadata
92 | bin/
93 | tmp/
94 | *.tmp
95 | *.bak
96 | *.swp
97 | *~.nib
98 | local.properties
99 | .settings/
100 | .loadpath
101 |
102 | # Eclipse Core
103 | .project
104 |
105 | # External tool builders
106 | .externalToolBuilders/
107 |
108 | # Locally stored "Eclipse launch configurations"
109 | *.launch
110 |
111 | # CDT-specific
112 | .cproject
113 |
114 | # JDT-specific (Eclipse Java Development Tools)
115 | .classpath
116 |
117 | # Java annotation processor (APT)
118 | .factorypath
119 |
120 | # PDT-specific
121 | .buildpath
122 |
123 | # sbteclipse plugin
124 | .target
125 |
126 | # TeXlipse plugin
127 | .texlipse
128 |
129 | # STS (Spring Tool Suite)
130 | .springBeans
131 | /target/
132 | checkstyle.xml
133 | classes/
134 | docs/
135 | build/
--------------------------------------------------------------------------------
/HEADER.txt:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ---
6 |
7 | Builders-Utilities was a requested plugin by Alex_deGrote,
8 | who won the plugin giveaway at my panel from McBcon.
9 | This plugin is a collection of a lot of tiny features that help with building.
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | ## Links
18 |
19 | * [Download](https://www.spigotmc.org/resources/builders-utilities.42361/)
20 | * [Development Builds](https://ci.athion.net/job/Builders-Utilities/)
21 | * [Discord](https://discord.gg/jpRVrjd)
22 | * [Issues](https://github.com/Arcaniax-Development/Builders-Utilities/issues)
23 |
24 | # Building
25 | Gradle is the recommended way to build the project. Use `./gradlew build` in the main project directory to build the project.
26 |
27 | # Contributing
28 | See [here](https://github.com/Brennian/Builders-Utilities/blob/master/CONTRIBUTING.md)
29 |
30 | ## Suggestions
31 | Suggestions are welcome! We have a separate issue form for suggestions, which can be found [here](https://github.com/Arcaniax-Development/Builders-Utilities/issues).
32 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2 | import com.diffplug.gradle.spotless.SpotlessPlugin
3 | import org.ajoberstar.grgit.Grgit
4 |
5 | plugins {
6 | java
7 |
8 | id("com.diffplug.spotless") version "7.0.3"
9 | id("com.github.johnrengelman.shadow") version "8.1.1"
10 | id("org.ajoberstar.grgit") version "5.3.0"
11 |
12 | idea
13 | eclipse
14 | }
15 |
16 | the().toolchain {
17 | languageVersion.set(JavaLanguageVersion.of(17))
18 | }
19 |
20 | tasks.compileJava.configure {
21 | options.release.set(8)
22 | }
23 |
24 | configurations.all {
25 | attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
26 | }
27 |
28 | repositories {
29 | mavenCentral()
30 | maven {
31 | name = "Paper"
32 | url = uri("https://repo.papermc.io/repository/maven-public/")
33 | }
34 | maven {
35 | name = "Mojang"
36 | url = uri("https://libraries.minecraft.net/")
37 | }
38 | }
39 |
40 | dependencies {
41 | compileOnly("io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT")
42 | compileOnly("com.mojang:authlib:1.5.25")
43 | implementation("org.bstats:bstats-bukkit:3.1.0")
44 | implementation("org.bstats:bstats-base:3.1.0")
45 | implementation("com.github.cryptomorin:XSeries:13.2.0")
46 | implementation("dev.notmyfault.serverlib:ServerLib:2.3.7")
47 | implementation("io.papermc:paperlib:1.0.8")
48 | compileOnly("org.apache.logging.log4j:log4j-api:2.24.3")
49 | }
50 |
51 | var buildNumber by extra("")
52 | ext {
53 | val git: Grgit = Grgit.open {
54 | dir = File("$rootDir/.git")
55 | }
56 | val commit: String? = git.head().abbreviatedId
57 | buildNumber = if (project.hasProperty("buildnumber")) {
58 | project.properties["buildnumber"] as String
59 | } else {
60 | commit.toString()
61 | }
62 | }
63 |
64 | version = String.format("%s-%s", rootProject.version, buildNumber)
65 |
66 | tasks.named("shadowJar") {
67 | archiveClassifier.set(null as String?)
68 | dependencies {
69 | relocate("com.cryptomorin.xseries", "net.arcaniax.buildersutilities.xseries") {
70 | include(dependency("com.github.cryptomorin:XSeries:13.2.0"))
71 | }
72 | relocate("org.bstats", "net.arcaniax.buildersutilities.metrics") {
73 | include(dependency("org.bstats:bstats-base:3.1.0"))
74 | include(dependency("org.bstats:bstats-bukkit:3.1.0"))
75 | }
76 | relocate("io.papermc.lib", "net.arcaniax.buildersutilities.paperlib") {
77 | include(dependency("io.papermc:paperlib:1.0.8"))
78 | }
79 | relocate("org.incendo.serverlib", "net.arcaniax.buildersutilities.serverlib") {
80 | include(dependency("dev.notmyfault.serverlib:ServerLib:2.3.7"))
81 | }
82 | }
83 | minimize()
84 | }
85 |
86 | spotless {
87 | java {
88 | licenseHeaderFile(rootProject.file("HEADER.txt"))
89 | target("**/*.java")
90 | }
91 | }
92 |
93 | tasks.named("processResources") {
94 | filesMatching("plugin.yml") {
95 | expand("version" to project.version)
96 | }
97 | }
98 |
99 | tasks.named("build").configure {
100 | dependsOn("shadowJar")
101 | }
102 |
--------------------------------------------------------------------------------
/buildersutilities-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arcaniax-Development/Builders-Utilities/94b1c371ce325544916392e07ccc78a5170e01d0/buildersutilities-logo.png
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | version=2.1.1
2 |
3 | org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
4 | org.gradle.daemon=true
5 | org.gradle.configureondemand=true
6 | org.gradle.parallel=true
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arcaniax-Development/Builders-Utilities/94b1c371ce325544916392e07ccc78a5170e01d0/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | # SPDX-License-Identifier: Apache-2.0
19 | #
20 |
21 | ##############################################################################
22 | #
23 | # Gradle start up script for POSIX generated by Gradle.
24 | #
25 | # Important for running:
26 | #
27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28 | # noncompliant, but you have some other compliant shell such as ksh or
29 | # bash, then to run this script, type that shell name before the whole
30 | # command line, like:
31 | #
32 | # ksh Gradle
33 | #
34 | # Busybox and similar reduced shells will NOT work, because this script
35 | # requires all of these POSIX shell features:
36 | # * functions;
37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39 | # * compound commands having a testable exit status, especially «case»;
40 | # * various built-in commands including «command», «set», and «ulimit».
41 | #
42 | # Important for patching:
43 | #
44 | # (2) This script targets any POSIX shell, so it avoids extensions provided
45 | # by Bash, Ksh, etc; in particular arrays are avoided.
46 | #
47 | # The "traditional" practice of packing multiple parameters into a
48 | # space-separated string is a well documented source of bugs and security
49 | # problems, so this is (mostly) avoided, by progressively accumulating
50 | # options in "$@", and eventually passing that to Java.
51 | #
52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54 | # see the in-line comments for details.
55 | #
56 | # There are tweaks for specific operating systems such as AIX, CygWin,
57 | # Darwin, MinGW, and NonStop.
58 | #
59 | # (3) This script is generated from the Groovy template
60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61 | # within the Gradle project.
62 | #
63 | # You can find Gradle at https://github.com/gradle/gradle/.
64 | #
65 | ##############################################################################
66 |
67 | # Attempt to set APP_HOME
68 |
69 | # Resolve links: $0 may be a link
70 | app_path=$0
71 |
72 | # Need this for daisy-chained symlinks.
73 | while
74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75 | [ -h "$app_path" ]
76 | do
77 | ls=$( ls -ld "$app_path" )
78 | link=${ls#*' -> '}
79 | case $link in #(
80 | /*) app_path=$link ;; #(
81 | *) app_path=$APP_HOME$link ;;
82 | esac
83 | done
84 |
85 | # This is normally unused
86 | # shellcheck disable=SC2034
87 | APP_BASE_NAME=${0##*/}
88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH="\\\"\\\""
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | if ! command -v java >/dev/null 2>&1
137 | then
138 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
139 |
140 | Please set the JAVA_HOME variable in your environment to match the
141 | location of your Java installation."
142 | fi
143 | fi
144 |
145 | # Increase the maximum file descriptors if we can.
146 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
147 | case $MAX_FD in #(
148 | max*)
149 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
150 | # shellcheck disable=SC2039,SC3045
151 | MAX_FD=$( ulimit -H -n ) ||
152 | warn "Could not query maximum file descriptor limit"
153 | esac
154 | case $MAX_FD in #(
155 | '' | soft) :;; #(
156 | *)
157 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
158 | # shellcheck disable=SC2039,SC3045
159 | ulimit -n "$MAX_FD" ||
160 | warn "Could not set maximum file descriptor limit to $MAX_FD"
161 | esac
162 | fi
163 |
164 | # Collect all arguments for the java command, stacking in reverse order:
165 | # * args from the command line
166 | # * the main class name
167 | # * -classpath
168 | # * -D...appname settings
169 | # * --module-path (only if needed)
170 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
171 |
172 | # For Cygwin or MSYS, switch paths to Windows format before running java
173 | if "$cygwin" || "$msys" ; then
174 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
175 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
176 |
177 | JAVACMD=$( cygpath --unix "$JAVACMD" )
178 |
179 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
180 | for arg do
181 | if
182 | case $arg in #(
183 | -*) false ;; # don't mess with options #(
184 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
185 | [ -e "$t" ] ;; #(
186 | *) false ;;
187 | esac
188 | then
189 | arg=$( cygpath --path --ignore --mixed "$arg" )
190 | fi
191 | # Roll the args list around exactly as many times as the number of
192 | # args, so each arg winds up back in the position where it started, but
193 | # possibly modified.
194 | #
195 | # NB: a `for` loop captures its iteration list before it begins, so
196 | # changing the positional parameters here affects neither the number of
197 | # iterations, nor the values presented in `arg`.
198 | shift # remove old arg
199 | set -- "$@" "$arg" # push replacement arg
200 | done
201 | fi
202 |
203 |
204 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
206 |
207 | # Collect all arguments for the java command:
208 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209 | # and any embedded shellness will be escaped.
210 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211 | # treated as '${Hostname}' itself on the command line.
212 |
213 | set -- \
214 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
215 | -classpath "$CLASSPATH" \
216 | -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217 | "$@"
218 |
219 | # Stop when "xargs" is not available.
220 | if ! command -v xargs >/dev/null 2>&1
221 | then
222 | die "xargs is not available"
223 | fi
224 |
225 | # Use "xargs" to parse quoted args.
226 | #
227 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
228 | #
229 | # In Bash we could simply go:
230 | #
231 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
232 | # set -- "${ARGS[@]}" "$@"
233 | #
234 | # but POSIX shell has neither arrays nor command substitution, so instead we
235 | # post-process each arg (as a line of input to sed) to backslash-escape any
236 | # character that might be a shell metacharacter, then use eval to reverse
237 | # that process (while maintaining the separation between arguments), and wrap
238 | # the whole thing up as a single "set" statement.
239 | #
240 | # This will of course break if any of these variables contains a newline or
241 | # an unmatched quote.
242 | #
243 |
244 | eval "set -- $(
245 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
246 | xargs -n1 |
247 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
248 | tr '\n' ' '
249 | )" '"$@"'
250 |
251 | exec "$JAVACMD" "$@"
252 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "extends": [
4 | "config:base",
5 | ":semanticCommitsDisabled"
6 | ],
7 | "labels": ["Renovate"],
8 | "rebaseWhen": "conflicted",
9 | "ignoreDeps": ["log4j-bom"],
10 | "schedule": ["on the first day of the month"],
11 | "automerge": true
12 | }
13 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "Builders-Utilities"
2 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/BuildersUtilities.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities;
20 |
21 | import io.papermc.lib.PaperLib;
22 | import net.arcaniax.buildersutilities.commands.system.CommandForwarder;
23 | import net.arcaniax.buildersutilities.listeners.BlockBreakListener;
24 | import net.arcaniax.buildersutilities.listeners.BlockPhysicsListener;
25 | import net.arcaniax.buildersutilities.listeners.ExplosionListener;
26 | import net.arcaniax.buildersutilities.listeners.IronTrapdoorListener;
27 | import net.arcaniax.buildersutilities.listeners.LeafDecayListener;
28 | import net.arcaniax.buildersutilities.listeners.PlayerInteractListener;
29 | import net.arcaniax.buildersutilities.listeners.PlayerMoveListener;
30 | import net.arcaniax.buildersutilities.listeners.PlayerQuitAndJoinListener;
31 | import net.arcaniax.buildersutilities.listeners.TeleportListener;
32 | import net.arcaniax.buildersutilities.listeners.TerracottaInteractListener;
33 | import net.arcaniax.buildersutilities.listeners.WeatherChangeListener;
34 | import net.arcaniax.buildersutilities.menus.inv.InventoryManager;
35 | import net.arcaniax.buildersutilities.utils.BannerUtil;
36 | import net.arcaniax.buildersutilities.utils.CustomConfig;
37 | import org.bstats.bukkit.Metrics;
38 | import org.bukkit.ChatColor;
39 | import org.bukkit.command.Command;
40 | import org.bukkit.command.CommandExecutor;
41 | import org.bukkit.command.CommandSender;
42 | import org.bukkit.plugin.java.JavaPlugin;
43 | import org.incendo.serverlib.ServerLib;
44 |
45 | public final class BuildersUtilities extends JavaPlugin {
46 |
47 | public static final String MSG_PREFIX = ChatColor.DARK_AQUA + "Builders-Utilities > " + ChatColor.AQUA;
48 | public static final String MSG_NO_PERMISSION = MSG_PREFIX + ChatColor.AQUA + "You do not have access to this command. Lacking permission: " + ChatColor.RED;
49 | public static final String MSG_ERROR = MSG_PREFIX + ChatColor.DARK_RED + "Error: " + ChatColor.RED;
50 | private static final int BSTATS_ID = 5168;
51 | private static BuildersUtilities instance;
52 | private Settings settings;
53 | private NoClipManager noClipManager;
54 |
55 | private InventoryManager inventoryManager;
56 |
57 | public static BuildersUtilities getInstance() {
58 | return instance;
59 | }
60 |
61 | @Override
62 | public void onEnable() {
63 | instance = this;
64 |
65 | this.settings = new Settings(new CustomConfig(this, "config.yml"));
66 |
67 | this.noClipManager = new NoClipManager(this);
68 | this.noClipManager.start();
69 |
70 | this.inventoryManager = new InventoryManager(this);
71 | this.inventoryManager.init();
72 |
73 | BannerUtil.addColors();
74 | BannerUtil.addPatterns();
75 |
76 | Metrics metrics = new Metrics(this, BSTATS_ID);
77 |
78 | // Check if we are in a safe environment
79 | ServerLib.checkUnsafeForks();
80 | ServerLib.checkJavaLTS();
81 | PaperLib.suggestPaper(this);
82 |
83 | this.getServer().getPluginManager().registerEvents(new BlockBreakListener(), this);
84 | this.getServer().getPluginManager().registerEvents(new BlockPhysicsListener(), this);
85 | this.getServer().getPluginManager().registerEvents(new ExplosionListener(), this);
86 | this.getServer().getPluginManager().registerEvents(new IronTrapdoorListener(), this);
87 | this.getServer().getPluginManager().registerEvents(new LeafDecayListener(), this);
88 | this.getServer().getPluginManager().registerEvents(new PlayerInteractListener(), this);
89 | this.getServer().getPluginManager().registerEvents(new PlayerMoveListener(), this);
90 | this.getServer().getPluginManager().registerEvents(new PlayerQuitAndJoinListener(), this);
91 | this.getServer().getPluginManager().registerEvents(new TeleportListener(), this);
92 | this.getServer().getPluginManager().registerEvents(new TerracottaInteractListener(), this);
93 | this.getServer().getPluginManager().registerEvents(new WeatherChangeListener(), this);
94 |
95 | CommandForwarder executor = new CommandForwarder();
96 |
97 | CommandExecutor commandExecutor = new CommandExecutor() {
98 | @Override
99 | public boolean onCommand(
100 | CommandSender commandSender, Command command, String s,
101 | String[] strings
102 | ) {
103 | String[] commandArgs = new String[strings.length + 1];
104 | commandArgs[0] = s;
105 | System.arraycopy(strings, 0, commandArgs, 1, strings.length);
106 | executor.onCommand(commandSender, command, s, commandArgs);
107 | return true;
108 | }
109 | };
110 |
111 | getCommand("butil").setExecutor(commandExecutor);
112 | getCommand("banner").setExecutor(commandExecutor);
113 | getCommand("banner").setExecutor(commandExecutor);
114 | getCommand("armorcolor").setExecutor(commandExecutor);
115 | getCommand("secretblocks").setExecutor(commandExecutor);
116 | getCommand("blocks").setExecutor(commandExecutor);
117 | getCommand("n").setExecutor(commandExecutor);
118 | getCommand("nc").setExecutor(commandExecutor);
119 | getCommand("/cuboid").setExecutor(commandExecutor);
120 | getCommand("/convex").setExecutor(commandExecutor);
121 | getCommand("/s").setExecutor(commandExecutor);
122 | getCommand("/r").setExecutor(commandExecutor);
123 | getCommand("/f").setExecutor(commandExecutor);
124 | getCommand("/pa").setExecutor(commandExecutor);
125 | getCommand("/c").setExecutor(commandExecutor);
126 | getCommand("ws").setExecutor(commandExecutor);
127 | getCommand("fs").setExecutor(commandExecutor);
128 | getCommand("af").setExecutor(commandExecutor);
129 | getCommand("advfly").setExecutor(commandExecutor);
130 | getCommand("/derot").setExecutor(commandExecutor);
131 | getCommand("/scale").setExecutor(commandExecutor);
132 | getCommand("/twist").setExecutor(commandExecutor);
133 | }
134 |
135 | public Settings getSettings() {
136 | return settings;
137 | }
138 |
139 | public NoClipManager getNoClipManager() {
140 | return noClipManager;
141 | }
142 |
143 | public InventoryManager getInventoryManager() {
144 | return inventoryManager;
145 | }
146 |
147 |
148 | }
149 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/NoClipManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities;
20 |
21 | import org.bukkit.Bukkit;
22 | import org.bukkit.GameMode;
23 | import org.bukkit.entity.Player;
24 | import org.bukkit.plugin.java.JavaPlugin;
25 | import org.checkerframework.checker.nullness.qual.NonNull;
26 |
27 | import java.util.HashSet;
28 | import java.util.Set;
29 | import java.util.UUID;
30 |
31 | public class NoClipManager {
32 |
33 | public static Set noClipPlayerIds = new HashSet<>();
34 | private final JavaPlugin javaPlugin;
35 |
36 | public NoClipManager(
37 | final @NonNull JavaPlugin javaPlugin
38 | ) {
39 | this.javaPlugin = javaPlugin;
40 | }
41 |
42 | public void start() {
43 | Bukkit.getScheduler().runTaskTimer(javaPlugin, this::checkForBlocks, 1L, 1L);
44 | }
45 |
46 | private void checkForBlocks() {
47 | for (final UUID id : noClipPlayerIds) {
48 | final Player p = javaPlugin.getServer().getPlayer(id);
49 |
50 | if (p == null || !p.isOnline()) {
51 | continue;
52 | }
53 |
54 | final boolean noClip;
55 | if (p.getGameMode() == GameMode.CREATIVE) {
56 | if (p.getLocation().add(0, -0.1, 0).getBlock().getType().isSolid() && p.isSneaking()) {
57 | noClip = true;
58 | } else {
59 | noClip = this.shouldNoClip(p);
60 | }
61 |
62 | if (noClip) {
63 | p.setGameMode(GameMode.SPECTATOR);
64 | }
65 | } else if (p.getGameMode() == GameMode.SPECTATOR) {
66 | if (p.getLocation().add(0, -0.1, 0).getBlock().getType().isSolid()) {
67 | noClip = true;
68 | } else {
69 | noClip = this.shouldNoClip(p);
70 | }
71 |
72 | if (!noClip) {
73 | p.setGameMode(GameMode.CREATIVE);
74 | }
75 | }
76 | }
77 | }
78 |
79 | private boolean shouldNoClip(final Player player) {
80 | return player.getLocation().add(+0.4, 0, 0).getBlock().getType().isSolid()
81 | || player.getLocation().add(-0.4, 0, 0).getBlock().getType().isSolid()
82 | || player.getLocation().add(0, 0, +0.4).getBlock().getType().isSolid()
83 | || player.getLocation().add(0, 0, -0.4).getBlock().getType().isSolid()
84 | || player.getLocation().add(+0.4, 1, 0).getBlock().getType().isSolid()
85 | || player.getLocation().add(-0.4, 1, 0).getBlock().getType().isSolid()
86 | || player.getLocation().add(0, 1, +0.4).getBlock().getType().isSolid()
87 | || player.getLocation().add(0, 1, -0.4).getBlock().getType().isSolid()
88 | || player.getLocation().add(0, +1.9, 0).getBlock().getType().isSolid();
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/Settings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities;
20 |
21 | import net.arcaniax.buildersutilities.utils.CustomConfig;
22 |
23 | public class Settings {
24 |
25 | public static boolean disableWeatherChanges;
26 | public static boolean disableRedstone;
27 | public static boolean disablePhysics;
28 | public static boolean disableGravityPhysics;
29 | public static boolean disableExplosions;
30 | public static boolean disableSoilTrample;
31 | public static boolean disableLeavesDecay;
32 | public static boolean fixAttackSpeed;
33 | public static boolean preventDragonEggTeleport;
34 | public static boolean sendErrorMessages;
35 | public static boolean sendDebugMessages;
36 |
37 | private final CustomConfig customConfig;
38 |
39 | public Settings(CustomConfig customConfig) {
40 | this.customConfig = customConfig;
41 | reloadSettings();
42 | }
43 |
44 | public void reloadSettings() {
45 | disableWeatherChanges = customConfig.get("disable-weather-changes", Boolean.class, true);
46 | disableRedstone = customConfig.get("disable-redstone", Boolean.class, false);
47 | disablePhysics = customConfig.get("disable-physics", Boolean.class, true);
48 | disableGravityPhysics = customConfig.get("disable-gravity-physics", Boolean.class, false);
49 | disableExplosions = customConfig.get("disable-explosions", Boolean.class, true);
50 | disableSoilTrample = customConfig.get("disable-soil-trample", Boolean.class, true);
51 | disableLeavesDecay = customConfig.get("disable-leaves-decay", Boolean.class, true);
52 | fixAttackSpeed = customConfig.get("fix-attackspeed", Boolean.class, false);
53 | preventDragonEggTeleport = customConfig.get("prevent-dragon-egg-teleport", Boolean.class, true);
54 | sendErrorMessages = customConfig.get("send-error-messages", Boolean.class, true);
55 | sendDebugMessages = customConfig.get("send-debug-messages", Boolean.class, false);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/AdvancedFlyCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import net.arcaniax.buildersutilities.listeners.PlayerMoveListener;
25 | import org.bukkit.ChatColor;
26 | import org.bukkit.entity.Player;
27 |
28 | public class AdvancedFlyCommand implements ICommand {
29 |
30 | @Override
31 | public void execute(Player player, String[] args) {
32 | if (!player.hasPermission("builders.util.advancedfly")) {
33 | if (Settings.sendErrorMessages) {
34 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.advancedfly");
35 | }
36 | return;
37 | }
38 |
39 | if (PlayerMoveListener.togglePlayer(player)) {
40 | player.sendMessage(BuildersUtilities.MSG_PREFIX + "Advanced Fly " + ChatColor.GREEN + "enabled");
41 | } else {
42 | player.sendMessage(BuildersUtilities.MSG_PREFIX + "Advanced Fly " + ChatColor.RED + "disabled");
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/BannerCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import net.arcaniax.buildersutilities.menus.Menus;
25 | import org.bukkit.entity.Player;
26 |
27 | public class BannerCommand implements ICommand {
28 |
29 | @Override
30 | public void execute(Player player, String[] args) {
31 | if (!player.hasPermission("builders.util.banner")) {
32 | if (Settings.sendErrorMessages) {
33 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.banner");
34 | }
35 | return;
36 | }
37 |
38 | Menus.BANNER_MENU.open(player);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/ColorCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import net.arcaniax.buildersutilities.menus.Menus;
25 | import org.bukkit.entity.Player;
26 |
27 | public class ColorCommand implements ICommand {
28 |
29 | @Override
30 | public void execute(Player player, String[] args) {
31 | if (!player.hasPermission("builders.util.color")) {
32 | if (Settings.sendErrorMessages) {
33 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.color");
34 | }
35 | return;
36 | }
37 |
38 | Menus.COLOR_MENU.open(player);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/NightVisionCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.ChatColor;
25 | import org.bukkit.entity.Player;
26 | import org.bukkit.potion.PotionEffect;
27 | import org.bukkit.potion.PotionEffectType;
28 |
29 | public class NightVisionCommand implements ICommand {
30 |
31 | @Override
32 | public void execute(Player player, String[] args) {
33 | if (!player.hasPermission("builders.util.nightvision")) {
34 | if (Settings.sendErrorMessages) {
35 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.nightvision");
36 | }
37 | return;
38 | }
39 |
40 | if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
41 | player.removePotionEffect(PotionEffectType.NIGHT_VISION);
42 | player.sendMessage(BuildersUtilities.MSG_PREFIX + "Night Vision " + ChatColor.RED + "disabled");
43 | } else {
44 | player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false));
45 | player.sendMessage(BuildersUtilities.MSG_PREFIX + "Night Vision " + ChatColor.GREEN + "enabled");
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/NoClipCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.NoClipManager;
23 | import net.arcaniax.buildersutilities.Settings;
24 | import net.arcaniax.buildersutilities.commands.system.ICommand;
25 | import org.bukkit.ChatColor;
26 | import org.bukkit.GameMode;
27 | import org.bukkit.entity.Player;
28 |
29 | public class NoClipCommand implements ICommand {
30 |
31 | @Override
32 | public void execute(Player player, String[] args) {
33 | if (!player.hasPermission("builders.util.noclip")) {
34 | if (Settings.sendErrorMessages) {
35 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.noclip");
36 | }
37 | return;
38 | }
39 |
40 | if (NoClipManager.noClipPlayerIds.contains(player.getUniqueId())) {
41 | NoClipManager.noClipPlayerIds.remove(player.getUniqueId());
42 | player.sendMessage(BuildersUtilities.MSG_PREFIX + "NoClip " + ChatColor.RED + "disabled");
43 | if (player.getGameMode() == GameMode.SPECTATOR) {
44 | player.setGameMode(GameMode.CREATIVE);
45 | }
46 | } else {
47 | NoClipManager.noClipPlayerIds.add(player.getUniqueId());
48 | player.sendMessage(BuildersUtilities.MSG_PREFIX + "NoClip " + ChatColor.GREEN + "enabled");
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/SecretBlockCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import net.arcaniax.buildersutilities.menus.Menus;
25 | import org.bukkit.entity.Player;
26 |
27 | public class SecretBlockCommand implements ICommand {
28 |
29 | @Override
30 | public void execute(Player player, String[] args) {
31 | if (!player.hasPermission("builders.util.secretblocks")) {
32 | if (Settings.sendErrorMessages) {
33 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.secretblocks");
34 | }
35 | return;
36 | }
37 |
38 | Menus.SECRET_BLOCK_MENU.open(player);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/UtilsCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import net.arcaniax.buildersutilities.menus.Menus;
25 | import org.bukkit.entity.Player;
26 |
27 | public class UtilsCommand implements ICommand {
28 |
29 | @Override
30 | public void execute(Player player, String[] args) {
31 | if (!player.hasPermission("builders.util.gui")) {
32 | if (Settings.sendErrorMessages) {
33 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.gui");
34 | }
35 | return;
36 | }
37 |
38 | Menus.TOGGLE_MENU.open(player);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/ConvexSelectionAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.entity.Player;
25 |
26 | public class ConvexSelectionAliasCommand implements ICommand {
27 |
28 | @Override
29 | public void execute(Player player, String[] args) {
30 | if (!player.hasPermission("builders.util.aliases")) {
31 | if (Settings.sendErrorMessages) {
32 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
33 | }
34 | return;
35 | }
36 |
37 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/sel convex");
38 |
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/CopyAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.entity.Player;
25 |
26 | public class CopyAliasCommand implements ICommand {
27 |
28 | @Override
29 | public void execute(Player player, String[] args) {
30 | if (!player.hasPermission("builders.util.aliases")) {
31 | if (Settings.sendErrorMessages) {
32 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
33 | }
34 | return;
35 | }
36 |
37 | StringBuilder builder = new StringBuilder();
38 | if (args.length != 0) {
39 | for (String arg : args) {
40 | builder.append(arg).append(" ");
41 | }
42 | }
43 |
44 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/copy " + builder);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/CuboidSelectionAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.entity.Player;
25 |
26 | public class CuboidSelectionAliasCommand implements ICommand {
27 |
28 | @Override
29 | public void execute(Player player, String[] args) {
30 | if (!player.hasPermission("builders.util.aliases")) {
31 | if (Settings.sendErrorMessages) {
32 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
33 | }
34 | return;
35 | }
36 |
37 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/sel cuboid");
38 |
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/DeformRotateAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.ChatColor;
25 | import org.bukkit.entity.Player;
26 |
27 | public class DeformRotateAliasCommand implements ICommand {
28 |
29 | @Override
30 | public void execute(Player player, String[] args) {
31 | if (!player.hasPermission("builders.util.aliases")) {
32 | if (Settings.sendErrorMessages) {
33 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
34 | }
35 | return;
36 | }
37 |
38 | if (args.length != 2) {
39 | player.sendMessage(BuildersUtilities.MSG_PREFIX + ChatColor.RED + "//derot [axis] [degrees]");
40 | return;
41 | }
42 |
43 | int degrees;
44 | try {
45 | degrees = Integer.parseInt(args[1]);
46 | } catch (Exception e) {
47 | player.sendMessage(BuildersUtilities.MSG_PREFIX + ChatColor.RED + "//derot [axis] [degrees]");
48 | return;
49 | }
50 | // Old:
51 | // float radian = (float) (((float) degrees / (float) 360) * 2 * Math.PI);
52 |
53 | //Use the degree to radian conversion number: "0.0174533" radians per degree
54 | float radiansPerDegree = 0.0174533f;
55 | float radian = degrees * radiansPerDegree;
56 |
57 | if (args[0].equalsIgnoreCase("x")) {
58 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/deform rotate(y,z," + radian + ")");
59 | } else if (args[0].equalsIgnoreCase("y")) {
60 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/deform rotate(x,z," + radian + ")");
61 | } else if (args[0].equalsIgnoreCase("z")) {
62 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/deform rotate(x,y," + radian + ")");
63 | } else {
64 | player.sendMessage(BuildersUtilities.MSG_PREFIX + ChatColor.RED + "//derot [axis] [degrees]");
65 | }
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/FlipAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.entity.Player;
25 |
26 | public class FlipAliasCommand implements ICommand {
27 |
28 | @Override
29 | public void execute(Player player, String[] args) {
30 | if (!player.hasPermission("builders.util.aliases")) {
31 | if (Settings.sendErrorMessages) {
32 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
33 | }
34 | return;
35 | }
36 |
37 | StringBuilder builder = new StringBuilder();
38 | if (args.length != 0) {
39 | for (String arg : args) {
40 | builder.append(arg).append(" ");
41 | }
42 | }
43 |
44 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/flip " + builder);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/FlySpeedAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.entity.Player;
25 |
26 | public class FlySpeedAliasCommand implements ICommand {
27 |
28 | @Override
29 | public void execute(Player player, String[] args) {
30 | if (!player.hasPermission("builders.util.aliases")) {
31 | if (Settings.sendErrorMessages) {
32 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
33 | }
34 | return;
35 | }
36 |
37 | StringBuilder builder = new StringBuilder();
38 | if (args.length != 0) {
39 | for (String arg : args) {
40 | builder.append(arg).append(" ");
41 | }
42 | }
43 |
44 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "speed fly " + builder);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/PasteAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.entity.Player;
25 |
26 | public class PasteAliasCommand implements ICommand {
27 |
28 | @Override
29 | public void execute(Player player, String[] args) {
30 | if (!player.hasPermission("builders.util.aliases")) {
31 | if (Settings.sendErrorMessages) {
32 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
33 | }
34 | return;
35 | }
36 |
37 | StringBuilder builder = new StringBuilder();
38 | if (args.length != 0) {
39 | for (String arg : args) {
40 | builder.append(arg).append(" ");
41 | }
42 | }
43 |
44 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/paste " + builder);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/PosOneAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.entity.Player;
25 |
26 | public class PosOneAliasCommand implements ICommand {
27 |
28 | @Override
29 | public void execute(Player player, String[] args) {
30 | if (!player.hasPermission("builders.util.aliases")) {
31 | if (Settings.sendErrorMessages) {
32 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
33 | }
34 | return;
35 | }
36 |
37 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/pos1");
38 |
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/PosTwoAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.entity.Player;
25 |
26 | public class PosTwoAliasCommand implements ICommand {
27 |
28 | @Override
29 | public void execute(Player player, String[] args) {
30 | if (!player.hasPermission("builders.util.aliases")) {
31 | if (Settings.sendErrorMessages) {
32 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
33 | }
34 | return;
35 | }
36 |
37 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/pos2");
38 |
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/ReplaceAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.entity.Player;
25 |
26 | public class ReplaceAliasCommand implements ICommand {
27 |
28 | @Override
29 | public void execute(Player player, String[] args) {
30 | if (!player.hasPermission("builders.util.aliases")) {
31 | if (Settings.sendErrorMessages) {
32 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
33 | }
34 | return;
35 | }
36 |
37 | StringBuilder builder = new StringBuilder();
38 | if (args.length != 0) {
39 | for (String arg : args) {
40 | builder.append(arg).append(" ");
41 | }
42 | }
43 |
44 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/replace " + builder);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/ScaleAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.ChatColor;
25 | import org.bukkit.entity.Player;
26 |
27 | public class ScaleAliasCommand implements ICommand {
28 |
29 | @Override
30 | public void execute(Player player, String[] args) {
31 | if (!player.hasPermission("builders.util.aliases")) {
32 | if (Settings.sendErrorMessages) {
33 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
34 | }
35 | return;
36 | }
37 |
38 | if (args.length != 1) {
39 | player.sendMessage(BuildersUtilities.MSG_PREFIX + ChatColor.RED + "//scale [size]");
40 | return;
41 | }
42 |
43 | double size;
44 | try {
45 | size = Double.parseDouble(args[0]);
46 | } catch (Exception e) {
47 | player.sendMessage(BuildersUtilities.MSG_PREFIX + ChatColor.RED + "//scale [size]");
48 | return;
49 | }
50 |
51 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/deform x/=" + size + ";y/=" + size + ";z/=" + size);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/SetAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.entity.Player;
25 |
26 | public class SetAliasCommand implements ICommand {
27 |
28 | @Override
29 | public void execute(Player player, String[] args) {
30 | if (!player.hasPermission("builders.util.aliases")) {
31 | if (Settings.sendErrorMessages) {
32 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
33 | }
34 | return;
35 | }
36 |
37 | StringBuilder builder = new StringBuilder();
38 | if (args.length != 0) {
39 | for (String arg : args) {
40 | builder.append(arg).append(" ");
41 | }
42 | }
43 |
44 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/set " + builder);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/TwistAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.ChatColor;
25 | import org.bukkit.entity.Player;
26 |
27 | public class TwistAliasCommand implements ICommand {
28 |
29 | @Override
30 | public void execute(Player player, String[] args) {
31 | if (!player.hasPermission("builders.util.aliases")) {
32 | if (Settings.sendErrorMessages) {
33 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
34 | }
35 | return;
36 | }
37 |
38 | if (args.length != 2) {
39 | player.sendMessage(BuildersUtilities.MSG_PREFIX + ChatColor.RED + "//twist [axis] [degrees]");
40 | return;
41 | }
42 |
43 | int degrees;
44 | try {
45 | degrees = Integer.parseInt(args[1]);
46 | } catch (Exception e) {
47 | player.sendMessage(BuildersUtilities.MSG_PREFIX + ChatColor.RED + "//twist [axis] [degrees]");
48 | return;
49 | }
50 |
51 | float radiansPerDegree = 0.0174533f;
52 | float radian = degrees * radiansPerDegree;
53 |
54 | if (args[0].equalsIgnoreCase("x")) {
55 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/deform rotate(y,z," + radian / 2 + "*(x+1))");
56 | } else if (args[0].equalsIgnoreCase("y")) {
57 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/deform rotate(x,z," + radian / 2 + "*(y+1))");
58 | } else if (args[0].equalsIgnoreCase("z")) {
59 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "/deform rotate(x,y," + radian / 2 + "*(z+1))");
60 | } else {
61 | player.sendMessage(BuildersUtilities.MSG_PREFIX + ChatColor.RED + "//twist [axis] [degrees]");
62 | }
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/aliases/WalkSpeedAliasCommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.aliases;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.Settings;
23 | import net.arcaniax.buildersutilities.commands.system.ICommand;
24 | import org.bukkit.entity.Player;
25 |
26 | public class WalkSpeedAliasCommand implements ICommand {
27 |
28 | @Override
29 | public void execute(Player player, String[] args) {
30 | if (!player.hasPermission("builders.util.aliases")) {
31 | if (Settings.sendErrorMessages) {
32 | player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.aliases");
33 | }
34 | return;
35 | }
36 |
37 | StringBuilder builder = new StringBuilder();
38 | if (args.length != 0) {
39 | for (String arg : args) {
40 | builder.append(arg).append(" ");
41 | }
42 | }
43 |
44 | BuildersUtilities.getInstance().getServer().dispatchCommand(player, "speed walk " + builder);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/system/CommandForwarder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.system;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.commands.AdvancedFlyCommand;
23 | import net.arcaniax.buildersutilities.commands.BannerCommand;
24 | import net.arcaniax.buildersutilities.commands.ColorCommand;
25 | import net.arcaniax.buildersutilities.commands.NightVisionCommand;
26 | import net.arcaniax.buildersutilities.commands.NoClipCommand;
27 | import net.arcaniax.buildersutilities.commands.SecretBlockCommand;
28 | import net.arcaniax.buildersutilities.commands.UtilsCommand;
29 | import net.arcaniax.buildersutilities.commands.aliases.ConvexSelectionAliasCommand;
30 | import net.arcaniax.buildersutilities.commands.aliases.CopyAliasCommand;
31 | import net.arcaniax.buildersutilities.commands.aliases.CuboidSelectionAliasCommand;
32 | import net.arcaniax.buildersutilities.commands.aliases.DeformRotateAliasCommand;
33 | import net.arcaniax.buildersutilities.commands.aliases.FlipAliasCommand;
34 | import net.arcaniax.buildersutilities.commands.aliases.FlySpeedAliasCommand;
35 | import net.arcaniax.buildersutilities.commands.aliases.PasteAliasCommand;
36 | import net.arcaniax.buildersutilities.commands.aliases.PosOneAliasCommand;
37 | import net.arcaniax.buildersutilities.commands.aliases.PosTwoAliasCommand;
38 | import net.arcaniax.buildersutilities.commands.aliases.ReplaceAliasCommand;
39 | import net.arcaniax.buildersutilities.commands.aliases.ScaleAliasCommand;
40 | import net.arcaniax.buildersutilities.commands.aliases.SetAliasCommand;
41 | import net.arcaniax.buildersutilities.commands.aliases.TwistAliasCommand;
42 | import net.arcaniax.buildersutilities.commands.aliases.WalkSpeedAliasCommand;
43 | import org.bukkit.command.Command;
44 | import org.bukkit.command.CommandExecutor;
45 | import org.bukkit.command.CommandSender;
46 | import org.bukkit.entity.Player;
47 |
48 | import java.util.Arrays;
49 | import java.util.HashMap;
50 | import java.util.Map;
51 |
52 | public class CommandForwarder implements CommandExecutor {
53 |
54 | private final Map commands;
55 |
56 | public CommandForwarder() {
57 | commands = new HashMap<>();
58 | registerCommand(new AdvancedFlyCommand(), "af", "advfly");
59 | registerCommand(new BannerCommand(), "banner", "bm");
60 | registerCommand(new ColorCommand(), "color", "ac", "armorcolor");
61 | registerCommand(new SecretBlockCommand(), "blocks", "secretblocks");
62 | registerCommand(new NoClipCommand(), "noclip", "nc");
63 | registerCommand(new NightVisionCommand(), "nv", "nightvision", "n");
64 | registerCommand(new UtilsCommand(), "butil", "bu");
65 | registerCommand(new PosOneAliasCommand(), "/p1", "/1");
66 | registerCommand(new PosTwoAliasCommand(), "/p2", "/2");
67 | registerCommand(new CuboidSelectionAliasCommand(), "/cub");
68 | registerCommand(new ConvexSelectionAliasCommand(), "/con");
69 | registerCommand(new SetAliasCommand(), "/s");
70 | registerCommand(new ReplaceAliasCommand(), "/r");
71 | registerCommand(new PasteAliasCommand(), "/pa");
72 | registerCommand(new FlipAliasCommand(), "/f");
73 | registerCommand(new CopyAliasCommand(), "/c");
74 | registerCommand(new DeformRotateAliasCommand(), "/derot");
75 | registerCommand(new TwistAliasCommand(), "/twist");
76 | registerCommand(new ScaleAliasCommand(), "/scale");
77 | registerCommand(new WalkSpeedAliasCommand(), "walkspeed", "ws");
78 | registerCommand(new FlySpeedAliasCommand(), "flyspeed", "fs");
79 | }
80 |
81 | private void registerCommand(ICommand iCommand, String... aliases) {
82 | for (String alias : aliases) {
83 | commands.put(alias.toLowerCase(), iCommand);
84 | }
85 | }
86 |
87 | @Override
88 | public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
89 | //Make it player-only
90 | Player player = sender instanceof Player ? ((Player) sender) : null;
91 | if (player == null) {
92 | sender.sendMessage(BuildersUtilities.MSG_ERROR + "Sorry this command can only be used by a player.");
93 | return false;
94 | }
95 |
96 | ICommand iCommand = commands.get(s.toLowerCase());
97 | if (iCommand != null) {
98 | iCommand.execute(player, Arrays.copyOfRange(args, 1, args.length));
99 | }
100 | return true;
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/commands/system/ICommand.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.commands.system;
20 |
21 | import org.bukkit.entity.Player;
22 |
23 | public interface ICommand {
24 |
25 | void execute(Player player, String[] args);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/listeners/BlockBreakListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.listeners;
20 |
21 | import org.bukkit.GameMode;
22 | import org.bukkit.Location;
23 | import org.bukkit.Material;
24 | import org.bukkit.block.Block;
25 | import org.bukkit.block.data.type.Slab;
26 | import org.bukkit.entity.Player;
27 | import org.bukkit.event.EventHandler;
28 | import org.bukkit.event.EventPriority;
29 | import org.bukkit.event.Listener;
30 | import org.bukkit.event.block.BlockBreakEvent;
31 |
32 | import java.util.HashSet;
33 | import java.util.Set;
34 | import java.util.UUID;
35 |
36 | public class BlockBreakListener implements Listener {
37 |
38 | public static Set slabIds;
39 |
40 | public BlockBreakListener() {
41 | slabIds = new HashSet<>();
42 | }
43 |
44 | @EventHandler(priority = EventPriority.MONITOR)
45 | public void onBlockBreak(BlockBreakEvent e) {
46 | if (e.isCancelled()) {
47 | return;
48 | }
49 | if (slabIds.contains(e.getPlayer().getUniqueId())) {
50 | return;
51 | }
52 | if (!e.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
53 | return;
54 | }
55 | if (!e.getPlayer().hasPermission("builders.util.slabs")) {
56 | return;
57 | }
58 | Material type = e.getPlayer().getInventory().getItemInMainHand().getType();
59 | if (type.toString().toLowerCase().contains("slab")) {
60 | if (e.isCancelled()) {
61 | return;
62 | }
63 | if (e.getBlock().getType().toString().toLowerCase().contains("slab")) {
64 | if (isTop(e.getPlayer(), e.getBlock())) {
65 | Slab blockdata = (Slab) e.getBlock().getBlockData();
66 | if (blockdata.getType().equals(Slab.Type.DOUBLE)) {
67 | blockdata.setType(Slab.Type.BOTTOM);
68 | e.getBlock().setBlockData(blockdata, true);
69 | e.setCancelled(true);
70 | }
71 | } else {
72 | Slab blockdata = (Slab) e.getBlock().getBlockData();
73 | if (blockdata.getType().equals(Slab.Type.DOUBLE)) {
74 | blockdata.setType(Slab.Type.TOP);
75 | e.getBlock().setBlockData(blockdata, true);
76 | e.setCancelled(true);
77 | }
78 | }
79 | }
80 | }
81 | }
82 |
83 | private boolean isTop(Player player, Block block) {
84 | Location start = player.getEyeLocation().clone();
85 | while ((!start.getBlock().equals(block)) && start.distance(player.getEyeLocation()) < 6) {
86 | start.add(player.getLocation().getDirection().multiply(0.05));
87 | }
88 | final double y = start.getY();
89 | return Math.round(y) > y;
90 | }
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/listeners/BlockPhysicsListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.listeners;
20 |
21 | import net.arcaniax.buildersutilities.Settings;
22 | import net.arcaniax.buildersutilities.utils.LogManagerCompat;
23 | import org.apache.logging.log4j.Logger;
24 | import org.bukkit.Material;
25 | import org.bukkit.event.EventHandler;
26 | import org.bukkit.event.Listener;
27 | import org.bukkit.event.block.BlockPhysicsEvent;
28 |
29 | public class BlockPhysicsListener implements Listener {
30 |
31 | private static final Logger logger = LogManagerCompat.getLogger();
32 |
33 | @EventHandler
34 | public void onPhysics(BlockPhysicsEvent e) {
35 | if (e.getSourceBlock().getType().equals(Material.AIR)) {
36 | if (e.getChangedType().equals(Material.AIR)) {
37 | if (e.getBlock().getLocation().getBlockY() > 0) {
38 | if (e
39 | .getBlock()
40 | .getLocation()
41 | .add(0, -1, 0)
42 | .getBlock()
43 | .getType()
44 | .name()
45 | .toLowerCase()
46 | .contains("grass_block")) {
47 | return;
48 | }
49 | }
50 | }
51 | }
52 | if (e.getSourceBlock().getType().name().toLowerCase().contains("snow")) {
53 | if (e.getBlock().getLocation().getBlockY() > 0) {
54 | if (e.getBlock().getLocation().add(0, -1, 0).getBlock().getType().name().toLowerCase().contains("grass_block")) {
55 | return;
56 | }
57 | }
58 | }
59 | String blockName = e.getChangedType().name().toLowerCase();
60 | try {
61 | if (blockName.contains("chest") ||
62 | blockName.contains("stair") ||
63 | blockName.contains("fence") ||
64 | blockName.contains("pane") ||
65 | blockName.contains("wall") ||
66 | blockName.contains("bar") ||
67 | blockName.contains("door")) {
68 | return;
69 | }
70 | } catch (Exception ex) {
71 | return;
72 | }
73 | if (!Settings.disableRedstone) {
74 | if (blockName.contains("redstone") ||
75 | blockName.contains("daylight") ||
76 | blockName.contains("diode") ||
77 | blockName.contains("note") ||
78 | blockName.contains("lever") ||
79 | blockName.contains("button") ||
80 | blockName.contains("command") ||
81 | blockName.contains("tripwire") ||
82 | blockName.contains("plate") ||
83 | blockName.contains("string") ||
84 | blockName.contains("piston") ||
85 | blockName.contains("observer")) {
86 | if (!e.getBlock().getType().name().contains("air")) {
87 | return;
88 | }
89 | }
90 | }
91 |
92 | if (e.getChangedType().hasGravity()) {
93 | if (Settings.disableGravityPhysics) {
94 | e.setCancelled(true);
95 | if (Settings.sendDebugMessages) {
96 | logger.info(
97 | "Gravity physics were cancelled because disable-gravity-physics: true");
98 | }
99 |
100 | }
101 | } else {
102 | if (Settings.disablePhysics) {
103 | e.setCancelled(true);
104 | if (Settings.sendDebugMessages) {
105 | logger.info(
106 | "Physics were cancelled because disable-physics: true");
107 | }
108 | }
109 | }
110 |
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/listeners/ExplosionListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.listeners;
20 |
21 | import net.arcaniax.buildersutilities.Settings;
22 | import net.arcaniax.buildersutilities.utils.LogManagerCompat;
23 | import org.apache.logging.log4j.Logger;
24 | import org.bukkit.event.EventHandler;
25 | import org.bukkit.event.Listener;
26 | import org.bukkit.event.entity.EntityExplodeEvent;
27 |
28 | public class ExplosionListener implements Listener {
29 |
30 | private static final Logger logger = LogManagerCompat.getLogger();
31 |
32 | @EventHandler
33 | public void onExplode(EntityExplodeEvent event) {
34 | if (Settings.disableExplosions) {
35 | event.setCancelled(true);
36 | if (Settings.sendDebugMessages) {
37 | logger.info(
38 | "Explosion was cancelled because disable-explosions: true");
39 | }
40 | }
41 | }
42 |
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/listeners/IronTrapdoorListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.listeners;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import org.bukkit.Bukkit;
23 | import org.bukkit.GameMode;
24 | import org.bukkit.Material;
25 | import org.bukkit.Sound;
26 | import org.bukkit.block.Block;
27 | import org.bukkit.block.data.type.TrapDoor;
28 | import org.bukkit.event.EventHandler;
29 | import org.bukkit.event.EventPriority;
30 | import org.bukkit.event.Listener;
31 | import org.bukkit.event.block.Action;
32 | import org.bukkit.event.player.PlayerInteractEvent;
33 | import org.bukkit.inventory.EquipmentSlot;
34 |
35 | import java.util.HashSet;
36 | import java.util.Set;
37 | import java.util.UUID;
38 |
39 | public class IronTrapdoorListener implements Listener {
40 |
41 | public static Set ironTrapdoorIds;
42 |
43 | public IronTrapdoorListener() {
44 | ironTrapdoorIds = new HashSet<>();
45 | }
46 |
47 | @EventHandler(priority = EventPriority.MONITOR)
48 | public void ironTrapDoorInteract(final PlayerInteractEvent e) {
49 | if (e.isCancelled()) {
50 | return;
51 | }
52 | if (ironTrapdoorIds.contains(e.getPlayer().getUniqueId())) {
53 | return;
54 | }
55 | if (!e.getPlayer().getGameMode().equals(GameMode.CREATIVE)) {
56 | return;
57 | }
58 | if (!e.getPlayer().hasPermission("builders.util.trapdoor")) {
59 | return;
60 | }
61 | if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
62 | return;
63 | }
64 | if (!e.getClickedBlock().getType().equals(Material.IRON_TRAPDOOR)) {
65 | return;
66 | }
67 | if (!e.getHand().equals(EquipmentSlot.HAND)) {
68 | return;
69 | }
70 | if (e.getPlayer().isSneaking()) {
71 | return;
72 | }
73 | Bukkit.getScheduler().runTaskLater(BuildersUtilities.getInstance(), () -> {
74 | Block b = e.getClickedBlock();
75 | TrapDoor trapDoor = (TrapDoor) b.getBlockData();
76 | trapDoor.setOpen(!trapDoor.isOpen());
77 | b.setBlockData(trapDoor);
78 | b.getWorld().playSound(b.getLocation(), trapDoor.isOpen() ? Sound.BLOCK_IRON_TRAPDOOR_CLOSE : Sound.BLOCK_IRON_TRAPDOOR_OPEN, 1F, 1F);
79 | e.getPlayer().swingMainHand();
80 | }, 0L);
81 | e.setCancelled(true);
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/listeners/LeafDecayListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.listeners;
20 |
21 | import net.arcaniax.buildersutilities.Settings;
22 | import net.arcaniax.buildersutilities.utils.LogManagerCompat;
23 | import org.apache.logging.log4j.Logger;
24 | import org.bukkit.event.EventHandler;
25 | import org.bukkit.event.Listener;
26 | import org.bukkit.event.block.LeavesDecayEvent;
27 |
28 | public class LeafDecayListener implements Listener {
29 |
30 | private static final Logger logger = LogManagerCompat.getLogger();
31 |
32 | @EventHandler
33 | public void onLeafDecay(LeavesDecayEvent event) {
34 | if (Settings.disableLeavesDecay) {
35 | event.setCancelled(true);
36 | if (Settings.sendDebugMessages) {
37 | logger.info(
38 | "Leaf decay was cancelled because disable-leaves-decay: true");
39 | }
40 | }
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/listeners/PlayerInteractListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.listeners;
20 |
21 | import net.arcaniax.buildersutilities.Settings;
22 | import net.arcaniax.buildersutilities.utils.LogManagerCompat;
23 | import org.apache.logging.log4j.Logger;
24 | import org.bukkit.Material;
25 | import org.bukkit.block.Block;
26 | import org.bukkit.event.EventHandler;
27 | import org.bukkit.event.EventPriority;
28 | import org.bukkit.event.Listener;
29 | import org.bukkit.event.block.Action;
30 | import org.bukkit.event.player.PlayerInteractEvent;
31 |
32 | public class PlayerInteractListener implements Listener {
33 |
34 | private static final Logger logger = LogManagerCompat.getLogger();
35 |
36 | @EventHandler(priority = EventPriority.MONITOR)
37 | public void onDragonEggTP(PlayerInteractEvent event) {
38 | if (event.isCancelled()) {
39 | return;
40 | }
41 | if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
42 | && event.getClickedBlock().getType().equals(Material.DRAGON_EGG)
43 | && Settings.preventDragonEggTeleport
44 | && !(event.getPlayer().isSneaking()
45 | && (!event.getPlayer().getInventory().getItemInOffHand().getType().isAir()
46 | || !event.getPlayer().getInventory().getItemInMainHand().getType().isAir()))
47 | ) {
48 | event.setCancelled(true);
49 | if (Settings.sendDebugMessages) {
50 | logger.info(
51 | "Dragon egg teleport was cancelled because prevent-dragon-egg-teleport: true");
52 | }
53 | }
54 | }
55 |
56 | @EventHandler
57 | public void onPlayerInteract(PlayerInteractEvent event) {
58 | if (event.isCancelled()) {
59 | return;
60 | }
61 | if (Settings.disableSoilTrample) {
62 | if (event.getAction() == Action.PHYSICAL) {
63 | Block block = event.getClickedBlock();
64 | if (block != null && block.getType() == Material.FARMLAND) {
65 | event.setUseInteractedBlock(org.bukkit.event.Event.Result.DENY);
66 | event.setCancelled(true);
67 | if (Settings.sendDebugMessages) {
68 | logger.info(
69 | "Soil trampling was cancelled because disable-soil-trample: true");
70 | }
71 | }
72 | }
73 | }
74 |
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/listeners/PlayerMoveListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.listeners;
20 |
21 | import org.bukkit.entity.Player;
22 | import org.bukkit.event.EventHandler;
23 | import org.bukkit.event.EventPriority;
24 | import org.bukkit.event.Listener;
25 | import org.bukkit.event.player.PlayerMoveEvent;
26 | import org.bukkit.util.Vector;
27 |
28 | import java.util.ArrayList;
29 | import java.util.HashMap;
30 | import java.util.HashSet;
31 | import java.util.List;
32 | import java.util.Set;
33 | import java.util.UUID;
34 |
35 | public class PlayerMoveListener implements Listener {
36 |
37 | private static final List slower = new ArrayList<>();
38 | private static final List slower2 = new ArrayList<>();
39 | public static Set enabledPlayers = new HashSet<>();
40 | private final HashMap lastVelocity = new HashMap<>();
41 |
42 | public static boolean togglePlayer(Player p) {
43 | if (enabledPlayers.contains(p.getUniqueId())) {
44 | enabledPlayers.remove(p.getUniqueId());
45 | return false;
46 | } else {
47 | enabledPlayers.add(p.getUniqueId());
48 | return true;
49 | }
50 | }
51 |
52 | @EventHandler(priority = EventPriority.LOWEST)
53 | public void onMove(final PlayerMoveEvent e) {
54 | if (e.getPlayer().isFlying()) {
55 | if (!enabledPlayers.contains(e.getPlayer().getUniqueId())) {
56 | return;
57 | }
58 | Double speed = e.getFrom().clone().add(0, -e.getFrom().getY(), 0).distance(e
59 | .getTo()
60 | .clone()
61 | .add(0, -e.getTo().getY(), 0));
62 |
63 | if (Math.abs(e.getFrom().getYaw() - e.getTo().getYaw()) > 2.5) {
64 | return;
65 | }
66 | if (Math.abs(e.getFrom().getPitch() - e.getTo().getPitch()) > 2.5) {
67 | return;
68 | }
69 | if (lastVelocity.containsKey(e.getPlayer().getName())) {
70 | Double lastSpeed = lastVelocity.get(e.getPlayer().getName());
71 | if (speed * 1.3 < lastSpeed) {
72 | if (slower.contains(e.getPlayer().getName())) {
73 | if (slower2.contains(e.getPlayer().getName())) {
74 | Vector v = e.getPlayer().getVelocity().clone();
75 | v.setX(0);
76 | v.setZ(0);
77 | e.getPlayer().setVelocity(v);
78 | lastVelocity.put(e.getPlayer().getName(), 0.0);
79 | //No more if slower.contains** as if e.getPlayer().getName() isn't there, it won't get removed (:
80 | slower.remove(e.getPlayer().getName());
81 | slower2.remove(e.getPlayer().getName());
82 | } else {
83 | slower2.add(e.getPlayer().getName());
84 | }
85 | } else {
86 | slower.add(e.getPlayer().getName());
87 | }
88 | } else if (speed > lastSpeed) {
89 | lastVelocity.put(e.getPlayer().getName(), speed);
90 | slower.remove(e.getPlayer().getName());
91 | slower2.remove(e.getPlayer().getName());
92 | }
93 | } else {
94 | lastVelocity.put(e.getPlayer().getName(), speed);
95 | slower.remove(e.getPlayer().getName());
96 | }
97 | }
98 | }
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/listeners/PlayerQuitAndJoinListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.listeners;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.NoClipManager;
23 | import net.arcaniax.buildersutilities.Settings;
24 | import org.bukkit.attribute.Attribute;
25 | import org.bukkit.attribute.AttributeInstance;
26 | import org.bukkit.entity.Player;
27 | import org.bukkit.event.EventHandler;
28 | import org.bukkit.event.Listener;
29 | import org.bukkit.event.player.PlayerJoinEvent;
30 | import org.bukkit.event.player.PlayerQuitEvent;
31 |
32 | public class PlayerQuitAndJoinListener implements Listener {
33 |
34 | @EventHandler
35 | public void onPlayerQuit(PlayerQuitEvent event) {
36 | Player player = event.getPlayer();
37 | NoClipManager.noClipPlayerIds.remove(player.getUniqueId());
38 | }
39 |
40 | @EventHandler
41 | public void onPlayerJoin(PlayerJoinEvent event) {
42 | AttributeInstance attribute = event.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED);
43 | if (attribute == null) {
44 | return;
45 | }
46 |
47 | if (Settings.fixAttackSpeed) {
48 | attribute.setBaseValue(1024.0D);
49 | } else if (attribute.getBaseValue() == 1024.0D) {
50 | attribute.setBaseValue(4.0D);
51 | }
52 | event.getPlayer().saveData();
53 |
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/listeners/TeleportListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.listeners;
20 |
21 | import net.arcaniax.buildersutilities.Settings;
22 | import net.arcaniax.buildersutilities.utils.LogManagerCompat;
23 | import org.apache.logging.log4j.Logger;
24 | import org.bukkit.event.EventHandler;
25 | import org.bukkit.event.Listener;
26 | import org.bukkit.event.player.PlayerTeleportEvent;
27 |
28 | public class TeleportListener implements Listener {
29 |
30 | private static final Logger logger = LogManagerCompat.getLogger();
31 |
32 | @EventHandler
33 | public void onTeleport(PlayerTeleportEvent event) {
34 | if (event.isCancelled()) {
35 | return;
36 | }
37 | if (event.getCause().equals(PlayerTeleportEvent.TeleportCause.SPECTATE)) {
38 | if (!event.getPlayer().hasPermission("builders.util.tpgm3")) {
39 | event.setCancelled(true);
40 | if (Settings.sendDebugMessages) {
41 | logger.info(
42 | "Spectate teleport was cancelled because {} lacks the permission builders.util.tpgm3",
43 | event.getPlayer()
44 | );
45 | }
46 | }
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/listeners/TerracottaInteractListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.listeners;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import org.bukkit.Bukkit;
23 | import org.bukkit.Material;
24 | import org.bukkit.block.Block;
25 | import org.bukkit.block.BlockFace;
26 | import org.bukkit.block.data.Directional;
27 | import org.bukkit.event.EventHandler;
28 | import org.bukkit.event.EventPriority;
29 | import org.bukkit.event.Listener;
30 | import org.bukkit.event.block.Action;
31 | import org.bukkit.event.player.PlayerInteractEvent;
32 | import org.bukkit.inventory.EquipmentSlot;
33 |
34 | import java.util.HashSet;
35 | import java.util.Set;
36 | import java.util.UUID;
37 |
38 | public class TerracottaInteractListener implements Listener {
39 |
40 | public static Set terracottaIds;
41 |
42 | public TerracottaInteractListener() {
43 | terracottaIds = new HashSet<>();
44 | }
45 |
46 | @EventHandler(priority = EventPriority.MONITOR)
47 | public void GlazedTerracottaInteract(PlayerInteractEvent event) {
48 | if (event.isCancelled()) {
49 | return;
50 | }
51 | if (terracottaIds.contains(event.getPlayer().getUniqueId())) {
52 | return;
53 | }
54 | if (!event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
55 | return;
56 | }
57 | if (!event.getHand().equals(EquipmentSlot.HAND)) {
58 | return;
59 | }
60 | if (!event.getClickedBlock().getType().name().contains("GLAZED")) {
61 | return;
62 | }
63 | if (!event.getPlayer().isSneaking()) {
64 | return;
65 | }
66 | if (!event.getPlayer().hasPermission("builders.util.terracotta")) {
67 | return;
68 | }
69 | Material type = event.getPlayer().getInventory().getItemInHand().getType();
70 | if (!(type.equals(Material.AIR))) {
71 | return;
72 | }
73 | Bukkit.getScheduler().runTaskLater(BuildersUtilities.getInstance(), () -> {
74 | Block block = event.getClickedBlock();
75 | Directional directional = (Directional) block.getBlockData();
76 | if (directional.getFacing().equals(BlockFace.NORTH)) {
77 | directional.setFacing(BlockFace.EAST);
78 | } else if (directional.getFacing().equals(BlockFace.EAST)) {
79 | directional.setFacing(BlockFace.SOUTH);
80 | } else if (directional.getFacing().equals(BlockFace.SOUTH)) {
81 | directional.setFacing(BlockFace.WEST);
82 | } else if (directional.getFacing().equals(BlockFace.WEST)) {
83 | directional.setFacing(BlockFace.NORTH);
84 | }
85 | block.setBlockData(directional);
86 | }, 0L);
87 | event.setCancelled(true);
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/listeners/WeatherChangeListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.listeners;
20 |
21 | import net.arcaniax.buildersutilities.Settings;
22 | import net.arcaniax.buildersutilities.utils.LogManagerCompat;
23 | import org.apache.logging.log4j.Logger;
24 | import org.bukkit.event.EventHandler;
25 | import org.bukkit.event.Listener;
26 | import org.bukkit.event.weather.WeatherChangeEvent;
27 |
28 | public class WeatherChangeListener implements Listener {
29 |
30 | private static final Logger logger = LogManagerCompat.getLogger();
31 |
32 | @EventHandler
33 | public void onWeather(WeatherChangeEvent e) {
34 | if (Settings.disableWeatherChanges) {
35 | e.setCancelled(true);
36 | if (Settings.sendDebugMessages) {
37 | logger.info(
38 | "Weather changing was cancelled because disable-weather-changes: true");
39 | }
40 | }
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/Menus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus;
20 |
21 | import net.arcaniax.buildersutilities.BuildersUtilities;
22 | import net.arcaniax.buildersutilities.menus.bannermenus.BannerColorMenuProvider;
23 | import net.arcaniax.buildersutilities.menus.bannermenus.BannerMenuProvider;
24 | import net.arcaniax.buildersutilities.menus.bannermenus.BannerPatternMenuProvider;
25 | import net.arcaniax.buildersutilities.menus.inv.InventoryListener;
26 | import net.arcaniax.buildersutilities.menus.inv.SmartInventory;
27 | import org.bukkit.Bukkit;
28 | import org.bukkit.ChatColor;
29 | import org.bukkit.entity.Player;
30 | import org.bukkit.event.inventory.InventoryCloseEvent;
31 |
32 | public class Menus {
33 |
34 | private static final InventoryListener removeGhostItemsListener =
35 | new InventoryListener<>(InventoryCloseEvent.class, inventoryCloseEvent -> {
36 | Bukkit.getScheduler().runTaskLater(BuildersUtilities.getInstance(), () -> {
37 | ((Player) inventoryCloseEvent.getPlayer()).updateInventory();
38 | }, 1L);
39 | });
40 |
41 | public static final SmartInventory BANNER_MENU = SmartInventory.builder()
42 | .manager(BuildersUtilities.getInstance().getInventoryManager())
43 | .id("buildersutilsbanner")
44 | .provider(new BannerMenuProvider())
45 | .size(6, 9)
46 | .listener(removeGhostItemsListener)
47 | .title(ChatColor.BLUE + "Select a base color")
48 | .closeable(true)
49 | .build();
50 |
51 | public static final SmartInventory BANNER_MENU_COLOR = SmartInventory.builder()
52 | .manager(BuildersUtilities.getInstance().getInventoryManager())
53 | .id("buildersutilsbannercolor")
54 | .provider(new BannerColorMenuProvider())
55 | .size(6, 9)
56 | .listener(removeGhostItemsListener)
57 | .title(ChatColor.BLUE + "Select a color")
58 | .closeable(true)
59 | .build();
60 |
61 | public static final SmartInventory BANNER_MENU_PATTERN = SmartInventory.builder()
62 | .manager(BuildersUtilities.getInstance().getInventoryManager())
63 | .id("buildersutilsbannerpattern")
64 | .provider(new BannerPatternMenuProvider())
65 | .size(6, 9)
66 | .listener(removeGhostItemsListener)
67 | .title(ChatColor.BLUE + "Select a pattern")
68 | .closeable(true)
69 | .build();
70 |
71 | public static final SmartInventory COLOR_MENU = SmartInventory.builder()
72 | .manager(BuildersUtilities.getInstance().getInventoryManager())
73 | .id("buildersutilscolor")
74 | .provider(new ColorMenuProvider())
75 | .size(6, 9)
76 | .listener(removeGhostItemsListener)
77 | .title(ChatColor.BLUE + "Armor Color Creator")
78 | .closeable(true)
79 | .build();
80 |
81 | public static final SmartInventory SECRET_BLOCK_MENU = SmartInventory.builder()
82 | .manager(BuildersUtilities.getInstance().getInventoryManager())
83 | .id("buildersutilssecretblock")
84 | .provider(new SecretBlockMenuProvider())
85 | .size(1, 9)
86 | .listener(removeGhostItemsListener)
87 | .title(ChatColor.BLUE + "Secret Blocks")
88 | .closeable(true)
89 | .build();
90 |
91 | public static final SmartInventory TOGGLE_MENU = SmartInventory.builder()
92 | .manager(BuildersUtilities.getInstance().getInventoryManager())
93 | .id("buildersutilstoggle")
94 | .provider(new UtilitiesMenuProvider())
95 | .size(3, 9)
96 | .listener(removeGhostItemsListener)
97 | .title(ChatColor.BLUE + "Builder's Utilities")
98 | .closeable(true)
99 | .build();
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/SecretBlockMenuProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus;
20 |
21 | import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
22 | import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
23 | import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
24 | import net.arcaniax.buildersutilities.utils.Items;
25 | import org.bukkit.ChatColor;
26 | import org.bukkit.Material;
27 | import org.bukkit.entity.Player;
28 | import org.bukkit.inventory.ItemStack;
29 |
30 | public class SecretBlockMenuProvider implements InventoryProvider {
31 |
32 | private static final ItemStack SPAWNER = Items.create(Material.SPAWNER, ChatColor.BLUE + "Spawner", "");
33 | private static final ItemStack BARRIER = Items.create(Material.BARRIER, ChatColor.RED + "Barrier", "");
34 | private static final ItemStack DRAGON_EGG = Items.create(
35 | Material.DRAGON_EGG,
36 | ChatColor.LIGHT_PURPLE + "Dragon Egg",
37 | ""
38 | );
39 | private static final ItemStack STRUCTURE_VOID = Items.create(
40 | Material.STRUCTURE_VOID,
41 | ChatColor.DARK_AQUA + "Structure Void",
42 | ""
43 | );
44 | private static final ItemStack DEBUG_STICK = Items.create(
45 | Material.DEBUG_STICK,
46 | ChatColor.AQUA + "Debug Stick",
47 | "&7Only works as operator in creative."
48 | );
49 | private static final ItemStack STRUCTURE_BLOCK = Items.create(
50 | Material.STRUCTURE_BLOCK,
51 | ChatColor.AQUA + "Structure Block",
52 | ""
53 | );
54 | private static final ItemStack LIGHT = Items.create(
55 | "LIGHT",
56 | ChatColor.GOLD + "Light Block",
57 | ""
58 | );
59 |
60 | @Override
61 | public void init(Player player, InventoryContents contents) {
62 | contents.set(0, 0, ClickableItem.of(DEBUG_STICK, inventoryClickEvent -> player.getInventory().addItem(DEBUG_STICK)));
63 | contents.set(0, 1, ClickableItem.of(SPAWNER, inventoryClickEvent -> player.getInventory().addItem(SPAWNER)));
64 | contents.set(0, 2, ClickableItem.of(BARRIER, inventoryClickEvent -> player.getInventory().addItem(BARRIER)));
65 | contents.set(
66 | 0,
67 | 3,
68 | ClickableItem.of(STRUCTURE_VOID, inventoryClickEvent -> player.getInventory().addItem(STRUCTURE_VOID))
69 | );
70 | contents.set(0, 4, ClickableItem.of(DRAGON_EGG, inventoryClickEvent -> player.getInventory().addItem(DRAGON_EGG)));
71 | contents.set(
72 | 0,
73 | 5,
74 | ClickableItem.of(STRUCTURE_BLOCK, inventoryClickEvent -> player.getInventory().addItem(STRUCTURE_BLOCK))
75 | );
76 | if (LIGHT != null) {
77 | contents.set(0, 6, ClickableItem.of(LIGHT, inventoryClickEvent -> player.getInventory().addItem(LIGHT)));
78 | }
79 | }
80 |
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/bannermenus/BannerColorMenuProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus.bannermenus;
20 |
21 | import net.arcaniax.buildersutilities.menus.Menus;
22 | import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
23 | import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
24 | import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
25 | import net.arcaniax.buildersutilities.utils.BannerUtil;
26 | import net.arcaniax.buildersutilities.utils.Items;
27 | import org.apache.commons.lang3.StringUtils;
28 | import org.bukkit.DyeColor;
29 | import org.bukkit.Material;
30 | import org.bukkit.entity.Player;
31 | import org.bukkit.inventory.ItemStack;
32 | import org.bukkit.inventory.meta.ItemMeta;
33 |
34 | import java.util.ArrayList;
35 |
36 | public class BannerColorMenuProvider implements InventoryProvider {
37 |
38 |
39 | private static final ItemStack grayPane = Items
40 | .create(Material.GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", "");
41 | private static final ItemStack randomizeHead = Items.createHead(
42 | "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzk3OTU1NDYyZTRlNTc2NjY0NDk5YWM0YTFjNTcyZjYxNDNmMTlhZDJkNjE5NDc3NjE5OGY4ZDEzNmZkYjIifX19",
43 | 1,
44 | "&7Click to randomise",
45 | ""
46 | );
47 | // private static final ItemStack currentColor = BannerUtil.createBanner("&a", 1, DyeColor.WHITE, "");
48 | private static final ItemStack closeButton = Items
49 | .create(Material.BARRIER, (short) 0, 1, "&cClick to close", "");
50 | private static final ItemStack whiteBanner = Items
51 | .create(Material.WHITE_BANNER, (short) 0, 1, "&c", "");
52 |
53 | @Override
54 | public void init(Player player, InventoryContents contents) {
55 | contents.fill(ClickableItem.empty(grayPane));
56 | contents.set(0, 1, ClickableItem.of(randomizeHead, inventoryClickEvent -> selectRandomColor(player)));
57 | contents.set(
58 | 0,
59 | 4,
60 | ClickableItem.of(BannerUtil.currentBanner.get(player.getUniqueId()), inventoryClickEvent -> getBanner(player))
61 | );
62 | contents.set(0, 7, ClickableItem.of(closeButton, inventoryClickEvent -> contents.inventory().close(player)));
63 |
64 | int row = 2;
65 | int column = 1;
66 | for (DyeColor color : BannerUtil.allColors) {
67 | contents.set(
68 | row,
69 | column,
70 | ClickableItem.of(
71 | BannerUtil.createDye("&3" + StringUtils.capitalize(color
72 | .toString()
73 | .toLowerCase()
74 | .replace("_", " ")), color, "&7__&7click to select"),
75 | inventoryClickEvent -> selectColor(player, color)
76 | )
77 | );
78 | column++;
79 | if (column == 9) {
80 | column = 1;
81 | row++;
82 | }
83 | }
84 |
85 | // contents.set(0, 1, ClickableItem.of(randomizeHead, NULL));
86 | // contents.set(0, 4, ClickableItem.empty(currentColor));
87 | // contents.set(0, 7, ClickableItem.of(closeButton, inventoryClickEvent -> contents.inventory().close(player)));
88 | // for (int x = 19; x < 27; x++) {
89 | // ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 19).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 19), "&7__&7click to select");
90 | // contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
91 | // }
92 | // for (int x = 28; x < 36; x++) {
93 | // ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 28 + 8).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 28 + 8), "&7__&7click to select");
94 | // contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
95 | // }
96 | }
97 |
98 | private void selectRandomColor(Player player) {
99 | DyeColor dyeColor = BannerUtil.getRandomDye();
100 | BannerUtil.selectedColor.put(player.getUniqueId(), dyeColor);
101 | Menus.BANNER_MENU_PATTERN.open(player);
102 | }
103 |
104 | private void selectColor(Player player, DyeColor dyeColor) {
105 | BannerUtil.selectedColor.put(player.getUniqueId(), dyeColor);
106 | Menus.BANNER_MENU_PATTERN.open(player);
107 | }
108 |
109 | private void getBanner(Player player) {
110 | ItemStack banner = BannerUtil.currentBanner.get(player.getUniqueId());
111 | ItemMeta meta = banner.getItemMeta();
112 | meta.setDisplayName("");
113 | meta.setLore(new ArrayList<>());
114 | banner.setItemMeta(meta);
115 | player.getInventory().addItem(banner);
116 | player.closeInventory();
117 | BannerUtil.currentBanner.remove(player.getUniqueId());
118 | }
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/bannermenus/BannerMenuProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus.bannermenus;
20 |
21 | import net.arcaniax.buildersutilities.menus.Menus;
22 | import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
23 | import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
24 | import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
25 | import net.arcaniax.buildersutilities.utils.BannerUtil;
26 | import net.arcaniax.buildersutilities.utils.Items;
27 | import org.apache.commons.lang3.StringUtils;
28 | import org.bukkit.DyeColor;
29 | import org.bukkit.Material;
30 | import org.bukkit.entity.Player;
31 | import org.bukkit.inventory.ItemStack;
32 |
33 | public class BannerMenuProvider implements InventoryProvider {
34 |
35 | private static final ItemStack grayPane = Items
36 | .create(Material.GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", "");
37 | private static final ItemStack randomizeHead = Items.createHead(
38 | "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzk3OTU1NDYyZTRlNTc2NjY0NDk5YWM0YTFjNTcyZjYxNDNmMTlhZDJkNjE5NDc3NjE5OGY4ZDEzNmZkYjIifX19",
39 | 1,
40 | "&7Click to randomise",
41 | ""
42 | );
43 | // private static final ItemStack currentColor = BannerUtil.createBanner("&a", 1, DyeColor.WHITE, "");
44 | private static final ItemStack closeButton = Items
45 | .create(Material.BARRIER, (short) 0, 1, "&cClick to close", "");
46 | private static final ItemStack whiteBanner = Items
47 | .create(Material.WHITE_BANNER, (short) 0, 1, "&c", "");
48 |
49 | @Override
50 | public void init(Player player, InventoryContents contents) {
51 | contents.fill(ClickableItem.empty(grayPane));
52 | contents.set(0, 1, ClickableItem.of(randomizeHead, inventoryClickEvent -> selectRandomColor(player)));
53 | contents.set(0, 4, ClickableItem.empty(whiteBanner));
54 | contents.set(0, 7, ClickableItem.of(closeButton, inventoryClickEvent -> contents.inventory().close(player)));
55 |
56 | int row = 2;
57 | int column = 1;
58 | for (DyeColor color : BannerUtil.allColors) {
59 | contents.set(
60 | row,
61 | column,
62 | ClickableItem.of(
63 | BannerUtil.createBanner("&3" + StringUtils.capitalize(color
64 | .toString()
65 | .toLowerCase()
66 | .replace("_", " ")), color, "&7__&7Click to select"),
67 | inventoryClickEvent -> selectColor(player, color)
68 | )
69 | );
70 | column++;
71 | if (column == 9) {
72 | column = 1;
73 | row++;
74 | }
75 | }
76 |
77 | // contents.set(0, 1, ClickableItem.of(randomizeHead, NULL));
78 | // contents.set(0, 4, ClickableItem.empty(currentColor));
79 | // contents.set(0, 7, ClickableItem.of(closeButton, inventoryClickEvent -> contents.inventory().close(player)));
80 | // for (int x = 19; x < 27; x++) {
81 | // ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 19).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 19), "&7__&7click to select");
82 | // contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
83 | // }
84 | // for (int x = 28; x < 36; x++) {
85 | // ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 28 + 8).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 28 + 8), "&7__&7click to select");
86 | // contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
87 | // }
88 | }
89 |
90 | private void selectRandomColor(Player player) {
91 | DyeColor dyeColor = BannerUtil.getRandomDye();
92 | BannerUtil.currentBanner.put(
93 | player.getUniqueId(),
94 | BannerUtil.createBanner("&6Banner", dyeColor, "&7__&7Click to get banner")
95 | );
96 | Menus.BANNER_MENU_COLOR.open(player);
97 | }
98 |
99 | private void selectColor(Player player, DyeColor dyeColor) {
100 | BannerUtil.currentBanner.put(
101 | player.getUniqueId(),
102 | BannerUtil.createBanner("&6Banner", dyeColor, "&7__&7Click to get banner")
103 | );
104 | Menus.BANNER_MENU_COLOR.open(player);
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/bannermenus/BannerPatternMenuProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus.bannermenus;
20 |
21 | import net.arcaniax.buildersutilities.menus.Menus;
22 | import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
23 | import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
24 | import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
25 | import net.arcaniax.buildersutilities.utils.BannerUtil;
26 | import net.arcaniax.buildersutilities.utils.Items;
27 | import org.apache.commons.lang3.StringUtils;
28 | import org.bukkit.Material;
29 | import org.bukkit.block.banner.Pattern;
30 | import org.bukkit.block.banner.PatternType;
31 | import org.bukkit.entity.Player;
32 | import org.bukkit.inventory.ItemStack;
33 | import org.bukkit.inventory.meta.ItemMeta;
34 |
35 | import java.util.ArrayList;
36 | import java.util.List;
37 |
38 | public class BannerPatternMenuProvider implements InventoryProvider {
39 |
40 | private static final ItemStack grayPane = Items
41 | .create(Material.GRAY_STAINED_GLASS_PANE, (short) 0, 1, "&7", "");
42 | private static final ItemStack randomizeHead = Items.createHead(
43 | "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzk3OTU1NDYyZTRlNTc2NjY0NDk5YWM0YTFjNTcyZjYxNDNmMTlhZDJkNjE5NDc3NjE5OGY4ZDEzNmZkYjIifX19",
44 | 1,
45 | "&7Click to randomise",
46 | ""
47 | );
48 | // private static final ItemStack currentColor = BannerUtil.createBanner("&a", 1, DyeColor.WHITE, "");
49 | private static final ItemStack closeButton = Items
50 | .create(Material.BARRIER, (short) 0, 1, "&cClick to close", "");
51 | private static final ItemStack whiteBanner = Items
52 | .create(Material.WHITE_BANNER, (short) 0, 1, "&c", "");
53 |
54 | @Override
55 | public void init(Player player, InventoryContents contents) {
56 | contents.fill(ClickableItem.empty(grayPane));
57 | contents.set(0, 1, ClickableItem.of(randomizeHead, inventoryClickEvent -> selectRandomPattern(player)));
58 | contents.set(
59 | 0,
60 | 4,
61 | ClickableItem.of(BannerUtil.currentBanner.get(player.getUniqueId()), inventoryClickEvent -> getBanner(player))
62 | );
63 | contents.set(0, 7, ClickableItem.of(closeButton, inventoryClickEvent -> contents.inventory().close(player)));
64 |
65 | int row = 1;
66 | int column = 0;
67 | for (PatternType pattern : BannerUtil.allPatterns) {
68 | List patterns = new ArrayList<>();
69 | patterns.add(new Pattern(BannerUtil.selectedColor.get(player.getUniqueId()), pattern));
70 | contents.set(
71 | row,
72 | column,
73 | ClickableItem.of(BannerUtil.createBanner(
74 | "&3" + StringUtils.capitalize(pattern
75 | .toString()
76 | .toLowerCase()
77 | .replace("_", " ")),
78 | BannerUtil.getOppositeBaseColor(BannerUtil.selectedColor.get(player.getUniqueId())),
79 | "&7__&7click to select",
80 | patterns
81 | ), inventoryClickEvent -> selectPattern(player, pattern))
82 | );
83 | column++;
84 | if (column == 9) {
85 | column = 0;
86 | row++;
87 | }
88 | }
89 |
90 | // contents.set(0, 1, ClickableItem.of(randomizeHead, NULL));
91 | // contents.set(0, 4, ClickableItem.empty(currentColor));
92 | // contents.set(0, 7, ClickableItem.of(closeButton, inventoryClickEvent -> contents.inventory().close(player)));
93 | // for (int x = 19; x < 27; x++) {
94 | // ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 19).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 19), "&7__&7click to select");
95 | // contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
96 | // }
97 | // for (int x = 28; x < 36; x++) {
98 | // ItemStack banner = BannerUtil.createBanner("&3" + BannerUtil.allColors.get(x - 28 + 8).toString().toLowerCase().replace("_", " "), 1, BannerUtil.allColors.get(x - 28 + 8), "&7__&7click to select");
99 | // contents.set(x / 9, x % 9, ClickableItem.of(banner, NULL));
100 | // }
101 | }
102 |
103 | private void selectRandomPattern(Player player) {
104 | ItemStack banner = BannerUtil.currentBanner.get(player.getUniqueId());
105 |
106 |
107 | PatternType pattern = BannerUtil.getRandomPattern();
108 | BannerUtil.currentBanner.put(player.getUniqueId(), BannerUtil.addPattern(
109 | banner, new Pattern(BannerUtil.selectedColor.get(player.getUniqueId()), pattern)));
110 | if (BannerUtil.getPatterns(banner).size() == 15) {
111 | getBanner(player);
112 | } else {
113 | Menus.BANNER_MENU_COLOR.open(player);
114 | }
115 |
116 | }
117 |
118 | private void selectPattern(Player player, PatternType patternType) {
119 | ItemStack banner = BannerUtil.currentBanner.get(player.getUniqueId());
120 |
121 | BannerUtil.currentBanner.put(player.getUniqueId(), BannerUtil.addPattern(
122 | banner, new Pattern(BannerUtil.selectedColor.get(player.getUniqueId()), patternType)));
123 | if (BannerUtil.getPatterns(banner).size() == 15) {
124 | getBanner(player);
125 | } else {
126 | Menus.BANNER_MENU_COLOR.open(player);
127 | }
128 | }
129 |
130 | private void getBanner(Player player) {
131 | ItemStack banner = BannerUtil.currentBanner.get(player.getUniqueId());
132 | ItemMeta meta = banner.getItemMeta();
133 | meta.setDisplayName("");
134 | meta.setLore(new ArrayList<>());
135 | banner.setItemMeta(meta);
136 | player.getInventory().addItem(banner);
137 | player.closeInventory();
138 | BannerUtil.currentBanner.remove(player.getUniqueId());
139 | }
140 |
141 | }
142 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/inv/ClickableItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus.inv;
20 |
21 | import org.bukkit.event.inventory.InventoryClickEvent;
22 | import org.bukkit.inventory.ItemStack;
23 |
24 | import java.util.function.Consumer;
25 |
26 | public class ClickableItem {
27 |
28 | private final ItemStack item;
29 | private final Consumer consumer;
30 |
31 | private ClickableItem(ItemStack item, Consumer consumer) {
32 | this.item = item;
33 | this.consumer = consumer;
34 | }
35 |
36 | public static ClickableItem empty(ItemStack item) {
37 | return of(item, e -> {
38 | });
39 | }
40 |
41 | public static ClickableItem of(ItemStack item, Consumer consumer) {
42 | return new ClickableItem(item, consumer);
43 | }
44 |
45 | public void run(InventoryClickEvent e) {
46 | consumer.accept(e);
47 | }
48 |
49 | public ItemStack getItem() {
50 | return item;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/inv/InventoryListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus.inv;
20 |
21 | import java.util.function.Consumer;
22 |
23 | public class InventoryListener {
24 |
25 | private final Class type;
26 | private final Consumer consumer;
27 |
28 | public InventoryListener(Class type, Consumer consumer) {
29 | this.type = type;
30 | this.consumer = consumer;
31 | }
32 |
33 | public void accept(T t) {
34 | consumer.accept(t);
35 | }
36 |
37 | public Class getType() {
38 | return type;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/inv/SmartInventory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus.inv;
20 |
21 | import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
22 | import net.arcaniax.buildersutilities.menus.inv.content.InventoryProvider;
23 | import net.arcaniax.buildersutilities.menus.inv.opener.InventoryOpener;
24 | import org.bukkit.entity.Player;
25 | import org.bukkit.event.Event;
26 | import org.bukkit.event.inventory.InventoryCloseEvent;
27 | import org.bukkit.event.inventory.InventoryType;
28 | import org.bukkit.inventory.Inventory;
29 |
30 | import java.util.ArrayList;
31 | import java.util.List;
32 | import java.util.Optional;
33 |
34 | @SuppressWarnings("unchecked")
35 | public class SmartInventory {
36 |
37 | private final InventoryManager manager;
38 | private String id;
39 | private String title;
40 | private InventoryType type;
41 | private int rows, columns;
42 | private boolean closeable;
43 | private InventoryProvider provider;
44 | private SmartInventory parent;
45 | private List> listeners;
46 |
47 | private SmartInventory(InventoryManager manager) {
48 | this.manager = manager;
49 | }
50 |
51 | public static Builder builder() {
52 | return new Builder();
53 | }
54 |
55 | public Inventory open(Player player) {
56 | return open(player, 0);
57 | }
58 |
59 | public Inventory open(Player player, int page) {
60 | Optional oldInv = this.manager.getInventory(player);
61 |
62 | oldInv.ifPresent(inv -> {
63 | inv.getListeners().stream()
64 | .filter(listener -> listener.getType() == InventoryCloseEvent.class)
65 | .forEach(listener -> ((InventoryListener) listener)
66 | .accept(new InventoryCloseEvent(player.getOpenInventory())));
67 |
68 | this.manager.setInventory(player, null);
69 | });
70 |
71 | InventoryContents contents = new InventoryContents.Impl(this, player);
72 | contents.pagination().page(page);
73 |
74 | this.manager.setContents(player, contents);
75 | this.provider.init(player, contents);
76 |
77 | InventoryOpener opener = this.manager.findOpener(type)
78 | .orElseThrow(() -> new IllegalStateException(
79 | "No opener found for the inventory type " + type.name()));
80 | Inventory handle = opener.open(this, player);
81 |
82 | this.manager.setInventory(player, this);
83 |
84 | return handle;
85 | }
86 |
87 | @SuppressWarnings("unchecked")
88 | public void close(Player player) {
89 | listeners.stream()
90 | .filter(listener -> listener.getType() == InventoryCloseEvent.class)
91 | .forEach(listener -> ((InventoryListener) listener)
92 | .accept(new InventoryCloseEvent(player.getOpenInventory())));
93 |
94 | this.manager.setInventory(player, null);
95 | player.closeInventory();
96 |
97 | this.manager.setContents(player, null);
98 | }
99 |
100 | public String getId() {
101 | return id;
102 | }
103 |
104 | public String getTitle() {
105 | return title;
106 | }
107 |
108 | public InventoryType getType() {
109 | return type;
110 | }
111 |
112 | public int getRows() {
113 | return rows;
114 | }
115 |
116 | public int getColumns() {
117 | return columns;
118 | }
119 |
120 | public boolean isCloseable() {
121 | return closeable;
122 | }
123 |
124 | public void setCloseable(boolean closeable) {
125 | this.closeable = closeable;
126 | }
127 |
128 | public InventoryProvider getProvider() {
129 | return provider;
130 | }
131 |
132 | public Optional getParent() {
133 | return Optional.ofNullable(parent);
134 | }
135 |
136 | public InventoryManager getManager() {
137 | return manager;
138 | }
139 |
140 | List> getListeners() {
141 | return listeners;
142 | }
143 |
144 | public static final class Builder {
145 |
146 | private final List> listeners = new ArrayList<>();
147 | private String id = "unknown";
148 | private String title = "";
149 | private InventoryType type = InventoryType.CHEST;
150 | private int rows = 6, columns = 9;
151 | private boolean closeable = true;
152 | private InventoryManager manager;
153 | private InventoryProvider provider;
154 | private SmartInventory parent;
155 |
156 | private Builder() {
157 | }
158 |
159 | public Builder id(String id) {
160 | this.id = id;
161 | return this;
162 | }
163 |
164 | public Builder title(String title) {
165 | this.title = title;
166 | return this;
167 | }
168 |
169 | public Builder type(InventoryType type) {
170 | this.type = type;
171 | return this;
172 | }
173 |
174 | public Builder size(int rows, int columns) {
175 | this.rows = rows;
176 | this.columns = columns;
177 | return this;
178 | }
179 |
180 | public Builder closeable(boolean closeable) {
181 | this.closeable = closeable;
182 | return this;
183 | }
184 |
185 | public Builder provider(InventoryProvider provider) {
186 | this.provider = provider;
187 | return this;
188 | }
189 |
190 | public Builder parent(SmartInventory parent) {
191 | this.parent = parent;
192 | return this;
193 | }
194 |
195 | public Builder listener(InventoryListener extends Event> listener) {
196 | this.listeners.add(listener);
197 | return this;
198 | }
199 |
200 | public Builder manager(InventoryManager manager) {
201 | this.manager = manager;
202 | return this;
203 | }
204 |
205 | public SmartInventory build() {
206 | if (this.provider == null) {
207 | throw new IllegalStateException(
208 | "The provider of the SmartInventory.Builder must be set.");
209 | }
210 |
211 | InventoryManager manager = this.manager;
212 |
213 | if (manager == null) {
214 | throw new IllegalStateException(
215 | "The manager of the SmartInventory.Builder must be set, "
216 | + "or the SmartInvs should be loaded as a plugin.");
217 | }
218 |
219 | SmartInventory inv = new SmartInventory(manager);
220 | inv.id = this.id;
221 | inv.title = this.title;
222 | inv.type = this.type;
223 | inv.rows = this.rows;
224 | inv.columns = this.columns;
225 | inv.closeable = this.closeable;
226 | inv.provider = this.provider;
227 | inv.parent = this.parent;
228 | inv.listeners = this.listeners;
229 |
230 | return inv;
231 | }
232 |
233 | }
234 |
235 | }
236 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/inv/content/InventoryProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus.inv.content;
20 |
21 | import org.bukkit.entity.Player;
22 |
23 | public interface InventoryProvider {
24 |
25 | void init(Player player, InventoryContents contents);
26 |
27 | default void update(Player player, InventoryContents contents) {
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/inv/content/Pagination.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus.inv.content;
20 |
21 | import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
22 |
23 | import java.util.Arrays;
24 |
25 | public interface Pagination {
26 |
27 | ClickableItem[] getPageItems();
28 |
29 | int getPage();
30 |
31 | Pagination page(int page);
32 |
33 | boolean isFirst();
34 |
35 | boolean isLast();
36 |
37 | Pagination first();
38 |
39 | Pagination previous();
40 |
41 | Pagination next();
42 |
43 | Pagination last();
44 |
45 | Pagination addToIterator(SlotIterator iterator);
46 |
47 | Pagination setItems(ClickableItem... items);
48 |
49 | Pagination setItemsPerPage(int itemsPerPage);
50 |
51 |
52 | class Impl implements Pagination {
53 |
54 | private int currentPage;
55 |
56 | private ClickableItem[] items = new ClickableItem[0];
57 | private int itemsPerPage = 5;
58 |
59 | @Override
60 | public ClickableItem[] getPageItems() {
61 | return Arrays.copyOfRange(
62 | items,
63 | currentPage * itemsPerPage,
64 | (currentPage + 1) * itemsPerPage
65 | );
66 | }
67 |
68 | @Override
69 | public int getPage() {
70 | return this.currentPage;
71 | }
72 |
73 | @Override
74 | public Pagination page(int page) {
75 | this.currentPage = page;
76 | return this;
77 | }
78 |
79 | @Override
80 | public boolean isFirst() {
81 | return this.currentPage == 0;
82 | }
83 |
84 | @Override
85 | public boolean isLast() {
86 | int pageCount = (int) Math.ceil((double) this.items.length / this.itemsPerPage);
87 | return this.currentPage >= pageCount - 1;
88 | }
89 |
90 | @Override
91 | public Pagination first() {
92 | this.currentPage = 0;
93 | return this;
94 | }
95 |
96 | @Override
97 | public Pagination previous() {
98 | if (!isFirst()) {
99 | this.currentPage--;
100 | }
101 |
102 | return this;
103 | }
104 |
105 | @Override
106 | public Pagination next() {
107 | if (!isLast()) {
108 | this.currentPage++;
109 | }
110 |
111 | return this;
112 | }
113 |
114 | @Override
115 | public Pagination last() {
116 | this.currentPage = this.items.length / this.itemsPerPage;
117 | return this;
118 | }
119 |
120 | @Override
121 | public Pagination addToIterator(SlotIterator iterator) {
122 | for (ClickableItem item : getPageItems()) {
123 | iterator.next().set(item);
124 |
125 | if (iterator.ended()) {
126 | break;
127 | }
128 | }
129 |
130 | return this;
131 | }
132 |
133 | @Override
134 | public Pagination setItems(ClickableItem... items) {
135 | this.items = items;
136 | return this;
137 | }
138 |
139 | @Override
140 | public Pagination setItemsPerPage(int itemsPerPage) {
141 | this.itemsPerPage = itemsPerPage;
142 | return this;
143 | }
144 |
145 | }
146 |
147 | }
148 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/inv/content/SlotIterator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus.inv.content;
20 |
21 | import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
22 | import net.arcaniax.buildersutilities.menus.inv.SmartInventory;
23 |
24 | import java.util.HashSet;
25 | import java.util.Optional;
26 | import java.util.Set;
27 |
28 | public interface SlotIterator {
29 |
30 | Optional get();
31 |
32 | SlotIterator set(ClickableItem item);
33 |
34 | SlotIterator previous();
35 |
36 | SlotIterator next();
37 |
38 | SlotIterator blacklist(int row, int column);
39 |
40 | SlotIterator blacklist(SlotPos slotPos);
41 |
42 | int row();
43 |
44 | SlotIterator row(int row);
45 |
46 | int column();
47 |
48 | SlotIterator column(int column);
49 |
50 | boolean started();
51 |
52 | boolean ended();
53 |
54 | boolean doesAllowOverride();
55 |
56 | SlotIterator allowOverride(boolean override);
57 |
58 | enum Type {
59 | HORIZONTAL,
60 | VERTICAL
61 | }
62 |
63 | class Impl implements SlotIterator {
64 |
65 | private final InventoryContents contents;
66 | private final SmartInventory inv;
67 |
68 | private final Type type;
69 | private final Set blacklisted = new HashSet<>();
70 | private boolean started = false;
71 | private boolean allowOverride = true;
72 | private int row, column;
73 |
74 | public Impl(
75 | InventoryContents contents, SmartInventory inv,
76 | Type type, int startRow, int startColumn
77 | ) {
78 |
79 | this.contents = contents;
80 | this.inv = inv;
81 |
82 | this.type = type;
83 |
84 | this.row = startRow;
85 | this.column = startColumn;
86 | }
87 |
88 | public Impl(
89 | InventoryContents contents, SmartInventory inv,
90 | Type type
91 | ) {
92 |
93 | this(contents, inv, type, 0, 0);
94 | }
95 |
96 | @Override
97 | public Optional get() {
98 | return contents.get(row, column);
99 | }
100 |
101 | @Override
102 | public SlotIterator set(ClickableItem item) {
103 | if (canPlace()) {
104 | contents.set(row, column, item);
105 | }
106 |
107 | return this;
108 | }
109 |
110 | @Override
111 | public SlotIterator previous() {
112 | if (row == 0 && column == 0) {
113 | this.started = true;
114 | return this;
115 | }
116 |
117 | do {
118 | if (!this.started) {
119 | this.started = true;
120 | } else {
121 | switch (type) {
122 | case HORIZONTAL:
123 | column--;
124 |
125 | if (column == 0) {
126 | column = inv.getColumns() - 1;
127 | row--;
128 | }
129 | break;
130 | case VERTICAL:
131 | row--;
132 |
133 | if (row == 0) {
134 | row = inv.getRows() - 1;
135 | column--;
136 | }
137 | break;
138 | }
139 | }
140 | }
141 | while (!canPlace() && (row != 0 || column != 0));
142 |
143 | return this;
144 | }
145 |
146 | @Override
147 | public SlotIterator next() {
148 | if (ended()) {
149 | this.started = true;
150 | return this;
151 | }
152 |
153 | do {
154 | if (!this.started) {
155 | this.started = true;
156 | } else {
157 | switch (type) {
158 | case HORIZONTAL:
159 | column = ++column % inv.getColumns();
160 |
161 | if (column == 0) {
162 | row++;
163 | }
164 | break;
165 | case VERTICAL:
166 | row = ++row % inv.getRows();
167 |
168 | if (row == 0) {
169 | column++;
170 | }
171 | break;
172 | }
173 | }
174 | }
175 | while (!canPlace() && !ended());
176 |
177 | return this;
178 | }
179 |
180 | @Override
181 | public SlotIterator blacklist(int row, int column) {
182 | this.blacklisted.add(SlotPos.of(row, column));
183 | return this;
184 | }
185 |
186 | @Override
187 | public SlotIterator blacklist(SlotPos slotPos) {
188 | return blacklist(slotPos.getRow(), slotPos.getColumn());
189 | }
190 |
191 | @Override
192 | public int row() {
193 | return row;
194 | }
195 |
196 | @Override
197 | public SlotIterator row(int row) {
198 | this.row = row;
199 | return this;
200 | }
201 |
202 | @Override
203 | public int column() {
204 | return column;
205 | }
206 |
207 | @Override
208 | public SlotIterator column(int column) {
209 | this.column = column;
210 | return this;
211 | }
212 |
213 | @Override
214 | public boolean started() {
215 | return this.started;
216 | }
217 |
218 | @Override
219 | public boolean ended() {
220 | return row == inv.getRows() - 1
221 | && column == inv.getColumns() - 1;
222 | }
223 |
224 | @Override
225 | public boolean doesAllowOverride() {
226 | return allowOverride;
227 | }
228 |
229 | @Override
230 | public SlotIterator allowOverride(boolean override) {
231 | this.allowOverride = override;
232 | return this;
233 | }
234 |
235 | private boolean canPlace() {
236 | return !blacklisted.contains(SlotPos.of(row, column)) && (allowOverride || !this.get()
237 | .isPresent());
238 | }
239 |
240 | }
241 |
242 | }
243 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/inv/content/SlotPos.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus.inv.content;
20 |
21 | public class SlotPos {
22 |
23 | private final int row;
24 | private final int column;
25 |
26 | public SlotPos(int row, int column) {
27 | this.row = row;
28 | this.column = column;
29 | }
30 |
31 | public static SlotPos of(int row, int column) {
32 | return new SlotPos(row, column);
33 | }
34 |
35 | @Override
36 | public boolean equals(Object obj) {
37 | if (this == obj) {
38 | return true;
39 | }
40 | if (obj == null || getClass() != obj.getClass()) {
41 | return false;
42 | }
43 |
44 | SlotPos slotPos = (SlotPos) obj;
45 |
46 | return row == slotPos.row && column == slotPos.column;
47 | }
48 |
49 | @Override
50 | public int hashCode() {
51 | int result = row;
52 | result = 31 * result + column;
53 |
54 | return result;
55 | }
56 |
57 | public int getRow() {
58 | return row;
59 | }
60 |
61 | public int getColumn() {
62 | return column;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/inv/opener/ChestInventoryOpener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus.inv.opener;
20 |
21 | import com.google.common.base.Preconditions;
22 | import net.arcaniax.buildersutilities.menus.inv.InventoryManager;
23 | import net.arcaniax.buildersutilities.menus.inv.SmartInventory;
24 | import org.bukkit.Bukkit;
25 | import org.bukkit.entity.Player;
26 | import org.bukkit.event.inventory.InventoryType;
27 | import org.bukkit.inventory.Inventory;
28 |
29 | public class ChestInventoryOpener implements InventoryOpener {
30 |
31 | @Override
32 | public Inventory open(SmartInventory inv, Player player) {
33 | Preconditions.checkArgument(inv.getColumns() == 9,
34 | "The column count for the chest inventory must be 9, found: %s.", inv.getColumns()
35 | );
36 | Preconditions.checkArgument(inv.getRows() >= 1 && inv.getRows() <= 6,
37 | "The row count for the chest inventory must be between 1 and 6, found: %s", inv.getRows()
38 | );
39 |
40 | InventoryManager manager = inv.getManager();
41 | Inventory handle = Bukkit
42 | .createInventory(player, inv.getRows() * inv.getColumns(), inv.getTitle());
43 |
44 | fill(handle, manager.getContents(player).get());
45 |
46 | player.openInventory(handle);
47 | return handle;
48 | }
49 |
50 | @Override
51 | public boolean supports(InventoryType type) {
52 | return type == InventoryType.CHEST || type == InventoryType.ENDER_CHEST;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/inv/opener/InventoryOpener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus.inv.opener;
20 |
21 | import net.arcaniax.buildersutilities.menus.inv.ClickableItem;
22 | import net.arcaniax.buildersutilities.menus.inv.SmartInventory;
23 | import net.arcaniax.buildersutilities.menus.inv.content.InventoryContents;
24 | import org.bukkit.entity.Player;
25 | import org.bukkit.event.inventory.InventoryType;
26 | import org.bukkit.inventory.Inventory;
27 |
28 | public interface InventoryOpener {
29 |
30 | Inventory open(SmartInventory inv, Player player);
31 |
32 | boolean supports(InventoryType type);
33 |
34 | default void fill(Inventory handle, InventoryContents contents) {
35 | ClickableItem[][] items = contents.all();
36 |
37 | for (int row = 0; row < items.length; row++) {
38 | for (int column = 0; column < items[row].length; column++) {
39 | if (items[row][column] != null) {
40 | handle.setItem(9 * row + column, items[row][column].getItem());
41 | }
42 | }
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/menus/inv/opener/SpecialInventoryOpener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.menus.inv.opener;
20 |
21 | import com.google.common.collect.ImmutableList;
22 | import net.arcaniax.buildersutilities.menus.inv.InventoryManager;
23 | import net.arcaniax.buildersutilities.menus.inv.SmartInventory;
24 | import org.bukkit.Bukkit;
25 | import org.bukkit.entity.Player;
26 | import org.bukkit.event.inventory.InventoryType;
27 | import org.bukkit.inventory.Inventory;
28 |
29 | import java.util.List;
30 |
31 | public class SpecialInventoryOpener implements InventoryOpener {
32 |
33 | private static final List SUPPORTED = ImmutableList.of(
34 | InventoryType.FURNACE,
35 | InventoryType.WORKBENCH,
36 | InventoryType.DISPENSER,
37 | InventoryType.DROPPER,
38 | InventoryType.ENCHANTING,
39 | InventoryType.BREWING,
40 | InventoryType.ANVIL,
41 | InventoryType.BEACON,
42 | InventoryType.HOPPER
43 | );
44 |
45 | @Override
46 | public Inventory open(SmartInventory inv, Player player) {
47 | InventoryManager manager = inv.getManager();
48 | Inventory handle = Bukkit.createInventory(player, inv.getType(), inv.getTitle());
49 |
50 | fill(handle, manager.getContents(player).get());
51 |
52 | player.openInventory(handle);
53 | return handle;
54 | }
55 |
56 | @Override
57 | public boolean supports(InventoryType type) {
58 | return SUPPORTED.contains(type);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/utils/BannerUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.utils;
20 |
21 | import com.cryptomorin.xseries.XMaterial;
22 | import org.bukkit.Bukkit;
23 | import org.bukkit.ChatColor;
24 | import org.bukkit.DyeColor;
25 | import org.bukkit.block.banner.Pattern;
26 | import org.bukkit.block.banner.PatternType;
27 | import org.bukkit.inventory.ItemStack;
28 | import org.bukkit.inventory.meta.BannerMeta;
29 | import org.bukkit.inventory.meta.ItemMeta;
30 |
31 | import java.lang.reflect.InvocationTargetException;
32 | import java.lang.reflect.Method;
33 | import java.util.ArrayList;
34 | import java.util.HashMap;
35 | import java.util.List;
36 | import java.util.Random;
37 | import java.util.UUID;
38 |
39 | public class BannerUtil {
40 |
41 | public static final HashMap currentBanner = new HashMap<>();
42 | public static final HashMap selectedColor = new HashMap<>();
43 |
44 | public static final List allColors = new ArrayList<>();
45 | public static final List allPatterns = new ArrayList<>();
46 | private static final Random random = new Random();
47 |
48 | public static void addPatterns() {
49 | for (PatternType pt : PatternType.values()) {
50 | if (!pt.equals(PatternType.BASE)) {
51 | allPatterns.add(pt);
52 | }
53 | }
54 |
55 | Class> craftPatternTypeClass;
56 | Method bukkitToMinecraftHolder;
57 | try {
58 | String craftBukkitPackage = Bukkit.getServer().getClass().getPackage().getName();
59 | craftPatternTypeClass = Class.forName(craftBukkitPackage + ".block.banner.CraftPatternType");
60 | bukkitToMinecraftHolder = craftPatternTypeClass.getMethod("bukkitToMinecraftHolder", PatternType.class);
61 | } catch (ClassNotFoundException | NoSuchMethodException ignored) {
62 | // CraftPatternType class was only added in 1.20.5
63 | return;
64 | }
65 |
66 | allPatterns.removeIf(pt -> {
67 | try {
68 | // Attempt to find pattern in banner pattern registry
69 | bukkitToMinecraftHolder.invoke(craftPatternTypeClass, pt);
70 | return false;
71 | } catch (InvocationTargetException | IllegalAccessException ignored) {
72 | // Pattern is not present in registry, thus remove it
73 | return true;
74 | }
75 | });
76 | }
77 |
78 | public static void addColors() {
79 | allColors.add(DyeColor.BLACK);
80 | allColors.add(DyeColor.RED);
81 | allColors.add(DyeColor.GREEN);
82 | allColors.add(DyeColor.BROWN);
83 | allColors.add(DyeColor.BLUE);
84 | allColors.add(DyeColor.PURPLE);
85 | allColors.add(DyeColor.CYAN);
86 | allColors.add(DyeColor.LIGHT_GRAY);
87 | allColors.add(DyeColor.GRAY);
88 | allColors.add(DyeColor.PINK);
89 | allColors.add(DyeColor.LIME);
90 | allColors.add(DyeColor.YELLOW);
91 | allColors.add(DyeColor.LIGHT_BLUE);
92 | allColors.add(DyeColor.MAGENTA);
93 | allColors.add(DyeColor.ORANGE);
94 | allColors.add(DyeColor.WHITE);
95 | }
96 |
97 | public static ItemStack createBanner(String name, DyeColor base, String lore, List patterns) {
98 | ItemStack item = Items.create(
99 | XMaterial.matchXMaterial(base.toString() + "_BANNER").get().parseMaterial(),
100 | (short) 0,
101 | 1,
102 | name,
103 | ""
104 | );
105 | BannerMeta meta = (BannerMeta) item.getItemMeta();
106 |
107 | meta.setPatterns(patterns);
108 | if (!lore.equals("")) {
109 | String[] loreListArray = lore.split("__");
110 | List loreList = new ArrayList<>();
111 | for (String s : loreListArray) {
112 | loreList.add(s.replace('&', ChatColor.COLOR_CHAR));
113 | }
114 | meta.setLore(loreList);
115 | }
116 | item.setItemMeta(meta);
117 | return item;
118 | }
119 |
120 | public static ItemStack createDye(String name, DyeColor base, String lore) {
121 | ItemStack item = Items.create(
122 | XMaterial.matchXMaterial(base.toString() + "_DYE").get().parseMaterial(),
123 | (short) 0,
124 | 1,
125 | name,
126 | ""
127 | );
128 | ItemMeta meta = item.getItemMeta();
129 | if (!lore.equals("")) {
130 | String[] loreListArray = lore.split("__");
131 | List loreList = new ArrayList<>();
132 | for (String s : loreListArray) {
133 | loreList.add(s.replace('&', ChatColor.COLOR_CHAR));
134 | }
135 | meta.setLore(loreList);
136 | }
137 | item.setItemMeta(meta);
138 | return item;
139 | }
140 |
141 | public static ItemStack createBanner(String name, DyeColor base, String lore) {
142 | XMaterial.matchXMaterial(base.toString() + "_BANNER").get().parseMaterial();
143 |
144 | ItemStack item = Items.create(
145 | XMaterial.matchXMaterial(base + "_BANNER").get().parseMaterial(),
146 | (short) 0,
147 | 1,
148 | name,
149 | ""
150 | );
151 | BannerMeta meta = (BannerMeta) item.getItemMeta();
152 | if (!lore.equals("")) {
153 | String[] loreListArray = lore.split("__");
154 | List loreList = new ArrayList<>();
155 | for (String s : loreListArray) {
156 | loreList.add(s.replace('&', ChatColor.COLOR_CHAR));
157 | }
158 | meta.setLore(loreList);
159 | }
160 | item.setItemMeta(meta);
161 | return item;
162 | }
163 |
164 | public static ItemStack createBanner(String name, int amount, DyeColor base, String lore, Pattern pat) {
165 | ItemStack item = Items.create(
166 | XMaterial.matchXMaterial(base.toString() + "_BANNER").get().parseMaterial(),
167 | (short) 0,
168 | 1,
169 | name,
170 | ""
171 | );
172 | BannerMeta meta = (BannerMeta) item.getItemMeta();
173 | meta.addPattern(pat);
174 | if (!lore.equals("")) {
175 | String[] loreListArray = lore.split("__");
176 | List loreList = new ArrayList<>();
177 | for (String s : loreListArray) {
178 | loreList.add(s.replace('&', ChatColor.COLOR_CHAR));
179 | }
180 | meta.setLore(loreList);
181 | }
182 | item.setItemMeta(meta);
183 | return item;
184 | }
185 |
186 | public static ItemStack addPattern(ItemStack i, Pattern pat) {
187 | if (i.getType().toString().contains("BANNER")) {
188 | BannerMeta meta = (BannerMeta) i.getItemMeta();
189 | List patterns = meta.getPatterns();
190 | patterns.add(pat);
191 | meta.setPatterns(patterns);
192 | i.setItemMeta(meta);
193 | return i;
194 | }
195 | return null;
196 | }
197 |
198 | public static List getPatterns(ItemStack i) {
199 | if (i.getType().toString().contains("BANNER")) {
200 | BannerMeta meta = (BannerMeta) i.getItemMeta();
201 | List patterns = meta.getPatterns();
202 | return patterns;
203 | }
204 | return new ArrayList<>();
205 | }
206 |
207 | public static DyeColor getRandomDye() {
208 | return allColors.get(random.nextInt(allColors.size()));
209 | }
210 |
211 | public static PatternType getRandomPattern() {
212 | return allPatterns.get(random.nextInt(allPatterns.size()));
213 | }
214 |
215 | public static DyeColor getOppositeBaseColor(DyeColor dyeColor) {
216 | switch (dyeColor) {
217 | case RED:
218 | case BLUE:
219 | case CYAN:
220 | case GRAY:
221 | case BLACK:
222 | case BROWN:
223 | case GREEN:
224 | case PURPLE:
225 | return DyeColor.WHITE;
226 | case PINK:
227 | case WHITE:
228 | case ORANGE:
229 | case YELLOW:
230 | case MAGENTA:
231 | case LIGHT_BLUE:
232 | case LIGHT_GRAY:
233 | case LIME:
234 | default:
235 | return DyeColor.BLACK;
236 | }
237 | }
238 |
239 | }
240 |
241 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/utils/CustomConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.utils;
20 |
21 | import org.apache.logging.log4j.Logger;
22 | import org.bukkit.configuration.ConfigurationSection;
23 | import org.bukkit.configuration.file.FileConfiguration;
24 | import org.bukkit.configuration.file.YamlConfiguration;
25 | import org.bukkit.plugin.java.JavaPlugin;
26 |
27 | import javax.naming.ConfigurationException;
28 | import java.io.File;
29 | import java.util.ArrayList;
30 | import java.util.List;
31 | import java.util.Set;
32 |
33 | public class CustomConfig {
34 |
35 | private static final Logger logger = LogManagerCompat.getLogger();
36 |
37 | private final JavaPlugin plugin;
38 | private final String fileName;
39 | private final File configFile;
40 | private FileConfiguration config;
41 |
42 | public CustomConfig(JavaPlugin plugin, File folder, String fileName) {
43 | this.plugin = plugin;
44 | if (!fileName.endsWith(".yml")) {
45 | fileName += ".yml";
46 | }
47 | this.fileName = fileName;
48 | configFile = new File(folder, fileName);
49 | reloadConfig();
50 | }
51 |
52 | public CustomConfig(JavaPlugin plugin, String fileName) {
53 | this(plugin, plugin.getDataFolder(), fileName);
54 | }
55 |
56 | public void reloadConfig() {
57 | if (!configFile.exists()) {
58 | logger.info("Attempting to save resource: {}", configFile.getName());
59 | plugin.saveResource(fileName, true);
60 | }
61 | config = YamlConfiguration.loadConfiguration(configFile);
62 | }
63 |
64 | public void saveConfig() {
65 | try {
66 | config.save(configFile);
67 | } catch (Exception e) {
68 | logger.error("Couldn't save {}, because {}", fileName, e.getMessage());
69 | }
70 | reloadConfig();
71 | }
72 |
73 | public void set(String path, Object value, boolean save) {
74 | config.set(path, value);
75 | if (save) {
76 | saveConfig();
77 | }
78 | }
79 |
80 | public void set(String path, Object value) {
81 | set(path, value, false);
82 | }
83 |
84 | public Set getKeys(boolean deep) {
85 | return this.config.getKeys(deep);
86 | }
87 |
88 | public ConfigurationSection getConfigurationSection(String path) {
89 | return this.config.getConfigurationSection(path);
90 | }
91 |
92 | public boolean has(String path) {
93 | return config.contains(path);
94 | }
95 |
96 | public T get(String path, Class tClass) {
97 | return get(path, tClass, null);
98 | }
99 |
100 | public T get(String path, Class tClass, T tDefault) {
101 | if (tClass.isPrimitive()) {
102 | throw new IllegalArgumentException(
103 | tClass + " is of a primitive type, please use the objectified version.");
104 | }
105 | if (!has(path)) {
106 | if (tDefault == null) {
107 | try {
108 | throw new ConfigurationException(
109 | "Configuration key doesn't exist and the default is null");
110 | } catch (ConfigurationException e) {
111 | e.printStackTrace();
112 | }
113 | }
114 | return tDefault;
115 | }
116 | Object object = config.get(path);
117 | if (object == null) {
118 | return tDefault;
119 | }
120 | if (!tClass.isInstance(object)) {
121 | throw new IllegalArgumentException(path + " is not of type " + tClass.getSimpleName());
122 | }
123 | return tClass.cast(object);
124 | }
125 |
126 | public List getStringList(String path) {
127 | if (!has(path)) {
128 | return new ArrayList<>();
129 | }
130 | return config.getStringList(path);
131 | }
132 |
133 | }
134 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/utils/Items.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.utils;
20 |
21 | import com.mojang.authlib.GameProfile;
22 | import com.mojang.authlib.properties.Property;
23 | import org.bukkit.ChatColor;
24 | import org.bukkit.Color;
25 | import org.bukkit.Material;
26 | import org.bukkit.inventory.ItemStack;
27 | import org.bukkit.inventory.meta.ItemMeta;
28 | import org.bukkit.inventory.meta.LeatherArmorMeta;
29 | import org.bukkit.inventory.meta.SkullMeta;
30 |
31 | import java.lang.reflect.Field;
32 | import java.util.ArrayList;
33 | import java.util.List;
34 | import java.util.UUID;
35 |
36 | public class Items {
37 |
38 | public static ItemStack create(String materialName, String name, String lore) {
39 | Material mat = Material.getMaterial(materialName);
40 |
41 | if(mat == null) {
42 | return null;
43 | }
44 |
45 | return Items.create(mat, (short) 0, 1, name, lore);
46 | }
47 |
48 | public static ItemStack create(Material mat, String name, String lore) {
49 | return Items.create(mat, (short) 0, 1, name, lore);
50 | }
51 |
52 | public static ItemStack create(Material mat, short data, int amount, String name, String lore) {
53 | ItemStack is = new ItemStack(mat, amount);
54 | ItemMeta meta = is.getItemMeta();
55 | if (!lore.isEmpty()) {
56 | String[] loreListArray = lore.split("__");
57 | List loreList = new ArrayList<>();
58 | for (String s : loreListArray) {
59 | loreList.add(s.replace('&', ChatColor.COLOR_CHAR));
60 | }
61 | meta.setLore(loreList);
62 | }
63 | if (!name.isEmpty()) {
64 | meta.setDisplayName(name.replace('&', ChatColor.COLOR_CHAR));
65 | }
66 | is.setItemMeta(meta);
67 | is.setDurability(data);
68 | return is;
69 | }
70 |
71 | public static ItemStack color(ItemStack is, int r, int g, int b) {
72 | LeatherArmorMeta lam = (LeatherArmorMeta) is.getItemMeta();
73 | Color c = Color.fromRGB(r, g, b);
74 | lam.setColor(c);
75 | is.setItemMeta(lam);
76 | return is;
77 | }
78 |
79 |
80 | public static ItemStack createHead(String data, int amount, String name, String lore) {
81 | ItemStack item = new ItemStack(Material.PLAYER_HEAD, amount);
82 | ItemMeta meta = item.getItemMeta();
83 | if (!lore.isEmpty()) {
84 | String[] loreListArray = lore.split("__");
85 | List loreList = new ArrayList<>();
86 | for (String s : loreListArray) {
87 | loreList.add(s.replace('&', ChatColor.COLOR_CHAR));
88 | }
89 | meta.setLore(loreList);
90 | }
91 | if (!name.isEmpty()) {
92 | meta.setDisplayName(name.replace('&', ChatColor.COLOR_CHAR));
93 | }
94 | item.setItemMeta(meta);
95 | SkullMeta headMeta = (SkullMeta) item.getItemMeta();
96 | GameProfile profile = new GameProfile(UUID.randomUUID(), "BuildersUtils");
97 | profile.getProperties().put("textures", new Property("textures", data));
98 | Field profileField;
99 | try {
100 | profileField = headMeta.getClass().getDeclaredField("profile");
101 | profileField.setAccessible(true);
102 | if (profileField.getType() == GameProfile.class) {
103 | profileField.set(headMeta, profile);
104 | } else {
105 | Class> resolvableProfileClass = Class.forName("net.minecraft.world.item.component.ResolvableProfile");
106 | profileField.set(headMeta, resolvableProfileClass.getConstructor(GameProfile.class).newInstance(profile));
107 | }
108 | } catch (Exception ignored) {
109 | }
110 | item.setItemMeta(headMeta);
111 | return item;
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/utils/LogManagerCompat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.utils;
20 |
21 | import com.google.common.base.Throwables;
22 | import org.apache.logging.log4j.LogManager;
23 | import org.apache.logging.log4j.Logger;
24 |
25 | import java.util.List;
26 |
27 | public class LogManagerCompat {
28 |
29 | private LogManagerCompat() {
30 | }
31 |
32 | public static Logger getLogger() {
33 | return LogManager.getLogger(getCallerCallerClassName());
34 | }
35 |
36 | private static String getCallerCallerClassName() {
37 | List lazyStack = Throwables.lazyStackTrace(new Throwable());
38 | // 0 - this method
39 | // 1 - caller
40 | // 2 - caller caller
41 | return lazyStack.get(2).getClassName();
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/net/arcaniax/buildersutilities/utils/Utility.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Builder's Utilities is a collection of a lot of tiny features that help with building.
3 | * Copyright (C) Arcaniax-Development
4 | * Copyright (C) Arcaniax team and contributors
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with this program. If not, see .
18 | */
19 | package net.arcaniax.buildersutilities.utils;
20 |
21 | import java.io.BufferedReader;
22 | import java.io.File;
23 | import java.io.FileReader;
24 | import java.io.IOException;
25 |
26 | public class Utility {
27 |
28 | public static String readFileAsString(File file) {
29 | try (BufferedReader br = new BufferedReader(new FileReader(file))) {
30 | StringBuilder sb = new StringBuilder();
31 | String line = br.readLine();
32 |
33 | while (line != null) {
34 | sb.append(line);
35 | sb.append(System.lineSeparator());
36 | line = br.readLine();
37 | }
38 | return sb.toString();
39 | } catch (IOException e) {
40 | e.printStackTrace();
41 | return e.getMessage();
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/resources/config.yml:
--------------------------------------------------------------------------------
1 | # This disables weather changing from what it currently is
2 | # If it is currently raining, it will continue raining
3 | # If it is currently sunny, it will continue being sunny
4 | # True if you want this feature, false if you do not.
5 | disable-weather-changes: true
6 |
7 | # This completely disables all redstone functions
8 | # True if you want this feature, false if you do not
9 | disable-redstone: false
10 |
11 | # This completely disables all physics for blocks
12 | disable-physics: true
13 |
14 | disable-gravity-physics: false
15 |
16 | # Disables all types of explosions
17 | # EX: creepers, tnt, end crystals, etc.
18 | disable-explosions: true
19 |
20 | # Prevents pesky peers pulverizing produce
21 | # Prevent people from trampling your crops and ruining
22 | # your soil
23 | disable-soil-trample: true
24 |
25 | # Disables leaves from vanishing when they are not
26 | # nearby any logs
27 | disable-leaves-decay: true
28 |
29 | # Makes blocks and items appear faster in your hand
30 | # Great for better building on creative servers
31 | # This changes Player NBT data and is hard to reverse without this plugin!
32 | # DO NOT ENABLE on PVP or PVE servers!
33 | fix-attackspeed: false
34 |
35 | # Prevent the dragon egg from teleporting away
36 | prevent-dragon-egg-teleport: true
37 |
38 | # Determines if players will be sent messages such as
39 | # "You do not have permission for this command"
40 | # This is useful for when you do not want to give away what
41 | # plugins exist on your server.
42 | send-error-messages: true
43 |
44 | # Whether or not Builders-Utilities should send debug messages
45 | # Leave it on "false" unless you are debugging Builders-Utilities' events.
46 | send-debug-messages: false
47 |
--------------------------------------------------------------------------------
/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | name: Builders-Utilities
2 | version: "${version}"
3 | api-version: 1.13
4 | main: net.arcaniax.buildersutilities.BuildersUtilities
5 | authors: [ Ktar5, Arcaniax ]
6 | website: "https://www.spigotmc.org/resources/42361/"
7 | commands:
8 | butil:
9 | aliases: bu
10 | description: opens toggle menu
11 | permission: builders.util.gui
12 | banner:
13 | description: opens banner creator
14 | aliases: bm
15 | permission: builders.util.banner
16 | armorcolor:
17 | description: opens armor color creator
18 | aliases: color
19 | permission: builders.util.color
20 | nc:
21 | aliases: noclip
22 | description: Toggles NoClip.
23 | permission: builders.util.noclip
24 | af:
25 | aliases: advfly
26 | description: Toggles Advanced fly.
27 | permission: builders.util.advancedfly
28 | n:
29 | aliases: nv
30 | description: Toggles Nightvision.
31 | permission: builders.util.nightvision
32 | /r:
33 | description: alias
34 | permission: builders.util.aliases
35 | /s:
36 | description: alias
37 | permission: builders.util.aliases
38 | /c:
39 | description: alias
40 | permission: builders.util.aliases
41 | /f:
42 | description: alias
43 | permission: builders.util.aliases
44 | /pa:
45 | description: alias
46 | permission: builders.util.aliases
47 | /derot:
48 | description: alias
49 | permission: builders.util.aliases
50 | /twist:
51 | description: alias
52 | permission: builders.util.aliases
53 | /scale:
54 | description: alias
55 | permission: builders.util.aliases
56 | /cuboid:
57 | description: alias
58 | aliases: /cub
59 | permission: builders.util.aliases
60 | /flip:
61 | description: alias
62 | permission: builders.util.aliases
63 | /convex:
64 | description: alias
65 | aliases: /con
66 | permission: builders.util.aliases
67 | blocks:
68 | description: Opens secret blocks menu
69 | aliases: secretblocks
70 | permission: builders.util.secretblocks
71 | ws:
72 | description: alias
73 | permission: builders.util.aliases
74 | fs:
75 | description: alias
76 | permission: builders.util.aliases
77 |
78 | permissions:
79 | builders.util.trapdoor:
80 | default: true
81 | builders.util.slabs:
82 | default: true
83 | builders.util.terracotta:
84 | default: true
85 | builders.util.nightvision:
86 | default: op
87 | builders.util.noclip:
88 | default: op
89 | builders.util.advancedfly:
90 | default: op
91 |
--------------------------------------------------------------------------------