December 26, 2024, 07:12:04 am

Author Topic: New protection system - Gonna try and code it  (Read 7188 times)

0 Members and 1 Guest are viewing this topic.

Chief149

  • Hero Member
  • **
  • Posts: 646
  • Oppan Gangnam Style
    • View Profile
New protection system - Gonna try and code it
« on: August 02, 2012, 02:31:14 am »
Ok so I previously made a suggestion for a new protection system. With the system you purchase 2 redstone ores for very cheap, and then you place them to form a cube just like when world edit is used and the user selects point 1 and point 2. Then the user has the option to buy the protection for 50 cents per block or not. I looked into the precious stones plugin, and I am just having too hard of a time understanding the dude's style of programming. Therefore I will make an attempt at making my idea a reality, but I'm going to need a few tidbits of information.

First off, while flatfiles are easier to read/write, they are also noobish for a programmer to work with, and it doesn't take much for them to get messed up. Therefore I need to know what type of database this server uses. I am assuming it's a basic SQL server, but I just want to make sure. Until then I guess I could code everything other than the storage system.



Best griefer name ^



optical

  • Administrator
  • Champion Member
  • *****
  • Posts: 1844
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #1 on: August 02, 2012, 06:25:26 am »
Yes, MySQL. Use the abstraction layer provided by Preciousstones

Chief149

  • Hero Member
  • **
  • Posts: 646
  • Oppan Gangnam Style
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #2 on: August 02, 2012, 03:24:10 pm »
Yeah, I did see the abstraction layer in the project file which should be of help since I don't know SQL.

Thanks dude, Ill see what I can do with this, and hopefully I can get it to work!



Best griefer name ^



Chief149

  • Hero Member
  • **
  • Posts: 646
  • Oppan Gangnam Style
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #3 on: August 04, 2012, 05:40:30 pm »
Sorry for the double post, but I think I have to bump this thread in order to get a reply, but does the area protect plugin on this server have an API I can use? If so I could just have my plugin take advantage of the Area Protect api by protecting areas with the boundries of the two placed redstone ore blocks.



Best griefer name ^



cschurz

  • Hero Member
  • **
  • Posts: 545
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #4 on: August 04, 2012, 09:42:45 pm »
i've never seen any of your code, despite seeing claims that you know how to program. i'm a bit skeptical, so let's just do a quick test...

you wish to build a system that protects a cube given two input coordinates (the redstone ores placed in the opposite corners of the desired cube)

write me some code to print out each coordinate that should be protected given a set of input coordinates in this format:

input:
Code: [Select]
1 1 1 2 2 2

where 1 1 1 is the x,y,z coordinate of the first redstone block and 2 2 2 is the x,y,z coordinate of the second redstone block.

this would be the output for the line "1 1 1 2 2 2"
output:
Code: [Select]
1 1 1
1 1 2
1 2 1
1 2 2
2 1 1
2 1 2
2 2 1
2 2 2

i don't care what order the output is in, as long as it is complete.

no time limit, no stress, just show me that you can at least write some code.

Chief149

  • Hero Member
  • **
  • Posts: 646
  • Oppan Gangnam Style
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #5 on: August 04, 2012, 09:48:50 pm »
so you give me two coordinates meaning I must simply develope a "cube" of coordinates and print all of those coordinates out?


Alright. Well I am on my laptop which is a shitty pc for developement, but this is simple even to code on the laptop.



EDIT: This would normally take 15 to 20 minutes to code, but I'm gonna spice it up with a GUI, and at the same time I am out of town (hence the reason Im on my laptop instead of my gaming rig, and I am going to be visiting relatives and going to the lake tomorrow. In other words I might not have much of a chance to code until tomorrow afternoon when I get back from the lake. I know me giving you this delay can be suspicious, but I can guaruntee you I know how to code. It's just timing in this case.
« Last Edit: August 04, 2012, 10:02:30 pm by Chief149 »



Best griefer name ^



cschurz

  • Hero Member
  • **
  • Posts: 545
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #6 on: August 04, 2012, 10:25:03 pm »
no gui, please :| just a simple problem solving challenge to show that you can at least make a working program,

take your time, no excuses needed.

Chief149

  • Hero Member
  • **
  • Posts: 646
  • Oppan Gangnam Style
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #7 on: August 05, 2012, 04:06:10 am »
lol I already coded the gui. I didn't really put too much detail into it though.


Do you want to be able to put the xyz for points one and two onto a single line, or put the X, Y, and Z values for both coordinates in seperately?



Best griefer name ^



cschurz

  • Hero Member
  • **
  • Posts: 545
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #8 on: August 05, 2012, 12:03:31 pm »

Chief149

  • Hero Member
  • **
  • Posts: 646
  • Oppan Gangnam Style
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #9 on: August 06, 2012, 03:46:36 am »
Sorry about it taking so long. LOL big mistake by me, I spent an hour trying to figure out why in.split("\\s") wasn't properly splitting the input string "in" only to find out that the whole problem was because I was getting user input using scan.next(); instead of scan.nextLine();


Anyways here is the source file:
<temporarily redacted>

Tested it with a couple coordinates and I think it works. It gives the correct results for your sample coordinates, and it did with a couple tests I did so I think we're good.
« Last Edit: August 07, 2012, 04:59:52 am by cschurz »



Best griefer name ^



cschurz

  • Hero Member
  • **
  • Posts: 545
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #10 on: August 06, 2012, 05:05:57 am »
yep, you did the job.

but with spaghetti code like that... you are definitely contributing to the stereotype of "bad minecraft programmer" :)

this was my code, if you're interested :\

Code: [Select]
<temporarily redacted>
« Last Edit: August 07, 2012, 04:59:36 am by cschurz »

optical

  • Administrator
  • Champion Member
  • *****
  • Posts: 1844
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #11 on: August 06, 2012, 05:23:04 am »
Where is this GUI?

Chief149

  • Hero Member
  • **
  • Posts: 646
  • Oppan Gangnam Style
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #12 on: August 06, 2012, 01:07:50 pm »
Where is this GUI?

Also I wasn't really paying attention to how neat the code was. When I write code I do write in spaghetti code (such as with school projects), but then I neaten it up, or at least I do for larger projects. If you want to see a neater version of the code I can do a quick edit once I get home (flying home today).

Also, Optical he said no gui so I didn't include that. I still have the code so I'd just have to copy and paste a few lines from the code I uploaded onto the code for the gui.

Anyways when I get home I'm also going to learn some more with the bukkit api, and I think your area protection plugin has an API as well. If that's the case my plugin could simply use the area protection plugin for making/deleting the actual protected areas, but my plugin would simply set positions one and two using redstone ore placements, and not set the protected area until the player uses the command to make payment for the area.
« Last Edit: August 06, 2012, 01:12:45 pm by Chief149 »



Best griefer name ^



Uryiel

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #13 on: August 06, 2012, 02:17:51 pm »
goodluck bro!! ;D ;D

optical

  • Administrator
  • Champion Member
  • *****
  • Posts: 1844
    • View Profile
Re: New protection system - Gonna try and code it
« Reply #14 on: August 07, 2012, 12:55:31 am »
Both WorldGuard and PreciousStones have API's, either one would work