mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-24 14:16:44 +01:00
Fixed stuff...
This commit is contained in:
parent
2705220ece
commit
f0a27eaff4
1
.idea/.name
Normal file
1
.idea/.name
Normal file
@ -0,0 +1 @@
|
||||
plot_news
|
23
.idea/compiler.xml
Normal file
23
.idea/compiler.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
|
3
.idea/copyright/profiles_settings.xml
Normal file
3
.idea/copyright/profiles_settings.xml
Normal file
@ -0,0 +1,3 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings default="" />
|
||||
</component>
|
5
.idea/encodings.xml
Normal file
5
.idea/encodings.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
|
||||
</project>
|
||||
|
11
.idea/misc.xml
Normal file
11
.idea/misc.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="IdProvider" IDEtalkID="2A33D3A7CBC0F43E264AB479A12203C5" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
9
.idea/modules.xml
Normal file
9
.idea/modules.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/PlotSquared/PlotSquared.iml" filepath="$PROJECT_DIR$/PlotSquared/PlotSquared.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
|
5
.idea/scopes/scope_settings.xml
Normal file
5
.idea/scopes/scope_settings.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="DependencyValidationManager">
|
||||
<state>
|
||||
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
|
||||
</state>
|
||||
</component>
|
125
.idea/uiDesigner.xml
Normal file
125
.idea/uiDesigner.xml
Normal file
@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
|
7
.idea/vcs.xml
Normal file
7
.idea/vcs.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
509
.idea/workspace.xml
Normal file
509
.idea/workspace.xml
Normal file
@ -0,0 +1,509 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="f6aaf715-4424-4f9e-96dc-b47edea10520" name="Default" comment="" />
|
||||
<ignored path="plot_news.iws" />
|
||||
<ignored path=".idea/workspace.xml" />
|
||||
<option name="TRACKING_ENABLED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
|
||||
<component name="CreatePatchCommitExecutor">
|
||||
<option name="PATCH_PATH" value="C:\Users\Citymonstret\Desktop\workspace\bukkit\plot_news" />
|
||||
</component>
|
||||
<component name="DaemonCodeAnalyzer">
|
||||
<disable_hints />
|
||||
</component>
|
||||
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
|
||||
<component name="FavoritesManager">
|
||||
<favorites_list name="plot_news" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf>
|
||||
<file leaf-file-name="compiler.xml" pinned="false" current="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/.idea/compiler.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="493">
|
||||
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="encodings.xml" pinned="false" current="true" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/.idea/encodings.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.09149623" vertical-offset="0" max-vertical-offset="929">
|
||||
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FindManager">
|
||||
<FindUsagesManager>
|
||||
<setting name="OPEN_NEW_TAB" value="true" />
|
||||
</FindUsagesManager>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="changedFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/src/com/intellectualcrafters/plot/Plot.java" />
|
||||
<option value="$PROJECT_DIR$/src/plot_news1.iml" />
|
||||
<option value="$PROJECT_DIR$/src/com/intellectualcrafters/plot/database/PlotMeConverter.java" />
|
||||
<option value="$PROJECT_DIR$/src/com/intellectualcrafters/plot/PlotMain.java" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds">
|
||||
<option name="x" value="-6" />
|
||||
<option name="y" value="-6" />
|
||||
<option name="width" value="1932" />
|
||||
<option name="height" value="1062" />
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
<OptionsSetting value="true" id="Checkout" />
|
||||
<OptionsSetting value="true" id="Update" />
|
||||
<OptionsSetting value="true" id="Status" />
|
||||
<OptionsSetting value="true" id="Edit" />
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectReloadState">
|
||||
<option name="STATE" value="0" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator currentView="ProjectPane" proportions="" version="1">
|
||||
<flattenPackages />
|
||||
<showMembers />
|
||||
<showModules />
|
||||
<showLibraryContents />
|
||||
<hideEmptyPackages />
|
||||
<abbreviatePackageNames />
|
||||
<autoscrollToSource />
|
||||
<autoscrollFromSource />
|
||||
<sortByType />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<PATH>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="plot_news" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
||||
</PATH_ELEMENT>
|
||||
</PATH>
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="PackagesPane">
|
||||
<subPane>
|
||||
<PATH>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="plot_news" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewProjectNode" />
|
||||
</PATH_ELEMENT>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="plot_news1" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PackageViewModuleNode" />
|
||||
</PATH_ELEMENT>
|
||||
</PATH>
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="Scope" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="GoToClass.includeLibraries" value="false" />
|
||||
<property name="GoToClass.toSaveIncludeLibraries" value="false" />
|
||||
<property name="GoToFile.includeJavaFiles" value="false" />
|
||||
<property name="MemberChooser.sorted" value="false" />
|
||||
<property name="MemberChooser.showClasses" value="true" />
|
||||
<property name="MemberChooser.copyJavadoc" value="false" />
|
||||
<property name="WebServerToolWindowFactoryState" value="true" />
|
||||
<property name="project.structure.last.edited" value="Modules" />
|
||||
<property name="project.structure.proportion" value="0.15" />
|
||||
<property name="project.structure.side.proportion" value="0.2" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/lib/BarAPI.jar!/" />
|
||||
<property name="Downloaded.Files.Path.Enabled" value="false" />
|
||||
<property name="Repository.Attach.JavaDocs" value="false" />
|
||||
<property name="Repository.Attach.Sources" value="false" />
|
||||
<property name="LayoutCode.rearrangeEntriesJava" value="false" />
|
||||
<property name="FullScreen" value="false" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="C:\Users\Citymonstret\Desktop\workspace\bukkit\plot_news\src" />
|
||||
<recent name="C:\Users\Citymonstret\Desktop\workspace\bukkit\plot_news\src\com" />
|
||||
<recent name="C:\Users\Citymonstret\Desktop\workspace\bukkit\plot_news\lib" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration default="true" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" factoryName="Plugin">
|
||||
<module name="" />
|
||||
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
|
||||
<option name="PROGRAM_PARAMETERS" />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="Remote" factoryName="Remote">
|
||||
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||
<option name="SERVER_MODE" value="false" />
|
||||
<option name="SHMEM_ADDRESS" value="javadebug" />
|
||||
<option name="HOST" value="localhost" />
|
||||
<option name="PORT" value="5005" />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="FlexUnitRunConfigurationType" factoryName="FlexUnit" appDescriptorForEmulator="Android" class_name="" emulatorAdlOptions="" method_name="" package_name="" scope="Class">
|
||||
<option name="BCName" value="" />
|
||||
<option name="launcherParameters">
|
||||
<LauncherParameters>
|
||||
<option name="browser" value="a7bb68e0-33c0-4d6f-a81a-aac1fdb870c8" />
|
||||
<option name="launcherType" value="OSDefault" />
|
||||
<option name="newPlayerInstance" value="false" />
|
||||
<option name="playerPath" value="FlashPlayerDebugger.exe" />
|
||||
</LauncherParameters>
|
||||
</option>
|
||||
<option name="moduleName" value="" />
|
||||
<option name="trusted" value="true" />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="Applet" factoryName="Applet">
|
||||
<module name="" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="HTML_FILE_NAME" />
|
||||
<option name="HTML_USED" value="false" />
|
||||
<option name="WIDTH" value="400" />
|
||||
<option name="HEIGHT" value="300" />
|
||||
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="Application" factoryName="Application">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
<option name="PROGRAM_PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<module name="" />
|
||||
<envs />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="JUnit" factoryName="JUnit">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<module name="" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="PACKAGE_NAME" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="METHOD_NAME" />
|
||||
<option name="TEST_OBJECT" value="class" />
|
||||
<option name="VM_PARAMETERS" value="-ea" />
|
||||
<option name="PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<option name="TEST_SEARCH_SCOPE">
|
||||
<value defaultName="moduleWithDependencies" />
|
||||
</option>
|
||||
<envs />
|
||||
<patterns />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="true" type="FlashRunConfigurationType" factoryName="Flash App">
|
||||
<option name="BCName" value="" />
|
||||
<option name="IOSSimulatorSdkPath" value="" />
|
||||
<option name="adlOptions" value="" />
|
||||
<option name="airProgramParameters" value="" />
|
||||
<option name="appDescriptorForEmulator" value="Android" />
|
||||
<option name="debugTransport" value="USB" />
|
||||
<option name="debuggerSdkRaw" value="BC SDK" />
|
||||
<option name="emulator" value="NexusOne" />
|
||||
<option name="emulatorAdlOptions" value="" />
|
||||
<option name="fastPackaging" value="true" />
|
||||
<option name="fullScreenHeight" value="0" />
|
||||
<option name="fullScreenWidth" value="0" />
|
||||
<option name="launchUrl" value="false" />
|
||||
<option name="launcherParameters">
|
||||
<LauncherParameters>
|
||||
<option name="browser" value="a7bb68e0-33c0-4d6f-a81a-aac1fdb870c8" />
|
||||
<option name="launcherType" value="OSDefault" />
|
||||
<option name="newPlayerInstance" value="false" />
|
||||
<option name="playerPath" value="FlashPlayerDebugger.exe" />
|
||||
</LauncherParameters>
|
||||
</option>
|
||||
<option name="mobileRunTarget" value="Emulator" />
|
||||
<option name="moduleName" value="" />
|
||||
<option name="overriddenMainClass" value="" />
|
||||
<option name="overriddenOutputFileName" value="" />
|
||||
<option name="overrideMainClass" value="false" />
|
||||
<option name="runTrusted" value="true" />
|
||||
<option name="screenDpi" value="0" />
|
||||
<option name="screenHeight" value="0" />
|
||||
<option name="screenWidth" value="0" />
|
||||
<option name="url" value="http://" />
|
||||
<option name="usbDebugPort" value="7936" />
|
||||
<method />
|
||||
</configuration>
|
||||
<list size="0" />
|
||||
<configuration name="<template>" type="TestNG" default="true" selected="false">
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="VM_PARAMETERS" value="-ea" />
|
||||
<option name="PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
</configuration>
|
||||
<configuration name="<template>" type="WebApp" default="true" selected="false">
|
||||
<Host>localhost</Host>
|
||||
<Port>5050</Port>
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="ShelveChangesManager" show_recycled="false" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="f6aaf715-4424-4f9e-96dc-b47edea10520" name="Default" comment="" />
|
||||
<created>1411382235722</created>
|
||||
<updated>1411382235722</updated>
|
||||
<workItem from="1411382238709" duration="182000" />
|
||||
<workItem from="1411382421959" duration="656000" />
|
||||
<workItem from="1411383098267" duration="708000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="First Commit">
|
||||
<created>1411382351159</created>
|
||||
<updated>1411382351159</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00002" summary="Use this xD">
|
||||
<created>1411383645660</created>
|
||||
<updated>1411383645660</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00003" summary="Included source...">
|
||||
<created>1411383734427</created>
|
||||
<updated>1411383734427</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="4" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="1546000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="-6" y="-6" width="1932" height="1062" extended-state="6" />
|
||||
<editor active="false" />
|
||||
<layout>
|
||||
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Remote Host" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="IDEtalk Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3291536" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="IDEtalk" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3291536" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.25" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="Vcs.Log.UiProperties">
|
||||
<option name="RECENTLY_FILTERED_USER_GROUPS">
|
||||
<collection />
|
||||
</option>
|
||||
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
|
||||
<collection />
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsContentAnnotationSettings">
|
||||
<option name="myLimit" value="2678400000" />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="myTodoPanelSettings">
|
||||
<TodoPanelSettings />
|
||||
</option>
|
||||
<MESSAGE value="First Commit" />
|
||||
<MESSAGE value="Use this xD" />
|
||||
<MESSAGE value="Included source..." />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Included source..." />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/.idea/compiler.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="493">
|
||||
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.idea/encodings.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0" vertical-offset="85" max-vertical-offset="187">
|
||||
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.idea/compiler.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="493">
|
||||
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.idea/encodings.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0" vertical-offset="85" max-vertical-offset="187">
|
||||
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.idea/compiler.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="493">
|
||||
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.05654102" vertical-offset="0" max-vertical-offset="902">
|
||||
<caret line="3" column="0" selection-start-line="3" selection-start-column="0" selection-end-line="3" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
<provider editor-type-id="MarkdownPreviewEditor">
|
||||
<state />
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/.idea/encodings.xml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state vertical-scroll-proportion="0.09149623" vertical-offset="0" max-vertical-offset="929">
|
||||
<caret line="5" column="0" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
<state key="ArtifactsStructureConfigurable.UI">
|
||||
<settings>
|
||||
<artifact-editor />
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="FacetStructureConfigurable.UI">
|
||||
<settings>
|
||||
<last-edited>No facets are configured</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="GlobalLibrariesConfigurable.UI">
|
||||
<settings>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="JdkListConfigurable.UI">
|
||||
<settings>
|
||||
<last-edited>1.7</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="ModuleStructureConfigurable.UI">
|
||||
<settings>
|
||||
<last-edited>PlotSquared</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="ProjectJDKs.UI">
|
||||
<settings>
|
||||
<last-edited>1.7</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="ProjectLibrariesConfigurable.UI">
|
||||
<settings>
|
||||
<last-edited>lib</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
</states>
|
||||
</component>
|
||||
</project>
|
||||
|
12
out/production/plot_news1/plot_news1.iml
Normal file
12
out/production/plot_news1/plot_news1.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
@ -1,276 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = C.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:43
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* Captions class.
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public enum C {
|
||||
/*
|
||||
Schematic Stuff
|
||||
*/
|
||||
SCHEMATIC_MISSING_ARG("&cYou need to specify an argument. Possible values: &6test {name}"),
|
||||
SCHEMATIC_INVALID("&cThat is not a valid schematic. Reason: &c%s"),
|
||||
SCHEMATIC_VALID("&cThat's a valid schematic"),
|
||||
/*
|
||||
Title Stuff
|
||||
*/
|
||||
TITLE_ENTERED_PLOT("You entered plot %s"),
|
||||
TITLE_ENTERED_PLOT_COLOR("GOLD"),
|
||||
TITLE_ENTERED_PLOT_SUB("Owned by %s"),
|
||||
TITLE_ENTERED_PLOT_SUB_COLOR("RED"),
|
||||
TITLE_LEFT_PLOT("You entered plot %s"),
|
||||
TITLE_LEFT_PLOT_COLOR("GOLD"),
|
||||
TITLE_LEFT_PLOT_SUB("Owned by %s"),
|
||||
TITLE_LEFT_PLOT_SUB_COLOR("RED"),
|
||||
/*
|
||||
Core Stuff
|
||||
*/
|
||||
PREFIX("&c[&6&lPlot&c] "),
|
||||
ENABLED("&6Plots are now enabled"),
|
||||
EXAMPLE_MESSAGE("&cThis is an example message &k!!!"),
|
||||
/*
|
||||
Reload
|
||||
*/
|
||||
RELOADED_CONFIGS("&6The translation files has been reloaded"),
|
||||
RELOAD_FAILED("&cFailed to reload the translations file"),
|
||||
/*
|
||||
BarAPI
|
||||
*/
|
||||
BOSSBAR_CLEARING("&cClearing plot: &6%id%"),
|
||||
/*
|
||||
Alias
|
||||
*/
|
||||
ALIAS_SET_TO("&cPlot alias set to &6%alias%"),
|
||||
MISSING_ALIAS("&cYou need to specify the alias"),
|
||||
ALIAS_IS_TAKEN("&cThat alias is already taken"),
|
||||
/*
|
||||
Position
|
||||
*/
|
||||
MISSING_POSITION("&cYou need to specify a position. Possible values: &6default&c, &6center"),
|
||||
POSITION_SET("&cPlot home position set"),
|
||||
INVALID_POSITION("&cThat is not a valid position value"),
|
||||
/*
|
||||
Time
|
||||
*/
|
||||
TIME_FORMAT("&6%hours%, %min%, %sec%"),
|
||||
/*
|
||||
Permission
|
||||
*/
|
||||
NO_PERMISSION("&cYou don't have the permissions required to use this command."),
|
||||
NO_PLOT_PERMS("&cYou don't have the permissions to do that in this plot"),
|
||||
CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."),
|
||||
YOU_BE_DENIED("&cYou are not allowed to enter this plot"),
|
||||
/*
|
||||
Commands
|
||||
*/
|
||||
NOT_VALID_SUBCOMMAND("&cThat is not a valid subcommand."),
|
||||
NO_COMMANDS("&cI'm sorry, but you're not permitted to use any subcommands."),
|
||||
SUBCOMMAND_SET_OPTIONS_HEADER("&cPossible Values: "),
|
||||
/*
|
||||
No {plot}
|
||||
*/
|
||||
NOT_IN_PLOT("&cYou're not in a plot"),
|
||||
NOT_IN_PLOT_WORLD("&cYou're not in a plot world"),
|
||||
NO_PLOTS("&cYou don't have any plots"),
|
||||
/*
|
||||
Block List
|
||||
*/
|
||||
NOT_VALID_BLOCK_LIST_HEADER("&cThat's not a valid block. Valid blocks are:\\n"),
|
||||
BLOCK_LIST_ITEM(" &6%mat%&c,"),
|
||||
/*
|
||||
Biome
|
||||
*/
|
||||
NEED_BIOME("&cYou've got to specify a biome"),
|
||||
BIOME_SET_TO("&cPlot biome set to &c"),
|
||||
/*
|
||||
Teleport / Entry
|
||||
*/
|
||||
TELEPORTED_TO_PLOT("&6You have been teleported"),
|
||||
/*
|
||||
Set Block
|
||||
*/
|
||||
SET_BLOCK_ACTION_FINISHED("&6The last setblock action is now finished."),
|
||||
/*
|
||||
Debug
|
||||
*/
|
||||
DEUBG_HEADER("&6Debug Information\\n"),
|
||||
DEBUG_SECTION("&c>> &6&l%val%"),
|
||||
DEBUG_LINE("&c>> &6%var%&c:&6 %val%\\n"),
|
||||
/*
|
||||
Invalid
|
||||
*/
|
||||
NOT_VALID_DATA("&cThat's not a valid data id."),
|
||||
NOT_VALID_BLOCK("&cThat's not a valid block."),
|
||||
NOT_VALID_NUMBER("&cThat's not a valid number"),
|
||||
NOT_VALID_PLOT_ID("&cThat's not a valid plot id."),
|
||||
NOT_YOUR_PLOT("&cThat is not your plot."),
|
||||
NO_SUCH_PLOT("&cThere is no such plot"),
|
||||
PLAYER_HAS_NOT_BEEN_ON("&cThat player hasn't been in the plotworld"),
|
||||
FOUND_NO_PLOTS("&cFound no plots with your search query"),
|
||||
/*
|
||||
Camera
|
||||
*/
|
||||
CAMERA_STARTED("&cYou have entered camera mode for plot &6%s"),
|
||||
CAMERA_STOPPED("&cYou are no longer in camera mode"),
|
||||
/*
|
||||
Need
|
||||
*/
|
||||
NEED_PLOT_NUMBER("&cYou've got to specify a plot number or alias"),
|
||||
NEED_BLOCK("&cYou've got to specify a block"),
|
||||
NEED_PLOT_ID("&cYou've got to specify a plot id."),
|
||||
NEED_USER("&cYou need to specify a username"),
|
||||
/*
|
||||
Info
|
||||
*/
|
||||
PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"),
|
||||
PLOT_INFO("plot ID: &6%id%&c, plot Alias: &6%alias%&c, plot Owner: &6%owner%&c, plot Biome: &6%biome%&c, plot Time: &6%time%&c, plot Weather: &6%weather%&c, plot Helpers:&6%helpers%&c, plot Denied:&6%denied%&c"),
|
||||
PLOT_USER_LIST(" &6%user%&c,"),
|
||||
/*
|
||||
Generating
|
||||
*/
|
||||
GENERATING_FLOOR("&6Started generating floor from your settings. It will take %time%"),
|
||||
GENERATING_WALL("&6Started generating wall from your settings"),
|
||||
GENERATING_WALL_FILLING("&cStarted generating wall filling from your settings."),
|
||||
/*
|
||||
Clearing
|
||||
*/
|
||||
CLEARING_PLOT("&cClearing plot."),
|
||||
CLEARING_DONE("&aDone! Took %time% seconds"),
|
||||
/*
|
||||
Claiming
|
||||
*/
|
||||
PLOT_IS_CLAIMED("&cThis plot is already claimed"),
|
||||
CLAIMED("&6You successfully claimed the plot"),
|
||||
/*
|
||||
List
|
||||
*/
|
||||
PLOT_LIST_HEADER("&6List of %word% plots"),
|
||||
PLOT_LIST_ITEM("&c>> &6%id% &c- &6%owner%"),
|
||||
PLOT_LIST_FOOTER("&c>> &6%word% a total of &c%num% &6claimed %plot%."),
|
||||
/*
|
||||
Left
|
||||
*/
|
||||
LEFT_PLOT("&cYou left a plot"),
|
||||
/*
|
||||
Wait
|
||||
*/
|
||||
WAIT_FOR_TIMER("&cA setblock timer is bound to either the current plot or you. Please wait for it to finish"),
|
||||
/*
|
||||
Chat
|
||||
*/
|
||||
PLOT_CHAT_FORMAT("&c[&6Plot Chat&c][&6%plot_id%&c] &6%sender%&c: &6%msg%"),
|
||||
/*
|
||||
Denied
|
||||
*/
|
||||
DENIED_REMOVED("&cYou successfully undenied the player from this plot"),
|
||||
DENIED_ADDED("&cYou successfully denied the player from this plot"),
|
||||
DENIED_NEED_ARGUMENT("&cArguments are missing. &6/plot denied add {name} &cor &6/plot helpers remove {name}"),
|
||||
WAS_NOT_DENIED("&cThat player was not denied on this plot"),
|
||||
/*
|
||||
Rain
|
||||
*/
|
||||
NEED_ON_OFF("&cYou need to specify a value. Possible values: &6on&c, &6off"),
|
||||
SETTING_UPDATED("&cYou successfully updated the setting"),
|
||||
/*
|
||||
Helper
|
||||
*/
|
||||
HELPER_ADDED("&6You successfully added a helper to the plot"),
|
||||
HELPER_REMOVED("&6You successfully removed a helper from the plot"),
|
||||
HELPER_NEED_ARGUMENT("&cArguments are missing. &6/plot helpers add {name} &cor &6/plot helpers remove {name}"),
|
||||
WAS_NOT_ADDED("&cThat player was not added as a helper on this plot"),
|
||||
/*
|
||||
Set Owner
|
||||
*/
|
||||
SET_OWNER("&6You successfully set the plot owner"),
|
||||
/*
|
||||
Signs
|
||||
*/
|
||||
OWNER_SIGN_LINE_1("&cID: &6%id%"),
|
||||
OWNER_SIGN_LINE_2("&cOwner:"),
|
||||
OWNER_SIGN_LINE_3("&6%plr%"),
|
||||
OWNER_SIGN_LINE_4("&2Claimed"),
|
||||
/*
|
||||
Help
|
||||
*/
|
||||
HELP_CATEGORY("&6Current Category&c: &l%category%"),
|
||||
HELP_INFO("&6You need to specify a help category"),
|
||||
HELP_INFO_ITEM("&6/plots help %category% &c- &6%category_desc%"),
|
||||
HELP_PAGE("&c>> &6%usage% &c[&6%alias%&c] &c- &6%desc%"),
|
||||
HELP_HEADER("&6Help for Plots"),
|
||||
/*
|
||||
Custom
|
||||
*/
|
||||
CUSTOM_STRING("-")
|
||||
;
|
||||
/**
|
||||
* Default
|
||||
*/
|
||||
private String d;
|
||||
/**
|
||||
* Translated
|
||||
*/
|
||||
private String s;
|
||||
|
||||
/**
|
||||
* Constructor for custom strings.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
C() {
|
||||
/*
|
||||
use setCustomString();
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param d default
|
||||
*/
|
||||
C(String d) {
|
||||
this.d = d;
|
||||
this.s = PlotMain.translations.getString(this.toString());
|
||||
if (this.s==null) {
|
||||
this.s = "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default string
|
||||
* @return default
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public String d() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get translated if exists
|
||||
* @return translated if exists else default
|
||||
*/
|
||||
public String s() {
|
||||
if(this.s.length() < 1)
|
||||
return this.d.replace("\\n", "\n");
|
||||
return this.s.replace("\\n", "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return translated and color decoded
|
||||
*/
|
||||
public String translated() {
|
||||
return ChatColor.translateAlternateColorCodes('&', this.s());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = LSetCube.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:43
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
* Cube utilities
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class LSetCube {
|
||||
|
||||
/**
|
||||
* Base locations
|
||||
*/
|
||||
private Location l1,l2;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param l1
|
||||
* @param l2
|
||||
*/
|
||||
public LSetCube(Location l1, Location l2) {
|
||||
this.l1 = l1;
|
||||
this.l1 = l2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Secondary constructor
|
||||
* @param l1
|
||||
* @param size
|
||||
*/
|
||||
public LSetCube(Location l1, int size) {
|
||||
this.l1 = l1;
|
||||
this.l2 = l1.clone().add(size, size, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute min. of the cube
|
||||
* @return abs. min
|
||||
*/
|
||||
public Location minLoc() {
|
||||
int x = Math.min(l1.getBlockX(), l2.getBlockX());
|
||||
int y = Math.min(l1.getBlockY(), l2.getBlockY());
|
||||
int z = Math.min(l1.getBlockZ(), l2.getBlockZ());
|
||||
return new Location(l1.getWorld(), x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute max. of the cube
|
||||
* @return abs. max
|
||||
*/
|
||||
public Location maxLoc() {
|
||||
int x = Math.max(l1.getBlockX(), l2.getBlockX());
|
||||
int y = Math.max(l1.getBlockY(), l2.getBlockY());
|
||||
int z = Math.max(l1.getBlockZ(), l2.getBlockZ());
|
||||
return new Location(l1.getWorld(), x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a LCycler for the cube.
|
||||
* @return new lcycler
|
||||
*/
|
||||
public LCycler getCycler() {
|
||||
return new LCycler(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
*/
|
||||
protected class LCycler {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Location min;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Location max;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Location current;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cube
|
||||
*/
|
||||
public LCycler(LSetCube cube) {
|
||||
this.min = cube.minLoc();
|
||||
this.max = cube.maxLoc();
|
||||
this.current = this.min;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean hasNext() {
|
||||
return ((this.current.getBlockX() + 1) <= this.max.getBlockX()) && ((this.current.getBlockY() + 1) <= this.max.getBlockY()) && ((this.current.getBlockZ() + 1) <= this.max.getBlockZ());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Location getNext() {
|
||||
if(!hasNext()) return null;
|
||||
this.current = this.current.add(1,1,1);
|
||||
return this.current;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Lag.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:43
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
/**
|
||||
* TPS and Lag Checker.
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class Lag implements Runnable{
|
||||
|
||||
/**
|
||||
* Tick count
|
||||
*/
|
||||
public static int TC = 0;
|
||||
/**
|
||||
* Ticks
|
||||
*/
|
||||
public static long[] T = new long[600];
|
||||
/**
|
||||
* something :_:
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static long LT = 0L;
|
||||
|
||||
/**
|
||||
* Get the server TPS
|
||||
* @return server tick per second
|
||||
*/
|
||||
public static double getTPS() {
|
||||
return Math.round(getTPS(100)) > 20.0D ? 20.0D : Math.round(getTPS(100));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the tick per second (measured in $ticks)
|
||||
* @param ticks Ticks
|
||||
* @return ticks per second
|
||||
*/
|
||||
public static double getTPS(int ticks) {
|
||||
if(TC < ticks)
|
||||
return 20.0D;
|
||||
int t = (TC - 1 - ticks) % T.length;
|
||||
long e = System.currentTimeMillis() - T[t];
|
||||
return ticks / (e / 1000.0D);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of ticks since
|
||||
* @param tI Ticks <
|
||||
* @return number of ticks since $tI
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static long getElapsed(int tI) {
|
||||
long t = T[tI % T.length];
|
||||
return System.currentTimeMillis() - t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
T[TC % T.length] = System.currentTimeMillis();
|
||||
TC++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lag percentage
|
||||
* @return lag percentage
|
||||
*/
|
||||
public static double getPercentage() {
|
||||
return Math.round((1.0D - Lag.getTPS() / 20.0D) * 100.0D);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TPS percentage (of 20)
|
||||
* @return TPS percentage
|
||||
*/
|
||||
public static double getFullPercentage() {
|
||||
return getTPS() * 5.0D;
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Logger.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:43
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Logging of errors and debug messages.
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class Logger {
|
||||
|
||||
private static ArrayList<String> entries;
|
||||
private static File log;
|
||||
|
||||
public static void setup(File file) {
|
||||
log = file;
|
||||
entries = new ArrayList<>();
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String line;
|
||||
while((line = reader.readLine()) != null) {
|
||||
entries.add(line);
|
||||
}
|
||||
reader.close();
|
||||
} catch(IOException e) {
|
||||
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "File setup error Logger#setup");
|
||||
}
|
||||
}
|
||||
|
||||
public enum LogLevel {
|
||||
GENERAL("General"),
|
||||
WARNING("Warning"),
|
||||
DANGER("Danger");
|
||||
private String name;
|
||||
LogLevel(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
public static void write() throws IOException {
|
||||
FileWriter writer = new FileWriter(log);
|
||||
for(String string : entries) {
|
||||
writer.write(string + System.lineSeparator());
|
||||
}
|
||||
writer.close();
|
||||
}
|
||||
|
||||
public static void add(LogLevel level, String string) {
|
||||
append("[" + level.toString() + "] " + string);
|
||||
}
|
||||
|
||||
private static void append(String string) {
|
||||
entries.add("[" + new Date().toString() + "]" + string);
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldedit.masks.RegionMask;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class PWE {
|
||||
|
||||
public static void setMask(Player p, Location l) {
|
||||
LocalSession s = PlotMain.worldEdit.getSession(p);
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(p);
|
||||
if (plot!=null) {
|
||||
boolean r;
|
||||
if (plot.getOwner()!=null)
|
||||
r = plot.getOwner().equals(p.getUniqueId());
|
||||
else
|
||||
r = false;
|
||||
if (!r) {
|
||||
if (p.hasPermission("plots.we.member") && plot.hasRights(p))
|
||||
r = true;
|
||||
else if (p.hasPermission("plots.we.bypass")) {
|
||||
s.setMask(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (r) {
|
||||
World w = p.getWorld();
|
||||
Location b = PlotHelper.getPlotBottomLoc(w, plot.id);
|
||||
Location t = PlotHelper.getPlotTopLoc(w, plot.id);
|
||||
Vector p1 = new Vector(b.getBlockX(),b.getBlockY(),b.getBlockZ());
|
||||
Vector p2 = new Vector(t.getBlockX(),t.getBlockY(),t.getBlockZ());
|
||||
LocalWorld world = PlotMain.worldEdit.wrapPlayer(p).getWorld();
|
||||
CuboidRegion cr = new CuboidRegion(world, p1, p2);
|
||||
RegionMask rm = new RegionMask(cr);
|
||||
s.setMask(rm);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(s.getMask() == null) {
|
||||
BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p);
|
||||
LocalWorld world = plr.getWorld();
|
||||
Vector p1 = new Vector(0,0,0), p2 = new Vector(0,0,0);
|
||||
s.setMask(new RegionMask(new CuboidRegion(world, p1, p2)));
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeMask(Player p) {
|
||||
LocalSession s = PlotMain.worldEdit.getSession(p);
|
||||
s.setMask(null);
|
||||
}
|
||||
}
|
@ -1,237 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = PlayerFunctions.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:43
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Functions involving players, plots and locations.
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("javadoc")
|
||||
public class PlayerFunctions {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player player
|
||||
* @return
|
||||
*/
|
||||
public static boolean isInPlot(Player player) {
|
||||
return getCurrentPlot(player) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plot plot
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasExpired(Plot plot) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(plot.owner);
|
||||
long lp = player.getLastPlayed();
|
||||
long cu = System.currentTimeMillis();
|
||||
return (lp - cu) > 30l;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param loc
|
||||
* @return
|
||||
*/
|
||||
public static PlotId getPlot(Location loc) {
|
||||
int valx = loc.getBlockX();
|
||||
int valz = loc.getBlockZ();
|
||||
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(loc.getWorld());
|
||||
int size = plotworld.PLOT_WIDTH + plotworld.ROAD_WIDTH;
|
||||
int pathsize = plotworld.ROAD_WIDTH;
|
||||
|
||||
boolean road = false;
|
||||
double n3;
|
||||
|
||||
int mod2 = 0;
|
||||
int mod1 = 1;
|
||||
|
||||
int x = (int) Math.ceil((double) valx / size);
|
||||
int z = (int) Math.ceil((double) valz / size);
|
||||
|
||||
if(pathsize % 2 == 1) {
|
||||
n3 = Math.ceil(((double) pathsize) / 2);
|
||||
mod2 = -1;
|
||||
} else {
|
||||
n3 = Math.floor(((double) pathsize) / 2);
|
||||
}
|
||||
|
||||
for(double i = n3; i >= 0; i--) {
|
||||
if((valx - i + mod1) % size == 0 || (valx + i + mod2) % size == 0) {
|
||||
road = true;
|
||||
x = (int) Math.ceil((valx - n3) / size);
|
||||
}
|
||||
if((valz - i + mod1) % size == 0 || (valz + i + mod2) % size == 0) {
|
||||
road = true;
|
||||
z = (int) Math.ceil((valz - n3) / size);
|
||||
}
|
||||
}
|
||||
if(road) {
|
||||
return null;
|
||||
} else {
|
||||
return new PlotId(x,z);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @param plot
|
||||
*/
|
||||
public static void togglePlotWeather(Player player, Plot plot) {
|
||||
player.setPlayerWeather(plot.settings.getRain() ? WeatherType.DOWNFALL : WeatherType.CLEAR);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @param plot
|
||||
*/
|
||||
public static void togglePlotTime(Player player, Plot plot) {
|
||||
player.setPlayerTime(plot.settings.getTime(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Plot getCurrentPlot(Player player) {
|
||||
if (!PlotMain.isPlotWorld(player.getWorld()))
|
||||
return null;
|
||||
PlotId id = getPlot(player.getLocation());
|
||||
World world = player.getWorld();
|
||||
if(id==null) {
|
||||
return null;
|
||||
}
|
||||
HashMap<PlotId, Plot> plots = PlotMain.getPlots(world);
|
||||
|
||||
if (plots!=null) {
|
||||
if(plots.containsKey(id)) {
|
||||
return plots.get(id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), world.getName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @param id
|
||||
* @param plot
|
||||
*/
|
||||
public static void set(Integer[] id, Plot plot) {
|
||||
PlotMain.updatePlot(plot);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plr
|
||||
* @return
|
||||
*/
|
||||
// public static Set<Plot> getPlayerPlots(Player plr) {
|
||||
// return PlotMain.getPlots(plr);
|
||||
// }
|
||||
//
|
||||
public static Set<Plot> getPlayerPlots(World world, Player plr) {
|
||||
Set<Plot> p = PlotMain.getPlots(world, plr);
|
||||
if (p==null)
|
||||
return new HashSet<Plot>();
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plr
|
||||
* @return
|
||||
*/
|
||||
// public static int getPlayerPlotCount(Player plr) {
|
||||
// return getPlayerPlots(plr).size();
|
||||
// }
|
||||
//
|
||||
public static int getPlayerPlotCount(World world, Player plr) {
|
||||
return getPlayerPlots(world, plr).size();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
public static int getAllowedPlots(Player p) {
|
||||
if(p.hasPermission("plots.admin")) return Integer.MAX_VALUE;
|
||||
int y = 0;
|
||||
for(int x = 1; x <= 100; x++) {
|
||||
if(p.hasPermission("plots.plot." + x)) y = x;
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return PlotMain.getPlots();
|
||||
* @deprecated
|
||||
*/
|
||||
public static Set<Plot> getPlots() {
|
||||
return PlotMain.getPlots();
|
||||
}
|
||||
|
||||
/**
|
||||
* \\previous\\
|
||||
* @param plr
|
||||
* @param msg
|
||||
* Was used to wrap the chat client length (Packets out--)
|
||||
*/
|
||||
public static void sendMessageWrapped(Player plr, String msg) {
|
||||
plr.sendMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the player
|
||||
* @param plr Player to recieve message
|
||||
* @param msg Message to send
|
||||
*/
|
||||
public static void sendMessage(Player plr, String msg) {
|
||||
if(msg.length() == 0 || msg.equalsIgnoreCase("")) return;
|
||||
sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&', C.PREFIX.s() + msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the player
|
||||
* @param plr Player to recieve message
|
||||
* @param c Caption to send
|
||||
*/
|
||||
public static void sendMessage(Player plr, C c, String ... args) {
|
||||
if(c.s().length() < 1) return;
|
||||
String msg = c.s();
|
||||
if(args != null && args.length > 0) {
|
||||
for(String str : args)
|
||||
msg = msg.replaceFirst("%s", str);
|
||||
}
|
||||
sendMessage(plr, msg);
|
||||
}
|
||||
}
|
@ -1,240 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Plot.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:43
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* The plot class
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Plot implements Cloneable{
|
||||
|
||||
/**
|
||||
* plot ID
|
||||
*/
|
||||
public PlotId id;
|
||||
/**
|
||||
* plot world
|
||||
*/
|
||||
public String world;
|
||||
/**
|
||||
* plot owner
|
||||
*/
|
||||
public UUID owner;
|
||||
/**
|
||||
* Deny Entry
|
||||
*/
|
||||
public boolean deny_entry;
|
||||
/**
|
||||
* List of helpers (with plot permissions)
|
||||
*/
|
||||
public ArrayList<UUID> helpers;
|
||||
/**
|
||||
* List of denied players
|
||||
*/
|
||||
public ArrayList<UUID> denied;
|
||||
/**
|
||||
* External settings class
|
||||
*/
|
||||
public PlotSettings settings;
|
||||
/**
|
||||
* Delete on next save cycle?
|
||||
*/
|
||||
public boolean delete;
|
||||
/**
|
||||
* Has the plot changed since the last save cycle?
|
||||
*/
|
||||
public boolean hasChanged = false;
|
||||
|
||||
/**
|
||||
* Primary constructor
|
||||
* @param id
|
||||
* @param owner
|
||||
* @param plotBiome
|
||||
* @param helpers
|
||||
* @param denied
|
||||
*/
|
||||
public Plot(PlotId id, UUID owner, Biome plotBiome, ArrayList<UUID> helpers, ArrayList<UUID> denied, String world) {
|
||||
this.id = id;
|
||||
this.settings = new PlotSettings(this);
|
||||
this.settings.setBiome(plotBiome);
|
||||
this.owner = owner;
|
||||
this.deny_entry = this.owner == null;
|
||||
this.helpers = helpers;
|
||||
this.denied = denied;
|
||||
this.settings.setTime(8000l);
|
||||
this.settings.setRain(false);
|
||||
this.settings.setTimeChange(false);
|
||||
this.settings.setAlias("");
|
||||
this.settings.setPosition(PlotHomePosition.DEFAULT);
|
||||
this.delete = false;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for saved plots
|
||||
* @param id
|
||||
* @param owner
|
||||
* @param plotBiome
|
||||
* @param helpers
|
||||
* @param denied
|
||||
* @param changeTime
|
||||
* @param time
|
||||
*/
|
||||
public Plot(PlotId id, UUID owner, Biome plotBiome, ArrayList<UUID> helpers, ArrayList<UUID> denied, boolean changeTime, long time, boolean rain, String alias, PlotHomePosition position, String world) {
|
||||
this.id = id;
|
||||
this.settings = new PlotSettings(this);
|
||||
this.settings.setBiome(plotBiome);
|
||||
this.owner = owner;
|
||||
this.deny_entry = this.owner != null;
|
||||
this.helpers = helpers;
|
||||
this.denied = denied;
|
||||
this.settings.setTime(time);
|
||||
this.settings.setRain(rain);
|
||||
this.settings.setTimeChange(changeTime);
|
||||
this.settings.setAlias(alias);
|
||||
this.settings.setPosition(position);
|
||||
this.delete = false;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the plot has a set owner
|
||||
* @return false if there is no owner
|
||||
*/
|
||||
public boolean hasOwner() {
|
||||
return this.owner != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the owner
|
||||
* @param player
|
||||
*/
|
||||
public void setOwner(Player player) {
|
||||
this.owner = player.getUniqueId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the player is either the owner or on the helpers list
|
||||
* @param player
|
||||
* @return true if the player is added as a helper or is the owner
|
||||
*/
|
||||
public boolean hasRights(Player player) {
|
||||
return player.hasPermission("plots.admin") || this.helpers != null && this.helpers.contains(DBFunc.everyone) || this.helpers != null && this.helpers.contains(player.getUniqueId()) || this.owner != null && this.owner.equals(player.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the player be allowed to enter?
|
||||
* @param player
|
||||
* @return false if the player is allowed to enter
|
||||
*/
|
||||
public boolean deny_entry(Player player) {
|
||||
return this.denied != null && (this.denied.contains(DBFunc.everyone) && !this.hasRights(player) || !this.hasRights(player) && this.denied.contains(player.getUniqueId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UUID of the owner
|
||||
*
|
||||
*/
|
||||
public UUID getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plot ID
|
||||
*
|
||||
*/
|
||||
public PlotId getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the plot World
|
||||
*
|
||||
*/
|
||||
public World getWorld() {
|
||||
return Bukkit.getWorld(this.world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a clone of the plot
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch(CloneNotSupportedException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deny someone (use DBFunc.addDenied() as well)
|
||||
* @param uuid
|
||||
*/
|
||||
public void addDenied(UUID uuid) { this.denied.add(uuid); }
|
||||
|
||||
/**
|
||||
* Add someone as a helper (use DBFunc as well)
|
||||
* @param uuid
|
||||
*/
|
||||
public void addHelper(UUID uuid) { this.helpers.add(uuid); }
|
||||
|
||||
/**
|
||||
* Get plot display name
|
||||
* @return alias if set, else id
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
if(this.settings.getAlias().length() > 1) {
|
||||
return this.settings.getAlias();
|
||||
}
|
||||
return this.getId().x+";"+this.getId().y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a denied player (use DBFunc as well)
|
||||
* @param uuid
|
||||
*/
|
||||
public void removeDenied(UUID uuid) { this.denied.remove(uuid); }
|
||||
|
||||
/**
|
||||
* Remove a helper (use DBFunc as well)
|
||||
* @param uuid
|
||||
*/
|
||||
public void removeHelper(UUID uuid) { this.helpers.remove(uuid); }
|
||||
|
||||
/**
|
||||
* Clear a plot
|
||||
* @param plr initiator
|
||||
*/
|
||||
public void clear(Player plr) {
|
||||
PlotHelper.clear(plr, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a plot
|
||||
* @param plr initiator
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public void delete(Player plr) { this.clear(plr); }
|
||||
}
|
@ -1,757 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = PlotHelper.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:43
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.intellectualcrafters.plot.Settings.*;
|
||||
|
||||
/**
|
||||
* plot functions
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class PlotHelper {
|
||||
|
||||
private static double calculateNeededTime(double blocks, double blocks_per_second) {
|
||||
return (blocks / blocks_per_second);
|
||||
}
|
||||
|
||||
public static Short[] getRandom(Random random, Object[] filling) {
|
||||
int len= ((Short[]) filling[0]).length;
|
||||
if (len==1) {
|
||||
return new Short[] {((Short[]) filling[0])[0],((Short[]) filling[1])[0]};
|
||||
}
|
||||
int index = random.nextInt(len);
|
||||
return new Short[] {((Short[]) filling[0])[index],((Short[]) filling[1])[index]};
|
||||
}
|
||||
|
||||
public static void removeSign(Player plr, Plot p) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(p.world));
|
||||
Location pl = new Location(plr.getWorld(), getPlotBottomLoc(plr.getWorld(), p.id).getBlockX() , plotworld.ROAD_HEIGHT + 1, getPlotBottomLoc(plr.getWorld(), p.id).getBlockZ());
|
||||
Block bs = pl.add(0,0,-1).getBlock();
|
||||
bs.setType(Material.AIR);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setSign(Player plr, Plot p) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(p.world));
|
||||
Location pl = new Location(plr.getWorld(), getPlotBottomLoc(plr.getWorld(), p.id).getBlockX() , plotworld.ROAD_HEIGHT + 1, getPlotBottomLoc(plr.getWorld(), p.id).getBlockZ());
|
||||
Block bs = pl.add(0,0,-1).getBlock();
|
||||
bs.setType(Material.AIR);
|
||||
bs.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false);
|
||||
String id = p.id.y+";"+p.id.x;
|
||||
Sign sign = (Sign) bs.getState();
|
||||
sign.setLine(0, C.OWNER_SIGN_LINE_1.translated().replaceAll("%id%", id));
|
||||
sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName()));
|
||||
sign.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName()));
|
||||
sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName()));
|
||||
sign.update(true);
|
||||
}
|
||||
|
||||
public static String getPlayerName(UUID uuid) {
|
||||
if(uuid == null) return "unknown";
|
||||
OfflinePlayer plr = Bukkit.getOfflinePlayer(uuid);
|
||||
if(plr == null) return "unknown";
|
||||
return plr.getName();
|
||||
}
|
||||
|
||||
public static String getStringSized(int max, String string) {
|
||||
if(string.length() > max) return string.substring(0,max);
|
||||
return string;
|
||||
}
|
||||
|
||||
public static void adjustWall(World w, Plot plot, short id, byte data) {
|
||||
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world));
|
||||
|
||||
List<String> wallIds = new ArrayList<String>();
|
||||
|
||||
wallIds.add("" + id + ":" + data);
|
||||
|
||||
Location bottom = getPlotBottomLoc(w, plot.id);
|
||||
Location top = getPlotTopLoc(w, plot.id);
|
||||
|
||||
int x, z;
|
||||
|
||||
Block block;
|
||||
|
||||
for (x = bottom.getBlockX(); x < top.getBlockX() + 1; x++) {
|
||||
z = bottom.getBlockZ();
|
||||
|
||||
block = w.getBlockAt(x, plotworld.ROAD_HEIGHT + 1, z);
|
||||
setWall(block, "" + id + ":" + data);
|
||||
}
|
||||
|
||||
for (z = bottom.getBlockZ(); z < top.getBlockZ() + 1; z++) {
|
||||
x = top.getBlockX() + 1;
|
||||
|
||||
block = w.getBlockAt(x, plotworld.ROAD_HEIGHT + 1, z);
|
||||
setWall(block, "" + id + ":" + data);
|
||||
}
|
||||
|
||||
for (x = top.getBlockX() + 1; x > bottom.getBlockX() - 1; x--) {
|
||||
z = top.getBlockZ() + 1;
|
||||
|
||||
block = w.getBlockAt(x, plotworld.ROAD_HEIGHT + 1, z);
|
||||
setWall(block, "" + id + ":" + data);
|
||||
}
|
||||
|
||||
for (z = top.getBlockZ() + 1; z > bottom.getBlockZ() - 1; z--) {
|
||||
x = bottom.getBlockX();
|
||||
block = w.getBlockAt(x, plotworld.ROAD_HEIGHT + 1, z);
|
||||
setWall(block, "" + id + ":" + data);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean createPlot(Player player, Plot plot) {
|
||||
@SuppressWarnings("deprecation")
|
||||
World w = plot.getWorld();
|
||||
Plot p = new Plot(plot.id, player.getUniqueId(), plot.settings.getBiome(), null, null, w.getName());
|
||||
PlotMain.updatePlot(p);
|
||||
DBFunc.createPlot(p);
|
||||
DBFunc.createPlotSettings(DBFunc.getId(w.getName(),p.id), p);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getLoadedChunks(World world) {
|
||||
return world.getLoadedChunks().length;
|
||||
}
|
||||
|
||||
public static int getEntities(World world) {
|
||||
return world.getEntities().size();
|
||||
}
|
||||
|
||||
public static int getTileEntities(World world) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
int x = 0;
|
||||
for(Chunk chunk : world.getLoadedChunks()) {
|
||||
x += chunk.getTileEntities().length;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public static double getWorldFolderSize(){
|
||||
//long size = FileUtils.sizeOfDirectory(Bukkit.getWorld(Settings.PLOT_WORLD).getWorldFolder());
|
||||
long size = 10;
|
||||
return (((size) / 1024) / 1024);
|
||||
}
|
||||
|
||||
// public static void adjustLinkedPlots(String id) {
|
||||
// World world = Bukkit.getWorld(Settings.PLOT_WORLD);
|
||||
// int x = getIdX(id);
|
||||
// int z = getIdZ(id);
|
||||
//
|
||||
// plot p11 = getPlot(id);
|
||||
// if (p11 != null) {
|
||||
// plot p01, p10, p12, p21, p00, p02, p20, p22;
|
||||
// p01 = getPlot(x - 1, z);
|
||||
// p10 = getPlot(x, z - 1);
|
||||
// p12 = getPlot(x, z + 1);
|
||||
// p21 = getPlot(x + 1, z);
|
||||
// p00 = getPlot(x - 1, z - 1);
|
||||
// p02 = getPlot(x - 1, z + 1);
|
||||
// p20 = getPlot(x + 1, z - 1);
|
||||
// p22 = getPlot(x + 1, z + 1);
|
||||
// if (p01 != null && p01.owner.equals(p11.owner)) {
|
||||
// fillroad(p01, p11, world);
|
||||
// }
|
||||
//
|
||||
// if (p10 != null && p10.owner.equals(p11.owner)) {
|
||||
// fillroad(p10, p11, world);
|
||||
// }
|
||||
//
|
||||
// if (p12 != null && p12.owner.equals(p11.owner)) {
|
||||
// fillroad(p12, p11, world);
|
||||
// }
|
||||
//
|
||||
// if (p21 != null && p21.owner.equals(p11.owner)) {
|
||||
// fillroad(p21, p11, world);
|
||||
// }
|
||||
//
|
||||
// if (p00 != null && p10 != null && p01 != null
|
||||
// && p00.owner.equals(p11.owner)
|
||||
// && p11.owner.equals(p10.owner)
|
||||
// && p10.owner.equals(p01.owner)) {
|
||||
// fillmiddleroad(p00, p11, world);
|
||||
// }
|
||||
//
|
||||
// if (p10 != null && p20 != null && p21 != null
|
||||
// && p10.owner.equals(p11.owner)
|
||||
// && p11.owner.equals(p20.owner)
|
||||
// && p20.owner.equals(p21.owner)) {
|
||||
// fillmiddleroad(p20, p11, world);
|
||||
// }
|
||||
//
|
||||
// if (p01 != null && p02 != null && p12 != null
|
||||
// && p01.owner.equals(p11.owner)
|
||||
// && p11.owner.equals(p02.owner)
|
||||
// && p02.owner.equals(p12.owner)) {
|
||||
// fillmiddleroad(p02, p11, world);
|
||||
// }
|
||||
//
|
||||
// if (p12 != null && p21 != null && p22 != null
|
||||
// && p12.owner.equals(p11.owner)
|
||||
// && p11.owner.equals(p21.owner)
|
||||
// && p21.owner.equals(p22.owner)) {
|
||||
// fillmiddleroad(p22, p11, world);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static void fillroad(plot plot1, plot plot2, World w) {
|
||||
// Location bottomPlot1, topPlot1, bottomPlot2, topPlot2;
|
||||
// bottomPlot1 = getPlotBottomLoc(w, plot1.id);
|
||||
// topPlot1 = getPlotTopLoc(w, plot1.id);
|
||||
// bottomPlot2 = getPlotBottomLoc(w, plot2.id);
|
||||
// topPlot2 = getPlotTopLoc(w, plot2.id);
|
||||
//
|
||||
// int minX, maxX, minZ, maxZ;
|
||||
//
|
||||
// boolean isWallX;
|
||||
//
|
||||
// int h = Settings.ROAD_HEIGHT;
|
||||
// int wallId = Settings.WALL_BLOCK;
|
||||
// int fillId = Settings.TOP_BLOCK;
|
||||
//
|
||||
// if(bottomPlot1.getBlockX() == bottomPlot2.getBlockX()) {
|
||||
// minX = bottomPlot1.getBlockX();
|
||||
// maxX = topPlot1.getBlockX();
|
||||
//
|
||||
// minZ = Math.min(bottomPlot1.getBlockZ(), bottomPlot2.getBlockZ()) + Settings.PLOT_WIDTH;
|
||||
// maxZ = Math.min(topPlot1.getBlockZ(), topPlot2.getBlockZ()) - Settings.PLOT_WIDTH;
|
||||
// } else {
|
||||
// minZ = bottomPlot1.getBlockZ();
|
||||
// maxZ = topPlot1.getBlockZ();
|
||||
//
|
||||
// minX = Math.min(bottomPlot1.getBlockX(), bottomPlot2.getBlockX()) + Settings.PLOT_WIDTH;
|
||||
// maxX = Math.max(topPlot1.getBlockX(), topPlot2.getBlockX()) - Settings.PLOT_WIDTH;
|
||||
// }
|
||||
//
|
||||
// isWallX = (maxX - minX) > (maxZ - minZ);
|
||||
//
|
||||
// if(isWallX) {
|
||||
// minX--;
|
||||
// maxX++;
|
||||
// } else {
|
||||
// minZ--;
|
||||
// maxZ++;
|
||||
// }
|
||||
//
|
||||
// for(int x = minX; x <= maxX; x++) {
|
||||
// for(int z = minZ; x <= maxZ; z++) {
|
||||
// for(int y = h; y < h + 3; y++) {
|
||||
// if(y >= (h + 2)) {
|
||||
// w.getBlockAt(x,y,z).setType(Material.AIR);
|
||||
// } else if(y == (h + 1)) {
|
||||
// if(isWallX && (x == minX || x == maxX)) {
|
||||
// w.getBlockAt(x,y,z).setTypeIdAndData(wallId, (byte) 0, true);
|
||||
// } else if(!isWallX && (z == minZ || z == maxZ)) {
|
||||
// w.getBlockAt(x,y,z).setTypeIdAndData(wallId, (byte) 0, true);
|
||||
// } else {
|
||||
// w.getBlockAt(x,y,z).setType(Material.AIR);
|
||||
// }
|
||||
// } else {
|
||||
// w.getBlockAt(x,y,z).setTypeIdAndData(fillId, (byte) 0, true);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static void fillmiddleroad(plot p1, plot p2, World w) {
|
||||
// Location b1 = getPlotBottomLoc(w, p1.id);
|
||||
// Location t1 = getPlotTopLoc(w, p1.id);
|
||||
// Location b2 = getPlotBottomLoc(w, p2.id);
|
||||
// Location t2 = getPlotTopLoc(w, p2.id);
|
||||
//
|
||||
// int minX, maxX, minZ, maxZ;
|
||||
//
|
||||
// int h = Settings.ROAD_HEIGHT;
|
||||
// int fillID = Settings.TOP_BLOCK;
|
||||
//
|
||||
// minX = Math.min(t1.getBlockX(), t2.getBlockX());
|
||||
// maxX = Math.max(b1.getBlockX(), b2.getBlockX());
|
||||
//
|
||||
// minZ = Math.min(t1.getBlockZ(), t2.getBlockZ());
|
||||
// maxZ = Math.max(b1.getBlockZ(), b2.getBlockZ());
|
||||
//
|
||||
// for(int x = minX; x <= maxX; x++) {
|
||||
// for(int z = minZ; z <= maxZ; z++) {
|
||||
// for(int y = h; y < h + 3; y++) {
|
||||
// if(y >= (h + 1)) {
|
||||
// w.getBlockAt(x,y,z).setType(Material.AIR);
|
||||
// } else {
|
||||
// w.getBlockAt(x,y,z).setTypeId(fillID);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public static String createId(int x, int z) {
|
||||
return x + ";" + z;
|
||||
}
|
||||
|
||||
public static ArrayList<String> runners_p = new ArrayList<String>();
|
||||
public static HashMap<Plot, Integer> runners = new HashMap<Plot, Integer>();
|
||||
|
||||
public static void adjustWallFilling(final Player requester, final World w, final Plot plot,
|
||||
final short id, final byte data) {
|
||||
if(runners.containsKey(plot)) {
|
||||
PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER);
|
||||
return;
|
||||
}
|
||||
PlayerFunctions.sendMessage(requester, C.GENERATING_WALL_FILLING);
|
||||
final PlotWorld plotworld = PlotMain.getWorldSettings(w);
|
||||
runners.put(
|
||||
plot,
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotMain.getMain(),
|
||||
new Runnable() {
|
||||
Location bottom = getPlotBottomLoc(w, plot.id);
|
||||
Location top = getPlotTopLoc(w, plot.id);
|
||||
int y = plotworld.ROAD_HEIGHT;
|
||||
int x, z;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (x = bottom.getBlockX(); x < top
|
||||
.getBlockX() + 1; x++) {
|
||||
z = bottom.getBlockZ();
|
||||
setWall(w.getBlockAt(x, y, z), "" + id
|
||||
+ ":" + data);
|
||||
}
|
||||
|
||||
for (z = bottom.getBlockZ(); z < top
|
||||
.getBlockZ() + 1; z++) {
|
||||
x = top.getBlockX() + 1;
|
||||
setWall(w.getBlockAt(x, y, z), "" + id
|
||||
+ ":" + data);
|
||||
}
|
||||
|
||||
for (x = top.getBlockX() + 1; x > bottom
|
||||
.getBlockX() - 1; x--) {
|
||||
z = top.getBlockZ() + 1;
|
||||
setWall(w.getBlockAt(x, y, z), "" + id
|
||||
+ ":" + data);
|
||||
}
|
||||
|
||||
for (z = top.getBlockZ() + 1; z > bottom
|
||||
.getBlockZ() - 1; z--) {
|
||||
x = bottom.getBlockX();
|
||||
setWall(w.getBlockAt(x, y, z), "" + id
|
||||
+ ":" + data);
|
||||
}
|
||||
|
||||
y--;
|
||||
if (y < 1) {
|
||||
int runner = runners.get(plot);
|
||||
runners.remove(plot);
|
||||
PlayerFunctions.sendMessage(requester, C.SET_BLOCK_ACTION_FINISHED);
|
||||
Bukkit.getScheduler().cancelTask(runner);
|
||||
}
|
||||
}
|
||||
}, 0l, 5l));
|
||||
}
|
||||
|
||||
public static void setFloor(final Player requester, final Plot plot, final Material material[], final byte data[]) {
|
||||
final PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world));
|
||||
if(runners.containsKey(plot)) {
|
||||
PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER);
|
||||
return;
|
||||
}
|
||||
String time = RUtils.formatTime(calculateNeededTime(square(plotworld.PLOT_WIDTH), 2 * plotworld.PLOT_WIDTH));
|
||||
String send = C.GENERATING_FLOOR.s().replaceAll("%time%", time);
|
||||
PlayerFunctions.sendMessage(requester, send);
|
||||
runners.put(plot, Bukkit.getScheduler().scheduleSyncRepeatingTask(PlotMain.getMain(), new Runnable() {
|
||||
World world = Bukkit.getWorld(plot.world);
|
||||
int x1 = getPlotBottomLoc(world, plot.id).getBlockX();
|
||||
int x2 = x1 + plotworld.PLOT_WIDTH;
|
||||
int z1 = getPlotBottomLoc(world, plot.id).getBlockZ();
|
||||
int z2 = z1 + plotworld.PLOT_WIDTH;
|
||||
|
||||
int xMin = Math.min(x1, x2) + 1;
|
||||
int xMax = Math.max(x1, x2);
|
||||
|
||||
int zMin = Math.min(z1, z2) + 1;
|
||||
int zMax = Math.max(z1, z2);
|
||||
Random random = new Random();
|
||||
int x = xMin;
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void run() {
|
||||
for(int z = zMin; z <= zMax; z++) {
|
||||
int y = plotworld.PLOT_HEIGHT;
|
||||
byte d;
|
||||
short id;
|
||||
if(material.length > 1) {
|
||||
int index = random.nextInt(material.length);
|
||||
d = data[index];
|
||||
id = (short) material[index].getId();
|
||||
} else {
|
||||
d = data[0];
|
||||
id = (short)material[0].getId();
|
||||
}
|
||||
world.getBlockAt(x, y, z).setTypeIdAndData(id,d, true);
|
||||
}
|
||||
x++;
|
||||
if(x > xMax) {
|
||||
int runner = runners.get(plot);
|
||||
runners.remove(plot);
|
||||
PlayerFunctions.sendMessage(requester, C.SET_BLOCK_ACTION_FINISHED);
|
||||
Bukkit.getScheduler().cancelTask(runner);
|
||||
}
|
||||
}
|
||||
|
||||
},0l, 10l));
|
||||
}
|
||||
|
||||
|
||||
public static int square(int x) {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
public static int getPlotSize(World world) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
return (square(plotworld.PLOT_WIDTH)) * (world.getMaxHeight());
|
||||
}
|
||||
public static Short[] getBlock(String block) {
|
||||
if (block.contains(":")) {
|
||||
String[] split = block.split(":");
|
||||
return new Short[] {Short.parseShort(split[0]),Short.parseShort(split[1])};
|
||||
}
|
||||
return new Short[] {Short.parseShort(block),0};
|
||||
}
|
||||
|
||||
public static void clear(final Player requester, final Plot plot) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world));
|
||||
long start = System.currentTimeMillis();
|
||||
PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST);
|
||||
PlotHelper.removeSign(requester, plot);
|
||||
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
|
||||
World world = requester.getWorld();
|
||||
Location pos1 = getPlotBottomLoc(world, plot.id);
|
||||
Location pos2 = getPlotTopLoc(world, plot.id);
|
||||
SetBlockFast setBlockClass = null;
|
||||
|
||||
Short[] plotfloors = new Short[plotworld.TOP_BLOCK.length];
|
||||
Short[] plotfloors_data = new Short[plotworld.TOP_BLOCK.length];
|
||||
|
||||
Short[] filling = new Short[plotworld.MAIN_BLOCK.length];
|
||||
Short[] filling_data = new Short[plotworld.MAIN_BLOCK.length];
|
||||
|
||||
for (int i = 0; i < plotworld.TOP_BLOCK.length; i++) {
|
||||
Short[] result = getBlock(plotworld.TOP_BLOCK[i]);
|
||||
plotfloors[i] = result[0];
|
||||
plotfloors_data[i] = result[1];
|
||||
}
|
||||
for (int i = 0; i < plotworld.MAIN_BLOCK.length; i++) {
|
||||
Short[] result = getBlock(plotworld.MAIN_BLOCK[i]);
|
||||
filling[i] = result[0];
|
||||
filling_data[i] = result[1];
|
||||
}
|
||||
try {
|
||||
setBlockClass = new SetBlockFast();
|
||||
regenerateCuboid(pos1, pos2,requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data});
|
||||
}
|
||||
catch (NoClassDefFoundError e) {
|
||||
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&cFast plot clearing is currently not enabled.");
|
||||
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&c - Please get PlotSquared for "+Bukkit.getVersion()+" for improved performance");
|
||||
}
|
||||
if (pos2.getBlockX()-pos1.getBlockX()<16) {
|
||||
regenerateCuboid(pos1, pos2,requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data});
|
||||
return;
|
||||
}
|
||||
int startX = (pos1.getBlockX()/16)*16;
|
||||
int startZ = (pos1.getBlockZ()/16)*16;
|
||||
int chunkX = 16+pos2.getBlockX();
|
||||
int chunkZ = 16+pos2.getBlockZ();
|
||||
int plotMinX = getPlotBottomLoc(world,plot.id).getBlockX()+1;
|
||||
int plotMinZ = getPlotBottomLoc(world,plot.id).getBlockZ()+1;
|
||||
int plotMaxX = getPlotTopLoc(world,plot.id).getBlockX();
|
||||
int plotMaxZ = getPlotTopLoc(world,plot.id).getBlockZ();
|
||||
Location min = null;
|
||||
Location max = null;
|
||||
for (int i = startX; i<chunkX;i+=16) {
|
||||
for (int j = startZ; j<chunkZ;j+=16) {
|
||||
Plot plot1 = getCurrentPlot(new Location(world, i, 0, j));
|
||||
if (plot1!=null && plot1.getId()!=plot.getId() && plot1.hasOwner()) {
|
||||
break;
|
||||
}
|
||||
Plot plot2 = getCurrentPlot(new Location(world, i+15, 0, j));
|
||||
if (plot2!=null && plot2.getId()!=plot.getId() && plot2.hasOwner()) {
|
||||
break;
|
||||
}
|
||||
Plot plot3 = getCurrentPlot(new Location(world, i+15, 0, j+15));
|
||||
if (plot3!=null && plot3.getId()!=plot.getId() && plot3.hasOwner()) {
|
||||
break;
|
||||
}
|
||||
Plot plot4 = getCurrentPlot(new Location(world, i, 0, j+15));
|
||||
if (plot4!=null && plot4.getId()!=plot.getId() && plot4.hasOwner()) {
|
||||
break;
|
||||
}
|
||||
Plot plot5 = getCurrentPlot(new Location(world, i+15, 0, j+15));
|
||||
if (plot5!=null && plot5.getId()!=plot.getId() && plot5.hasOwner()) {
|
||||
break;
|
||||
}
|
||||
if (min==null) {
|
||||
min = new Location(world, Math.max(i-1, plotMinX), 0, Math.max(j-1, plotMinZ));
|
||||
max = new Location(world, Math.min(i+16, plotMaxX), 0, Math.min(j+16, plotMaxZ));
|
||||
}
|
||||
else if (max.getBlockZ() < j + 15 || max.getBlockX() < i + 15) {
|
||||
max = new Location(world, Math.min(i+16, plotMaxX), 0, Math.min(j+16, plotMaxZ));
|
||||
}
|
||||
world.regenerateChunk(i/16, j/16);
|
||||
}
|
||||
}
|
||||
if (min==null) {
|
||||
regenerateCuboid(pos1, pos2,requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data});
|
||||
}
|
||||
else {
|
||||
int height = world.getMaxHeight();
|
||||
regenerateCuboid(new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getBlockX(), height, min.getBlockZ()),requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); //1
|
||||
regenerateCuboid(new Location(world, min.getBlockX(), 0, plotMinZ), new Location(world, max.getBlockX(), height, min.getBlockZ()),requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); //2
|
||||
regenerateCuboid(new Location(world, max.getBlockX(), 0, plotMinZ), new Location(world, plotMaxX, height, min.getBlockZ()),requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); //3
|
||||
regenerateCuboid(new Location(world, plotMinX, 0, min.getBlockZ()), new Location(world, min.getBlockX(), height, max.getBlockZ()),requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); //4
|
||||
regenerateCuboid(new Location(world, plotMinX, 0, max.getBlockZ()), new Location(world, min.getBlockX(), height, plotMaxZ),requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); //5
|
||||
regenerateCuboid(new Location(world, min.getBlockX(), 0, max.getBlockZ()), new Location(world, max.getBlockX(), height, plotMaxZ),requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); //6
|
||||
regenerateCuboid(new Location(world, max.getBlockX(), 0, min.getBlockZ()), new Location(world, plotMaxX, height, max.getBlockZ()),requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); //7
|
||||
regenerateCuboid(new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX, height, plotMaxZ),requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); //8
|
||||
}
|
||||
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", ""+((System.currentTimeMillis()-start)/1000.0)));
|
||||
if (setBlockClass!=null) {
|
||||
SetBlockFast.update(requester);
|
||||
}
|
||||
}
|
||||
public static void regenerateCuboid(Location pos1, Location pos2,Player player, PlotWorld plotworld, Object[] plotfloors, Object[] filling) {
|
||||
World world = pos1.getWorld();
|
||||
int zMin = pos1.getBlockZ();
|
||||
int zMax = pos2.getBlockZ();
|
||||
int xMin = pos1.getBlockX();
|
||||
int xMax = pos2.getBlockX();
|
||||
int height = pos2.getBlockY();
|
||||
Random random = new Random();
|
||||
|
||||
for (int y = 0; y<=height; y++) {
|
||||
for (int x = xMin; x<=xMax; x++) {
|
||||
for(int z = zMin; z <= zMax; z++) {
|
||||
short d = 0;
|
||||
short id = 0;
|
||||
boolean change = true;
|
||||
Block block = world.getBlockAt(x,y,z);
|
||||
int type = block.getTypeId();
|
||||
if(y == 0) {
|
||||
if(type != 7)
|
||||
id = (short) Material.BEDROCK.getId();
|
||||
else
|
||||
change = false;
|
||||
} else if(y == plotworld.PLOT_HEIGHT) {
|
||||
Short[] result = getRandom(random, plotfloors);
|
||||
id = result[0];
|
||||
d = result[1];
|
||||
} else if(y < plotworld.PLOT_HEIGHT) {
|
||||
Short[] result = getRandom(random, filling);
|
||||
id = result[0];
|
||||
d = result[1];
|
||||
} else if(y > plotworld.PLOT_HEIGHT && y < world.getMaxHeight()) {
|
||||
if(type != 0)
|
||||
id = 0;
|
||||
else
|
||||
change = false;
|
||||
}
|
||||
else {
|
||||
change = false;
|
||||
}
|
||||
if(change) {
|
||||
if (type!=id) {
|
||||
block.setTypeIdAndData(id, (byte) d, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void setBiome(World world, Plot plot, Biome b) {
|
||||
int bottomX = getPlotBottomLoc(world, plot.id).getBlockX() - 1;
|
||||
int topX = getPlotTopLoc(world, plot.id).getBlockX() + 1;
|
||||
int bottomZ = getPlotBottomLoc(world, plot.id).getBlockZ() - 1;
|
||||
int topZ = getPlotTopLoc(world, plot.id).getBlockZ() + 1;
|
||||
|
||||
for (int x = bottomX; x <= topX; x++) {
|
||||
for (int z = bottomZ; z <= topZ; z++) {
|
||||
world.getBlockAt(x, 0, z).setBiome(b);
|
||||
}
|
||||
}
|
||||
|
||||
plot.settings.setBiome(b);
|
||||
PlotMain.updatePlot(plot);
|
||||
refreshPlotChunks(world, plot);
|
||||
}
|
||||
|
||||
public static Location getPlotHome(World w, Plot plot) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(w);
|
||||
if(plot.settings.getPosition() == PlotHomePosition.DEFAULT) {
|
||||
int x = getPlotBottomLoc(w, plot.id).getBlockX()
|
||||
+ (getPlotTopLoc(w, plot.id).getBlockX() - getPlotBottomLoc(w,
|
||||
plot.id).getBlockX());
|
||||
int z = getPlotBottomLoc(w, plot.id).getBlockZ() - 2;
|
||||
return new Location(w, x, plotworld.ROAD_HEIGHT + 2, z);
|
||||
} else {
|
||||
World world = w;
|
||||
int x1 = getPlotBottomLoc(world, plot.id).getBlockX();
|
||||
int x2 = x1 + plotworld.PLOT_WIDTH;
|
||||
int z1 = getPlotBottomLoc(world, plot.id).getBlockZ();
|
||||
int z2 = z1 + plotworld.PLOT_WIDTH;
|
||||
|
||||
int xMin = Math.min(x1, x2) + 1;
|
||||
// int xMax = Math.max(x1, x2);
|
||||
|
||||
int zMin = Math.min(z1, z2) + 1;
|
||||
// int zMax = Math.max(z1, z2);
|
||||
|
||||
double adder = (plotworld.PLOT_WIDTH / 2);
|
||||
double x = (xMin + adder), y = plotworld.ROAD_HEIGHT + 3, z = (zMin + adder);
|
||||
return new Location(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
public static Location getPlotHome(World w, PlotId id) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(w);
|
||||
if(getPlot(w,id).settings.getPosition() == PlotHomePosition.DEFAULT) {
|
||||
int x = getPlotBottomLoc(w, id).getBlockX()
|
||||
+ (getPlotTopLoc(w, id).getBlockX() - getPlotBottomLoc(w, id)
|
||||
.getBlockX());
|
||||
int z = getPlotBottomLoc(w, id).getBlockZ() - 2;
|
||||
return new Location(w, x, plotworld.ROAD_HEIGHT + 2, z);
|
||||
} else {
|
||||
World world = w;
|
||||
int x1 = getPlotBottomLoc(world, id).getBlockX();
|
||||
int x2 = x1 + plotworld.PLOT_WIDTH;
|
||||
int z1 = getPlotBottomLoc(world, id).getBlockZ();
|
||||
int z2 = z1 + plotworld.PLOT_WIDTH;
|
||||
|
||||
int xMin = Math.min(x1, x2) + 1;
|
||||
int xMax = Math.max(x1, x2);
|
||||
|
||||
int zMin = Math.min(z1, z2) + 1;
|
||||
int zMax = Math.max(z1, z2);
|
||||
|
||||
double adder = (plotworld.PLOT_WIDTH / 2);
|
||||
double x = (xMin + adder), y = plotworld.ROAD_HEIGHT + 3, z = (zMin + adder);
|
||||
return new Location(world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
public static void refreshPlotChunks(World world, Plot plot) {
|
||||
int bottomX = getPlotBottomLoc(world, plot.id).getBlockX();
|
||||
int topX = getPlotTopLoc(world, plot.id).getBlockX();
|
||||
int bottomZ = getPlotBottomLoc(world, plot.id).getBlockZ();
|
||||
int topZ = getPlotTopLoc(world, plot.id).getBlockZ();
|
||||
|
||||
int minChunkX = (int) Math.floor((double) bottomX / 16);
|
||||
int maxChunkX = (int) Math.floor((double) topX / 16);
|
||||
int minChunkZ = (int) Math.floor((double) bottomZ / 16);
|
||||
int maxChunkZ = (int) Math.floor((double) topZ / 16);
|
||||
|
||||
for (int x = minChunkX; x <= maxChunkX; x++) {
|
||||
for (int z = minChunkZ; z <= maxChunkZ; z++) {
|
||||
world.refreshChunk(x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Location getPlotTopLoc(World world, PlotId id) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
int px = id.x;
|
||||
int pz = id.y;
|
||||
|
||||
int x = px * (plotworld.ROAD_WIDTH + plotworld.PLOT_WIDTH)
|
||||
- ((int) Math.floor(plotworld.ROAD_WIDTH / 2)) - 1;
|
||||
int z = pz * (plotworld.ROAD_WIDTH + plotworld.PLOT_WIDTH)
|
||||
- ((int) Math.floor(plotworld.ROAD_WIDTH / 2)) - 1;
|
||||
|
||||
return new Location(world, x, 255, z);
|
||||
}
|
||||
|
||||
public static Location getPlotBottomLoc(World world, PlotId id) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
int px = id.x;
|
||||
int pz = id.y;
|
||||
|
||||
int x = px * (plotworld.ROAD_WIDTH + plotworld.PLOT_WIDTH) - plotworld.PLOT_WIDTH
|
||||
- ((int) Math.floor(plotworld.ROAD_WIDTH / 2)) - 1;
|
||||
int z = pz * (plotworld.ROAD_WIDTH + plotworld.PLOT_WIDTH) - plotworld.PLOT_WIDTH
|
||||
- ((int) Math.floor(plotworld.ROAD_WIDTH / 2)) - 1;
|
||||
|
||||
return new Location(world, x, 1, z);
|
||||
}
|
||||
|
||||
public static Plot getPlot(World world, PlotId id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
if (PlotMain.getPlots(world).containsKey(id)) {
|
||||
return PlotMain.getPlots(world).get(id);
|
||||
}
|
||||
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), world.getName());
|
||||
}
|
||||
|
||||
public static Plot getCurrentPlot(Location loc) {
|
||||
/*
|
||||
* Vector vector = player.getLocation().toVector(); for(plot plot :
|
||||
* getPlots()) if(vector.isInAABB(plot.l1.toVector(),
|
||||
* plot.l2.toVector())) return plot; return null;
|
||||
*/
|
||||
PlotId id = PlayerFunctions.getPlot(loc);
|
||||
if (id.equals("...") || id.equals("road")) {
|
||||
return null;
|
||||
}
|
||||
if (PlotMain.getPlots(loc.getWorld()).containsKey(id)) {
|
||||
return PlotMain.getPlots(loc.getWorld()).get(id);
|
||||
}
|
||||
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), loc.getWorld().getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "deprecation" })
|
||||
private static void setWall(Block block, String currentBlockId) {
|
||||
int blockId;
|
||||
byte blockData = 0;
|
||||
if (currentBlockId.contains(":")) {
|
||||
try {
|
||||
blockId = Integer.parseInt(currentBlockId.substring(0,
|
||||
currentBlockId.indexOf(":")));
|
||||
blockData = Byte.parseByte(currentBlockId
|
||||
.substring(currentBlockId.indexOf(":") + 1));
|
||||
} catch (NumberFormatException e) {
|
||||
blockId = 1;
|
||||
blockData = (byte) 0;
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
blockId = Integer.parseInt(currentBlockId);
|
||||
} catch (NumberFormatException e) {
|
||||
blockId = 1;
|
||||
blockData = (byte) 0;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
block.setTypeIdAndData(blockId, blockData, true);
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = PlotHomePosition.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:44
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-05.
|
||||
*/
|
||||
public enum PlotHomePosition {
|
||||
CENTER("Center", 'c'),
|
||||
DEFAULT("Default", 'd')
|
||||
;
|
||||
|
||||
private String string;
|
||||
private char ch;
|
||||
PlotHomePosition(String string, char ch) {
|
||||
this.string = string;
|
||||
this.ch = ch;
|
||||
}
|
||||
|
||||
public boolean isMatching(String string) {
|
||||
if(string.length() < 2 && string.charAt(0) == this.ch) return true;
|
||||
if(string.equalsIgnoreCase(this.string)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public class PlotId {
|
||||
public int x;
|
||||
public int y;
|
||||
public PlotId(int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
PlotId other = (PlotId) obj;
|
||||
return (this.x==other.x && this.y==other.y);
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + x;
|
||||
result = prime * result + y;
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,740 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Main.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:43
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import ca.mera.CameraAPI;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.Camera;
|
||||
import com.intellectualcrafters.plot.database.*;
|
||||
import com.intellectualcrafters.plot.Logger.LogLevel;
|
||||
import com.intellectualcrafters.plot.Settings.Web;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
|
||||
import com.intellectualcrafters.plot.listeners.PlayerEvents;
|
||||
import com.intellectualcrafters.plot.listeners.WorldEditListener;
|
||||
import com.intellectualsites.web.PlotWeb;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
|
||||
import me.confuser.barapi.BarAPI;
|
||||
import net.gravitydevelopment.updater.Updater;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.bukkit.Material.*;
|
||||
|
||||
/**
|
||||
* @awesome @author Empire92
|
||||
* @author Citymonstret
|
||||
* PlotMain class.
|
||||
*/
|
||||
public class PlotMain extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* settings.properties
|
||||
*/
|
||||
public static File configFile;
|
||||
public static YamlConfiguration config;
|
||||
private static int config_ver = 1;
|
||||
/**
|
||||
* storage.properties
|
||||
*/
|
||||
public static File storageFile;
|
||||
public static YamlConfiguration storage;
|
||||
public static int storage_ver = 1;
|
||||
/**
|
||||
* translations.properties
|
||||
*/
|
||||
public static File translationsFile;
|
||||
public static YamlConfiguration translations;
|
||||
public static int translations_ver = 1;
|
||||
/**
|
||||
* MySQL Object
|
||||
*/
|
||||
private static MySQL mySQL;
|
||||
/**
|
||||
* MySQL Connection
|
||||
*/
|
||||
public static Connection connection;
|
||||
/**
|
||||
* WorldEdit object
|
||||
*/
|
||||
public static WorldEditPlugin worldEdit = null;
|
||||
/**
|
||||
* BarAPI object
|
||||
*/
|
||||
public static BarAPI barAPI = null;
|
||||
/**
|
||||
* CameraAPI object
|
||||
*/
|
||||
public static CameraAPI cameraAPI;
|
||||
|
||||
/**
|
||||
* !!WorldGeneration!!
|
||||
*/
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldname, String id) {
|
||||
return new WorldGenerator(worldname);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Implement better system
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void checkForExpiredPlots() {
|
||||
final JavaPlugin plugin = PlotMain.getMain();
|
||||
Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
checkExpired(plugin, true);
|
||||
}
|
||||
}, 0l, 12 * 60 * 60 * 20l);
|
||||
}
|
||||
|
||||
/**
|
||||
* All loaded plots
|
||||
*/
|
||||
private static HashMap<String, HashMap<PlotId, Plot>> plots;
|
||||
/**
|
||||
* All loaded plot worlds
|
||||
*/
|
||||
private static HashMap<String, PlotWorld> worlds = new HashMap<String, PlotWorld>();
|
||||
|
||||
/**
|
||||
* Get all plots
|
||||
*
|
||||
* @return HashMap containing the plot ID and the plot object.
|
||||
*/
|
||||
public static Set<Plot> getPlots() {
|
||||
ArrayList<Plot> myplots = new ArrayList<Plot>();
|
||||
for (HashMap<PlotId, Plot> world:plots.values()) {
|
||||
myplots.addAll(world.values());
|
||||
}
|
||||
return new HashSet<Plot>(myplots);
|
||||
}
|
||||
|
||||
public static Set<Plot> getPlots(Player player) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
ArrayList<Plot> myplots = new ArrayList<Plot>();
|
||||
for (HashMap<PlotId, Plot> world:plots.values()) {
|
||||
for (Plot plot:world.values()) {
|
||||
if (plot.getOwner().equals(uuid)) {
|
||||
myplots.add(plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new HashSet<Plot>(myplots);
|
||||
}
|
||||
public static Set<Plot> getPlots(World world, Player player) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
ArrayList<Plot> myplots = new ArrayList<Plot>();
|
||||
for (Plot plot:getPlots(world).values()) {
|
||||
if (plot.getOwner().equals(uuid)) {
|
||||
myplots.add(plot);
|
||||
}
|
||||
}
|
||||
return new HashSet<Plot>(myplots);
|
||||
}
|
||||
|
||||
public static HashMap<PlotId, Plot> getPlots(World world) {
|
||||
if (plots.containsKey(world.getName())) {
|
||||
return plots.get(world.getName());
|
||||
}
|
||||
return new HashMap<PlotId, Plot>();
|
||||
}
|
||||
/**
|
||||
* get all plot worlds
|
||||
*/
|
||||
public static World[] getPlotWorlds() {
|
||||
return (worlds.keySet().toArray(new World[0]));
|
||||
}
|
||||
public static String[] getPlotWorldsString() {
|
||||
return plots.keySet().toArray(new String[0]);
|
||||
}
|
||||
public static boolean isPlotWorld(World world) {
|
||||
return (worlds.containsKey(world.getName()));
|
||||
}
|
||||
public static PlotWorld getWorldSettings(World world) {
|
||||
if (worlds.containsKey(world.getName()))
|
||||
return worlds.get(world.getName());
|
||||
return null;
|
||||
}
|
||||
public static PlotWorld getWorldSettings(String world) {
|
||||
if (worlds.containsKey(world))
|
||||
return worlds.get(world);
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param world
|
||||
* @return set containing the plots for a world
|
||||
*/
|
||||
public static Plot[] getWorldPlots(World world) {
|
||||
return (Plot[])(plots.get(world.getName()).values().toArray(new Plot[0]));
|
||||
}
|
||||
|
||||
public static void removePlot(String world, PlotId id) {
|
||||
plots.get(world).remove(id);
|
||||
}
|
||||
/**
|
||||
* Replace the plot object with an updated version
|
||||
*
|
||||
* @param id plot Id
|
||||
* @param plot plot object
|
||||
*/
|
||||
public static void updatePlot(Plot plot) {
|
||||
String world = plot.world;
|
||||
if (!plots.containsKey(world))
|
||||
plots.put(world,new HashMap<PlotId, Plot>());
|
||||
plot.hasChanged = true;
|
||||
plots.get(world).put(plot.id, plot);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Implement better system
|
||||
*
|
||||
* @param plugin Plugin
|
||||
* @param async Call async?
|
||||
*/
|
||||
private static void checkExpired(JavaPlugin plugin, boolean async) {
|
||||
if (async) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (String world:getPlotWorldsString()) {
|
||||
if (plots.containsKey(world)) {
|
||||
for (Plot plot : plots.get(world).values()) {
|
||||
if (plot.owner == null) {
|
||||
continue;
|
||||
}
|
||||
if (PlayerFunctions.hasExpired(plot)) {
|
||||
DBFunc.delete(world, plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (String world:getPlotWorldsString()) {
|
||||
if (PlotMain.plots.containsKey(world)) {
|
||||
for (Plot plot : PlotMain.plots.get(world).values()) {
|
||||
if (PlayerFunctions.hasExpired(plot)) {
|
||||
DBFunc.delete(world, plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On Load.
|
||||
* TODO: Load updates async
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onEnable() {
|
||||
{
|
||||
File log = new File(getMain().getDataFolder() + File.separator + "logs" + File.separator + "plots.log");
|
||||
if (!log.exists()) {
|
||||
try {
|
||||
if (!new File(getMain().getDataFolder() + File.separator + "logs").mkdirs()) {
|
||||
sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to create logs folder. Do it manually.");
|
||||
}
|
||||
if (log.createNewFile()) {
|
||||
FileWriter writer = new FileWriter(log);
|
||||
writer.write("Created at: " + new Date().toString() + "\n\n\n");
|
||||
writer.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Logger.setup(log);
|
||||
Logger.add(LogLevel.GENERAL, "Logger enabled");
|
||||
}
|
||||
configs();
|
||||
|
||||
// TODO make this configurable
|
||||
PlotWorld.BLOCKS = new ArrayList<>(Arrays.asList(new Material[]{
|
||||
ACACIA_STAIRS, BEACON, BEDROCK,
|
||||
BIRCH_WOOD_STAIRS, BOOKSHELF,
|
||||
BREWING_STAND, BRICK, BRICK_STAIRS,
|
||||
BURNING_FURNACE, CAKE_BLOCK,
|
||||
CAULDRON, CLAY_BRICK, CLAY,
|
||||
COAL_BLOCK, COAL_ORE, COBBLE_WALL,
|
||||
COBBLESTONE, COBBLESTONE_STAIRS,
|
||||
COMMAND, DARK_OAK_STAIRS,
|
||||
DAYLIGHT_DETECTOR, DIAMOND_ORE,
|
||||
DIAMOND_BLOCK, DIRT, DISPENSER,
|
||||
DROPPER, EMERALD_BLOCK, EMERALD_ORE,
|
||||
ENCHANTMENT_TABLE, ENDER_PORTAL_FRAME,
|
||||
ENDER_STONE, FURNACE, GLOWSTONE,
|
||||
GOLD_ORE, GOLD_BLOCK, GRASS,
|
||||
GRAVEL, GLASS, HARD_CLAY,
|
||||
HAY_BLOCK, HUGE_MUSHROOM_1,
|
||||
HUGE_MUSHROOM_2, IRON_BLOCK,
|
||||
IRON_ORE, JACK_O_LANTERN, JUKEBOX,
|
||||
JUNGLE_WOOD_STAIRS, LAPIS_BLOCK,
|
||||
LAPIS_ORE, LEAVES, LEAVES_2,
|
||||
LOG, LOG_2, MELON_BLOCK,
|
||||
MOB_SPAWNER, MOSSY_COBBLESTONE,
|
||||
MYCEL, NETHER_BRICK,
|
||||
NETHER_BRICK_STAIRS, NETHERRACK,
|
||||
NOTE_BLOCK, OBSIDIAN, PACKED_ICE,
|
||||
PUMPKIN, QUARTZ_BLOCK, QUARTZ_ORE,
|
||||
QUARTZ_STAIRS, REDSTONE_BLOCK,
|
||||
SANDSTONE, SAND, SANDSTONE_STAIRS,
|
||||
SMOOTH_BRICK, SMOOTH_STAIRS,
|
||||
SNOW_BLOCK, SOUL_SAND, SPONGE,
|
||||
SPRUCE_WOOD_STAIRS, STONE, WOOD,
|
||||
WOOD_STAIRS, WORKBENCH, WOOL,
|
||||
getMaterial(44), getMaterial(126)}));
|
||||
if (Settings.KILL_ROAD_MOBS)
|
||||
killAllEntities();
|
||||
|
||||
if (C.ENABLED.s().length() > 0) {
|
||||
Broadcast(C.ENABLED);
|
||||
}
|
||||
if (Settings.Update.AUTO_UPDATE) {
|
||||
Updater updater = new Updater(this, 83369, this.getFile(), Updater.UpdateType.DEFAULT, true);
|
||||
switch (updater.getResult()) {
|
||||
case SUCCESS:
|
||||
sendConsoleSenderMessage(C.PREFIX.s() + "&cUpdate " + updater.getLatestName() + " installed successfully. Restart the server to load it.");
|
||||
break;
|
||||
case FAIL_DOWNLOAD:
|
||||
sendConsoleSenderMessage(C.PREFIX.s() + "&cUpdate could not be installed.");
|
||||
break;
|
||||
case UPDATE_AVAILABLE:
|
||||
sendConsoleSenderMessage(C.PREFIX.s() + ChatColor.GREEN + "There is an available update.");
|
||||
break;
|
||||
default:
|
||||
sendConsoleSenderMessage(C.PREFIX.s() + ChatColor.GREEN + "You're using the latest update.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Settings.DB.USE_MYSQL) {
|
||||
try {
|
||||
mySQL = new MySQL(this, Settings.DB.HOST_NAME, Settings.DB.PORT,
|
||||
Settings.DB.DATABASE, Settings.DB.USER,
|
||||
Settings.DB.PASSWORD);
|
||||
connection = mySQL.openConnection();
|
||||
{
|
||||
DatabaseMetaData meta = connection.getMetaData();
|
||||
ResultSet res = meta.getTables(null, null, "plot", null);
|
||||
if(!res.next())
|
||||
DBFunc.createTables();
|
||||
}
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
Logger.add(LogLevel.DANGER, "MySQL connection failed.");
|
||||
System.out.print("\u001B[31m[Plots] MySQL is not setup correctly. The plugin will disable itself.\u001B[0m");
|
||||
System.out.print("\u001B[36m==== Here is an ugly stacktrace if you are interested in those things ====\u001B[0m");
|
||||
e.printStackTrace();
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
plots = DBFunc.getPlots();
|
||||
|
||||
} else if (Settings.DB.USE_MONGO) {
|
||||
sendConsoleSenderMessage(C.PREFIX.s() + "MongoDB is not yet implemented");
|
||||
} else {
|
||||
Logger.add(LogLevel.DANGER, "No storage type is set.");
|
||||
sendConsoleSenderMessage(C.PREFIX + "&cNo storage type is set!");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
if (getServer().getPluginManager().getPlugin("PlotMe") != null ) {
|
||||
try {
|
||||
new PlotMeConverter(this).runAsync();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
getCommand("plots").setExecutor(new MainCommand());
|
||||
getCommand("plots").setAliases(
|
||||
new ArrayList<String>() {
|
||||
{
|
||||
add("p");
|
||||
add("plotme");
|
||||
add("plot");
|
||||
}
|
||||
});
|
||||
getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("CameraAPI") != null ){
|
||||
cameraAPI = CameraAPI.getInstance();
|
||||
Camera camera = new Camera();
|
||||
MainCommand.subCommands.add(camera);
|
||||
getServer().getPluginManager().registerEvents(camera, this);
|
||||
}
|
||||
if (getServer().getPluginManager().getPlugin("BarAPI") != null) {
|
||||
barAPI = (BarAPI) getServer().getPluginManager().getPlugin("BarAPI");
|
||||
}
|
||||
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
||||
worldEdit = (WorldEditPlugin) getServer().getPluginManager()
|
||||
.getPlugin("WorldEdit");
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new WorldEditListener(), this);
|
||||
}
|
||||
checkExpired(PlotMain.getMain(), true);
|
||||
checkForExpiredPlots();
|
||||
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Lag(),
|
||||
100L, 1L);
|
||||
if(Web.ENABLED) {
|
||||
try {
|
||||
PlotWeb web = new PlotWeb("PlotWeb", Web.PORT);
|
||||
web.start();
|
||||
sendConsoleSenderMessage("Web Server running on port " + Web.PORT);
|
||||
} catch(Exception e) {
|
||||
sendConsoleSenderMessage("Failed to start web server.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get MySQL Connection
|
||||
*
|
||||
* @return connection MySQL Connection.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
/** .. */
|
||||
|
||||
//Old Stuff
|
||||
/*private static boolean checkForUpdate() throws IOException {
|
||||
URL call = new URL(Settings.Update.VERSION_URL);
|
||||
InputStream stream = call.openStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||
String latest = reader.readLine();
|
||||
reader.close();
|
||||
return !getPlotMain().getDescription().getVersion().equalsIgnoreCase(latest);
|
||||
}
|
||||
|
||||
private static String getNextUpdateString() throws IOException {
|
||||
URL call = new URL(Settings.Update.VERSION_URL);
|
||||
InputStream stream = call.openStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||
return reader.readLine();
|
||||
}
|
||||
|
||||
private static void update() throws IOException {
|
||||
sendConsoleSenderMessage(C.PREFIX.s() + "&c&lThere is an update! New Update: &6&l" + getNextUpdateString() + "&c&l, Current Update: &6&l" + getPlotMain().getDescription().getVersion());
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Send a message to the console.
|
||||
*
|
||||
* @param string message
|
||||
*/
|
||||
public static void sendConsoleSenderMessage(String string) {
|
||||
getMain().getServer().getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', string));
|
||||
}
|
||||
|
||||
public static boolean teleportPlayer(Player player, Location from, Plot plot) {
|
||||
PlayerTeleportToPlotEvent event = new PlayerTeleportToPlotEvent(player, from, plot);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled()) {
|
||||
Location location = PlotHelper.getPlotHome(Bukkit.getWorld(plot.world), plot);
|
||||
if(location.getBlockX() >= 29999999 || location.getBlockX() <= -29999999 ||
|
||||
location.getBlockZ() >= 299999999 ||location.getBlockZ() <= -29999999) {
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
}
|
||||
player.teleport(location);
|
||||
PlayerFunctions.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||
}
|
||||
return event.isCancelled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the console
|
||||
*
|
||||
* @param c message
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static void sendConsoleSenderMessage(C c) {
|
||||
sendConsoleSenderMessage(c.s());
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast publicly
|
||||
*
|
||||
* @param c message
|
||||
*/
|
||||
public static void Broadcast(C c) {
|
||||
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&',
|
||||
C.PREFIX.s() + c.s()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the main class.
|
||||
*
|
||||
* @return (this class)
|
||||
*/
|
||||
public static PlotMain getMain() {
|
||||
return JavaPlugin.getPlugin(PlotMain.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast a message to all admins
|
||||
*
|
||||
* @param c message
|
||||
*/
|
||||
public static void BroadcastWithPerms(C c) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (player.hasPermission("plots.admin"))
|
||||
PlayerFunctions.sendMessage(player, c);
|
||||
}
|
||||
System.out.println(ChatColor.stripColor(ChatColor
|
||||
.translateAlternateColorCodes('&', C.PREFIX.s() + c.s())));
|
||||
}
|
||||
|
||||
|
||||
public static void reloadTranslations() throws IOException {
|
||||
translations = YamlConfiguration.loadConfiguration(translationsFile);
|
||||
}
|
||||
/**
|
||||
* Load configuration files
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void configs() {
|
||||
File folder = new File(getMain().getDataFolder() + File.separator + "config");
|
||||
if (!folder.exists() && !folder.mkdirs()) {
|
||||
sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to create the /plugins/config folder. Please create it manually.");
|
||||
}
|
||||
try {
|
||||
configFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator +"settings.yml");
|
||||
if (!configFile.exists()) {
|
||||
configFile.createNewFile();
|
||||
}
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
setupConfig();
|
||||
}
|
||||
catch (Exception err_trans) {
|
||||
Logger.add(LogLevel.DANGER, "Failed to save settings.yml");
|
||||
System.out.println("Failed to save settings.yml");
|
||||
}
|
||||
try {
|
||||
storageFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator +"storage.yml");
|
||||
if (!storageFile.exists()) {
|
||||
storageFile.createNewFile();
|
||||
}
|
||||
storage = YamlConfiguration.loadConfiguration(storageFile);
|
||||
setupStorage();
|
||||
}
|
||||
catch (Exception err_trans) {
|
||||
Logger.add(LogLevel.DANGER, "Failed to save storage.yml");
|
||||
System.out.println("Failed to save storage.yml");
|
||||
}
|
||||
try {
|
||||
translationsFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator +"translations.yml");
|
||||
if (!translationsFile.exists()) {
|
||||
translationsFile.createNewFile();
|
||||
}
|
||||
translations = YamlConfiguration.loadConfiguration(translationsFile);
|
||||
setupTranslations();
|
||||
}
|
||||
catch (Exception err_trans) {
|
||||
Logger.add(LogLevel.DANGER, "Failed to save translations.yml");
|
||||
System.out.println("Failed to save translations.yml");
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
config.save(configFile);
|
||||
storage.save(storageFile);
|
||||
translations.save(translationsFile);
|
||||
} catch (IOException e) {
|
||||
Logger.add(LogLevel.DANGER, "Configuration file saving failed");
|
||||
e.printStackTrace();
|
||||
}
|
||||
{
|
||||
Settings.DB.USE_MYSQL = true;
|
||||
Settings.DB.USER = storage.getString("mysql_user");
|
||||
Settings.DB.PASSWORD = storage.getString("mysql_password");
|
||||
Settings.DB.HOST_NAME = storage.getString("mysql_host");
|
||||
Settings.DB.PORT = storage.getString("mysql_port");
|
||||
Settings.DB.DATABASE = storage.getString("mysql_database");
|
||||
}
|
||||
{
|
||||
Settings.Update.AUTO_UPDATE = config.getBoolean("auto_update");
|
||||
|
||||
|
||||
|
||||
//Web
|
||||
Web.ENABLED = config.getBoolean("web.enabled");
|
||||
Web.PORT = config.getInt("web.port");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kill all entities on roads
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void killAllEntities() {
|
||||
Bukkit.getScheduler().scheduleAsyncRepeatingTask(getMain(),
|
||||
new Runnable() {
|
||||
World world;
|
||||
Location location;
|
||||
long ticked = 0l;
|
||||
long error = 0l;
|
||||
@Override
|
||||
public void run() {
|
||||
for (World w: getPlotWorlds()) {
|
||||
World world = w;
|
||||
try {
|
||||
if(world.getLoadedChunks().length < 1) {
|
||||
return;
|
||||
}
|
||||
for (Chunk chunk : world.getLoadedChunks()) {
|
||||
for (Entity entity : chunk.getEntities()){
|
||||
if (entity.getType() == EntityType.PLAYER)
|
||||
continue;
|
||||
location = entity.getLocation();
|
||||
if (!PlayerEvents.isInPlot(location))
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
++error;
|
||||
}
|
||||
finally {
|
||||
++ticked;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0l, 2l);
|
||||
}
|
||||
|
||||
/**
|
||||
* SETUP: settings.properties
|
||||
*/
|
||||
private static void setupConfig() {
|
||||
config.set("version", config_ver);
|
||||
Map<String, Object> options = new HashMap<String, Object>();
|
||||
options.put("auto_update", false);
|
||||
options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT);
|
||||
options.put("web.enabled", Web.ENABLED);
|
||||
options.put("web.port", Web.PORT);
|
||||
for (Entry<String, Object> node : options.entrySet()) {
|
||||
if (!config.contains(node.getKey())) {
|
||||
config.set(node.getKey(), node.getValue());
|
||||
}
|
||||
}
|
||||
for (String node:config.getConfigurationSection("worlds").getKeys(false)) {
|
||||
World world = Bukkit.getWorld(node);
|
||||
if (world==null) {
|
||||
Logger.add(LogLevel.WARNING, "World '"+node+"' in settings.yml does not exist (case sensitive)");
|
||||
}
|
||||
else {
|
||||
ChunkGenerator gen = world.getGenerator();
|
||||
if (gen==null || gen.toString().equals("PlotSquared")) {
|
||||
Logger.add(LogLevel.WARNING, "World '"+node+"' in settings.yml is not using PlotSquared generator");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SETUP: storage.properties
|
||||
*/
|
||||
private static void setupStorage() {
|
||||
storage.set("version", storage_ver);
|
||||
Map<String, Object> options = new HashMap<String, Object>();
|
||||
options.put("mysql_host", "localhost");
|
||||
options.put("mysql_port", "3306");
|
||||
options.put("mysql_user", "root");
|
||||
options.put("mysql_password", "password");
|
||||
options.put("mysql_database", "plot_db");
|
||||
for (Entry<String, Object> node : options.entrySet()) {
|
||||
if (!storage.contains(node.getKey())) {
|
||||
storage.set(node.getKey(), node.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SETUP: translations.properties
|
||||
*/
|
||||
public static void setupTranslations() {
|
||||
translations.set("version", translations_ver);
|
||||
for (C c : C.values()) {
|
||||
if (!translations.contains(c.toString())) {
|
||||
translations.set(c.toString(), c.s());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On unload
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Logger.add(LogLevel.GENERAL, "Logger disabled");
|
||||
try {
|
||||
Logger.write();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
try {
|
||||
connection.close();
|
||||
mySQL.closeConnection();
|
||||
}
|
||||
catch (NullPointerException | SQLException e) {
|
||||
if (connection!=null) {
|
||||
Logger.add(LogLevel.DANGER, "Could not close mysql connection");
|
||||
}
|
||||
}
|
||||
if(PlotWeb.PLOTWEB != null) {
|
||||
try {
|
||||
PlotWeb.PLOTWEB.stop();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void addPlotWorld(String world,PlotWorld plotworld) {
|
||||
PlotMain.worlds.put(world,plotworld);
|
||||
if(!plots.containsKey(world))
|
||||
plots.put(world, new HashMap<PlotId, Plot>());
|
||||
}
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = PlotSettings.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:44
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
/**
|
||||
* plot settings
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class PlotSettings {
|
||||
|
||||
private String alias;
|
||||
/**
|
||||
* plot object
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private Plot plot;
|
||||
/**
|
||||
* plot biome
|
||||
*/
|
||||
private Biome biome;
|
||||
/**
|
||||
* plot rain
|
||||
*/
|
||||
private boolean rain;
|
||||
/**
|
||||
* plot time
|
||||
*/
|
||||
private Long time;
|
||||
/**
|
||||
* Change time?
|
||||
*/
|
||||
private boolean changeTime;
|
||||
private PlotHomePosition position;
|
||||
/**
|
||||
* Constructor
|
||||
* @param plot
|
||||
*/
|
||||
public PlotSettings(Plot plot) {
|
||||
this.plot = plot;
|
||||
this.alias = "";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param b
|
||||
*/
|
||||
public void setBiome(Biome b) {
|
||||
this.biome = b;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param b
|
||||
*/
|
||||
public void setTimeChange(boolean b) {
|
||||
this.changeTime = b;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param l
|
||||
*/
|
||||
public void setTime(long l) {
|
||||
this.time = l;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @deprecated
|
||||
*/
|
||||
public Biome getBiome() {
|
||||
return this.biome;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean getRain() {
|
||||
return this.rain;
|
||||
}
|
||||
|
||||
public void setRain(boolean b) {
|
||||
this.rain = b;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getTime() {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean getChangeTime() {
|
||||
return this.changeTime;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setAlias(String alias) {
|
||||
this.alias = alias;
|
||||
}
|
||||
|
||||
public PlotHomePosition getPosition() { return this.position; }
|
||||
public void setPosition(PlotHomePosition position) { this.position = position; }
|
||||
public String getAlias() { return this.alias; }
|
||||
public String getJoinMessage() { return ""; }
|
||||
|
||||
public String getLeaveMessage() { return ""; }
|
||||
}
|
@ -1,163 +0,0 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class PlotWorld {
|
||||
/**
|
||||
* Road Height
|
||||
*/
|
||||
public int ROAD_HEIGHT;
|
||||
/**
|
||||
* Default Road Height: 64
|
||||
*/
|
||||
public static int ROAD_HEIGHT_DEFAULT = 64;
|
||||
|
||||
/**
|
||||
* plot height
|
||||
*/
|
||||
public int PLOT_HEIGHT;
|
||||
/**
|
||||
* Default plot height: 64
|
||||
*/
|
||||
public static int PLOT_HEIGHT_DEFAULT = 64;
|
||||
|
||||
/**
|
||||
* Wall height
|
||||
*/
|
||||
public int WALL_HEIGHT;
|
||||
/**
|
||||
* Default Wall Height: 64
|
||||
*/
|
||||
public static int WALL_HEIGHT_DEFAULT = 64;
|
||||
|
||||
/**
|
||||
* plot width
|
||||
*/
|
||||
public int PLOT_WIDTH;
|
||||
/**
|
||||
* Default plot width: 32
|
||||
*/
|
||||
public static int PLOT_WIDTH_DEFAULT = 32;
|
||||
|
||||
/**
|
||||
* Road width
|
||||
*/
|
||||
public int ROAD_WIDTH;
|
||||
/**
|
||||
* Default road width: 7
|
||||
*/
|
||||
public static int ROAD_WIDTH_DEFAULT = 7;
|
||||
|
||||
/**
|
||||
* Plot biome
|
||||
*/
|
||||
public String PLOT_BIOME;
|
||||
/**
|
||||
* Default biome = FOREST
|
||||
*/
|
||||
public static String PLOT_BIOME_DEFAULT = "FOREST";
|
||||
/**
|
||||
* PlotMain block
|
||||
*/
|
||||
public String[] MAIN_BLOCK;
|
||||
/**
|
||||
* Default main block: 1
|
||||
*/
|
||||
public static String[] MAIN_BLOCK_DEFAULT = new String[] {"1:0"};
|
||||
/**
|
||||
* Top blocks
|
||||
*/
|
||||
public String[] TOP_BLOCK;
|
||||
/**
|
||||
* Default top blocks: {"2"}
|
||||
*/
|
||||
public static String[] TOP_BLOCK_DEFAULT = new String[] {"2:0"};
|
||||
|
||||
/**
|
||||
* Wall block
|
||||
*/
|
||||
public String WALL_BLOCK;
|
||||
/**
|
||||
* Default wall block: 44
|
||||
*/
|
||||
public static String WALL_BLOCK_DEFAULT = "44:0";
|
||||
|
||||
/**
|
||||
* Wall filling
|
||||
*/
|
||||
public String WALL_FILLING;
|
||||
/**
|
||||
* Default wall filling: 1
|
||||
*/
|
||||
public static String WALL_FILLING_DEFAULT = "1:0";
|
||||
|
||||
// /**
|
||||
// * Road stripes
|
||||
// */
|
||||
// public int ROAD_STRIPES;
|
||||
// /**
|
||||
// * Default road stripes: 35
|
||||
// */
|
||||
// public static int ROAD_STRIPES_DEFAULT = 35;
|
||||
//
|
||||
// /**
|
||||
// * Road stripes data value (byte)
|
||||
// */
|
||||
// public int ROAD_STRIPES_DATA;
|
||||
// /**
|
||||
// * Default road stripes data value: (byte) 0
|
||||
// */
|
||||
// public static int ROAD_STRIPES_DATA_DEFAULT = 0;
|
||||
//
|
||||
// /**
|
||||
// * Wall block data value (byte)
|
||||
// */
|
||||
// public int WALL_BLOCK_DATA;
|
||||
// /**
|
||||
// * Default wall block data value: (byte) 0
|
||||
// */
|
||||
// public static int WALL_BLOCK_DATA_DEFAULT = 0;
|
||||
//
|
||||
// /**
|
||||
// * Wall filling data value (byte)
|
||||
// */
|
||||
// public int WALL_FILLING_DATA;
|
||||
// /**
|
||||
// * Default wall filling data value: (byte) 0
|
||||
// */
|
||||
// public static int WALL_FILLING_DATA_DEFAULT = 0;
|
||||
/**
|
||||
* Road block
|
||||
*/
|
||||
public String ROAD_BLOCK;
|
||||
/**
|
||||
* Default road block: 155
|
||||
*/
|
||||
public static String ROAD_BLOCK_DEFAULT = "155:0";
|
||||
//
|
||||
// /**
|
||||
// * Road block data value (byte)
|
||||
// */
|
||||
// public int ROAD_BLOCK_DATA;
|
||||
// /**
|
||||
// * Default road block data value: (byte) 0
|
||||
// */
|
||||
// public static int ROAD_BLOCK_DATA_DEFAULT = 0;
|
||||
|
||||
/**
|
||||
* plot chat?
|
||||
*/
|
||||
public boolean PLOT_CHAT;
|
||||
/**
|
||||
* Default plot chat: true
|
||||
*/
|
||||
public static boolean PLOT_CHAT_DEFAULT = false;
|
||||
|
||||
/**
|
||||
* Blocks available in /p set
|
||||
*/
|
||||
public static ArrayList<Material> BLOCKS = new ArrayList<Material>();
|
||||
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = RUtils.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:44
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Random utilities
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class RUtils {
|
||||
|
||||
public static long getTotalRam() {
|
||||
return (Runtime.getRuntime().maxMemory() / 1024) / 1024;
|
||||
}
|
||||
|
||||
public static long getFreeRam() {
|
||||
return (Runtime.getRuntime().freeMemory() / 1024) / 1024;
|
||||
}
|
||||
|
||||
public static long getRamPercentage() {
|
||||
return (getFreeRam() / getTotalRam()) * 100;
|
||||
}
|
||||
|
||||
public static String formatTime(double sec) {
|
||||
double h = sec / 3600;
|
||||
double m = (sec % 3600) / 60;
|
||||
double s = sec % 60;
|
||||
String string = C.TIME_FORMAT.s();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
//String s_d = (int) d + " " + (d != 1 ? "days" : "day");
|
||||
String s_h = (int) h + " " + ((int) h != 1 ? "hours" : "hour");
|
||||
String s_m = (int) m + " " + ((int) m != 1 ? "minutes" : "minute");
|
||||
String s_s = (int) s + " " + ((int) s != 1 ? "seconds" : "second");
|
||||
return string.replaceAll("%sec%", s_s).replaceAll("%min%", s_m).replaceAll("%hours%", s_h);
|
||||
}
|
||||
|
||||
enum Direction {
|
||||
SOUTH(0),
|
||||
EAST(1),
|
||||
NORTH(2),
|
||||
WEST(3)
|
||||
;
|
||||
private int i;
|
||||
Direction(int i) {
|
||||
this.i = i;
|
||||
}
|
||||
public int getInt() {
|
||||
return this.i;
|
||||
}
|
||||
}
|
||||
|
||||
public void forceTexture(Player p) {
|
||||
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
|
||||
}
|
||||
|
||||
public Direction getDirection(Location l) {
|
||||
double d = (l.getYaw() * 4.0F / 360.0F) + 0.5D;
|
||||
int i = (int) d;
|
||||
int x = d < i ? i - 1 : i;
|
||||
|
||||
float yaw;
|
||||
|
||||
|
||||
|
||||
switch(x) {
|
||||
case 0:
|
||||
return Direction.SOUTH;
|
||||
case 1:
|
||||
return Direction.EAST;
|
||||
case 2:
|
||||
return Direction.NORTH;
|
||||
case 3:
|
||||
return Direction.WEST;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean compareDirections(Location l1, Location l2) {
|
||||
return getDirection(l1) == getDirection(l2);
|
||||
}
|
||||
|
||||
private boolean AND(boolean b1, boolean b2) {
|
||||
return b1 && b2;
|
||||
}
|
||||
|
||||
private boolean OR(boolean b1, boolean b2) {
|
||||
return b1 || b2;
|
||||
}
|
||||
|
||||
private boolean XOR(boolean b1, boolean b2) {
|
||||
return b1 ^ b2;
|
||||
}
|
||||
|
||||
private boolean NAND(boolean b1, boolean b2) {
|
||||
return !b1 && !b2;
|
||||
}
|
||||
|
||||
private boolean NOR(boolean b1, boolean b2) {
|
||||
return !b1 || !b2;
|
||||
}
|
||||
|
||||
}
|
@ -1,483 +0,0 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author DPOH-VAR
|
||||
* @version 1.0
|
||||
*/
|
||||
@SuppressWarnings({ "UnusedDeclaration", "rawtypes" })
|
||||
public class ReflectionUtils {
|
||||
|
||||
/** prefix of bukkit classes */
|
||||
private static String preClassB = "org.bukkit.craftbukkit";
|
||||
/** prefix of minecraft classes */
|
||||
private static String preClassM = "net.minecraft.server";
|
||||
/** boolean value, TRUE if server uses forge or MCPC+ */
|
||||
private static boolean forge = false;
|
||||
|
||||
/** check server version and class names */
|
||||
static {
|
||||
if(Bukkit.getServer()!=null) {
|
||||
if(Bukkit.getVersion().contains("MCPC")||Bukkit.getVersion().contains("Forge")) forge = true;
|
||||
Server server = Bukkit.getServer();
|
||||
Class<?> bukkitServerClass = server.getClass();
|
||||
String[] pas = bukkitServerClass.getName().split("\\.");
|
||||
if (pas.length == 5) {
|
||||
String verB = pas[3];
|
||||
preClassB += "."+verB;
|
||||
}
|
||||
try {
|
||||
Method getHandle = bukkitServerClass.getDeclaredMethod("getHandle");
|
||||
Object handle = getHandle.invoke(server);
|
||||
Class handleServerClass = handle.getClass();
|
||||
pas = handleServerClass.getName().split("\\.");
|
||||
if (pas.length == 5) {
|
||||
String verM = pas[3];
|
||||
preClassM += "."+verM;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if server has forge classes
|
||||
*/
|
||||
public static boolean isForge(){
|
||||
return forge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class for name.
|
||||
* Replace {nms} to net.minecraft.server.V*.
|
||||
* Replace {cb} to org.bukkit.craftbukkit.V*.
|
||||
* Replace {nm} to net.minecraft
|
||||
* @param classes possible class paths
|
||||
* @return RefClass object
|
||||
* @throws RuntimeException if no class found
|
||||
*/
|
||||
public static RefClass getRefClass(String... classes){
|
||||
for (String className: classes) try {
|
||||
className = className
|
||||
.replace("{cb}", preClassB)
|
||||
.replace("{nms}", preClassM)
|
||||
.replace("{nm}", "net.minecraft");
|
||||
return getRefClass(Class.forName(className));
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
throw new RuntimeException("no class found");
|
||||
}
|
||||
|
||||
/**
|
||||
* get RefClass object by real class
|
||||
* @param clazz class
|
||||
* @return RefClass based on passed class
|
||||
*/
|
||||
public static RefClass getRefClass(Class clazz) {
|
||||
return new RefClass(clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* RefClass - utility to simplify work with reflections.
|
||||
*/
|
||||
public static class RefClass {
|
||||
private final Class<?> clazz;
|
||||
|
||||
/**
|
||||
* get passed class
|
||||
* @return class
|
||||
*/
|
||||
public Class<?> getRealClass() {
|
||||
return clazz;
|
||||
}
|
||||
private RefClass(Class<?> clazz) {
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
/**
|
||||
* see {@link Class#isInstance(Object)}
|
||||
* @param object the object to check
|
||||
* @return true if object is an instance of this class
|
||||
*/
|
||||
public boolean isInstance(Object object){
|
||||
return clazz.isInstance(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* get existing method by name and types
|
||||
* @param name name
|
||||
* @param types method parameters. can be Class or RefClass
|
||||
* @return RefMethod object
|
||||
* @throws RuntimeException if method not found
|
||||
*/
|
||||
public RefMethod getMethod(String name, Object... types) {
|
||||
try {
|
||||
Class[] classes = new Class[types.length];
|
||||
int i=0; for (Object e: types) {
|
||||
if (e instanceof Class) classes[i++] = (Class)e;
|
||||
else if (e instanceof RefClass) classes[i++] = ((RefClass) e).getRealClass();
|
||||
else classes[i++] = e.getClass();
|
||||
}
|
||||
try {
|
||||
return new RefMethod(clazz.getMethod(name, classes));
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
return new RefMethod(clazz.getDeclaredMethod(name, classes));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get existing constructor by types
|
||||
* @param types parameters. can be Class or RefClass
|
||||
* @return RefMethod object
|
||||
* @throws RuntimeException if constructor not found
|
||||
*/
|
||||
public RefConstructor getConstructor(Object... types) {
|
||||
try {
|
||||
Class[] classes = new Class[types.length];
|
||||
int i=0; for (Object e: types) {
|
||||
if (e instanceof Class) classes[i++] = (Class)e;
|
||||
else if (e instanceof RefClass) classes[i++] = ((RefClass) e).getRealClass();
|
||||
else classes[i++] = e.getClass();
|
||||
}
|
||||
try {
|
||||
return new RefConstructor(clazz.getConstructor(classes));
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
return new RefConstructor(clazz.getDeclaredConstructor(classes));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* find method by type parameters
|
||||
* @param types parameters. can be Class or RefClass
|
||||
* @return RefMethod object
|
||||
* @throws RuntimeException if method not found
|
||||
*/
|
||||
public RefMethod findMethod(Object... types) {
|
||||
Class[] classes = new Class[types.length];
|
||||
int t=0; for (Object e: types) {
|
||||
if (e instanceof Class) classes[t++] = (Class)e;
|
||||
else if (e instanceof RefClass) classes[t++] = ((RefClass) e).getRealClass();
|
||||
else classes[t++] = e.getClass();
|
||||
}
|
||||
List<Method> methods = new ArrayList<>();
|
||||
Collections.addAll(methods, clazz.getMethods());
|
||||
Collections.addAll(methods, clazz.getDeclaredMethods());
|
||||
findMethod: for (Method m: methods) {
|
||||
Class<?>[] methodTypes = m.getParameterTypes();
|
||||
if (methodTypes.length != classes.length) continue;
|
||||
for (int i=0; i<classes.length; i++) {
|
||||
if (!classes.equals(methodTypes)) continue findMethod;
|
||||
return new RefMethod(m);
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("no such method");
|
||||
}
|
||||
|
||||
/**
|
||||
* find method by name
|
||||
* @param names possible names of method
|
||||
* @return RefMethod object
|
||||
* @throws RuntimeException if method not found
|
||||
*/
|
||||
public RefMethod findMethodByName(String... names) {
|
||||
List<Method> methods = new ArrayList<>();
|
||||
Collections.addAll(methods, clazz.getMethods());
|
||||
Collections.addAll(methods, clazz.getDeclaredMethods());
|
||||
for (Method m: methods) {
|
||||
for (String name: names) {
|
||||
if (m.getName().equals(name)) {
|
||||
return new RefMethod(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("no such method");
|
||||
}
|
||||
|
||||
/**
|
||||
* find method by return value
|
||||
* @param type type of returned value
|
||||
* @throws RuntimeException if method not found
|
||||
* @return RefMethod
|
||||
*/
|
||||
public RefMethod findMethodByReturnType(RefClass type) {
|
||||
return findMethodByReturnType(type.clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* find method by return value
|
||||
* @param type type of returned value
|
||||
* @return RefMethod
|
||||
* @throws RuntimeException if method not found
|
||||
*/
|
||||
public RefMethod findMethodByReturnType(Class type) {
|
||||
if (type==null) type = void.class;
|
||||
List<Method> methods = new ArrayList<>();
|
||||
Collections.addAll(methods, clazz.getMethods());
|
||||
Collections.addAll(methods, clazz.getDeclaredMethods());
|
||||
for (Method m: methods) {
|
||||
if (type.equals(m.getReturnType())) {
|
||||
return new RefMethod(m);
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("no such method");
|
||||
}
|
||||
|
||||
/**
|
||||
* find constructor by number of arguments
|
||||
* @param number number of arguments
|
||||
* @return RefConstructor
|
||||
* @throws RuntimeException if constructor not found
|
||||
*/
|
||||
public RefConstructor findConstructor(int number) {
|
||||
List<Constructor> constructors = new ArrayList<>();
|
||||
Collections.addAll(constructors, clazz.getConstructors());
|
||||
Collections.addAll(constructors, clazz.getDeclaredConstructors());
|
||||
for (Constructor m: constructors) {
|
||||
if (m.getParameterTypes().length == number) return new RefConstructor(m);
|
||||
}
|
||||
throw new RuntimeException("no such constructor");
|
||||
}
|
||||
|
||||
/**
|
||||
* get field by name
|
||||
* @param name field name
|
||||
* @return RefField
|
||||
* @throws RuntimeException if field not found
|
||||
*/
|
||||
public RefField getField(String name) {
|
||||
try {
|
||||
try {
|
||||
return new RefField(clazz.getField(name));
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
return new RefField(clazz.getDeclaredField(name));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* find field by type
|
||||
* @param type field type
|
||||
* @return RefField
|
||||
* @throws RuntimeException if field not found
|
||||
*/
|
||||
public RefField findField(RefClass type) {
|
||||
return findField(type.clazz);
|
||||
}
|
||||
|
||||
/**
|
||||
* find field by type
|
||||
* @param type field type
|
||||
* @return RefField
|
||||
* @throws RuntimeException if field not found
|
||||
*/
|
||||
public RefField findField(Class type) {
|
||||
if (type==null) type = void.class;
|
||||
List<Field> fields = new ArrayList<>();
|
||||
Collections.addAll(fields, clazz.getFields());
|
||||
Collections.addAll(fields, clazz.getDeclaredFields());
|
||||
for (Field f: fields) {
|
||||
if (type.equals(f.getType())) {
|
||||
return new RefField(f);
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("no such field");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method wrapper
|
||||
*/
|
||||
public static class RefMethod {
|
||||
private final Method method;
|
||||
|
||||
/**
|
||||
* @return passed method
|
||||
*/
|
||||
public Method getRealMethod(){
|
||||
return method;
|
||||
}
|
||||
/**
|
||||
* @return owner class of method
|
||||
*/
|
||||
public RefClass getRefClass(){
|
||||
return new RefClass(method.getDeclaringClass());
|
||||
}
|
||||
/**
|
||||
* @return class of method return type
|
||||
*/
|
||||
public RefClass getReturnRefClass(){
|
||||
return new RefClass(method.getReturnType());
|
||||
}
|
||||
private RefMethod (Method method) {
|
||||
this.method = method;
|
||||
method.setAccessible(true);
|
||||
}
|
||||
/**
|
||||
* apply method to object
|
||||
* @param e object to which the method is applied
|
||||
* @return RefExecutor with method call(...)
|
||||
*/
|
||||
public RefExecutor of(Object e) {
|
||||
return new RefExecutor(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* call static method
|
||||
* @param params sent parameters
|
||||
* @return return value
|
||||
*/
|
||||
public Object call(Object... params) {
|
||||
try{
|
||||
return method.invoke(null,params);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public class RefExecutor {
|
||||
Object e;
|
||||
public RefExecutor(Object e) {
|
||||
this.e = e;
|
||||
}
|
||||
|
||||
/**
|
||||
* apply method for selected object
|
||||
* @param params sent parameters
|
||||
* @return return value
|
||||
* @throws RuntimeException if something went wrong
|
||||
*/
|
||||
public Object call(Object... params) {
|
||||
try{
|
||||
return method.invoke(e,params);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor wrapper
|
||||
*/
|
||||
public static class RefConstructor {
|
||||
private final Constructor constructor;
|
||||
|
||||
/**
|
||||
* @return passed constructor
|
||||
*/
|
||||
public Constructor getRealConstructor(){
|
||||
return constructor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return owner class of method
|
||||
*/
|
||||
public RefClass getRefClass(){
|
||||
return new RefClass(constructor.getDeclaringClass());
|
||||
}
|
||||
private RefConstructor (Constructor constructor) {
|
||||
this.constructor = constructor;
|
||||
constructor.setAccessible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* create new instance with constructor
|
||||
* @param params parameters for constructor
|
||||
* @return new object
|
||||
* @throws RuntimeException if something went wrong
|
||||
*/
|
||||
public Object create(Object... params) {
|
||||
try{
|
||||
return constructor.newInstance(params);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class RefField {
|
||||
private Field field;
|
||||
|
||||
/**
|
||||
* @return passed field
|
||||
*/
|
||||
public Field getRealField(){
|
||||
return field;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return owner class of field
|
||||
*/
|
||||
public RefClass getRefClass(){
|
||||
return new RefClass(field.getDeclaringClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return type of field
|
||||
*/
|
||||
public RefClass getFieldRefClass(){
|
||||
return new RefClass(field.getType());
|
||||
}
|
||||
private RefField (Field field) {
|
||||
this.field = field;
|
||||
field.setAccessible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* apply fiend for object
|
||||
* @param e applied object
|
||||
* @return RefExecutor with getter and setter
|
||||
*/
|
||||
public RefExecutor of(Object e) {
|
||||
return new RefExecutor(e);
|
||||
}
|
||||
public class RefExecutor {
|
||||
Object e;
|
||||
public RefExecutor(Object e) {
|
||||
this.e = e;
|
||||
}
|
||||
|
||||
/**
|
||||
* set field value for applied object
|
||||
* @param param value
|
||||
*/
|
||||
public void set(Object param) {
|
||||
try{
|
||||
field.set(e,param);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get field value for applied object
|
||||
* @return value of field
|
||||
*/
|
||||
public Object get() {
|
||||
try{
|
||||
return field.get(e);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import com.sk89q.jnbt.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-09-15.
|
||||
*/
|
||||
public class SchematicHandler {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean paste(Location location, Schematic schematic) {
|
||||
if(schematic == null) {
|
||||
PlotMain.sendConsoleSenderMessage("Schematic == null :|");
|
||||
return false;
|
||||
}
|
||||
|
||||
Dimension dimension = schematic.getSchematicDimension();
|
||||
DataCollection[] collection = schematic.getBlockCollection();
|
||||
World world = location.getWorld();
|
||||
|
||||
for(int x = 0; x < dimension.getX(); x++) {
|
||||
for(int y = 0; y < dimension.getY(); y++) {
|
||||
for(int z = 0; z < dimension.getZ(); z++) {
|
||||
DataCollection current = collection[getCurrent(x, y, z, dimension)];
|
||||
(new Location(world, location.getBlockX() + x, location.getBlockY() + y, location.getBlockZ() + z).getBlock()).setTypeIdAndData(current.getBlock(), current.getData(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Schematic getSchematic(String name) {
|
||||
{
|
||||
File parent = new File(PlotMain.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics");
|
||||
if(!parent.exists()) {
|
||||
parent.mkdir();
|
||||
}
|
||||
}
|
||||
File file = new File(PlotMain.getPlugin(PlotMain.class).getDataFolder() + File.separator + "schematics" + File.separator + name + ".schematic");
|
||||
if(!file.exists()) {
|
||||
PlotMain.sendConsoleSenderMessage(file.toString() + " doesn't exist");
|
||||
return null;
|
||||
}
|
||||
|
||||
Schematic schematic = null;
|
||||
try {
|
||||
InputStream iStream = new FileInputStream(file);
|
||||
NBTInputStream stream = new NBTInputStream(new GZIPInputStream(iStream));
|
||||
CompoundTag tag = (CompoundTag) stream.readTag();
|
||||
Map<String, Tag> tagMap = tag.getValue();
|
||||
|
||||
byte[] addId = new byte[0];
|
||||
if (tagMap.containsKey("AddBlocks")) {
|
||||
addId = ByteArrayTag.class.cast(tagMap.get("AddBlocks")).getValue();
|
||||
}
|
||||
|
||||
short width = ShortTag.class.cast(tagMap.get("Width")).getValue();
|
||||
short length = ShortTag.class.cast(tagMap.get("Length")).getValue();
|
||||
short height = ShortTag.class.cast(tagMap.get("Height")).getValue();
|
||||
|
||||
byte[] b = ByteArrayTag.class.cast(tagMap.get("Blocks")).getValue();
|
||||
byte[] d = ByteArrayTag.class.cast(tagMap.get("Data")).getValue();
|
||||
short[] blocks = new short[b.length];
|
||||
|
||||
Dimension dimension = new Dimension(width, height, length);
|
||||
|
||||
for (int index = 0; index < b.length; index++) {
|
||||
if ((index >> 1) >= addId.length) { // No corresponding AddBlocks index
|
||||
blocks[index] = (short) (b[index] & 0xFF);
|
||||
} else {
|
||||
if ((index & 1) == 0) {
|
||||
blocks[index] = (short) (((addId[index >> 1] & 0x0F) << 8) + (b[index] & 0xFF));
|
||||
} else {
|
||||
blocks[index] = (short) (((addId[index >> 1] & 0xF0) << 4) + (b[index] & 0xFF));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DataCollection[] collection = new DataCollection[b.length];
|
||||
|
||||
for(int x = 0; x < b.length; x++) {
|
||||
collection[x] = new DataCollection(blocks[x], d[x]);
|
||||
}
|
||||
|
||||
schematic = new Schematic(collection, dimension);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} finally {
|
||||
return schematic;
|
||||
}
|
||||
}
|
||||
|
||||
private int getCurrent(int x, int y, int z, Dimension dimension) {
|
||||
return (x * dimension.getX()) + (y * dimension.getY()) + (z * dimension.getZ());
|
||||
}
|
||||
|
||||
public class Schematic {
|
||||
private DataCollection[] blockCollection;
|
||||
private Dimension schematicDimension;
|
||||
|
||||
public Schematic(DataCollection[] blockCollection, Dimension schematicDimension) {
|
||||
this.blockCollection = blockCollection;
|
||||
this.schematicDimension = schematicDimension;
|
||||
}
|
||||
|
||||
public Dimension getSchematicDimension() {
|
||||
return this.schematicDimension;
|
||||
}
|
||||
|
||||
public DataCollection[] getBlockCollection() {
|
||||
return this.blockCollection;
|
||||
}
|
||||
}
|
||||
|
||||
public class Dimension {
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
public Dimension(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
}
|
||||
|
||||
public class DataCollection {
|
||||
private short block;
|
||||
private byte data;
|
||||
|
||||
public DataCollection(short block, byte data) {
|
||||
this.block = block;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public short getBlock() {
|
||||
return this.block;
|
||||
}
|
||||
|
||||
public byte getData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static com.intellectualcrafters.plot.ReflectionUtils.*;
|
||||
|
||||
public class SetBlockFast {
|
||||
|
||||
private static final RefClass classBlock = getRefClass("{nms}.Block");
|
||||
private static final RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
private static final RefClass classWorld = getRefClass("{nms}.World");
|
||||
private static final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
|
||||
|
||||
private static final RefMethod methodGetHandle = classCraftWorld.getMethod("getHandle");
|
||||
private static final RefMethod methodGetChunkAt = classWorld.getMethod("getChunkAt",int.class,int.class);
|
||||
private static final RefMethod methodA = classChunk.getMethod("a",int.class,int.class,int.class,classBlock,int.class);
|
||||
private static final RefMethod methodGetById = classBlock.getMethod("getById", int.class);
|
||||
|
||||
public SetBlockFast() {
|
||||
|
||||
}
|
||||
|
||||
public static boolean set(org.bukkit.World world, int x, int y, int z, int blockId, byte data) {
|
||||
Object w = methodGetHandle.of(world).call();
|
||||
|
||||
Object chunk = methodGetChunkAt.of(w).call(x >> 4, z >> 4);
|
||||
Object block = methodGetById.of(null).call(blockId);
|
||||
methodA.of(chunk).call(x & 0x0f, y, z & 0x0f,block , data);
|
||||
return true;
|
||||
}
|
||||
public static void update(Player player) {
|
||||
for (int cx = -8; cx < 8; cx++) {
|
||||
for (int cz = -8; cz < 8; cz++) {
|
||||
player.getWorld().refreshChunk(player.getLocation().getChunk().getX() + cx, player.getLocation().getChunk().getZ() + cz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Settings.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:44
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Updater and DB settings
|
||||
* @author Citymonstret
|
||||
*
|
||||
* @author Empire92
|
||||
*/
|
||||
public class Settings {
|
||||
/**
|
||||
* plot specific resource pack
|
||||
*/
|
||||
public static String PLOT_SPECIFIC_RESOURCE_PACK = "";
|
||||
/**
|
||||
* Kill road mobs?
|
||||
*/
|
||||
public static boolean KILL_ROAD_MOBS;
|
||||
/**
|
||||
* Default kill road mobs: true
|
||||
*/
|
||||
public static boolean KILL_ROAD_MOBS_DEFAULT = true;
|
||||
/**
|
||||
* Update settings
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public static String URL = "http://dev.bukkit.org/bukkit-plugins/plotsquared/";
|
||||
public static class Update {
|
||||
/**
|
||||
* Update plugin?
|
||||
*/
|
||||
public static boolean AUTO_UPDATE = false;
|
||||
}
|
||||
|
||||
public static class Web {
|
||||
public static boolean ENABLED = false;
|
||||
public static int PORT = 9000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Database settings
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public static class DB {
|
||||
public static boolean USE_MONGO = false; /* TODO: Implement Mongo */;
|
||||
public static boolean USE_MYSQL = true; /* NOTE: Fixed connector */
|
||||
public static String HOST_NAME = "localhost";
|
||||
public static String PORT = "3306";
|
||||
public static String DATABASE = "plot_db";
|
||||
public static String USER = "root";
|
||||
public static String PASSWORD = "password";
|
||||
}
|
||||
}
|
@ -1,436 +0,0 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Minecraft 1.8 Title
|
||||
*
|
||||
* @version 1.0.3
|
||||
* @author Maxim Van de Wynckel
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class Title {
|
||||
/* Title packet */
|
||||
private Class<?> packetTitle;
|
||||
/* Title packet actions ENUM */
|
||||
private Class<?> packetActions;
|
||||
/* Chat serializer */
|
||||
private Class<?> nmsChatSerializer;
|
||||
/* Title text and color */
|
||||
private String title = "";
|
||||
private ChatColor titleColor = ChatColor.WHITE;
|
||||
/* Subtitle text and color */
|
||||
private String subtitle = "";
|
||||
private ChatColor subtitleColor = ChatColor.WHITE;
|
||||
/* Title timings */
|
||||
private int fadeInTime = -1;
|
||||
private int stayTime = -1;
|
||||
private int fadeOutTime = -1;
|
||||
private boolean ticks = false;
|
||||
|
||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES;
|
||||
|
||||
static {
|
||||
CORRESPONDING_TYPES = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title
|
||||
*
|
||||
* @param title
|
||||
* Title
|
||||
*/
|
||||
public Title(String title) {
|
||||
this.title = title;
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title
|
||||
*
|
||||
* @param title
|
||||
* Title text
|
||||
* @param subtitle
|
||||
* Subtitle text
|
||||
*/
|
||||
public Title(String title, String subtitle) {
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title
|
||||
*
|
||||
* @param title
|
||||
* Title text
|
||||
* @param subtitle
|
||||
* Subtitle text
|
||||
* @param fadeInTime
|
||||
* Fade in time
|
||||
* @param stayTime
|
||||
* Stay on screen time
|
||||
* @param fadeOutTime
|
||||
* Fade out time
|
||||
*/
|
||||
public Title(String title, String subtitle, int fadeInTime, int stayTime,
|
||||
int fadeOutTime) {
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
this.fadeInTime = fadeInTime;
|
||||
this.stayTime = stayTime;
|
||||
this.fadeOutTime = fadeOutTime;
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load spigot and NMS classes
|
||||
*/
|
||||
private void loadClasses() {
|
||||
packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle");
|
||||
packetActions = getClass("org.spigotmc.ProtocolInjector$PacketTitle$Action");
|
||||
nmsChatSerializer = getNMSClass("ChatSerializer");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title color
|
||||
*
|
||||
* @param color
|
||||
* Chat color
|
||||
*/
|
||||
public void setTitleColor(ChatColor color) {
|
||||
this.titleColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the subtitle color
|
||||
*
|
||||
* @param color
|
||||
* Chat color
|
||||
*/
|
||||
public void setSubtitleColor(ChatColor color) {
|
||||
this.subtitleColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade in time
|
||||
*
|
||||
* @param time
|
||||
* Time
|
||||
*/
|
||||
public void setFadeInTime(int time) {
|
||||
this.fadeInTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade out time
|
||||
*
|
||||
* @param time
|
||||
* Time
|
||||
*/
|
||||
public void setFadeOutTime(int time) {
|
||||
this.fadeOutTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title stay time
|
||||
*
|
||||
* @param time
|
||||
* Time
|
||||
*/
|
||||
public void setStayTime(int time) {
|
||||
this.stayTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to ticks
|
||||
*/
|
||||
public void setTimingsToTicks() {
|
||||
ticks = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to seconds
|
||||
*/
|
||||
public void setTimingsToSeconds() {
|
||||
ticks = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the title to a player
|
||||
*
|
||||
* @param player
|
||||
* Player
|
||||
*/
|
||||
public void send(Player player) {
|
||||
if (getProtocolVersion(player) >= 47 && isSpigot()
|
||||
&& packetTitle != null) {
|
||||
// First reset previous settings
|
||||
resetTitle(player);
|
||||
try {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
Object connection = getField(handle.getClass(),
|
||||
"playerConnection").get(handle);
|
||||
Object[] actions = packetActions.getEnumConstants();
|
||||
Method sendPacket = getMethod(connection.getClass(),
|
||||
"sendPacket");
|
||||
Object packet = packetTitle.getConstructor(packetActions,
|
||||
Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(
|
||||
actions[2], fadeInTime * (ticks ? 1 : 20),
|
||||
stayTime * (ticks ? 1 : 20),
|
||||
fadeOutTime * (ticks ? 1 : 20));
|
||||
// Send if set
|
||||
if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1)
|
||||
sendPacket.invoke(connection, packet);
|
||||
|
||||
// Send title
|
||||
Object serialized = getMethod(nmsChatSerializer, "a",
|
||||
String.class).invoke(
|
||||
null,
|
||||
"{text:\""
|
||||
+ ChatColor.translateAlternateColorCodes('&',
|
||||
title) + "\",color:"
|
||||
+ titleColor.name().toLowerCase() + "}");
|
||||
packet = packetTitle.getConstructor(packetActions,
|
||||
getNMSClass("IChatBaseComponent")).newInstance(
|
||||
actions[0], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
if (!subtitle.equals("")) {
|
||||
// Send subtitle if present
|
||||
serialized = getMethod(nmsChatSerializer, "a", String.class)
|
||||
.invoke(null,
|
||||
"{text:\""
|
||||
+ ChatColor
|
||||
.translateAlternateColorCodes(
|
||||
'&', subtitle)
|
||||
+ "\",color:"
|
||||
+ subtitleColor.name()
|
||||
.toLowerCase() + "}");
|
||||
packet = packetTitle.getConstructor(packetActions,
|
||||
getNMSClass("IChatBaseComponent")).newInstance(
|
||||
actions[1], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast the title to all players
|
||||
*/
|
||||
public void broadcast() {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
send(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the title
|
||||
*
|
||||
* @param player
|
||||
* Player
|
||||
*/
|
||||
public void clearTitle(Player player) {
|
||||
if (getProtocolVersion(player) >= 47 && isSpigot()) {
|
||||
try {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
Object connection = getField(handle.getClass(),
|
||||
"playerConnection").get(handle);
|
||||
Object[] actions = packetActions.getEnumConstants();
|
||||
Method sendPacket = getMethod(connection.getClass(),
|
||||
"sendPacket");
|
||||
Object packet = packetTitle.getConstructor(packetActions)
|
||||
.newInstance(actions[3]);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the title settings
|
||||
*
|
||||
* @param player
|
||||
* Player
|
||||
*/
|
||||
public void resetTitle(Player player) {
|
||||
if (getProtocolVersion(player) >= 47 && isSpigot()) {
|
||||
try {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
Object connection = getField(handle.getClass(),
|
||||
"playerConnection").get(handle);
|
||||
Object[] actions = packetActions.getEnumConstants();
|
||||
Method sendPacket = getMethod(connection.getClass(),
|
||||
"sendPacket");
|
||||
Object packet = packetTitle.getConstructor(packetActions)
|
||||
.newInstance(actions[4]);
|
||||
sendPacket.invoke(connection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the protocol version of the player
|
||||
*
|
||||
* @param player
|
||||
* Player
|
||||
* @return Protocol version
|
||||
*/
|
||||
private int getProtocolVersion(Player player) {
|
||||
int version = 0;
|
||||
try {
|
||||
Object handle = getHandle(player);
|
||||
Object connection = getField(handle.getClass(), "playerConnection")
|
||||
.get(handle);
|
||||
Object networkManager = getValue("networkManager", connection);
|
||||
version = (Integer) getMethod("getVersion",
|
||||
networkManager.getClass()).invoke(networkManager);
|
||||
|
||||
return version;
|
||||
} catch (Exception ex) {
|
||||
// ex.printStackTrace(); <-- spammy console
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if running spigot
|
||||
*
|
||||
* @return Spigot
|
||||
*/
|
||||
private boolean isSpigot() {
|
||||
return Bukkit.getVersion().contains("Spigot");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class by url
|
||||
*
|
||||
* @param namespace
|
||||
* Namespace url
|
||||
* @return Class
|
||||
*/
|
||||
private Class<?> getClass(String namespace) {
|
||||
try {
|
||||
return Class.forName(namespace);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Field getField(String name, Class<?> clazz) throws Exception {
|
||||
return clazz.getDeclaredField(name);
|
||||
}
|
||||
|
||||
private Object getValue(String name, Object obj) throws Exception {
|
||||
Field f = getField(name, obj.getClass());
|
||||
f.setAccessible(true);
|
||||
return f.get(obj);
|
||||
}
|
||||
|
||||
private Class<?> getPrimitiveType(Class<?> clazz) {
|
||||
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES
|
||||
.get(clazz) : clazz;
|
||||
}
|
||||
|
||||
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
||||
int a = classes != null ? classes.length : 0;
|
||||
Class<?>[] types = new Class<?>[a];
|
||||
for (int i = 0; i < a; i++)
|
||||
types[i] = getPrimitiveType(classes[i]);
|
||||
return types;
|
||||
}
|
||||
|
||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
if (a.length != o.length)
|
||||
return false;
|
||||
for (int i = 0; i < a.length; i++)
|
||||
if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private Object getHandle(Object obj) {
|
||||
try {
|
||||
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Method getMethod(String name, Class<?> clazz,
|
||||
Class<?>... paramTypes) {
|
||||
Class<?>[] t = toPrimitiveTypeArray(paramTypes);
|
||||
for (Method m : clazz.getMethods()) {
|
||||
Class<?>[] types = toPrimitiveTypeArray(m.getParameterTypes());
|
||||
if (m.getName().equals(name) && equalsTypeArray(types, t))
|
||||
return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getVersion() {
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
return name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
}
|
||||
|
||||
private Class<?> getNMSClass(String className) {
|
||||
String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
Class<?> clazz = null;
|
||||
try {
|
||||
clazz = Class.forName(fullName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
|
||||
private Field getField(Class<?> clazz, String name) {
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
||||
for (Method m : clazz.getMethods())
|
||||
if (m.getName().equals(name)
|
||||
&& (args.length == 0 || ClassListEqual(args,
|
||||
m.getParameterTypes()))) {
|
||||
m.setAccessible(true);
|
||||
return m;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
|
||||
boolean equal = true;
|
||||
if (l1.length != l2.length)
|
||||
return false;
|
||||
for (int i = 0; i < l1.length; i++)
|
||||
if (l1[i] != l2[i]) {
|
||||
equal = false;
|
||||
break;
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
}
|
@ -1,412 +0,0 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.command.defaults.SaveCommand;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static com.intellectualcrafters.plot.PlotWorld.*;
|
||||
|
||||
|
||||
/**
|
||||
* TODO finish recoding this class
|
||||
* @auther Empire92
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class WorldGenerator extends ChunkGenerator {
|
||||
short[][] result;
|
||||
double plotsize;
|
||||
double pathsize;
|
||||
short bottom;
|
||||
short wall;
|
||||
short wallfilling;
|
||||
short floor1;
|
||||
short floor2;
|
||||
double size;
|
||||
Biome biome;
|
||||
int roadheight;
|
||||
int wallheight;
|
||||
int plotheight;
|
||||
|
||||
Short[] plotfloors;
|
||||
Short[] filling;
|
||||
|
||||
public short getFilling(Random random) {
|
||||
if (filling.length==1) {
|
||||
return filling[0];
|
||||
}
|
||||
return filling[random.nextInt(filling.length)];
|
||||
}
|
||||
|
||||
public short getPlotFloor(Random random) {
|
||||
if (plotfloors.length==1) {
|
||||
return plotfloors[0];
|
||||
}
|
||||
return plotfloors[random.nextInt(plotfloors.length)];
|
||||
}
|
||||
|
||||
public Short getBlock(String block) {
|
||||
if (block.contains(":")) {
|
||||
String[] split = block.split(":");
|
||||
return Short.parseShort(split[0]);
|
||||
}
|
||||
return Short.parseShort(block);
|
||||
}
|
||||
|
||||
public WorldGenerator(String world) {
|
||||
YamlConfiguration config = PlotMain.config;
|
||||
PlotWorld plotworld = new PlotWorld();
|
||||
Map<String, Object> options = new HashMap<String, Object>();
|
||||
|
||||
options.put("worlds."+world+".plot_height", PLOT_HEIGHT_DEFAULT);
|
||||
options.put("worlds."+world+".plot_size", PLOT_WIDTH_DEFAULT);
|
||||
options.put("worlds."+world+".plot_biome", PLOT_BIOME_DEFAULT);
|
||||
options.put("worlds."+world+".plot_filling", Arrays.asList(MAIN_BLOCK_DEFAULT));
|
||||
options.put("worlds."+world+".top_floor", Arrays.asList(TOP_BLOCK_DEFAULT));
|
||||
options.put("worlds."+world+".wall_block", WALL_BLOCK_DEFAULT);
|
||||
options.put("worlds."+world+".road_width", ROAD_WIDTH_DEFAULT);
|
||||
options.put("worlds."+world+".road_height", ROAD_HEIGHT_DEFAULT);
|
||||
options.put("worlds."+world+".road_block", ROAD_BLOCK_DEFAULT);
|
||||
// options.put("worlds."+world+".road_stripes", ROAD_STRIPES_DEFAULT);
|
||||
options.put("worlds."+world+".wall_filling", WALL_FILLING_DEFAULT);
|
||||
options.put("worlds."+world+".wall_height", WALL_HEIGHT_DEFAULT);
|
||||
|
||||
for (Entry<String, Object> node : options.entrySet()) {
|
||||
if (!config.contains(node.getKey())) {
|
||||
config.set(node.getKey(), node.getValue());
|
||||
}
|
||||
}
|
||||
try {
|
||||
config.save(PlotMain.configFile);
|
||||
} catch (IOException e) {
|
||||
PlotMain.sendConsoleSenderMessage("&c[Warning] PlotSquared failed to save the configuration&7 (settings.yml may differ from the one in memory)\n - To force a save from console use /plots save");
|
||||
}
|
||||
plotworld.PLOT_HEIGHT = config.getInt("worlds."+world+".plot_height");
|
||||
plotworld.PLOT_WIDTH = config.getInt("worlds."+world+".plot_size");
|
||||
plotworld.PLOT_BIOME = config.getString("worlds."+world+".plot_biome");
|
||||
plotworld.MAIN_BLOCK = config.getStringList("worlds."+world+".plot_filling").toArray(new String[0]);
|
||||
plotworld.TOP_BLOCK = config.getStringList("worlds."+world+".top_floor").toArray(new String[0]);
|
||||
plotworld.WALL_BLOCK = config.getString("worlds."+world+".wall_block");
|
||||
plotworld.ROAD_WIDTH = config.getInt("worlds."+world+".road_width");
|
||||
plotworld.ROAD_HEIGHT = config.getInt("worlds."+world+".road_height");
|
||||
plotworld.ROAD_BLOCK = config.getString("worlds."+world+".road_block");
|
||||
// plotworld.ROAD_STRIPES = config.getInt("worlds."+world+".road_stripes");
|
||||
plotworld.WALL_FILLING = config.getString("worlds."+world+".wall_filling");
|
||||
plotworld.WALL_HEIGHT = config.getInt("worlds."+world+".wall_height");
|
||||
plotworld.PLOT_CHAT = config.getBoolean("worlds."+world+".plot_chat");
|
||||
PlotMain.addPlotWorld(world, plotworld);
|
||||
|
||||
plotsize = plotworld.PLOT_WIDTH;
|
||||
pathsize = plotworld.ROAD_WIDTH;
|
||||
bottom = (short) Material.BEDROCK.getId();
|
||||
filling = new Short[plotworld.MAIN_BLOCK.length];
|
||||
plotfloors = new Short[plotworld.TOP_BLOCK.length];
|
||||
|
||||
floor1 = getBlock(plotworld.ROAD_BLOCK);
|
||||
// floor2 = getBlock(plotworld.ROAD_STRIPES);
|
||||
wallfilling = getBlock(plotworld.WALL_FILLING);
|
||||
size = pathsize + plotsize;
|
||||
wall = getBlock(plotworld.WALL_BLOCK);
|
||||
|
||||
Short[] plotfloors = new Short[plotworld.TOP_BLOCK.length];
|
||||
Short[] plotfloors_data = new Short[plotworld.TOP_BLOCK.length];
|
||||
|
||||
for (int i = 0; i < plotworld.TOP_BLOCK.length; i++) {
|
||||
plotfloors[i] = getBlock(plotworld.TOP_BLOCK[i]);
|
||||
}
|
||||
for (int i = 0; i < plotworld.MAIN_BLOCK.length; i++) {
|
||||
filling[i] = getBlock(plotworld.MAIN_BLOCK[i]);
|
||||
}
|
||||
|
||||
wallheight = plotworld.WALL_HEIGHT;
|
||||
roadheight = plotworld.ROAD_HEIGHT;
|
||||
plotheight = plotworld.PLOT_HEIGHT;
|
||||
|
||||
biome = Biome.FOREST;
|
||||
for (Biome myBiome:Biome.values()) {
|
||||
if (myBiome.name().equalsIgnoreCase(plotworld.PLOT_BIOME)) {
|
||||
biome = myBiome;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getDefaultPopulators(World world) {
|
||||
return Arrays.asList((BlockPopulator) new XPopulator());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getFixedSpawnLocation(World world, Random random) {
|
||||
return new Location(world, 0, PlotMain.getWorldSettings(world).ROAD_HEIGHT + 2, 0);
|
||||
}
|
||||
|
||||
public void setCuboidRegion(double x1,double x2, int y1, int y2, double z1, double z2, short id) {
|
||||
for (double x = x1; x < x2; x++) {
|
||||
for (double z = z1; z < z2; z++) {
|
||||
for (int y = y1; y < y2; y++) {
|
||||
setBlock(result, (int) x, y, (int) z, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public short[][] generateExtBlockSections(World world, Random random,
|
||||
int cx, int cz, BiomeGrid biomes) {
|
||||
int maxY = world.getMaxHeight();
|
||||
|
||||
result = new short[maxY / 16][];
|
||||
|
||||
double pathWidthLower;
|
||||
pathWidthLower = Math.floor(pathsize/2);
|
||||
if (cx<0)
|
||||
cx+=((-cx)*(size));
|
||||
if (cz<0)
|
||||
cz+=((-cz)*(size));
|
||||
double absX = (cx*16+16-pathWidthLower-1+8*size);
|
||||
double absZ = (cz*16+16-pathWidthLower-1+8*size);
|
||||
double plotMinX = (((absX)%size));
|
||||
double plotMinZ = (((absZ)%size));
|
||||
double roadStartX = (plotMinX + pathsize);
|
||||
double roadStartZ = (plotMinZ + pathsize);
|
||||
if (roadStartX>=size)
|
||||
roadStartX-=size;
|
||||
if (roadStartZ>=size)
|
||||
roadStartZ-=size;
|
||||
|
||||
// BOTTOM (1/1 cuboids)
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
setBlock(result, x, 0, z, bottom);
|
||||
biomes.setBiome(x, z, biome);
|
||||
}
|
||||
}
|
||||
// ROAD (0/24) The following is an inefficient placeholder as it is too much work to finish it
|
||||
|
||||
if (plotMinZ+1<=16||roadStartZ<=16&&roadStartZ>0) {
|
||||
int start = (int) Math.max(16-plotMinZ-pathsize+1,16-roadStartZ+1);
|
||||
int end = (int) Math.min(16-plotMinZ-1,16-roadStartZ+pathsize);
|
||||
if (start>=0 && start<=16 && end <0)
|
||||
end = 16;
|
||||
setCuboidRegion(0, 16, 1, roadheight+1, Math.max(start,0),Math.min(16,end), floor1);
|
||||
}
|
||||
if (plotMinX+1<=16||roadStartX<=16&&roadStartX>0) {
|
||||
int start = (int) Math.max(16-plotMinX-pathsize+1,16-roadStartX+1);
|
||||
int end = (int) Math.min(16-plotMinX-1,16-roadStartX+pathsize);
|
||||
if (start>=0 && start<=16 && end <0)
|
||||
end = 16;
|
||||
setCuboidRegion(Math.max(start,0), Math.min(16,end), 1, roadheight+1, 0, 16, floor1);
|
||||
}
|
||||
|
||||
// Plot filling (28/28 cuboids) (10x2 + 4x2)
|
||||
if (plotsize>16) {
|
||||
if (roadStartX<=16) {
|
||||
if (roadStartZ<=16) {
|
||||
setCuboidRegion(0, 16-roadStartX, 1, plotheight, 0, 16-roadStartZ, getFilling(random));
|
||||
setCuboidRegion(0, 16-roadStartX, plotheight, plotheight+1, 0, 16-roadStartZ, getPlotFloor(random));
|
||||
}
|
||||
if (plotMinZ<=16) {
|
||||
setCuboidRegion(0, 16-roadStartX, 1, plotheight, 16-plotMinZ, 16, getFilling(random));
|
||||
setCuboidRegion(0, 16-roadStartX, plotheight, plotheight+1, 16-plotMinZ, 16, getPlotFloor(random));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (roadStartZ<=16) {
|
||||
if (plotMinX>16) {
|
||||
setCuboidRegion(0, 16, 1, plotheight, 0, 16-roadStartZ, getFilling(random));
|
||||
setCuboidRegion(0, 16, plotheight, plotheight+1, 0, 16-roadStartZ, getPlotFloor(random));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plotMinX<=16) {
|
||||
if (plotMinZ<=16) {
|
||||
setCuboidRegion(16-plotMinX, 16, 1, plotheight, 16-plotMinZ, 16, getFilling(random));
|
||||
setCuboidRegion(16-plotMinX, 16, plotheight, plotheight+1, 16-plotMinZ, 16, getPlotFloor(random));
|
||||
}
|
||||
else {
|
||||
int z = (int) (16-roadStartZ);
|
||||
if (z<0)
|
||||
z=16;
|
||||
setCuboidRegion(16-plotMinX, 16, 1, plotheight, 0, z, getFilling(random));
|
||||
setCuboidRegion(16-plotMinX, 16, plotheight, plotheight+1, 0, z, getPlotFloor(random));
|
||||
}
|
||||
if (roadStartZ<=16) {
|
||||
setCuboidRegion(16-plotMinX, 16, 1, plotheight, 0, 16-roadStartZ, getFilling(random));
|
||||
setCuboidRegion(16-plotMinX, 16, plotheight, plotheight+1, 0, 16-roadStartZ, getPlotFloor(random));
|
||||
}
|
||||
else {
|
||||
if (roadStartX<=16) {
|
||||
if (plotMinZ>16) {
|
||||
int x = (int) (16-roadStartX);
|
||||
if (x<0)
|
||||
x=16;
|
||||
setCuboidRegion(0, x, 1, plotheight, 0, 16, getFilling(random));
|
||||
setCuboidRegion(0, x, plotheight,plotheight+1, 0, 16, getPlotFloor(random));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (plotMinZ<=16) {
|
||||
if (roadStartX>16) {
|
||||
int x = (int) (16-roadStartX);
|
||||
if (x<0)
|
||||
x=16;
|
||||
setCuboidRegion(0, x, 1, plotheight, 16-plotMinZ, 16, getFilling(random));
|
||||
setCuboidRegion(0, x, plotheight, plotheight+1, 16-plotMinZ, 16, getPlotFloor(random));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (roadStartZ>16) {
|
||||
int x = (int) (16-roadStartX);
|
||||
if (x<0)
|
||||
x=16;
|
||||
int z = (int) (16-roadStartZ);
|
||||
if (z<0)
|
||||
z=16;
|
||||
if (roadStartX>16) {
|
||||
setCuboidRegion(0, x, 1, plotheight, 0, z, getFilling(random));
|
||||
setCuboidRegion(0, x, plotheight, plotheight+1, 0, z, getPlotFloor(random));
|
||||
}
|
||||
else {
|
||||
setCuboidRegion(0, x, 1, plotheight, 0, z, getFilling(random));
|
||||
setCuboidRegion(0, x, plotheight, plotheight+1, 0, z, getPlotFloor(random));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (roadStartX<=16) {
|
||||
if (roadStartZ<=16) {
|
||||
setCuboidRegion(0, 16-roadStartX, 1, plotheight, 0, 16-roadStartZ, getFilling(random));
|
||||
setCuboidRegion(0, 16-roadStartX, plotheight, plotheight+1, 0, 16-roadStartZ, getPlotFloor(random));
|
||||
}
|
||||
if (plotMinZ<=16) {
|
||||
setCuboidRegion(0, 16-roadStartX, 1, plotheight, 16-plotMinZ, 16, getFilling(random));
|
||||
setCuboidRegion(0, 16-roadStartX, plotheight, plotheight+1, 16-plotMinZ, 16, getPlotFloor(random));
|
||||
}
|
||||
}
|
||||
if (plotMinX<=16) {
|
||||
if (plotMinZ<=16) {
|
||||
setCuboidRegion(16-plotMinX, 16, 1, plotheight, 16-plotMinZ, 16, getFilling(random));
|
||||
setCuboidRegion(16-plotMinX, 16, plotheight, plotheight+1, 16-plotMinZ, 16, getPlotFloor(random));
|
||||
}
|
||||
if (roadStartZ<=16) {
|
||||
setCuboidRegion(16-plotMinX, 16, 1, plotheight, 0, 16-roadStartZ, getFilling(random));
|
||||
setCuboidRegion(16-plotMinX, 16, plotheight, plotheight+1, 0, 16-roadStartZ, getPlotFloor(random));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WALLS (16/16 cuboids)
|
||||
|
||||
if (plotMinZ+1<=16) {
|
||||
double start,end;
|
||||
if (plotMinX+2<=16)
|
||||
start = 16-plotMinX-1;
|
||||
else
|
||||
start = 16;
|
||||
if (roadStartX-1<=16)
|
||||
end = 16-roadStartX+1;
|
||||
else
|
||||
end = 0;
|
||||
if (!(plotMinX+2<=16||roadStartX-1<=16)) {
|
||||
start = 0;
|
||||
}
|
||||
setCuboidRegion(0, end, 1, wallheight+1, 16-plotMinZ-1, 16-plotMinZ, wallfilling);
|
||||
setCuboidRegion(0, end, wallheight+1, wallheight+2, 16-plotMinZ-1, 16-plotMinZ, wall);
|
||||
setCuboidRegion(start, 16, 1, wallheight+1, 16-plotMinZ-1, 16-plotMinZ, wallfilling);
|
||||
setCuboidRegion(start, 16, wallheight+1, wallheight+2, 16-plotMinZ-1, 16-plotMinZ, wall);
|
||||
}
|
||||
if (plotMinX+1<=16) {
|
||||
double start,end;
|
||||
if (plotMinZ+2<=16)
|
||||
start = 16-plotMinZ-1;
|
||||
else
|
||||
start = 16;
|
||||
if (roadStartZ-1<=16)
|
||||
end = 16-roadStartZ+1;
|
||||
else
|
||||
end = 0;
|
||||
if (!(plotMinZ+2<=16||roadStartZ-1<=16)) {
|
||||
start = 0;
|
||||
}
|
||||
setCuboidRegion( 16-plotMinX-1, 16-plotMinX, 1, wallheight+1,0, end, wallfilling);
|
||||
setCuboidRegion( 16-plotMinX-1, 16-plotMinX,wallheight+1, wallheight+2, 0, end, wall);
|
||||
setCuboidRegion(16-plotMinX-1, 16-plotMinX, 1, wallheight+1, start, 16, wallfilling);
|
||||
setCuboidRegion( 16-plotMinX-1, 16-plotMinX, wallheight+1, wallheight+2,start, 16, wall);
|
||||
}
|
||||
if (roadStartZ<=16&&roadStartZ>0) {
|
||||
double start,end;
|
||||
if (plotMinX+1<=16)
|
||||
start = 16-plotMinX;
|
||||
else
|
||||
start = 16;
|
||||
if (roadStartX<=16)
|
||||
end = 16-roadStartX;
|
||||
else
|
||||
end = 0;
|
||||
if (!(plotMinX+1<=16||roadStartX<=16)) {
|
||||
start = 0;
|
||||
}
|
||||
setCuboidRegion(0, end, 1, wallheight+1, 16-roadStartZ, 16-roadStartZ+1, wallfilling);
|
||||
setCuboidRegion(0, end, wallheight+1, wallheight+2, 16-roadStartZ, 16-roadStartZ+1, wall);
|
||||
setCuboidRegion(start, 16, 1, wallheight+1, 16-roadStartZ, 16-roadStartZ+1, wallfilling);
|
||||
setCuboidRegion(start, 16, wallheight+1, wallheight+2, 16-roadStartZ, 16-roadStartZ+1, wall);
|
||||
}
|
||||
if (roadStartX<=16&&roadStartX>0) {
|
||||
double start,end;
|
||||
if (plotMinZ+1<=16)
|
||||
start = 16-plotMinZ;
|
||||
else
|
||||
start = 16;
|
||||
if (roadStartZ+1<=16)
|
||||
end = 16-roadStartZ+1;
|
||||
else
|
||||
end = 0;
|
||||
if (!(plotMinZ+1<=16||roadStartZ+1<=16)) {
|
||||
start = 0;
|
||||
}
|
||||
setCuboidRegion( 16-roadStartX, 16-roadStartX+1, 1, wallheight+1,0, end, wallfilling);
|
||||
setCuboidRegion( 16-roadStartX, 16-roadStartX+1,wallheight+1, roadheight+2,0, end, wall);
|
||||
setCuboidRegion( 16-roadStartX, 16-roadStartX+1, 1, wallheight+1, start, 16,wallfilling);
|
||||
setCuboidRegion( 16-roadStartX, 16-roadStartX+1,wallheight+1, wallheight+2, start, 16, wall);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings({ "deprecation", "unused" })
|
||||
private void setBlock(short[][] result, int x, int y, int z,
|
||||
Material material) {
|
||||
setBlock(result, x, y, z, (short) material.getId());
|
||||
|
||||
}
|
||||
|
||||
private void setBlock(short[][] result, int x, int y, int z, short blkid) {
|
||||
if (result[y >> 4] == null) {
|
||||
result[y >> 4] = new short[4096];
|
||||
}
|
||||
result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid;
|
||||
}
|
||||
}
|
@ -1,213 +0,0 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* TODO recode this class
|
||||
* Fuck you PlotMe!
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class XPopulator extends BlockPopulator {
|
||||
private SetBlockFast setBlockClass = null;
|
||||
public XPopulator() {
|
||||
try {
|
||||
setBlockClass = new SetBlockFast();
|
||||
}
|
||||
catch (NoClassDefFoundError e) {
|
||||
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&cFast plot clearing is currently not enabled.");
|
||||
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&c - Please get PlotSquared for "+Bukkit.getVersion()+" for improved performance");
|
||||
}
|
||||
}
|
||||
|
||||
public void setCuboidRegion(int x1,int x2, int y1, int y2, int z1, int z2, short id, byte data, World w) {
|
||||
if (data!=0) {
|
||||
for (int x = x1; x < x2; x++) {
|
||||
for (int z = z1; z < z2; z++) {
|
||||
for (int y = y1; y < y2; y++) {
|
||||
if (w.getBlockTypeIdAt(x, y, z)==id)
|
||||
setBlock(w, x, y, z, id, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public short[] getBlock(String block) {
|
||||
if (block.contains(":")) {
|
||||
String[] split = block.split(":");
|
||||
return new short[] {Short.parseShort(split[0]),Short.parseShort(split[1])};
|
||||
}
|
||||
return new short[] {Short.parseShort(block),0};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(World w, Random r, Chunk c) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(w);
|
||||
|
||||
int plotsize = plotworld.PLOT_WIDTH;
|
||||
int pathsize = plotworld.ROAD_WIDTH;
|
||||
int wallheight = plotworld.WALL_HEIGHT;
|
||||
int roadheight = plotworld.ROAD_HEIGHT;
|
||||
int plotheight = plotworld.PLOT_HEIGHT;
|
||||
int size = pathsize + plotsize;
|
||||
byte w_v, f1_v, wf_v;
|
||||
|
||||
short w_id, f1_id, wf_id;
|
||||
|
||||
// WALL
|
||||
short[] result_w = getBlock(plotworld.WALL_BLOCK);
|
||||
w_id = result_w[0];
|
||||
w_v = (byte) result_w[1];
|
||||
|
||||
// WALL FILLING
|
||||
short[] result_wf = getBlock(plotworld.WALL_FILLING);
|
||||
wf_id = result_wf[0];
|
||||
wf_v = (byte) result_wf[1];
|
||||
|
||||
// ROAD
|
||||
short[] result_f1 = getBlock(plotworld.ROAD_BLOCK);
|
||||
f1_id = result_f1[0];
|
||||
f1_v = (byte) result_f1[1];
|
||||
//
|
||||
|
||||
// Floor 2
|
||||
// f2_id = (short) Settings.ROAD_STRIPES;
|
||||
// f2_v = (byte) Settings.ROAD_STRIPES_DATA;
|
||||
//
|
||||
|
||||
int cx = c.getX(), cz = c.getZ();
|
||||
|
||||
double pathWidthLower;
|
||||
pathWidthLower = Math.floor(pathsize/2);
|
||||
if (cx<0)
|
||||
cx+=((-cx)*(size));
|
||||
if (cz<0)
|
||||
cz+=((-cz)*(size));
|
||||
double absX = (cx*16+16-pathWidthLower-1+8*size);
|
||||
double absZ = (cz*16+16-pathWidthLower-1+8*size);
|
||||
int plotMinX = (int) (((absX)%size));
|
||||
int plotMinZ = (int) (((absZ)%size));
|
||||
int roadStartX = (plotMinX + pathsize);
|
||||
int roadStartZ = (plotMinZ + pathsize);
|
||||
if (roadStartX>=size)
|
||||
roadStartX-=size;
|
||||
if (roadStartZ>=size)
|
||||
roadStartZ-=size;
|
||||
|
||||
// ROADS
|
||||
|
||||
if (plotMinZ+1<=16||roadStartZ<=16&&roadStartZ>0) {
|
||||
int start = (int) Math.max(16-plotMinZ-pathsize+1,16-roadStartZ+1);
|
||||
int end = (int) Math.min(16-plotMinZ-1,16-roadStartZ+pathsize);
|
||||
if (start>=0 && start<=16 && end <0)
|
||||
end = 16;
|
||||
setCuboidRegion(0, 16, 1, roadheight+1, Math.max(start,0),Math.min(16,end), f1_id, f1_v, w);
|
||||
}
|
||||
if (plotMinX+1<=16||roadStartX<=16&&roadStartX>0) {
|
||||
int start = (int) Math.max(16-plotMinX-pathsize+1,16-roadStartX+1);
|
||||
int end = (int) Math.min(16-plotMinX-1,16-roadStartX+pathsize);
|
||||
if (start>=0 && start<=16 && end <0)
|
||||
end = 16;
|
||||
setCuboidRegion(Math.max(start,0), Math.min(16,end), 1, roadheight+1, 0, 16, f1_id, f1_v, w);
|
||||
}
|
||||
|
||||
// WALLS
|
||||
|
||||
if (plotMinZ+1<=16) {
|
||||
int start,end;
|
||||
if (plotMinX+2<=16)
|
||||
start = 16-plotMinX-1;
|
||||
else
|
||||
start = 16;
|
||||
if (roadStartX-1<=16)
|
||||
end = 16-roadStartX+1;
|
||||
else
|
||||
end = 0;
|
||||
if (!(plotMinX+2<=16||roadStartX-1<=16)) {
|
||||
start = 0;
|
||||
}
|
||||
setCuboidRegion(0, end, 1, wallheight+1, 16-plotMinZ-1, 16-plotMinZ, wf_id, wf_v, w);
|
||||
setCuboidRegion(0, end, wallheight+1, wallheight+2, 16-plotMinZ-1, 16-plotMinZ, w_id, w_v, w);
|
||||
setCuboidRegion(start, 16, 1, wallheight+1, 16-plotMinZ-1, 16-plotMinZ, wf_id, wf_v, w);
|
||||
setCuboidRegion(start, 16, wallheight+1, wallheight+2, 16-plotMinZ-1, 16-plotMinZ, w_id, w_v, w);
|
||||
}
|
||||
if (plotMinX+1<=16) {
|
||||
int start,end;
|
||||
if (plotMinZ+2<=16)
|
||||
start = 16-plotMinZ-1;
|
||||
else
|
||||
start = 16;
|
||||
if (roadStartZ-1<=16)
|
||||
end = 16-roadStartZ+1;
|
||||
else
|
||||
end = 0;
|
||||
if (!(plotMinZ+2<=16||roadStartZ-1<=16)) {
|
||||
start = 0;
|
||||
}
|
||||
setCuboidRegion( 16-plotMinX-1, 16-plotMinX, 1, wallheight+1,0, end, wf_id, wf_v, w);
|
||||
setCuboidRegion( 16-plotMinX-1, 16-plotMinX,wallheight+1, wallheight+2, 0, end, w_id, w_v, w);
|
||||
setCuboidRegion(16-plotMinX-1, 16-plotMinX, 1, wallheight+1, start, 16, wf_id, wf_v, w);
|
||||
setCuboidRegion( 16-plotMinX-1, 16-plotMinX, wallheight+1, wallheight+2,start, 16, w_id, w_v, w);
|
||||
}
|
||||
if (roadStartZ<=16&&roadStartZ>0) {
|
||||
int start,end;
|
||||
if (plotMinX+1<=16)
|
||||
start = 16-plotMinX;
|
||||
else
|
||||
start = 16;
|
||||
if (roadStartX<=16)
|
||||
end = 16-roadStartX;
|
||||
else
|
||||
end = 0;
|
||||
if (!(plotMinX+1<=16||roadStartX<=16)) {
|
||||
start = 0;
|
||||
}
|
||||
setCuboidRegion(0, end, 1, wallheight+1, 16-roadStartZ, 16-roadStartZ+1, wf_id, wf_v, w);
|
||||
setCuboidRegion(0, end, wallheight+1, wallheight+2, 16-roadStartZ, 16-roadStartZ+1, w_id, w_v, w);
|
||||
setCuboidRegion(start, 16, 1, wallheight+1, 16-roadStartZ, 16-roadStartZ+1, wf_id, wf_v, w);
|
||||
setCuboidRegion(start, 16, wallheight+1, wallheight+2, 16-roadStartZ, 16-roadStartZ+1, w_id, w_v, w);
|
||||
}
|
||||
if (roadStartX<=16&&roadStartX>0) {
|
||||
int start,end;
|
||||
if (plotMinZ+1<=16)
|
||||
start = 16-plotMinZ;
|
||||
else
|
||||
start = 16;
|
||||
if (roadStartZ+1<=16)
|
||||
end = 16-roadStartZ+1;
|
||||
else
|
||||
end = 0;
|
||||
if (!(plotMinZ+1<=16||roadStartZ+1<=16)) {
|
||||
start = 0;
|
||||
}
|
||||
setCuboidRegion( 16-roadStartX, 16-roadStartX+1, 1, wallheight+1,0, end, wf_id, wf_v, w);
|
||||
setCuboidRegion( 16-roadStartX, 16-roadStartX+1,wallheight+1, roadheight+2,0, end, w_id, w_v, w);
|
||||
setCuboidRegion( 16-roadStartX, 16-roadStartX+1, 1, wallheight+1, start, 16,wf_id, wf_v, w);
|
||||
setCuboidRegion( 16-roadStartX, 16-roadStartX+1,wallheight+1, wallheight+2, start, 16, w_id, w_v, w);
|
||||
}
|
||||
|
||||
// TODO PLOT MAIN - How are we going to do the IDs for the actual plot if we have randomized blocks...
|
||||
// - possibly on plot claiming, we could regenerate using the xpopulator
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void setBlock(World w, int x, int y, int z, short id, byte val) {
|
||||
if (setBlockClass!=null) {
|
||||
setBlockClass.set(w, x, y, z, id, val);
|
||||
}
|
||||
else {
|
||||
if (val != 0) {
|
||||
w.getBlockAt(x, y, z).setTypeIdAndData(id, val, false);
|
||||
} else {
|
||||
w.getBlockAt(x, y, z).setTypeId(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,291 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = PlotAPI.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:44
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.api;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.commands.SubCommand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The plotMain api class.
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@SuppressWarnings({"unused", "javadoc"})
|
||||
public class PlotAPI {
|
||||
|
||||
//To perform bukkit operations correctly.
|
||||
private JavaPlugin plugin;
|
||||
//To access plotMain stuffz.
|
||||
private PlotMain plotMain;
|
||||
//To access the plotworld.
|
||||
private World plotWorld;
|
||||
//Reference
|
||||
public static final String ADMIN_PERMISSION = "plots.admin";
|
||||
|
||||
|
||||
/**
|
||||
* Constructor. Insert any Plugin.
|
||||
* @param plugin
|
||||
*/
|
||||
public PlotAPI(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.plotMain = JavaPlugin.getPlugin(PlotMain.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to a player.
|
||||
* @param player
|
||||
* @param c (Caption)
|
||||
*/
|
||||
public void sendMessage(Player player, C c){
|
||||
PlayerFunctions.sendMessage(player, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to a player.
|
||||
* @param player
|
||||
* @param string
|
||||
*/
|
||||
public void sendMessage(Player player, String string) {
|
||||
PlayerFunctions.sendMessage(player, string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the console.
|
||||
* @param msg
|
||||
*/
|
||||
public void sendConsoleMessage(String msg) {
|
||||
PlotMain.sendConsoleSenderMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the console
|
||||
* @param c (Caption)
|
||||
*/
|
||||
public void sendConsoleMessage(C c) {
|
||||
sendConsoleMessage(c.s());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot based on the ID
|
||||
* @param id
|
||||
* @return plot, null if ID is wrong
|
||||
*/
|
||||
public Plot getPlot(World world, int x, int z) {
|
||||
return PlotHelper.getPlot(world, new PlotId(x, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot based on the location
|
||||
* @param l
|
||||
* @return plot if found, otherwise it creates a temporary plot-
|
||||
*/
|
||||
public Plot getPlot(Location l) {
|
||||
return PlotHelper.getCurrentPlot(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot based on the player location
|
||||
* @param player
|
||||
* @return plot if found, otherwise it creates a temporary plot
|
||||
*/
|
||||
public Plot getPlot(Player player) {
|
||||
return this.getPlot(player.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether or not a player has a plot
|
||||
* @param player
|
||||
* @return true if player has a plot, false if not.
|
||||
*/
|
||||
public boolean hasPlot(World world, Player player) {
|
||||
return getPlots(world, player, true) != null && getPlots(world, player, true).length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all plots for the player
|
||||
* @param plr to search for
|
||||
* @param just_owner should we just search for owner? Or with rights?
|
||||
*/
|
||||
public Plot[] getPlots(World world, Player plr, boolean just_owner) {
|
||||
ArrayList<Plot> pPlots = new ArrayList<>();
|
||||
for(Plot plot : PlotMain.getPlots(world).values()) {
|
||||
if(just_owner) {
|
||||
if(plot.owner != null && plot.owner == plr.getUniqueId()) {
|
||||
pPlots.add(plot);
|
||||
}
|
||||
} else {
|
||||
if(plot.hasRights(plr)) {
|
||||
pPlots.add(plot);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (Plot[]) pPlots.toArray();
|
||||
}
|
||||
/**
|
||||
* Get all plots for the world
|
||||
* @param World to get plots of
|
||||
* @return Plot[] - array of plot objects in world
|
||||
*/
|
||||
public Plot[] getPlots(World world) {
|
||||
return PlotMain.getWorldPlots(world);
|
||||
}
|
||||
/**
|
||||
* Get all plot worlds
|
||||
* @return World[] - array of plot worlds
|
||||
*/
|
||||
public World[] getPlotWorlds() {
|
||||
return PlotMain.getPlotWorlds();
|
||||
}
|
||||
/**
|
||||
* Get if plot world
|
||||
* @param world (to check if plot world)
|
||||
* @return boolean (if plot world or not)
|
||||
*/
|
||||
public boolean isPlotWorld(World world) {
|
||||
for (World w:PlotMain.getPlotWorlds()) {
|
||||
if (w.equals(world))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Get the settings for a world (settings bundled in PlotWorld class)
|
||||
* @param world (to get settings of)
|
||||
* @return PlotWorld class for ther world
|
||||
* ! will return null if not a plot world
|
||||
*/
|
||||
public PlotWorld getWorldSettings(World world) {
|
||||
return PlotMain.getWorldSettings(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plot locations
|
||||
* @param p
|
||||
* @return [0] = bottomLc, [1] = topLoc, [2] = home
|
||||
*/
|
||||
public Location[] getLocations(Plot p) {
|
||||
World world = Bukkit.getWorld(p.world);
|
||||
return new Location[] {
|
||||
PlotHelper.getPlotBottomLoc(world, p.id),
|
||||
PlotHelper.getPlotTopLoc(world, p.id),
|
||||
PlotHelper.getPlotHome(world, p.id)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get home location
|
||||
* @param p
|
||||
* @return plot bottom location
|
||||
*/
|
||||
public Location getHomeLocation(Plot p) {
|
||||
return PlotHelper.getPlotHome(getPlotWorld(), p.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bottom Location
|
||||
* @param p
|
||||
* @return plot bottom location
|
||||
*/
|
||||
public Location getBottomLocation(Plot p){
|
||||
World world = Bukkit.getWorld(p.world);
|
||||
return PlotHelper.getPlotBottomLoc(world, p.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Top Location
|
||||
* @param p
|
||||
* @return plot top location
|
||||
*/
|
||||
public Location getTopLocation(Plot p){
|
||||
World world = Bukkit.getWorld(p.world);
|
||||
return PlotHelper.getPlotTopLoc(world, p.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether or not a player is in a plot
|
||||
* @param player
|
||||
* @return true if the player is in a plot, false if not-
|
||||
*/
|
||||
public boolean isInPlot(Player player) {
|
||||
return PlayerFunctions.isInPlot(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a subcommand
|
||||
* @param c
|
||||
*/
|
||||
public void registerCommand(SubCommand c) {
|
||||
MainCommand.subCommands.add(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plotworld object
|
||||
* @return PlotWorld
|
||||
*/
|
||||
public World getPlotWorld() {
|
||||
return this.plotWorld;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plotMain class
|
||||
* @return PlotMain Class
|
||||
*/
|
||||
public PlotMain getPlotMain() {
|
||||
return this.plotMain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the inserted plugin
|
||||
* @return Plugin.
|
||||
* @deprecated
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private JavaPlugin getPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player plot count
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public int getPlayerPlotCount(World world, Player player) {
|
||||
return PlayerFunctions.getPlayerPlotCount(world, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a players plots
|
||||
* @param player
|
||||
* @return a set containing the players plots
|
||||
*/
|
||||
public Set<Plot> getPlayerPlots(World world, Player player) {
|
||||
return PlayerFunctions.getPlayerPlots(world, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the allowed plot count for a player
|
||||
* @param player
|
||||
* @return the number of allowed plots
|
||||
*/
|
||||
public int getAllowedPlots(Player player) {
|
||||
return PlayerFunctions.getAllowedPlots(player);
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Auto.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:40
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotHelper;
|
||||
import com.intellectualcrafters.plot.PlotId;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Auto extends SubCommand {
|
||||
|
||||
public Auto() {
|
||||
super("auto", "plots.auto", "Claim the nearest plot", "auto", "a", CommandCategory.CLAIMING);
|
||||
}
|
||||
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
World world;
|
||||
if (PlotMain.getPlotWorlds().length==1)
|
||||
world = PlotMain.getPlotWorlds()[0];
|
||||
else {
|
||||
if (PlotMain.isPlotWorld(plr.getWorld()))
|
||||
world = plr.getWorld();
|
||||
else {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
if(PlayerFunctions.getPlayerPlotCount(world, plr) >= PlayerFunctions.getAllowedPlots(plr)) {
|
||||
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
return true;
|
||||
}
|
||||
boolean br = false;
|
||||
int x = 0, z = 0, q = 100;
|
||||
PlotId id;
|
||||
while(!br) {
|
||||
id = new PlotId(x,z);
|
||||
if(PlotHelper.getPlot(world, id).owner == null) {
|
||||
Plot plot = PlotHelper.getPlot(world, id);
|
||||
Claim.claimPlot(plr, plot, true);
|
||||
br = true;
|
||||
}
|
||||
if(z < q && (z - x) < q) {
|
||||
z++;
|
||||
} else if(x < q) {
|
||||
x++;
|
||||
z = q - 100;
|
||||
} else {
|
||||
q += 100;
|
||||
x = q;
|
||||
z = q;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,86 +0,0 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import ca.mera.CameraAPI;
|
||||
import ca.mera.CameraController;
|
||||
import ca.mera.events.TravelEndEvent;
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-15.
|
||||
*/
|
||||
public class Camera extends SubCommand implements Listener {
|
||||
|
||||
private CameraAPI api;
|
||||
public Camera() {
|
||||
super("camera", "plots.camera", "Go into camera mode", "camera", "c", CommandCategory.TELEPORT);
|
||||
api = CameraAPI.getInstance();
|
||||
travelers = new ArrayList<String>();
|
||||
}
|
||||
|
||||
private ArrayList<String> travelers;
|
||||
|
||||
@Override
|
||||
public boolean execute(Player player, String ... args) {
|
||||
if(!PlayerFunctions.isInPlot(player)) {
|
||||
PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
api = CameraAPI.getInstance();
|
||||
Plot plot = PlotHelper.getCurrentPlot(player.getLocation());
|
||||
if(api.isTravelling(player)) {
|
||||
api.stopTravel(player);
|
||||
PlayerFunctions.sendMessage(player, C.CAMERA_STOPPED);
|
||||
return true;
|
||||
}
|
||||
api.travel(getController(player, plot));
|
||||
PlayerFunctions.sendMessage(player, C.CAMERA_STARTED, plot.getId().x+";"+plot.getId().y);
|
||||
travelers.add(player.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTravelEnded(TravelEndEvent event) {
|
||||
if(travelers.contains(event.getPlayer().getName())) {
|
||||
|
||||
travelers.remove(event.getPlayer().getName());
|
||||
PlayerFunctions.sendMessage(event.getPlayer(), C.CAMERA_STOPPED);
|
||||
}
|
||||
if(travelers.contains(event.getPlayer().getName())) {
|
||||
event.getHandlers().bake();
|
||||
}
|
||||
}
|
||||
|
||||
public CameraController getController(Player player, Plot plot) {
|
||||
World w = Bukkit.getWorld(plot.world);
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(w);
|
||||
int seconds = plotworld.PLOT_WIDTH * 5;
|
||||
Location loc1, loc2, loc3, loc4, loc5;
|
||||
double y = player.getLocation().getY();
|
||||
Location bottomLoc = PlotHelper.getPlotBottomLoc(w, plot.id);
|
||||
Location topLoc = PlotHelper.getPlotTopLoc(w, plot.id );
|
||||
World world = bottomLoc.getWorld();
|
||||
int maxX = Math.max(bottomLoc.getBlockX(), topLoc.getBlockX());
|
||||
int maxZ = Math.max(bottomLoc.getBlockZ(), topLoc.getBlockZ());
|
||||
int minX = Math.min(bottomLoc.getBlockX(), topLoc.getBlockX());
|
||||
int minZ = Math.min(bottomLoc.getBlockZ(), topLoc.getBlockZ());
|
||||
loc1 = new Location(world, maxX, y, maxZ);
|
||||
loc2 = new Location(world, maxX, y, minZ);
|
||||
loc3 = new Location(world, minX, y, minZ);
|
||||
loc4 = new Location(world, minX, y, maxZ);
|
||||
loc1.setYaw((3 / 4.0F * 360.0F) - 0.5F);
|
||||
loc3.setYaw((1 / 4.0F * 360.0F) - 0.5F);
|
||||
loc4.setYaw((2 / 4.0F * 360.0F) - 0.5F);
|
||||
loc2.setYaw((0 / 4.0F * 360.0F) - 0.5F);
|
||||
loc5 = loc1.clone();
|
||||
CameraController controller = api.createController(player, seconds, loc1, loc2, loc3, loc4, loc5);
|
||||
return controller;
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Claim.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import com.intellectualcrafters.plot.events.PlayerClaimPlotEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class Claim extends SubCommand{
|
||||
|
||||
public Claim() {
|
||||
super(Command.CLAIM, "Claim the current plot you're standing on.", "claim", CommandCategory.CLAIMING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
if(!PlayerFunctions.isInPlot(plr)) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return true;
|
||||
}
|
||||
if(PlayerFunctions.getPlayerPlotCount(plr.getWorld() , plr) >= PlayerFunctions.getAllowedPlots(plr)) {
|
||||
PlayerFunctions.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
return true;
|
||||
}
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
if(plot.hasOwner()) {
|
||||
PlayerFunctions.sendMessage(plr, C.PLOT_IS_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
claimPlot(plr, plot, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static boolean claimPlot(Player player, Plot plot, boolean teleport) {
|
||||
PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled()) {
|
||||
PlotHelper.createPlot(player, plot);
|
||||
PlotHelper.setSign(player, plot);
|
||||
PlayerFunctions.sendMessage(player, C.CLAIMED);
|
||||
if(teleport) {
|
||||
PlotMain.teleportPlayer(player, player.getLocation(), plot);
|
||||
}
|
||||
}
|
||||
return event.isCancelled();
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Clear.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-01.
|
||||
*/
|
||||
public class Clear extends SubCommand {
|
||||
|
||||
public Clear() {
|
||||
super(Command.CLEAR, "Clear a plot", "clear", CommandCategory.ACTIONS);
|
||||
}
|
||||
@Override
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
if(!PlayerFunctions.isInPlot(plr)) {
|
||||
PlayerFunctions.sendMessage(plr, "You're not in a plot.");
|
||||
return true;
|
||||
}
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
DBFunc.delete(plr.getWorld().getName(), plot);
|
||||
PlotMain.removePlot(plr.getWorld().getName(), plot.id);
|
||||
plot.clear(plr);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Command.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-03.
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public enum Command {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
HELPERS("helpers", "hp"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
DENIED("denied", "dn"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CLAIM("claim", "c"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CLEAR("clear", "delete", new CommandPermission("plots.admin")),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
DEBUG("debug", "database", new CommandPermission("plots.admin")),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
HOME("home", "h"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INFO("info", "i"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
LIST("list", "l"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
SET("set", "s"),
|
||||
/**
|
||||
*
|
||||
*/
|
||||
TP("tp", "tp");
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String command;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String alias;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private CommandPermission permission;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param command
|
||||
*/
|
||||
Command(String command) {
|
||||
this.command = command;
|
||||
this.alias = command;
|
||||
this.permission = new CommandPermission("plots." + command);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param command
|
||||
* @param permission
|
||||
*/
|
||||
Command(String command, CommandPermission permission) {
|
||||
this.command = command;
|
||||
this.permission = permission;
|
||||
this.alias = command;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param command
|
||||
* @param alias
|
||||
*/
|
||||
Command(String command, String alias) {
|
||||
this.command = command;
|
||||
this.alias = alias;
|
||||
this.permission = new CommandPermission("plots." + command);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Command
|
||||
* @param alias
|
||||
* @param permission
|
||||
*/
|
||||
Command(String command, String alias, CommandPermission permission) {
|
||||
this.command = command;
|
||||
this.alias = alias;
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getCommand() {
|
||||
return this.command;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getAlias() {
|
||||
return this.alias;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public CommandPermission getPermission(){
|
||||
return this.permission;
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = CommandPermission.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-03.
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public class CommandPermission {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String permission;
|
||||
|
||||
/**
|
||||
* @param permission
|
||||
*/
|
||||
public CommandPermission(String permission) {
|
||||
this.permission = permission.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean hasPermission(Player player) {
|
||||
return player.hasPermission(this.permission) || player.hasPermission("plots.admin");
|
||||
}
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Debug.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
* \\SuperCharged Compiler made by Citymonstret\\
|
||||
* ||#Compiler:ALPHA-1.0#########################
|
||||
* ||#ST:Java(1.7.*)\impl(bukkit)->api(s[])######
|
||||
* ||#Section:\Debug\############################
|
||||
* ||##Debug->Debug.properties|Debug.txt#########
|
||||
* ||############################################
|
||||
* ||#Signed By:Citymonstret@IC##################
|
||||
* \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
|
||||
*/
|
||||
public class Debug extends SubCommand{
|
||||
|
||||
//private extends SubCommand^Implements {Command, Information} from >>\\S.txt6\\
|
||||
public Debug() {
|
||||
super(Command.DEBUG, "Show debug information", "debug [msg]", CommandCategory.INFO);
|
||||
{
|
||||
/**
|
||||
* This.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
||||
if(args.length > 0 && args[0].equalsIgnoreCase("msg")) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for(C c : C.values()) {
|
||||
msg.append(c.s() + "\n");
|
||||
}
|
||||
PlayerFunctions.sendMessage(plr, msg.toString());
|
||||
return true;
|
||||
}
|
||||
StringBuilder information;
|
||||
String header, line, section;
|
||||
/**
|
||||
* {$notnull || compile:: \\Debug:Captions\\}
|
||||
*/
|
||||
{
|
||||
information = new StringBuilder();
|
||||
header = C.DEUBG_HEADER.s();
|
||||
line = C.DEBUG_LINE.s();
|
||||
section = C.DEBUG_SECTION.s();
|
||||
}
|
||||
/**
|
||||
* {||direct:: load: debug::I>Captions::trsl}
|
||||
* \\
|
||||
* if(missing) set(default) -> this->(){}
|
||||
* \\
|
||||
* echo line->line(Compiler.cpp -> lineCompiler);
|
||||
* when finished: now = this();
|
||||
* now(getter)->setter(this())->{
|
||||
* "string" = getter(this);
|
||||
* setter(string) = getter(this->setter);
|
||||
* }
|
||||
* when ^ finished compile;
|
||||
* if(^compile failed -> |this->failed.|tests->failed.|
|
||||
* ||run test {this->test}|on fail(action(){return FAILED})|
|
||||
*/
|
||||
{
|
||||
StringBuilder worlds = new StringBuilder("");
|
||||
for (World world: PlotMain.getPlotWorlds())
|
||||
worlds.append(world.getName()+" ");
|
||||
information.append(header);
|
||||
information.append(getSection(section, "Lag / TPS"));
|
||||
information.append(getLine(line, "Ticks Per Second", Lag.getTPS()));
|
||||
information.append(getLine(line, "Lag Percentage", (int) Lag.getPercentage() + "%"));
|
||||
information.append(getLine(line, "TPS Percentage", (int) Lag.getFullPercentage() + "%"));
|
||||
information.append(getSection(section, "PlotWorld"));
|
||||
information.append(getLine(line, "Plot Worlds", worlds));
|
||||
information.append(getLine(line, "Owned Plots", PlotMain.getPlots().size()));
|
||||
information.append(getLine(line, "PlotWorld Size", PlotHelper.getWorldFolderSize() + "MB"));
|
||||
information.append(getLine(line, "Entities", PlotHelper.getEntities(plr.getWorld())));
|
||||
information.append(getLine(line, "Loaded Tile Entities", PlotHelper.getTileEntities(plr.getWorld())));
|
||||
information.append(getLine(line, "Loaded Chunks", PlotHelper.getLoadedChunks(plr.getWorld())));
|
||||
information.append(getSection(section, "RAM"));
|
||||
information.append(getLine(line, "Free Ram", RUtils.getFreeRam() + "MB"));
|
||||
information.append(getLine(line, "Total Ram", RUtils.getTotalRam() + "MB"));
|
||||
information.append(getSection(section, "Messages"));
|
||||
information.append(getLine(line, "Total Messages", C.values().length));
|
||||
information.append(getLine(line, "View all captions", "/plot debug msg"));
|
||||
}
|
||||
/**
|
||||
* {function:: SEND_MESSAGE |local player -> plr|local string -> information.toString())}
|
||||
*/
|
||||
{
|
||||
PlayerFunctions.sendMessage(plr, information.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getSection(String line, String val) {
|
||||
return line.replaceAll("%val%", val) + "\n";
|
||||
}
|
||||
|
||||
private String getLine(String line, String var, Object val) {
|
||||
return line.replaceAll("%var%", var).replaceAll("%val%", "" + val) + "\n";
|
||||
}
|
||||
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Denied.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-03.
|
||||
*/
|
||||
@SuppressWarnings("deprecated")
|
||||
public class Denied extends SubCommand{
|
||||
|
||||
public Denied() {
|
||||
super(Command.DENIED, "Manage plot helpers", "denied {add|remove} {player}", CommandCategory.ACTIONS);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecated")
|
||||
private boolean hasBeenOnServer(String name) {
|
||||
Player plr;
|
||||
if((plr = Bukkit.getPlayer(name)) == null) {
|
||||
OfflinePlayer oplr = Bukkit.getOfflinePlayer(name);
|
||||
if(oplr == null) return false;
|
||||
else return oplr.hasPlayedBefore();
|
||||
} else {
|
||||
if(plr.isOnline()) return true;
|
||||
else return plr.hasPlayedBefore();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
if(args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.DENIED_NEED_ARGUMENT);
|
||||
return true;
|
||||
}
|
||||
if(!PlayerFunctions.isInPlot(plr)) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return true;
|
||||
}
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
if(plot.owner == null || !plot.hasRights(plr)) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("add")) {
|
||||
if(args[1].equalsIgnoreCase("*")) {
|
||||
UUID uuid = DBFunc.everyone;
|
||||
plot.addDenied(uuid);
|
||||
DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
||||
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED);
|
||||
return true;
|
||||
}
|
||||
if(!hasBeenOnServer(args[1])) {
|
||||
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
||||
return true;
|
||||
}
|
||||
UUID uuid = null;
|
||||
if(Bukkit.getPlayer(args[1]) != null && Bukkit.getPlayer(args[1]).isOnline())
|
||||
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
|
||||
else
|
||||
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
|
||||
plot.addDenied(uuid);
|
||||
DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
||||
PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED);
|
||||
if(Bukkit.getPlayer(uuid) != null && Bukkit.getPlayer(uuid).isOnline()) {
|
||||
Plot pl = PlayerFunctions.getCurrentPlot(Bukkit.getPlayer((uuid)));
|
||||
if(pl.id == plot.id) {
|
||||
PlayerFunctions.sendMessage(Bukkit.getPlayer(uuid), C.YOU_BE_DENIED);
|
||||
Bukkit.getPlayer(uuid).teleport(Bukkit.getPlayer(uuid).getWorld().getSpawnLocation());
|
||||
}
|
||||
}
|
||||
} else if(args[0].equalsIgnoreCase("remove")) {
|
||||
if(args[1].equalsIgnoreCase("*")) {
|
||||
UUID uuid = DBFunc.everyone;
|
||||
if(!plot.denied.contains(uuid)) {
|
||||
PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED);
|
||||
return true;
|
||||
}
|
||||
plot.removeDenied(uuid);
|
||||
DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
||||
PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED);
|
||||
return true;
|
||||
}
|
||||
if(!hasBeenOnServer(args[1])) {
|
||||
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
||||
return true;
|
||||
}
|
||||
UUID uuid = null;
|
||||
if(Bukkit.getPlayer(args[1]).isOnline())
|
||||
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
|
||||
else
|
||||
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
|
||||
if(!plot.denied.contains(uuid)) {
|
||||
PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED);
|
||||
return true;
|
||||
}
|
||||
plot.removeDenied(uuid);
|
||||
DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
||||
PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, false);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
PlayerFunctions.sendMessage(plr, C.DENIED_REMOVED);
|
||||
} else {
|
||||
PlayerFunctions.sendMessage(plr, C.DENIED_NEED_ARGUMENT);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Help.java
|
||||
* >> Generated by: Citymonstret at 2014-08-11 17:32
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-11.
|
||||
*/
|
||||
public class Help extends SubCommand {
|
||||
public Help() {
|
||||
super("help", "", "Get this help menu", "help", "he", SubCommand.CommandCategory.INFO);
|
||||
}
|
||||
public boolean execute(Player plr, String ... args) { return false; }
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Helpers.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class Helpers extends SubCommand{
|
||||
|
||||
public Helpers() {
|
||||
super(Command.HELPERS, "Manage plot helpers", "helpers {add|remove} {player}", CommandCategory.ACTIONS);
|
||||
}
|
||||
|
||||
|
||||
private boolean hasBeenOnServer(String name) {
|
||||
Player plr;
|
||||
if((plr = Bukkit.getPlayer(name)) == null) {
|
||||
OfflinePlayer oplr = Bukkit.getOfflinePlayer(name);
|
||||
if(oplr == null) return false;
|
||||
else return oplr.hasPlayedBefore();
|
||||
} else {
|
||||
if(plr.isOnline()) return true;
|
||||
else return plr.hasPlayedBefore();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
if(args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.HELPER_NEED_ARGUMENT);
|
||||
return true;
|
||||
}
|
||||
if(!PlayerFunctions.isInPlot(plr)) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return true;
|
||||
}
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
if(plot.owner == null || !plot.hasRights(plr)) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
||||
return true;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("add")) {
|
||||
if(args[1].equalsIgnoreCase("*")) {
|
||||
UUID uuid = DBFunc.everyone;
|
||||
plot.addHelper(uuid);
|
||||
DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
||||
PlayerFunctions.sendMessage(plr, C.HELPER_ADDED);
|
||||
return true;
|
||||
}
|
||||
if(!hasBeenOnServer(args[1])) {
|
||||
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
||||
return true;
|
||||
}
|
||||
UUID uuid = null;
|
||||
if(Bukkit.getPlayer(args[1]) != null && Bukkit.getPlayer(args[1]).isOnline())
|
||||
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
|
||||
else
|
||||
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
|
||||
plot.addHelper(uuid);
|
||||
DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
||||
PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
PlayerFunctions.sendMessage(plr, C.HELPER_ADDED);
|
||||
} else if(args[0].equalsIgnoreCase("remove")) {
|
||||
if(args[1].equalsIgnoreCase("*")) {
|
||||
UUID uuid = DBFunc.everyone;
|
||||
if(!plot.helpers.contains(uuid)) {
|
||||
PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED);
|
||||
return true;
|
||||
}
|
||||
plot.removeHelper(uuid);
|
||||
DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
||||
PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED);
|
||||
return true;
|
||||
}
|
||||
if(!hasBeenOnServer(args[1])) {
|
||||
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
|
||||
return true;
|
||||
}
|
||||
UUID uuid = null;
|
||||
if(Bukkit.getPlayer(args[1]).isOnline())
|
||||
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
|
||||
else
|
||||
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
|
||||
if(!plot.helpers.contains(uuid)) {
|
||||
PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED);
|
||||
return true;
|
||||
}
|
||||
plot.removeHelper(uuid);
|
||||
DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
|
||||
PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, false);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
PlayerFunctions.sendMessage(plr, C.HELPER_REMOVED);
|
||||
} else {
|
||||
PlayerFunctions.sendMessage(plr, C.HELPER_NEED_ARGUMENT);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Home.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class Home extends SubCommand{
|
||||
|
||||
public Home() {
|
||||
super(Command.HOME, "Go to your plot", "home {id|alias}", CommandCategory.TELEPORT);
|
||||
}
|
||||
private Plot isAlias(String a) {
|
||||
for(Plot p : PlotMain.getPlots()) {
|
||||
if(p.settings.getAlias().length() > 0 && p.settings.getAlias().equalsIgnoreCase(a))
|
||||
return p;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
|
||||
// TODO plot names / alias
|
||||
|
||||
Plot[] plots = PlotMain.getPlots(plr).toArray(new Plot[0]);
|
||||
if(plots.length == 1) {
|
||||
PlotMain.teleportPlayer(plr, plr.getLocation(), plots[0]);
|
||||
return true;
|
||||
} else if(plots.length > 1) {
|
||||
if(args.length < 1) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_PLOT_NUMBER);
|
||||
return true;
|
||||
}
|
||||
int id = 0;
|
||||
try {
|
||||
id = Integer.parseInt(args[0]);
|
||||
} catch (Exception e) {
|
||||
|
||||
Plot temp;
|
||||
if((temp = isAlias(args[0])) != null) {
|
||||
if (temp.hasOwner()) {
|
||||
if (temp.getOwner().equals(plr.getUniqueId())) {
|
||||
PlotMain.teleportPlayer(plr, plr.getLocation(), temp);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_YOUR_PLOT);
|
||||
return false;
|
||||
}
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||
return true;
|
||||
}
|
||||
if(id > (plots.length) || id < 1) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
PlotMain.teleportPlayer(plr, plr.getLocation(), plots[id - 1]);
|
||||
return true;
|
||||
} else {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PLOTS);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Info.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class Info extends SubCommand{
|
||||
|
||||
public Info() {
|
||||
super(Command.INFO, "Display plot info", "info", CommandCategory.INFO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(Player player, String ... args) {
|
||||
if(!PlayerFunctions.isInPlot(player)) {
|
||||
PlayerFunctions.sendMessage(player, C.NOT_IN_PLOT);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ||
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(player);
|
||||
|
||||
boolean hasOwner = plot.hasOwner();
|
||||
boolean containsEveryone;
|
||||
|
||||
// Wildcard player {added}
|
||||
{
|
||||
if(plot.helpers == null) {
|
||||
containsEveryone = false;
|
||||
} else {
|
||||
containsEveryone = plot.helpers.contains(DBFunc.everyone);
|
||||
}
|
||||
}
|
||||
|
||||
// Unclaimed?
|
||||
if(!hasOwner && !containsEveryone) {
|
||||
PlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, plot.id.x+";"+plot.id.y);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Helpers :D
|
||||
StringBuilder helpers = new StringBuilder();
|
||||
|
||||
String owner = "none";
|
||||
if(plot.owner != null)
|
||||
owner = Bukkit.getOfflinePlayer(plot.owner).getName();
|
||||
|
||||
String info = C.PLOT_INFO.s();
|
||||
info = info.replaceAll("%alias%", plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none");
|
||||
info = info.replaceAll("%id%", plot.id.x+";"+plot.id.y);
|
||||
info = info.replaceAll("%biome%", getBiomeAt(plot).toString());
|
||||
info = info.replaceAll("%owner%", owner);
|
||||
info = info.replaceAll("%time%", plot.settings.getChangeTime() ? plot.settings.getTime() + "" : "default");
|
||||
info = info.replaceAll("%weather%", plot.settings.getRain() ? "rain" : "default");
|
||||
info = info.replaceAll("%helpers%", getPlayerList(plot.helpers));
|
||||
info = info.replaceAll("%denied%", getPlayerList(plot.denied));
|
||||
PlayerFunctions.sendMessage(player, info);
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getPlayerList(ArrayList<UUID> l) {
|
||||
if(l == null || l.size() < 1) return " none";
|
||||
String c = C.PLOT_USER_LIST.s();
|
||||
StringBuilder list = new StringBuilder();
|
||||
for(int x = 0; x < l.size(); x++) {
|
||||
if(x + 1 == l.size())
|
||||
list.append(c.replace("%user%", getPlayerName(l.get(x))).replace(",", ""));
|
||||
else
|
||||
list.append(c.replace("%user%", getPlayerName(l.get(x))));
|
||||
}
|
||||
return list.toString();
|
||||
}
|
||||
|
||||
private String getPlayerName(UUID uuid) {
|
||||
if(uuid == null) return "unknown";
|
||||
if(uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString()))
|
||||
return "everyone";
|
||||
OfflinePlayer plr = Bukkit.getOfflinePlayer(uuid);
|
||||
if(plr == null) return "unknown";
|
||||
return plr.getName();
|
||||
}
|
||||
|
||||
private Biome getBiomeAt(Plot plot) {
|
||||
World w = Bukkit.getWorld(plot.world);
|
||||
Location bl = PlotHelper.getPlotTopLoc(w, plot.id);
|
||||
return bl.getBlock().getBiome();
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Inventory.java
|
||||
* >> Generated by: Citymonstret at 2014-08-10 13:57
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Inventory extends SubCommand {
|
||||
|
||||
public Inventory() {
|
||||
super("inventory", "plots.inventory", "Open a command inventory", "inventory", "inv", CommandCategory.INFO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final Player plr, String ... args) {
|
||||
ArrayList<SubCommand> cmds = new ArrayList<>();
|
||||
for(SubCommand cmd : MainCommand.subCommands) {
|
||||
if(cmd.permission.hasPermission(plr))
|
||||
cmds.add(cmd);
|
||||
}
|
||||
int size = 9 * (int) Math.ceil(cmds.size() / 9.0);
|
||||
org.bukkit.inventory.Inventory inventory = Bukkit.createInventory(null, size, "PlotSquared Commands");
|
||||
for(SubCommand cmd : cmds) {
|
||||
inventory.addItem(getItem(cmd));
|
||||
}
|
||||
plr.openInventory(inventory);
|
||||
return true;
|
||||
}
|
||||
|
||||
private ItemStack getItem(final SubCommand cmd) {
|
||||
ItemStack stack = new ItemStack(Material.COMMAND);
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
{
|
||||
meta.setDisplayName(ChatColor.GREEN + cmd.cmd + ChatColor.DARK_GRAY + " [" + ChatColor.GREEN + cmd.alias + ChatColor.DARK_GRAY + "]");
|
||||
meta.setLore(new ArrayList<String>() {
|
||||
{
|
||||
add(ChatColor.RED + "Category: " + ChatColor.GOLD + cmd.category.toString());
|
||||
add(ChatColor.RED + "Description: " + ChatColor.GOLD + cmd.description);
|
||||
add(ChatColor.RED + "Usage: " + ChatColor.GOLD + "/plot " + cmd.usage);
|
||||
}
|
||||
});
|
||||
}
|
||||
stack.setItemMeta(meta);
|
||||
return stack;
|
||||
}
|
||||
}
|
@ -1,158 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = MainCommand.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:42
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* PlotMain command class
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class MainCommand implements CommandExecutor{
|
||||
|
||||
private static SubCommand[] _subCommands = new SubCommand[] {
|
||||
new Claim(),
|
||||
new Auto(),
|
||||
new Home(),
|
||||
new Visit(),
|
||||
new TP(),
|
||||
new Set(),
|
||||
new Clear(),
|
||||
new SetOwner(),
|
||||
new Denied(),
|
||||
new Helpers(),
|
||||
new Info(),
|
||||
new list(),
|
||||
new Help(),
|
||||
new Debug(),
|
||||
new Schematic(),
|
||||
new plugin(),
|
||||
new Inventory(),
|
||||
new Reload()
|
||||
};
|
||||
|
||||
public static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() { {
|
||||
addAll(Arrays.asList(_subCommands));
|
||||
}};
|
||||
|
||||
public static boolean no_permission(Player player) {
|
||||
PlayerFunctions.sendMessage(player, C.NO_PERMISSION);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
|
||||
String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
if (args.length>0) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
new Reload().executeConsole(args);
|
||||
}
|
||||
}
|
||||
else {
|
||||
PlotMain.sendConsoleSenderMessage(C.PREFIX.s()+C.HELP_HEADER.s());
|
||||
PlotMain.sendConsoleSenderMessage("&6/plots reload &c-&6 reloads the plugin");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if(!player.hasPermission("plots.use")) {
|
||||
return no_permission(player);
|
||||
}
|
||||
if(args.length < 1 || (args.length >= 1 && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he"))) )
|
||||
{
|
||||
if(args.length < 2) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.HELP_INFO.s());
|
||||
for(SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) {
|
||||
builder.append("\n" + C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
|
||||
}
|
||||
PlayerFunctions.sendMessage(player, builder.toString());
|
||||
return true;
|
||||
}
|
||||
String cat = args[1];
|
||||
SubCommand.CommandCategory cato = null;
|
||||
for(SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) {
|
||||
if(cat.equalsIgnoreCase(category.toString())){
|
||||
cato = category;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(cato == null) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.HELP_INFO.s());
|
||||
for(SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) {
|
||||
builder.append("\n" + C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
|
||||
}
|
||||
PlayerFunctions.sendMessage(player, builder.toString());
|
||||
return true;
|
||||
}
|
||||
StringBuilder help = new StringBuilder();
|
||||
for(String string : helpMenu(player, cato))
|
||||
help.append(string + "\n");
|
||||
PlayerFunctions.sendMessage(player, help.toString());
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
for(SubCommand command : subCommands) {
|
||||
if(command.cmd.equalsIgnoreCase(args[0]) || command.alias.equalsIgnoreCase(args[0])) {
|
||||
String[] arguments = new String[args.length - 1];
|
||||
for(int x = 1; x < args.length; x++)
|
||||
arguments[x - 1] = args[x];
|
||||
if(command.permission.hasPermission(player))
|
||||
return command.execute(player, arguments);
|
||||
else return no_permission(player);
|
||||
}
|
||||
}
|
||||
PlayerFunctions.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ArrayList<String> helpMenu(Player player, final SubCommand.CommandCategory category) {
|
||||
ArrayList<String> help = new ArrayList<String>(){
|
||||
{
|
||||
add(t(C.HELP_HEADER.s()));
|
||||
add(t(C.HELP_CATEGORY.s().replaceAll("%category%", category.toString())));
|
||||
}
|
||||
};
|
||||
for (SubCommand cmd : subCommands) {
|
||||
if (cmd.permission.hasPermission(player) && cmd.category == category) {
|
||||
String s = t(C.HELP_PAGE.s());
|
||||
s = s.replaceAll("%alias%", cmd.alias);
|
||||
s = s.replaceAll("%usage%", "/plot " + cmd.usage);
|
||||
s = s.replaceAll("%cmd%", cmd.cmd);
|
||||
s = s.replaceAll("%desc%", cmd.description);
|
||||
help.add(s);
|
||||
}
|
||||
}
|
||||
if (help.size() < 2) {
|
||||
help.add(t(C.NO_COMMANDS.s()));
|
||||
}
|
||||
return help;
|
||||
}
|
||||
|
||||
private static String t(String s) {
|
||||
return ChatColor.translateAlternateColorCodes('&', s);
|
||||
}
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Reload.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:42
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
|
||||
/**
|
||||
* @Deprecated
|
||||
*/
|
||||
public class Reload extends SubCommand{
|
||||
|
||||
public Reload() {
|
||||
super("reload", "plots.admin", "Reload configurations", "", "reload", CommandCategory.INFO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
try {
|
||||
PlotMain.reloadTranslations();
|
||||
PlotMain.BroadcastWithPerms(C.RELOADED_CONFIGS);
|
||||
} catch(Exception e) {
|
||||
if (plr!=null)
|
||||
PlayerFunctions.sendMessage(plr, C.RELOAD_FAILED);
|
||||
else
|
||||
PlotMain.sendConsoleSenderMessage(C.RELOAD_FAILED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.Settings;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Schematic extends SubCommand {
|
||||
|
||||
public Schematic() {
|
||||
super("schematic", "plots.admin", "Schematic Command", "schematic {arg}", "sch", CommandCategory.ACTIONS);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean execute(Player plr, String... args) {
|
||||
if(args.length < 1) {
|
||||
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
return true;
|
||||
}
|
||||
String arg = args[0];
|
||||
switch(arg) {
|
||||
case "test":
|
||||
if(args.length < 2) {
|
||||
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
break;
|
||||
}
|
||||
String file = args[1];
|
||||
SchematicHandler.Schematic schematic = new SchematicHandler().getSchematic(file);
|
||||
if(schematic == null) {
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
||||
break;
|
||||
}
|
||||
int l1 = schematic.getSchematicDimension().getX();
|
||||
int l2 = schematic.getSchematicDimension().getZ();
|
||||
int length = PlotMain.getWorldSettings(plr.getWorld()).PLOT_WIDTH;
|
||||
if(l1 != length || l2 != length) {
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
|
||||
break;
|
||||
}
|
||||
sendMessage(plr, C.SCHEMATIC_VALID);
|
||||
break;
|
||||
default:
|
||||
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,324 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Set.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:42
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.WeatherType;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class Set extends SubCommand{
|
||||
|
||||
public Set() {
|
||||
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS);
|
||||
}
|
||||
|
||||
public static String[] values = new String[] {
|
||||
"biome", "wall", "wall_filling", "floor", "alias", "home", "rain"
|
||||
};
|
||||
public static String[] aliases = new String[] {
|
||||
"b", "w", "wf", "f", "a", "h", "r"
|
||||
};
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
if(!PlayerFunctions.isInPlot(plr)) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
|
||||
if(!plot.hasRights(plr) && !plr.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if(args.length < 1) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
|
||||
builder.append(getArgumentList(values));
|
||||
PlayerFunctions.sendMessage(plr, builder.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
for(int i = 0; i < aliases.length; i++) {
|
||||
if(aliases[i].equalsIgnoreCase(args[0])) {
|
||||
args[0] = values[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: Implement option */
|
||||
boolean advanced_permissions = false;
|
||||
if(advanced_permissions) {
|
||||
if(!plr.hasPermission("plots.set." + args[0].toLowerCase())) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("rain")) {
|
||||
if(args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_ON_OFF);
|
||||
return false;
|
||||
}
|
||||
String word = args[1];
|
||||
if(!word.equalsIgnoreCase("on") && !word.equalsIgnoreCase("off")) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_ON_OFF);
|
||||
return true;
|
||||
}
|
||||
boolean b = word.equalsIgnoreCase("on");
|
||||
DBFunc.setWeather(plr.getWorld().getName(), plot, b);
|
||||
PlayerFunctions.sendMessage(plr, C.SETTING_UPDATED);
|
||||
for(Player p : Bukkit.getOnlinePlayers()) {
|
||||
if(PlayerFunctions.getCurrentPlot(plr).id == plot.id) {
|
||||
if(b) p.setPlayerWeather(WeatherType.DOWNFALL);
|
||||
else p.resetPlayerWeather();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("home")) {
|
||||
if(args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.MISSING_POSITION);
|
||||
return false;
|
||||
}
|
||||
PlotHomePosition position = null;
|
||||
for(PlotHomePosition p : PlotHomePosition.values()) {
|
||||
if(p.isMatching(args[1])) position = p;
|
||||
}
|
||||
if(position == null) {
|
||||
PlayerFunctions.sendMessage(plr, C.INVALID_POSITION);
|
||||
return false;
|
||||
}
|
||||
DBFunc.setPosition(plr.getWorld().getName(), plot, position.toString());
|
||||
PlayerFunctions.sendMessage(plr, C.POSITION_SET);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(args[0].equalsIgnoreCase("alias")) {
|
||||
if(args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.MISSING_ALIAS);
|
||||
return false;
|
||||
}
|
||||
String alias = args[1];
|
||||
for(Plot p : PlotMain.getPlots()) {
|
||||
if(p.settings.getAlias().equalsIgnoreCase(alias)) {
|
||||
PlayerFunctions.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
DBFunc.setAlias(plr.getWorld().getName(), plot, alias);
|
||||
PlayerFunctions.sendMessage(plr, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias));
|
||||
return true;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("biome")) {
|
||||
if(args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_BIOME);
|
||||
return true;
|
||||
}
|
||||
Biome biome = null;
|
||||
for(Biome b : Biome.values()) {
|
||||
if(b.toString().equalsIgnoreCase(args[1])) {
|
||||
biome = b;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(biome == null) {
|
||||
PlayerFunctions.sendMessage(plr, getBiomeList(Arrays.asList(Biome.values())));
|
||||
return true;
|
||||
}
|
||||
PlotHelper.setBiome(plr.getWorld(), plot, biome);
|
||||
PlayerFunctions.sendMessage(plr, C.BIOME_SET_TO.s() + biome.toString().toLowerCase());
|
||||
return true;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("wall")) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
||||
if (plotworld==null) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return true;
|
||||
}
|
||||
if(args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
||||
return true;
|
||||
}
|
||||
Material material = null;
|
||||
for(Material m : plotworld.BLOCKS) {
|
||||
if(m.toString().equalsIgnoreCase(args[1])) {
|
||||
material = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(material == null) {
|
||||
PlayerFunctions.sendMessage(plr, getBlockList(plotworld.BLOCKS));
|
||||
return true;
|
||||
}
|
||||
byte data = 0;
|
||||
|
||||
if(args.length > 2) {
|
||||
try {
|
||||
data = (byte) Integer.parseInt(args[2]);
|
||||
} catch(Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
PlayerFunctions.sendMessage(plr, C.GENERATING_WALL);
|
||||
PlotHelper.adjustWall(plr.getWorld(), plot, (short)material.getId(), data);
|
||||
return true;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("floor")) {
|
||||
if(args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
||||
return true;
|
||||
}
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
||||
if (plotworld==null) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return true;
|
||||
}
|
||||
//
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<Material> materials = (ArrayList<Material>) plotworld.BLOCKS.clone();
|
||||
materials.add(Material.AIR);
|
||||
//
|
||||
String[] strings = args[1].split(",");
|
||||
//
|
||||
Material[] material = new Material[strings.length];
|
||||
byte[] data = new byte[strings.length];
|
||||
//
|
||||
int index = 0;
|
||||
//
|
||||
byte b = (byte) 0;
|
||||
Material m = null;
|
||||
//
|
||||
for(String s : strings) {
|
||||
s = s.replaceAll(",", "");
|
||||
String[] ss = s.split(";");
|
||||
ss[0] = ss[0].replaceAll(";", "");
|
||||
for(Material ma : materials) {
|
||||
if(ma.toString().equalsIgnoreCase(ss[0])) {
|
||||
m = ma;
|
||||
}
|
||||
}
|
||||
if(m == null) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_BLOCK);
|
||||
return true;
|
||||
}
|
||||
if(ss.length == 1) {
|
||||
data[index] = (byte) 0;
|
||||
material[index] = m;
|
||||
} else {
|
||||
try {
|
||||
b = (byte) Integer.parseInt(ss[1]);
|
||||
} catch(Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
||||
return true;
|
||||
}
|
||||
data[index] = b;
|
||||
material[index] = m;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
PlotHelper.setFloor(plr, plot, material, data);
|
||||
return true;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("wall_filling")) {
|
||||
if(args.length < 2) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_BLOCK);
|
||||
return true;
|
||||
}
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(plr.getWorld());
|
||||
if (plotworld==null) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return true;
|
||||
}
|
||||
Material material = null;
|
||||
for(Material m : plotworld.BLOCKS) {
|
||||
if(m.toString().equalsIgnoreCase(args[1])) {
|
||||
material = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(material == null) {
|
||||
PlayerFunctions.sendMessage(plr, getBlockList(plotworld.BLOCKS));
|
||||
return true;
|
||||
}
|
||||
byte data = 0;
|
||||
|
||||
if(args.length > 2) {
|
||||
try {
|
||||
data = (byte) Integer.parseInt(args[2]);
|
||||
} catch(Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_DATA);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
PlotHelper.adjustWallFilling(plr, plr.getWorld(), plot, (short)material.getId(), data);
|
||||
return true;
|
||||
}
|
||||
PlayerFunctions.sendMessage(plr, "Not a valid option. Use {TODO: Insert list.}");
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getMaterial(Material m) {
|
||||
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", m.toString().toLowerCase()));
|
||||
}
|
||||
|
||||
private String getBiome(Biome b) {
|
||||
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", b.toString().toLowerCase()));
|
||||
}
|
||||
|
||||
private String getString(String s) {
|
||||
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s));
|
||||
}
|
||||
|
||||
private String getArgumentList(String[] strings) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for(String s : strings) {
|
||||
builder.append(getString(s));
|
||||
}
|
||||
return builder.toString().substring(1, builder.toString().length() - 1);
|
||||
}
|
||||
|
||||
private String getBiomeList(List<Biome> biomes) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
||||
for(Biome b : biomes) {
|
||||
builder.append(getBiome(b));
|
||||
}
|
||||
return builder.toString().substring(1,builder.toString().length() - 1);
|
||||
}
|
||||
|
||||
private String getBlockList(List<Material> blocks) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(ChatColor.translateAlternateColorCodes('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
||||
for(Material b : blocks) {
|
||||
builder.append(getMaterial(b));
|
||||
}
|
||||
return builder.toString().substring(1,builder.toString().length() - 1);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = SetOwner.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:42
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class SetOwner extends SubCommand{
|
||||
|
||||
public SetOwner() {
|
||||
super("setowner", "plots.admin", "Set the plot owner", "setowner {player}", "so", CommandCategory.ACTIONS);
|
||||
}
|
||||
|
||||
private UUID getUUID(String string) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(string);
|
||||
return (player != null && player.hasPlayedBefore()) ? player.getUniqueId() : null;
|
||||
}
|
||||
@Override
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
if(!PlayerFunctions.isInPlot(plr)) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return true;
|
||||
}
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
if(args.length < 1) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_USER);
|
||||
return true;
|
||||
}
|
||||
plot.owner = getUUID(args[0]);
|
||||
PlotMain.updatePlot(plot);
|
||||
DBFunc.setOwner(plot, plot.owner);
|
||||
PlayerFunctions.sendMessage(plr, C.SET_OWNER);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = SubCommand.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:42
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* SubCommand class
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public abstract class SubCommand {
|
||||
|
||||
/**
|
||||
* Command
|
||||
*/
|
||||
public String cmd;
|
||||
/**
|
||||
* Permission node
|
||||
*/
|
||||
public CommandPermission permission;
|
||||
/**
|
||||
* Simple description
|
||||
*/
|
||||
public String description;
|
||||
/**
|
||||
* Alias
|
||||
*/
|
||||
public String alias;
|
||||
|
||||
/**
|
||||
* Command usage
|
||||
*/
|
||||
public String usage;
|
||||
|
||||
public CommandCategory category;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cmd Command /plot {cmd} <-- That!
|
||||
* @param permission Permission Node
|
||||
* @param description Simple description
|
||||
* @param usage Usage description: /plot command {args...}
|
||||
* @param alias Command alias
|
||||
* @param category CommandCategory. Pick whichever closests to what you want.
|
||||
*/
|
||||
public SubCommand(String cmd, String permission, String description, String usage, String alias, CommandCategory category) {
|
||||
this.cmd = cmd;
|
||||
this.permission = new CommandPermission(permission);
|
||||
this.description = description;
|
||||
this.alias = alias;
|
||||
this.usage = usage;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param command Command /plot {cmd} <-- That!
|
||||
* @param description Simple description
|
||||
* @param usage Usage description: /plot command {args...}
|
||||
* @param category CommandCategory. Pick whichever closests to what you want.
|
||||
*/
|
||||
public SubCommand(Command command, String description, String usage, CommandCategory category) {
|
||||
this.cmd = command.getCommand();
|
||||
this.permission = command.getPermission();
|
||||
this.alias = command.getAlias();
|
||||
this.description = description;
|
||||
this.usage = usage;
|
||||
this.category = category;
|
||||
}
|
||||
/**
|
||||
* Execute.
|
||||
* @param plr executor
|
||||
* @param args arguments
|
||||
* @return true on success, false on failure
|
||||
*/
|
||||
public abstract boolean execute(Player plr, String ... args);
|
||||
public void executeConsole(String ... args) { this.execute(null, args); }
|
||||
|
||||
public void sendMessage(Player plr, C c, String ... args) {
|
||||
PlayerFunctions.sendMessage(plr, c, args);
|
||||
}
|
||||
|
||||
|
||||
public enum CommandCategory {
|
||||
CLAIMING("Claiming"),
|
||||
TELEPORT("Teleportation"),
|
||||
ACTIONS("Actions"),
|
||||
INFO("Information");
|
||||
private String name;
|
||||
CommandCategory(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = TP.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:42
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class TP extends SubCommand {
|
||||
|
||||
public TP() {
|
||||
super(Command.TP, "Teleport to a plot", "tp {alias|id}", CommandCategory.TELEPORT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
if(args.length < 1) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_PLOT_ID);
|
||||
return false;
|
||||
}
|
||||
String id = args[0];
|
||||
PlotId plotid;
|
||||
World world = plr.getWorld();
|
||||
if (args.length==2) {
|
||||
if (Bukkit.getWorld(args[1])!=null)
|
||||
world = Bukkit.getWorld(args[1]);
|
||||
}
|
||||
if (!PlotMain.isPlotWorld(world)) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
Plot temp;
|
||||
if((temp = isAlias(id)) != null) {
|
||||
PlotMain.teleportPlayer(plr, plr.getLocation(), temp);
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
|
||||
PlotMain.teleportPlayer(plr, plr.getLocation(), PlotHelper.getPlot(world, plotid));
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Plot isAlias(String a) {
|
||||
for(Plot p : PlotMain.getPlots()) {
|
||||
if(p.settings.getAlias().length() > 0 && p.settings.getAlias().equalsIgnoreCase(a))
|
||||
return p;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = Visit.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:42
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class Visit extends SubCommand{
|
||||
public Visit() {
|
||||
super("visit", "plots.visit", "Visit someones plot", "visit {player} [#]", "v", CommandCategory.TELEPORT);
|
||||
}
|
||||
|
||||
public List<Plot> getPlots(UUID uuid) {
|
||||
List<Plot> plots = new ArrayList<Plot>();
|
||||
for(Plot p : PlotMain.getPlots())
|
||||
if(p.owner.equals(uuid))
|
||||
plots.add(p);
|
||||
return plots;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
if(args.length < 1) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_USER);
|
||||
return true;
|
||||
}
|
||||
String username = args[0];
|
||||
List<Plot> plots = getPlots(Bukkit.getOfflinePlayer(username).getUniqueId());
|
||||
if(plots.isEmpty()) {
|
||||
PlayerFunctions.sendMessage(plr, C.FOUND_NO_PLOTS);
|
||||
return true;
|
||||
}
|
||||
if(args.length < 2){
|
||||
Plot plot = plots.get(0);
|
||||
PlotMain.teleportPlayer(plr, plr.getLocation(), plot);
|
||||
return true;
|
||||
}
|
||||
int i;
|
||||
try {
|
||||
i = Integer.parseInt(args[1]);
|
||||
} catch(Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||
return true;
|
||||
}
|
||||
if(i < 0 || i > plots.size()) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||
return true;
|
||||
}
|
||||
Plot plot = plots.get(i);
|
||||
PlotMain.teleportPlayer(plr, plr.getLocation(), plot);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = list.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:41
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotId;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class list extends SubCommand{
|
||||
|
||||
public list() {
|
||||
super(Command.LIST, "List all plots", "list {mine|all|world}", CommandCategory.INFO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
if(args.length < 1) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
|
||||
builder.append(getArgumentList(new String[]{"mine", "all", "world"}));
|
||||
PlayerFunctions.sendMessage(plr, builder.toString());
|
||||
return true;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("mine")) {
|
||||
StringBuilder string = new StringBuilder();
|
||||
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "your") + "\n");
|
||||
int idx = 0;
|
||||
for(Plot p : PlotMain.getPlots(plr)) {
|
||||
string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id%", p.id.x+";"+p.id.y+";"+p.world).replaceAll("%owner%", getName(p.owner)) + "\n");
|
||||
idx++;
|
||||
}
|
||||
if(idx == 0) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PLOTS);
|
||||
return true;
|
||||
}
|
||||
string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "You have").replaceAll("%num%", idx + "").replaceAll("%plot%", idx == 1 ? "plot" : "plots"));
|
||||
PlayerFunctions.sendMessage(plr, string.toString());
|
||||
return true;
|
||||
} else if(args[0].equalsIgnoreCase("all")) {
|
||||
StringBuilder string = new StringBuilder();
|
||||
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") + "\n");
|
||||
for(Plot p : PlotMain.getPlots()) {
|
||||
string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id%", p.id.x+";"+p.id.y+";"+p.world).replaceAll("%owner%", getName(p.owner)) + "\n");
|
||||
}
|
||||
string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", PlotMain.getPlots().size() + "").replaceAll("%plot%", PlotMain.getPlots().size() == 1 ? "plot" : "plots"));
|
||||
PlayerFunctions.sendMessage(plr, string.toString());
|
||||
return true;
|
||||
} else if(args[0].equalsIgnoreCase("world")) {
|
||||
StringBuilder string = new StringBuilder();
|
||||
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") + "\n");
|
||||
HashMap<PlotId, Plot> plots = PlotMain.getPlots(plr.getWorld());
|
||||
for(Plot p : plots.values()) {
|
||||
string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id%", p.id.x+";"+p.id.y+";"+p.world).replaceAll("%owner%", getName(p.owner)) + "\n");
|
||||
}
|
||||
string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", plots.values().size() + "").replaceAll("%plot%", plots.values().size() == 1 ? "plot" : "plots"));
|
||||
PlayerFunctions.sendMessage(plr, string.toString());
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
execute(plr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getName(UUID id) {
|
||||
if(id == null)
|
||||
return "none";
|
||||
return Bukkit.getOfflinePlayer(id).getName();
|
||||
}
|
||||
private String getArgumentList(String[] strings) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for(String s : strings) {
|
||||
builder.append(getString(s));
|
||||
}
|
||||
return builder.toString().substring(1, builder.toString().length() - 1);
|
||||
}
|
||||
|
||||
|
||||
private String getString(String s) {
|
||||
return ChatColor.translateAlternateColorCodes('&', C.BLOCK_LIST_ITEM.s().replaceAll("%mat%", s));
|
||||
}
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = plugin.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:42
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Settings;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class plugin extends SubCommand {
|
||||
|
||||
public plugin() {
|
||||
super("plugin", "", "Show plugin information", "plugin", "pl", CommandCategory.INFO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(Player plr, String ... args) {
|
||||
ArrayList<String> strings = new ArrayList<String>() {
|
||||
{
|
||||
add(String.format("&c>> &6PlotSquared (Version: %s)", PlotMain.getMain().getDescription().getVersion()));
|
||||
add(String.format("&c>> &6Made by Citymonstret and brandonrelph"));
|
||||
add(String.format("&c>> &6Download at %s", Settings.URL));
|
||||
}
|
||||
};
|
||||
for(String s : strings)
|
||||
PlayerFunctions.sendMessage(plr, s);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,543 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = DBFunc.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:43
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.database;
|
||||
import com.intellectualcrafters.plot.Logger;
|
||||
import com.intellectualcrafters.plot.Logger.LogLevel;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotHomePosition;
|
||||
import com.intellectualcrafters.plot.PlotId;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.intellectualcrafters.plot.PlotMain.connection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class DBFunc {
|
||||
|
||||
/**
|
||||
* Set Plot owner
|
||||
* @param plot
|
||||
* @param uuid
|
||||
*/
|
||||
public static void setOwner(final Plot plot, final UUID uuid) {
|
||||
runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement("UPDATE `plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ? ");
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setInt(2, plot.id.x);
|
||||
statement.setInt(3, plot.id.y);
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
} catch(SQLException e) {
|
||||
e.printStackTrace();
|
||||
Logger.add(LogLevel.DANGER, "Could not set owner for plot " + plot.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plot
|
||||
* @param plot
|
||||
*/
|
||||
public static void createPlot(Plot plot) {
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
stmt = connection.prepareStatement("INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) VALUES(?, ?, ?, ?)");
|
||||
stmt.setInt(1, plot.id.x);
|
||||
stmt.setInt(2, plot.id.y);
|
||||
stmt.setString(3, plot.owner.toString());
|
||||
stmt.setString(4, plot.world);
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
Logger.add(LogLevel.DANGER, "Failed to save plot " + plot.id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create tables
|
||||
* @throws SQLException
|
||||
*/
|
||||
public static void createTables() throws SQLException{
|
||||
Statement stmt = connection.createStatement();
|
||||
stmt.addBatch(
|
||||
"CREATE TABLE IF NOT EXISTS `plot` (" +
|
||||
"`id` int(11) NOT NULL AUTO_INCREMENT," +
|
||||
"`plot_id_x` int(11) NOT NULL," +
|
||||
"`plot_id_z` int(11) NOT NULL," +
|
||||
"`owner` varchar(45) NOT NULL," +
|
||||
"`world` varchar(45) NOT NULL," +
|
||||
"`timestamp` timestamp not null DEFAULT CURRENT_TIMESTAMP," +
|
||||
"PRIMARY KEY (`id`)" +
|
||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0");
|
||||
stmt.addBatch(
|
||||
"CREATE TABLE IF NOT EXISTS `plot_helpers` (" +
|
||||
"`plot_plot_id` int(11) NOT NULL," +
|
||||
"`user_uuid` varchar(40) NOT NULL" +
|
||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8"
|
||||
);
|
||||
stmt.addBatch(
|
||||
"CREATE TABLE IF NOT EXISTS `plot_denied` (" +
|
||||
"`plot_plot_id` int(11) NOT NULL," +
|
||||
"`user_uuid` varchar(40) NOT NULL" +
|
||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8"
|
||||
);
|
||||
stmt.addBatch(
|
||||
"CREATE TABLE IF NOT EXISTS `plot_settings` (" +
|
||||
" `plot_plot_id` INT(11) NOT NULL," +
|
||||
" `biome` VARCHAR(45) DEFAULT 'FOREST'," +
|
||||
" `rain` INT(1) DEFAULT 0," +
|
||||
" `custom_time` TINYINT(1) DEFAULT '0'," +
|
||||
" `time` INT(11) DEFAULT '8000'," +
|
||||
" `deny_entry` TINYINT(1) DEFAULT '0'," +
|
||||
" `alias` VARCHAR(50) DEFAULT NULL," +
|
||||
" `position` VARCHAR(50) NOT NULL DEFAULT 'DEFAULT'," +
|
||||
" PRIMARY KEY (`plot_plot_id`)," +
|
||||
" UNIQUE KEY `unique_alias` (`alias`)" +
|
||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8"
|
||||
);
|
||||
stmt.addBatch(
|
||||
"ALTER TABLE `plot_settings` ADD CONSTRAINT `plot_settings_ibfk_1` FOREIGN KEY (`plot_plot_id`) REFERENCES `plot` (`id`) ON DELETE CASCADE"
|
||||
);
|
||||
stmt.executeBatch();
|
||||
stmt.clearBatch();
|
||||
stmt.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a plot
|
||||
* @param plot
|
||||
*/
|
||||
public static void delete(final String world, final Plot plot) {
|
||||
PlotMain.removePlot(world,plot.id);
|
||||
runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PreparedStatement stmt = null;
|
||||
int id = getId(world,plot.id);
|
||||
try {
|
||||
stmt = connection.prepareStatement("DELETE FROM `plot_settings` WHERE `plot_plot_id` = ?");
|
||||
stmt.setInt(1, id);
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
stmt = connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ?");
|
||||
stmt.setInt(1, id);
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
stmt = connection.prepareStatement("DELETE FROM `plot` WHERE `id` = ?");
|
||||
stmt.setInt(1, id);
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
Logger.add(LogLevel.DANGER, "Failed to delete plot " + plot.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create plot settings
|
||||
* @param id
|
||||
* @param plot
|
||||
*/
|
||||
public static void createPlotSettings(final int id, final Plot plot) {
|
||||
runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
stmt = connection.prepareStatement("INSERT INTO `plot_settings`(`plot_plot_id`) VALUES(" +
|
||||
"?)");
|
||||
stmt.setInt(1, id);
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
} catch(SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot id
|
||||
* @param plot_id
|
||||
* @return
|
||||
*/
|
||||
public static int getId(String world, PlotId id2) {
|
||||
Statement stmt = null;
|
||||
try {
|
||||
stmt = connection.createStatement();
|
||||
ResultSet r = stmt.executeQuery("SELECT `id` FROM `plot` WHERE `plot_id_x` = '" + id2.x + "' AND `plot_id_z` = '" + id2.y + "' AND `world` = '" + world + "' ORDER BY `timestamp` ASC");
|
||||
int id = Integer.MAX_VALUE;
|
||||
while(r.next()) {
|
||||
id = r.getInt("id");
|
||||
}
|
||||
stmt.close();
|
||||
return id;
|
||||
} catch(SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static HashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
||||
HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<String, HashMap<PlotId, Plot>>();
|
||||
HashMap<String, World> worldMap = new HashMap<String, World>();
|
||||
Statement stmt = null;
|
||||
try {
|
||||
stmt = connection.createStatement();
|
||||
ResultSet r = stmt.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world` FROM `plot`");
|
||||
PlotId plot_id;
|
||||
int id;
|
||||
Plot p;
|
||||
World w;
|
||||
while (r.next()) {
|
||||
plot_id = new PlotId(r.getInt("plot_id_x"),r.getInt("plot_id_z"));
|
||||
id = r.getInt("id");
|
||||
String worldname = r.getString("world");
|
||||
// Quicker to get cache the UUID to the World than to convert each time.
|
||||
HashMap<String, Object> settings = getSettings(id);
|
||||
UUID owner = UUID.fromString(r.getString("owner"));
|
||||
Biome plotBiome = Biome.valueOf((String) settings.get("biome"));
|
||||
if(plotBiome == null) plotBiome = Biome.FOREST;
|
||||
ArrayList<UUID> helpers = plotHelpers(id);
|
||||
ArrayList<UUID> denied = plotDenied(id);
|
||||
//boolean changeTime = ((Short) settings.get("custom_time") == 0) ? false : true;
|
||||
long time = 8000l;
|
||||
//if(changeTime) {
|
||||
// time = Long.parseLong(settings.get("time").toString());
|
||||
//}
|
||||
//boolean rain = Integer.parseInt(settings.get("rain").toString()) == 1 ? true : false;
|
||||
boolean rain = false;
|
||||
String alias = (String) settings.get("alias");
|
||||
if(alias == null || alias.equalsIgnoreCase("NEW")) alias = "";
|
||||
PlotHomePosition position = null;
|
||||
for(PlotHomePosition plotHomePosition : PlotHomePosition.values())
|
||||
if(plotHomePosition.isMatching((String)settings.get("position"))) position = plotHomePosition;
|
||||
if(position == null) position = PlotHomePosition.DEFAULT;
|
||||
|
||||
p = new Plot(plot_id, owner, plotBiome, helpers, denied, /*changeTime*/ false, time, rain, alias, position, worldname);
|
||||
if (plots.containsKey(worldname)) {
|
||||
plots.get(worldname).put((plot_id), p);
|
||||
}
|
||||
else {
|
||||
HashMap<PlotId, Plot> map = new HashMap<PlotId, Plot>();
|
||||
map.put((plot_id), p);
|
||||
plots.put(worldname, map);
|
||||
}
|
||||
}
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
Logger.add(LogLevel.WARNING, "Failed to load plots.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return plots;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plot
|
||||
* @param rain
|
||||
*/
|
||||
public static void setWeather(final String world, final Plot plot, final boolean rain) {
|
||||
plot.settings.setRain(rain);
|
||||
runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
int weather = rain ? 1 : 0;
|
||||
PreparedStatement stmt = connection.prepareStatement("UPDATE `plot_settings` SET `rain` = ? WHERE `plot_plot_id` = ?");
|
||||
stmt.setInt(1, weather);
|
||||
stmt.setInt(2, getId(world, plot.id));
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch(SQLException e) {
|
||||
e.printStackTrace();
|
||||
Logger.add(LogLevel.WARNING, "Could not set weather for plot " + plot.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plot
|
||||
* @param alias
|
||||
*/
|
||||
public static void setAlias(final String world, final Plot plot, final String alias) {
|
||||
plot.settings.setAlias(alias);
|
||||
runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
stmt = connection.prepareStatement("UPDATE `plot_settings` SET `alias` = ? WHERE `plot_plot_id` = ?");
|
||||
stmt.setString(1, alias);
|
||||
stmt.setInt(2, getId(world, plot.id));
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
} catch(SQLException e) {
|
||||
Logger.add(LogLevel.WARNING, "Failed to set alias for plot " + plot.id);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param r
|
||||
*/
|
||||
private static void runTask(Runnable r) {
|
||||
PlotMain.getMain().getServer().getScheduler().runTaskAsynchronously(PlotMain.getMain(), r);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plot
|
||||
* @param position
|
||||
*/
|
||||
public static void setPosition(final String world,final Plot plot, final String position) {
|
||||
plot.settings.setPosition(PlotHomePosition.valueOf(position));
|
||||
runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
stmt = connection.prepareStatement("UPDATE `plot_settings` SET `position` = ? WHERE `plot_plot_id` = ?");
|
||||
stmt.setString(1, position);
|
||||
stmt.setInt(2, getId(world, plot.id));
|
||||
stmt.executeUpdate();
|
||||
stmt.close();
|
||||
} catch(SQLException e) {
|
||||
Logger.add(LogLevel.WARNING, "Failed to set position for plot " + plot.id);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static HashMap<String, Object> getSettings(int id) {
|
||||
HashMap<String, Object> h = new HashMap<String, Object>();
|
||||
Statement stmt = null;
|
||||
try {
|
||||
stmt = connection.createStatement();
|
||||
ResultSet r = stmt.executeQuery("SELECT * FROM `plot_settings` WHERE `plot_plot_id` = " + id);
|
||||
String var;
|
||||
Object val;
|
||||
while(r.next()) {
|
||||
var = "biome";
|
||||
val = r.getObject(var);
|
||||
h.put(var,val);
|
||||
var = "rain";
|
||||
val = r.getObject(var);
|
||||
h.put(var,val);
|
||||
var = "custom_time";
|
||||
val = r.getObject(var);
|
||||
h.put(var, val);
|
||||
var = "time";
|
||||
val = r.getObject(var);
|
||||
h.put(var,val);
|
||||
var = "deny_entry";
|
||||
val = r.getObject(var);
|
||||
h.put(var, (short) 0);
|
||||
var = "alias";
|
||||
val = r.getObject(var);
|
||||
h.put(var, val);
|
||||
var = "position";
|
||||
val = r.getObject(var);
|
||||
h.put(var, val);
|
||||
}
|
||||
stmt.close();;
|
||||
} catch(SQLException e) {
|
||||
Logger.add(LogLevel.WARNING, "Failed to load settings for plot: " + id);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static UUID everyone = UUID.fromString("1-1-3-3-7");
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private static ArrayList<UUID> plotDenied(int id) {
|
||||
ArrayList<UUID> l = new ArrayList<UUID>();
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
stmt = connection.prepareStatement("SELECT `user_uuid` FROM `plot_denied` WHERE `plot_plot_id` = ?");
|
||||
stmt.setInt(1, id);
|
||||
ResultSet r = stmt.executeQuery();
|
||||
UUID u;
|
||||
while(r.next()) {
|
||||
u = UUID.fromString(r.getString("user_uuid"));
|
||||
l.add(u);
|
||||
}
|
||||
stmt.close();
|
||||
} catch(Exception e) {
|
||||
Logger.add(LogLevel.DANGER, "Failed to load denied for plot: " + id);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private static ArrayList<UUID> plotHelpers(int id) {
|
||||
ArrayList<UUID> l = new ArrayList<UUID>();
|
||||
Statement stmt = null;
|
||||
try {
|
||||
stmt = connection.createStatement();
|
||||
ResultSet r = stmt.executeQuery("SELECT `user_uuid` FROM `plot_helpers` WHERE `plot_plot_id` = " + id);
|
||||
UUID u;
|
||||
while(r.next()) {
|
||||
u = UUID.fromString(r.getString("user_uuid"));
|
||||
l.add(u);
|
||||
}
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
Logger.add(LogLevel.WARNING, "Failed to load helpers for plot: " + id);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plot
|
||||
* @param player
|
||||
*/
|
||||
public static void removeHelper(final String world,final Plot plot, final OfflinePlayer player) {
|
||||
runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement("DELETE FROM `plot_helpers` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
||||
statement.setInt(1, getId(world, plot.id));
|
||||
statement.setString(2, player.getUniqueId().toString());
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
} catch(SQLException e) {
|
||||
e.printStackTrace();
|
||||
Logger.add(LogLevel.WARNING, "Failed to remove helper for plot " + plot.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plot
|
||||
* @param player
|
||||
*/
|
||||
public static void setHelper(final String world,final Plot plot, final OfflinePlayer player) {
|
||||
runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO `plot_helpers` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
||||
statement.setInt(1, getId(world, plot.id));
|
||||
statement.setString(2, player.getUniqueId().toString());
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
} catch(SQLException e) {
|
||||
Logger.add(LogLevel.WARNING, "Failed to set helper for plot " + plot.id);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plot
|
||||
* @param player
|
||||
*/
|
||||
public static void removeDenied(final String world, final Plot plot, final OfflinePlayer player) {
|
||||
runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement("DELETE FROM `plot_denied` WHERE `plot_plot_id` = ? AND `user_uuid` = ?");
|
||||
statement.setInt(1, getId(world, plot.id));
|
||||
statement.setString(2, player.getUniqueId().toString());
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
} catch(SQLException e) {
|
||||
e.printStackTrace();
|
||||
Logger.add(LogLevel.WARNING, "Failed to remove denied for plot " + plot.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plot
|
||||
* @param player
|
||||
*/
|
||||
public static void setDenied(final String world, final Plot plot, final OfflinePlayer player) {
|
||||
runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO `plot_denied` (`plot_plot_id`, `user_uuid`) VALUES(?,?)");
|
||||
statement.setInt(1, getId(world, plot.id));
|
||||
statement.setString(2, player.getUniqueId().toString());
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
} catch(SQLException e) {
|
||||
Logger.add(LogLevel.WARNING, "Failed to set denied for plot " + plot.id);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
package com.intellectualcrafters.plot.database;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Abstract Database class, serves as a base for any connection method (MySQL,
|
||||
* SQLite, etc.)
|
||||
*
|
||||
* @author -_Husky_-
|
||||
* @author tips48
|
||||
*/
|
||||
public abstract class Database {
|
||||
|
||||
/**
|
||||
* Plugin instance, use for plugin.getDataFolder()
|
||||
*/
|
||||
protected Plugin plugin;
|
||||
|
||||
/**
|
||||
* Creates a new Database
|
||||
*
|
||||
* @param plugin
|
||||
* Plugin instance
|
||||
*/
|
||||
protected Database(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a connection with the database
|
||||
*
|
||||
* @return Opened connection
|
||||
* @throws SQLException
|
||||
* if the connection can not be opened
|
||||
* @throws ClassNotFoundException
|
||||
* if the driver cannot be found
|
||||
*/
|
||||
public abstract Connection openConnection() throws SQLException,
|
||||
ClassNotFoundException;
|
||||
|
||||
/**
|
||||
* Checks if a connection is open with the database
|
||||
*
|
||||
* @return true if the connection is open
|
||||
* @throws SQLException
|
||||
* if the connection cannot be checked
|
||||
*/
|
||||
public abstract boolean checkConnection() throws SQLException;
|
||||
|
||||
/**
|
||||
* Gets the connection with the database
|
||||
*
|
||||
* @return Connection with the database, null if none
|
||||
*/
|
||||
public abstract Connection getConnection();
|
||||
|
||||
/**
|
||||
* Closes the connection with the database
|
||||
*
|
||||
* @return true if successful
|
||||
* @throws SQLException
|
||||
* if the connection cannot be closed
|
||||
*/
|
||||
public abstract boolean closeConnection() throws SQLException;
|
||||
|
||||
/**
|
||||
* Executes a SQL Query<br>
|
||||
*
|
||||
* If the connection is closed, it will be opened
|
||||
*
|
||||
* @param query
|
||||
* Query to be run
|
||||
* @return the results of the query
|
||||
* @throws SQLException
|
||||
* If the query cannot be executed
|
||||
* @throws ClassNotFoundException
|
||||
* If the driver cannot be found; see {@link #openConnection()}
|
||||
*/
|
||||
public abstract ResultSet querySQL(String query) throws SQLException,
|
||||
ClassNotFoundException;
|
||||
|
||||
/**
|
||||
* Executes an Update SQL Query<br>
|
||||
* See {@link java.sql.Statement#executeUpdate(String)}<br>
|
||||
* If the connection is closed, it will be opened
|
||||
*
|
||||
* @param query
|
||||
* Query to be run
|
||||
* @return Result Code, see {@link java.sql.Statement#executeUpdate(String)}
|
||||
* @throws SQLException
|
||||
* If the query cannot be executed
|
||||
* @throws ClassNotFoundException
|
||||
* If the driver cannot be found; see {@link #openConnection()}
|
||||
*/
|
||||
public abstract int updateSQL(String query) throws SQLException,
|
||||
ClassNotFoundException;
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
package com.intellectualcrafters.plot.database;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
/**
|
||||
* Connects to and uses a MySQL database
|
||||
*
|
||||
* @author -_Husky_-
|
||||
* @author tips48
|
||||
*/
|
||||
public class MySQL extends Database {
|
||||
private final String user;
|
||||
private final String database;
|
||||
private final String password;
|
||||
private final String port;
|
||||
private final String hostname;
|
||||
|
||||
private Connection connection;
|
||||
|
||||
/**
|
||||
* Creates a new MySQL instance
|
||||
*
|
||||
* @param plugin
|
||||
* Plugin instance
|
||||
* @param hostname
|
||||
* Name of the host
|
||||
* @param port
|
||||
* Port number
|
||||
* @param database
|
||||
* Database name
|
||||
* @param username
|
||||
* Username
|
||||
* @param password
|
||||
* Password
|
||||
*/
|
||||
public MySQL(Plugin plugin, String hostname, String port, String database,
|
||||
String username, String password) {
|
||||
super(plugin);
|
||||
this.hostname = hostname;
|
||||
this.port = port;
|
||||
this.database = database;
|
||||
this.user = username;
|
||||
this.password = password;
|
||||
this.connection = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection openConnection() throws SQLException,
|
||||
ClassNotFoundException {
|
||||
if (checkConnection()) {
|
||||
return connection;
|
||||
}
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
connection = DriverManager.getConnection("jdbc:mysql://"
|
||||
+ this.hostname + ":" + this.port + "/" + this.database,
|
||||
this.user, this.password);
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkConnection() throws SQLException {
|
||||
return connection != null && !connection.isClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean closeConnection() throws SQLException {
|
||||
if (connection == null) {
|
||||
return false;
|
||||
}
|
||||
connection.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet querySQL(String query) throws SQLException,
|
||||
ClassNotFoundException {
|
||||
if (checkConnection()) {
|
||||
openConnection();
|
||||
}
|
||||
|
||||
Statement statement = connection.createStatement();
|
||||
|
||||
ResultSet result = statement.executeQuery(query);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSQL(String query) throws SQLException,
|
||||
ClassNotFoundException {
|
||||
if (checkConnection()) {
|
||||
openConnection();
|
||||
}
|
||||
|
||||
Statement statement = connection.createStatement();
|
||||
|
||||
int result = statement.executeUpdate(query);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
package com.intellectualcrafters.plot.database;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotHomePosition;
|
||||
import com.intellectualcrafters.plot.PlotId;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.worldcretornica.plotme.PlayerList;
|
||||
import com.worldcretornica.plotme.Plot;
|
||||
import com.worldcretornica.plotme.PlotManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-17.
|
||||
*/
|
||||
public class PlotMeConverter {
|
||||
|
||||
private PlotMain plugin;
|
||||
|
||||
public PlotMeConverter(PlotMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void runAsync() throws Exception {
|
||||
final PrintStream stream = new PrintStream("converter_log.txt");
|
||||
|
||||
PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has started");
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (World world:Bukkit.getWorlds()) {
|
||||
HashMap<String, Plot> plots = PlotManager.getPlots(world);
|
||||
PlotMain.sendConsoleSenderMessage("Converting "+plots.size()+" plots for '"+world.toString()+"'...");
|
||||
for (Plot plot : plots.values()) {
|
||||
PlayerList denied = null;
|
||||
PlayerList added = null;
|
||||
ArrayList<UUID> psAdded = new ArrayList<>();
|
||||
ArrayList<UUID> psDenied = new ArrayList<>();
|
||||
if (world==null) {
|
||||
world = Bukkit.getWorld("world");
|
||||
}
|
||||
long eR3040bl230 = 22392948l;
|
||||
try {
|
||||
Field fAdded = plot.getClass().getField("added");
|
||||
Field fDenied = plot.getClass().getField("denied");
|
||||
fAdded.setAccessible(true);
|
||||
fDenied.setAccessible(true);
|
||||
added = (PlayerList) fAdded.get(plot);
|
||||
denied = (PlayerList) fDenied.get(plot);
|
||||
|
||||
for(Map.Entry<String, UUID> set : added.getAllPlayers().entrySet()) {
|
||||
if(set.getKey().equalsIgnoreCase("*") || set.getValue().toString().equalsIgnoreCase("*")) {
|
||||
psAdded.add(DBFunc.everyone);
|
||||
continue;
|
||||
}
|
||||
psAdded.add(set.getValue());
|
||||
}
|
||||
|
||||
for(Map.Entry<String, UUID> set : denied.getAllPlayers().entrySet()) {
|
||||
if(set.getKey().equalsIgnoreCase("*") || set.getValue().toString().equalsIgnoreCase("*")) {
|
||||
psDenied.add(DBFunc.everyone);
|
||||
continue;
|
||||
}
|
||||
psDenied.add(set.getValue());
|
||||
}
|
||||
} catch(NoSuchFieldException | IllegalAccessException e) {
|
||||
eR3040bl230 = 232000499888388747l;
|
||||
} finally {
|
||||
eR3040bl230 = 232999304998392004l;
|
||||
}
|
||||
stream.println(eR3040bl230);
|
||||
PlotId id = new PlotId(Integer.parseInt(plot.id.split(";")[0]),Integer.parseInt(plot.id.split(";")[1]));
|
||||
com.intellectualcrafters.plot.Plot pl = new com.intellectualcrafters.plot.Plot(
|
||||
id,
|
||||
plot.getOwnerId(),
|
||||
plot.getBiome(),
|
||||
psAdded,
|
||||
psDenied,
|
||||
false,
|
||||
8000l,
|
||||
false,
|
||||
"",
|
||||
PlotHomePosition.DEFAULT,
|
||||
world.getName()
|
||||
);
|
||||
DBFunc.createPlot(pl);
|
||||
DBFunc.createPlotSettings(DBFunc.getId(world.getName(),pl.id), pl);
|
||||
}
|
||||
}
|
||||
PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has finished");
|
||||
stream.close();
|
||||
Bukkit.getPluginManager().disablePlugin(plugin);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = PlayerClaimPlotEvent.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 15:21
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.events;
|
||||
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-09.
|
||||
*/
|
||||
public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable{
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
|
||||
private Plot plot;
|
||||
|
||||
public PlayerClaimPlotEvent(Player player, Plot plot) {
|
||||
super(player);
|
||||
this.plot = plot;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean b) {
|
||||
this.cancelled = b;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package com.intellectualcrafters.plot.events;
|
||||
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-16.
|
||||
*/
|
||||
public class PlayerEnterPlotEvent extends PlayerEvent {
|
||||
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
|
||||
private Plot plot;
|
||||
|
||||
public PlayerEnterPlotEvent(Player player, Plot plot) {
|
||||
super(player);
|
||||
this.plot = plot;
|
||||
}
|
||||
|
||||
public Plot getPlot() {
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
package com.intellectualcrafters.plot.events;
|
||||
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-16.
|
||||
*/
|
||||
public class PlayerLeavePlotEvent extends PlayerEvent {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
|
||||
private Plot plot;
|
||||
public PlayerLeavePlotEvent(Player player, Plot plot) {
|
||||
super(player);
|
||||
this.plot = plot;
|
||||
}
|
||||
|
||||
public Plot getPlot() {
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package com.intellectualcrafters.plot.events;
|
||||
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-16.
|
||||
*/
|
||||
public class PlayerPlotDeniedEvent extends Event {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
|
||||
private Plot plot;
|
||||
private Player initiator;
|
||||
private boolean added;
|
||||
private UUID player;
|
||||
|
||||
public PlayerPlotDeniedEvent(Player initiator, Plot plot, UUID player, boolean added) {
|
||||
this.initiator = initiator;
|
||||
this.plot = plot;
|
||||
this.added = added;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public boolean wasAdded() {
|
||||
return this.added;
|
||||
}
|
||||
|
||||
public UUID getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public Plot getPlot() {
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
public Player getInitiator() {
|
||||
return this.initiator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package com.intellectualcrafters.plot.events;
|
||||
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-16.
|
||||
*/
|
||||
public class PlayerPlotHelperEvent extends Event {
|
||||
private static HandlerList handlers = new HandlerList();
|
||||
|
||||
private Plot plot;
|
||||
private Player initiator;
|
||||
private boolean added;
|
||||
private UUID player;
|
||||
|
||||
public PlayerPlotHelperEvent(Player initiator, Plot plot, UUID player, boolean added) {
|
||||
this.initiator = initiator;
|
||||
this.plot = plot;
|
||||
this.added = added;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public boolean wasAdded() {
|
||||
return this.added;
|
||||
}
|
||||
|
||||
public UUID getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public Plot getPlot() {
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
public Player getInitiator() {
|
||||
return this.initiator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = PlayerTeleportToPlotEvent.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 14:57
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.events;
|
||||
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
|
||||
public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Location from;
|
||||
private Plot plot;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerTeleportToPlotEvent(Player player, Location from, Plot plot) {
|
||||
super(player);
|
||||
this.from = from;
|
||||
this.plot = plot;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Location getFrom() {
|
||||
return this.from;
|
||||
}
|
||||
|
||||
public Plot getPlot() {
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
@ -1,703 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) IntellectualCrafters - 2014.
|
||||
* You are not allowed to distribute and/or monetize any of our intellectual property.
|
||||
* IntellectualCrafters is not affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||
*
|
||||
* >> File = PlayerEvents.java
|
||||
* >> Generated by: Citymonstret at 2014-08-09 01:43
|
||||
*/
|
||||
|
||||
package com.intellectualcrafters.plot.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
|
||||
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Player Events involving plots
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class PlayerEvents implements Listener {
|
||||
|
||||
private String replaceColours(String string) {
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
}
|
||||
|
||||
private String getName(UUID uuid){
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
|
||||
if(player != null) {
|
||||
return player.getName();
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
public boolean enteredPlot(Location l1, Location l2) {
|
||||
return !isInPlot(l1) && isInPlot(l2);
|
||||
}
|
||||
|
||||
public boolean leftPlot(Location l1, Location l2){
|
||||
return isInPlot(l1) && !isInPlot(l2);
|
||||
}
|
||||
|
||||
private boolean isPlotWorld(Location l) { return PlotMain.isPlotWorld(l.getWorld());}
|
||||
private boolean isPlotWorld(World w) { return PlotMain.isPlotWorld(w);}
|
||||
|
||||
public static boolean isInPlot(Location loc) {
|
||||
return getCurrentPlot(loc) != null;
|
||||
}
|
||||
|
||||
public static Plot getCurrentPlot(Location loc) {
|
||||
PlotId id = PlayerFunctions.getPlot(loc);
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
World world = loc.getWorld();
|
||||
if (PlotMain.getPlots(world).containsKey(id)) {
|
||||
return PlotMain.getPlots(world).get(id);
|
||||
}
|
||||
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), loc.getWorld().getName());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
if (!event.getPlayer().hasPlayedBefore())
|
||||
event.getPlayer().saveData();
|
||||
textures(event.getPlayer());
|
||||
}
|
||||
|
||||
private void textures(Player p) {
|
||||
if(Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1 && isPlotWorld(p.getWorld()))
|
||||
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChangeWorld(PlayerChangedWorldEvent event) {
|
||||
if (isPlotWorld(event.getFrom()))
|
||||
event.getPlayer().setResourcePack("");
|
||||
else
|
||||
textures(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
if (from.getBlockX()!=to.getBlockX() || from.getBlockZ()!=to.getBlockZ()) {
|
||||
if (!isPlotWorld(player.getWorld()))
|
||||
return;
|
||||
if (enteredPlot(event.getFrom(), event.getTo())) {
|
||||
Plot plot = getCurrentPlot(event.getTo());
|
||||
if(plot.hasOwner()) {
|
||||
if(C.TITLE_ENTERED_PLOT.s().length() > 2) {
|
||||
String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", plot.getDisplayName());
|
||||
String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner));
|
||||
ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s());
|
||||
ChatColor sTitleSubColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s());
|
||||
Title title = new Title(sTitleMain, sTitleSub, 10, 20, 10);
|
||||
title.setTitleColor(sTitleMainColor);
|
||||
title.setSubtitleColor(sTitleSubColor);
|
||||
title.setTimingsToTicks();
|
||||
title.send(player);
|
||||
}
|
||||
{
|
||||
PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot);
|
||||
Bukkit.getPluginManager().callEvent(callEvent);
|
||||
}
|
||||
boolean admin = player.hasPermission("plots.admin");
|
||||
|
||||
PlayerFunctions.sendMessage(player, plot.settings.getJoinMessage());
|
||||
if (plot.deny_entry(player) && !admin) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (plot.settings.getRain())
|
||||
PlayerFunctions.togglePlotWeather(player, plot);
|
||||
if (plot.settings.getChangeTime())
|
||||
PlayerFunctions.togglePlotTime(player, plot);
|
||||
}
|
||||
} else if (leftPlot(event.getFrom(), event.getTo())) {
|
||||
Plot plot = getCurrentPlot(event.getFrom());
|
||||
{
|
||||
PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
|
||||
Bukkit.getPluginManager().callEvent(callEvent);
|
||||
}
|
||||
event.getPlayer().resetPlayerTime();
|
||||
event.getPlayer().resetPlayerWeather();
|
||||
PlayerFunctions.sendMessage(player, plot.settings.getLeaveMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
World world = event.getPlayer().getWorld();
|
||||
if (!isPlotWorld(world))
|
||||
return;
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
if (!plotworld.PLOT_CHAT)
|
||||
return;
|
||||
if (getCurrentPlot(event.getPlayer().getLocation()) == null)
|
||||
return;
|
||||
String message = event.getMessage();
|
||||
String format = C.PLOT_CHAT_FORMAT.s();
|
||||
String sender = event.getPlayer().getDisplayName();
|
||||
Plot plot = getCurrentPlot(event.getPlayer().getLocation());
|
||||
PlotId id = plot.id;
|
||||
Set<Player> recipients = event.getRecipients();
|
||||
recipients.clear();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (p.getLocation()
|
||||
.distanceSquared(event.getPlayer().getLocation()) <= Math
|
||||
.pow((double) plotworld.PLOT_WIDTH, 2d)) {
|
||||
if (getCurrentPlot(p.getLocation()) == plot) {
|
||||
recipients.add(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
format = format.replaceAll("%plot_id%", id.x+";"+id.y)
|
||||
.replaceAll("%sender%", sender).replaceAll("%msg%", message);
|
||||
format = ChatColor.translateAlternateColorCodes('&', format);
|
||||
event.setFormat(format);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void BlockDestroy(BlockBreakEvent event) {
|
||||
World world = event.getPlayer().getWorld();
|
||||
if (!isPlotWorld(world))
|
||||
return;
|
||||
if (event.getPlayer().hasPermission("plots.admin")) {
|
||||
return;
|
||||
}
|
||||
if (isInPlot(event.getBlock().getLocation())) {
|
||||
Plot plot = getCurrentPlot(event.getBlock().getLocation());
|
||||
if (!plot.hasRights(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (PlayerFunctions.getPlot(event.getBlock().getLocation()).equals(
|
||||
"road")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void BlockCreate(BlockPlaceEvent event) {
|
||||
World world = event.getPlayer().getWorld();
|
||||
if (!isPlotWorld(world))
|
||||
return;
|
||||
if (event.getPlayer().hasPermission("plots.admin")) {
|
||||
return;
|
||||
}
|
||||
if (isInPlot(event.getBlock().getLocation())) {
|
||||
Plot plot = getCurrentPlot(event.getBlockPlaced().getLocation());
|
||||
if (!plot.hasRights(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (PlayerFunctions.getPlot(event.getBlockPlaced().getLocation()).equals(
|
||||
"road")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBigBoom(EntityExplodeEvent event) {
|
||||
World world = event.getLocation().getWorld();
|
||||
if (!isPlotWorld(world))
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPeskyMobsChangeTheWorldLikeWTFEvent( // LOL!
|
||||
EntityChangeBlockEvent event) {
|
||||
World world = event.getBlock().getWorld();
|
||||
if (!isPlotWorld(world))
|
||||
return;
|
||||
Entity e = event.getEntity();
|
||||
if (!(e instanceof Player)) {
|
||||
if (!(e instanceof org.bukkit.entity.FallingBlock)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
Block b = event.getBlock();
|
||||
Player p = (Player) e;
|
||||
if(!isInPlot(b.getLocation())) {
|
||||
if(!p.hasPermission("plots.admin")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else{
|
||||
Plot plot = getCurrentPlot(b.getLocation());
|
||||
if(plot == null) {
|
||||
if(!p.hasPermission("plots.admin")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if(!plot.hasRights(p)) {
|
||||
if(!p.hasPermission("plots.admin")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityBlockForm(final EntityBlockFormEvent event) {
|
||||
World world = event.getBlock().getWorld();
|
||||
if (!isPlotWorld(world))
|
||||
return;
|
||||
if ((!(event.getEntity() instanceof Player)))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBS(final BlockSpreadEvent e) {
|
||||
Block b = e.getBlock();
|
||||
if(isPlotWorld(b.getLocation())) {
|
||||
if(!isInPlot(b.getLocation()))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBF(final BlockFormEvent e) {
|
||||
Block b = e.getBlock();
|
||||
if(isPlotWorld(b.getLocation())) {
|
||||
if(!isInPlot(b.getLocation()))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBD(final BlockDamageEvent e) {
|
||||
Block b = e.getBlock();
|
||||
if(isPlotWorld(b.getLocation())) {
|
||||
if(!isInPlot(b.getLocation()))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onFade(final BlockFadeEvent e) {
|
||||
Block b = e.getBlock();
|
||||
if(isPlotWorld(b.getLocation())) {
|
||||
if(!isInPlot(b.getLocation()))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onChange(final BlockFromToEvent e) {
|
||||
Block b = e.getToBlock();
|
||||
if(isPlotWorld(b.getLocation())) {
|
||||
if(!isInPlot(b.getLocation()))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onGrow(final BlockGrowEvent e) {
|
||||
Block b = e.getBlock();
|
||||
if(isPlotWorld(b.getLocation())) {
|
||||
if(!isInPlot(b.getLocation()))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockPistonExtend(final BlockPistonExtendEvent e) {
|
||||
if(isInPlot(e.getBlock().getLocation())) {
|
||||
|
||||
BlockFace face = e.getDirection();
|
||||
int modifier = e.getBlocks().size();
|
||||
Location l = e.getBlock().getLocation();
|
||||
{
|
||||
if(e.getDirection() == BlockFace.EAST) {
|
||||
l = e.getBlock().getLocation().subtract(modifier, 0, 0);
|
||||
} else if(e.getDirection() == BlockFace.NORTH) {
|
||||
l = e.getBlock().getLocation().subtract(0, 0, modifier);
|
||||
} else if(e.getDirection() == BlockFace.SOUTH) {
|
||||
l = e.getBlock().getLocation().add(0, 0, modifier);
|
||||
} else if(e.getDirection() == BlockFace.WEST) {
|
||||
l = e.getBlock().getLocation().add(modifier, 0, 0);
|
||||
}
|
||||
|
||||
if(!isInPlot(l)) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for(Block b : e.getBlocks()) {
|
||||
if(!isInPlot(b.getLocation())) return;
|
||||
{
|
||||
if(e.getDirection() == BlockFace.EAST) {
|
||||
if(!isInPlot(b.getLocation().subtract(1, 0, 0))) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else if(e.getDirection() == BlockFace.NORTH) {
|
||||
if(!isInPlot(b.getLocation().subtract(0, 0, 1))) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else if(e.getDirection() == BlockFace.SOUTH) {
|
||||
if(!isInPlot(b.getLocation().add(0, 0, 1))) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else if(e.getDirection() == BlockFace.WEST) {
|
||||
if(!isInPlot(b.getLocation().add(1, 0, 0))) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(final BlockPistonRetractEvent e) {
|
||||
Block b = e.getRetractLocation().getBlock();
|
||||
if(isPlotWorld(b.getLocation()) && e.getBlock().getType() == Material.PISTON_STICKY_BASE) {
|
||||
if(!isInPlot(b.getLocation()))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onStructureGrow(final StructureGrowEvent e) {
|
||||
List<BlockState> blocks = e.getBlocks();
|
||||
boolean f = false;
|
||||
for(int i = 0; i < blocks.size(); i++) {
|
||||
if(f || isPlotWorld(blocks.get(i).getLocation())) {
|
||||
f = true;
|
||||
if(!isInPlot(blocks.get(i).getLocation())) {
|
||||
e.getBlocks().remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
if (event.getClickedBlock() == null)
|
||||
return;
|
||||
World world = event.getPlayer().getWorld();
|
||||
if (!isPlotWorld(world))
|
||||
return;
|
||||
if (event.getPlayer().hasPermission("plots.admin")) {
|
||||
return;
|
||||
}
|
||||
if (isInPlot(event.getClickedBlock().getLocation())) {
|
||||
Plot plot = getCurrentPlot(event.getClickedBlock().getLocation());
|
||||
if (new ArrayList<>(Arrays.asList(new Material[]{
|
||||
Material.STONE_BUTTON,
|
||||
Material.WOOD_BUTTON,
|
||||
Material.LEVER,
|
||||
Material.STONE_PLATE,
|
||||
Material.WOOD_PLATE,
|
||||
Material.CHEST,
|
||||
Material.TRAPPED_CHEST,
|
||||
Material.TRAP_DOOR,
|
||||
Material.WOOD_DOOR,
|
||||
Material.WOODEN_DOOR,
|
||||
Material.DISPENSER,
|
||||
Material.DROPPER
|
||||
|
||||
})).contains(event.getClickedBlock().getType())) {
|
||||
return;
|
||||
}
|
||||
if (!plot.hasRights(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (PlayerFunctions.getPlot(event.getClickedBlock().getLocation())
|
||||
.equals("road")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void MobSpawn(CreatureSpawnEvent event) {
|
||||
World world = event.getLocation().getWorld();
|
||||
if (!isPlotWorld(world))
|
||||
return;
|
||||
if ((isInPlot(event.getLocation()) && event.getSpawnReason() != SpawnReason.SPAWNER_EGG)
|
||||
|| !isInPlot(event.getLocation()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBlockIgnite(final BlockIgniteEvent e) {
|
||||
if(e.getCause() == BlockIgniteEvent.IgniteCause.LIGHTNING) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Block b = e.getBlock();
|
||||
if(b != null) {
|
||||
if (e.getPlayer()!=null) {
|
||||
Player p = e.getPlayer();
|
||||
if(!isInPlot(b.getLocation())) {
|
||||
if (!p.hasPermission("plots.admin")) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
Plot plot = getCurrentPlot(b.getLocation());
|
||||
if(plot == null) {
|
||||
if (!p.hasPermission("plots.admin")) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else if(!plot.hasRights(p)) {
|
||||
if (!p.hasPermission("plots.admin")) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onTeleport(PlayerTeleportEvent event) {
|
||||
if(isPlotWorld(event.getTo())) {
|
||||
if(isInPlot(event.getTo())) {
|
||||
Plot plot = getCurrentPlot(event.getTo());
|
||||
if(plot.deny_entry(event.getPlayer())) {
|
||||
PlayerFunctions.sendMessage(event.getPlayer(), C.YOU_BE_DENIED);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
if(event.getTo().getBlockX() >= 29999999 || event.getTo().getBlockX() <= -29999999 ||
|
||||
event.getTo().getBlockZ() >= 29999999 ||event.getTo().getBlockZ() <= -29999999) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBucketEmpty(PlayerBucketEmptyEvent e) {
|
||||
if(!e.getPlayer().hasPermission("plots.admin")) {
|
||||
BlockFace bf = e.getBlockFace();
|
||||
Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock();
|
||||
if(isPlotWorld(b.getLocation())) {
|
||||
if(!isInPlot(b.getLocation())) {
|
||||
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
} else {
|
||||
Plot plot = getCurrentPlot(b.getLocation());
|
||||
if(plot == null) {
|
||||
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
} else if(!plot.hasRights(e.getPlayer())) {
|
||||
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if(event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands"))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onBucketFill(PlayerBucketFillEvent e) {
|
||||
if(!e.getPlayer().hasPermission("plots.admin")) {
|
||||
Block b = e.getBlockClicked();
|
||||
if(isPlotWorld(b.getLocation())) {
|
||||
if(!isInPlot(b.getLocation())) {
|
||||
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
} else {
|
||||
Plot plot = getCurrentPlot(b.getLocation());
|
||||
if(plot == null) {
|
||||
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
} else if(!plot.hasRights(e.getPlayer())) {
|
||||
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onHangingPlace(final HangingPlaceEvent e) {
|
||||
Block b = e.getBlock();
|
||||
if(isPlotWorld(b.getLocation())) {
|
||||
Player p = e.getPlayer();
|
||||
if(isInPlot(b.getLocation())) {
|
||||
if (!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
Plot plot = getCurrentPlot(b.getLocation());
|
||||
if(plot == null) {
|
||||
if (!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else if(!plot.hasRights(p)) {
|
||||
if (!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onHangingBreakByEntity(final HangingBreakByEntityEvent e) {
|
||||
Entity r = e.getRemover();
|
||||
if(r instanceof Player) {
|
||||
Player p = (Player) r;
|
||||
Location l = e.getEntity().getLocation();
|
||||
if (isPlotWorld(l)) {
|
||||
if (!isInPlot(l)) {
|
||||
if (!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
Plot plot = getCurrentPlot(l);
|
||||
if (plot == null) {
|
||||
if (!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else if (!plot.hasRights(p)) {
|
||||
if (!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerInteractEntity(final PlayerInteractEntityEvent e) {
|
||||
Location l = e.getRightClicked().getLocation();
|
||||
if(isPlotWorld(l)) {
|
||||
Player p = e.getPlayer();
|
||||
if(!isInPlot(l)) {
|
||||
if(!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
Plot plot = getCurrentPlot(l);
|
||||
if(plot == null) {
|
||||
if(!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else if(!plot.hasRights(p)) {
|
||||
if(!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) {
|
||||
Location l = e.getEntity().getLocation();
|
||||
Entity d = e.getDamager();
|
||||
if(isPlotWorld(l)) {
|
||||
if(d instanceof Player) {
|
||||
Player p = (Player) d;
|
||||
if(!isInPlot(l)) {
|
||||
if(!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
Plot plot = getCurrentPlot(l);
|
||||
if(plot == null) {
|
||||
if(!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else if(!plot.hasRights(p)) {
|
||||
if(!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerEggThrow(final PlayerEggThrowEvent e) {
|
||||
Location l = e.getEgg().getLocation();
|
||||
if(isPlotWorld(l)) {
|
||||
Player p = e.getPlayer();
|
||||
if(!isInPlot(l)) {
|
||||
if(!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setHatching(false);
|
||||
}
|
||||
} else {
|
||||
Plot plot = getCurrentPlot(l);
|
||||
if(plot == null) {
|
||||
if(!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setHatching(false);
|
||||
}
|
||||
} else if(!plot.hasRights(p)) {
|
||||
if(!p.hasPermission("plots.admin")) {
|
||||
PlayerFunctions.sendMessage(p, C.NO_PERMISSION);
|
||||
e.setHatching(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
package com.intellectualcrafters.plot.listeners;
|
||||
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Citymonstret
|
||||
*
|
||||
*/
|
||||
public class WorldEditListener implements Listener{
|
||||
|
||||
private boolean isPlotWorld(Location l) {
|
||||
return (PlotMain.isPlotWorld(l.getWorld()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerMove(final PlayerMoveEvent e){
|
||||
if(e.getPlayer().hasPermission("plots.worldedit.bypass")) return;
|
||||
Location f = e.getFrom();
|
||||
Location t = e.getTo();
|
||||
boolean cm = false;
|
||||
Player p = e.getPlayer();
|
||||
if(t == null)
|
||||
PWE.removeMask(p);
|
||||
else {
|
||||
if(f != null) {
|
||||
if(!f.getWorld().getName().equalsIgnoreCase(t.getWorld().getName()))
|
||||
cm = true;
|
||||
else if(f.getBlockX() != t.getBlockX() || f.getBlockZ() != t.getBlockZ()) {
|
||||
PlotId idF = PlayerFunctions.getPlot(f);
|
||||
PlotId idT = PlayerFunctions.getPlot(t);
|
||||
if(!(idF==idT))
|
||||
cm = true;
|
||||
}
|
||||
}
|
||||
if(cm) {
|
||||
if(isPlotWorld(t)) {
|
||||
PWE.setMask(p,p.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerJoin(final PlayerJoinEvent e) {
|
||||
if(e.getPlayer().hasPermission("plots.worldedit.bypass")) return;
|
||||
Player p = e.getPlayer();
|
||||
if(isPlotWorld(p.getLocation()))
|
||||
PWE.setMask(p,p.getLocation());
|
||||
else
|
||||
PWE.removeMask(p);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onTeleport(final PlayerTeleportEvent e) {
|
||||
if(e.getPlayer().hasPermission("plots.worldedit.bypass")) return;
|
||||
Player p = e.getPlayer();
|
||||
Location f = e.getFrom(), t = e.getTo();
|
||||
|
||||
if(t == null)
|
||||
PWE.removeMask(p);
|
||||
else {
|
||||
if(f != null && isPlotWorld(f) && !isPlotWorld(t))
|
||||
PWE.removeMask(p);
|
||||
else if(isPlotWorld(t))
|
||||
PWE.setMask(p,p.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPortal(PlayerPortalEvent e) {
|
||||
if(e.getPlayer().hasPermission("plots.worldedit.bypass")) return;
|
||||
Player p = e.getPlayer();
|
||||
Location f = e.getFrom(), t = e.getTo();
|
||||
if(t == null)
|
||||
PWE.removeMask(p);
|
||||
else {
|
||||
if(f != null && isPlotWorld(f) && !isPlotWorld(t))
|
||||
PWE.removeMask(p);
|
||||
else if(isPlotWorld(t))
|
||||
PWE.setMask(p,p.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
|
||||
if(e.getPlayer().hasPermission("plots.worldedit.bypass")) return;
|
||||
Player p = e.getPlayer();
|
||||
if(isPlotWorld(p.getLocation())) {
|
||||
String msg = e.getMessage().toLowerCase();
|
||||
if(msg.startsWith("//gmask") || msg.startsWith("/gmask") || msg.startsWith("/worldedit:gmask") || msg.startsWith("/worldedit:/gmask"))
|
||||
e.setCancelled(true);
|
||||
else if(msg.startsWith("/up") || msg.startsWith("//up") || msg.startsWith("/worldedit:up") || msg.startsWith("/worldedit:/up")) {
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(p);
|
||||
if(p == null || !plot.hasRights(p))
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if(!p.hasPermission("plots.admin") && isPlotWorld(p.getLocation())) {
|
||||
if((e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_BLOCK) && p.getItemInHand() != null && p.getItemInHand().getType() != Material.AIR) {
|
||||
Block b = e.getClickedBlock();
|
||||
Plot plot = PlotHelper.getCurrentPlot(b.getLocation());
|
||||
if(plot != null && plot.hasRights(p))
|
||||
PWE.setMask(p, b.getLocation());
|
||||
else
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package com.intellectualcrafters.plot.uuid;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author
|
||||
*
|
||||
*/
|
||||
public class NameFetcher implements Callable<Map<UUID, String>> {
|
||||
private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
||||
private final JSONParser jsonParser = new JSONParser();
|
||||
private final List<UUID> uuids;
|
||||
public NameFetcher(List<UUID> uuids) {
|
||||
this.uuids = ImmutableList.copyOf(uuids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, String> call() throws Exception {
|
||||
Map<UUID, String> uuidStringMap = new HashMap<UUID, String>();
|
||||
for (UUID uuid: uuids) {
|
||||
if(uuidStringMap.containsKey(uuid)) continue;
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(PROFILE_URL+uuid.toString().replace("-", "")).openConnection();
|
||||
JSONObject response = (JSONObject) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
||||
String name = (String) response.get("name");
|
||||
if (name == null) {
|
||||
continue;
|
||||
}
|
||||
String cause = (String) response.get("cause");
|
||||
String errorMessage = (String) response.get("errorMessage");
|
||||
if (cause != null && cause.length() > 0) {
|
||||
throw new IllegalStateException(errorMessage);
|
||||
}
|
||||
uuidStringMap.put(uuid, name);
|
||||
}
|
||||
return uuidStringMap;
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
package com.intellectualcrafters.plot.uuid;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* @author
|
||||
*/
|
||||
public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||
private static final double PROFILES_PER_REQUEST = 100;
|
||||
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
|
||||
private final JSONParser jsonParser = new JSONParser();
|
||||
private final List<String> names;
|
||||
private final boolean rateLimiting;
|
||||
|
||||
public UUIDFetcher(List<String> names, boolean rateLimiting) {
|
||||
this.names = ImmutableList.copyOf(names);
|
||||
this.rateLimiting = rateLimiting;
|
||||
}
|
||||
|
||||
public UUIDFetcher(List<String> names) {
|
||||
this(names, true);
|
||||
}
|
||||
|
||||
public Map<String, UUID> call() throws Exception {
|
||||
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
|
||||
for (int i = 0; i < requests; i++) {
|
||||
HttpURLConnection connection = createConnection();
|
||||
String body = JSONArray.toJSONString(names.subList(i * 100, Math.min((i + 1) * 100, names.size())));
|
||||
writeBody(connection, body);
|
||||
JSONArray array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
||||
for (Object profile : array) {
|
||||
JSONObject jsonProfile = (JSONObject) profile;
|
||||
String id = (String) jsonProfile.get("id");
|
||||
String name = (String) jsonProfile.get("name");
|
||||
UUID uuid = UUIDFetcher.getUUID(id);
|
||||
uuidMap.put(name, uuid);
|
||||
}
|
||||
if (rateLimiting && i != requests - 1) {
|
||||
Thread.sleep(100L);
|
||||
}
|
||||
}
|
||||
return uuidMap;
|
||||
}
|
||||
|
||||
private static void writeBody(HttpURLConnection connection, String body) throws Exception {
|
||||
OutputStream stream = connection.getOutputStream();
|
||||
stream.write(body.getBytes());
|
||||
stream.flush();
|
||||
stream.close();
|
||||
}
|
||||
|
||||
private static HttpURLConnection createConnection() throws Exception {
|
||||
URL url = new URL(PROFILE_URL);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setUseCaches(false);
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
return connection;
|
||||
}
|
||||
|
||||
public static UUID getUUID(String id) {
|
||||
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" +id.substring(20, 32));
|
||||
}
|
||||
|
||||
public static byte[] toBytes(UUID uuid) {
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
|
||||
byteBuffer.putLong(uuid.getMostSignificantBits());
|
||||
byteBuffer.putLong(uuid.getLeastSignificantBits());
|
||||
return byteBuffer.array();
|
||||
}
|
||||
|
||||
public static UUID fromBytes(byte[] array) {
|
||||
if (array.length != 16) {
|
||||
throw new IllegalArgumentException("Illegal byte array length: " + array.length);
|
||||
}
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(array);
|
||||
long mostSignificant = byteBuffer.getLong();
|
||||
long leastSignificant = byteBuffer.getLong();
|
||||
return new UUID(mostSignificant, leastSignificant);
|
||||
}
|
||||
|
||||
public static UUID getUUIDOf(String name) throws Exception {
|
||||
return new UUIDFetcher(Arrays.asList(name)).call().get(name);
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-05.
|
||||
*/
|
||||
package com.intellectualcrafters.plot.uuid;
|
@ -1,104 +0,0 @@
|
||||
package com.intellectualsites.web;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.simpleframework.http.Path;
|
||||
import org.simpleframework.http.Query;
|
||||
import org.simpleframework.http.Request;
|
||||
import org.simpleframework.http.Response;
|
||||
import org.simpleframework.http.core.Container;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-09-20.
|
||||
*/
|
||||
public class IndexHandler implements Container {
|
||||
|
||||
private JavaPlugin plugin;
|
||||
private String title;
|
||||
|
||||
public IndexHandler(JavaPlugin plugin, String title) {
|
||||
this.plugin = plugin;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void handle(Request request, Response response) {
|
||||
try {
|
||||
PrintStream body;
|
||||
long time;
|
||||
Query query;
|
||||
Path path;
|
||||
int page;
|
||||
String coverage;
|
||||
|
||||
body = response.getPrintStream();
|
||||
time = System.currentTimeMillis();
|
||||
query = request.getQuery();
|
||||
path = request.getPath();
|
||||
|
||||
if((page = request.getInteger("page")) < 0) {
|
||||
page = 0;
|
||||
}
|
||||
if((coverage = request.getTarget()) == null || coverage.equals("/")) {
|
||||
coverage = "index";
|
||||
}
|
||||
|
||||
coverage = coverage.toLowerCase();
|
||||
|
||||
List<String> list = new ArrayList<>(
|
||||
Arrays.asList(new String[] {
|
||||
"install",
|
||||
"index",
|
||||
"stylesheet"
|
||||
})
|
||||
);
|
||||
|
||||
if(!list.contains(coverage)) {
|
||||
coverage = "index";
|
||||
}
|
||||
|
||||
if(coverage.equals("stylesheet")) {
|
||||
response.setValue("Content-Type", "text/css");
|
||||
response.setValue("Server", "PlotWeb/1.0 (Simple 5.0)");
|
||||
response.setDate("Date", time);
|
||||
response.setDate("Last-Modified", time);
|
||||
|
||||
ResourceHandler stylesheet = new ResourceHandler("stylesheet", ResourceHandler.FileType.CSS, plugin.getDataFolder());
|
||||
|
||||
String stylesheetHTML = stylesheet.getHTML();
|
||||
|
||||
stylesheet.done();
|
||||
|
||||
body.print(stylesheetHTML);
|
||||
} else {
|
||||
response.setValue("Content-Type", "html");
|
||||
response.setValue("Server", "PlotWeb/1.0 (Simple 5.0)");
|
||||
response.setDate("Date", time);
|
||||
response.setDate("Last-Modified", time);
|
||||
|
||||
ResourceHandler header = new ResourceHandler("header", ResourceHandler.FileType.HTML, plugin.getDataFolder());
|
||||
ResourceHandler footer = new ResourceHandler("footer", ResourceHandler.FileType.HTML, plugin.getDataFolder());
|
||||
ResourceHandler cPage = new ResourceHandler(coverage, ResourceHandler.FileType.HTML, plugin.getDataFolder());
|
||||
|
||||
String headerHTML = header.getHTML().replace("@title", title);
|
||||
String footerHTML = footer.getHTML();
|
||||
String cPageHTML = cPage.getHTML();
|
||||
|
||||
header.done();
|
||||
footer.done();
|
||||
cPage.done();
|
||||
|
||||
body.print(headerHTML);
|
||||
body.print(cPageHTML);
|
||||
body.print(footerHTML);
|
||||
}
|
||||
body.close();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package com.intellectualsites.web;
|
||||
|
||||
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.simpleframework.http.core.Container;
|
||||
import org.simpleframework.http.core.ContainerServer;
|
||||
import org.simpleframework.transport.Server;
|
||||
import org.simpleframework.transport.connect.Connection;
|
||||
import org.simpleframework.transport.connect.SocketConnection;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-09-20.
|
||||
*/
|
||||
public class PlotWeb {
|
||||
|
||||
public static PlotWeb PLOTWEB;
|
||||
|
||||
private String title;
|
||||
private int port;
|
||||
private Server server;
|
||||
private Connection connection;
|
||||
private Container container;
|
||||
private SocketAddress address;
|
||||
|
||||
public PlotWeb(String title, int port) {
|
||||
this.title = title;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public void start() throws Exception {
|
||||
container = new IndexHandler(JavaPlugin.getPlugin(PlotMain.class), title);
|
||||
server = new ContainerServer(container);
|
||||
connection = new SocketConnection(server);
|
||||
address = new InetSocketAddress(port);
|
||||
|
||||
connection.connect(address);
|
||||
PLOTWEB = this;
|
||||
}
|
||||
|
||||
public void stop() throws Exception {
|
||||
connection.close();
|
||||
PLOTWEB = null;
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
package com.intellectualsites.web;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-09-20.
|
||||
*/
|
||||
public class ResourceHandler {
|
||||
|
||||
private String filePath;
|
||||
private File file;
|
||||
private FileType fileType;
|
||||
private File folder;
|
||||
private BufferedReader reader;
|
||||
|
||||
public ResourceHandler(String filePath, FileType fileType, File folder) throws Exception {
|
||||
this.filePath = filePath;
|
||||
this.fileType = fileType;
|
||||
this.folder = folder;
|
||||
if(fileType == FileType.CSS) {
|
||||
file = new File(folder.toPath().toString() + File.separator + "web" + File.separator + "css" + File.separator + filePath + "." + fileType.toString());
|
||||
} else {
|
||||
file = new File(folder.toPath().toString() + File.separator + "web" + File.separator + filePath + "." + fileType.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public String getHTML() throws Exception {
|
||||
StringBuilder html = new StringBuilder();
|
||||
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
|
||||
String line = "";
|
||||
while((line = reader.readLine()) != null) {
|
||||
html.append(line);
|
||||
}
|
||||
return html.toString();
|
||||
}
|
||||
|
||||
public void done() throws Exception {
|
||||
reader.close();
|
||||
}
|
||||
|
||||
public static enum FileType {
|
||||
CSS("css"),
|
||||
HTML("html"),
|
||||
JS("js");
|
||||
|
||||
private String ext;
|
||||
FileType(String ext) {
|
||||
this.ext = ext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.ext;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.intellectualsites.web;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-09-20.
|
||||
*/
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
new PlotWeb("Test", 9000).start();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user